From 73ee5e2ff27395e219c379e47298aadda6778ef9 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 9 Jul 2026 12:06:00 +0000 Subject: [PATCH 1/5] feat(core-backend): spike Kubb codegen with a @metamask/superstruct plugin Adds a Kubb-based code generation pipeline to @metamask/core-backend, spiked against the Price API: - codegen/kubb-plugin-superstruct: a Kubb plugin that generates @metamask/superstruct structs from an OpenAPI document - codegen/kubb-plugin-query-core: a Kubb plugin that generates TanStack query-core bindings (query keys, query options, fetchers) that validate responses with the generated structs - codegen/openapi/price-api.json: curated Price API OpenAPI 3.1 document enriched with response schemas - src/generated/price-api: generated types (plugin-ts), structs, faker mocks (plugin-faker), MSW handlers (plugin-msw) and query bindings - new subpath exports: @metamask/core-backend/price-api and @metamask/core-backend/mocks - yarn codegen script wired into the package build step Co-authored-by: Prithpal Sooriya --- eslint.config.mjs | 9 + knip.config.ts | 5 + .../codegen/annotate-msw-handlers.mjs | 59 + .../generators/queryCoreGenerator.ts | 333 ++++ .../codegen/kubb-plugin-query-core/index.ts | 3 + .../codegen/kubb-plugin-query-core/plugin.ts | 108 ++ .../codegen/kubb-plugin-query-core/types.ts | 85 + .../generators/superstructGenerator.ts | 203 +++ .../codegen/kubb-plugin-superstruct/index.ts | 5 + .../codegen/kubb-plugin-superstruct/parser.ts | 346 +++++ .../codegen/kubb-plugin-superstruct/plugin.ts | 150 ++ .../codegen/kubb-plugin-superstruct/types.ts | 86 + packages/core-backend/codegen/kubb.config.ts | 100 ++ .../codegen/openapi/price-api.json | 948 +++++++++++ packages/core-backend/codegen/tsconfig.json | 21 + packages/core-backend/codegen/utils/casing.ts | 45 + packages/core-backend/jest.config.js | 4 + packages/core-backend/package.json | 46 +- .../src/api/prices/query-client.test.ts | 229 +++ .../src/api/prices/query-client.ts | 46 + .../core-backend/src/api/query-runtime.ts | 45 + .../mocks/createCoinGeckoSpotPrice.ts | 18 + .../mocks/createCoinGeckoSpotPrices.ts | 19 + .../price-api/mocks/createExchangeRateInfo.ts | 18 + .../price-api/mocks/createExchangeRates.ts | 18 + .../mocks/createGetV1ExchangeRates.ts | 29 + .../mocks/createGetV1FiatExchangeRates.ts | 21 + .../mocks/createGetV1HistoricalPrices.ts | 35 + .../mocks/createGetV1SpotPriceByCoinId.ts | 35 + .../mocks/createGetV1SpotPricesByCoinIds.ts | 27 + .../mocks/createGetV1SupportedNetworks.ts | 21 + .../price-api/mocks/createGetV2SpotPrices.ts | 35 + .../mocks/createGetV2SupportedNetworks.ts | 21 + .../price-api/mocks/createGetV2TopTokens.ts | 38 + .../mocks/createGetV3HistoricalPrices.ts | 35 + .../price-api/mocks/createGetV3SpotPrices.ts | 27 + .../price-api/mocks/createHistoricalPrices.ts | 16 + .../price-api/mocks/createMarketData.ts | 18 + .../mocks/createMarketDataSpotPrices.ts | 19 + .../price-api/mocks/createPricePoint.ts | 15 + .../mocks/createSupportedNetworks.ts | 18 + .../price-api/mocks/createTopToken.ts | 18 + .../mocks/createV3HistoricalPrices.ts | 16 + .../price-api/mocks/createV3SpotPrice.ts | 18 + .../price-api/mocks/createV3SpotPrices.ts | 19 + .../price-api/mocks/createVsCurrency.ts | 15 + .../src/generated/price-api/mocks/index.ts | 25 + .../msw/getV1ExchangeRatesHandler.ts | 34 + .../msw/getV1FiatExchangeRatesHandler.ts | 34 + .../msw/getV1HistoricalPricesHandler.ts | 34 + .../msw/getV1SpotPriceByCoinIdHandler.ts | 34 + .../msw/getV1SpotPricesByCoinIdsHandler.ts | 34 + .../msw/getV1SupportedNetworksHandler.ts | 34 + .../price-api/msw/getV2SpotPricesHandler.ts | 34 + .../msw/getV2SupportedNetworksHandler.ts | 34 + .../price-api/msw/getV2TopTokensHandler.ts | 34 + .../msw/getV3HistoricalPricesHandler.ts | 34 + .../price-api/msw/getV3SpotPricesHandler.ts | 34 + .../src/generated/price-api/msw/handlers.ts | 19 + .../src/generated/price-api/msw/index.ts | 12 + .../price-api/queries/getV1ExchangeRates.ts | 60 + .../queries/getV1FiatExchangeRates.ts | 59 + .../queries/getV1HistoricalPrices.ts | 60 + .../queries/getV1SpotPriceByCoinId.ts | 60 + .../queries/getV1SpotPricesByCoinIds.ts | 60 + .../queries/getV1SupportedNetworks.ts | 59 + .../price-api/queries/getV2SpotPrices.ts | 60 + .../queries/getV2SupportedNetworks.ts | 59 + .../price-api/queries/getV2TopTokens.ts | 60 + .../queries/getV3HistoricalPrices.ts | 60 + .../price-api/queries/getV3SpotPrices.ts | 60 + .../src/generated/price-api/queries/index.ts | 11 + .../schemas/coinGeckoSpotPriceStruct.ts | 31 + .../schemas/coinGeckoSpotPricesStruct.ts | 12 + .../schemas/exchangeRateInfoStruct.ts | 16 + .../price-api/schemas/exchangeRatesStruct.ts | 12 + .../schemas/getV1ExchangeRatesStruct.ts | 18 + .../schemas/getV1FiatExchangeRatesStruct.ts | 13 + .../schemas/getV1HistoricalPricesStruct.ts | 25 + .../schemas/getV1SpotPriceByCoinIdStruct.ts | 23 + .../schemas/getV1SpotPricesByCoinIdsStruct.ts | 20 + .../schemas/getV1SupportedNetworksStruct.ts | 13 + .../schemas/getV2SpotPricesStruct.ts | 25 + .../schemas/getV2SupportedNetworksStruct.ts | 13 + .../price-api/schemas/getV2TopTokensStruct.ts | 24 + .../schemas/getV3HistoricalPricesStruct.ts | 28 + .../schemas/getV3SpotPricesStruct.ts | 22 + .../schemas/historicalPricesStruct.ts | 14 + .../src/generated/price-api/schemas/index.ts | 25 + .../schemas/marketDataSpotPricesStruct.ts | 12 + .../price-api/schemas/marketDataStruct.ts | 31 + .../price-api/schemas/pricePointStruct.ts | 11 + .../schemas/supportedNetworksStruct.ts | 14 + .../price-api/schemas/topTokenStruct.ts | 17 + .../schemas/v3HistoricalPricesStruct.ts | 16 + .../price-api/schemas/v3SpotPriceStruct.ts | 16 + .../price-api/schemas/v3SpotPricesStruct.ts | 12 + .../price-api/schemas/vsCurrencyStruct.ts | 11 + .../price-api/types/CoinGeckoSpotPrice.ts | 106 ++ .../price-api/types/CoinGeckoSpotPrices.ts | 13 + .../price-api/types/ExchangeRateInfo.ts | 38 + .../price-api/types/ExchangeRates.ts | 13 + .../price-api/types/GetV1ExchangeRates.ts | 27 + .../price-api/types/GetV1FiatExchangeRates.ts | 18 + .../price-api/types/GetV1HistoricalPrices.ts | 48 + .../price-api/types/GetV1SpotPriceByCoinId.ts | 38 + .../types/GetV1SpotPricesByCoinIds.ts | 34 + .../price-api/types/GetV1SupportedNetworks.ts | 18 + .../price-api/types/GetV2SpotPrices.ts | 49 + .../price-api/types/GetV2SupportedNetworks.ts | 18 + .../price-api/types/GetV2TopTokens.ts | 46 + .../price-api/types/GetV3HistoricalPrices.ts | 71 + .../price-api/types/GetV3SpotPrices.ts | 46 + .../price-api/types/HistoricalPrices.ts | 17 + .../generated/price-api/types/MarketData.ts | 106 ++ .../price-api/types/MarketDataSpotPrices.ts | 13 + .../generated/price-api/types/PricePoint.ts | 13 + .../price-api/types/SupportedNetworks.ts | 21 + .../src/generated/price-api/types/TopToken.ts | 36 + .../price-api/types/V3HistoricalPrices.ts | 27 + .../generated/price-api/types/V3SpotPrice.ts | 31 + .../generated/price-api/types/V3SpotPrices.ts | 13 + .../generated/price-api/types/VsCurrency.ts | 73 + .../src/generated/price-api/types/index.ts | 28 + packages/core-backend/src/mocks/index.ts | 23 + packages/core-backend/src/price-api/index.ts | 26 + yarn.lock | 1380 ++++++++++++++++- 127 files changed, 7388 insertions(+), 19 deletions(-) create mode 100644 packages/core-backend/codegen/annotate-msw-handlers.mjs create mode 100644 packages/core-backend/codegen/kubb-plugin-query-core/generators/queryCoreGenerator.ts create mode 100644 packages/core-backend/codegen/kubb-plugin-query-core/index.ts create mode 100644 packages/core-backend/codegen/kubb-plugin-query-core/plugin.ts create mode 100644 packages/core-backend/codegen/kubb-plugin-query-core/types.ts create mode 100644 packages/core-backend/codegen/kubb-plugin-superstruct/generators/superstructGenerator.ts create mode 100644 packages/core-backend/codegen/kubb-plugin-superstruct/index.ts create mode 100644 packages/core-backend/codegen/kubb-plugin-superstruct/parser.ts create mode 100644 packages/core-backend/codegen/kubb-plugin-superstruct/plugin.ts create mode 100644 packages/core-backend/codegen/kubb-plugin-superstruct/types.ts create mode 100644 packages/core-backend/codegen/kubb.config.ts create mode 100644 packages/core-backend/codegen/openapi/price-api.json create mode 100644 packages/core-backend/codegen/tsconfig.json create mode 100644 packages/core-backend/codegen/utils/casing.ts create mode 100644 packages/core-backend/src/api/prices/query-client.test.ts create mode 100644 packages/core-backend/src/api/prices/query-client.ts create mode 100644 packages/core-backend/src/api/query-runtime.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createCoinGeckoSpotPrice.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createCoinGeckoSpotPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createExchangeRateInfo.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createExchangeRates.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createGetV1ExchangeRates.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createGetV1FiatExchangeRates.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createGetV1HistoricalPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createGetV1SpotPriceByCoinId.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createGetV1SpotPricesByCoinIds.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createGetV1SupportedNetworks.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createGetV2SpotPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createGetV2SupportedNetworks.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createGetV2TopTokens.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createGetV3HistoricalPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createGetV3SpotPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createHistoricalPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createMarketData.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createMarketDataSpotPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createPricePoint.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createSupportedNetworks.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createTopToken.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createV3HistoricalPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createV3SpotPrice.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createV3SpotPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/createVsCurrency.ts create mode 100644 packages/core-backend/src/generated/price-api/mocks/index.ts create mode 100644 packages/core-backend/src/generated/price-api/msw/getV1ExchangeRatesHandler.ts create mode 100644 packages/core-backend/src/generated/price-api/msw/getV1FiatExchangeRatesHandler.ts create mode 100644 packages/core-backend/src/generated/price-api/msw/getV1HistoricalPricesHandler.ts create mode 100644 packages/core-backend/src/generated/price-api/msw/getV1SpotPriceByCoinIdHandler.ts create mode 100644 packages/core-backend/src/generated/price-api/msw/getV1SpotPricesByCoinIdsHandler.ts create mode 100644 packages/core-backend/src/generated/price-api/msw/getV1SupportedNetworksHandler.ts create mode 100644 packages/core-backend/src/generated/price-api/msw/getV2SpotPricesHandler.ts create mode 100644 packages/core-backend/src/generated/price-api/msw/getV2SupportedNetworksHandler.ts create mode 100644 packages/core-backend/src/generated/price-api/msw/getV2TopTokensHandler.ts create mode 100644 packages/core-backend/src/generated/price-api/msw/getV3HistoricalPricesHandler.ts create mode 100644 packages/core-backend/src/generated/price-api/msw/getV3SpotPricesHandler.ts create mode 100644 packages/core-backend/src/generated/price-api/msw/handlers.ts create mode 100644 packages/core-backend/src/generated/price-api/msw/index.ts create mode 100644 packages/core-backend/src/generated/price-api/queries/getV1ExchangeRates.ts create mode 100644 packages/core-backend/src/generated/price-api/queries/getV1FiatExchangeRates.ts create mode 100644 packages/core-backend/src/generated/price-api/queries/getV1HistoricalPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/queries/getV1SpotPriceByCoinId.ts create mode 100644 packages/core-backend/src/generated/price-api/queries/getV1SpotPricesByCoinIds.ts create mode 100644 packages/core-backend/src/generated/price-api/queries/getV1SupportedNetworks.ts create mode 100644 packages/core-backend/src/generated/price-api/queries/getV2SpotPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/queries/getV2SupportedNetworks.ts create mode 100644 packages/core-backend/src/generated/price-api/queries/getV2TopTokens.ts create mode 100644 packages/core-backend/src/generated/price-api/queries/getV3HistoricalPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/queries/getV3SpotPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/queries/index.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPriceStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPricesStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/exchangeRateInfoStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/exchangeRatesStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/getV1ExchangeRatesStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/getV1FiatExchangeRatesStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/getV1HistoricalPricesStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/getV1SpotPriceByCoinIdStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/getV1SpotPricesByCoinIdsStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/getV1SupportedNetworksStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/getV2SpotPricesStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/getV2SupportedNetworksStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/getV2TopTokensStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/getV3HistoricalPricesStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/getV3SpotPricesStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/historicalPricesStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/index.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/marketDataSpotPricesStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/marketDataStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/pricePointStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/supportedNetworksStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/topTokenStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/v3HistoricalPricesStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/v3SpotPriceStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/v3SpotPricesStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/schemas/vsCurrencyStruct.ts create mode 100644 packages/core-backend/src/generated/price-api/types/CoinGeckoSpotPrice.ts create mode 100644 packages/core-backend/src/generated/price-api/types/CoinGeckoSpotPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/types/ExchangeRateInfo.ts create mode 100644 packages/core-backend/src/generated/price-api/types/ExchangeRates.ts create mode 100644 packages/core-backend/src/generated/price-api/types/GetV1ExchangeRates.ts create mode 100644 packages/core-backend/src/generated/price-api/types/GetV1FiatExchangeRates.ts create mode 100644 packages/core-backend/src/generated/price-api/types/GetV1HistoricalPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/types/GetV1SpotPriceByCoinId.ts create mode 100644 packages/core-backend/src/generated/price-api/types/GetV1SpotPricesByCoinIds.ts create mode 100644 packages/core-backend/src/generated/price-api/types/GetV1SupportedNetworks.ts create mode 100644 packages/core-backend/src/generated/price-api/types/GetV2SpotPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/types/GetV2SupportedNetworks.ts create mode 100644 packages/core-backend/src/generated/price-api/types/GetV2TopTokens.ts create mode 100644 packages/core-backend/src/generated/price-api/types/GetV3HistoricalPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/types/GetV3SpotPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/types/HistoricalPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/types/MarketData.ts create mode 100644 packages/core-backend/src/generated/price-api/types/MarketDataSpotPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/types/PricePoint.ts create mode 100644 packages/core-backend/src/generated/price-api/types/SupportedNetworks.ts create mode 100644 packages/core-backend/src/generated/price-api/types/TopToken.ts create mode 100644 packages/core-backend/src/generated/price-api/types/V3HistoricalPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/types/V3SpotPrice.ts create mode 100644 packages/core-backend/src/generated/price-api/types/V3SpotPrices.ts create mode 100644 packages/core-backend/src/generated/price-api/types/VsCurrency.ts create mode 100644 packages/core-backend/src/generated/price-api/types/index.ts create mode 100644 packages/core-backend/src/mocks/index.ts create mode 100644 packages/core-backend/src/price-api/index.ts diff --git a/eslint.config.mjs b/eslint.config.mjs index 2c7f92cf28..47c641e198 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -82,6 +82,8 @@ const config = createConfig([ 'merged-packages/**', 'scripts/create-package/package-template/**', '.platform-api-docs/**', + // Code generated from OpenAPI documents by Kubb (`yarn codegen`). + 'packages/*/src/generated/**', ], }, { @@ -305,6 +307,13 @@ const config = createConfig([ 'import-x/no-nodejs-modules': 'off', }, }, + { + // Code generation tooling (Kubb configs and plugins) runs under Node. + files: ['packages/*/codegen/**/*.ts'], + rules: { + 'import-x/no-nodejs-modules': 'off', + }, + }, { files: ['packages/wallet-cli/src/**/*.{js,ts}'], rules: { diff --git a/knip.config.ts b/knip.config.ts index 97dc77e7c6..ced3c05c10 100644 --- a/knip.config.ts +++ b/knip.config.ts @@ -71,6 +71,11 @@ const config: KnipConfig = { ignoreDependencies: ['cockatiel'], }, 'packages/core-backend': { + // Scan the Kubb code generation tooling (`codegen/`) next to `src/` so + // the `@kubb/*` devDependencies used by `kubb.config.ts` and the custom + // plugins are seen. + entry: ['codegen/kubb.config.ts'], + project: ['src/**/*.ts', 'codegen/**/*.ts'], ignoreDependencies: ['@metamask/keyring-internal-api'], }, 'packages/earn-controller': { diff --git a/packages/core-backend/codegen/annotate-msw-handlers.mjs b/packages/core-backend/codegen/annotate-msw-handlers.mjs new file mode 100644 index 0000000000..f7ae7c91ee --- /dev/null +++ b/packages/core-backend/codegen/annotate-msw-handlers.mjs @@ -0,0 +1,59 @@ +/** + * Post-processes the MSW handlers generated by `@kubb/plugin-msw`, adding + * explicit `HttpHandler` type annotations. + * + * Without the annotations, TypeScript's declaration emit fails with TS2742 + * ("The inferred type of 'xHandler' cannot be named without a reference to + * 'msw/lib/core/handlers/HttpHandler'") because the inferred handler type + * resolves to a non-portable path inside the msw package. + * + * Runs as part of `yarn codegen` (see `package.json`). + */ + +import { readdir, readFile, writeFile } from 'node:fs/promises'; +import path from 'node:path'; + +const MSW_DIRECTORY = path.resolve( + import.meta.dirname, + '../src/generated/price-api/msw', +); + +const HTTP_HANDLER_IMPORT = 'import type { HttpHandler } from "msw";'; + +const files = await readdir(MSW_DIRECTORY); + +for (const file of files.filter((name) => name.endsWith('.ts'))) { + const filePath = path.join(MSW_DIRECTORY, file); + const source = await readFile(filePath, 'utf8'); + if (source.includes(HTTP_HANDLER_IMPORT)) { + continue; + } + + const annotated = source + // Annotate the return type of `export function xHandler(...) {`. + .replace( + /(export function \w+Handler\([\s\S]*?\)\)) \{/u, + '$1: HttpHandler {', + ) + // Annotate the aggregated `handlers` array in `handlers.ts`. + .replace( + /export const handlers = (\[[\s\S]*?\]) as const/u, + 'export const handlers: HttpHandler[] = $1', + ); + + if (annotated === source) { + continue; + } + + // Add the type import after the last existing import (`handlers.ts` has no + // "msw" import of its own, so anchoring on the import block keeps this + // uniform). + const lines = annotated.split('\n'); + const lastImportIndex = lines.reduce( + (last, line, index) => (line.startsWith('import ') ? index : last), + -1, + ); + lines.splice(lastImportIndex + 1, 0, HTTP_HANDLER_IMPORT); + + await writeFile(filePath, lines.join('\n')); +} diff --git a/packages/core-backend/codegen/kubb-plugin-query-core/generators/queryCoreGenerator.ts b/packages/core-backend/codegen/kubb-plugin-query-core/generators/queryCoreGenerator.ts new file mode 100644 index 0000000000..706e5578de --- /dev/null +++ b/packages/core-backend/codegen/kubb-plugin-query-core/generators/queryCoreGenerator.ts @@ -0,0 +1,333 @@ +import type { KubbFile } from '@kubb/fabric-core/types'; +import type { SchemaObject } from '@kubb/oas'; +import type { OperationSchema } from '@kubb/plugin-oas'; +import { createGenerator } from '@kubb/plugin-oas/generators'; +import { getBanner, getFooter } from '@kubb/plugin-oas/utils'; +import { pluginTsName } from '@kubb/plugin-ts'; + +import { pluginSuperstructName } from '../../kubb-plugin-superstruct'; +import { camelCase, pascalCase } from '../../utils/casing'; +import type { PluginQueryCore } from '../types'; + +/** + * Returns whether an operation schema contains at least one required + * property, which determines whether the generated parameter is required. + * + * @param schema - The raw OpenAPI schema of the operation parameters. + * @returns Whether at least one property is required. + */ +function hasRequiredProperties(schema: SchemaObject | undefined): boolean { + if (!schema) { + return false; + } + const { required } = schema as { required?: string[] | boolean }; + if (Array.isArray(required)) { + return required.length > 0; + } + return Boolean(required); +} + +/** + * Renders a property access, using dot notation when the property name is a + * valid identifier and bracket notation otherwise. + * + * @param objectName - The name of the object being accessed. + * @param propertyName - The property being accessed. + * @returns The rendered property access. + */ +function accessProperty(objectName: string, propertyName: string): string { + return /^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(propertyName) + ? `${objectName}.${propertyName}` + : `${objectName}[${JSON.stringify(propertyName)}]`; +} + +/** + * Converts an OpenAPI path into either a string literal (no path parameters) + * or a template literal that reads path parameters from a `pathParams` + * object. + * + * @param operationPath - The OpenAPI path, e.g. `/v1/spot-prices/{coinId}`. + * @returns The rendered URL expression. + */ +function renderUrl(operationPath: string): string { + if (!operationPath.includes('{')) { + return JSON.stringify(operationPath); + } + const template = operationPath.replace( + /\{([^}]+)\}/gu, + (_match, parameterName: string) => + `\${${accessProperty('pathParams', parameterName)}}`, + ); + return `\`${template}\``; +} + +/** + * The resolved name and file of a generated artifact in another plugin, used + * to build cross-plugin imports. + */ +type ResolvedSymbol = { + name: string; + path: KubbFile.Path; +}; + +/** + * Generator that emits a TanStack `query-core` binding per operation: + * a query key factory, a query options factory and a `fetch` convenience + * function that validates the response against the generated + * `@metamask/superstruct` struct. + */ +export const queryCoreGenerator = createGenerator({ + name: 'query-core', + + async operation({ operation, generator, config }) { + const { pluginManager, plugin, mode, oas } = generator.context; + const { queryKeyPrefix, runtimeImportPath } = plugin.options; + + const operationSchemas = generator.getSchemas(operation); + const operationId = operation.getOperationId(); + const baseName = camelCase(operationId); + + const file = pluginManager.getFile({ + name: pluginManager.resolveName({ + name: operationId, + pluginKey: plugin.key, + type: 'file', + }), + extname: '.ts', + mode, + pluginKey: plugin.key, + }); + + /** + * Resolves the name and file path of a type generated by `plugin-ts` for + * this operation. + * + * @param schemaName - The operation schema name, e.g. `GetPetsQueryParams`. + * @returns The resolved type name and file path. + */ + const resolveType = (schemaName: string): ResolvedSymbol => ({ + name: pluginManager.resolveName({ + name: schemaName, + pluginKey: [pluginTsName], + type: 'type', + }), + path: pluginManager.resolvePath({ + baseName: `${pluginManager.resolveName({ + name: operationId, + pluginKey: [pluginTsName], + type: 'file', + })}.ts`, + pluginKey: [pluginTsName], + options: { type: 'file' }, + }) as KubbFile.Path, + }); + + /** + * Resolves the name and file path of a struct generated by + * `plugin-superstruct` for this operation. + * + * @param schemaName - The operation schema name, e.g. `GetPetsQueryResponse`. + * @returns The resolved struct name and file path. + */ + const resolveStruct = (schemaName: string): ResolvedSymbol => ({ + name: pluginManager.resolveName({ + name: schemaName, + pluginKey: [pluginSuperstructName], + type: 'const', + }), + path: pluginManager.resolvePath({ + baseName: `${pluginManager.resolveName({ + name: operationId, + pluginKey: [pluginSuperstructName], + type: 'file', + })}.ts`, + pluginKey: [pluginSuperstructName], + options: { type: 'file' }, + }) as KubbFile.Path, + }); + + const response = resolveType(operationSchemas.response.name); + const responseStruct = resolveStruct(operationSchemas.response.name); + + const pathParamsSchema: OperationSchema | undefined = + operationSchemas.pathParams; + const queryParamsSchema: OperationSchema | undefined = + operationSchemas.queryParams; + + const pathParams = pathParamsSchema + ? resolveType(pathParamsSchema.name) + : undefined; + const queryParams = queryParamsSchema + ? resolveType(queryParamsSchema.name) + : undefined; + const queryParamsOptional = queryParamsSchema + ? !hasRequiredProperties(queryParamsSchema.schema) + : false; + + const queryKeyName = `${baseName}QueryKey`; + const queryOptionsName = `${baseName}QueryOptions`; + const fetcherName = baseName.startsWith('get') + ? `fetch${baseName.slice('get'.length)}` + : `fetch${pascalCase(baseName)}`; + + // Parameters shared by all three generated functions (minus `client`, + // which the query key factory does not need). + const parameterEntries: Array<{ signature: string; forward: string }> = []; + if (pathParams) { + parameterEntries.push({ + signature: `pathParams: ${pathParams.name}`, + forward: 'pathParams', + }); + } + if (queryParams) { + parameterEntries.push({ + signature: `params${queryParamsOptional ? '?' : ''}: ${queryParams.name}`, + forward: 'params', + }); + } + + const parameterSignatures = parameterEntries + .map((entry) => entry.signature) + .join(', '); + const parameterForwards = parameterEntries + .map((entry) => entry.forward) + .join(', '); + const withLeadingComma = (value: string): string => + value.length > 0 ? `, ${value}` : ''; + + const queryKeyParts = [ + JSON.stringify(queryKeyPrefix), + JSON.stringify(baseName), + ...(pathParams ? ['pathParams'] : []), + ...(queryParams + ? [queryParamsOptional ? '...(params ? [params] : [])' : 'params'] + : []), + ]; + + const method = operation.method.toLowerCase(); + const summary = operation.getSummary(); + const description = operation.getDescription(); + const endpoint = `${method.toUpperCase()} ${operation.path}`; + const docLines = [summary, description] + .filter(Boolean) + .map((line) => ` * ${line as string}`); + + const queryKeySource = ` +/** + * Query key for \`${endpoint}\`. + */ +export const ${queryKeyName} = (${parameterSignatures}) => + [${queryKeyParts.join(', ')}] as const; +`; + + const requestArguments = [ + `method: '${method}'`, + `url: ${renderUrl(operation.path)}`, + ...(queryParams ? ['params'] : []), + 'signal', + ]; + + const queryOptionsSource = ` +/** +${docLines.length > 0 ? `${docLines.join('\n')}\n *\n` : ''} * Returns the TanStack Query options for \`${endpoint}\`. The response is + * validated against {@link ${responseStruct.name}} before it is returned. + */ +export function ${queryOptionsName}( + client: ApiRequestClient${withLeadingComma(parameterSignatures)}, + options?: FetchOptions, +): FetchQueryOptions<${response.name}> { + return { + queryKey: ${queryKeyName}(${parameterForwards}), + queryFn: async ({ signal }: QueryFunctionContext) => { + const data = await client.request<${response.name}>({ + ${requestArguments.join(',\n ')}, + }); + assert(data, ${responseStruct.name}); + return data; + }, + ...getQueryOptionsOverrides(options), + }; +} +`; + + const fetcherSource = ` +/** +${docLines.length > 0 ? `${docLines.join('\n')}\n *\n` : ''} * Fetches \`${endpoint}\` through the client's QueryClient, deduplicating + * concurrent calls and reusing fresh cached data. + */ +export async function ${fetcherName}( + client: ApiRequestClient${withLeadingComma(parameterSignatures)}, + options?: FetchOptions, +): Promise<${response.name}> { + return client.queryClient.fetchQuery( + ${queryOptionsName}(client${withLeadingComma(parameterForwards)}, options), + ); +} +`; + + const typeImports = [ + response, + ...(pathParams ? [pathParams] : []), + ...(queryParams ? [queryParams] : []), + ]; + + return [ + { + ...file, + banner: getBanner({ oas, output: plugin.options.output, config }), + footer: getFooter({ oas, output: plugin.options.output }), + sources: [ + { + name: queryKeyName, + value: queryKeySource.trim(), + isExportable: true, + isIndexable: true, + }, + { + name: queryOptionsName, + value: queryOptionsSource.trim(), + isExportable: true, + isIndexable: true, + }, + { + name: fetcherName, + value: fetcherSource.trim(), + isExportable: true, + isIndexable: true, + }, + ], + imports: [ + { + name: ['FetchQueryOptions', 'QueryFunctionContext'], + path: '@tanstack/query-core', + isTypeOnly: true, + }, + { + name: ['assert'], + path: '@metamask/superstruct', + }, + { + name: ['getQueryOptionsOverrides'], + path: runtimeImportPath, + }, + { + name: ['ApiRequestClient', 'FetchOptions'], + path: runtimeImportPath, + isTypeOnly: true, + }, + { + name: [responseStruct.name], + path: responseStruct.path, + root: file.path, + }, + { + name: typeImports.map((typeImport) => typeImport.name), + path: response.path, + root: file.path, + isTypeOnly: true, + }, + ], + }, + ]; + }, +}); diff --git a/packages/core-backend/codegen/kubb-plugin-query-core/index.ts b/packages/core-backend/codegen/kubb-plugin-query-core/index.ts new file mode 100644 index 0000000000..2b4ea8f8a3 --- /dev/null +++ b/packages/core-backend/codegen/kubb-plugin-query-core/index.ts @@ -0,0 +1,3 @@ +export { pluginQueryCore, pluginQueryCoreName } from './plugin'; +export { queryCoreGenerator } from './generators/queryCoreGenerator'; +export type { Options, PluginQueryCore, ResolvedOptions } from './types'; diff --git a/packages/core-backend/codegen/kubb-plugin-query-core/plugin.ts b/packages/core-backend/codegen/kubb-plugin-query-core/plugin.ts new file mode 100644 index 0000000000..0ccf8a03c0 --- /dev/null +++ b/packages/core-backend/codegen/kubb-plugin-query-core/plugin.ts @@ -0,0 +1,108 @@ +import path from 'node:path'; + +import { definePlugin, getBarrelFiles, getMode } from '@kubb/core'; +import { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'; +import { pluginTsName } from '@kubb/plugin-ts'; + +import { queryCoreGenerator } from './generators/queryCoreGenerator'; +import type { PluginQueryCore } from './types'; +import { pluginSuperstructName } from '../kubb-plugin-superstruct'; +import { camelCase, pascalCase } from '../utils/casing'; + +export const pluginQueryCoreName = 'plugin-query-core' satisfies PluginQueryCore['name']; + +/** + * Kubb plugin that generates framework-agnostic TanStack `query-core` + * bindings for every operation in an OpenAPI document. + * + * For every operation the plugin generates: + * - a query key factory (`QueryKey`), + * - a query options factory (`QueryOptions`) whose `queryFn` + * performs the request through an injected {@link ApiRequestClient} and + * validates the response with the `@metamask/superstruct` struct generated + * by `plugin-superstruct`, and + * - a `fetch` convenience function that runs the query through + * the client's `QueryClient`. + * + * Depends on `plugin-ts` (for types) and `plugin-superstruct` (for response + * validation). + */ +export const pluginQueryCore = definePlugin((options = {}) => { + const { + output = { path: 'queries', barrelType: 'named' }, + exclude = [], + include, + override = [], + transformers = {}, + contentType, + queryKeyPrefix = 'api', + runtimeImportPath = '../../../api/query-runtime', + generators = [queryCoreGenerator], + } = options; + + return { + name: pluginQueryCoreName, + options: { + output, + contentType, + include, + exclude, + override, + queryKeyPrefix, + runtimeImportPath, + transformers, + }, + pre: [pluginOasName, pluginTsName, pluginSuperstructName], + resolvePath(baseName, pathMode) { + const root = path.resolve(this.config.root, this.config.output.path); + const mode = pathMode ?? getMode(path.resolve(root, output.path)); + + if (mode === 'single') { + return path.resolve(root, output.path); + } + + return path.resolve(root, output.path, baseName); + }, + resolveName(name, type) { + const resolvedName = + type === 'type' ? pascalCase(name) : camelCase(name); + + if (type) { + return transformers?.name?.(resolvedName, type) || resolvedName; + } + + return resolvedName; + }, + async install() { + const root = path.resolve(this.config.root, this.config.output.path); + const mode = getMode(path.resolve(root, output.path)); + const oas = await this.getOas(); + + const operationGenerator = new OperationGenerator(this.plugin.options, { + fabric: this.fabric, + oas, + pluginManager: this.pluginManager, + events: this.events, + plugin: this.plugin, + contentType, + exclude, + include, + override, + mode, + }); + + const operationFiles = await operationGenerator.build(...generators); + await this.upsertFile(...operationFiles); + + const barrelFiles = await getBarrelFiles(this.fabric.files, { + root, + output, + meta: { + pluginKey: this.plugin.key, + }, + }); + + await this.upsertFile(...barrelFiles); + }, + }; +}); diff --git a/packages/core-backend/codegen/kubb-plugin-query-core/types.ts b/packages/core-backend/codegen/kubb-plugin-query-core/types.ts new file mode 100644 index 0000000000..a0f565348e --- /dev/null +++ b/packages/core-backend/codegen/kubb-plugin-query-core/types.ts @@ -0,0 +1,85 @@ +import type { Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'; +import type { Oas, contentType } from '@kubb/oas'; +import type { Exclude, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas'; +import type { Generator } from '@kubb/plugin-oas/generators'; + +/** + * User-facing options for the TanStack `query-core` Kubb plugin. + */ +export type Options = { + /** + * Specify the export location for the files and define the behavior of the + * output. + * @default { path: 'queries', barrelType: 'named' } + */ + output?: Output; + /** + * Define which contentType should be used. By default, the first JSON valid + * mediaType is used. + */ + contentType?: contentType; + /** + * Array containing exclude parameters to exclude/skip + * tags/operations/methods/paths. + */ + exclude?: Array; + /** + * Array containing include parameters to include tags/operations/methods/paths. + */ + include?: Array; + /** + * Array containing override parameters to override `options` based on + * tags/operations/methods/paths. + */ + override?: Array>; + /** + * The first element of every generated query key, scoping the generated + * queries in the QueryClient cache (e.g. `'prices'`). + * @default 'api' + */ + queryKeyPrefix?: string; + /** + * Module specifier that the generated files import the request-client + * runtime from (`ApiRequestClient`, `FetchOptions` and + * `getQueryOptionsOverrides`). Relative specifiers are resolved from the + * generated query files. + * @default '../../../api/query-runtime' + */ + runtimeImportPath?: string; + transformers?: { + /** + * Customize the names based on the type that is provided by the plugin. + */ + name?: ( + name: ResolveNameParams['name'], + type?: ResolveNameParams['type'], + ) => string; + }; + /** + * Define some generators next to the query-core generators. + */ + generators?: Array>; +}; + +/** + * Options for the TanStack `query-core` Kubb plugin after defaults have been + * applied. + */ +export type ResolvedOptions = { + output: Output; + contentType: Options['contentType']; + include: Options['include']; + exclude: Options['exclude']; + override: NonNullable; + queryKeyPrefix: NonNullable; + runtimeImportPath: NonNullable; + transformers: NonNullable; +}; + +export type PluginQueryCore = PluginFactoryOptions< + 'plugin-query-core', + Options, + ResolvedOptions, + never, + ResolvePathOptions +>; diff --git a/packages/core-backend/codegen/kubb-plugin-superstruct/generators/superstructGenerator.ts b/packages/core-backend/codegen/kubb-plugin-superstruct/generators/superstructGenerator.ts new file mode 100644 index 0000000000..9eecb879e8 --- /dev/null +++ b/packages/core-backend/codegen/kubb-plugin-superstruct/generators/superstructGenerator.ts @@ -0,0 +1,203 @@ +import type { Plugin, PluginManager } from '@kubb/core'; +import type { KubbFile } from '@kubb/fabric-core/types'; +import type { OperationSchema, Schema } from '@kubb/plugin-oas'; +import { SchemaGenerator } from '@kubb/plugin-oas'; +import { createGenerator } from '@kubb/plugin-oas/generators'; +import { getBanner, getFooter, getImports } from '@kubb/plugin-oas/utils'; + +import { parse } from '../parser'; +import type { PluginSuperstruct } from '../types'; + +/** + * A named schema (component schema or operation schema) that should be + * emitted as a struct. + */ +type NamedSchemaTree = { + name: string; + tree: Array; + description?: string; +}; + +/** + * Renders the source code of a single schema file: the + * `@metamask/superstruct` import plus one exported struct per schema. + * + * @param trees - The named schema trees to emit. + * @param pluginManager - The Kubb plugin manager, used to resolve struct + * names. + * @param plugin - The current plugin instance. + * @returns The rendered sources and the helpers that must be imported. + */ +function renderStructs( + trees: Array, + pluginManager: PluginManager, + plugin: Plugin, +): { sources: Array; usedHelpers: Set } { + const usedHelpers = new Set(); + + const sources = trees.map(({ name, tree, description }): KubbFile.Source => { + const structName = pluginManager.resolveName({ + name, + pluginKey: plugin.key, + type: 'const', + }); + const expression = parse(tree, { usedHelpers }) || 'unknown()'; + if (expression === 'unknown()') { + usedHelpers.add('unknown'); + } + + const jsdoc = description + ? `/**\n * ${description.replace(/\n/gu, '\n * ')}\n */\n` + : ''; + + return { + name: structName, + value: `${jsdoc}export const ${structName} = ${expression};`, + isExportable: true, + isIndexable: true, + }; + }); + + return { sources, usedHelpers }; +} + +/** + * Generator for `@metamask/superstruct` structs. + * + * The `schema` hook emits one file per named component schema; the + * `operation` hook emits one file per operation containing structs for its + * path params, query params, request body and response. + */ +export const superstructGenerator = createGenerator({ + name: 'superstruct', + + async schema({ schema, generator, config }) { + const { pluginManager, plugin, mode, oas } = generator.context; + + const file = pluginManager.getFile({ + name: pluginManager.resolveName({ + name: schema.name, + pluginKey: plugin.key, + type: 'file', + }), + extname: '.ts', + mode, + pluginKey: plugin.key, + }); + + const { sources, usedHelpers } = renderStructs( + [ + { + name: schema.name, + tree: schema.tree, + description: schema.value.description, + }, + ], + pluginManager, + plugin, + ); + + const refImports = getImports(schema.tree); + + return [ + { + ...file, + sources, + banner: getBanner({ oas, output: plugin.options.output, config }), + footer: getFooter({ oas, output: plugin.options.output }), + imports: [ + { + name: [...usedHelpers].sort(), + path: plugin.options.importPath, + }, + ...refImports.map((refImport) => ({ + name: refImport.name, + path: refImport.path, + root: file.path, + })), + ], + }, + ]; + }, + + async operation({ operation, generator, config }) { + const { pluginManager, plugin, mode, oas, fabric, events, override } = + generator.context; + + const schemaGenerator = new SchemaGenerator(plugin.options, { + fabric, + oas, + pluginManager, + plugin, + events, + mode, + override, + }); + + const operationSchemas = generator.getSchemas(operation); + // Note: `response` aliases one of the `statusCodes` schemas, so the + // status code schemas must be emitted first. + const namedSchemas = [ + operationSchemas.pathParams, + operationSchemas.queryParams, + operationSchemas.headerParams, + ...(operationSchemas.statusCodes ?? []), + operationSchemas.request, + operationSchemas.response, + ].filter( + (operationSchema): operationSchema is OperationSchema => + operationSchema !== undefined && operationSchema.schema !== undefined, + ); + + const trees = namedSchemas.map( + (operationSchema): NamedSchemaTree => ({ + name: operationSchema.name, + tree: schemaGenerator.parse({ + schema: operationSchema.schema, + name: operationSchema.name, + parentName: null, + }), + description: operationSchema.description, + }), + ); + + const file = pluginManager.getFile({ + name: pluginManager.resolveName({ + name: operation.getOperationId(), + pluginKey: plugin.key, + type: 'file', + }), + extname: '.ts', + mode, + pluginKey: plugin.key, + }); + + const { sources, usedHelpers } = renderStructs( + trees, + pluginManager, + plugin, + ); + + const refImports = trees.flatMap((tree) => getImports(tree.tree)); + + return [ + { + ...file, + sources, + banner: getBanner({ oas, output: plugin.options.output, config }), + footer: getFooter({ oas, output: plugin.options.output }), + imports: [ + { + name: [...usedHelpers].sort(), + path: plugin.options.importPath, + }, + ...refImports.map((refImport) => ({ + name: refImport.name, + path: refImport.path, + root: file.path, + })), + ], + }, + ]; + }, +}); diff --git a/packages/core-backend/codegen/kubb-plugin-superstruct/index.ts b/packages/core-backend/codegen/kubb-plugin-superstruct/index.ts new file mode 100644 index 0000000000..6d4559d5e2 --- /dev/null +++ b/packages/core-backend/codegen/kubb-plugin-superstruct/index.ts @@ -0,0 +1,5 @@ +export { pluginSuperstruct, pluginSuperstructName } from './plugin'; +export { superstructGenerator } from './generators/superstructGenerator'; +export { parse } from './parser'; +export type { ParserOptions } from './parser'; +export type { Options, PluginSuperstruct, ResolvedOptions } from './types'; diff --git a/packages/core-backend/codegen/kubb-plugin-superstruct/parser.ts b/packages/core-backend/codegen/kubb-plugin-superstruct/parser.ts new file mode 100644 index 0000000000..b1a351a873 --- /dev/null +++ b/packages/core-backend/codegen/kubb-plugin-superstruct/parser.ts @@ -0,0 +1,346 @@ +import type { Schema, SchemaKeywordMapper } from '@kubb/plugin-oas'; +import { isKeyword, schemaKeywords } from '@kubb/plugin-oas'; + +/** + * Options for {@link parse}. + */ +export type ParserOptions = { + /** + * Collects the names of the `@metamask/superstruct` helpers that were used + * while parsing, so the generator can emit a matching import statement. + */ + usedHelpers: Set; +}; + +/** + * The subset of Kubb schema keywords that produce a struct on their own. + * Everything else (min/max/optional/nullable/describe/...) decorates one of + * these. + */ +const BASE_KEYWORDS: string[] = [ + schemaKeywords.object, + schemaKeywords.array, + schemaKeywords.tuple, + schemaKeywords.enum, + schemaKeywords.union, + schemaKeywords.and, + schemaKeywords.const, + schemaKeywords.ref, + schemaKeywords.matches, + schemaKeywords.string, + schemaKeywords.number, + schemaKeywords.integer, + schemaKeywords.bigint, + schemaKeywords.boolean, + schemaKeywords.datetime, + schemaKeywords.date, + schemaKeywords.time, + schemaKeywords.email, + schemaKeywords.uuid, + schemaKeywords.url, + schemaKeywords.firstName, + schemaKeywords.lastName, + schemaKeywords.password, + schemaKeywords.phone, + schemaKeywords.blob, + schemaKeywords.null, + schemaKeywords.undefined, + schemaKeywords.any, + schemaKeywords.unknown, + schemaKeywords.void, +]; + +/** + * Quotes an object property name when it is not a valid JavaScript + * identifier. + * + * @param name - The property name. + * @returns The property name, quoted if necessary. + */ +function formatPropertyName(name: string): string { + return /^[A-Za-z_$][A-Za-z0-9_$]*$/u.test(name) ? name : JSON.stringify(name); +} + +/** + * Serializes a literal value (from `const`, `default` or `enum` keywords) + * into source code. + * + * @param value - The literal value. + * @param format - Optional format hint provided by Kubb. + * @returns The serialized value. + */ +function formatLiteral( + value: string | number | boolean | undefined, + format?: 'string' | 'number' | 'boolean', +): string { + if (value === undefined) { + return 'undefined'; + } + if (format === 'number' || format === 'boolean') { + return String(value); + } + if (typeof value === 'string') { + return JSON.stringify(value); + } + return String(value); +} + +/** + * Registers a `@metamask/superstruct` helper as used and returns a call + * expression for it. + * + * @param options - The parser options carrying the used-helper collector. + * @param helper - The helper name, e.g. `string`. + * @param args - The source code of the arguments. + * @returns The call expression, e.g. `string()`. + */ +function call(options: ParserOptions, helper: string, ...args: string[]): string { + options.usedHelpers.add(helper); + return `${helper}(${args.join(', ')})`; +} + +/** + * Converts a single base schema to a superstruct expression. + * + * @param current - The schema keyword to convert. + * @param siblings - The sibling keywords of `current` (constraints such as + * min/max live here). + * @param options - The parser options. + * @returns The superstruct expression for the schema. + */ +function parseBase( + current: Schema, + siblings: Schema[], + options: ParserOptions, +): string { + if (isKeyword(current, schemaKeywords.object)) { + return parseObject(current, options); + } + + if (isKeyword(current, schemaKeywords.array)) { + // Kubb represents the array item type as a list of sibling keywords. + const item = parse(current.args.items, options); + return call(options, 'array', item === '' ? call(options, 'unknown') : item); + } + + if (isKeyword(current, schemaKeywords.tuple)) { + const items = current.args.items.map((item) => parse([item], options)); + return call(options, 'tuple', `[${items.join(', ')}]`); + } + + if (isKeyword(current, schemaKeywords.enum)) { + const values = current.args.items.map((item) => + formatLiteral(item.value, item.format), + ); + const formats = new Set(current.args.items.map((item) => item.format)); + if (formats.has('boolean') || formats.size > 1) { + // `enums()` only supports homogeneous string/number lists; fall back to + // a union of literals for anything else. + const literals = values.map((value) => call(options, 'literal', value)); + return call(options, 'union', `[${literals.join(', ')}]`); + } + return call(options, 'enums', `[${values.join(', ')}]`); + } + + if (isKeyword(current, schemaKeywords.union)) { + const members = current.args + .map((member) => parse([member], options)) + .filter(Boolean); + if (members.length === 1) { + return members[0] as string; + } + return call(options, 'union', `[${members.join(', ')}]`); + } + + if (isKeyword(current, schemaKeywords.and)) { + const members = current.args + .filter((member) => BASE_KEYWORDS.includes(member.keyword)) + .map((member) => parse([member], options)) + .filter(Boolean); + if (members.length === 1) { + return members[0] as string; + } + return call(options, 'intersection', `[${members.join(', ')}]`); + } + + if (isKeyword(current, schemaKeywords.const)) { + return call( + options, + 'literal', + formatLiteral(current.args.value, current.args.format), + ); + } + + if (isKeyword(current, schemaKeywords.ref)) { + // Reference the imported struct directly. `lazy()` is only necessary for + // circular references, which we do not generate for now. + return current.args.name; + } + + if (isKeyword(current, schemaKeywords.matches)) { + if (current.args) { + return call( + options, + 'pattern', + call(options, 'string'), + `new RegExp(${JSON.stringify(current.args)})`, + ); + } + return call(options, 'string'); + } + + if (isKeyword(current, schemaKeywords.number) || isKeyword(current, schemaKeywords.integer)) { + let output = isKeyword(current, schemaKeywords.integer) + ? call(options, 'integer') + : call(options, 'number'); + + const minimum = findKeyword(siblings, schemaKeywords.min)?.args; + const maximum = findKeyword(siblings, schemaKeywords.max)?.args; + const exclusiveMinimum = findKeyword(siblings, schemaKeywords.exclusiveMinimum)?.args; + const exclusiveMaximum = findKeyword(siblings, schemaKeywords.exclusiveMaximum)?.args; + + if (minimum !== undefined) { + output = call(options, 'min', output, String(minimum)); + } + if (exclusiveMinimum !== undefined) { + output = call(options, 'min', output, String(exclusiveMinimum), '{ exclusive: true }'); + } + if (maximum !== undefined) { + output = call(options, 'max', output, String(maximum)); + } + if (exclusiveMaximum !== undefined) { + output = call(options, 'max', output, String(exclusiveMaximum), '{ exclusive: true }'); + } + return output; + } + + if (isKeyword(current, schemaKeywords.bigint)) { + return call(options, 'bigint'); + } + + if (isKeyword(current, schemaKeywords.boolean)) { + return call(options, 'boolean'); + } + + if (isKeyword(current, schemaKeywords.null)) { + return call(options, 'literal', 'null'); + } + + if (isKeyword(current, schemaKeywords.any)) { + return call(options, 'any'); + } + + if ( + isKeyword(current, schemaKeywords.unknown) || + isKeyword(current, schemaKeywords.undefined) || + isKeyword(current, schemaKeywords.void) || + isKeyword(current, schemaKeywords.blob) + ) { + return call(options, 'unknown'); + } + + // All string-like formats (datetime, date, time, email, uuid, url, ...) are + // plain strings on the wire. + return call(options, 'string'); +} + +/** + * Converts an object schema to a superstruct expression. + * + * Objects with only `additionalProperties` become `record()` structs. Objects + * with properties become `type()` structs (which tolerate unknown properties, + * matching how API responses evolve) unless the OpenAPI schema sets + * `additionalProperties: false`, in which case a strict `object()` struct is + * generated. + * + * @param current - The object schema keyword. + * @param options - The parser options. + * @returns The superstruct expression for the object. + */ +function parseObject( + current: SchemaKeywordMapper['object'], + options: ParserOptions, +): string { + const propertyEntries = Object.entries(current.args?.properties ?? {}); + const additionalProperties = current.args?.additionalProperties ?? []; + + if (propertyEntries.length === 0 && additionalProperties.length > 0) { + const value = parse(additionalProperties, options); + return call( + options, + 'record', + call(options, 'string'), + value === '' ? call(options, 'unknown') : value, + ); + } + + const properties = propertyEntries + .map(([propertyName, propertySchemas]) => { + const value = parse(propertySchemas, options); + return `${formatPropertyName(propertyName)}: ${value === '' ? call(options, 'unknown') : value}`; + }) + .join(',\n'); + + const helper = current.args?.strict ? 'object' : 'type'; + return call(options, helper, `{\n${properties}\n}`); +} + +/** + * Finds a keyword within a list of sibling schemas. + * + * @param siblings - The sibling schemas to search. + * @param keyword - The keyword to search for. + * @returns The matching schema, if any. + */ +function findKeyword( + siblings: Schema[], + keyword: TKeyword, +): SchemaKeywordMapper[TKeyword] | undefined { + return siblings.find((schema): schema is SchemaKeywordMapper[TKeyword] => + isKeyword(schema, keyword), + ); +} + +/** + * Converts a list of sibling schema keywords — Kubb's representation of a + * single value — into a `@metamask/superstruct` expression. + * + * The base schema (object/array/string/...) is converted first, then + * decorated with constraints (`min`/`max`) and modifiers + * (`defaulted`/`nullable`/`optional`). + * + * @param schemas - The sibling schema keywords describing a single value. + * @param options - The parser options. + * @returns The superstruct expression, or an empty string when the schemas + * contain no base keyword. + */ +export function parse(schemas: Schema[], options: ParserOptions): string { + const base = schemas.find((schema) => BASE_KEYWORDS.includes(schema.keyword)); + if (!base) { + return ''; + } + + let output = parseBase(base, schemas, options); + + const defaultSchema = findKeyword(schemas, schemaKeywords.default); + if (defaultSchema?.args !== undefined) { + // Kubb pre-serializes string defaults (quotes included), so the value can + // be emitted as-is. + output = call(options, 'defaulted', output, String(defaultSchema.args)); + } + + const isNullish = schemas.some((schema) => isKeyword(schema, schemaKeywords.nullish)); + const isNullable = + isNullish || schemas.some((schema) => isKeyword(schema, schemaKeywords.nullable)); + const isOptional = + isNullish || schemas.some((schema) => isKeyword(schema, schemaKeywords.optional)); + + if (isNullable) { + output = call(options, 'nullable', output); + } + if (isOptional) { + output = call(options, 'optional', output); + } + + return output; +} diff --git a/packages/core-backend/codegen/kubb-plugin-superstruct/plugin.ts b/packages/core-backend/codegen/kubb-plugin-superstruct/plugin.ts new file mode 100644 index 0000000000..5a2c2f59cc --- /dev/null +++ b/packages/core-backend/codegen/kubb-plugin-superstruct/plugin.ts @@ -0,0 +1,150 @@ +import path from 'node:path'; + +import { definePlugin, getBarrelFiles, getMode } from '@kubb/core'; +import type { Group } from '@kubb/core'; +import { OperationGenerator, SchemaGenerator, pluginOasName } from '@kubb/plugin-oas'; + +import { superstructGenerator } from './generators/superstructGenerator'; +import type { PluginSuperstruct } from './types'; +import { camelCase, pascalCase } from '../utils/casing'; + +export const pluginSuperstructName = 'plugin-superstruct' satisfies PluginSuperstruct['name']; + +/** + * Kubb plugin that generates `@metamask/superstruct` structs from an OpenAPI + * document. + * + * For every component schema and every operation (path params, query params, + * request body and response) a `Struct` is generated, following the + * naming convention used across MetaMask packages. + */ +export const pluginSuperstruct = definePlugin((options = {}) => { + const { + output = { path: 'schemas', barrelType: 'named' }, + group, + exclude = [], + include, + override = [], + transformers = {}, + importPath = '@metamask/superstruct', + contentType, + generators = [superstructGenerator], + } = options; + + return { + name: pluginSuperstructName, + options: { + output, + group, + contentType, + include, + exclude, + override, + importPath, + transformers, + // Options consumed by Kubb's SchemaGenerator. Dates, times and other + // string formats are all treated as strings on the wire. + dateType: 'string', + unknownType: 'unknown', + emptySchemaType: 'unknown', + usedEnumNames: {}, + }, + pre: [pluginOasName], + resolvePath(baseName, pathMode, resolvePathOptions) { + const root = path.resolve(this.config.root, this.config.output.path); + const mode = pathMode ?? getMode(path.resolve(root, output.path)); + + if (mode === 'single') { + return path.resolve(root, output.path); + } + + if (group && (resolvePathOptions?.group?.path || resolvePathOptions?.group?.tag)) { + const groupName: Group['name'] = group.name + ? group.name + : (context) => { + if (group.type === 'path') { + return `${context.group.split('/')[1]}`; + } + return `${camelCase(context.group)}Controller`; + }; + + return path.resolve( + root, + output.path, + groupName({ + group: + group.type === 'path' + ? (resolvePathOptions.group.path as string) + : (resolvePathOptions.group.tag as string), + }), + baseName, + ); + } + + return path.resolve(root, output.path, baseName); + }, + resolveName(name, type) { + // Structs follow the `Struct` convention used across + // MetaMask packages; files use the camelCase variant. References + // between structs are resolved with `type: 'function'`, so those must + // match the exported (PascalCase) names. + const resolvedName = + type === 'file' + ? camelCase(`${name}Struct`) + : pascalCase(`${name}Struct`); + + if (type) { + return transformers?.name?.(resolvedName, type) || resolvedName; + } + + return resolvedName; + }, + async install() { + const root = path.resolve(this.config.root, this.config.output.path); + const mode = getMode(path.resolve(root, output.path)); + const oas = await this.getOas(); + + const schemaGenerator = new SchemaGenerator(this.plugin.options, { + fabric: this.fabric, + oas, + pluginManager: this.pluginManager, + events: this.events, + plugin: this.plugin, + contentType, + include: undefined, + override, + mode, + output: output.path, + }); + + const schemaFiles = await schemaGenerator.build(...generators); + await this.upsertFile(...schemaFiles); + + const operationGenerator = new OperationGenerator(this.plugin.options, { + fabric: this.fabric, + oas, + pluginManager: this.pluginManager, + events: this.events, + plugin: this.plugin, + contentType, + exclude, + include, + override, + mode, + }); + + const operationFiles = await operationGenerator.build(...generators); + await this.upsertFile(...operationFiles); + + const barrelFiles = await getBarrelFiles(this.fabric.files, { + root, + output, + meta: { + pluginKey: this.plugin.key, + }, + }); + + await this.upsertFile(...barrelFiles); + }, + }; +}); diff --git a/packages/core-backend/codegen/kubb-plugin-superstruct/types.ts b/packages/core-backend/codegen/kubb-plugin-superstruct/types.ts new file mode 100644 index 0000000000..0dde4a348f --- /dev/null +++ b/packages/core-backend/codegen/kubb-plugin-superstruct/types.ts @@ -0,0 +1,86 @@ +import type { Group, Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'; +import type { Oas, contentType } from '@kubb/oas'; +import type { Exclude, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas'; +import type { Generator } from '@kubb/plugin-oas/generators'; + +/** + * User-facing options for the `@metamask/superstruct` Kubb plugin. + */ +export type Options = { + /** + * Specify the export location for the files and define the behavior of the + * output. + * @default { path: 'schemas', barrelType: 'named' } + */ + output?: Output; + /** + * Group the superstruct schemas based on the provided name. + */ + group?: Group; + /** + * Define which contentType should be used. By default, the first JSON valid + * mediaType is used. + */ + contentType?: contentType; + /** + * Array containing exclude parameters to exclude/skip + * tags/operations/methods/paths. + */ + exclude?: Array; + /** + * Array containing include parameters to include tags/operations/methods/paths. + */ + include?: Array; + /** + * Array containing override parameters to override `options` based on + * tags/operations/methods/paths. + */ + override?: Array>; + /** + * The module that structs are imported from. + * @default '@metamask/superstruct' + */ + importPath?: string; + transformers?: { + /** + * Customize the names based on the type that is provided by the plugin. + */ + name?: ( + name: ResolveNameParams['name'], + type?: ResolveNameParams['type'], + ) => string; + }; + /** + * Define some generators next to the superstruct generators. + */ + generators?: Array>; +}; + +/** + * Options for the `@metamask/superstruct` Kubb plugin after defaults have + * been applied. Also carries the options that Kubb's `SchemaGenerator` + * requires (`dateType`, `unknownType`, ...), since this plugin drives schema + * parsing through that class. + */ +export type ResolvedOptions = { + output: Output; + group: Options['group']; + contentType: Options['contentType']; + include: Options['include']; + exclude: Options['exclude']; + override: NonNullable; + importPath: NonNullable; + transformers: NonNullable; + dateType: 'string'; + unknownType: 'unknown'; + emptySchemaType: 'unknown'; + usedEnumNames: Record; +}; + +export type PluginSuperstruct = PluginFactoryOptions< + 'plugin-superstruct', + Options, + ResolvedOptions, + never, + ResolvePathOptions +>; diff --git a/packages/core-backend/codegen/kubb.config.ts b/packages/core-backend/codegen/kubb.config.ts new file mode 100644 index 0000000000..6f97866ba6 --- /dev/null +++ b/packages/core-backend/codegen/kubb.config.ts @@ -0,0 +1,100 @@ +import { defineConfig } from '@kubb/core'; +import { pluginFaker } from '@kubb/plugin-faker'; +import { pluginMsw } from '@kubb/plugin-msw'; +import { pluginOas } from '@kubb/plugin-oas'; +import { pluginTs } from '@kubb/plugin-ts'; + +import { pluginQueryCore } from './kubb-plugin-query-core'; +import { pluginSuperstruct } from './kubb-plugin-superstruct'; + +/** + * Kubb code generation for the Price API (https://price.api.cx.metamask.io). + * + * Generates, from `codegen/openapi/price-api.json` into + * `src/generated/price-api`: + * - `types/` TypeScript types (@kubb/plugin-ts) + * - `schemas/` @metamask/superstruct structs (codegen/kubb-plugin-superstruct) + * - `mocks/` Faker-based mock builders (@kubb/plugin-faker) + * - `msw/` MSW request handlers (@kubb/plugin-msw) + * - `queries/` TanStack query-core bindings (codegen/kubb-plugin-query-core) + * + * Run with `yarn workspace @metamask/core-backend run codegen`. + */ +export default defineConfig({ + name: 'price-api', + // Resolved relative to the working directory, which is the package root + // when run through `yarn workspace @metamask/core-backend run codegen`. + root: '.', + input: { + path: './codegen/openapi/price-api.json', + }, + output: { + path: './src/generated/price-api', + clean: true, + // No root barrel: the package's `./price-api` and `./mocks` entry points + // (`src/price-api/index.ts` and `src/mocks/index.ts`) re-export the + // per-plugin barrels, keeping the msw/faker mocks out of the runtime + // entry point. + barrelType: false, + defaultBanner: 'simple', + // Emit extension-less relative imports so the generated code can be + // compiled by ts-bridge (CommonJS + ESM). + extension: { + '.ts': '', + }, + // Formatting is handled by the repo's own tooling (`yarn lint:fix`). + format: false, + lint: false, + }, + plugins: [ + pluginOas({ + validate: true, + // Don't emit the raw JSON schema files. + generators: [], + output: { + path: 'json', + barrelType: false, + }, + }), + pluginTs({ + output: { + path: 'types', + barrelType: 'named', + }, + enumType: 'asConst', + unknownType: 'unknown', + }), + pluginSuperstruct({ + output: { + path: 'schemas', + barrelType: 'named', + }, + }), + pluginFaker({ + output: { + path: 'mocks', + barrelType: 'named', + }, + unknownType: 'unknown', + // Deterministic mock data across runs and tests. + seed: [220], + }), + pluginMsw({ + output: { + path: 'msw', + barrelType: 'named', + }, + baseURL: 'https://price.api.cx.metamask.io', + parser: 'faker', + handlers: true, + }), + pluginQueryCore({ + output: { + path: 'queries', + barrelType: 'named', + }, + queryKeyPrefix: 'prices', + runtimeImportPath: '../../../api/query-runtime', + }), + ], +}); diff --git a/packages/core-backend/codegen/openapi/price-api.json b/packages/core-backend/codegen/openapi/price-api.json new file mode 100644 index 0000000000..67523d855e --- /dev/null +++ b/packages/core-backend/codegen/openapi/price-api.json @@ -0,0 +1,948 @@ +{ + "openapi": "3.1.0", + "info": { + "title": "Price API", + "description": "MetaMask Price API. Provides spot prices, exchange rates, historical prices and market data for tokens across networks. This document is a curated subset of https://price.api.cx.metamask.io/docs-json, enriched with response schemas (the live document does not declare response DTOs for most endpoints).", + "version": "1.0.0", + "contact": { + "name": "MetaMask", + "url": "https://github.com/MetaMask/core" + } + }, + "servers": [ + { + "url": "https://price.api.cx.metamask.io" + } + ], + "tags": [ + { + "name": "Supported Networks" + }, + { + "name": "Exchange Rates" + }, + { + "name": "Spot Prices" + }, + { + "name": "Historical Prices" + }, + { + "name": "Top Tokens" + } + ], + "paths": { + "/v1/supportedNetworks": { + "get": { + "operationId": "getV1SupportedNetworks", + "summary": "Get supported networks", + "description": "Returns the list of supported networks, keyed by decimal chain ID.", + "tags": ["Supported Networks"], + "responses": { + "200": { + "description": "The supported networks, split by level of support.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SupportedNetworks" + } + } + } + } + } + } + }, + "/v2/supportedNetworks": { + "get": { + "operationId": "getV2SupportedNetworks", + "summary": "Get supported networks (CAIP-2)", + "description": "Returns the list of supported networks, keyed by CAIP-2 chain ID.", + "tags": ["Supported Networks"], + "responses": { + "200": { + "description": "The supported networks, split by level of support.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/SupportedNetworks" + } + } + } + } + } + } + }, + "/v1/exchange-rates": { + "get": { + "operationId": "getV1ExchangeRates", + "summary": "Get exchange rates", + "description": "Returns a list of exchange rates for all supported currencies against the given base currency.", + "tags": ["Exchange Rates"], + "parameters": [ + { + "name": "baseCurrency", + "in": "query", + "required": true, + "description": "The base currency to convert rates against.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Exchange rates keyed by currency ticker.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ExchangeRates" + } + } + } + } + } + } + }, + "/v1/exchange-rates/fiat": { + "get": { + "operationId": "getV1FiatExchangeRates", + "summary": "Get fiat exchange rates", + "description": "Returns a list of exchange rates for all supported fiat currencies.", + "tags": ["Exchange Rates"], + "responses": { + "200": { + "description": "Exchange rates keyed by currency ticker.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ExchangeRates" + } + } + } + } + } + } + }, + "/v1/spot-prices": { + "get": { + "operationId": "getV1SpotPricesByCoinIds", + "summary": "Get spot prices by CoinGecko coin IDs", + "description": "Returns a list of spot prices for a given list of CoinGecko coin IDs.", + "tags": ["Spot Prices"], + "parameters": [ + { + "name": "coinIds", + "in": "query", + "required": true, + "description": "Comma-separated CoinGecko IDs of the coins to get prices for.", + "schema": { + "type": "string" + } + }, + { + "name": "vsCurrency", + "in": "query", + "required": false, + "description": "Currency to convert prices to.", + "schema": { + "$ref": "#/components/schemas/VsCurrency" + } + } + ], + "responses": { + "200": { + "description": "Spot prices keyed by CoinGecko coin ID.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CoinGeckoSpotPrices" + } + } + } + } + } + } + }, + "/v1/spot-prices/{coinId}": { + "get": { + "operationId": "getV1SpotPriceByCoinId", + "summary": "Get spot price by CoinGecko coin ID", + "description": "Returns the spot price for a supported CoinGecko coin ID.", + "tags": ["Spot Prices"], + "parameters": [ + { + "name": "coinId", + "in": "path", + "required": true, + "description": "CoinGecko ID of the coin to get the price for.", + "schema": { + "type": "string" + } + }, + { + "name": "vsCurrency", + "in": "query", + "required": false, + "description": "Currency to convert the price to.", + "schema": { + "$ref": "#/components/schemas/VsCurrency" + } + } + ], + "responses": { + "200": { + "description": "The spot price of the coin.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CoinGeckoSpotPrice" + } + } + } + } + } + } + }, + "/v2/chains/{chainId}/spot-prices": { + "get": { + "operationId": "getV2SpotPrices", + "summary": "Get spot prices with market data by token addresses", + "description": "Returns spot prices with full market data for a given list of token addresses on a chain.", + "tags": ["Spot Prices"], + "parameters": [ + { + "name": "chainId", + "in": "path", + "required": true, + "description": "Decimal chain ID of the network to query.", + "schema": { + "type": "number" + } + }, + { + "name": "tokenAddresses", + "in": "query", + "required": true, + "description": "Comma-separated token contract addresses to get prices for.", + "schema": { + "type": "string" + } + }, + { + "name": "vsCurrency", + "in": "query", + "required": false, + "description": "Currency to convert prices to.", + "schema": { + "$ref": "#/components/schemas/VsCurrency" + } + }, + { + "name": "includeMarketData", + "in": "query", + "required": false, + "description": "Whether to include market data in the response.", + "schema": { + "type": "boolean", + "default": true + } + } + ], + "responses": { + "200": { + "description": "Market data keyed by lowercased token contract address.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/MarketDataSpotPrices" + } + } + } + } + } + } + }, + "/v3/spot-prices": { + "get": { + "operationId": "getV3SpotPrices", + "summary": "Get spot prices by CAIP-19 asset IDs", + "description": "Returns a list of spot prices for a given list of CAIP-19 asset IDs.", + "tags": ["Spot Prices"], + "parameters": [ + { + "name": "assetIds", + "in": "query", + "required": true, + "description": "Comma-separated CAIP-19 asset IDs to get prices for.", + "schema": { + "type": "string" + } + }, + { + "name": "vsCurrency", + "in": "query", + "required": false, + "description": "Currency to convert prices to.", + "schema": { + "$ref": "#/components/schemas/VsCurrency" + } + }, + { + "name": "includeMarketData", + "in": "query", + "required": false, + "description": "Whether to include market data in the response.", + "schema": { + "type": "boolean", + "default": false + } + }, + { + "name": "cacheOnly", + "in": "query", + "required": false, + "description": "Whether to only return prices that are already cached.", + "schema": { + "type": "boolean", + "default": false + } + } + ], + "responses": { + "200": { + "description": "Spot prices keyed by CAIP-19 asset ID. Unknown assets map to null.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/V3SpotPrices" + } + } + } + } + } + } + }, + "/v1/chains/{chainId}/historical-prices/{tokenAddress}": { + "get": { + "operationId": "getV1HistoricalPrices", + "summary": "Get historical prices by token address", + "description": "Returns historical prices for a single token on a chain.", + "tags": ["Historical Prices"], + "parameters": [ + { + "name": "chainId", + "in": "path", + "required": true, + "description": "Decimal chain ID of the network to query.", + "schema": { + "type": "number" + } + }, + { + "name": "tokenAddress", + "in": "path", + "required": true, + "description": "Contract address of the token to get prices for.", + "schema": { + "type": "string" + } + }, + { + "name": "vsCurrency", + "in": "query", + "required": false, + "description": "Currency to convert prices to.", + "schema": { + "$ref": "#/components/schemas/VsCurrency" + } + }, + { + "name": "timePeriod", + "in": "query", + "required": false, + "description": "Time period for the historical prices (e.g. 1d, 7d, 1m, 3m, 1y, 1000d).", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The historical prices of the token.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HistoricalPrices" + } + } + } + } + } + } + }, + "/v3/historical-prices/{chainId}/{assetType}": { + "get": { + "operationId": "getV3HistoricalPrices", + "summary": "Get historical prices by CAIP-19 asset ID", + "description": "Returns historical prices, market caps and total volumes for a CAIP-19 asset.", + "tags": ["Historical Prices"], + "parameters": [ + { + "name": "chainId", + "in": "path", + "required": true, + "description": "CAIP-2 chain ID of the network to query (e.g. eip155:1).", + "schema": { + "type": "string" + } + }, + { + "name": "assetType", + "in": "path", + "required": true, + "description": "Asset type portion of the CAIP-19 asset ID (e.g. slip44:60).", + "schema": { + "type": "string" + } + }, + { + "name": "vsCurrency", + "in": "query", + "required": false, + "description": "Currency to convert prices to.", + "schema": { + "$ref": "#/components/schemas/VsCurrency" + } + }, + { + "name": "timePeriod", + "in": "query", + "required": false, + "description": "Time period for the historical prices (e.g. 1d, 7d, 1m, 3m, 1y, 1000d).", + "schema": { + "type": "string" + } + }, + { + "name": "from", + "in": "query", + "required": false, + "description": "Start of the time range as a Unix timestamp in seconds.", + "schema": { + "type": "number" + } + }, + { + "name": "to", + "in": "query", + "required": false, + "description": "End of the time range as a Unix timestamp in seconds.", + "schema": { + "type": "number" + } + }, + { + "name": "interval", + "in": "query", + "required": false, + "description": "Data point interval.", + "schema": { + "type": "string", + "enum": ["5m", "hourly", "daily"] + } + } + ], + "responses": { + "200": { + "description": "The historical prices of the asset.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/V3HistoricalPrices" + } + } + } + } + } + } + }, + "/v2/chains/{chainId}/top-tokens": { + "get": { + "operationId": "getV2TopTokens", + "summary": "Get top tokens by market cap", + "description": "Returns the top tokens on a chain, ordered by market cap.", + "tags": ["Top Tokens"], + "parameters": [ + { + "name": "chainId", + "in": "path", + "required": true, + "description": "Decimal chain ID of the network to query.", + "schema": { + "type": "number" + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "description": "Maximum number of tokens to return.", + "schema": { + "type": "number", + "default": 100, + "minimum": 1, + "maximum": 300 + } + }, + { + "name": "vsCurrency", + "in": "query", + "required": false, + "description": "Currency to convert prices to.", + "schema": { + "$ref": "#/components/schemas/VsCurrency" + } + } + ], + "responses": { + "200": { + "description": "The top tokens ordered by market cap.", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/TopToken" + } + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "VsCurrency": { + "type": "string", + "description": "A currency that prices can be denominated in.", + "default": "usd", + "enum": [ + "btc", + "eth", + "ltc", + "bch", + "bnb", + "eos", + "xrp", + "xlm", + "link", + "dot", + "yfi", + "usd", + "aed", + "ars", + "aud", + "bdt", + "bhd", + "bmd", + "brl", + "cad", + "chf", + "clp", + "cny", + "czk", + "dkk", + "eur", + "gbp", + "gel", + "hkd", + "huf", + "idr", + "ils", + "inr", + "jpy", + "krw", + "kwd", + "lkr", + "mmk", + "mxn", + "myr", + "ngn", + "nok", + "nzd", + "php", + "pkr", + "pln", + "rub", + "sar", + "sek", + "sgd", + "thb", + "try", + "twd", + "uah", + "vef", + "vnd", + "zar" + ] + }, + "SupportedNetworks": { + "type": "object", + "description": "Networks supported by the Price API, split by level of support.", + "properties": { + "fullSupport": { + "type": "array", + "description": "Chain IDs with full price support.", + "items": { + "type": "string" + } + }, + "partialSupport": { + "type": "array", + "description": "Chain IDs with partial price support.", + "items": { + "type": "string" + } + } + }, + "required": ["fullSupport", "partialSupport"] + }, + "ExchangeRateInfo": { + "type": "object", + "description": "Exchange rate details for a single currency.", + "properties": { + "name": { + "type": "string", + "description": "Human-readable name of the currency." + }, + "ticker": { + "type": "string", + "description": "Ticker symbol of the currency." + }, + "value": { + "type": "number", + "description": "Exchange rate against the base currency." + }, + "currencyType": { + "type": "string", + "description": "Whether the currency is a cryptocurrency or fiat currency.", + "enum": ["crypto", "fiat"] + } + }, + "required": ["name", "ticker", "value", "currencyType"] + }, + "ExchangeRates": { + "type": "object", + "description": "Exchange rates keyed by currency ticker.", + "additionalProperties": { + "$ref": "#/components/schemas/ExchangeRateInfo" + } + }, + "CoinGeckoSpotPrice": { + "type": "object", + "description": "Spot price and market data for a CoinGecko-listed coin.", + "properties": { + "id": { + "type": "string", + "description": "CoinGecko coin ID." + }, + "price": { + "type": "number", + "description": "Current price in the requested currency." + }, + "marketCap": { + "type": "number", + "description": "Market capitalization." + }, + "allTimeHigh": { + "type": "number", + "description": "All-time high price." + }, + "allTimeLow": { + "type": "number", + "description": "All-time low price." + }, + "totalVolume": { + "type": "number", + "description": "Total trading volume." + }, + "high1d": { + "type": "number", + "description": "24h high price." + }, + "low1d": { + "type": "number", + "description": "24h low price." + }, + "circulatingSupply": { + "type": "number", + "description": "Circulating supply." + }, + "dilutedMarketCap": { + "type": "number", + "description": "Fully diluted market cap." + }, + "marketCapPercentChange1d": { + "type": "number", + "description": "Market cap 24h change percentage." + }, + "priceChange1d": { + "type": "number", + "description": "24h price change amount." + }, + "pricePercentChange1h": { + "type": "number", + "description": "1h price change percentage." + }, + "pricePercentChange1d": { + "type": "number", + "description": "24h price change percentage." + }, + "pricePercentChange7d": { + "type": "number", + "description": "7d price change percentage." + }, + "pricePercentChange14d": { + "type": "number", + "description": "14d price change percentage." + }, + "pricePercentChange30d": { + "type": "number", + "description": "30d price change percentage." + }, + "pricePercentChange200d": { + "type": "number", + "description": "200d price change percentage." + }, + "pricePercentChange1y": { + "type": "number", + "description": "1y price change percentage." + } + }, + "required": ["id", "price"] + }, + "CoinGeckoSpotPrices": { + "type": "object", + "description": "Spot prices keyed by CoinGecko coin ID.", + "additionalProperties": { + "$ref": "#/components/schemas/CoinGeckoSpotPrice" + } + }, + "MarketData": { + "type": "object", + "description": "Market data for a token, as returned by the v2 spot prices endpoint.", + "properties": { + "price": { + "type": "number", + "description": "Current price in the requested currency." + }, + "currency": { + "type": "string", + "description": "Currency the price is denominated in." + }, + "priceChange1d": { + "type": "number", + "description": "24h price change amount." + }, + "pricePercentChange1d": { + "type": "number", + "description": "24h price change percentage." + }, + "pricePercentChange1h": { + "type": "number", + "description": "1h price change percentage." + }, + "pricePercentChange7d": { + "type": "number", + "description": "7d price change percentage." + }, + "pricePercentChange14d": { + "type": "number", + "description": "14d price change percentage." + }, + "pricePercentChange30d": { + "type": "number", + "description": "30d price change percentage." + }, + "pricePercentChange200d": { + "type": "number", + "description": "200d price change percentage." + }, + "pricePercentChange1y": { + "type": "number", + "description": "1y price change percentage." + }, + "marketCap": { + "type": "number", + "description": "Market capitalization." + }, + "marketCapPercentChange1d": { + "type": "number", + "description": "Market cap 24h change percentage." + }, + "allTimeHigh": { + "type": "number", + "description": "All-time high price." + }, + "allTimeLow": { + "type": "number", + "description": "All-time low price." + }, + "high1d": { + "type": "number", + "description": "24h high price." + }, + "low1d": { + "type": "number", + "description": "24h low price." + }, + "totalVolume": { + "type": "number", + "description": "Total trading volume." + }, + "circulatingSupply": { + "type": "number", + "description": "Circulating supply." + }, + "dilutedMarketCap": { + "type": "number", + "description": "Fully diluted market cap." + } + }, + "required": ["price", "currency"] + }, + "MarketDataSpotPrices": { + "type": "object", + "description": "Market data keyed by lowercased token contract address.", + "additionalProperties": { + "$ref": "#/components/schemas/MarketData" + } + }, + "V3SpotPrice": { + "type": "object", + "description": "Spot price and optional market data for a CAIP-19 asset.", + "properties": { + "price": { + "type": "number", + "description": "Current price in the requested currency." + }, + "pricePercentChange1d": { + "type": "number", + "description": "24h price change percentage." + }, + "marketCap": { + "type": "number", + "description": "Market capitalization." + }, + "totalVolume": { + "type": "number", + "description": "Total trading volume." + } + }, + "required": ["price"] + }, + "V3SpotPrices": { + "type": "object", + "description": "Spot prices keyed by CAIP-19 asset ID. Assets without a known price map to null.", + "additionalProperties": { + "oneOf": [ + { + "$ref": "#/components/schemas/V3SpotPrice" + }, + { + "type": "null" + } + ] + } + }, + "PricePoint": { + "type": "array", + "description": "A [timestamp, value] tuple. The timestamp is a Unix timestamp in milliseconds.", + "prefixItems": [ + { + "type": "number", + "description": "Unix timestamp in milliseconds." + }, + { + "type": "number", + "description": "Value at the given timestamp." + } + ], + "items": false, + "minItems": 2, + "maxItems": 2 + }, + "HistoricalPrices": { + "type": "object", + "description": "Historical prices for a token.", + "properties": { + "prices": { + "type": "array", + "description": "Price data points.", + "items": { + "$ref": "#/components/schemas/PricePoint" + } + } + }, + "required": ["prices"] + }, + "V3HistoricalPrices": { + "type": "object", + "description": "Historical prices, market caps and total volumes for a CAIP-19 asset.", + "properties": { + "prices": { + "type": "array", + "description": "Price data points.", + "items": { + "$ref": "#/components/schemas/PricePoint" + } + }, + "marketCaps": { + "type": "array", + "description": "Market cap data points.", + "items": { + "$ref": "#/components/schemas/PricePoint" + } + }, + "totalVolumes": { + "type": "array", + "description": "Total volume data points.", + "items": { + "$ref": "#/components/schemas/PricePoint" + } + } + }, + "required": ["prices"] + }, + "TopToken": { + "type": "object", + "description": "A token in the top tokens list.", + "properties": { + "assetId": { + "type": "string", + "description": "CAIP-19 asset ID of the token." + }, + "name": { + "type": "string", + "description": "Human-readable name of the token." + }, + "symbol": { + "type": "string", + "description": "Ticker symbol of the token." + }, + "price": { + "type": "number", + "description": "Current price in the requested currency." + }, + "marketCap": { + "type": "number", + "description": "Market capitalization." + } + }, + "required": ["assetId", "name", "symbol", "price", "marketCap"] + } + } + } +} diff --git a/packages/core-backend/codegen/tsconfig.json b/packages/core-backend/codegen/tsconfig.json new file mode 100644 index 0000000000..a5e14b963f --- /dev/null +++ b/packages/core-backend/codegen/tsconfig.json @@ -0,0 +1,21 @@ +{ + /** + * Standalone configuration for the code generation tooling in this + * directory (the Kubb config and custom Kubb plugins). These files are + * executed by the Kubb CLI directly (via jiti) and are never built or + * published, so this project is type-check only. + * + * It intentionally does not extend `tsconfig.packages.json`: codegen files + * are Node tooling, not package source, and use bundler-style module + * resolution to match how the Kubb CLI loads them. + */ + "extends": "../../../tsconfig.base.json", + "compilerOptions": { + "composite": false, + "module": "ESNext", + "moduleResolution": "Bundler", + "noEmit": true, + "types": ["node"] + }, + "include": ["./**/*.ts"] +} diff --git a/packages/core-backend/codegen/utils/casing.ts b/packages/core-backend/codegen/utils/casing.ts new file mode 100644 index 0000000000..cecbb96f76 --- /dev/null +++ b/packages/core-backend/codegen/utils/casing.ts @@ -0,0 +1,45 @@ +/** + * Splits a name into its word parts, understanding camelCase, PascalCase, + * snake_case, kebab-case and digit boundaries. + * + * @param name - The name to split. + * @returns The word parts. + */ +function splitWords(name: string): string[] { + return ( + name + .replace(/([a-z0-9])([A-Z])/gu, '$1 $2') + .replace(/([A-Z]+)([A-Z][a-z])/gu, '$1 $2') + .match(/[A-Za-z0-9]+/gu) ?? [] + ); +} + +/** + * Converts a name to camelCase. + * + * @param name - The name to convert. + * @returns The camelCase name. + */ +export function camelCase(name: string): string { + const words = splitWords(name); + return words + .map((word, index) => + index === 0 + ? word.charAt(0).toLowerCase() + word.slice(1) + : word.charAt(0).toUpperCase() + word.slice(1), + ) + .join(''); +} + +/** + * Converts a name to PascalCase. + * + * @param name - The name to convert. + * @returns The PascalCase name. + */ +export function pascalCase(name: string): string { + const words = splitWords(name); + return words + .map((word) => word.charAt(0).toUpperCase() + word.slice(1)) + .join(''); +} diff --git a/packages/core-backend/jest.config.js b/packages/core-backend/jest.config.js index 4512a71fcd..bfdfa16fde 100644 --- a/packages/core-backend/jest.config.js +++ b/packages/core-backend/jest.config.js @@ -18,6 +18,10 @@ module.exports = merge(baseConfig, { testEnvironment: 'jsdom', testEnvironmentOptions: {}, + // Exclude code generated from OpenAPI documents by Kubb (`yarn codegen`) + // from coverage. + coveragePathIgnorePatterns: ['/src/generated/'], + // An object that configures minimum threshold enforcement for coverage results coverageThreshold: { global: { diff --git a/packages/core-backend/package.json b/packages/core-backend/package.json index a3fb2b39e7..2561b27756 100644 --- a/packages/core-backend/package.json +++ b/packages/core-backend/package.json @@ -32,6 +32,26 @@ "default": "./dist/index.cjs" } }, + "./mocks": { + "import": { + "types": "./dist/mocks/index.d.mts", + "default": "./dist/mocks/index.mjs" + }, + "require": { + "types": "./dist/mocks/index.d.cts", + "default": "./dist/mocks/index.cjs" + } + }, + "./price-api": { + "import": { + "types": "./dist/price-api/index.d.mts", + "default": "./dist/price-api/index.mjs" + }, + "require": { + "types": "./dist/price-api/index.d.cts", + "default": "./dist/price-api/index.cjs" + } + }, "./package.json": "./package.json" }, "publishConfig": { @@ -39,11 +59,12 @@ "registry": "https://registry.npmjs.org/" }, "scripts": { - "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references", - "build:all": "ts-bridge --project tsconfig.build.json --verbose --clean", + "build": "yarn codegen && ts-bridge --project tsconfig.build.json --verbose --clean --no-references", + "build:all": "yarn codegen && ts-bridge --project tsconfig.build.json --verbose --clean", "build:docs": "typedoc", "changelog:update": "../../scripts/update-changelog.sh @metamask/core-backend", "changelog:validate": "../../scripts/validate-changelog.sh @metamask/core-backend", + "codegen": "kubb generate --config codegen/kubb.config.ts && node codegen/annotate-msw-handlers.mjs", "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --check", "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --generate", "since-latest-release": "../../scripts/since-latest-release.sh", @@ -58,24 +79,45 @@ "@metamask/keyring-controller": "^27.1.0", "@metamask/messenger": "^2.0.0", "@metamask/profile-sync-controller": "^28.2.0", + "@metamask/superstruct": "^3.3.0", "@metamask/utils": "^11.11.0", "@tanstack/query-core": "^5.62.16", "async-mutex": "^0.5.0", "uuid": "^8.3.2" }, "devDependencies": { + "@faker-js/faker": "^9.9.0", + "@kubb/cli": "^4.39.2", + "@kubb/core": "^4.39.2", + "@kubb/plugin-faker": "^4.39.2", + "@kubb/plugin-msw": "^4.39.2", + "@kubb/plugin-oas": "^4.39.2", + "@kubb/plugin-ts": "^4.39.2", "@metamask/auto-changelog": "^6.1.0", "@ts-bridge/cli": "^0.6.4", "@types/jest": "^29.5.14", "deepmerge": "^4.2.2", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", + "msw": "~2.10.5", "ts-jest": "^29.2.5", "tsx": "^4.20.5", "typedoc": "^0.25.13", "typedoc-plugin-missing-exports": "^2.0.0", "typescript": "~5.3.3" }, + "peerDependencies": { + "@faker-js/faker": "^9.9.0", + "msw": "^2.0.0" + }, + "peerDependenciesMeta": { + "@faker-js/faker": { + "optional": true + }, + "msw": { + "optional": true + } + }, "engines": { "node": "^18.18 || >=20" } diff --git a/packages/core-backend/src/api/prices/query-client.test.ts b/packages/core-backend/src/api/prices/query-client.test.ts new file mode 100644 index 0000000000..67f33692a7 --- /dev/null +++ b/packages/core-backend/src/api/prices/query-client.test.ts @@ -0,0 +1,229 @@ +/** + * Integration tests for the generated Price API bindings + * (`src/generated/price-api`, produced by `yarn codegen`) and the + * {@link PricesApiRequestClient} that backs them. + * + * @jest-environment node + */ + +import { assert, is } from '@metamask/superstruct'; +import { QueryClient } from '@tanstack/query-core'; +import { getResponse } from 'msw'; + +import { PricesApiRequestClient } from './query-client'; +import { + createCoinGeckoSpotPrice, + createExchangeRateInfo, + createGetV1SupportedNetworksQueryResponse, + createHistoricalPrices, + createMarketData, + createSupportedNetworks, + createTopToken, + createV3SpotPrice, +} from '../../generated/price-api/mocks'; +import { + getV1SupportedNetworksHandler, + handlers, +} from '../../generated/price-api/msw'; +import { + fetchV1HistoricalPrices, + fetchV1SupportedNetworks, + fetchV3SpotPrices, + getV3SpotPricesQueryKey, + getV3SpotPricesQueryOptions, +} from '../../generated/price-api/queries'; +import { + CoinGeckoSpotPriceStruct, + ExchangeRateInfoStruct, + HistoricalPricesStruct, + MarketDataStruct, + SupportedNetworksStruct, + TopTokenStruct, + V3SpotPriceStruct, +} from '../../generated/price-api/schemas'; + +/** + * Routes all `fetch` calls through the generated MSW handlers, so requests + * made by the `BaseApiClient` transport are answered with the generated mock + * data. + * + * @param requestHandlers - The MSW handlers to serve responses from. + */ +function serveMswHandlers( + requestHandlers: Parameters[0], +): void { + (globalThis as { fetch: unknown }).fetch = jest.fn( + async (input: string | URL): Promise => { + const response = await getResponse( + requestHandlers, + new Request(String(input)), + ); + if (!response) { + throw new Error(`No MSW handler matched: ${String(input)}`); + } + return response; + }, + ); +} + +/** + * Creates a request client with caching and retries disabled. + * + * @returns The request client under test. + */ +function createTestClient(): PricesApiRequestClient { + return new PricesApiRequestClient({ + clientProduct: 'test-client', + clientVersion: '1.0.0', + queryClient: new QueryClient({ + defaultOptions: { + queries: { + retry: false, + gcTime: 0, + staleTime: 0, + }, + }, + }), + }); +} + +describe('generated Price API bindings', () => { + describe('generated mocks and structs', () => { + it.each([ + ['SupportedNetworks', createSupportedNetworks(), SupportedNetworksStruct], + ['ExchangeRateInfo', createExchangeRateInfo(), ExchangeRateInfoStruct], + [ + 'CoinGeckoSpotPrice', + createCoinGeckoSpotPrice(), + CoinGeckoSpotPriceStruct, + ], + ['MarketData', createMarketData(), MarketDataStruct], + ['V3SpotPrice', createV3SpotPrice(), V3SpotPriceStruct], + ['HistoricalPrices', createHistoricalPrices(), HistoricalPricesStruct], + ['TopToken', createTopToken(), TopTokenStruct], + ])('the generated %s mock satisfies its struct', (_name, mock, struct) => { + expect(is(mock, struct)).toBe(true); + }); + + it('rejects data that does not match the struct', () => { + expect(() => + assert({ fullSupport: 'not-an-array' }, SupportedNetworksStruct), + ).toThrow( + 'At path: fullSupport -- Expected an array value, but received: "not-an-array"', + ); + }); + }); + + describe('query options', () => { + it('builds a scoped query key including the parameters', () => { + expect( + getV3SpotPricesQueryKey({ assetIds: 'eip155:1/slip44:60' }), + ).toStrictEqual([ + 'prices', + 'getV3SpotPrices', + { assetIds: 'eip155:1/slip44:60' }, + ]); + }); + + it('exposes TanStack Query options usable with any QueryClient', async () => { + const client = createTestClient(); + const request = jest + .spyOn(client, 'request') + .mockResolvedValue({ 'eip155:1/slip44:60': { price: 3254.48 } }); + + const options = getV3SpotPricesQueryOptions(client, { + assetIds: 'eip155:1/slip44:60', + }); + const result = await client.queryClient.fetchQuery(options); + + expect(request).toHaveBeenCalledWith({ + method: 'get', + url: '/v3/spot-prices', + params: { assetIds: 'eip155:1/slip44:60' }, + signal: expect.any(AbortSignal), + }); + expect(result).toStrictEqual({ + 'eip155:1/slip44:60': { price: 3254.48 }, + }); + }); + + it('rejects responses that fail struct validation', async () => { + const client = createTestClient(); + jest + .spyOn(client, 'request') + .mockResolvedValue({ 'eip155:1/slip44:60': { price: 'not-a-number' } }); + + await expect( + fetchV3SpotPrices(client, { assetIds: 'eip155:1/slip44:60' }), + ).rejects.toThrow( + 'At path: eip155:1/slip44:60 -- Expected the value to satisfy a union of `type | literal`, but received: [object Object]', + ); + }); + }); + + describe('end-to-end through the generated MSW handlers', () => { + it('fetches and validates mock data served by the handlers', async () => { + serveMswHandlers(handlers); + const client = createTestClient(); + + const networks = await fetchV1SupportedNetworks(client); + + // The generated mocks are seeded, so the round-trip result is exactly + // the generated mock data — and it satisfies the generated struct. + expect(networks).toStrictEqual( + createGetV1SupportedNetworksQueryResponse(), + ); + expect(is(networks, SupportedNetworksStruct)).toBe(true); + }); + + it('interpolates path parameters and serializes query parameters', async () => { + serveMswHandlers(handlers); + const client = createTestClient(); + + const prices = await fetchV1HistoricalPrices( + client, + { chainId: 1, tokenAddress: '0x6b175474e89094c44da98b954eedeac495271d0f' }, + { vsCurrency: 'eur', timePeriod: '7d' }, + ); + + expect(is(prices, HistoricalPricesStruct)).toBe(true); + expect(globalThis.fetch).toHaveBeenCalledWith( + 'https://price.api.cx.metamask.io/v1/chains/1/historical-prices/0x6b175474e89094c44da98b954eedeac495271d0f?vsCurrency=eur&timePeriod=7d', + expect.objectContaining({ method: 'GET' }), + ); + }); + + it('supports overriding handler data', async () => { + const supportedNetworks = { + fullSupport: ['eip155:1'], + partialSupport: [], + }; + serveMswHandlers([getV1SupportedNetworksHandler(supportedNetworks)]); + const client = createTestClient(); + + expect(await fetchV1SupportedNetworks(client)).toStrictEqual( + supportedNetworks, + ); + }); + + it('deduplicates requests through the QueryClient', async () => { + serveMswHandlers(handlers); + const client = new PricesApiRequestClient({ + clientProduct: 'test-client', + queryClient: new QueryClient({ + defaultOptions: { + queries: { retry: false, staleTime: 60_000 }, + }, + }), + }); + + const [first, second] = await Promise.all([ + fetchV1SupportedNetworks(client), + fetchV1SupportedNetworks(client), + ]); + + expect(first).toStrictEqual(second); + expect(globalThis.fetch).toHaveBeenCalledTimes(1); + }); + }); +}); diff --git a/packages/core-backend/src/api/prices/query-client.ts b/packages/core-backend/src/api/prices/query-client.ts new file mode 100644 index 0000000000..361252bb1b --- /dev/null +++ b/packages/core-backend/src/api/prices/query-client.ts @@ -0,0 +1,46 @@ +/** + * Request client backing the generated Price API query-core bindings (see + * `src/generated/price-api/queries`). + */ + +import { API_URLS, BaseApiClient } from '../base-client'; +import type { ApiRequestArgs, ApiRequestClient } from '../query-runtime'; + +/** + * An {@link ApiRequestClient} for the Price API, backed by the shared + * `BaseApiClient` transport (auth headers, retries and caching included). + * + * Use it with the generated query-core bindings: + * + * ```ts + * import { PricesApiRequestClient } from '@metamask/core-backend'; + * import { fetchV3SpotPrices } from '@metamask/core-backend/price-api'; + * + * const client = new PricesApiRequestClient({ clientProduct: 'metamask-extension' }); + * const prices = await fetchV3SpotPrices(client, { + * assetIds: 'eip155:1/slip44:60', + * }); + * ``` + */ +export class PricesApiRequestClient + extends BaseApiClient + implements ApiRequestClient +{ + /** + * Perform a request against the Price API. + * + * Note: the shared `BaseApiClient` transport only issues GET requests, so + * the `method` of the request is currently ignored. All Price API + * operations are GETs. + * + * @param args - The request to perform. + * @returns The parsed JSON response. + */ + async request({ + url, + params, + signal, + }: ApiRequestArgs): Promise { + return this.fetch(API_URLS.PRICES, url, { signal, params }); + } +} diff --git a/packages/core-backend/src/api/query-runtime.ts b/packages/core-backend/src/api/query-runtime.ts new file mode 100644 index 0000000000..b4cdac9150 --- /dev/null +++ b/packages/core-backend/src/api/query-runtime.ts @@ -0,0 +1,45 @@ +/** + * Runtime contract between the generated TanStack query-core bindings (see + * `src/generated//queries`) and the hand-written API clients. + * + * The generated query options factories perform their requests through an + * {@link ApiRequestClient}, so any transport (the `BaseApiClient`, a plain + * `fetch` wrapper, a test double, ...) can back them. + */ + +import type { QueryClient } from '@tanstack/query-core'; + +export { getQueryOptionsOverrides } from './shared-types'; +export type { FetchOptions } from './shared-types'; + +/** + * A single HTTP request issued by a generated query. + */ +export type ApiRequestArgs = { + /** HTTP method of the request. */ + method: 'get' | 'post' | 'put' | 'patch' | 'delete' | 'head' | 'options'; + /** Path of the endpoint, relative to the API base URL. */ + url: string; + /** Query parameters to append to the URL. */ + params?: Record< + string, + string | string[] | number | number[] | boolean | undefined + >; + /** Abort signal forwarded from TanStack Query. */ + signal?: AbortSignal; +}; + +/** + * The client that generated queries perform their requests through. + */ +export type ApiRequestClient = { + /** The TanStack QueryClient used for caching and request deduplication. */ + queryClient: QueryClient; + /** + * Perform an HTTP request against the API. + * + * @param args - The request to perform. + * @returns The parsed JSON response. + */ + request(args: ApiRequestArgs): Promise; +}; diff --git a/packages/core-backend/src/generated/price-api/mocks/createCoinGeckoSpotPrice.ts b/packages/core-backend/src/generated/price-api/mocks/createCoinGeckoSpotPrice.ts new file mode 100644 index 0000000000..1d496d1c55 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createCoinGeckoSpotPrice.ts @@ -0,0 +1,18 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { CoinGeckoSpotPrice } from "../types/CoinGeckoSpotPrice"; +import { faker } from "@faker-js/faker"; + +/** + * @description Spot price and market data for a CoinGecko-listed coin. + */ +export function createCoinGeckoSpotPrice(data?: Partial): CoinGeckoSpotPrice { + faker.seed([220]) + return { + ...{"id": faker.string.alpha(),"price": faker.number.float(),"marketCap": faker.number.float(),"allTimeHigh": faker.number.float(),"allTimeLow": faker.number.float(),"totalVolume": faker.number.float(),"high1d": faker.number.float(),"low1d": faker.number.float(),"circulatingSupply": faker.number.float(),"dilutedMarketCap": faker.number.float(),"marketCapPercentChange1d": faker.number.float(),"priceChange1d": faker.number.float(),"pricePercentChange1h": faker.number.float(),"pricePercentChange1d": faker.number.float(),"pricePercentChange7d": faker.number.float(),"pricePercentChange14d": faker.number.float(),"pricePercentChange30d": faker.number.float(),"pricePercentChange200d": faker.number.float(),"pricePercentChange1y": faker.number.float()}, + ...data || {} + } +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createCoinGeckoSpotPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createCoinGeckoSpotPrices.ts new file mode 100644 index 0000000000..7349e73929 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createCoinGeckoSpotPrices.ts @@ -0,0 +1,19 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { CoinGeckoSpotPrices } from "../types/CoinGeckoSpotPrices"; +import { createCoinGeckoSpotPrice } from "./createCoinGeckoSpotPrice"; +import { faker } from "@faker-js/faker"; + +/** + * @description Spot prices keyed by CoinGecko coin ID. + */ +export function createCoinGeckoSpotPrices(data?: Partial): CoinGeckoSpotPrices { + faker.seed([220]) + return { + ...{}, + ...data || {} + } +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createExchangeRateInfo.ts b/packages/core-backend/src/generated/price-api/mocks/createExchangeRateInfo.ts new file mode 100644 index 0000000000..221c3ac705 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createExchangeRateInfo.ts @@ -0,0 +1,18 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { ExchangeRateInfo } from "../types/ExchangeRateInfo"; +import { faker } from "@faker-js/faker"; + +/** + * @description Exchange rate details for a single currency. + */ +export function createExchangeRateInfo(data?: Partial): ExchangeRateInfo { + faker.seed([220]) + return { + ...{"name": faker.string.alpha(),"ticker": faker.string.alpha(),"value": faker.number.float(),"currencyType": faker.helpers.arrayElement["currencyType"]>(["crypto", "fiat"])}, + ...data || {} + } +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createExchangeRates.ts b/packages/core-backend/src/generated/price-api/mocks/createExchangeRates.ts new file mode 100644 index 0000000000..3ef865cde2 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createExchangeRates.ts @@ -0,0 +1,18 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { ExchangeRates } from "../types/ExchangeRates"; +import { faker } from "@faker-js/faker"; + +/** + * @description Exchange rates keyed by currency ticker. + */ +export function createExchangeRates(data?: Partial): ExchangeRates { + faker.seed([220]) + return { + ...{}, + ...data || {} + } +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV1ExchangeRates.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV1ExchangeRates.ts new file mode 100644 index 0000000000..84282305cc --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV1ExchangeRates.ts @@ -0,0 +1,29 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV1ExchangeRates200, GetV1ExchangeRatesQueryParams, GetV1ExchangeRatesQueryResponse } from "../types/GetV1ExchangeRates"; +import { createExchangeRates } from "./createExchangeRates"; +import { faker } from "@faker-js/faker"; + +export function createGetV1ExchangeRatesQueryParams(data?: Partial): GetV1ExchangeRatesQueryParams { + faker.seed([220]) + return { + ...{"baseCurrency": faker.string.alpha()}, + ...data || {} + } +} + +/** + * @description Exchange rates keyed by currency ticker. + */ +export function createGetV1ExchangeRates200(data?: Partial): GetV1ExchangeRates200 { + faker.seed([220]) + return createExchangeRates(data) +} + +export function createGetV1ExchangeRatesQueryResponse(data?: Partial): GetV1ExchangeRatesQueryResponse { + faker.seed([220]) + return data || faker.helpers.arrayElement([createGetV1ExchangeRates200()]) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV1FiatExchangeRates.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV1FiatExchangeRates.ts new file mode 100644 index 0000000000..8f40013c4e --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV1FiatExchangeRates.ts @@ -0,0 +1,21 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV1FiatExchangeRates200, GetV1FiatExchangeRatesQueryResponse } from "../types/GetV1FiatExchangeRates"; +import { createExchangeRates } from "./createExchangeRates"; +import { faker } from "@faker-js/faker"; + +/** + * @description Exchange rates keyed by currency ticker. + */ +export function createGetV1FiatExchangeRates200(data?: Partial): GetV1FiatExchangeRates200 { + faker.seed([220]) + return createExchangeRates(data) +} + +export function createGetV1FiatExchangeRatesQueryResponse(data?: Partial): GetV1FiatExchangeRatesQueryResponse { + faker.seed([220]) + return data || faker.helpers.arrayElement([createGetV1FiatExchangeRates200()]) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV1HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV1HistoricalPrices.ts new file mode 100644 index 0000000000..b65497ef48 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV1HistoricalPrices.ts @@ -0,0 +1,35 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV1HistoricalPrices200, GetV1HistoricalPricesPathParams, GetV1HistoricalPricesQueryParams, GetV1HistoricalPricesQueryResponse } from "../types/GetV1HistoricalPrices"; +import { createHistoricalPrices } from "./createHistoricalPrices"; +import { createVsCurrency } from "./createVsCurrency"; +import { faker } from "@faker-js/faker"; + +export function createGetV1HistoricalPricesPathParams(data?: Partial): GetV1HistoricalPricesPathParams { + faker.seed([220]) + return { + ...{"chainId": faker.number.float(),"tokenAddress": faker.string.alpha()}, + ...data || {} + } +} + +export function createGetV1HistoricalPricesQueryParams(data?: Partial): GetV1HistoricalPricesQueryParams { + faker.seed([220]) + return { ...{get "vsCurrency"() { return createVsCurrency() },"timePeriod": faker.string.alpha(),...(data || {})} } +} + +/** + * @description The historical prices of the token. + */ +export function createGetV1HistoricalPrices200(data?: Partial): GetV1HistoricalPrices200 { + faker.seed([220]) + return createHistoricalPrices(data) +} + +export function createGetV1HistoricalPricesQueryResponse(data?: Partial): GetV1HistoricalPricesQueryResponse { + faker.seed([220]) + return data || faker.helpers.arrayElement([createGetV1HistoricalPrices200()]) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV1SpotPriceByCoinId.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV1SpotPriceByCoinId.ts new file mode 100644 index 0000000000..c9040dd185 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV1SpotPriceByCoinId.ts @@ -0,0 +1,35 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV1SpotPriceByCoinId200, GetV1SpotPriceByCoinIdPathParams, GetV1SpotPriceByCoinIdQueryParams, GetV1SpotPriceByCoinIdQueryResponse } from "../types/GetV1SpotPriceByCoinId"; +import { createCoinGeckoSpotPrice } from "./createCoinGeckoSpotPrice"; +import { createVsCurrency } from "./createVsCurrency"; +import { faker } from "@faker-js/faker"; + +export function createGetV1SpotPriceByCoinIdPathParams(data?: Partial): GetV1SpotPriceByCoinIdPathParams { + faker.seed([220]) + return { + ...{"coinId": faker.string.alpha()}, + ...data || {} + } +} + +export function createGetV1SpotPriceByCoinIdQueryParams(data?: Partial): GetV1SpotPriceByCoinIdQueryParams { + faker.seed([220]) + return { ...{get "vsCurrency"() { return createVsCurrency() },...(data || {})} } +} + +/** + * @description The spot price of the coin. + */ +export function createGetV1SpotPriceByCoinId200(data?: Partial): GetV1SpotPriceByCoinId200 { + faker.seed([220]) + return createCoinGeckoSpotPrice(data) +} + +export function createGetV1SpotPriceByCoinIdQueryResponse(data?: Partial): GetV1SpotPriceByCoinIdQueryResponse { + faker.seed([220]) + return data || faker.helpers.arrayElement([createGetV1SpotPriceByCoinId200()]) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV1SpotPricesByCoinIds.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV1SpotPricesByCoinIds.ts new file mode 100644 index 0000000000..0f7ecccaa7 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV1SpotPricesByCoinIds.ts @@ -0,0 +1,27 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV1SpotPricesByCoinIds200, GetV1SpotPricesByCoinIdsQueryParams, GetV1SpotPricesByCoinIdsQueryResponse } from "../types/GetV1SpotPricesByCoinIds"; +import { createCoinGeckoSpotPrices } from "./createCoinGeckoSpotPrices"; +import { createVsCurrency } from "./createVsCurrency"; +import { faker } from "@faker-js/faker"; + +export function createGetV1SpotPricesByCoinIdsQueryParams(data?: Partial): GetV1SpotPricesByCoinIdsQueryParams { + faker.seed([220]) + return { ...{"coinIds": faker.string.alpha(),get "vsCurrency"() { return createVsCurrency() },...(data || {})} } +} + +/** + * @description Spot prices keyed by CoinGecko coin ID. + */ +export function createGetV1SpotPricesByCoinIds200(data?: Partial): GetV1SpotPricesByCoinIds200 { + faker.seed([220]) + return createCoinGeckoSpotPrices(data) +} + +export function createGetV1SpotPricesByCoinIdsQueryResponse(data?: Partial): GetV1SpotPricesByCoinIdsQueryResponse { + faker.seed([220]) + return data || faker.helpers.arrayElement([createGetV1SpotPricesByCoinIds200()]) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV1SupportedNetworks.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV1SupportedNetworks.ts new file mode 100644 index 0000000000..6ec13376f0 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV1SupportedNetworks.ts @@ -0,0 +1,21 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV1SupportedNetworks200, GetV1SupportedNetworksQueryResponse } from "../types/GetV1SupportedNetworks"; +import { createSupportedNetworks } from "./createSupportedNetworks"; +import { faker } from "@faker-js/faker"; + +/** + * @description The supported networks, split by level of support. + */ +export function createGetV1SupportedNetworks200(data?: Partial): GetV1SupportedNetworks200 { + faker.seed([220]) + return createSupportedNetworks(data) +} + +export function createGetV1SupportedNetworksQueryResponse(data?: Partial): GetV1SupportedNetworksQueryResponse { + faker.seed([220]) + return data || faker.helpers.arrayElement([createGetV1SupportedNetworks200()]) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV2SpotPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV2SpotPrices.ts new file mode 100644 index 0000000000..7cc0b45444 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV2SpotPrices.ts @@ -0,0 +1,35 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV2SpotPrices200, GetV2SpotPricesPathParams, GetV2SpotPricesQueryParams, GetV2SpotPricesQueryResponse } from "../types/GetV2SpotPrices"; +import { createMarketDataSpotPrices } from "./createMarketDataSpotPrices"; +import { createVsCurrency } from "./createVsCurrency"; +import { faker } from "@faker-js/faker"; + +export function createGetV2SpotPricesPathParams(data?: Partial): GetV2SpotPricesPathParams { + faker.seed([220]) + return { + ...{"chainId": faker.number.float()}, + ...data || {} + } +} + +export function createGetV2SpotPricesQueryParams(data?: Partial): GetV2SpotPricesQueryParams { + faker.seed([220]) + return { ...{"tokenAddresses": faker.string.alpha(),get "vsCurrency"() { return createVsCurrency() },"includeMarketData": faker.datatype.boolean(),...(data || {})} } +} + +/** + * @description Market data keyed by lowercased token contract address. + */ +export function createGetV2SpotPrices200(data?: Partial): GetV2SpotPrices200 { + faker.seed([220]) + return createMarketDataSpotPrices(data) +} + +export function createGetV2SpotPricesQueryResponse(data?: Partial): GetV2SpotPricesQueryResponse { + faker.seed([220]) + return data || faker.helpers.arrayElement([createGetV2SpotPrices200()]) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV2SupportedNetworks.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV2SupportedNetworks.ts new file mode 100644 index 0000000000..b913aadcb2 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV2SupportedNetworks.ts @@ -0,0 +1,21 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV2SupportedNetworks200, GetV2SupportedNetworksQueryResponse } from "../types/GetV2SupportedNetworks"; +import { createSupportedNetworks } from "./createSupportedNetworks"; +import { faker } from "@faker-js/faker"; + +/** + * @description The supported networks, split by level of support. + */ +export function createGetV2SupportedNetworks200(data?: Partial): GetV2SupportedNetworks200 { + faker.seed([220]) + return createSupportedNetworks(data) +} + +export function createGetV2SupportedNetworksQueryResponse(data?: Partial): GetV2SupportedNetworksQueryResponse { + faker.seed([220]) + return data || faker.helpers.arrayElement([createGetV2SupportedNetworks200()]) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV2TopTokens.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV2TopTokens.ts new file mode 100644 index 0000000000..0fbef0cf38 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV2TopTokens.ts @@ -0,0 +1,38 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV2TopTokens200, GetV2TopTokensPathParams, GetV2TopTokensQueryParams, GetV2TopTokensQueryResponse } from "../types/GetV2TopTokens"; +import { createTopToken } from "./createTopToken"; +import { createVsCurrency } from "./createVsCurrency"; +import { faker } from "@faker-js/faker"; + +export function createGetV2TopTokensPathParams(data?: Partial): GetV2TopTokensPathParams { + faker.seed([220]) + return { + ...{"chainId": faker.number.float()}, + ...data || {} + } +} + +export function createGetV2TopTokensQueryParams(data?: Partial): GetV2TopTokensQueryParams { + faker.seed([220]) + return { ...{"limit": faker.number.float({ min: 1, max: 300 }),get "vsCurrency"() { return createVsCurrency() },...(data || {})} } +} + +/** + * @description The top tokens ordered by market cap. + */ +export function createGetV2TopTokens200(data?: GetV2TopTokens200): GetV2TopTokens200 { + faker.seed([220]) + return [ + ...faker.helpers.multiple(() => (createTopToken())), + ...data || [] + ] +} + +export function createGetV2TopTokensQueryResponse(data?: Partial): GetV2TopTokensQueryResponse { + faker.seed([220]) + return data || faker.helpers.arrayElement([createGetV2TopTokens200()]) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV3HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV3HistoricalPrices.ts new file mode 100644 index 0000000000..350f47f165 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV3HistoricalPrices.ts @@ -0,0 +1,35 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV3HistoricalPrices200, GetV3HistoricalPricesPathParams, GetV3HistoricalPricesQueryParams, GetV3HistoricalPricesQueryResponse } from "../types/GetV3HistoricalPrices"; +import { createV3HistoricalPrices } from "./createV3HistoricalPrices"; +import { createVsCurrency } from "./createVsCurrency"; +import { faker } from "@faker-js/faker"; + +export function createGetV3HistoricalPricesPathParams(data?: Partial): GetV3HistoricalPricesPathParams { + faker.seed([220]) + return { + ...{"chainId": faker.string.alpha(),"assetType": faker.string.alpha()}, + ...data || {} + } +} + +export function createGetV3HistoricalPricesQueryParams(data?: Partial): GetV3HistoricalPricesQueryParams { + faker.seed([220]) + return { ...{get "vsCurrency"() { return createVsCurrency() },"timePeriod": faker.string.alpha(),"from": faker.number.float(),"to": faker.number.float(),"interval": faker.helpers.arrayElement["interval"]>(["5m", "hourly", "daily"]),...(data || {})} } +} + +/** + * @description The historical prices of the asset. + */ +export function createGetV3HistoricalPrices200(data?: Partial): GetV3HistoricalPrices200 { + faker.seed([220]) + return createV3HistoricalPrices(data) +} + +export function createGetV3HistoricalPricesQueryResponse(data?: Partial): GetV3HistoricalPricesQueryResponse { + faker.seed([220]) + return data || faker.helpers.arrayElement([createGetV3HistoricalPrices200()]) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV3SpotPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV3SpotPrices.ts new file mode 100644 index 0000000000..33eba31903 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV3SpotPrices.ts @@ -0,0 +1,27 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV3SpotPrices200, GetV3SpotPricesQueryParams, GetV3SpotPricesQueryResponse } from "../types/GetV3SpotPrices"; +import { createV3SpotPrices } from "./createV3SpotPrices"; +import { createVsCurrency } from "./createVsCurrency"; +import { faker } from "@faker-js/faker"; + +export function createGetV3SpotPricesQueryParams(data?: Partial): GetV3SpotPricesQueryParams { + faker.seed([220]) + return { ...{"assetIds": faker.string.alpha(),get "vsCurrency"() { return createVsCurrency() },"includeMarketData": faker.datatype.boolean(),"cacheOnly": faker.datatype.boolean(),...(data || {})} } +} + +/** + * @description Spot prices keyed by CAIP-19 asset ID. Unknown assets map to null. + */ +export function createGetV3SpotPrices200(data?: Partial): GetV3SpotPrices200 { + faker.seed([220]) + return createV3SpotPrices(data) +} + +export function createGetV3SpotPricesQueryResponse(data?: Partial): GetV3SpotPricesQueryResponse { + faker.seed([220]) + return data || faker.helpers.arrayElement([createGetV3SpotPrices200()]) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createHistoricalPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createHistoricalPrices.ts new file mode 100644 index 0000000000..2021884ddf --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createHistoricalPrices.ts @@ -0,0 +1,16 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { HistoricalPrices } from "../types/HistoricalPrices"; +import { createPricePoint } from "./createPricePoint"; +import { faker } from "@faker-js/faker"; + +/** + * @description Historical prices for a token. + */ +export function createHistoricalPrices(data?: Partial): HistoricalPrices { + faker.seed([220]) + return { ...{get "prices"() { return faker.helpers.multiple(() => (createPricePoint())) },...(data || {})} } +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createMarketData.ts b/packages/core-backend/src/generated/price-api/mocks/createMarketData.ts new file mode 100644 index 0000000000..ccf836122f --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createMarketData.ts @@ -0,0 +1,18 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { MarketData } from "../types/MarketData"; +import { faker } from "@faker-js/faker"; + +/** + * @description Market data for a token, as returned by the v2 spot prices endpoint. + */ +export function createMarketData(data?: Partial): MarketData { + faker.seed([220]) + return { + ...{"price": faker.number.float(),"currency": faker.string.alpha(),"priceChange1d": faker.number.float(),"pricePercentChange1d": faker.number.float(),"pricePercentChange1h": faker.number.float(),"pricePercentChange7d": faker.number.float(),"pricePercentChange14d": faker.number.float(),"pricePercentChange30d": faker.number.float(),"pricePercentChange200d": faker.number.float(),"pricePercentChange1y": faker.number.float(),"marketCap": faker.number.float(),"marketCapPercentChange1d": faker.number.float(),"allTimeHigh": faker.number.float(),"allTimeLow": faker.number.float(),"high1d": faker.number.float(),"low1d": faker.number.float(),"totalVolume": faker.number.float(),"circulatingSupply": faker.number.float(),"dilutedMarketCap": faker.number.float()}, + ...data || {} + } +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createMarketDataSpotPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createMarketDataSpotPrices.ts new file mode 100644 index 0000000000..bd5ed0580b --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createMarketDataSpotPrices.ts @@ -0,0 +1,19 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { MarketDataSpotPrices } from "../types/MarketDataSpotPrices"; +import { createMarketData } from "./createMarketData"; +import { faker } from "@faker-js/faker"; + +/** + * @description Market data keyed by lowercased token contract address. + */ +export function createMarketDataSpotPrices(data?: Partial): MarketDataSpotPrices { + faker.seed([220]) + return { + ...{}, + ...data || {} + } +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createPricePoint.ts b/packages/core-backend/src/generated/price-api/mocks/createPricePoint.ts new file mode 100644 index 0000000000..38aee8563d --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createPricePoint.ts @@ -0,0 +1,15 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { PricePoint } from "../types/PricePoint"; +import { faker } from "@faker-js/faker"; + +/** + * @description A [timestamp, value] tuple. The timestamp is a Unix timestamp in milliseconds. + */ +export function createPricePoint(data?: PricePoint): PricePoint { + faker.seed([220]) + return [faker.number.float(), faker.number.float()] +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createSupportedNetworks.ts b/packages/core-backend/src/generated/price-api/mocks/createSupportedNetworks.ts new file mode 100644 index 0000000000..9e1035b241 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createSupportedNetworks.ts @@ -0,0 +1,18 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { SupportedNetworks } from "../types/SupportedNetworks"; +import { faker } from "@faker-js/faker"; + +/** + * @description Networks supported by the Price API, split by level of support. + */ +export function createSupportedNetworks(data?: Partial): SupportedNetworks { + faker.seed([220]) + return { + ...{"fullSupport": faker.helpers.multiple(() => (faker.string.alpha())),"partialSupport": faker.helpers.multiple(() => (faker.string.alpha()))}, + ...data || {} + } +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createTopToken.ts b/packages/core-backend/src/generated/price-api/mocks/createTopToken.ts new file mode 100644 index 0000000000..85745b3ea3 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createTopToken.ts @@ -0,0 +1,18 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { TopToken } from "../types/TopToken"; +import { faker } from "@faker-js/faker"; + +/** + * @description A token in the top tokens list. + */ +export function createTopToken(data?: Partial): TopToken { + faker.seed([220]) + return { + ...{"assetId": faker.string.alpha(),"name": faker.string.alpha(),"symbol": faker.string.alpha(),"price": faker.number.float(),"marketCap": faker.number.float()}, + ...data || {} + } +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createV3HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createV3HistoricalPrices.ts new file mode 100644 index 0000000000..c3356fb316 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createV3HistoricalPrices.ts @@ -0,0 +1,16 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { V3HistoricalPrices } from "../types/V3HistoricalPrices"; +import { createPricePoint } from "./createPricePoint"; +import { faker } from "@faker-js/faker"; + +/** + * @description Historical prices, market caps and total volumes for a CAIP-19 asset. + */ +export function createV3HistoricalPrices(data?: Partial): V3HistoricalPrices { + faker.seed([220]) + return { ...{get "prices"() { return faker.helpers.multiple(() => (createPricePoint())) },get "marketCaps"() { return faker.helpers.multiple(() => (createPricePoint())) },get "totalVolumes"() { return faker.helpers.multiple(() => (createPricePoint())) },...(data || {})} } +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createV3SpotPrice.ts b/packages/core-backend/src/generated/price-api/mocks/createV3SpotPrice.ts new file mode 100644 index 0000000000..ca8c32511c --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createV3SpotPrice.ts @@ -0,0 +1,18 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { V3SpotPrice } from "../types/V3SpotPrice"; +import { faker } from "@faker-js/faker"; + +/** + * @description Spot price and optional market data for a CAIP-19 asset. + */ +export function createV3SpotPrice(data?: Partial): V3SpotPrice { + faker.seed([220]) + return { + ...{"price": faker.number.float(),"pricePercentChange1d": faker.number.float(),"marketCap": faker.number.float(),"totalVolume": faker.number.float()}, + ...data || {} + } +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createV3SpotPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createV3SpotPrices.ts new file mode 100644 index 0000000000..91267816f8 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createV3SpotPrices.ts @@ -0,0 +1,19 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { V3SpotPrices } from "../types/V3SpotPrices"; +import { createV3SpotPrice } from "./createV3SpotPrice"; +import { faker } from "@faker-js/faker"; + +/** + * @description Spot prices keyed by CAIP-19 asset ID. Assets without a known price map to null. + */ +export function createV3SpotPrices(data?: Partial): V3SpotPrices { + faker.seed([220]) + return { + ...{}, + ...data || {} + } +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/createVsCurrency.ts b/packages/core-backend/src/generated/price-api/mocks/createVsCurrency.ts new file mode 100644 index 0000000000..27498e1522 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createVsCurrency.ts @@ -0,0 +1,15 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { VsCurrency } from "../types/VsCurrency"; +import { faker } from "@faker-js/faker"; + +/** + * @description A currency that prices can be denominated in. + */ +export function createVsCurrency(data?: Partial): VsCurrency { + faker.seed([220]) + return data || faker.helpers.arrayElement(["btc", "eth", "ltc", "bch", "bnb", "eos", "xrp", "xlm", "link", "dot", "yfi", "usd", "aed", "ars", "aud", "bdt", "bhd", "bmd", "brl", "cad", "chf", "clp", "cny", "czk", "dkk", "eur", "gbp", "gel", "hkd", "huf", "idr", "ils", "inr", "jpy", "krw", "kwd", "lkr", "mmk", "mxn", "myr", "ngn", "nok", "nzd", "php", "pkr", "pln", "rub", "sar", "sek", "sgd", "thb", "try", "twd", "uah", "vef", "vnd", "zar"]) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/mocks/index.ts b/packages/core-backend/src/generated/price-api/mocks/index.ts new file mode 100644 index 0000000000..6fe910c3ae --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/index.ts @@ -0,0 +1,25 @@ +export { createCoinGeckoSpotPrice } from "./createCoinGeckoSpotPrice"; +export { createCoinGeckoSpotPrices } from "./createCoinGeckoSpotPrices"; +export { createExchangeRateInfo } from "./createExchangeRateInfo"; +export { createExchangeRates } from "./createExchangeRates"; +export { createGetV1ExchangeRates200, createGetV1ExchangeRatesQueryParams, createGetV1ExchangeRatesQueryResponse } from "./createGetV1ExchangeRates"; +export { createGetV1FiatExchangeRates200, createGetV1FiatExchangeRatesQueryResponse } from "./createGetV1FiatExchangeRates"; +export { createGetV1HistoricalPrices200, createGetV1HistoricalPricesPathParams, createGetV1HistoricalPricesQueryParams, createGetV1HistoricalPricesQueryResponse } from "./createGetV1HistoricalPrices"; +export { createGetV1SpotPriceByCoinId200, createGetV1SpotPriceByCoinIdPathParams, createGetV1SpotPriceByCoinIdQueryParams, createGetV1SpotPriceByCoinIdQueryResponse } from "./createGetV1SpotPriceByCoinId"; +export { createGetV1SpotPricesByCoinIds200, createGetV1SpotPricesByCoinIdsQueryParams, createGetV1SpotPricesByCoinIdsQueryResponse } from "./createGetV1SpotPricesByCoinIds"; +export { createGetV1SupportedNetworks200, createGetV1SupportedNetworksQueryResponse } from "./createGetV1SupportedNetworks"; +export { createGetV2SpotPrices200, createGetV2SpotPricesPathParams, createGetV2SpotPricesQueryParams, createGetV2SpotPricesQueryResponse } from "./createGetV2SpotPrices"; +export { createGetV2SupportedNetworks200, createGetV2SupportedNetworksQueryResponse } from "./createGetV2SupportedNetworks"; +export { createGetV2TopTokens200, createGetV2TopTokensPathParams, createGetV2TopTokensQueryParams, createGetV2TopTokensQueryResponse } from "./createGetV2TopTokens"; +export { createGetV3HistoricalPrices200, createGetV3HistoricalPricesPathParams, createGetV3HistoricalPricesQueryParams, createGetV3HistoricalPricesQueryResponse } from "./createGetV3HistoricalPrices"; +export { createGetV3SpotPrices200, createGetV3SpotPricesQueryParams, createGetV3SpotPricesQueryResponse } from "./createGetV3SpotPrices"; +export { createHistoricalPrices } from "./createHistoricalPrices"; +export { createMarketData } from "./createMarketData"; +export { createMarketDataSpotPrices } from "./createMarketDataSpotPrices"; +export { createPricePoint } from "./createPricePoint"; +export { createSupportedNetworks } from "./createSupportedNetworks"; +export { createTopToken } from "./createTopToken"; +export { createV3HistoricalPrices } from "./createV3HistoricalPrices"; +export { createV3SpotPrice } from "./createV3SpotPrice"; +export { createV3SpotPrices } from "./createV3SpotPrices"; +export { createVsCurrency } from "./createVsCurrency"; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/msw/getV1ExchangeRatesHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV1ExchangeRatesHandler.ts new file mode 100644 index 0000000000..163393f24f --- /dev/null +++ b/packages/core-backend/src/generated/price-api/msw/getV1ExchangeRatesHandler.ts @@ -0,0 +1,34 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV1ExchangeRatesQueryResponse } from "../types/GetV1ExchangeRates"; +import { createGetV1ExchangeRatesQueryResponse } from "../mocks/createGetV1ExchangeRates"; +import { http } from "msw"; +import type { HttpHandler } from "msw"; + +export function getV1ExchangeRatesHandlerResponse200(data: GetV1ExchangeRatesQueryResponse) { + + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) +} + +export function getV1ExchangeRatesHandler(data?: GetV1ExchangeRatesQueryResponse | (( + info: Parameters[1]>[0], + ) => Response | Promise)): HttpHandler { + return http.get('https://price.api.cx.metamask.io/v1/exchange-rates', function handler(info) { + if(typeof data === 'function') return data(info) + + return new Response(JSON.stringify(data || createGetV1ExchangeRatesQueryResponse(data)), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) + }) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/msw/getV1FiatExchangeRatesHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV1FiatExchangeRatesHandler.ts new file mode 100644 index 0000000000..5ebc0b49c7 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/msw/getV1FiatExchangeRatesHandler.ts @@ -0,0 +1,34 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV1FiatExchangeRatesQueryResponse } from "../types/GetV1FiatExchangeRates"; +import { createGetV1FiatExchangeRatesQueryResponse } from "../mocks/createGetV1FiatExchangeRates"; +import { http } from "msw"; +import type { HttpHandler } from "msw"; + +export function getV1FiatExchangeRatesHandlerResponse200(data: GetV1FiatExchangeRatesQueryResponse) { + + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) +} + +export function getV1FiatExchangeRatesHandler(data?: GetV1FiatExchangeRatesQueryResponse | (( + info: Parameters[1]>[0], + ) => Response | Promise)): HttpHandler { + return http.get('https://price.api.cx.metamask.io/v1/exchange-rates/fiat', function handler(info) { + if(typeof data === 'function') return data(info) + + return new Response(JSON.stringify(data || createGetV1FiatExchangeRatesQueryResponse(data)), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) + }) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/msw/getV1HistoricalPricesHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV1HistoricalPricesHandler.ts new file mode 100644 index 0000000000..e959cb6d26 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/msw/getV1HistoricalPricesHandler.ts @@ -0,0 +1,34 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV1HistoricalPricesQueryResponse } from "../types/GetV1HistoricalPrices"; +import { createGetV1HistoricalPricesQueryResponse } from "../mocks/createGetV1HistoricalPrices"; +import { http } from "msw"; +import type { HttpHandler } from "msw"; + +export function getV1HistoricalPricesHandlerResponse200(data: GetV1HistoricalPricesQueryResponse) { + + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) +} + +export function getV1HistoricalPricesHandler(data?: GetV1HistoricalPricesQueryResponse | (( + info: Parameters[1]>[0], + ) => Response | Promise)): HttpHandler { + return http.get('https://price.api.cx.metamask.io/v1/chains/:chainId/historical-prices/:tokenAddress', function handler(info) { + if(typeof data === 'function') return data(info) + + return new Response(JSON.stringify(data || createGetV1HistoricalPricesQueryResponse(data)), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) + }) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/msw/getV1SpotPriceByCoinIdHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV1SpotPriceByCoinIdHandler.ts new file mode 100644 index 0000000000..a668824486 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/msw/getV1SpotPriceByCoinIdHandler.ts @@ -0,0 +1,34 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV1SpotPriceByCoinIdQueryResponse } from "../types/GetV1SpotPriceByCoinId"; +import { createGetV1SpotPriceByCoinIdQueryResponse } from "../mocks/createGetV1SpotPriceByCoinId"; +import { http } from "msw"; +import type { HttpHandler } from "msw"; + +export function getV1SpotPriceByCoinIdHandlerResponse200(data: GetV1SpotPriceByCoinIdQueryResponse) { + + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) +} + +export function getV1SpotPriceByCoinIdHandler(data?: GetV1SpotPriceByCoinIdQueryResponse | (( + info: Parameters[1]>[0], + ) => Response | Promise)): HttpHandler { + return http.get('https://price.api.cx.metamask.io/v1/spot-prices/:coinId', function handler(info) { + if(typeof data === 'function') return data(info) + + return new Response(JSON.stringify(data || createGetV1SpotPriceByCoinIdQueryResponse(data)), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) + }) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/msw/getV1SpotPricesByCoinIdsHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV1SpotPricesByCoinIdsHandler.ts new file mode 100644 index 0000000000..753e5cda93 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/msw/getV1SpotPricesByCoinIdsHandler.ts @@ -0,0 +1,34 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV1SpotPricesByCoinIdsQueryResponse } from "../types/GetV1SpotPricesByCoinIds"; +import { createGetV1SpotPricesByCoinIdsQueryResponse } from "../mocks/createGetV1SpotPricesByCoinIds"; +import { http } from "msw"; +import type { HttpHandler } from "msw"; + +export function getV1SpotPricesByCoinIdsHandlerResponse200(data: GetV1SpotPricesByCoinIdsQueryResponse) { + + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) +} + +export function getV1SpotPricesByCoinIdsHandler(data?: GetV1SpotPricesByCoinIdsQueryResponse | (( + info: Parameters[1]>[0], + ) => Response | Promise)): HttpHandler { + return http.get('https://price.api.cx.metamask.io/v1/spot-prices', function handler(info) { + if(typeof data === 'function') return data(info) + + return new Response(JSON.stringify(data || createGetV1SpotPricesByCoinIdsQueryResponse(data)), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) + }) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/msw/getV1SupportedNetworksHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV1SupportedNetworksHandler.ts new file mode 100644 index 0000000000..d40da5483d --- /dev/null +++ b/packages/core-backend/src/generated/price-api/msw/getV1SupportedNetworksHandler.ts @@ -0,0 +1,34 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV1SupportedNetworksQueryResponse } from "../types/GetV1SupportedNetworks"; +import { createGetV1SupportedNetworksQueryResponse } from "../mocks/createGetV1SupportedNetworks"; +import { http } from "msw"; +import type { HttpHandler } from "msw"; + +export function getV1SupportedNetworksHandlerResponse200(data: GetV1SupportedNetworksQueryResponse) { + + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) +} + +export function getV1SupportedNetworksHandler(data?: GetV1SupportedNetworksQueryResponse | (( + info: Parameters[1]>[0], + ) => Response | Promise)): HttpHandler { + return http.get('https://price.api.cx.metamask.io/v1/supportedNetworks', function handler(info) { + if(typeof data === 'function') return data(info) + + return new Response(JSON.stringify(data || createGetV1SupportedNetworksQueryResponse(data)), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) + }) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/msw/getV2SpotPricesHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV2SpotPricesHandler.ts new file mode 100644 index 0000000000..50fd35ecab --- /dev/null +++ b/packages/core-backend/src/generated/price-api/msw/getV2SpotPricesHandler.ts @@ -0,0 +1,34 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV2SpotPricesQueryResponse } from "../types/GetV2SpotPrices"; +import { createGetV2SpotPricesQueryResponse } from "../mocks/createGetV2SpotPrices"; +import { http } from "msw"; +import type { HttpHandler } from "msw"; + +export function getV2SpotPricesHandlerResponse200(data: GetV2SpotPricesQueryResponse) { + + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) +} + +export function getV2SpotPricesHandler(data?: GetV2SpotPricesQueryResponse | (( + info: Parameters[1]>[0], + ) => Response | Promise)): HttpHandler { + return http.get('https://price.api.cx.metamask.io/v2/chains/:chainId/spot-prices', function handler(info) { + if(typeof data === 'function') return data(info) + + return new Response(JSON.stringify(data || createGetV2SpotPricesQueryResponse(data)), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) + }) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/msw/getV2SupportedNetworksHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV2SupportedNetworksHandler.ts new file mode 100644 index 0000000000..5280750dfa --- /dev/null +++ b/packages/core-backend/src/generated/price-api/msw/getV2SupportedNetworksHandler.ts @@ -0,0 +1,34 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV2SupportedNetworksQueryResponse } from "../types/GetV2SupportedNetworks"; +import { createGetV2SupportedNetworksQueryResponse } from "../mocks/createGetV2SupportedNetworks"; +import { http } from "msw"; +import type { HttpHandler } from "msw"; + +export function getV2SupportedNetworksHandlerResponse200(data: GetV2SupportedNetworksQueryResponse) { + + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) +} + +export function getV2SupportedNetworksHandler(data?: GetV2SupportedNetworksQueryResponse | (( + info: Parameters[1]>[0], + ) => Response | Promise)): HttpHandler { + return http.get('https://price.api.cx.metamask.io/v2/supportedNetworks', function handler(info) { + if(typeof data === 'function') return data(info) + + return new Response(JSON.stringify(data || createGetV2SupportedNetworksQueryResponse(data)), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) + }) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/msw/getV2TopTokensHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV2TopTokensHandler.ts new file mode 100644 index 0000000000..67c173b9d5 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/msw/getV2TopTokensHandler.ts @@ -0,0 +1,34 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV2TopTokensQueryResponse } from "../types/GetV2TopTokens"; +import { createGetV2TopTokensQueryResponse } from "../mocks/createGetV2TopTokens"; +import { http } from "msw"; +import type { HttpHandler } from "msw"; + +export function getV2TopTokensHandlerResponse200(data: GetV2TopTokensQueryResponse) { + + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) +} + +export function getV2TopTokensHandler(data?: GetV2TopTokensQueryResponse | (( + info: Parameters[1]>[0], + ) => Response | Promise)): HttpHandler { + return http.get('https://price.api.cx.metamask.io/v2/chains/:chainId/top-tokens', function handler(info) { + if(typeof data === 'function') return data(info) + + return new Response(JSON.stringify(data || createGetV2TopTokensQueryResponse(data)), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) + }) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/msw/getV3HistoricalPricesHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV3HistoricalPricesHandler.ts new file mode 100644 index 0000000000..d9bcb8045c --- /dev/null +++ b/packages/core-backend/src/generated/price-api/msw/getV3HistoricalPricesHandler.ts @@ -0,0 +1,34 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV3HistoricalPricesQueryResponse } from "../types/GetV3HistoricalPrices"; +import { createGetV3HistoricalPricesQueryResponse } from "../mocks/createGetV3HistoricalPrices"; +import { http } from "msw"; +import type { HttpHandler } from "msw"; + +export function getV3HistoricalPricesHandlerResponse200(data: GetV3HistoricalPricesQueryResponse) { + + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) +} + +export function getV3HistoricalPricesHandler(data?: GetV3HistoricalPricesQueryResponse | (( + info: Parameters[1]>[0], + ) => Response | Promise)): HttpHandler { + return http.get('https://price.api.cx.metamask.io/v3/historical-prices/:chainId/:assetType', function handler(info) { + if(typeof data === 'function') return data(info) + + return new Response(JSON.stringify(data || createGetV3HistoricalPricesQueryResponse(data)), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) + }) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/msw/getV3SpotPricesHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV3SpotPricesHandler.ts new file mode 100644 index 0000000000..18d1e80dd2 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/msw/getV3SpotPricesHandler.ts @@ -0,0 +1,34 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { GetV3SpotPricesQueryResponse } from "../types/GetV3SpotPrices"; +import { createGetV3SpotPricesQueryResponse } from "../mocks/createGetV3SpotPrices"; +import { http } from "msw"; +import type { HttpHandler } from "msw"; + +export function getV3SpotPricesHandlerResponse200(data: GetV3SpotPricesQueryResponse) { + + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) +} + +export function getV3SpotPricesHandler(data?: GetV3SpotPricesQueryResponse | (( + info: Parameters[1]>[0], + ) => Response | Promise)): HttpHandler { + return http.get('https://price.api.cx.metamask.io/v3/spot-prices', function handler(info) { + if(typeof data === 'function') return data(info) + + return new Response(JSON.stringify(data || createGetV3SpotPricesQueryResponse(data)), { + status: 200, + headers: { + 'Content-Type': 'application/json' + }, + }) + }) +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/msw/handlers.ts b/packages/core-backend/src/generated/price-api/msw/handlers.ts new file mode 100644 index 0000000000..fb41a7cb55 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/msw/handlers.ts @@ -0,0 +1,19 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { getV1ExchangeRatesHandler } from "./getV1ExchangeRatesHandler"; +import { getV1FiatExchangeRatesHandler } from "./getV1FiatExchangeRatesHandler"; +import { getV1HistoricalPricesHandler } from "./getV1HistoricalPricesHandler"; +import { getV1SpotPriceByCoinIdHandler } from "./getV1SpotPriceByCoinIdHandler"; +import { getV1SpotPricesByCoinIdsHandler } from "./getV1SpotPricesByCoinIdsHandler"; +import { getV1SupportedNetworksHandler } from "./getV1SupportedNetworksHandler"; +import { getV2SpotPricesHandler } from "./getV2SpotPricesHandler"; +import { getV2SupportedNetworksHandler } from "./getV2SupportedNetworksHandler"; +import { getV2TopTokensHandler } from "./getV2TopTokensHandler"; +import { getV3HistoricalPricesHandler } from "./getV3HistoricalPricesHandler"; +import { getV3SpotPricesHandler } from "./getV3SpotPricesHandler"; +import type { HttpHandler } from "msw"; + +export const handlers: HttpHandler[] = [getV1SupportedNetworksHandler(),getV2SupportedNetworksHandler(),getV1ExchangeRatesHandler(),getV1FiatExchangeRatesHandler(),getV1SpotPricesByCoinIdsHandler(),getV1SpotPriceByCoinIdHandler(),getV2SpotPricesHandler(),getV3SpotPricesHandler(),getV1HistoricalPricesHandler(),getV3HistoricalPricesHandler(),getV2TopTokensHandler()] \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/msw/index.ts b/packages/core-backend/src/generated/price-api/msw/index.ts new file mode 100644 index 0000000000..08d31fe459 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/msw/index.ts @@ -0,0 +1,12 @@ +export { getV1ExchangeRatesHandler, getV1ExchangeRatesHandlerResponse200 } from "./getV1ExchangeRatesHandler"; +export { getV1FiatExchangeRatesHandler, getV1FiatExchangeRatesHandlerResponse200 } from "./getV1FiatExchangeRatesHandler"; +export { getV1HistoricalPricesHandler, getV1HistoricalPricesHandlerResponse200 } from "./getV1HistoricalPricesHandler"; +export { getV1SpotPriceByCoinIdHandler, getV1SpotPriceByCoinIdHandlerResponse200 } from "./getV1SpotPriceByCoinIdHandler"; +export { getV1SpotPricesByCoinIdsHandler, getV1SpotPricesByCoinIdsHandlerResponse200 } from "./getV1SpotPricesByCoinIdsHandler"; +export { getV1SupportedNetworksHandler, getV1SupportedNetworksHandlerResponse200 } from "./getV1SupportedNetworksHandler"; +export { getV2SpotPricesHandler, getV2SpotPricesHandlerResponse200 } from "./getV2SpotPricesHandler"; +export { getV2SupportedNetworksHandler, getV2SupportedNetworksHandlerResponse200 } from "./getV2SupportedNetworksHandler"; +export { getV2TopTokensHandler, getV2TopTokensHandlerResponse200 } from "./getV2TopTokensHandler"; +export { getV3HistoricalPricesHandler, getV3HistoricalPricesHandlerResponse200 } from "./getV3HistoricalPricesHandler"; +export { getV3SpotPricesHandler, getV3SpotPricesHandlerResponse200 } from "./getV3SpotPricesHandler"; +export { handlers } from "./handlers"; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/queries/getV1ExchangeRates.ts b/packages/core-backend/src/generated/price-api/queries/getV1ExchangeRates.ts new file mode 100644 index 0000000000..81bb94ea6e --- /dev/null +++ b/packages/core-backend/src/generated/price-api/queries/getV1ExchangeRates.ts @@ -0,0 +1,60 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; +import type { GetV1ExchangeRatesQueryResponse, GetV1ExchangeRatesQueryParams } from "../types/GetV1ExchangeRates"; +import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; +import { getQueryOptionsOverrides } from "../../../api/query-runtime"; +import { GetV1ExchangeRatesQueryResponseStruct } from "../schemas/getV1ExchangeRatesStruct"; +import { assert } from "@metamask/superstruct"; + +/** + * Query key for `GET /v1/exchange-rates`. + */ +export const getV1ExchangeRatesQueryKey = (params: GetV1ExchangeRatesQueryParams) => + ["prices", "getV1ExchangeRates", params] as const; + +/** + * Get exchange rates + * Returns a list of exchange rates for all supported currencies against the given base currency. + * + * Returns the TanStack Query options for `GET /v1/exchange-rates`. The response is + * validated against {@link GetV1ExchangeRatesQueryResponseStruct} before it is returned. + */ +export function getV1ExchangeRatesQueryOptions( + client: ApiRequestClient, params: GetV1ExchangeRatesQueryParams, + options?: FetchOptions, +): FetchQueryOptions { + return { + queryKey: getV1ExchangeRatesQueryKey(params), + queryFn: async ({ signal }: QueryFunctionContext) => { + const data = await client.request({ + method: 'get', + url: "/v1/exchange-rates", + params, + signal, + }); + assert(data, GetV1ExchangeRatesQueryResponseStruct); + return data; + }, + ...getQueryOptionsOverrides(options), + }; +} + +/** + * Get exchange rates + * Returns a list of exchange rates for all supported currencies against the given base currency. + * + * Fetches `GET /v1/exchange-rates` through the client's QueryClient, deduplicating + * concurrent calls and reusing fresh cached data. + */ +export async function fetchV1ExchangeRates( + client: ApiRequestClient, params: GetV1ExchangeRatesQueryParams, + options?: FetchOptions, +): Promise { + return client.queryClient.fetchQuery( + getV1ExchangeRatesQueryOptions(client, params, options), + ); +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/queries/getV1FiatExchangeRates.ts b/packages/core-backend/src/generated/price-api/queries/getV1FiatExchangeRates.ts new file mode 100644 index 0000000000..dc0b14c348 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/queries/getV1FiatExchangeRates.ts @@ -0,0 +1,59 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; +import type { GetV1FiatExchangeRatesQueryResponse } from "../types/GetV1FiatExchangeRates"; +import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; +import { getQueryOptionsOverrides } from "../../../api/query-runtime"; +import { GetV1FiatExchangeRatesQueryResponseStruct } from "../schemas/getV1FiatExchangeRatesStruct"; +import { assert } from "@metamask/superstruct"; + +/** + * Query key for `GET /v1/exchange-rates/fiat`. + */ +export const getV1FiatExchangeRatesQueryKey = () => + ["prices", "getV1FiatExchangeRates"] as const; + +/** + * Get fiat exchange rates + * Returns a list of exchange rates for all supported fiat currencies. + * + * Returns the TanStack Query options for `GET /v1/exchange-rates/fiat`. The response is + * validated against {@link GetV1FiatExchangeRatesQueryResponseStruct} before it is returned. + */ +export function getV1FiatExchangeRatesQueryOptions( + client: ApiRequestClient, + options?: FetchOptions, +): FetchQueryOptions { + return { + queryKey: getV1FiatExchangeRatesQueryKey(), + queryFn: async ({ signal }: QueryFunctionContext) => { + const data = await client.request({ + method: 'get', + url: "/v1/exchange-rates/fiat", + signal, + }); + assert(data, GetV1FiatExchangeRatesQueryResponseStruct); + return data; + }, + ...getQueryOptionsOverrides(options), + }; +} + +/** + * Get fiat exchange rates + * Returns a list of exchange rates for all supported fiat currencies. + * + * Fetches `GET /v1/exchange-rates/fiat` through the client's QueryClient, deduplicating + * concurrent calls and reusing fresh cached data. + */ +export async function fetchV1FiatExchangeRates( + client: ApiRequestClient, + options?: FetchOptions, +): Promise { + return client.queryClient.fetchQuery( + getV1FiatExchangeRatesQueryOptions(client, options), + ); +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/queries/getV1HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/queries/getV1HistoricalPrices.ts new file mode 100644 index 0000000000..7c4043343f --- /dev/null +++ b/packages/core-backend/src/generated/price-api/queries/getV1HistoricalPrices.ts @@ -0,0 +1,60 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; +import type { GetV1HistoricalPricesQueryResponse, GetV1HistoricalPricesPathParams, GetV1HistoricalPricesQueryParams } from "../types/GetV1HistoricalPrices"; +import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; +import { getQueryOptionsOverrides } from "../../../api/query-runtime"; +import { GetV1HistoricalPricesQueryResponseStruct } from "../schemas/getV1HistoricalPricesStruct"; +import { assert } from "@metamask/superstruct"; + +/** + * Query key for `GET /v1/chains/{chainId}/historical-prices/{tokenAddress}`. + */ +export const getV1HistoricalPricesQueryKey = (pathParams: GetV1HistoricalPricesPathParams, params?: GetV1HistoricalPricesQueryParams) => + ["prices", "getV1HistoricalPrices", pathParams, ...(params ? [params] : [])] as const; + +/** + * Get historical prices by token address + * Returns historical prices for a single token on a chain. + * + * Returns the TanStack Query options for `GET /v1/chains/{chainId}/historical-prices/{tokenAddress}`. The response is + * validated against {@link GetV1HistoricalPricesQueryResponseStruct} before it is returned. + */ +export function getV1HistoricalPricesQueryOptions( + client: ApiRequestClient, pathParams: GetV1HistoricalPricesPathParams, params?: GetV1HistoricalPricesQueryParams, + options?: FetchOptions, +): FetchQueryOptions { + return { + queryKey: getV1HistoricalPricesQueryKey(pathParams, params), + queryFn: async ({ signal }: QueryFunctionContext) => { + const data = await client.request({ + method: 'get', + url: `/v1/chains/${pathParams.chainId}/historical-prices/${pathParams.tokenAddress}`, + params, + signal, + }); + assert(data, GetV1HistoricalPricesQueryResponseStruct); + return data; + }, + ...getQueryOptionsOverrides(options), + }; +} + +/** + * Get historical prices by token address + * Returns historical prices for a single token on a chain. + * + * Fetches `GET /v1/chains/{chainId}/historical-prices/{tokenAddress}` through the client's QueryClient, deduplicating + * concurrent calls and reusing fresh cached data. + */ +export async function fetchV1HistoricalPrices( + client: ApiRequestClient, pathParams: GetV1HistoricalPricesPathParams, params?: GetV1HistoricalPricesQueryParams, + options?: FetchOptions, +): Promise { + return client.queryClient.fetchQuery( + getV1HistoricalPricesQueryOptions(client, pathParams, params, options), + ); +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/queries/getV1SpotPriceByCoinId.ts b/packages/core-backend/src/generated/price-api/queries/getV1SpotPriceByCoinId.ts new file mode 100644 index 0000000000..613b034284 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/queries/getV1SpotPriceByCoinId.ts @@ -0,0 +1,60 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; +import type { GetV1SpotPriceByCoinIdQueryResponse, GetV1SpotPriceByCoinIdPathParams, GetV1SpotPriceByCoinIdQueryParams } from "../types/GetV1SpotPriceByCoinId"; +import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; +import { getQueryOptionsOverrides } from "../../../api/query-runtime"; +import { GetV1SpotPriceByCoinIdQueryResponseStruct } from "../schemas/getV1SpotPriceByCoinIdStruct"; +import { assert } from "@metamask/superstruct"; + +/** + * Query key for `GET /v1/spot-prices/{coinId}`. + */ +export const getV1SpotPriceByCoinIdQueryKey = (pathParams: GetV1SpotPriceByCoinIdPathParams, params?: GetV1SpotPriceByCoinIdQueryParams) => + ["prices", "getV1SpotPriceByCoinId", pathParams, ...(params ? [params] : [])] as const; + +/** + * Get spot price by CoinGecko coin ID + * Returns the spot price for a supported CoinGecko coin ID. + * + * Returns the TanStack Query options for `GET /v1/spot-prices/{coinId}`. The response is + * validated against {@link GetV1SpotPriceByCoinIdQueryResponseStruct} before it is returned. + */ +export function getV1SpotPriceByCoinIdQueryOptions( + client: ApiRequestClient, pathParams: GetV1SpotPriceByCoinIdPathParams, params?: GetV1SpotPriceByCoinIdQueryParams, + options?: FetchOptions, +): FetchQueryOptions { + return { + queryKey: getV1SpotPriceByCoinIdQueryKey(pathParams, params), + queryFn: async ({ signal }: QueryFunctionContext) => { + const data = await client.request({ + method: 'get', + url: `/v1/spot-prices/${pathParams.coinId}`, + params, + signal, + }); + assert(data, GetV1SpotPriceByCoinIdQueryResponseStruct); + return data; + }, + ...getQueryOptionsOverrides(options), + }; +} + +/** + * Get spot price by CoinGecko coin ID + * Returns the spot price for a supported CoinGecko coin ID. + * + * Fetches `GET /v1/spot-prices/{coinId}` through the client's QueryClient, deduplicating + * concurrent calls and reusing fresh cached data. + */ +export async function fetchV1SpotPriceByCoinId( + client: ApiRequestClient, pathParams: GetV1SpotPriceByCoinIdPathParams, params?: GetV1SpotPriceByCoinIdQueryParams, + options?: FetchOptions, +): Promise { + return client.queryClient.fetchQuery( + getV1SpotPriceByCoinIdQueryOptions(client, pathParams, params, options), + ); +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/queries/getV1SpotPricesByCoinIds.ts b/packages/core-backend/src/generated/price-api/queries/getV1SpotPricesByCoinIds.ts new file mode 100644 index 0000000000..c223ae83b7 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/queries/getV1SpotPricesByCoinIds.ts @@ -0,0 +1,60 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; +import type { GetV1SpotPricesByCoinIdsQueryResponse, GetV1SpotPricesByCoinIdsQueryParams } from "../types/GetV1SpotPricesByCoinIds"; +import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; +import { getQueryOptionsOverrides } from "../../../api/query-runtime"; +import { GetV1SpotPricesByCoinIdsQueryResponseStruct } from "../schemas/getV1SpotPricesByCoinIdsStruct"; +import { assert } from "@metamask/superstruct"; + +/** + * Query key for `GET /v1/spot-prices`. + */ +export const getV1SpotPricesByCoinIdsQueryKey = (params: GetV1SpotPricesByCoinIdsQueryParams) => + ["prices", "getV1SpotPricesByCoinIds", params] as const; + +/** + * Get spot prices by CoinGecko coin IDs + * Returns a list of spot prices for a given list of CoinGecko coin IDs. + * + * Returns the TanStack Query options for `GET /v1/spot-prices`. The response is + * validated against {@link GetV1SpotPricesByCoinIdsQueryResponseStruct} before it is returned. + */ +export function getV1SpotPricesByCoinIdsQueryOptions( + client: ApiRequestClient, params: GetV1SpotPricesByCoinIdsQueryParams, + options?: FetchOptions, +): FetchQueryOptions { + return { + queryKey: getV1SpotPricesByCoinIdsQueryKey(params), + queryFn: async ({ signal }: QueryFunctionContext) => { + const data = await client.request({ + method: 'get', + url: "/v1/spot-prices", + params, + signal, + }); + assert(data, GetV1SpotPricesByCoinIdsQueryResponseStruct); + return data; + }, + ...getQueryOptionsOverrides(options), + }; +} + +/** + * Get spot prices by CoinGecko coin IDs + * Returns a list of spot prices for a given list of CoinGecko coin IDs. + * + * Fetches `GET /v1/spot-prices` through the client's QueryClient, deduplicating + * concurrent calls and reusing fresh cached data. + */ +export async function fetchV1SpotPricesByCoinIds( + client: ApiRequestClient, params: GetV1SpotPricesByCoinIdsQueryParams, + options?: FetchOptions, +): Promise { + return client.queryClient.fetchQuery( + getV1SpotPricesByCoinIdsQueryOptions(client, params, options), + ); +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/queries/getV1SupportedNetworks.ts b/packages/core-backend/src/generated/price-api/queries/getV1SupportedNetworks.ts new file mode 100644 index 0000000000..16c24f9e5c --- /dev/null +++ b/packages/core-backend/src/generated/price-api/queries/getV1SupportedNetworks.ts @@ -0,0 +1,59 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; +import type { GetV1SupportedNetworksQueryResponse } from "../types/GetV1SupportedNetworks"; +import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; +import { getQueryOptionsOverrides } from "../../../api/query-runtime"; +import { GetV1SupportedNetworksQueryResponseStruct } from "../schemas/getV1SupportedNetworksStruct"; +import { assert } from "@metamask/superstruct"; + +/** + * Query key for `GET /v1/supportedNetworks`. + */ +export const getV1SupportedNetworksQueryKey = () => + ["prices", "getV1SupportedNetworks"] as const; + +/** + * Get supported networks + * Returns the list of supported networks, keyed by decimal chain ID. + * + * Returns the TanStack Query options for `GET /v1/supportedNetworks`. The response is + * validated against {@link GetV1SupportedNetworksQueryResponseStruct} before it is returned. + */ +export function getV1SupportedNetworksQueryOptions( + client: ApiRequestClient, + options?: FetchOptions, +): FetchQueryOptions { + return { + queryKey: getV1SupportedNetworksQueryKey(), + queryFn: async ({ signal }: QueryFunctionContext) => { + const data = await client.request({ + method: 'get', + url: "/v1/supportedNetworks", + signal, + }); + assert(data, GetV1SupportedNetworksQueryResponseStruct); + return data; + }, + ...getQueryOptionsOverrides(options), + }; +} + +/** + * Get supported networks + * Returns the list of supported networks, keyed by decimal chain ID. + * + * Fetches `GET /v1/supportedNetworks` through the client's QueryClient, deduplicating + * concurrent calls and reusing fresh cached data. + */ +export async function fetchV1SupportedNetworks( + client: ApiRequestClient, + options?: FetchOptions, +): Promise { + return client.queryClient.fetchQuery( + getV1SupportedNetworksQueryOptions(client, options), + ); +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/queries/getV2SpotPrices.ts b/packages/core-backend/src/generated/price-api/queries/getV2SpotPrices.ts new file mode 100644 index 0000000000..640bb7bf5e --- /dev/null +++ b/packages/core-backend/src/generated/price-api/queries/getV2SpotPrices.ts @@ -0,0 +1,60 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; +import type { GetV2SpotPricesQueryResponse, GetV2SpotPricesPathParams, GetV2SpotPricesQueryParams } from "../types/GetV2SpotPrices"; +import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; +import { getQueryOptionsOverrides } from "../../../api/query-runtime"; +import { GetV2SpotPricesQueryResponseStruct } from "../schemas/getV2SpotPricesStruct"; +import { assert } from "@metamask/superstruct"; + +/** + * Query key for `GET /v2/chains/{chainId}/spot-prices`. + */ +export const getV2SpotPricesQueryKey = (pathParams: GetV2SpotPricesPathParams, params: GetV2SpotPricesQueryParams) => + ["prices", "getV2SpotPrices", pathParams, params] as const; + +/** + * Get spot prices with market data by token addresses + * Returns spot prices with full market data for a given list of token addresses on a chain. + * + * Returns the TanStack Query options for `GET /v2/chains/{chainId}/spot-prices`. The response is + * validated against {@link GetV2SpotPricesQueryResponseStruct} before it is returned. + */ +export function getV2SpotPricesQueryOptions( + client: ApiRequestClient, pathParams: GetV2SpotPricesPathParams, params: GetV2SpotPricesQueryParams, + options?: FetchOptions, +): FetchQueryOptions { + return { + queryKey: getV2SpotPricesQueryKey(pathParams, params), + queryFn: async ({ signal }: QueryFunctionContext) => { + const data = await client.request({ + method: 'get', + url: `/v2/chains/${pathParams.chainId}/spot-prices`, + params, + signal, + }); + assert(data, GetV2SpotPricesQueryResponseStruct); + return data; + }, + ...getQueryOptionsOverrides(options), + }; +} + +/** + * Get spot prices with market data by token addresses + * Returns spot prices with full market data for a given list of token addresses on a chain. + * + * Fetches `GET /v2/chains/{chainId}/spot-prices` through the client's QueryClient, deduplicating + * concurrent calls and reusing fresh cached data. + */ +export async function fetchV2SpotPrices( + client: ApiRequestClient, pathParams: GetV2SpotPricesPathParams, params: GetV2SpotPricesQueryParams, + options?: FetchOptions, +): Promise { + return client.queryClient.fetchQuery( + getV2SpotPricesQueryOptions(client, pathParams, params, options), + ); +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/queries/getV2SupportedNetworks.ts b/packages/core-backend/src/generated/price-api/queries/getV2SupportedNetworks.ts new file mode 100644 index 0000000000..bf311825d9 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/queries/getV2SupportedNetworks.ts @@ -0,0 +1,59 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; +import type { GetV2SupportedNetworksQueryResponse } from "../types/GetV2SupportedNetworks"; +import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; +import { getQueryOptionsOverrides } from "../../../api/query-runtime"; +import { GetV2SupportedNetworksQueryResponseStruct } from "../schemas/getV2SupportedNetworksStruct"; +import { assert } from "@metamask/superstruct"; + +/** + * Query key for `GET /v2/supportedNetworks`. + */ +export const getV2SupportedNetworksQueryKey = () => + ["prices", "getV2SupportedNetworks"] as const; + +/** + * Get supported networks (CAIP-2) + * Returns the list of supported networks, keyed by CAIP-2 chain ID. + * + * Returns the TanStack Query options for `GET /v2/supportedNetworks`. The response is + * validated against {@link GetV2SupportedNetworksQueryResponseStruct} before it is returned. + */ +export function getV2SupportedNetworksQueryOptions( + client: ApiRequestClient, + options?: FetchOptions, +): FetchQueryOptions { + return { + queryKey: getV2SupportedNetworksQueryKey(), + queryFn: async ({ signal }: QueryFunctionContext) => { + const data = await client.request({ + method: 'get', + url: "/v2/supportedNetworks", + signal, + }); + assert(data, GetV2SupportedNetworksQueryResponseStruct); + return data; + }, + ...getQueryOptionsOverrides(options), + }; +} + +/** + * Get supported networks (CAIP-2) + * Returns the list of supported networks, keyed by CAIP-2 chain ID. + * + * Fetches `GET /v2/supportedNetworks` through the client's QueryClient, deduplicating + * concurrent calls and reusing fresh cached data. + */ +export async function fetchV2SupportedNetworks( + client: ApiRequestClient, + options?: FetchOptions, +): Promise { + return client.queryClient.fetchQuery( + getV2SupportedNetworksQueryOptions(client, options), + ); +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/queries/getV2TopTokens.ts b/packages/core-backend/src/generated/price-api/queries/getV2TopTokens.ts new file mode 100644 index 0000000000..ab83f0a21b --- /dev/null +++ b/packages/core-backend/src/generated/price-api/queries/getV2TopTokens.ts @@ -0,0 +1,60 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; +import type { GetV2TopTokensQueryResponse, GetV2TopTokensPathParams, GetV2TopTokensQueryParams } from "../types/GetV2TopTokens"; +import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; +import { getQueryOptionsOverrides } from "../../../api/query-runtime"; +import { GetV2TopTokensQueryResponseStruct } from "../schemas/getV2TopTokensStruct"; +import { assert } from "@metamask/superstruct"; + +/** + * Query key for `GET /v2/chains/{chainId}/top-tokens`. + */ +export const getV2TopTokensQueryKey = (pathParams: GetV2TopTokensPathParams, params?: GetV2TopTokensQueryParams) => + ["prices", "getV2TopTokens", pathParams, ...(params ? [params] : [])] as const; + +/** + * Get top tokens by market cap + * Returns the top tokens on a chain, ordered by market cap. + * + * Returns the TanStack Query options for `GET /v2/chains/{chainId}/top-tokens`. The response is + * validated against {@link GetV2TopTokensQueryResponseStruct} before it is returned. + */ +export function getV2TopTokensQueryOptions( + client: ApiRequestClient, pathParams: GetV2TopTokensPathParams, params?: GetV2TopTokensQueryParams, + options?: FetchOptions, +): FetchQueryOptions { + return { + queryKey: getV2TopTokensQueryKey(pathParams, params), + queryFn: async ({ signal }: QueryFunctionContext) => { + const data = await client.request({ + method: 'get', + url: `/v2/chains/${pathParams.chainId}/top-tokens`, + params, + signal, + }); + assert(data, GetV2TopTokensQueryResponseStruct); + return data; + }, + ...getQueryOptionsOverrides(options), + }; +} + +/** + * Get top tokens by market cap + * Returns the top tokens on a chain, ordered by market cap. + * + * Fetches `GET /v2/chains/{chainId}/top-tokens` through the client's QueryClient, deduplicating + * concurrent calls and reusing fresh cached data. + */ +export async function fetchV2TopTokens( + client: ApiRequestClient, pathParams: GetV2TopTokensPathParams, params?: GetV2TopTokensQueryParams, + options?: FetchOptions, +): Promise { + return client.queryClient.fetchQuery( + getV2TopTokensQueryOptions(client, pathParams, params, options), + ); +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/queries/getV3HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/queries/getV3HistoricalPrices.ts new file mode 100644 index 0000000000..7b82ab3b1e --- /dev/null +++ b/packages/core-backend/src/generated/price-api/queries/getV3HistoricalPrices.ts @@ -0,0 +1,60 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; +import type { GetV3HistoricalPricesQueryResponse, GetV3HistoricalPricesPathParams, GetV3HistoricalPricesQueryParams } from "../types/GetV3HistoricalPrices"; +import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; +import { getQueryOptionsOverrides } from "../../../api/query-runtime"; +import { GetV3HistoricalPricesQueryResponseStruct } from "../schemas/getV3HistoricalPricesStruct"; +import { assert } from "@metamask/superstruct"; + +/** + * Query key for `GET /v3/historical-prices/{chainId}/{assetType}`. + */ +export const getV3HistoricalPricesQueryKey = (pathParams: GetV3HistoricalPricesPathParams, params?: GetV3HistoricalPricesQueryParams) => + ["prices", "getV3HistoricalPrices", pathParams, ...(params ? [params] : [])] as const; + +/** + * Get historical prices by CAIP-19 asset ID + * Returns historical prices, market caps and total volumes for a CAIP-19 asset. + * + * Returns the TanStack Query options for `GET /v3/historical-prices/{chainId}/{assetType}`. The response is + * validated against {@link GetV3HistoricalPricesQueryResponseStruct} before it is returned. + */ +export function getV3HistoricalPricesQueryOptions( + client: ApiRequestClient, pathParams: GetV3HistoricalPricesPathParams, params?: GetV3HistoricalPricesQueryParams, + options?: FetchOptions, +): FetchQueryOptions { + return { + queryKey: getV3HistoricalPricesQueryKey(pathParams, params), + queryFn: async ({ signal }: QueryFunctionContext) => { + const data = await client.request({ + method: 'get', + url: `/v3/historical-prices/${pathParams.chainId}/${pathParams.assetType}`, + params, + signal, + }); + assert(data, GetV3HistoricalPricesQueryResponseStruct); + return data; + }, + ...getQueryOptionsOverrides(options), + }; +} + +/** + * Get historical prices by CAIP-19 asset ID + * Returns historical prices, market caps and total volumes for a CAIP-19 asset. + * + * Fetches `GET /v3/historical-prices/{chainId}/{assetType}` through the client's QueryClient, deduplicating + * concurrent calls and reusing fresh cached data. + */ +export async function fetchV3HistoricalPrices( + client: ApiRequestClient, pathParams: GetV3HistoricalPricesPathParams, params?: GetV3HistoricalPricesQueryParams, + options?: FetchOptions, +): Promise { + return client.queryClient.fetchQuery( + getV3HistoricalPricesQueryOptions(client, pathParams, params, options), + ); +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/queries/getV3SpotPrices.ts b/packages/core-backend/src/generated/price-api/queries/getV3SpotPrices.ts new file mode 100644 index 0000000000..78a30a5864 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/queries/getV3SpotPrices.ts @@ -0,0 +1,60 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; +import type { GetV3SpotPricesQueryResponse, GetV3SpotPricesQueryParams } from "../types/GetV3SpotPrices"; +import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; +import { getQueryOptionsOverrides } from "../../../api/query-runtime"; +import { GetV3SpotPricesQueryResponseStruct } from "../schemas/getV3SpotPricesStruct"; +import { assert } from "@metamask/superstruct"; + +/** + * Query key for `GET /v3/spot-prices`. + */ +export const getV3SpotPricesQueryKey = (params: GetV3SpotPricesQueryParams) => + ["prices", "getV3SpotPrices", params] as const; + +/** + * Get spot prices by CAIP-19 asset IDs + * Returns a list of spot prices for a given list of CAIP-19 asset IDs. + * + * Returns the TanStack Query options for `GET /v3/spot-prices`. The response is + * validated against {@link GetV3SpotPricesQueryResponseStruct} before it is returned. + */ +export function getV3SpotPricesQueryOptions( + client: ApiRequestClient, params: GetV3SpotPricesQueryParams, + options?: FetchOptions, +): FetchQueryOptions { + return { + queryKey: getV3SpotPricesQueryKey(params), + queryFn: async ({ signal }: QueryFunctionContext) => { + const data = await client.request({ + method: 'get', + url: "/v3/spot-prices", + params, + signal, + }); + assert(data, GetV3SpotPricesQueryResponseStruct); + return data; + }, + ...getQueryOptionsOverrides(options), + }; +} + +/** + * Get spot prices by CAIP-19 asset IDs + * Returns a list of spot prices for a given list of CAIP-19 asset IDs. + * + * Fetches `GET /v3/spot-prices` through the client's QueryClient, deduplicating + * concurrent calls and reusing fresh cached data. + */ +export async function fetchV3SpotPrices( + client: ApiRequestClient, params: GetV3SpotPricesQueryParams, + options?: FetchOptions, +): Promise { + return client.queryClient.fetchQuery( + getV3SpotPricesQueryOptions(client, params, options), + ); +} \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/queries/index.ts b/packages/core-backend/src/generated/price-api/queries/index.ts new file mode 100644 index 0000000000..9f02deed4d --- /dev/null +++ b/packages/core-backend/src/generated/price-api/queries/index.ts @@ -0,0 +1,11 @@ +export { fetchV1ExchangeRates, getV1ExchangeRatesQueryKey, getV1ExchangeRatesQueryOptions } from "./getV1ExchangeRates"; +export { fetchV1FiatExchangeRates, getV1FiatExchangeRatesQueryKey, getV1FiatExchangeRatesQueryOptions } from "./getV1FiatExchangeRates"; +export { fetchV1HistoricalPrices, getV1HistoricalPricesQueryKey, getV1HistoricalPricesQueryOptions } from "./getV1HistoricalPrices"; +export { fetchV1SpotPriceByCoinId, getV1SpotPriceByCoinIdQueryKey, getV1SpotPriceByCoinIdQueryOptions } from "./getV1SpotPriceByCoinId"; +export { fetchV1SpotPricesByCoinIds, getV1SpotPricesByCoinIdsQueryKey, getV1SpotPricesByCoinIdsQueryOptions } from "./getV1SpotPricesByCoinIds"; +export { fetchV1SupportedNetworks, getV1SupportedNetworksQueryKey, getV1SupportedNetworksQueryOptions } from "./getV1SupportedNetworks"; +export { fetchV2SpotPrices, getV2SpotPricesQueryKey, getV2SpotPricesQueryOptions } from "./getV2SpotPrices"; +export { fetchV2SupportedNetworks, getV2SupportedNetworksQueryKey, getV2SupportedNetworksQueryOptions } from "./getV2SupportedNetworks"; +export { fetchV2TopTokens, getV2TopTokensQueryKey, getV2TopTokensQueryOptions } from "./getV2TopTokens"; +export { fetchV3HistoricalPrices, getV3HistoricalPricesQueryKey, getV3HistoricalPricesQueryOptions } from "./getV3HistoricalPrices"; +export { fetchV3SpotPrices, getV3SpotPricesQueryKey, getV3SpotPricesQueryOptions } from "./getV3SpotPrices"; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPriceStruct.ts b/packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPriceStruct.ts new file mode 100644 index 0000000000..4c811cc678 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPriceStruct.ts @@ -0,0 +1,31 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { number, optional, string, type } from "@metamask/superstruct"; + +/** + * Spot price and market data for a CoinGecko-listed coin. + */ +export const CoinGeckoSpotPriceStruct = type({ +id: string(), +price: number(), +marketCap: optional(number()), +allTimeHigh: optional(number()), +allTimeLow: optional(number()), +totalVolume: optional(number()), +high1d: optional(number()), +low1d: optional(number()), +circulatingSupply: optional(number()), +dilutedMarketCap: optional(number()), +marketCapPercentChange1d: optional(number()), +priceChange1d: optional(number()), +pricePercentChange1h: optional(number()), +pricePercentChange1d: optional(number()), +pricePercentChange7d: optional(number()), +pricePercentChange14d: optional(number()), +pricePercentChange30d: optional(number()), +pricePercentChange200d: optional(number()), +pricePercentChange1y: optional(number()) +}); \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPricesStruct.ts new file mode 100644 index 0000000000..d7f327f23d --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPricesStruct.ts @@ -0,0 +1,12 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { CoinGeckoSpotPriceStruct } from "./coinGeckoSpotPriceStruct"; +import { record, string } from "@metamask/superstruct"; + +/** + * Spot prices keyed by CoinGecko coin ID. + */ +export const CoinGeckoSpotPricesStruct = record(string(), CoinGeckoSpotPriceStruct); \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/exchangeRateInfoStruct.ts b/packages/core-backend/src/generated/price-api/schemas/exchangeRateInfoStruct.ts new file mode 100644 index 0000000000..ab3cf90e50 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/exchangeRateInfoStruct.ts @@ -0,0 +1,16 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { enums, number, string, type } from "@metamask/superstruct"; + +/** + * Exchange rate details for a single currency. + */ +export const ExchangeRateInfoStruct = type({ +name: string(), +ticker: string(), +value: number(), +currencyType: enums(["crypto", "fiat"]) +}); \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/exchangeRatesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/exchangeRatesStruct.ts new file mode 100644 index 0000000000..8cd8fa3a83 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/exchangeRatesStruct.ts @@ -0,0 +1,12 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { ExchangeRateInfoStruct } from "./exchangeRateInfoStruct"; +import { record, string } from "@metamask/superstruct"; + +/** + * Exchange rates keyed by currency ticker. + */ +export const ExchangeRatesStruct = record(string(), ExchangeRateInfoStruct); \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1ExchangeRatesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV1ExchangeRatesStruct.ts new file mode 100644 index 0000000000..35c011d29e --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/getV1ExchangeRatesStruct.ts @@ -0,0 +1,18 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { ExchangeRatesStruct } from "./exchangeRatesStruct"; +import { string, type } from "@metamask/superstruct"; + +export const GetV1ExchangeRatesQueryParamsStruct = type({ +baseCurrency: string() +}); + +/** + * Exchange rates keyed by currency ticker. + */ +export const GetV1ExchangeRates200Struct = ExchangeRatesStruct; + +export const GetV1ExchangeRatesQueryResponseStruct = GetV1ExchangeRates200Struct; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1FiatExchangeRatesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV1FiatExchangeRatesStruct.ts new file mode 100644 index 0000000000..bebb78f889 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/getV1FiatExchangeRatesStruct.ts @@ -0,0 +1,13 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { ExchangeRatesStruct } from "./exchangeRatesStruct"; + +/** + * Exchange rates keyed by currency ticker. + */ +export const GetV1FiatExchangeRates200Struct = ExchangeRatesStruct; + +export const GetV1FiatExchangeRatesQueryResponseStruct = GetV1FiatExchangeRates200Struct; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1HistoricalPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV1HistoricalPricesStruct.ts new file mode 100644 index 0000000000..34581941f4 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/getV1HistoricalPricesStruct.ts @@ -0,0 +1,25 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { HistoricalPricesStruct } from "./historicalPricesStruct"; +import { VsCurrencyStruct } from "./vsCurrencyStruct"; +import { defaulted, number, optional, string, type } from "@metamask/superstruct"; + +export const GetV1HistoricalPricesPathParamsStruct = type({ +chainId: number(), +tokenAddress: string() +}); + +export const GetV1HistoricalPricesQueryParamsStruct = type({ +vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")), +timePeriod: optional(string()) +}); + +/** + * The historical prices of the token. + */ +export const GetV1HistoricalPrices200Struct = HistoricalPricesStruct; + +export const GetV1HistoricalPricesQueryResponseStruct = GetV1HistoricalPrices200Struct; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1SpotPriceByCoinIdStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV1SpotPriceByCoinIdStruct.ts new file mode 100644 index 0000000000..cf0446167a --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/getV1SpotPriceByCoinIdStruct.ts @@ -0,0 +1,23 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { CoinGeckoSpotPriceStruct } from "./coinGeckoSpotPriceStruct"; +import { VsCurrencyStruct } from "./vsCurrencyStruct"; +import { defaulted, optional, string, type } from "@metamask/superstruct"; + +export const GetV1SpotPriceByCoinIdPathParamsStruct = type({ +coinId: string() +}); + +export const GetV1SpotPriceByCoinIdQueryParamsStruct = type({ +vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")) +}); + +/** + * The spot price of the coin. + */ +export const GetV1SpotPriceByCoinId200Struct = CoinGeckoSpotPriceStruct; + +export const GetV1SpotPriceByCoinIdQueryResponseStruct = GetV1SpotPriceByCoinId200Struct; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1SpotPricesByCoinIdsStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV1SpotPricesByCoinIdsStruct.ts new file mode 100644 index 0000000000..aadcd4ac3d --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/getV1SpotPricesByCoinIdsStruct.ts @@ -0,0 +1,20 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { CoinGeckoSpotPricesStruct } from "./coinGeckoSpotPricesStruct"; +import { VsCurrencyStruct } from "./vsCurrencyStruct"; +import { defaulted, optional, string, type } from "@metamask/superstruct"; + +export const GetV1SpotPricesByCoinIdsQueryParamsStruct = type({ +coinIds: string(), +vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")) +}); + +/** + * Spot prices keyed by CoinGecko coin ID. + */ +export const GetV1SpotPricesByCoinIds200Struct = CoinGeckoSpotPricesStruct; + +export const GetV1SpotPricesByCoinIdsQueryResponseStruct = GetV1SpotPricesByCoinIds200Struct; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1SupportedNetworksStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV1SupportedNetworksStruct.ts new file mode 100644 index 0000000000..bdb7c84e58 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/getV1SupportedNetworksStruct.ts @@ -0,0 +1,13 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { SupportedNetworksStruct } from "./supportedNetworksStruct"; + +/** + * The supported networks, split by level of support. + */ +export const GetV1SupportedNetworks200Struct = SupportedNetworksStruct; + +export const GetV1SupportedNetworksQueryResponseStruct = GetV1SupportedNetworks200Struct; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/getV2SpotPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV2SpotPricesStruct.ts new file mode 100644 index 0000000000..484a7b26ca --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/getV2SpotPricesStruct.ts @@ -0,0 +1,25 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { MarketDataSpotPricesStruct } from "./marketDataSpotPricesStruct"; +import { VsCurrencyStruct } from "./vsCurrencyStruct"; +import { boolean, defaulted, number, optional, string, type } from "@metamask/superstruct"; + +export const GetV2SpotPricesPathParamsStruct = type({ +chainId: number() +}); + +export const GetV2SpotPricesQueryParamsStruct = type({ +tokenAddresses: string(), +vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")), +includeMarketData: optional(defaulted(boolean(), true)) +}); + +/** + * Market data keyed by lowercased token contract address. + */ +export const GetV2SpotPrices200Struct = MarketDataSpotPricesStruct; + +export const GetV2SpotPricesQueryResponseStruct = GetV2SpotPrices200Struct; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/getV2SupportedNetworksStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV2SupportedNetworksStruct.ts new file mode 100644 index 0000000000..bf84847373 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/getV2SupportedNetworksStruct.ts @@ -0,0 +1,13 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { SupportedNetworksStruct } from "./supportedNetworksStruct"; + +/** + * The supported networks, split by level of support. + */ +export const GetV2SupportedNetworks200Struct = SupportedNetworksStruct; + +export const GetV2SupportedNetworksQueryResponseStruct = GetV2SupportedNetworks200Struct; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/getV2TopTokensStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV2TopTokensStruct.ts new file mode 100644 index 0000000000..c77e6bd580 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/getV2TopTokensStruct.ts @@ -0,0 +1,24 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { TopTokenStruct } from "./topTokenStruct"; +import { VsCurrencyStruct } from "./vsCurrencyStruct"; +import { array, defaulted, max, min, number, optional, type } from "@metamask/superstruct"; + +export const GetV2TopTokensPathParamsStruct = type({ +chainId: number() +}); + +export const GetV2TopTokensQueryParamsStruct = type({ +limit: optional(defaulted(max(min(number(), 1), 300), 100)), +vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")) +}); + +/** + * The top tokens ordered by market cap. + */ +export const GetV2TopTokens200Struct = array(TopTokenStruct); + +export const GetV2TopTokensQueryResponseStruct = GetV2TopTokens200Struct; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/getV3HistoricalPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV3HistoricalPricesStruct.ts new file mode 100644 index 0000000000..7b9a1d9063 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/getV3HistoricalPricesStruct.ts @@ -0,0 +1,28 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { V3HistoricalPricesStruct } from "./v3HistoricalPricesStruct"; +import { VsCurrencyStruct } from "./vsCurrencyStruct"; +import { defaulted, enums, number, optional, string, type } from "@metamask/superstruct"; + +export const GetV3HistoricalPricesPathParamsStruct = type({ +chainId: string(), +assetType: string() +}); + +export const GetV3HistoricalPricesQueryParamsStruct = type({ +vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")), +timePeriod: optional(string()), +from: optional(number()), +to: optional(number()), +interval: optional(enums(["5m", "hourly", "daily"])) +}); + +/** + * The historical prices of the asset. + */ +export const GetV3HistoricalPrices200Struct = V3HistoricalPricesStruct; + +export const GetV3HistoricalPricesQueryResponseStruct = GetV3HistoricalPrices200Struct; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/getV3SpotPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV3SpotPricesStruct.ts new file mode 100644 index 0000000000..df2e3dc3b2 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/getV3SpotPricesStruct.ts @@ -0,0 +1,22 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { V3SpotPricesStruct } from "./v3SpotPricesStruct"; +import { VsCurrencyStruct } from "./vsCurrencyStruct"; +import { boolean, defaulted, optional, string, type } from "@metamask/superstruct"; + +export const GetV3SpotPricesQueryParamsStruct = type({ +assetIds: string(), +vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")), +includeMarketData: optional(defaulted(boolean(), false)), +cacheOnly: optional(defaulted(boolean(), false)) +}); + +/** + * Spot prices keyed by CAIP-19 asset ID. Unknown assets map to null. + */ +export const GetV3SpotPrices200Struct = V3SpotPricesStruct; + +export const GetV3SpotPricesQueryResponseStruct = GetV3SpotPrices200Struct; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/historicalPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/historicalPricesStruct.ts new file mode 100644 index 0000000000..811505c19b --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/historicalPricesStruct.ts @@ -0,0 +1,14 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { PricePointStruct } from "./pricePointStruct"; +import { array, type } from "@metamask/superstruct"; + +/** + * Historical prices for a token. + */ +export const HistoricalPricesStruct = type({ +prices: array(PricePointStruct) +}); \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/index.ts b/packages/core-backend/src/generated/price-api/schemas/index.ts new file mode 100644 index 0000000000..fae7767b22 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/index.ts @@ -0,0 +1,25 @@ +export { CoinGeckoSpotPriceStruct } from "./coinGeckoSpotPriceStruct"; +export { CoinGeckoSpotPricesStruct } from "./coinGeckoSpotPricesStruct"; +export { ExchangeRateInfoStruct } from "./exchangeRateInfoStruct"; +export { ExchangeRatesStruct } from "./exchangeRatesStruct"; +export { GetV1ExchangeRates200Struct, GetV1ExchangeRatesQueryParamsStruct, GetV1ExchangeRatesQueryResponseStruct } from "./getV1ExchangeRatesStruct"; +export { GetV1FiatExchangeRates200Struct, GetV1FiatExchangeRatesQueryResponseStruct } from "./getV1FiatExchangeRatesStruct"; +export { GetV1HistoricalPrices200Struct, GetV1HistoricalPricesPathParamsStruct, GetV1HistoricalPricesQueryParamsStruct, GetV1HistoricalPricesQueryResponseStruct } from "./getV1HistoricalPricesStruct"; +export { GetV1SpotPriceByCoinId200Struct, GetV1SpotPriceByCoinIdPathParamsStruct, GetV1SpotPriceByCoinIdQueryParamsStruct, GetV1SpotPriceByCoinIdQueryResponseStruct } from "./getV1SpotPriceByCoinIdStruct"; +export { GetV1SpotPricesByCoinIds200Struct, GetV1SpotPricesByCoinIdsQueryParamsStruct, GetV1SpotPricesByCoinIdsQueryResponseStruct } from "./getV1SpotPricesByCoinIdsStruct"; +export { GetV1SupportedNetworks200Struct, GetV1SupportedNetworksQueryResponseStruct } from "./getV1SupportedNetworksStruct"; +export { GetV2SpotPrices200Struct, GetV2SpotPricesPathParamsStruct, GetV2SpotPricesQueryParamsStruct, GetV2SpotPricesQueryResponseStruct } from "./getV2SpotPricesStruct"; +export { GetV2SupportedNetworks200Struct, GetV2SupportedNetworksQueryResponseStruct } from "./getV2SupportedNetworksStruct"; +export { GetV2TopTokens200Struct, GetV2TopTokensPathParamsStruct, GetV2TopTokensQueryParamsStruct, GetV2TopTokensQueryResponseStruct } from "./getV2TopTokensStruct"; +export { GetV3HistoricalPrices200Struct, GetV3HistoricalPricesPathParamsStruct, GetV3HistoricalPricesQueryParamsStruct, GetV3HistoricalPricesQueryResponseStruct } from "./getV3HistoricalPricesStruct"; +export { GetV3SpotPrices200Struct, GetV3SpotPricesQueryParamsStruct, GetV3SpotPricesQueryResponseStruct } from "./getV3SpotPricesStruct"; +export { HistoricalPricesStruct } from "./historicalPricesStruct"; +export { MarketDataSpotPricesStruct } from "./marketDataSpotPricesStruct"; +export { MarketDataStruct } from "./marketDataStruct"; +export { PricePointStruct } from "./pricePointStruct"; +export { SupportedNetworksStruct } from "./supportedNetworksStruct"; +export { TopTokenStruct } from "./topTokenStruct"; +export { V3HistoricalPricesStruct } from "./v3HistoricalPricesStruct"; +export { V3SpotPriceStruct } from "./v3SpotPriceStruct"; +export { V3SpotPricesStruct } from "./v3SpotPricesStruct"; +export { VsCurrencyStruct } from "./vsCurrencyStruct"; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/marketDataSpotPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/marketDataSpotPricesStruct.ts new file mode 100644 index 0000000000..ff141630b2 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/marketDataSpotPricesStruct.ts @@ -0,0 +1,12 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { MarketDataStruct } from "./marketDataStruct"; +import { record, string } from "@metamask/superstruct"; + +/** + * Market data keyed by lowercased token contract address. + */ +export const MarketDataSpotPricesStruct = record(string(), MarketDataStruct); \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/marketDataStruct.ts b/packages/core-backend/src/generated/price-api/schemas/marketDataStruct.ts new file mode 100644 index 0000000000..9491ad5e2a --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/marketDataStruct.ts @@ -0,0 +1,31 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { number, optional, string, type } from "@metamask/superstruct"; + +/** + * Market data for a token, as returned by the v2 spot prices endpoint. + */ +export const MarketDataStruct = type({ +price: number(), +currency: string(), +priceChange1d: optional(number()), +pricePercentChange1d: optional(number()), +pricePercentChange1h: optional(number()), +pricePercentChange7d: optional(number()), +pricePercentChange14d: optional(number()), +pricePercentChange30d: optional(number()), +pricePercentChange200d: optional(number()), +pricePercentChange1y: optional(number()), +marketCap: optional(number()), +marketCapPercentChange1d: optional(number()), +allTimeHigh: optional(number()), +allTimeLow: optional(number()), +high1d: optional(number()), +low1d: optional(number()), +totalVolume: optional(number()), +circulatingSupply: optional(number()), +dilutedMarketCap: optional(number()) +}); \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/pricePointStruct.ts b/packages/core-backend/src/generated/price-api/schemas/pricePointStruct.ts new file mode 100644 index 0000000000..bf13fd00dc --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/pricePointStruct.ts @@ -0,0 +1,11 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { number, tuple } from "@metamask/superstruct"; + +/** + * A [timestamp, value] tuple. The timestamp is a Unix timestamp in milliseconds. + */ +export const PricePointStruct = tuple([number(), number()]); \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/supportedNetworksStruct.ts b/packages/core-backend/src/generated/price-api/schemas/supportedNetworksStruct.ts new file mode 100644 index 0000000000..4fc3b5255f --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/supportedNetworksStruct.ts @@ -0,0 +1,14 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { array, string, type } from "@metamask/superstruct"; + +/** + * Networks supported by the Price API, split by level of support. + */ +export const SupportedNetworksStruct = type({ +fullSupport: array(string()), +partialSupport: array(string()) +}); \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/topTokenStruct.ts b/packages/core-backend/src/generated/price-api/schemas/topTokenStruct.ts new file mode 100644 index 0000000000..b21ed9e9c4 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/topTokenStruct.ts @@ -0,0 +1,17 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { number, string, type } from "@metamask/superstruct"; + +/** + * A token in the top tokens list. + */ +export const TopTokenStruct = type({ +assetId: string(), +name: string(), +symbol: string(), +price: number(), +marketCap: number() +}); \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/v3HistoricalPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/v3HistoricalPricesStruct.ts new file mode 100644 index 0000000000..f87aca211d --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/v3HistoricalPricesStruct.ts @@ -0,0 +1,16 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { PricePointStruct } from "./pricePointStruct"; +import { array, optional, type } from "@metamask/superstruct"; + +/** + * Historical prices, market caps and total volumes for a CAIP-19 asset. + */ +export const V3HistoricalPricesStruct = type({ +prices: array(PricePointStruct), +marketCaps: optional(array(PricePointStruct)), +totalVolumes: optional(array(PricePointStruct)) +}); \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/v3SpotPriceStruct.ts b/packages/core-backend/src/generated/price-api/schemas/v3SpotPriceStruct.ts new file mode 100644 index 0000000000..386ec76a59 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/v3SpotPriceStruct.ts @@ -0,0 +1,16 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { number, optional, type } from "@metamask/superstruct"; + +/** + * Spot price and optional market data for a CAIP-19 asset. + */ +export const V3SpotPriceStruct = type({ +price: number(), +pricePercentChange1d: optional(number()), +marketCap: optional(number()), +totalVolume: optional(number()) +}); \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/v3SpotPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/v3SpotPricesStruct.ts new file mode 100644 index 0000000000..62169fce29 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/v3SpotPricesStruct.ts @@ -0,0 +1,12 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { V3SpotPriceStruct } from "./v3SpotPriceStruct"; +import { literal, record, string, union } from "@metamask/superstruct"; + +/** + * Spot prices keyed by CAIP-19 asset ID. Assets without a known price map to null. + */ +export const V3SpotPricesStruct = record(string(), union([V3SpotPriceStruct, literal(null)])); \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/schemas/vsCurrencyStruct.ts b/packages/core-backend/src/generated/price-api/schemas/vsCurrencyStruct.ts new file mode 100644 index 0000000000..7b0e0167ab --- /dev/null +++ b/packages/core-backend/src/generated/price-api/schemas/vsCurrencyStruct.ts @@ -0,0 +1,11 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import { defaulted, enums } from "@metamask/superstruct"; + +/** + * A currency that prices can be denominated in. + */ +export const VsCurrencyStruct = defaulted(enums(["btc", "eth", "ltc", "bch", "bnb", "eos", "xrp", "xlm", "link", "dot", "yfi", "usd", "aed", "ars", "aud", "bdt", "bhd", "bmd", "brl", "cad", "chf", "clp", "cny", "czk", "dkk", "eur", "gbp", "gel", "hkd", "huf", "idr", "ils", "inr", "jpy", "krw", "kwd", "lkr", "mmk", "mxn", "myr", "ngn", "nok", "nzd", "php", "pkr", "pln", "rub", "sar", "sek", "sgd", "thb", "try", "twd", "uah", "vef", "vnd", "zar"]), "usd"); \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/CoinGeckoSpotPrice.ts b/packages/core-backend/src/generated/price-api/types/CoinGeckoSpotPrice.ts new file mode 100644 index 0000000000..2e09ae10aa --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/CoinGeckoSpotPrice.ts @@ -0,0 +1,106 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + + +/** + * @description Spot price and market data for a CoinGecko-listed coin. +*/ +export type CoinGeckoSpotPrice = { + /** + * @description CoinGecko coin ID. + * @type string + */ + id: string; + /** + * @description Current price in the requested currency. + * @type number + */ + price: number; + /** + * @description Market capitalization. + * @type number | undefined + */ + marketCap?: number; + /** + * @description All-time high price. + * @type number | undefined + */ + allTimeHigh?: number; + /** + * @description All-time low price. + * @type number | undefined + */ + allTimeLow?: number; + /** + * @description Total trading volume. + * @type number | undefined + */ + totalVolume?: number; + /** + * @description 24h high price. + * @type number | undefined + */ + high1d?: number; + /** + * @description 24h low price. + * @type number | undefined + */ + low1d?: number; + /** + * @description Circulating supply. + * @type number | undefined + */ + circulatingSupply?: number; + /** + * @description Fully diluted market cap. + * @type number | undefined + */ + dilutedMarketCap?: number; + /** + * @description Market cap 24h change percentage. + * @type number | undefined + */ + marketCapPercentChange1d?: number; + /** + * @description 24h price change amount. + * @type number | undefined + */ + priceChange1d?: number; + /** + * @description 1h price change percentage. + * @type number | undefined + */ + pricePercentChange1h?: number; + /** + * @description 24h price change percentage. + * @type number | undefined + */ + pricePercentChange1d?: number; + /** + * @description 7d price change percentage. + * @type number | undefined + */ + pricePercentChange7d?: number; + /** + * @description 14d price change percentage. + * @type number | undefined + */ + pricePercentChange14d?: number; + /** + * @description 30d price change percentage. + * @type number | undefined + */ + pricePercentChange30d?: number; + /** + * @description 200d price change percentage. + * @type number | undefined + */ + pricePercentChange200d?: number; + /** + * @description 1y price change percentage. + * @type number | undefined + */ + pricePercentChange1y?: number; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/CoinGeckoSpotPrices.ts b/packages/core-backend/src/generated/price-api/types/CoinGeckoSpotPrices.ts new file mode 100644 index 0000000000..b0fcfa22e7 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/CoinGeckoSpotPrices.ts @@ -0,0 +1,13 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { CoinGeckoSpotPrice } from "./CoinGeckoSpotPrice"; + +/** + * @description Spot prices keyed by CoinGecko coin ID. +*/ +export type CoinGeckoSpotPrices = { + [key: string]: CoinGeckoSpotPrice; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/ExchangeRateInfo.ts b/packages/core-backend/src/generated/price-api/types/ExchangeRateInfo.ts new file mode 100644 index 0000000000..522104fc2c --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/ExchangeRateInfo.ts @@ -0,0 +1,38 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + + +export const exchangeRateInfoCurrencyTypeEnum = { + crypto: "crypto", + fiat: "fiat" +} as const; + +export type ExchangeRateInfoCurrencyTypeEnumKey = (typeof exchangeRateInfoCurrencyTypeEnum)[keyof typeof exchangeRateInfoCurrencyTypeEnum]; + +/** + * @description Exchange rate details for a single currency. +*/ +export type ExchangeRateInfo = { + /** + * @description Human-readable name of the currency. + * @type string + */ + name: string; + /** + * @description Ticker symbol of the currency. + * @type string + */ + ticker: string; + /** + * @description Exchange rate against the base currency. + * @type number + */ + value: number; + /** + * @description Whether the currency is a cryptocurrency or fiat currency. + * @type string + */ + currencyType: ExchangeRateInfoCurrencyTypeEnumKey; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/ExchangeRates.ts b/packages/core-backend/src/generated/price-api/types/ExchangeRates.ts new file mode 100644 index 0000000000..2b66934ed4 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/ExchangeRates.ts @@ -0,0 +1,13 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { ExchangeRateInfo } from "./ExchangeRateInfo"; + +/** + * @description Exchange rates keyed by currency ticker. +*/ +export type ExchangeRates = { + [key: string]: ExchangeRateInfo; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/GetV1ExchangeRates.ts b/packages/core-backend/src/generated/price-api/types/GetV1ExchangeRates.ts new file mode 100644 index 0000000000..eff6add9ba --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/GetV1ExchangeRates.ts @@ -0,0 +1,27 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { ExchangeRates } from "./ExchangeRates"; + +export type GetV1ExchangeRatesQueryParams = { + /** + * @description The base currency to convert rates against. + * @type string + */ + baseCurrency: string; +}; + +/** + * @description Exchange rates keyed by currency ticker. +*/ +export type GetV1ExchangeRates200 = ExchangeRates; + +export type GetV1ExchangeRatesQueryResponse = GetV1ExchangeRates200; + +export type GetV1ExchangeRatesQuery = { + Response: GetV1ExchangeRates200; + QueryParams: GetV1ExchangeRatesQueryParams; + Errors: any; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/GetV1FiatExchangeRates.ts b/packages/core-backend/src/generated/price-api/types/GetV1FiatExchangeRates.ts new file mode 100644 index 0000000000..69c91e12cc --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/GetV1FiatExchangeRates.ts @@ -0,0 +1,18 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { ExchangeRates } from "./ExchangeRates"; + +/** + * @description Exchange rates keyed by currency ticker. +*/ +export type GetV1FiatExchangeRates200 = ExchangeRates; + +export type GetV1FiatExchangeRatesQueryResponse = GetV1FiatExchangeRates200; + +export type GetV1FiatExchangeRatesQuery = { + Response: GetV1FiatExchangeRates200; + Errors: any; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/GetV1HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/types/GetV1HistoricalPrices.ts new file mode 100644 index 0000000000..fd5e749cff --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/GetV1HistoricalPrices.ts @@ -0,0 +1,48 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { HistoricalPrices } from "./HistoricalPrices"; +import type { VsCurrency } from "./VsCurrency"; + +export type GetV1HistoricalPricesPathParams = { + /** + * @description Decimal chain ID of the network to query. + * @type number + */ + chainId: number; + /** + * @description Contract address of the token to get prices for. + * @type string + */ + tokenAddress: string; +}; + +export type GetV1HistoricalPricesQueryParams = { + /** + * @description A currency that prices can be denominated in. + * @default "usd" + * @type string | undefined + */ + vsCurrency?: VsCurrency; + /** + * @description Time period for the historical prices (e.g. 1d, 7d, 1m, 3m, 1y, 1000d). + * @type string | undefined + */ + timePeriod?: string; +}; + +/** + * @description The historical prices of the token. +*/ +export type GetV1HistoricalPrices200 = HistoricalPrices; + +export type GetV1HistoricalPricesQueryResponse = GetV1HistoricalPrices200; + +export type GetV1HistoricalPricesQuery = { + Response: GetV1HistoricalPrices200; + PathParams: GetV1HistoricalPricesPathParams; + QueryParams: GetV1HistoricalPricesQueryParams; + Errors: any; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/GetV1SpotPriceByCoinId.ts b/packages/core-backend/src/generated/price-api/types/GetV1SpotPriceByCoinId.ts new file mode 100644 index 0000000000..ce7af74758 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/GetV1SpotPriceByCoinId.ts @@ -0,0 +1,38 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { CoinGeckoSpotPrice } from "./CoinGeckoSpotPrice"; +import type { VsCurrency } from "./VsCurrency"; + +export type GetV1SpotPriceByCoinIdPathParams = { + /** + * @description CoinGecko ID of the coin to get the price for. + * @type string + */ + coinId: string; +}; + +export type GetV1SpotPriceByCoinIdQueryParams = { + /** + * @description A currency that prices can be denominated in. + * @default "usd" + * @type string | undefined + */ + vsCurrency?: VsCurrency; +}; + +/** + * @description The spot price of the coin. +*/ +export type GetV1SpotPriceByCoinId200 = CoinGeckoSpotPrice; + +export type GetV1SpotPriceByCoinIdQueryResponse = GetV1SpotPriceByCoinId200; + +export type GetV1SpotPriceByCoinIdQuery = { + Response: GetV1SpotPriceByCoinId200; + PathParams: GetV1SpotPriceByCoinIdPathParams; + QueryParams: GetV1SpotPriceByCoinIdQueryParams; + Errors: any; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/GetV1SpotPricesByCoinIds.ts b/packages/core-backend/src/generated/price-api/types/GetV1SpotPricesByCoinIds.ts new file mode 100644 index 0000000000..e4d7b2552e --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/GetV1SpotPricesByCoinIds.ts @@ -0,0 +1,34 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { CoinGeckoSpotPrices } from "./CoinGeckoSpotPrices"; +import type { VsCurrency } from "./VsCurrency"; + +export type GetV1SpotPricesByCoinIdsQueryParams = { + /** + * @description Comma-separated CoinGecko IDs of the coins to get prices for. + * @type string + */ + coinIds: string; + /** + * @description A currency that prices can be denominated in. + * @default "usd" + * @type string | undefined + */ + vsCurrency?: VsCurrency; +}; + +/** + * @description Spot prices keyed by CoinGecko coin ID. +*/ +export type GetV1SpotPricesByCoinIds200 = CoinGeckoSpotPrices; + +export type GetV1SpotPricesByCoinIdsQueryResponse = GetV1SpotPricesByCoinIds200; + +export type GetV1SpotPricesByCoinIdsQuery = { + Response: GetV1SpotPricesByCoinIds200; + QueryParams: GetV1SpotPricesByCoinIdsQueryParams; + Errors: any; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/GetV1SupportedNetworks.ts b/packages/core-backend/src/generated/price-api/types/GetV1SupportedNetworks.ts new file mode 100644 index 0000000000..cabe18b92e --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/GetV1SupportedNetworks.ts @@ -0,0 +1,18 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { SupportedNetworks } from "./SupportedNetworks"; + +/** + * @description The supported networks, split by level of support. +*/ +export type GetV1SupportedNetworks200 = SupportedNetworks; + +export type GetV1SupportedNetworksQueryResponse = GetV1SupportedNetworks200; + +export type GetV1SupportedNetworksQuery = { + Response: GetV1SupportedNetworks200; + Errors: any; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/GetV2SpotPrices.ts b/packages/core-backend/src/generated/price-api/types/GetV2SpotPrices.ts new file mode 100644 index 0000000000..8e1f96e761 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/GetV2SpotPrices.ts @@ -0,0 +1,49 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { MarketDataSpotPrices } from "./MarketDataSpotPrices"; +import type { VsCurrency } from "./VsCurrency"; + +export type GetV2SpotPricesPathParams = { + /** + * @description Decimal chain ID of the network to query. + * @type number + */ + chainId: number; +}; + +export type GetV2SpotPricesQueryParams = { + /** + * @description Comma-separated token contract addresses to get prices for. + * @type string + */ + tokenAddresses: string; + /** + * @description A currency that prices can be denominated in. + * @default "usd" + * @type string | undefined + */ + vsCurrency?: VsCurrency; + /** + * @description Whether to include market data in the response. + * @default true + * @type boolean | undefined + */ + includeMarketData?: boolean; +}; + +/** + * @description Market data keyed by lowercased token contract address. +*/ +export type GetV2SpotPrices200 = MarketDataSpotPrices; + +export type GetV2SpotPricesQueryResponse = GetV2SpotPrices200; + +export type GetV2SpotPricesQuery = { + Response: GetV2SpotPrices200; + PathParams: GetV2SpotPricesPathParams; + QueryParams: GetV2SpotPricesQueryParams; + Errors: any; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/GetV2SupportedNetworks.ts b/packages/core-backend/src/generated/price-api/types/GetV2SupportedNetworks.ts new file mode 100644 index 0000000000..36eb59e40e --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/GetV2SupportedNetworks.ts @@ -0,0 +1,18 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { SupportedNetworks } from "./SupportedNetworks"; + +/** + * @description The supported networks, split by level of support. +*/ +export type GetV2SupportedNetworks200 = SupportedNetworks; + +export type GetV2SupportedNetworksQueryResponse = GetV2SupportedNetworks200; + +export type GetV2SupportedNetworksQuery = { + Response: GetV2SupportedNetworks200; + Errors: any; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/GetV2TopTokens.ts b/packages/core-backend/src/generated/price-api/types/GetV2TopTokens.ts new file mode 100644 index 0000000000..6f7ec6637a --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/GetV2TopTokens.ts @@ -0,0 +1,46 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { TopToken } from "./TopToken"; +import type { VsCurrency } from "./VsCurrency"; + +export type GetV2TopTokensPathParams = { + /** + * @description Decimal chain ID of the network to query. + * @type number + */ + chainId: number; +}; + +export type GetV2TopTokensQueryParams = { + /** + * @description Maximum number of tokens to return. + * @minLength 1 + * @maxLength 300 + * @default 100 + * @type number | undefined + */ + limit?: number; + /** + * @description A currency that prices can be denominated in. + * @default "usd" + * @type string | undefined + */ + vsCurrency?: VsCurrency; +}; + +/** + * @description The top tokens ordered by market cap. +*/ +export type GetV2TopTokens200 = TopToken[]; + +export type GetV2TopTokensQueryResponse = GetV2TopTokens200; + +export type GetV2TopTokensQuery = { + Response: GetV2TopTokens200; + PathParams: GetV2TopTokensPathParams; + QueryParams: GetV2TopTokensQueryParams; + Errors: any; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/GetV3HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/types/GetV3HistoricalPrices.ts new file mode 100644 index 0000000000..081693a932 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/GetV3HistoricalPrices.ts @@ -0,0 +1,71 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { V3HistoricalPrices } from "./V3HistoricalPrices"; +import type { VsCurrency } from "./VsCurrency"; + +export type GetV3HistoricalPricesPathParams = { + /** + * @description CAIP-2 chain ID of the network to query (e.g. eip155:1). + * @type string + */ + chainId: string; + /** + * @description Asset type portion of the CAIP-19 asset ID (e.g. slip44:60). + * @type string + */ + assetType: string; +}; + +export const getV3HistoricalPricesQueryParamsIntervalEnum = { + "5m": "5m", + hourly: "hourly", + daily: "daily" +} as const; + +export type GetV3HistoricalPricesQueryParamsIntervalEnumKey = (typeof getV3HistoricalPricesQueryParamsIntervalEnum)[keyof typeof getV3HistoricalPricesQueryParamsIntervalEnum]; + +export type GetV3HistoricalPricesQueryParams = { + /** + * @description A currency that prices can be denominated in. + * @default "usd" + * @type string | undefined + */ + vsCurrency?: VsCurrency; + /** + * @description Time period for the historical prices (e.g. 1d, 7d, 1m, 3m, 1y, 1000d). + * @type string | undefined + */ + timePeriod?: string; + /** + * @description Start of the time range as a Unix timestamp in seconds. + * @type number | undefined + */ + from?: number; + /** + * @description End of the time range as a Unix timestamp in seconds. + * @type number | undefined + */ + to?: number; + /** + * @description Data point interval. + * @type string | undefined + */ + interval?: GetV3HistoricalPricesQueryParamsIntervalEnumKey; +}; + +/** + * @description The historical prices of the asset. +*/ +export type GetV3HistoricalPrices200 = V3HistoricalPrices; + +export type GetV3HistoricalPricesQueryResponse = GetV3HistoricalPrices200; + +export type GetV3HistoricalPricesQuery = { + Response: GetV3HistoricalPrices200; + PathParams: GetV3HistoricalPricesPathParams; + QueryParams: GetV3HistoricalPricesQueryParams; + Errors: any; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/GetV3SpotPrices.ts b/packages/core-backend/src/generated/price-api/types/GetV3SpotPrices.ts new file mode 100644 index 0000000000..4c5c31c129 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/GetV3SpotPrices.ts @@ -0,0 +1,46 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { V3SpotPrices } from "./V3SpotPrices"; +import type { VsCurrency } from "./VsCurrency"; + +export type GetV3SpotPricesQueryParams = { + /** + * @description Comma-separated CAIP-19 asset IDs to get prices for. + * @type string + */ + assetIds: string; + /** + * @description A currency that prices can be denominated in. + * @default "usd" + * @type string | undefined + */ + vsCurrency?: VsCurrency; + /** + * @description Whether to include market data in the response. + * @default false + * @type boolean | undefined + */ + includeMarketData?: boolean; + /** + * @description Whether to only return prices that are already cached. + * @default false + * @type boolean | undefined + */ + cacheOnly?: boolean; +}; + +/** + * @description Spot prices keyed by CAIP-19 asset ID. Unknown assets map to null. +*/ +export type GetV3SpotPrices200 = V3SpotPrices; + +export type GetV3SpotPricesQueryResponse = GetV3SpotPrices200; + +export type GetV3SpotPricesQuery = { + Response: GetV3SpotPrices200; + QueryParams: GetV3SpotPricesQueryParams; + Errors: any; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/types/HistoricalPrices.ts new file mode 100644 index 0000000000..ca4680b3ea --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/HistoricalPrices.ts @@ -0,0 +1,17 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { PricePoint } from "./PricePoint"; + +/** + * @description Historical prices for a token. +*/ +export type HistoricalPrices = { + /** + * @description Price data points. + * @type array + */ + prices: PricePoint[]; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/MarketData.ts b/packages/core-backend/src/generated/price-api/types/MarketData.ts new file mode 100644 index 0000000000..a76f9a45e1 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/MarketData.ts @@ -0,0 +1,106 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + + +/** + * @description Market data for a token, as returned by the v2 spot prices endpoint. +*/ +export type MarketData = { + /** + * @description Current price in the requested currency. + * @type number + */ + price: number; + /** + * @description Currency the price is denominated in. + * @type string + */ + currency: string; + /** + * @description 24h price change amount. + * @type number | undefined + */ + priceChange1d?: number; + /** + * @description 24h price change percentage. + * @type number | undefined + */ + pricePercentChange1d?: number; + /** + * @description 1h price change percentage. + * @type number | undefined + */ + pricePercentChange1h?: number; + /** + * @description 7d price change percentage. + * @type number | undefined + */ + pricePercentChange7d?: number; + /** + * @description 14d price change percentage. + * @type number | undefined + */ + pricePercentChange14d?: number; + /** + * @description 30d price change percentage. + * @type number | undefined + */ + pricePercentChange30d?: number; + /** + * @description 200d price change percentage. + * @type number | undefined + */ + pricePercentChange200d?: number; + /** + * @description 1y price change percentage. + * @type number | undefined + */ + pricePercentChange1y?: number; + /** + * @description Market capitalization. + * @type number | undefined + */ + marketCap?: number; + /** + * @description Market cap 24h change percentage. + * @type number | undefined + */ + marketCapPercentChange1d?: number; + /** + * @description All-time high price. + * @type number | undefined + */ + allTimeHigh?: number; + /** + * @description All-time low price. + * @type number | undefined + */ + allTimeLow?: number; + /** + * @description 24h high price. + * @type number | undefined + */ + high1d?: number; + /** + * @description 24h low price. + * @type number | undefined + */ + low1d?: number; + /** + * @description Total trading volume. + * @type number | undefined + */ + totalVolume?: number; + /** + * @description Circulating supply. + * @type number | undefined + */ + circulatingSupply?: number; + /** + * @description Fully diluted market cap. + * @type number | undefined + */ + dilutedMarketCap?: number; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/MarketDataSpotPrices.ts b/packages/core-backend/src/generated/price-api/types/MarketDataSpotPrices.ts new file mode 100644 index 0000000000..202ee9b43c --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/MarketDataSpotPrices.ts @@ -0,0 +1,13 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { MarketData } from "./MarketData"; + +/** + * @description Market data keyed by lowercased token contract address. +*/ +export type MarketDataSpotPrices = { + [key: string]: MarketData; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/PricePoint.ts b/packages/core-backend/src/generated/price-api/types/PricePoint.ts new file mode 100644 index 0000000000..90a3382467 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/PricePoint.ts @@ -0,0 +1,13 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + + +/** + * @description A [timestamp, value] tuple. The timestamp is a Unix timestamp in milliseconds. +*/ +export type PricePoint = [ + number, + number +]; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/SupportedNetworks.ts b/packages/core-backend/src/generated/price-api/types/SupportedNetworks.ts new file mode 100644 index 0000000000..33e280b8f2 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/SupportedNetworks.ts @@ -0,0 +1,21 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + + +/** + * @description Networks supported by the Price API, split by level of support. +*/ +export type SupportedNetworks = { + /** + * @description Chain IDs with full price support. + * @type array + */ + fullSupport: string[]; + /** + * @description Chain IDs with partial price support. + * @type array + */ + partialSupport: string[]; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/TopToken.ts b/packages/core-backend/src/generated/price-api/types/TopToken.ts new file mode 100644 index 0000000000..35946bf16e --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/TopToken.ts @@ -0,0 +1,36 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + + +/** + * @description A token in the top tokens list. +*/ +export type TopToken = { + /** + * @description CAIP-19 asset ID of the token. + * @type string + */ + assetId: string; + /** + * @description Human-readable name of the token. + * @type string + */ + name: string; + /** + * @description Ticker symbol of the token. + * @type string + */ + symbol: string; + /** + * @description Current price in the requested currency. + * @type number + */ + price: number; + /** + * @description Market capitalization. + * @type number + */ + marketCap: number; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/V3HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/types/V3HistoricalPrices.ts new file mode 100644 index 0000000000..2c2036ddea --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/V3HistoricalPrices.ts @@ -0,0 +1,27 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { PricePoint } from "./PricePoint"; + +/** + * @description Historical prices, market caps and total volumes for a CAIP-19 asset. +*/ +export type V3HistoricalPrices = { + /** + * @description Price data points. + * @type array + */ + prices: PricePoint[]; + /** + * @description Market cap data points. + * @type array | undefined + */ + marketCaps?: PricePoint[]; + /** + * @description Total volume data points. + * @type array | undefined + */ + totalVolumes?: PricePoint[]; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/V3SpotPrice.ts b/packages/core-backend/src/generated/price-api/types/V3SpotPrice.ts new file mode 100644 index 0000000000..afcd92f167 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/V3SpotPrice.ts @@ -0,0 +1,31 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + + +/** + * @description Spot price and optional market data for a CAIP-19 asset. +*/ +export type V3SpotPrice = { + /** + * @description Current price in the requested currency. + * @type number + */ + price: number; + /** + * @description 24h price change percentage. + * @type number | undefined + */ + pricePercentChange1d?: number; + /** + * @description Market capitalization. + * @type number | undefined + */ + marketCap?: number; + /** + * @description Total trading volume. + * @type number | undefined + */ + totalVolume?: number; +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/V3SpotPrices.ts b/packages/core-backend/src/generated/price-api/types/V3SpotPrices.ts new file mode 100644 index 0000000000..e586aec8e0 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/V3SpotPrices.ts @@ -0,0 +1,13 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + +import type { V3SpotPrice } from "./V3SpotPrice"; + +/** + * @description Spot prices keyed by CAIP-19 asset ID. Assets without a known price map to null. +*/ +export type V3SpotPrices = { + [key: string]: (V3SpotPrice | null); +}; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/VsCurrency.ts b/packages/core-backend/src/generated/price-api/types/VsCurrency.ts new file mode 100644 index 0000000000..2260ec4832 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/VsCurrency.ts @@ -0,0 +1,73 @@ +/** +* Generated by Kubb (https://kubb.dev/). +* Do not edit manually. +*/ + + +export const vsCurrencyEnum = { + btc: "btc", + eth: "eth", + ltc: "ltc", + bch: "bch", + bnb: "bnb", + eos: "eos", + xrp: "xrp", + xlm: "xlm", + link: "link", + dot: "dot", + yfi: "yfi", + usd: "usd", + aed: "aed", + ars: "ars", + aud: "aud", + bdt: "bdt", + bhd: "bhd", + bmd: "bmd", + brl: "brl", + cad: "cad", + chf: "chf", + clp: "clp", + cny: "cny", + czk: "czk", + dkk: "dkk", + eur: "eur", + gbp: "gbp", + gel: "gel", + hkd: "hkd", + huf: "huf", + idr: "idr", + ils: "ils", + inr: "inr", + jpy: "jpy", + krw: "krw", + kwd: "kwd", + lkr: "lkr", + mmk: "mmk", + mxn: "mxn", + myr: "myr", + ngn: "ngn", + nok: "nok", + nzd: "nzd", + php: "php", + pkr: "pkr", + pln: "pln", + rub: "rub", + sar: "sar", + sek: "sek", + sgd: "sgd", + thb: "thb", + try: "try", + twd: "twd", + uah: "uah", + vef: "vef", + vnd: "vnd", + zar: "zar" +} as const; + +export type VsCurrencyEnumKey = (typeof vsCurrencyEnum)[keyof typeof vsCurrencyEnum]; + +/** + * @description A currency that prices can be denominated in. + * @default usd +*/ +export type VsCurrency = VsCurrencyEnumKey; \ No newline at end of file diff --git a/packages/core-backend/src/generated/price-api/types/index.ts b/packages/core-backend/src/generated/price-api/types/index.ts new file mode 100644 index 0000000000..0209fc7e56 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/index.ts @@ -0,0 +1,28 @@ +export type { CoinGeckoSpotPrice } from "./CoinGeckoSpotPrice"; +export type { CoinGeckoSpotPrices } from "./CoinGeckoSpotPrices"; +export type { ExchangeRateInfo, ExchangeRateInfoCurrencyTypeEnumKey } from "./ExchangeRateInfo"; +export type { ExchangeRates } from "./ExchangeRates"; +export type { GetV1ExchangeRates200, GetV1ExchangeRatesQuery, GetV1ExchangeRatesQueryParams, GetV1ExchangeRatesQueryResponse } from "./GetV1ExchangeRates"; +export type { GetV1FiatExchangeRates200, GetV1FiatExchangeRatesQuery, GetV1FiatExchangeRatesQueryResponse } from "./GetV1FiatExchangeRates"; +export type { GetV1HistoricalPrices200, GetV1HistoricalPricesPathParams, GetV1HistoricalPricesQuery, GetV1HistoricalPricesQueryParams, GetV1HistoricalPricesQueryResponse } from "./GetV1HistoricalPrices"; +export type { GetV1SpotPriceByCoinId200, GetV1SpotPriceByCoinIdPathParams, GetV1SpotPriceByCoinIdQuery, GetV1SpotPriceByCoinIdQueryParams, GetV1SpotPriceByCoinIdQueryResponse } from "./GetV1SpotPriceByCoinId"; +export type { GetV1SpotPricesByCoinIds200, GetV1SpotPricesByCoinIdsQuery, GetV1SpotPricesByCoinIdsQueryParams, GetV1SpotPricesByCoinIdsQueryResponse } from "./GetV1SpotPricesByCoinIds"; +export type { GetV1SupportedNetworks200, GetV1SupportedNetworksQuery, GetV1SupportedNetworksQueryResponse } from "./GetV1SupportedNetworks"; +export type { GetV2SpotPrices200, GetV2SpotPricesPathParams, GetV2SpotPricesQuery, GetV2SpotPricesQueryParams, GetV2SpotPricesQueryResponse } from "./GetV2SpotPrices"; +export type { GetV2SupportedNetworks200, GetV2SupportedNetworksQuery, GetV2SupportedNetworksQueryResponse } from "./GetV2SupportedNetworks"; +export type { GetV2TopTokens200, GetV2TopTokensPathParams, GetV2TopTokensQuery, GetV2TopTokensQueryParams, GetV2TopTokensQueryResponse } from "./GetV2TopTokens"; +export type { GetV3HistoricalPrices200, GetV3HistoricalPricesPathParams, GetV3HistoricalPricesQuery, GetV3HistoricalPricesQueryParams, GetV3HistoricalPricesQueryParamsIntervalEnumKey, GetV3HistoricalPricesQueryResponse } from "./GetV3HistoricalPrices"; +export type { GetV3SpotPrices200, GetV3SpotPricesQuery, GetV3SpotPricesQueryParams, GetV3SpotPricesQueryResponse } from "./GetV3SpotPrices"; +export type { HistoricalPrices } from "./HistoricalPrices"; +export type { MarketData } from "./MarketData"; +export type { MarketDataSpotPrices } from "./MarketDataSpotPrices"; +export type { PricePoint } from "./PricePoint"; +export type { SupportedNetworks } from "./SupportedNetworks"; +export type { TopToken } from "./TopToken"; +export type { V3HistoricalPrices } from "./V3HistoricalPrices"; +export type { V3SpotPrice } from "./V3SpotPrice"; +export type { V3SpotPrices } from "./V3SpotPrices"; +export type { VsCurrency, VsCurrencyEnumKey } from "./VsCurrency"; +export { exchangeRateInfoCurrencyTypeEnum } from "./ExchangeRateInfo"; +export { getV3HistoricalPricesQueryParamsIntervalEnum } from "./GetV3HistoricalPrices"; +export { vsCurrencyEnum } from "./VsCurrency"; \ No newline at end of file diff --git a/packages/core-backend/src/mocks/index.ts b/packages/core-backend/src/mocks/index.ts new file mode 100644 index 0000000000..80d0a1ee99 --- /dev/null +++ b/packages/core-backend/src/mocks/index.ts @@ -0,0 +1,23 @@ +/** + * Test and development mocks for the APIs consumed by this package, + * generated from their OpenAPI documents by Kubb (`yarn codegen`). + * + * Importable as `@metamask/core-backend/mocks`: + * + * ```ts + * import { + * // Faker-based mock data builders + * createGetV3SpotPricesQueryResponse, + * // MSW request handlers + * getV3SpotPricesHandler, + * handlers, + * } from '@metamask/core-backend/mocks'; + * ``` + * + * Using the MSW handlers requires the optional `msw` peer dependency; using + * the mock data builders requires the optional `@faker-js/faker` peer + * dependency. + */ + +export * from '../generated/price-api/mocks'; +export * from '../generated/price-api/msw'; diff --git a/packages/core-backend/src/price-api/index.ts b/packages/core-backend/src/price-api/index.ts new file mode 100644 index 0000000000..fb21e19362 --- /dev/null +++ b/packages/core-backend/src/price-api/index.ts @@ -0,0 +1,26 @@ +/** + * Price API bindings, generated from the API's OpenAPI document by Kubb + * (`yarn codegen`). + * + * Importable as `@metamask/core-backend/price-api`: + * + * ```ts + * import { + * // TypeScript types + * type GetV3SpotPricesQueryResponse, + * // @metamask/superstruct structs + * GetV3SpotPricesQueryResponseStruct, + * // TanStack query-core bindings + * fetchV3SpotPrices, + * getV3SpotPricesQueryOptions, + * } from '@metamask/core-backend/price-api'; + * ``` + * + * The faker mocks and MSW handlers generated from the same document are + * exposed separately through `@metamask/core-backend/mocks`, so this entry + * point stays free of test-only dependencies. + */ + +export * from '../generated/price-api/types'; +export * from '../generated/price-api/schemas'; +export * from '../generated/price-api/queries'; diff --git a/yarn.lock b/yarn.lock index e44825fb42..131ae3705c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -242,7 +242,18 @@ __metadata: languageName: node linkType: hard -"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.12.13, @babel/code-frame@npm:^7.29.7": +"@apidevtools/json-schema-ref-parser@npm:^14.1.1": + version: 14.2.1 + resolution: "@apidevtools/json-schema-ref-parser@npm:14.2.1" + dependencies: + js-yaml: "npm:^4.1.0" + peerDependencies: + "@types/json-schema": ^7.0.15 + checksum: 10/c3f6d97c0e885f9543b0654258ee16b2dd75463c8496499563c278089043317f89010e89eb51699c7fb38dfb83cc8592f0b0c4983b764b56789dc3329b25ebfd + languageName: node + linkType: hard + +"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.12.13, @babel/code-frame@npm:^7.22.5, @babel/code-frame@npm:^7.29.7": version: 7.29.7 resolution: "@babel/code-frame@npm:7.29.7" dependencies: @@ -1626,7 +1637,7 @@ __metadata: languageName: node linkType: hard -"@babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.10.3, @babel/runtime@npm:^7.12.13, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.23.9, @babel/runtime@npm:^7.25.9": +"@babel/runtime@npm:^7.1.2, @babel/runtime@npm:^7.10.3, @babel/runtime@npm:^7.12.13, @babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.18.3, @babel/runtime@npm:^7.22.5, @babel/runtime@npm:^7.23.9, @babel/runtime@npm:^7.25.9": version: 7.29.7 resolution: "@babel/runtime@npm:7.29.7" checksum: 10/9883b4951787779fd382b121f22f92966d85f19434841f65fb00b2dfec232107e139683f47c6f252891826ad8ee18317b46c3a0e4819116a9885f47b46d7126a @@ -1676,6 +1687,56 @@ __metadata: languageName: node linkType: hard +"@bundled-es-modules/cookie@npm:^2.0.1": + version: 2.0.1 + resolution: "@bundled-es-modules/cookie@npm:2.0.1" + dependencies: + cookie: "npm:^0.7.2" + checksum: 10/0038a5e82c41bfcd722afedabeb6961a5f15747b3681d7f4b61e35eb1e33130039e10ee9250dc9c9e4d3915ce1aeee717c0fb92225111574f0a030411abc0987 + languageName: node + linkType: hard + +"@bundled-es-modules/statuses@npm:^1.0.1": + version: 1.0.1 + resolution: "@bundled-es-modules/statuses@npm:1.0.1" + dependencies: + statuses: "npm:^2.0.1" + checksum: 10/9bf6a2bcf040a66fb805da0e1446041fd9def7468bb5da29c5ce02adf121a3f7cec123664308059a62a46fcaee666add83094b76df6dce72e5cafa8e6bebe60d + languageName: node + linkType: hard + +"@bundled-es-modules/tough-cookie@npm:^0.1.6": + version: 0.1.6 + resolution: "@bundled-es-modules/tough-cookie@npm:0.1.6" + dependencies: + "@types/tough-cookie": "npm:^4.0.5" + tough-cookie: "npm:^4.1.4" + checksum: 10/4f24a820f02c08c3ca0ff21272317357152093f76f9c8cc182517f61fa426ae53dadc4d68a3d6da5078e8d73f0ff8c0907a9f994c0be756162ba9c7358533e57 + languageName: node + linkType: hard + +"@clack/core@npm:1.4.3": + version: 1.4.3 + resolution: "@clack/core@npm:1.4.3" + dependencies: + fast-wrap-ansi: "npm:^0.2.0" + sisteransi: "npm:^1.0.5" + checksum: 10/9d875718cb161e0eca97c3ed3ba3063211436c4224a04556b840e045f18505c8fdb645754d9459181069b3a3b6699962d0f47e38e2502cb0acfef1649b3557b3 + languageName: node + linkType: hard + +"@clack/prompts@npm:^1.1.0, @clack/prompts@npm:^1.5.1": + version: 1.7.0 + resolution: "@clack/prompts@npm:1.7.0" + dependencies: + "@clack/core": "npm:1.4.3" + fast-string-width: "npm:^3.0.2" + fast-wrap-ansi: "npm:^0.2.0" + sisteransi: "npm:^1.0.5" + checksum: 10/2bfc89d6755a1e10166a3b7a6cc883a09c1d4d82c08fbe98763284d522f256a58ed20c5ee4ab36f2a6e06bc1b3f0c16b02657159f7d593dab12c55260755f0c2 + languageName: node + linkType: hard + "@colors/colors@npm:1.5.0": version: 1.5.0 resolution: "@colors/colors@npm:1.5.0" @@ -3801,6 +3862,20 @@ __metadata: languageName: node linkType: hard +"@exodus/schemasafe@npm:^1.0.0-rc.2": + version: 1.3.0 + resolution: "@exodus/schemasafe@npm:1.3.0" + checksum: 10/791d9e4b437fe04c6d7cf028d145ed963b8fe973ba6d5811aedf7edea40d5a055a49522241efdafbc32f964c27beaddf1c85fbcc8bf5436cf394623b08e5518b + languageName: node + linkType: hard + +"@faker-js/faker@npm:^9.9.0": + version: 9.9.0 + resolution: "@faker-js/faker@npm:9.9.0" + checksum: 10/b24b1be0fb3090d54abaaa3a814f37d1a7551f1207dcd330a1af2c70f6312a8b95ebb82653577757dd62f4cbbb56caa3c83513053253654dc3e286a05040ecbe + languageName: node + linkType: hard + "@firebase/analytics-compat@npm:0.2.17": version: 0.2.17 resolution: "@firebase/analytics-compat@npm:0.2.17" @@ -4403,6 +4478,13 @@ __metadata: languageName: node linkType: hard +"@humanwhocodes/momoa@npm:^2.0.3": + version: 2.0.4 + resolution: "@humanwhocodes/momoa@npm:2.0.4" + checksum: 10/d3c0601bc0c2ac77bd5804053a6e85698a0dfaec956d538483da79e9ad7467ffa79210293a22249fc9354ffe30e640af0bd386f864b2cd15ea8a48b534620e44 + languageName: node + linkType: hard + "@humanwhocodes/retry@npm:^0.3.0": version: 0.3.1 resolution: "@humanwhocodes/retry@npm:0.3.1" @@ -4417,6 +4499,13 @@ __metadata: languageName: node linkType: hard +"@inquirer/ansi@npm:^1.0.2": + version: 1.0.2 + resolution: "@inquirer/ansi@npm:1.0.2" + checksum: 10/d1496e573a63ee6752bcf3fc93375cdabc55b0d60f0588fe7902282c710b223252ad318ff600ee904e48555634663b53fda517f5b29ce9fbda90bfae18592fbc + languageName: node + linkType: hard + "@inquirer/ansi@npm:^2.0.3, @inquirer/ansi@npm:^2.0.7": version: 2.0.7 resolution: "@inquirer/ansi@npm:2.0.7" @@ -4441,6 +4530,21 @@ __metadata: languageName: node linkType: hard +"@inquirer/confirm@npm:^5.0.0": + version: 5.1.21 + resolution: "@inquirer/confirm@npm:5.1.21" + dependencies: + "@inquirer/core": "npm:^10.3.2" + "@inquirer/type": "npm:^3.0.10" + peerDependencies: + "@types/node": ">=18" + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10/a107aa0073965ea510affb9e5b55baf40333503d600970c458c07770cd4e0eee01efc4caba66f0409b0fadc9550d127329622efb543cffcabff3ad0e7f865372 + languageName: node + linkType: hard + "@inquirer/confirm@npm:^6.0.11, @inquirer/confirm@npm:^6.0.5": version: 6.1.1 resolution: "@inquirer/confirm@npm:6.1.1" @@ -4456,6 +4560,27 @@ __metadata: languageName: node linkType: hard +"@inquirer/core@npm:^10.3.2": + version: 10.3.2 + resolution: "@inquirer/core@npm:10.3.2" + dependencies: + "@inquirer/ansi": "npm:^1.0.2" + "@inquirer/figures": "npm:^1.0.15" + "@inquirer/type": "npm:^3.0.10" + cli-width: "npm:^4.1.0" + mute-stream: "npm:^2.0.0" + signal-exit: "npm:^4.1.0" + wrap-ansi: "npm:^6.2.0" + yoctocolors-cjs: "npm:^2.1.3" + peerDependencies: + "@types/node": ">=18" + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10/eb434bdf0ae7d904367003c772bcd80cbf679f79c087c99a4949fd7288e9a2f713ec3ea63381b9a001f52389ab56a77fcd88d64d81a03b1195193410ce8971c2 + languageName: node + linkType: hard + "@inquirer/core@npm:^11.1.4, @inquirer/core@npm:^11.2.1": version: 11.2.1 resolution: "@inquirer/core@npm:11.2.1" @@ -4522,6 +4647,13 @@ __metadata: languageName: node linkType: hard +"@inquirer/figures@npm:^1.0.15": + version: 1.0.15 + resolution: "@inquirer/figures@npm:1.0.15" + checksum: 10/3f858807f361ca29f41ec1076bbece4098cc140d86a06159d42c6e3f6e4d9bec9e10871ccfcbbaa367d6a8462b01dff89f2b1b157d9de6e8726bec85533f525c + languageName: node + linkType: hard + "@inquirer/figures@npm:^2.0.3, @inquirer/figures@npm:^2.0.7": version: 2.0.7 resolution: "@inquirer/figures@npm:2.0.7" @@ -4646,6 +4778,18 @@ __metadata: languageName: node linkType: hard +"@inquirer/type@npm:^3.0.10": + version: 3.0.10 + resolution: "@inquirer/type@npm:3.0.10" + peerDependencies: + "@types/node": ">=18" + peerDependenciesMeta: + "@types/node": + optional: true + checksum: 10/57d113a9db7abc73326491e29bedc88ef362e53779f9f58a1b61225e0be068ce0c54e33cd65f4a13ca46131676fb72c3ef488463c4c9af0aa89680684c55d74c + languageName: node + linkType: hard + "@inquirer/type@npm:^4.0.3, @inquirer/type@npm:^4.0.7": version: 4.0.7 resolution: "@inquirer/type@npm:4.0.7" @@ -4998,6 +5142,24 @@ __metadata: languageName: node linkType: hard +"@jsep-plugin/assignment@npm:^1.3.0": + version: 1.3.0 + resolution: "@jsep-plugin/assignment@npm:1.3.0" + peerDependencies: + jsep: ^0.4.0||^1.0.0 + checksum: 10/0c93b703d84af95b4be9fb6c23fbdbe7c7b6985b41c98fd10386cd54686ed1eb751cb39f5d54abcb621e4da2a0900a3b2a852e5bf7f2d322b756db3b22e42a45 + languageName: node + linkType: hard + +"@jsep-plugin/regex@npm:^1.0.4": + version: 1.0.4 + resolution: "@jsep-plugin/regex@npm:1.0.4" + peerDependencies: + jsep: ^0.4.0||^1.0.0 + checksum: 10/0ea6ba81f03955972b762fd9fbc8e3fd7e1c1c12e52ce3d4366e23c0a63c8bff8528687b8b3d8f641cf9f626f8bf5a7841efcd31a2489fe967e1900e5738ee3a + languageName: node + linkType: hard + "@json-rpc-specification/meta-schema@npm:^1.0.6": version: 1.0.7 resolution: "@json-rpc-specification/meta-schema@npm:1.0.7" @@ -5287,6 +5449,154 @@ __metadata: languageName: node linkType: hard +"@kubb/ast@npm:4.39.2": + version: 4.39.2 + resolution: "@kubb/ast@npm:4.39.2" + checksum: 10/d9cdb4f4aa3d856ed7099ba3a066719407686df473b735c3f16645e79ca94e1b26ec7232620791147482fe36201b756e3cd35c6c486f4144ec2ec78acb6a433c + languageName: node + linkType: hard + +"@kubb/cli@npm:^4.39.2": + version: 4.39.2 + resolution: "@kubb/cli@npm:4.39.2" + dependencies: + "@clack/prompts": "npm:^1.5.1" + "@kubb/core": "npm:4.39.2" + chokidar: "npm:^5.0.0" + cosmiconfig: "npm:^9.0.1" + jiti: "npm:2.5.1" + tinyexec: "npm:^1.2.4" + bin: + kubb: bin/kubb.cjs + checksum: 10/f6d988090ad42b5023f5f164ad4f278071d7175d31f911d2099b3cf6ec1efe8770b5e62d56ca822ec6831fadb46e4cc1b6f27758867aa1d79a7872ed3ba08d3d + languageName: node + linkType: hard + +"@kubb/core@npm:4.39.2, @kubb/core@npm:^4.39.2": + version: 4.39.2 + resolution: "@kubb/core@npm:4.39.2" + dependencies: + "@kubb/ast": "npm:4.39.2" + "@kubb/fabric-core": "npm:0.14.0" + "@kubb/react-fabric": "npm:0.14.0" + empathic: "npm:^2.0.1" + fflate: "npm:^0.8.3" + remeda: "npm:^2.37.0" + semver: "npm:^7.8.2" + tinyexec: "npm:^1.2.4" + peerDependencies: + "@kubb/fabric-core": 0.14.0 + "@kubb/react-fabric": 0.14.0 + checksum: 10/9bced5291624bfbc3099d0913d0b040eeca9839b638a5ecab8494f4dbc04bfa6c14514f64d01989d08bae73e93a4242b7b3b7c086a292c90bd28e31cf60c5390 + languageName: node + linkType: hard + +"@kubb/fabric-core@npm:0.14.0": + version: 0.14.0 + resolution: "@kubb/fabric-core@npm:0.14.0" + dependencies: + "@clack/prompts": "npm:^1.1.0" + p-limit: "npm:^7.3.0" + remeda: "npm:^2.33.6" + typescript: "npm:5.9.3" + checksum: 10/c824cf1855cba1ded248ba8fa66923fcd01a4d747d0097699f40a3347adde2dc5d78988441bb44b9a53e6da20cab87a68fd402a781dabd4e465dc9ddeabaaa80 + languageName: node + linkType: hard + +"@kubb/oas@npm:4.39.2": + version: 4.39.2 + resolution: "@kubb/oas@npm:4.39.2" + dependencies: + "@kubb/ast": "npm:4.39.2" + "@kubb/core": "npm:4.39.2" + "@kubb/fabric-core": "npm:0.14.0" + "@redocly/openapi-core": "npm:^2.31.6" + "@stoplight/yaml": "npm:^4.3.0" + jsonpointer: "npm:^5.0.1" + oas: "npm:^31.1.2" + oas-normalize: "npm:^16.0.5" + openapi-types: "npm:^12.1.3" + remeda: "npm:^2.37.0" + swagger2openapi: "npm:^7.0.8" + peerDependencies: + "@kubb/fabric-core": 0.14.0 + checksum: 10/3646fe925cd908858e9f5dbf629020b9a4633aa0b98e3092ce59a03015843579fbce12dfb1f7bef0101ac86d2e7fc706471dc5ee18ed4bee531f71455b095299 + languageName: node + linkType: hard + +"@kubb/plugin-faker@npm:4.39.2, @kubb/plugin-faker@npm:^4.39.2": + version: 4.39.2 + resolution: "@kubb/plugin-faker@npm:4.39.2" + dependencies: + "@kubb/core": "npm:4.39.2" + "@kubb/oas": "npm:4.39.2" + "@kubb/plugin-oas": "npm:4.39.2" + "@kubb/plugin-ts": "npm:4.39.2" + "@kubb/react-fabric": "npm:0.14.0" + checksum: 10/1693fb99ebf2a576e84fc95d31f3c258981cd3d6224c07fcaba6dc566786b7366526fd5aa94a0ece4ac7e66000bd3122887ddc6dea21158f25ebf6fe1b7188d8 + languageName: node + linkType: hard + +"@kubb/plugin-msw@npm:^4.39.2": + version: 4.39.2 + resolution: "@kubb/plugin-msw@npm:4.39.2" + dependencies: + "@kubb/core": "npm:4.39.2" + "@kubb/oas": "npm:4.39.2" + "@kubb/plugin-faker": "npm:4.39.2" + "@kubb/plugin-oas": "npm:4.39.2" + "@kubb/plugin-ts": "npm:4.39.2" + "@kubb/react-fabric": "npm:0.14.0" + checksum: 10/800fbb386f568ac403ef7e7c3ddc9a82be1cb0f8027ca64ca69dd8940c94e24e43c1cba2cfc252eb97804a5292c27b6dd5929b7a97c953f3d58a3773b036a77e + languageName: node + linkType: hard + +"@kubb/plugin-oas@npm:4.39.2, @kubb/plugin-oas@npm:^4.39.2": + version: 4.39.2 + resolution: "@kubb/plugin-oas@npm:4.39.2" + dependencies: + "@kubb/core": "npm:4.39.2" + "@kubb/fabric-core": "npm:0.14.0" + "@kubb/oas": "npm:4.39.2" + "@kubb/react-fabric": "npm:0.14.0" + remeda: "npm:^2.37.0" + peerDependencies: + "@kubb/fabric-core": 0.14.0 + "@kubb/react-fabric": 0.14.0 + checksum: 10/624f4a1ec6e9f4be58c7316497f613a0dbf0f3fdd0542845b5b3a563086252886fd223ae4cf19e1b08565f93cc4b9e48252daff1b2dd0992fd66c1eb5dbe0c50 + languageName: node + linkType: hard + +"@kubb/plugin-ts@npm:4.39.2, @kubb/plugin-ts@npm:^4.39.2": + version: 4.39.2 + resolution: "@kubb/plugin-ts@npm:4.39.2" + dependencies: + "@kubb/ast": "npm:4.39.2" + "@kubb/core": "npm:4.39.2" + "@kubb/fabric-core": "npm:0.14.0" + "@kubb/oas": "npm:4.39.2" + "@kubb/plugin-oas": "npm:4.39.2" + "@kubb/react-fabric": "npm:0.14.0" + remeda: "npm:^2.37.0" + typescript: "npm:5.9.3" + peerDependencies: + "@kubb/react-fabric": 0.14.0 + checksum: 10/944d09c6327e4830e30a19fb2f964dece5405fb0c2ebac33d7a6295ae8930edbe08b1f81f9d0bbe8366fa4d18df512659c0a09c1d6b849e07da25270b088f2ab + languageName: node + linkType: hard + +"@kubb/react-fabric@npm:0.14.0": + version: 0.14.0 + resolution: "@kubb/react-fabric@npm:0.14.0" + dependencies: + "@kubb/fabric-core": "npm:0.14.0" + react-devtools-core: "npm:6.1.5" + remeda: "npm:^2.33.6" + ws: "npm:8.18.0" + checksum: 10/aeb85781ff3773edc1346b5820d4ff94dfcfd4ce1af3b27d49ceb3aa307ad28391f9d3ba8b7783b6356684d31ff5e5ebc3a7bb3fd5245792864c9c5ae2ef72c8 + languageName: node + linkType: hard + "@lavamoat/aa@npm:^4.3.0": version: 4.3.0 resolution: "@lavamoat/aa@npm:4.3.0" @@ -6308,12 +6618,20 @@ __metadata: version: 0.0.0-use.local resolution: "@metamask/core-backend@workspace:packages/core-backend" dependencies: + "@faker-js/faker": "npm:^9.9.0" + "@kubb/cli": "npm:^4.39.2" + "@kubb/core": "npm:^4.39.2" + "@kubb/plugin-faker": "npm:^4.39.2" + "@kubb/plugin-msw": "npm:^4.39.2" + "@kubb/plugin-oas": "npm:^4.39.2" + "@kubb/plugin-ts": "npm:^4.39.2" "@metamask/accounts-controller": "npm:^39.0.4" "@metamask/auto-changelog": "npm:^6.1.0" "@metamask/controller-utils": "npm:^12.3.0" "@metamask/keyring-controller": "npm:^27.1.0" "@metamask/messenger": "npm:^2.0.0" "@metamask/profile-sync-controller": "npm:^28.2.0" + "@metamask/superstruct": "npm:^3.3.0" "@metamask/utils": "npm:^11.11.0" "@tanstack/query-core": "npm:^5.62.16" "@ts-bridge/cli": "npm:^0.6.4" @@ -6322,12 +6640,21 @@ __metadata: deepmerge: "npm:^4.2.2" jest: "npm:^29.7.0" jest-environment-jsdom: "npm:^29.7.0" + msw: "npm:~2.10.5" ts-jest: "npm:^29.2.5" tsx: "npm:^4.20.5" typedoc: "npm:^0.25.13" typedoc-plugin-missing-exports: "npm:^2.0.0" typescript: "npm:~5.3.3" uuid: "npm:^8.3.2" + peerDependencies: + "@faker-js/faker": ^9.9.0 + msw: ^2.14.6 + peerDependenciesMeta: + "@faker-js/faker": + optional: true + msw: + optional: true languageName: unknown linkType: soft @@ -9123,6 +9450,20 @@ __metadata: languageName: unknown linkType: soft +"@mswjs/interceptors@npm:^0.39.1": + version: 0.39.8 + resolution: "@mswjs/interceptors@npm:0.39.8" + dependencies: + "@open-draft/deferred-promise": "npm:^2.2.0" + "@open-draft/logger": "npm:^0.3.0" + "@open-draft/until": "npm:^2.0.0" + is-node-process: "npm:^1.2.0" + outvariant: "npm:^1.4.3" + strict-event-emitter: "npm:^0.5.1" + checksum: 10/d92546cf9bf670ddb927c53f5fa19f0554b7475a264ead4e1ae2339874f4312fe4ada5d42588f27eea3577bee29fa8f46889d398f0e7ecb3f7a4c1d3e0b71bdc + languageName: node + linkType: hard + "@myx-trade/sdk@npm:^0.1.265": version: 0.1.265 resolution: "@myx-trade/sdk@npm:0.1.265" @@ -9685,6 +10026,30 @@ __metadata: languageName: node linkType: hard +"@open-draft/deferred-promise@npm:^2.2.0": + version: 2.2.0 + resolution: "@open-draft/deferred-promise@npm:2.2.0" + checksum: 10/bc3bb1668a555bb87b33383cafcf207d9561e17d2ca0d9e61b7ce88e82b66e36a333d3676c1d39eb5848022c03c8145331fcdc828ba297f88cb1de9c5cef6c19 + languageName: node + linkType: hard + +"@open-draft/logger@npm:^0.3.0": + version: 0.3.0 + resolution: "@open-draft/logger@npm:0.3.0" + dependencies: + is-node-process: "npm:^1.2.0" + outvariant: "npm:^1.4.0" + checksum: 10/7a280f170bcd4e91d3eedbefe628efd10c3bd06dd2461d06a7fdbced89ef457a38785847f88cc630fb4fd7dfa176d6f77aed17e5a9b08000baff647433b5ff78 + languageName: node + linkType: hard + +"@open-draft/until@npm:^2.0.0, @open-draft/until@npm:^2.1.0": + version: 2.1.0 + resolution: "@open-draft/until@npm:2.1.0" + checksum: 10/622be42950afc8e89715d0fd6d56cbdcd13e36625e23b174bd3d9f06f80e25f9adf75d6698af93bca1e1bf465b9ce00ec05214a12189b671fb9da0f58215b6f4 + languageName: node + linkType: hard + "@open-rpc/meta-schema@npm:^1.14.6, @open-rpc/meta-schema@npm:^1.14.9": version: 1.14.9 resolution: "@open-rpc/meta-schema@npm:1.14.9" @@ -10406,6 +10771,106 @@ __metadata: languageName: node linkType: hard +"@readme/better-ajv-errors@npm:^2.3.2": + version: 2.4.0 + resolution: "@readme/better-ajv-errors@npm:2.4.0" + dependencies: + "@babel/code-frame": "npm:^7.22.5" + "@babel/runtime": "npm:^7.22.5" + "@humanwhocodes/momoa": "npm:^2.0.3" + jsonpointer: "npm:^5.0.0" + leven: "npm:^3.1.0" + picocolors: "npm:^1.1.1" + peerDependencies: + ajv: 4.11.8 - 8 + checksum: 10/989b0b9eb4b8ce5a28bf05dc1550242dc694590bc2097e76cba91222ae00ad58f67b2b062aa93e89ea7bfbb001a76e1b7b9ec9b25a60bb83b516e9b255eb4bff + languageName: node + linkType: hard + +"@readme/http-status-codes@npm:^7.2.0": + version: 7.2.0 + resolution: "@readme/http-status-codes@npm:7.2.0" + checksum: 10/c3b36650fada6d39e2578e230b52b855ef053c8b8091202a47115f899ab4e91730cb90e22f9e1fbc52451649154847e93ba8e30741b20cf6e15994351baaa8f4 + languageName: node + linkType: hard + +"@readme/openapi-parser@npm:^6.0.0, @readme/openapi-parser@npm:^6.2.0": + version: 6.2.0 + resolution: "@readme/openapi-parser@npm:6.2.0" + dependencies: + "@apidevtools/json-schema-ref-parser": "npm:^14.1.1" + "@readme/better-ajv-errors": "npm:^2.3.2" + "@readme/openapi-schemas": "npm:^3.1.0" + "@types/json-schema": "npm:^7.0.15" + ajv: "npm:^8.20.0" + ajv-draft-04: "npm:^1.0.0" + peerDependencies: + openapi-types: ">=7" + checksum: 10/4502b935a77ab201b8a9023d1d6822476bf18494282a61584bbecb9a5d0125fa0fc13fb6495a2b10a5b27c35d3bab26a6c46683e41d1c26151fbe3a1265ed09d + languageName: node + linkType: hard + +"@readme/openapi-schemas@npm:^3.1.0": + version: 3.1.0 + resolution: "@readme/openapi-schemas@npm:3.1.0" + checksum: 10/0ab4f5b6b1939cc99f926b157cd70330aae6fedf5842c6b2526810350035dceebbe00c22b095a1e8814ac46d07c70718ee519e39501005b2db875bffe1bd649b + languageName: node + linkType: hard + +"@readme/postman-to-openapi@npm:^4.1.0": + version: 4.1.0 + resolution: "@readme/postman-to-openapi@npm:4.1.0" + dependencies: + "@readme/http-status-codes": "npm:^7.2.0" + js-yaml: "npm:^4.1.0" + jsonc-parser: "npm:3.2.0" + lodash.camelcase: "npm:^4.3.0" + marked: "npm:^4.3.0" + mustache: "npm:^4.2.0" + checksum: 10/6c1c034dbdde7192d72325ce50d9fb27a513d6249a634a5969a4572487187ef846c82d16f1adf03cceac12ebb554faf00188b25714544da273acd03ad370f9be + languageName: node + linkType: hard + +"@redocly/ajv@npm:^8.18.1": + version: 8.18.3 + resolution: "@redocly/ajv@npm:8.18.3" + dependencies: + fast-deep-equal: "npm:^3.1.3" + fast-uri: "npm:^3.0.1" + json-schema-traverse: "npm:^1.0.0" + require-from-string: "npm:^2.0.2" + checksum: 10/5cdcc45c1a69d02fc3cd152a9c8b68f0a7346f80626254df937a43d86ee5279c991e5f7c21664adf46bae2be2fa137142a96dc3832f274c80d6ab745a5d0608a + languageName: node + linkType: hard + +"@redocly/config@npm:^0.50.0": + version: 0.50.1 + resolution: "@redocly/config@npm:0.50.1" + dependencies: + json-schema-to-ts: "npm:2.7.2" + checksum: 10/f8ec1c94e62c691bb1c4548ef532b25f6e642cd2cc6c0f3bf279cc6e65aa439e566f60cdbec490b3963aae7a286186b4577193920305aa606a2d51fa7d2f447e + languageName: node + linkType: hard + +"@redocly/openapi-core@npm:^2.31.6": + version: 2.37.0 + resolution: "@redocly/openapi-core@npm:2.37.0" + dependencies: + "@redocly/ajv": "npm:^8.18.1" + "@redocly/config": "npm:^0.50.0" + ajv: "npm:@redocly/ajv@8.18.1" + ajv-formats: "npm:^3.0.1" + colorette: "npm:^1.2.0" + graphql: "npm:^16.14.1" + js-levenshtein: "npm:^1.1.6" + js-yaml: "npm:^4.2.0" + picomatch: "npm:^4.0.4" + pluralize: "npm:^8.0.0" + yaml-ast-parser: "npm:0.0.43" + checksum: 10/9b15f55fc8c7181c0bebff5bb55bcc1252e23d0b9bb6196145aeca5bd44373eb875fa82c09e72026295ae075d4e165d9a37c21ab85bf6d2f6d5e9df8542e0d35 + languageName: node + linkType: hard + "@scure/base@npm:^1.0.0, @scure/base@npm:^1.1.1, @scure/base@npm:^1.1.3, @scure/base@npm:~1.2.5": version: 1.2.6 resolution: "@scure/base@npm:1.2.6" @@ -10675,6 +11140,42 @@ __metadata: languageName: node linkType: hard +"@stoplight/ordered-object-literal@npm:^1.0.5": + version: 1.0.5 + resolution: "@stoplight/ordered-object-literal@npm:1.0.5" + checksum: 10/d12374f46ef8ab7237196024cc387aa50c0ec8029a421ef1eac726d342687f79972a9d0f0dc39802719511b8f8a82f06b3859b8219ada040a7640bf9d954cd62 + languageName: node + linkType: hard + +"@stoplight/types@npm:^14.1.1": + version: 14.1.1 + resolution: "@stoplight/types@npm:14.1.1" + dependencies: + "@types/json-schema": "npm:^7.0.4" + utility-types: "npm:^3.10.0" + checksum: 10/1d053f4276872a1c31ef809ec13f57fcfcc3cac65cdd74ddc735c3b4397da6f8a5a8efd99d8c4f5d74cd8342dd28def304d69a4ef623e1f94bd0d5efe6e368be + languageName: node + linkType: hard + +"@stoplight/yaml-ast-parser@npm:0.0.50": + version: 0.0.50 + resolution: "@stoplight/yaml-ast-parser@npm:0.0.50" + checksum: 10/f3683c515eec5f5abcd301fad9c37f290506b8feeffc72fdb269c733561a5f6a8fa6f30acc67b861fd350b3859eb6ab9993373ed838dbf157d11d72b3319cfe9 + languageName: node + linkType: hard + +"@stoplight/yaml@npm:^4.3.0": + version: 4.3.0 + resolution: "@stoplight/yaml@npm:4.3.0" + dependencies: + "@stoplight/ordered-object-literal": "npm:^1.0.5" + "@stoplight/types": "npm:^14.1.1" + "@stoplight/yaml-ast-parser": "npm:0.0.50" + tslib: "npm:^2.2.0" + checksum: 10/4a3eacfb5fb8936cb4b229f69542224e5905f71a6e2baeb70f73a67de6ce3b20178079a79d7744a437db901f67740dcdfd9b53dafb918ce75cbbb498ec548fd7 + languageName: node + linkType: hard + "@svgr/babel-plugin-add-jsx-attribute@npm:8.0.0": version: 8.0.0 resolution: "@svgr/babel-plugin-add-jsx-attribute@npm:8.0.0" @@ -11089,6 +11590,13 @@ __metadata: languageName: node linkType: hard +"@types/cookie@npm:^0.6.0": + version: 0.6.0 + resolution: "@types/cookie@npm:0.6.0" + checksum: 10/b883348d5bf88695fbc2c2276b1c49859267a55cae3cf11ea1dccc1b3be15b466e637ce3242109ba27d616c77c6aa4efe521e3d557110b4fdd9bc332a12445c2 + languageName: node + linkType: hard + "@types/debug@npm:^4.0.0, @types/debug@npm:^4.1.7": version: 4.1.13 resolution: "@types/debug@npm:4.1.13" @@ -11318,7 +11826,7 @@ __metadata: languageName: node linkType: hard -"@types/json-schema@npm:*, @types/json-schema@npm:^7.0.15, @types/json-schema@npm:^7.0.8, @types/json-schema@npm:^7.0.9": +"@types/json-schema@npm:*, @types/json-schema@npm:^7.0.11, @types/json-schema@npm:^7.0.15, @types/json-schema@npm:^7.0.4, @types/json-schema@npm:^7.0.8, @types/json-schema@npm:^7.0.9": version: 7.0.15 resolution: "@types/json-schema@npm:7.0.15" checksum: 10/1a3c3e06236e4c4aab89499c428d585527ce50c24fe8259e8b3926d3df4cfbbbcf306cfc73ddfb66cbafc973116efd15967020b0f738f63e09e64c7d260519e7 @@ -11596,7 +12104,14 @@ __metadata: languageName: node linkType: hard -"@types/tough-cookie@npm:*": +"@types/statuses@npm:^2.0.4": + version: 2.0.6 + resolution: "@types/statuses@npm:2.0.6" + checksum: 10/dadfbb4f32a16d3106a8e2a957dab17b1ae99fc4788e1fd96aeaf82355e3b2b069d5ea0f5fb887efa830def033828955a5bbdfd35454ba2088822537aed9e5db + languageName: node + linkType: hard + +"@types/tough-cookie@npm:*, @types/tough-cookie@npm:^4.0.5": version: 4.0.5 resolution: "@types/tough-cookie@npm:4.0.5" checksum: 10/01fd82efc8202670865928629697b62fe9bf0c0dcbc5b1c115831caeb073a2c0abb871ff393d7df1ae94ea41e256cb87d2a5a91fd03cdb1b0b4384e08d4ee482 @@ -12169,6 +12684,18 @@ __metadata: languageName: node linkType: hard +"ajv-draft-04@npm:^1.0.0": + version: 1.0.0 + resolution: "ajv-draft-04@npm:1.0.0" + peerDependencies: + ajv: ^8.5.0 + peerDependenciesMeta: + ajv: + optional: true + checksum: 10/3f11fa0e7f7359bef6608657f02ab78e9cc62b1fb7bdd860db0d00351b3863a1189c1a23b72466d2d82726cab4eb20725c76f5e7c134a89865e2bfd0e6828137 + languageName: node + linkType: hard + "ajv-formats@npm:^2.1.1": version: 2.1.1 resolution: "ajv-formats@npm:2.1.1" @@ -12183,6 +12710,20 @@ __metadata: languageName: node linkType: hard +"ajv-formats@npm:^3.0.1": + version: 3.0.1 + resolution: "ajv-formats@npm:3.0.1" + dependencies: + ajv: "npm:^8.0.0" + peerDependencies: + ajv: ^8.0.0 + peerDependenciesMeta: + ajv: + optional: true + checksum: 10/5679b9f9ced9d0213a202a37f3aa91efcffe59a6de1a6e3da5c873344d3c161820a1f11cc29899661fee36271fd2895dd3851b6461c902a752ad661d1c1e8722 + languageName: node + linkType: hard + "ajv-keywords@npm:^3.5.2": version: 3.5.2 resolution: "ajv-keywords@npm:3.5.2" @@ -12203,9 +12744,21 @@ __metadata: languageName: node linkType: hard -"ajv@npm:^6.10.0, ajv@npm:^6.12.4, ajv@npm:^6.12.5": - version: 6.15.0 - resolution: "ajv@npm:6.15.0" +"ajv@npm:@redocly/ajv@8.18.1": + version: 8.18.1 + resolution: "@redocly/ajv@npm:8.18.1" + dependencies: + fast-deep-equal: "npm:^3.1.3" + fast-uri: "npm:^3.0.1" + json-schema-traverse: "npm:^1.0.0" + require-from-string: "npm:^2.0.2" + checksum: 10/1e821304bbfb3c8bef6f80db301efc5bd63a78051cc66a0f6d76cc0ac62a99192b0093115aa4cd196ac7832f7d9505174d7664d528b51e268feba2929a7c92ed + languageName: node + linkType: hard + +"ajv@npm:^6.10.0, ajv@npm:^6.12.4, ajv@npm:^6.12.5": + version: 6.15.0 + resolution: "ajv@npm:6.15.0" dependencies: fast-deep-equal: "npm:^3.1.1" fast-json-stable-stringify: "npm:^2.0.0" @@ -12215,7 +12768,7 @@ __metadata: languageName: node linkType: hard -"ajv@npm:^8.0.0, ajv@npm:^8.9.0": +"ajv@npm:^8.0.0, ajv@npm:^8.20.0, ajv@npm:^8.9.0": version: 8.20.0 resolution: "ajv@npm:8.20.0" dependencies: @@ -13189,6 +13742,13 @@ __metadata: languageName: node linkType: hard +"call-me-maybe@npm:^1.0.1": + version: 1.0.2 + resolution: "call-me-maybe@npm:1.0.2" + checksum: 10/3d375b6f810a82c751157b199daba60452876186c19ac653e81bfc5fc10d1e2ba7aedb8622367c3a8aca6879f0e6a29435a1193b35edb8f7fd8267a67ea32373 + languageName: node + linkType: hard + "callsites@npm:^3.0.0": version: 3.1.0 resolution: "callsites@npm:3.1.0" @@ -13379,6 +13939,15 @@ __metadata: languageName: node linkType: hard +"chokidar@npm:^5.0.0": + version: 5.0.0 + resolution: "chokidar@npm:5.0.0" + dependencies: + readdirp: "npm:^5.0.0" + checksum: 10/a1c2a4ee6ee81ba6409712c295a47be055fb9de1186dfbab33c1e82f28619de962ba02fc5f9d433daaedc96c35747460d8b2079ac2907de2c95e3f7cce913113 + languageName: node + linkType: hard + "chownr@npm:^1.1.1": version: 1.1.4 resolution: "chownr@npm:1.1.4" @@ -13591,6 +14160,13 @@ __metadata: languageName: node linkType: hard +"colorette@npm:^1.2.0": + version: 1.4.0 + resolution: "colorette@npm:1.4.0" + checksum: 10/c8d6c8c3ef5a99acfc3dd9a68f48019f1479ec347551387e4a1762e40f69e98ce19d4dc321ffb4919d1f28a7bdc90c39d4e9a901f4c474fd2124ad93a00c0454 + languageName: node + linkType: hard + "colorette@npm:^2.0.10": version: 2.0.20 resolution: "colorette@npm:2.0.20" @@ -13719,6 +14295,29 @@ __metadata: languageName: node linkType: hard +"compute-gcd@npm:^1.2.1": + version: 1.2.1 + resolution: "compute-gcd@npm:1.2.1" + dependencies: + validate.io-array: "npm:^1.0.3" + validate.io-function: "npm:^1.0.2" + validate.io-integer-array: "npm:^1.0.0" + checksum: 10/51cf33b75f7c8db5142fcb99a9d84a40260993fed8e02a7ab443834186c3ab99b3fd20b30ad9075a6a9d959d69df6da74dd3be8a59c78d9f2fe780ebda8242e1 + languageName: node + linkType: hard + +"compute-lcm@npm:^1.1.2": + version: 1.1.2 + resolution: "compute-lcm@npm:1.1.2" + dependencies: + compute-gcd: "npm:^1.2.1" + validate.io-array: "npm:^1.0.3" + validate.io-function: "npm:^1.0.2" + validate.io-integer-array: "npm:^1.0.0" + checksum: 10/d499ab57dcb48e8d0fd233b99844a06d1cc56115602c920c586e998ebba60293731f5b6976e8a1e83ae6cbfe86716f62d9432e8d94913fed8bd8352f447dc917 + languageName: node + linkType: hard + "concat-map@npm:0.0.1": version: 0.0.1 resolution: "concat-map@npm:0.0.1" @@ -13849,7 +14448,7 @@ __metadata: languageName: node linkType: hard -"cookie@npm:~0.7.1": +"cookie@npm:^0.7.2, cookie@npm:~0.7.1": version: 0.7.2 resolution: "cookie@npm:0.7.2" checksum: 10/24b286c556420d4ba4e9bc09120c9d3db7d28ace2bd0f8ccee82422ce42322f73c8312441271e5eefafbead725980e5996cc02766dbb89a90ac7f5636ede608f @@ -13926,6 +14525,23 @@ __metadata: languageName: node linkType: hard +"cosmiconfig@npm:^9.0.1": + version: 9.0.2 + resolution: "cosmiconfig@npm:9.0.2" + dependencies: + env-paths: "npm:^2.2.1" + import-fresh: "npm:^3.3.0" + js-yaml: "npm:^4.1.0" + parse-json: "npm:^5.2.0" + peerDependencies: + typescript: ">=4.9.5" + peerDependenciesMeta: + typescript: + optional: true + checksum: 10/e7b08c9c6ed862852bf0ed88c8fa49c57276d976901c9332c87d831926f332c32df3f5ff6a87f3823c3b7c5d6f857a7fd34336e0c2c596fa2d73e6cccbb7bf58 + languageName: node + linkType: hard + "crc-32@npm:^1.2.0": version: 1.2.2 resolution: "crc-32@npm:1.2.2" @@ -14296,6 +14912,16 @@ __metadata: languageName: node linkType: hard +"d@npm:1, d@npm:^1.0.1, d@npm:^1.0.2": + version: 1.0.2 + resolution: "d@npm:1.0.2" + dependencies: + es5-ext: "npm:^0.10.64" + type: "npm:^2.7.2" + checksum: 10/a3f45ef964622f683f6a1cb9b8dcbd75ce490cd2f4ac9794099db3d8f0e2814d412d84cd3fe522e58feb1f273117bb480f29c5381f6225f0abca82517caaa77a + languageName: node + linkType: hard + "data-urls@npm:^3.0.2": version: 3.0.2 resolution: "data-urls@npm:3.0.2" @@ -14831,6 +15457,13 @@ __metadata: languageName: node linkType: hard +"empathic@npm:^2.0.1": + version: 2.0.1 + resolution: "empathic@npm:2.0.1" + checksum: 10/c5a37b78926e722c38779e5026342350098771fa1cacb52cb808e5329896ab39abb88cd2f1374671d6e5c98aa24cba2534f00da2938d04f11de1a2d012ee75c3 + languageName: node + linkType: hard + "encodeurl@npm:~2.0.0": version: 2.0.0 resolution: "encodeurl@npm:2.0.0" @@ -14904,7 +15537,7 @@ __metadata: languageName: node linkType: hard -"env-paths@npm:^2.2.0": +"env-paths@npm:^2.2.0, env-paths@npm:^2.2.1": version: 2.2.1 resolution: "env-paths@npm:2.2.1" checksum: 10/65b5df55a8bab92229ab2b40dad3b387fad24613263d103a97f91c9fe43ceb21965cd3392b1ccb5d77088021e525c4e0481adb309625d0cb94ade1d1fb8dc17e @@ -14964,6 +15597,58 @@ __metadata: languageName: node linkType: hard +"es5-ext@npm:^0.10.35, es5-ext@npm:^0.10.46, es5-ext@npm:^0.10.62, es5-ext@npm:^0.10.64, es5-ext@npm:~0.10.14, es5-ext@npm:~0.10.2": + version: 0.10.64 + resolution: "es5-ext@npm:0.10.64" + dependencies: + es6-iterator: "npm:^2.0.3" + es6-symbol: "npm:^3.1.3" + esniff: "npm:^2.0.1" + next-tick: "npm:^1.1.0" + checksum: 10/0c5d8657708b1695ddc4b06f4e0b9fbdda4d2fe46d037b6bedb49a7d1931e542ec9eecf4824d59e1d357e93229deab014bb4b86485db2d41b1d68e54439689ce + languageName: node + linkType: hard + +"es6-iterator@npm:^2.0.3": + version: 2.0.3 + resolution: "es6-iterator@npm:2.0.3" + dependencies: + d: "npm:1" + es5-ext: "npm:^0.10.35" + es6-symbol: "npm:^3.1.1" + checksum: 10/dbadecf3d0e467692815c2b438dfa99e5a97cbbecf4a58720adcb467a04220e0e36282399ba297911fd472c50ae4158fffba7ed0b7d4273fe322b69d03f9e3a5 + languageName: node + linkType: hard + +"es6-promise@npm:^3.2.1": + version: 3.3.1 + resolution: "es6-promise@npm:3.3.1" + checksum: 10/14f46a0a20164d4d6f8a39133c7220688bb9ee2d89a78f2345694b8ac9b6ea7b94f73488e289a083dce732831f4040013b25222d1820580c7b10b698c50c8267 + languageName: node + linkType: hard + +"es6-symbol@npm:^3.1.1, es6-symbol@npm:^3.1.3": + version: 3.1.4 + resolution: "es6-symbol@npm:3.1.4" + dependencies: + d: "npm:^1.0.2" + ext: "npm:^1.7.0" + checksum: 10/3743119fe61f89e2f049a6ce52bd82fab5f65d13e2faa72453b73f95c15292c3cb9bdf3747940d504517e675e45fd375554c6b5d35d2bcbefd35f5489ecba546 + languageName: node + linkType: hard + +"es6-weak-map@npm:^2.0.3": + version: 2.0.3 + resolution: "es6-weak-map@npm:2.0.3" + dependencies: + d: "npm:1" + es5-ext: "npm:^0.10.46" + es6-iterator: "npm:^2.0.3" + es6-symbol: "npm:^3.1.1" + checksum: 10/5958a321cf8dfadc82b79eeaa57dc855893a4afd062b4ef5c9ded0010d3932099311272965c3d3fdd3c85df1d7236013a570e704fa6c1f159bbf979c203dd3a3 + languageName: node + linkType: hard + "esast-util-from-estree@npm:^2.0.0": version: 2.0.0 resolution: "esast-util-from-estree@npm:2.0.0" @@ -15402,6 +16087,18 @@ __metadata: languageName: node linkType: hard +"esniff@npm:^2.0.1": + version: 2.0.1 + resolution: "esniff@npm:2.0.1" + dependencies: + d: "npm:^1.0.1" + es5-ext: "npm:^0.10.62" + event-emitter: "npm:^0.3.5" + type: "npm:^2.7.2" + checksum: 10/f6a2abd2f8c5fe57c5fcf53e5407c278023313d0f6c3a92688e7122ab9ac233029fd424508a196ae5bc561aa1f67d23f4e2435b1a0d378030f476596129056ac + languageName: node + linkType: hard + "espree@npm:^10.0.1, espree@npm:^10.1.0, espree@npm:^10.4.0": version: 10.4.0 resolution: "espree@npm:10.4.0" @@ -15691,6 +16388,16 @@ __metadata: languageName: node linkType: hard +"event-emitter@npm:^0.3.5": + version: 0.3.5 + resolution: "event-emitter@npm:0.3.5" + dependencies: + d: "npm:1" + es5-ext: "npm:~0.10.14" + checksum: 10/a7f5ea80029193f4869782d34ef7eb43baa49cd397013add1953491b24588468efbe7e3cc9eb87d53f33397e7aab690fd74c079ec440bf8b12856f6bdb6e9396 + languageName: node + linkType: hard + "event-target-shim@npm:^5.0.0": version: 5.0.1 resolution: "event-target-shim@npm:5.0.1" @@ -15837,6 +16544,15 @@ __metadata: languageName: node linkType: hard +"ext@npm:^1.7.0": + version: 1.7.0 + resolution: "ext@npm:1.7.0" + dependencies: + type: "npm:^2.7.2" + checksum: 10/666a135980b002df0e75c8ac6c389140cdc59ac953db62770479ee2856d58ce69d2f845e5f2586716350b725400f6945e51e9159573158c39f369984c72dcd84 + languageName: node + linkType: hard + "extend-shallow@npm:^2.0.1": version: 2.0.1 resolution: "extend-shallow@npm:2.0.1" @@ -16070,6 +16786,13 @@ __metadata: languageName: node linkType: hard +"fflate@npm:^0.8.3": + version: 0.8.3 + resolution: "fflate@npm:0.8.3" + checksum: 10/6ebf528dc9c56e78e715eac615b009b25dc33e15c1920b11ebba44e6d76181c647756a81a23e19247907496b93aa99928514c53090579a65109e026ac2824aa7 + languageName: node + linkType: hard + "file-entry-cache@npm:^8.0.0": version: 8.0.0 resolution: "file-entry-cache@npm:8.0.0" @@ -16672,6 +17395,13 @@ __metadata: languageName: node linkType: hard +"graphql@npm:^16.14.1, graphql@npm:^16.8.1": + version: 16.14.2 + resolution: "graphql@npm:16.14.2" + checksum: 10/cd9a2581508f82621112a4dc625714e81ce725ab0a62502d97c14f61fee180e85276ac64bf9094f4fbf237737832ad4bb970aa26088f9dffece56f8919a49a29 + languageName: node + linkType: hard + "gray-matter@npm:^4.0.3": version: 4.0.3 resolution: "gray-matter@npm:4.0.3" @@ -16917,6 +17647,13 @@ __metadata: languageName: node linkType: hard +"headers-polyfill@npm:^4.0.2": + version: 4.0.3 + resolution: "headers-polyfill@npm:4.0.3" + checksum: 10/3a008aa2ef71591e2077706efb48db1b2729b90cf646cc217f9b69744e35cca4ba463f39debb6000904aa7de4fada2e5cc682463025d26bcc469c1d99fa5af27 + languageName: node + linkType: hard + "history@npm:^4.9.0": version: 4.10.1 resolution: "history@npm:4.10.1" @@ -17190,6 +17927,13 @@ __metadata: languageName: node linkType: hard +"http2-client@npm:^1.2.5": + version: 1.3.5 + resolution: "http2-client@npm:1.3.5" + checksum: 10/34ef17ea2814acbf9d9b5184f9e2c0767846d62abc357bd63c67b3d1f65e7b6ba772d4950ec4f5188686d3d8bfa15e3fb73721150db5bdb47bcefdba71734729 + languageName: node + linkType: hard + "http2-wrapper@npm:^2.1.10": version: 2.2.1 resolution: "http2-wrapper@npm:2.2.1" @@ -17676,6 +18420,13 @@ __metadata: languageName: node linkType: hard +"is-node-process@npm:^1.2.0": + version: 1.2.0 + resolution: "is-node-process@npm:1.2.0" + checksum: 10/930765cdc6d81ab8f1bbecbea4a8d35c7c6d88a3ff61f3630e0fc7f22d624d7661c1df05c58547d0eb6a639dfa9304682c8e342c4113a6ed51472b704cee2928 + languageName: node + linkType: hard + "is-npm@npm:^6.0.0": version: 6.1.0 resolution: "is-npm@npm:6.1.0" @@ -17741,6 +18492,13 @@ __metadata: languageName: node linkType: hard +"is-promise@npm:^2.2.2": + version: 2.2.2 + resolution: "is-promise@npm:2.2.2" + checksum: 10/18bf7d1c59953e0ad82a1ed963fb3dc0d135c8f299a14f89a17af312fc918373136e56028e8831700e1933519630cc2fd4179a777030330fde20d34e96f40c78 + languageName: node + linkType: hard + "is-regexp@npm:^1.0.0": version: 1.0.0 resolution: "is-regexp@npm:1.0.0" @@ -18450,6 +19208,15 @@ __metadata: languageName: node linkType: hard +"jiti@npm:2.5.1": + version: 2.5.1 + resolution: "jiti@npm:2.5.1" + bin: + jiti: lib/jiti-cli.mjs + checksum: 10/699f94c5c4e8952019b8d412de63a2517ed1f9e8514e61058f67de378525ec82f39c69b2d34cdebb136be95805b87367e67d1195f87897c325e3019ed3329f00 + languageName: node + linkType: hard + "jiti@npm:^1.20.0": version: 1.21.7 resolution: "jiti@npm:1.21.7" @@ -18481,6 +19248,13 @@ __metadata: languageName: node linkType: hard +"js-levenshtein@npm:^1.1.6": + version: 1.1.6 + resolution: "js-levenshtein@npm:1.1.6" + checksum: 10/bb034043fdebab606122fe5b5c0316036f1bb0ea352038af8b0ba4cda4b016303b24f64efb59d9918f66e3680eea97ff421396ff3c153cb00a6f982908f61f8a + languageName: node + linkType: hard + "js-sha3@npm:0.5.5": version: 0.5.5 resolution: "js-sha3@npm:0.5.5" @@ -18539,6 +19313,17 @@ __metadata: languageName: node linkType: hard +"js-yaml@npm:^4.2.0": + version: 4.3.0 + resolution: "js-yaml@npm:4.3.0" + dependencies: + argparse: "npm:^2.0.1" + bin: + js-yaml: bin/js-yaml.js + checksum: 10/2bcec3a8118d7f744badeb04e14366578d234a736f353d41fe35d2305e4ce2409a8e041d277f07cd6bbc8aaa12128d650a68ce43247072519bede20962d2126f + languageName: node + linkType: hard + "jsbn@npm:1.1.0": version: 1.1.0 resolution: "jsbn@npm:1.1.0" @@ -18592,6 +19377,13 @@ __metadata: languageName: node linkType: hard +"jsep@npm:^1.4.0": + version: 1.4.0 + resolution: "jsep@npm:1.4.0" + checksum: 10/935824fe6ac28fcff3cd13878f508f99f6c13e7f0f53ec9fca0d3db465e6dd15f8af030bcdc75a38b07c78359c656647435923a26aceb91607027021f00c17f2 + languageName: node + linkType: hard + "jsesc@npm:^3.0.2, jsesc@npm:~3.1.0": version: 3.1.0 resolution: "jsesc@npm:3.1.0" @@ -18638,6 +19430,37 @@ __metadata: languageName: node linkType: hard +"json-schema-compare@npm:^0.2.2": + version: 0.2.2 + resolution: "json-schema-compare@npm:0.2.2" + dependencies: + lodash: "npm:^4.17.4" + checksum: 10/90af65174517b281ffe93fc398946f215a9c1a0a4fe15a50723755e347c4305a2c208ea07d6cee3108c2db22d82b8d5410c006b8dc9cd1a9b4a7d4eb9a727fc1 + languageName: node + linkType: hard + +"json-schema-merge-allof@npm:^0.8.1": + version: 0.8.1 + resolution: "json-schema-merge-allof@npm:0.8.1" + dependencies: + compute-lcm: "npm:^1.1.2" + json-schema-compare: "npm:^0.2.2" + lodash: "npm:^4.17.20" + checksum: 10/a12d8690038cedd7391ac1f7d5897b2d7b8fb867174839ec7583f53b025ad0a90ccefab572bafdf0a5421b3434305c5797ffd6209edc835527b325e6a1a5d562 + languageName: node + linkType: hard + +"json-schema-to-ts@npm:2.7.2": + version: 2.7.2 + resolution: "json-schema-to-ts@npm:2.7.2" + dependencies: + "@babel/runtime": "npm:^7.18.3" + "@types/json-schema": "npm:^7.0.9" + ts-algebra: "npm:^1.2.0" + checksum: 10/e372eb5c652b9c1af470976f8a71d8b26db2b938914e9113ceb67bf3fbc03881d2dee41b76fbc93eaeb3bb28a6f2f0921ce8ce7725fa8d1f243fab4288a8ad2b + languageName: node + linkType: hard + "json-schema-traverse@npm:^0.4.1": version: 0.4.1 resolution: "json-schema-traverse@npm:0.4.1" @@ -18675,6 +19498,13 @@ __metadata: languageName: node linkType: hard +"jsonc-parser@npm:3.2.0": + version: 3.2.0 + resolution: "jsonc-parser@npm:3.2.0" + checksum: 10/bd68b902e5f9394f01da97921f49c5084b2dc03a0c5b4fdb2a429f8d6f292686c1bf87badaeb0a8148d024192a88f5ad2e57b2918ba43fe25cf15f3371db64d4 + languageName: node + linkType: hard + "jsonc-parser@npm:^3.2.0": version: 3.3.1 resolution: "jsonc-parser@npm:3.3.1" @@ -18695,6 +19525,27 @@ __metadata: languageName: node linkType: hard +"jsonpath-plus@npm:^10.4.0": + version: 10.4.0 + resolution: "jsonpath-plus@npm:10.4.0" + dependencies: + "@jsep-plugin/assignment": "npm:^1.3.0" + "@jsep-plugin/regex": "npm:^1.0.4" + jsep: "npm:^1.4.0" + bin: + jsonpath: bin/jsonpath-cli.js + jsonpath-plus: bin/jsonpath-cli.js + checksum: 10/0ff33c7eb6500d7c8d789ce15a63ac2c46cb01b855f1c53729ca9e3833e0253af70277fc1799ebfe0b3130ddc03c127562669b999729dd11f2621b81472248d4 + languageName: node + linkType: hard + +"jsonpointer@npm:^5.0.0, jsonpointer@npm:^5.0.1": + version: 5.0.1 + resolution: "jsonpointer@npm:5.0.1" + checksum: 10/0b40f712900ad0c846681ea2db23b6684b9d5eedf55807b4708c656f5894b63507d0e28ae10aa1bddbea551241035afe62b6df0800fc94c2e2806a7f3adecd7c + languageName: node + linkType: hard + "jsonschema@npm:^1.4.1": version: 1.4.1 resolution: "jsonschema@npm:1.4.1" @@ -18928,7 +19779,7 @@ __metadata: languageName: node linkType: hard -"lodash@npm:^4.17.20, lodash@npm:^4.17.21": +"lodash@npm:^4.17.20, lodash@npm:^4.17.21, lodash@npm:^4.17.4": version: 4.18.1 resolution: "lodash@npm:4.18.1" checksum: 10/306fea53dfd39dad1f03d45ba654a2405aebd35797b673077f401edb7df2543623dc44b9effbb98f69b32152295fff725a4cec99c684098947430600c6af0c3f @@ -19006,6 +19857,15 @@ __metadata: languageName: node linkType: hard +"lru-queue@npm:^0.1.0": + version: 0.1.0 + resolution: "lru-queue@npm:0.1.0" + dependencies: + es5-ext: "npm:~0.10.2" + checksum: 10/55b08ee3a7dbefb7d8ee2d14e0a97c69a887f78bddd9e28a687a1944b57e09513d4b401db515279e8829d52331df12a767f3ed27ca67c3322c723cc25c06403f + languageName: node + linkType: hard + "lunr-languages@npm:^1.4.0": version: 1.20.0 resolution: "lunr-languages@npm:1.20.0" @@ -19428,6 +20288,22 @@ __metadata: languageName: node linkType: hard +"memoizee@npm:^0.4.16": + version: 0.4.17 + resolution: "memoizee@npm:0.4.17" + dependencies: + d: "npm:^1.0.2" + es5-ext: "npm:^0.10.64" + es6-weak-map: "npm:^2.0.3" + event-emitter: "npm:^0.3.5" + is-promise: "npm:^2.2.2" + lru-queue: "npm:^0.1.0" + next-tick: "npm:^1.1.0" + timers-ext: "npm:^0.1.7" + checksum: 10/b7abda74d1057878f3570c45995f24da8a4f8636e0e9a7c29a6709be2314bf40c7d78e3be93c0b1660ba419de5740fa5e447c400ab5df407ffbd236421066380 + languageName: node + linkType: hard + "merge-descriptors@npm:1.0.3": version: 1.0.3 resolution: "merge-descriptors@npm:1.0.3" @@ -20271,6 +21147,39 @@ __metadata: languageName: node linkType: hard +"msw@npm:~2.10.5": + version: 2.10.5 + resolution: "msw@npm:2.10.5" + dependencies: + "@bundled-es-modules/cookie": "npm:^2.0.1" + "@bundled-es-modules/statuses": "npm:^1.0.1" + "@bundled-es-modules/tough-cookie": "npm:^0.1.6" + "@inquirer/confirm": "npm:^5.0.0" + "@mswjs/interceptors": "npm:^0.39.1" + "@open-draft/deferred-promise": "npm:^2.2.0" + "@open-draft/until": "npm:^2.1.0" + "@types/cookie": "npm:^0.6.0" + "@types/statuses": "npm:^2.0.4" + graphql: "npm:^16.8.1" + headers-polyfill: "npm:^4.0.2" + is-node-process: "npm:^1.2.0" + outvariant: "npm:^1.4.3" + path-to-regexp: "npm:^6.3.0" + picocolors: "npm:^1.1.1" + strict-event-emitter: "npm:^0.5.1" + type-fest: "npm:^4.26.1" + yargs: "npm:^17.7.2" + peerDependencies: + typescript: ">= 4.8.x" + peerDependenciesMeta: + typescript: + optional: true + bin: + msw: cli/index.js + checksum: 10/9e48c1d4d5e3da35720ab915f5e5624330203a6eb8d824f426d736635b884769c8ca0863634364c9f4b2466208049964706778ce69f31fdb7c35ae47064f396f + languageName: node + linkType: hard + "multicast-dns@npm:^7.2.5": version: 7.2.5 resolution: "multicast-dns@npm:7.2.5" @@ -20290,6 +21199,22 @@ __metadata: languageName: node linkType: hard +"mustache@npm:^4.2.0": + version: 4.2.0 + resolution: "mustache@npm:4.2.0" + bin: + mustache: bin/mustache + checksum: 10/6e668bd5803255ab0779c3983b9412b5c4f4f90e822230e0e8f414f5449ed7a137eed29430e835aa689886f663385cfe05f808eb34b16e1f3a95525889b05cd3 + languageName: node + linkType: hard + +"mute-stream@npm:^2.0.0": + version: 2.0.0 + resolution: "mute-stream@npm:2.0.0" + checksum: 10/d2e4fd2f5aa342b89b98134a8d899d8ef9b0a6d69274c4af9df46faa2d97aeb1f2ce83d867880d6de63643c52386579b99139801e24e7526c3b9b0a6d1e18d6c + languageName: node + linkType: hard + "mute-stream@npm:^3.0.0": version: 3.0.0 resolution: "mute-stream@npm:3.0.0" @@ -20341,6 +21266,13 @@ __metadata: languageName: node linkType: hard +"next-tick@npm:^1.1.0": + version: 1.1.0 + resolution: "next-tick@npm:1.1.0" + checksum: 10/83b5cf36027a53ee6d8b7f9c0782f2ba87f4858d977342bfc3c20c21629290a2111f8374d13a81221179603ffc4364f38374b5655d17b6a8f8a8c77bdea4fe8b + languageName: node + linkType: hard + "no-case@npm:^3.0.4": version: 3.0.4 resolution: "no-case@npm:3.0.4" @@ -20401,6 +21333,15 @@ __metadata: languageName: node linkType: hard +"node-fetch-h2@npm:^2.3.0": + version: 2.3.0 + resolution: "node-fetch-h2@npm:2.3.0" + dependencies: + http2-client: "npm:^1.2.5" + checksum: 10/9495b4e52cfb23241a1bca187640a15bcaacb7a0667a825074f9dbf2c1a9b10fedd5344d775d57dea8944eeee1049959a3f662492e2f57d6d5f34c7d296e7c65 + languageName: node + linkType: hard + "node-fetch@npm:^2.6.1, node-fetch@npm:^2.7.0": version: 2.7.0 resolution: "node-fetch@npm:2.7.0" @@ -20453,6 +21394,15 @@ __metadata: languageName: node linkType: hard +"node-readfiles@npm:^0.2.0": + version: 0.2.0 + resolution: "node-readfiles@npm:0.2.0" + dependencies: + es6-promise: "npm:^3.2.1" + checksum: 10/1db0f009955665e63983395f38c2479ef18b4ea8db1d12e03c155238ebe567f2e83981c0e47ac7c6d29ab4a3628082d5e02683e62d26e1af79852e0d8b77e3fb + languageName: node + linkType: hard + "node-releases@npm:^2.0.36": version: 2.0.46 resolution: "node-releases@npm:2.0.46" @@ -20623,6 +21573,95 @@ __metadata: languageName: node linkType: hard +"oas-kit-common@npm:^1.0.8": + version: 1.0.8 + resolution: "oas-kit-common@npm:1.0.8" + dependencies: + fast-safe-stringify: "npm:^2.0.7" + checksum: 10/576ab5f7c7fde551a9c780fde9392cb9dec5159b62c3ad4499e334bffdb12e089e97dccf2a9d0d1ac5be208f9d6f0e72da5ac3744d878134ef0177eed135cc52 + languageName: node + linkType: hard + +"oas-linter@npm:^3.2.2": + version: 3.2.2 + resolution: "oas-linter@npm:3.2.2" + dependencies: + "@exodus/schemasafe": "npm:^1.0.0-rc.2" + should: "npm:^13.2.1" + yaml: "npm:^1.10.0" + checksum: 10/8111c6c759648215b466e0e507e21e3c125762caf925dff28628c1ac0144bc82fe7f231a3249dd0400dff051574b4d5a7bbcc64b95d2f2f7e41a3377e859c395 + languageName: node + linkType: hard + +"oas-normalize@npm:^16.0.5": + version: 16.1.1 + resolution: "oas-normalize@npm:16.1.1" + dependencies: + "@readme/openapi-parser": "npm:^6.2.0" + "@readme/postman-to-openapi": "npm:^4.1.0" + js-yaml: "npm:^4.2.0" + openapi-types: "npm:^12.1.3" + swagger2openapi: "npm:^7.0.8" + checksum: 10/94687fbb5ef637e9bfb5f0c8daa74cf8f5f9f85fb967838c21bfa82cd7b17c5ad00d8e87c17e6b534fe6f5d1458141386bceaa590883a5cb69d270526a75a115 + languageName: node + linkType: hard + +"oas-resolver@npm:^2.5.6": + version: 2.5.6 + resolution: "oas-resolver@npm:2.5.6" + dependencies: + node-fetch-h2: "npm:^2.3.0" + oas-kit-common: "npm:^1.0.8" + reftools: "npm:^1.1.9" + yaml: "npm:^1.10.0" + yargs: "npm:^17.0.1" + bin: + resolve: resolve.js + checksum: 10/9e20118bf722cb9e9f71a7079336ce705259eb380fa9c2a776d9647b93725314c23abdb6b7b3bc3c91a3559485bbb729447f72ce0c3ca9ce48281b8214a9612d + languageName: node + linkType: hard + +"oas-schema-walker@npm:^1.1.5": + version: 1.1.5 + resolution: "oas-schema-walker@npm:1.1.5" + checksum: 10/27bdeda1ebcf557b90cfb5d2ac3ca8e851f601d96215747c19ce0ae8f8458ad8012701b615fe313eacf4665b733f46ec12870f72d453251217b8a3ceb2be9abf + languageName: node + linkType: hard + +"oas-validator@npm:^5.0.8": + version: 5.0.8 + resolution: "oas-validator@npm:5.0.8" + dependencies: + call-me-maybe: "npm:^1.0.1" + oas-kit-common: "npm:^1.0.8" + oas-linter: "npm:^3.2.2" + oas-resolver: "npm:^2.5.6" + oas-schema-walker: "npm:^1.1.5" + reftools: "npm:^1.1.9" + should: "npm:^13.2.1" + yaml: "npm:^1.10.0" + checksum: 10/3e392d6c99659e58860b78ef1a46eaf8ad782449fe9a21ccb594b74f88a2c211d39ab9d016ec08c995d8728a250229aba84cb02ca3381f0fb2cc1e6782f4e21a + languageName: node + linkType: hard + +"oas@npm:^31.1.2": + version: 31.1.2 + resolution: "oas@npm:31.1.2" + dependencies: + "@apidevtools/json-schema-ref-parser": "npm:^14.1.1" + "@readme/openapi-parser": "npm:^6.0.0" + "@types/json-schema": "npm:^7.0.11" + json-schema-merge-allof: "npm:^0.8.1" + jsonpath-plus: "npm:^10.4.0" + jsonpointer: "npm:^5.0.0" + memoizee: "npm:^0.4.16" + openapi-types: "npm:^12.1.1" + path-to-regexp: "npm:^8.1.0" + remove-undefined-objects: "npm:^7.0.0" + checksum: 10/602767c3362d91297797f05b8e084960dab172bdbf749f72ff2fac8536587ca1848a81c85237ac72ef465f0d6ea24299a1233a1f38008572693ffc0f83ead1cb + languageName: node + linkType: hard + "object-assign@npm:^4.1.1": version: 4.1.1 resolution: "object-assign@npm:4.1.1" @@ -20731,6 +21770,13 @@ __metadata: languageName: node linkType: hard +"openapi-types@npm:^12.1.1, openapi-types@npm:^12.1.3": + version: 12.1.3 + resolution: "openapi-types@npm:12.1.3" + checksum: 10/9d1d7ed848622b63d0a4c3f881689161b99427133054e46b8e3241e137f1c78bb0031c5d80b420ee79ac2e91d2e727ffd6fc13c553d1b0488ddc8ad389dcbef8 + languageName: node + linkType: hard + "opener@npm:^1.5.2": version: 1.5.2 resolution: "opener@npm:1.5.2" @@ -20754,6 +21800,13 @@ __metadata: languageName: node linkType: hard +"outvariant@npm:^1.4.0, outvariant@npm:^1.4.3": + version: 1.4.3 + resolution: "outvariant@npm:1.4.3" + checksum: 10/3a7582745850cb344d49641867a4c080858c54f4091afd91b9c0765ba6e471c2bc841348f0fff344845ddd0a4db42fd5d68c6f7ebaf32d4b676a3a9987b2488a + languageName: node + linkType: hard + "ox@npm:0.14.20": version: 0.14.20 resolution: "ox@npm:0.14.20" @@ -21021,6 +22074,15 @@ __metadata: languageName: node linkType: hard +"p-limit@npm:^7.3.0": + version: 7.3.0 + resolution: "p-limit@npm:7.3.0" + dependencies: + yocto-queue: "npm:^1.2.1" + checksum: 10/bd3f3487ec84401e2cbf243122eef11813edacb621a27808e60a425646d0e75a79514acc2c01e39c41911550dbae5ef0f0ab01caa61cfc1c541cd17a19e8f01b + languageName: node + linkType: hard + "p-locate@npm:^4.1.0": version: 4.1.0 resolution: "p-locate@npm:4.1.0" @@ -21327,6 +22389,20 @@ __metadata: languageName: node linkType: hard +"path-to-regexp@npm:^6.3.0": + version: 6.3.0 + resolution: "path-to-regexp@npm:6.3.0" + checksum: 10/6822f686f01556d99538b350722ef761541ec0ce95ca40ce4c29e20a5b492fe8361961f57993c71b2418de12e604478dcf7c430de34b2c31a688363a7a944d9c + languageName: node + linkType: hard + +"path-to-regexp@npm:^8.1.0": + version: 8.4.2 + resolution: "path-to-regexp@npm:8.4.2" + checksum: 10/70fd2cbce0b962cbcf4d312af07818bfce2bae11c09cf3bd86be99c0e30168238a1a7b02b18b452e73f075897df04597d30d63e56da7be41eecfc37998693389 + languageName: node + linkType: hard + "path-to-regexp@npm:~0.1.12": version: 0.1.13 resolution: "path-to-regexp@npm:0.1.13" @@ -21421,6 +22497,13 @@ __metadata: languageName: node linkType: hard +"pluralize@npm:^8.0.0": + version: 8.0.0 + resolution: "pluralize@npm:8.0.0" + checksum: 10/17877fdfdb7ddb3639ce257ad73a7c51a30a966091e40f56ea9f2f545b5727ce548d4928f8cb3ce38e7dc0c5150407d318af6a4ed0ea5265d378473b4c2c61ec + languageName: node + linkType: hard + "pony-cause@npm:^2.1.10, pony-cause@npm:^2.1.9": version: 2.1.11 resolution: "pony-cause@npm:2.1.11" @@ -22646,6 +23729,16 @@ __metadata: languageName: node linkType: hard +"react-devtools-core@npm:6.1.5": + version: 6.1.5 + resolution: "react-devtools-core@npm:6.1.5" + dependencies: + shell-quote: "npm:^1.6.1" + ws: "npm:^7" + checksum: 10/0323f1d006979374b79ac83fced5bb10c04f2817d7bd4338074ead815ff441b943290d563d7796233767dd973787116a4b3c62040de4d770e0ae5b207fc8d480 + languageName: node + linkType: hard + "react-dom@npm:^19.0.0": version: 19.2.6 resolution: "react-dom@npm:19.2.6" @@ -22836,6 +23929,13 @@ __metadata: languageName: node linkType: hard +"readdirp@npm:^5.0.0": + version: 5.0.0 + resolution: "readdirp@npm:5.0.0" + checksum: 10/a17a591b51d8b912083660df159e8bd17305dc1a9ef27c869c818bd95ff59e3a6496f97e91e724ef433e789d559d24e39496ea1698822eb5719606dc9c1a923d + languageName: node + linkType: hard + "readdirp@npm:~3.6.0": version: 3.6.0 resolution: "readdirp@npm:3.6.0" @@ -22909,6 +24009,13 @@ __metadata: languageName: node linkType: hard +"reftools@npm:^1.1.9": + version: 1.1.9 + resolution: "reftools@npm:1.1.9" + checksum: 10/6a124748f1c4af84bf651c31c76b7ed0a7f766533530a80cbf2d2517b26e6bfaadc0b1b3e399675343328ab861ab04881e64c8bc3c2f40fc7be27a8aacf8775e + languageName: node + linkType: hard + "regenerate-unicode-properties@npm:^10.2.2": version: 10.2.2 resolution: "regenerate-unicode-properties@npm:10.2.2" @@ -23108,6 +24215,20 @@ __metadata: languageName: node linkType: hard +"remeda@npm:^2.33.6, remeda@npm:^2.37.0": + version: 2.39.0 + resolution: "remeda@npm:2.39.0" + checksum: 10/5b0dc3aaf291a4b35c694bd1cd6584c1aeab90de31da47797c5e83f1cda2553a33cf557fe199d9a06c29814f608b808722ad82a51245e99f85df1b633f792258 + languageName: node + linkType: hard + +"remove-undefined-objects@npm:^7.0.0": + version: 7.0.0 + resolution: "remove-undefined-objects@npm:7.0.0" + checksum: 10/1d34044480b4ae8198b7f393f4aa0ca203e460049fa0193c9918ac0e39c4cf88751db14c30910961be63dafe673e833fce540283b850eac51227ae89ab6b963b + languageName: node + linkType: hard + "renderkid@npm:^3.0.0": version: 3.0.0 resolution: "renderkid@npm:3.0.0" @@ -23530,6 +24651,15 @@ __metadata: languageName: node linkType: hard +"semver@npm:^7.8.2": + version: 7.8.5 + resolution: "semver@npm:7.8.5" + bin: + semver: bin/semver.js + checksum: 10/9b01d2ff11e6e4a4539b7ca3c5f280c8704cb397a28504469f2ed4f00ad2194748d756647362a9712fff30984d15772ab7f083108c2fb508e2096ae9e708f22c + languageName: node + linkType: hard + "send@npm:~0.19.0, send@npm:~0.19.1": version: 0.19.2 resolution: "send@npm:0.19.2" @@ -23699,6 +24829,13 @@ __metadata: languageName: node linkType: hard +"shell-quote@npm:^1.6.1": + version: 1.9.0 + resolution: "shell-quote@npm:1.9.0" + checksum: 10/c3bc91e74a469c4f96b6fd13b0c777fff16bcbda202692a4e5402d3d6b78fc6e02fe92fdf8dc0bddf992a9c6758e43207bfc5bdbefbf8a58190b1c885cbcc171 + languageName: node + linkType: hard + "shell-quote@npm:^1.8.3": version: 1.8.4 resolution: "shell-quote@npm:1.8.4" @@ -23718,6 +24855,62 @@ __metadata: languageName: node linkType: hard +"should-equal@npm:^2.0.0": + version: 2.0.0 + resolution: "should-equal@npm:2.0.0" + dependencies: + should-type: "npm:^1.4.0" + checksum: 10/700e38f7815937f15e415b29df45ae22929c98c87979eb71e3a1085ba94cd0c601f435272eef3c9399ff74fa2d424df37ff03672f61ceda21630edcc77810744 + languageName: node + linkType: hard + +"should-format@npm:^3.0.3": + version: 3.0.3 + resolution: "should-format@npm:3.0.3" + dependencies: + should-type: "npm:^1.3.0" + should-type-adaptors: "npm:^1.0.1" + checksum: 10/099157f4f9bf458919bce8e981438e139c21789bb45f8b5cd8cf4bf01c5df498f1a1e666211bfd906b72b77d645a187563554ab38af807f8cd1aaf270e326186 + languageName: node + linkType: hard + +"should-type-adaptors@npm:^1.0.1": + version: 1.1.0 + resolution: "should-type-adaptors@npm:1.1.0" + dependencies: + should-type: "npm:^1.3.0" + should-util: "npm:^1.0.0" + checksum: 10/ca0fc7b24b916373e987b46e0c54db4aa824a80090a2fbff201679fd059240f4efabe415ffef9f5cfb99d85bf4241bdc3f212a9939724413203258a7dd73c24e + languageName: node + linkType: hard + +"should-type@npm:^1.3.0, should-type@npm:^1.4.0": + version: 1.4.0 + resolution: "should-type@npm:1.4.0" + checksum: 10/3e99a930fd43a47b0967fb5e8d0be31d9e2339c49267d3eabae014717012f4bd7cd942686fc49675114982240dcbfedba94ef49d0811b8f491c7cd74343bf97f + languageName: node + linkType: hard + +"should-util@npm:^1.0.0": + version: 1.0.1 + resolution: "should-util@npm:1.0.1" + checksum: 10/c3be15e0fdc851f8338676b3f8b590d330bbea94ec41c1343cc9983dea295915073f69a215795454b6adda6579ec8927c7c0ab178b83f9f11a0247ccdba53381 + languageName: node + linkType: hard + +"should@npm:^13.2.1": + version: 13.2.3 + resolution: "should@npm:13.2.3" + dependencies: + should-equal: "npm:^2.0.0" + should-format: "npm:^3.0.3" + should-type: "npm:^1.4.0" + should-type-adaptors: "npm:^1.0.1" + should-util: "npm:^1.0.0" + checksum: 10/4d3da94f11fee3db17be09673a73cd1939b0b75ebde102161eecef5559991deed691071ccab1d9289f4b69a45ef1a9d2362686a5f1ac530a43161d5832f6aa7d + languageName: node + linkType: hard + "side-channel-list@npm:^1.0.0": version: 1.0.1 resolution: "side-channel-list@npm:1.0.1" @@ -24125,7 +25318,7 @@ __metadata: languageName: node linkType: hard -"statuses@npm:~2.0.1, statuses@npm:~2.0.2": +"statuses@npm:^2.0.1, statuses@npm:~2.0.1, statuses@npm:~2.0.2": version: 2.0.2 resolution: "statuses@npm:2.0.2" checksum: 10/6927feb50c2a75b2a4caab2c565491f7a93ad3d8dbad7b1398d52359e9243a20e2ebe35e33726dee945125ef7a515e9097d8a1b910ba2bbd818265a2f6c39879 @@ -24154,6 +25347,13 @@ __metadata: languageName: node linkType: hard +"strict-event-emitter@npm:^0.5.1": + version: 0.5.1 + resolution: "strict-event-emitter@npm:0.5.1" + checksum: 10/25c84d88be85940d3547db665b871bfecea4ea0bedfeb22aae8db48126820cfb2b0bc2fba695392592a09b1aa36b686d6eede499e1ecd151593c03fe5a50d512 + languageName: node + linkType: hard + "string-length@npm:^4.0.1": version: 4.0.2 resolution: "string-length@npm:4.0.2" @@ -24387,6 +25587,29 @@ __metadata: languageName: node linkType: hard +"swagger2openapi@npm:^7.0.8": + version: 7.0.8 + resolution: "swagger2openapi@npm:7.0.8" + dependencies: + call-me-maybe: "npm:^1.0.1" + node-fetch: "npm:^2.6.1" + node-fetch-h2: "npm:^2.3.0" + node-readfiles: "npm:^0.2.0" + oas-kit-common: "npm:^1.0.8" + oas-resolver: "npm:^2.5.6" + oas-schema-walker: "npm:^1.1.5" + oas-validator: "npm:^5.0.8" + reftools: "npm:^1.1.9" + yaml: "npm:^1.10.0" + yargs: "npm:^17.0.1" + bin: + boast: boast.js + oas-validate: oas-validate.js + swagger2openapi: swagger2openapi.js + checksum: 10/f95fe71d306ff2b5763aaa488465c4f111810a6a19f233d3ed63495a544c040d544b914921d8362e31137290bb249585e07944bd91fbb1ecad2ad6e60e9c5a72 + languageName: node + linkType: hard + "symbol-tree@npm:^3.2.4": version: 3.2.4 resolution: "symbol-tree@npm:3.2.4" @@ -24564,6 +25787,16 @@ __metadata: languageName: node linkType: hard +"timers-ext@npm:^0.1.7": + version: 0.1.8 + resolution: "timers-ext@npm:0.1.8" + dependencies: + es5-ext: "npm:^0.10.64" + next-tick: "npm:^1.1.0" + checksum: 10/8abd168c57029e25d1fa4b7e101b053e261479e43ba4a32ead76e601e7037f74f850c311e22dc3dbb50dc211b34b092e0a349274d3997a493295e9ec725e6395 + languageName: node + linkType: hard + "tiny-invariant@npm:^1.0.2": version: 1.3.3 resolution: "tiny-invariant@npm:1.3.3" @@ -24578,6 +25811,13 @@ __metadata: languageName: node linkType: hard +"tinyexec@npm:^1.2.4": + version: 1.2.4 + resolution: "tinyexec@npm:1.2.4" + checksum: 10/f20b3e6f56f24c3ebe0129d0b6e657e561d225df2cf93c1a10362996232dd6ad4b8af8c9e81d258a64d09020e723772baf6fe0be26512dba7c61bb366d67b1f9 + languageName: node + linkType: hard + "tinyglobby@npm:^0.2.14, tinyglobby@npm:^0.2.15, tinyglobby@npm:^0.2.16, tinyglobby@npm:^0.2.17": version: 0.2.17 resolution: "tinyglobby@npm:0.2.17" @@ -24632,7 +25872,7 @@ __metadata: languageName: node linkType: hard -"tough-cookie@npm:^4.1.2": +"tough-cookie@npm:^4.1.2, tough-cookie@npm:^4.1.4": version: 4.1.4 resolution: "tough-cookie@npm:4.1.4" dependencies: @@ -24683,6 +25923,13 @@ __metadata: languageName: node linkType: hard +"ts-algebra@npm:^1.2.0": + version: 1.2.2 + resolution: "ts-algebra@npm:1.2.2" + checksum: 10/198f1d6fdfec0e8ffacf96d3db6464546afd147e80fac06158744188a64809524bc6d5eccfdbe3510e83e665d36d39fc7900940e5e258516a2c57a94b4963102 + languageName: node + linkType: hard + "ts-api-utils@npm:^2.4.0": version: 2.4.0 resolution: "ts-api-utils@npm:2.4.0" @@ -24756,7 +26003,7 @@ __metadata: languageName: node linkType: hard -"tslib@npm:^2.0.0, tslib@npm:^2.0.3, tslib@npm:^2.1.0, tslib@npm:^2.3.1, tslib@npm:^2.4.0, tslib@npm:^2.6.0, tslib@npm:^2.6.2, tslib@npm:^2.6.3, tslib@npm:^2.8.1": +"tslib@npm:^2.0.0, tslib@npm:^2.0.3, tslib@npm:^2.1.0, tslib@npm:^2.2.0, tslib@npm:^2.3.1, tslib@npm:^2.4.0, tslib@npm:^2.6.0, tslib@npm:^2.6.2, tslib@npm:^2.6.3, tslib@npm:^2.8.1": version: 2.8.1 resolution: "tslib@npm:2.8.1" checksum: 10/3e2e043d5c2316461cb54e5c7fe02c30ef6dccb3384717ca22ae5c6b5bc95232a6241df19c622d9c73b809bea33b187f6dbc73030963e29950c2141bc32a79f7 @@ -24841,7 +26088,7 @@ __metadata: languageName: node linkType: hard -"type-fest@npm:^4.0.0, type-fest@npm:^4.41.0": +"type-fest@npm:^4.0.0, type-fest@npm:^4.26.1, type-fest@npm:^4.41.0": version: 4.41.0 resolution: "type-fest@npm:4.41.0" checksum: 10/617ace794ac0893c2986912d28b3065ad1afb484cad59297835a0807dc63286c39e8675d65f7de08fafa339afcb8fe06a36e9a188b9857756ae1e92ee8bda212 @@ -24858,6 +26105,13 @@ __metadata: languageName: node linkType: hard +"type@npm:^2.7.2": + version: 2.7.3 + resolution: "type@npm:2.7.3" + checksum: 10/82e99e7795b3de3ecfe685680685e79a77aea515fad9f60b7c55fbf6d43a5c360b1e6e9443354ec8906b38cdf5325829c69f094cb7cd2a1238e85bef9026dc04 + languageName: node + linkType: hard + "typedarray-to-buffer@npm:^3.1.5": version: 3.1.5 resolution: "typedarray-to-buffer@npm:3.1.5" @@ -24914,6 +26168,16 @@ __metadata: languageName: node linkType: hard +"typescript@npm:5.9.3": + version: 5.9.3 + resolution: "typescript@npm:5.9.3" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10/c089d9d3da2729fd4ac517f9b0e0485914c4b3c26f80dc0cffcb5de1719a17951e92425d55db59515c1a7ddab65808466debb864d0d56dcf43f27007d0709594 + languageName: node + linkType: hard + "typescript@npm:~5.3.3": version: 5.3.3 resolution: "typescript@npm:5.3.3" @@ -24924,6 +26188,16 @@ __metadata: languageName: node linkType: hard +"typescript@patch:typescript@npm%3A5.9.3#optional!builtin": + version: 5.9.3 + resolution: "typescript@patch:typescript@npm%3A5.9.3#optional!builtin::version=5.9.3&hash=5786d5" + bin: + tsc: bin/tsc + tsserver: bin/tsserver + checksum: 10/696e1b017bc2635f4e0c94eb4435357701008e2f272f553d06e35b494b8ddc60aa221145e286c28ace0c89ee32827a28c2040e3a69bdc108b1a5dc8fb40b72e3 + languageName: node + linkType: hard + "typescript@patch:typescript@npm%3A~5.3.3#optional!builtin": version: 5.3.3 resolution: "typescript@patch:typescript@npm%3A5.3.3#optional!builtin::version=5.3.3&hash=e012d7" @@ -25332,6 +26606,46 @@ __metadata: languageName: node linkType: hard +"validate.io-array@npm:^1.0.3": + version: 1.0.6 + resolution: "validate.io-array@npm:1.0.6" + checksum: 10/54eca83ebc702e3e46499f9d9e77287a95ae25c4e727cd2fafee29c7333b3a36cca0c5d8f090b9406262786de80750fba85e7e7ef41e20bf8cc67d5570de449b + languageName: node + linkType: hard + +"validate.io-function@npm:^1.0.2": + version: 1.0.2 + resolution: "validate.io-function@npm:1.0.2" + checksum: 10/e4cce2479a20cb7c42e8630c777fb107059c27bc32925f769e3a73ca5fd62b4892d897b3c80227e14d5fcd1c5b7d05544e0579d63e59f14034c0052cda7f7c44 + languageName: node + linkType: hard + +"validate.io-integer-array@npm:^1.0.0": + version: 1.0.0 + resolution: "validate.io-integer-array@npm:1.0.0" + dependencies: + validate.io-array: "npm:^1.0.3" + validate.io-integer: "npm:^1.0.4" + checksum: 10/5f6d7fab8df7d2bf546a05e830201768464605539c75a2c2417b632b4411a00df84b462f81eac75e1be95303e7e0ac92f244c137424739f4e15cd21c2eb52c7f + languageName: node + linkType: hard + +"validate.io-integer@npm:^1.0.4": + version: 1.0.5 + resolution: "validate.io-integer@npm:1.0.5" + dependencies: + validate.io-number: "npm:^1.0.3" + checksum: 10/88b3f8bb5a5277a95305d64abbfc437079220ce4f57a148cc6113e7ccec03dd86b10a69d413982602aa90a62b8d516148a78716f550dcd3aff863ac1c2a7a5e6 + languageName: node + linkType: hard + +"validate.io-number@npm:^1.0.3": + version: 1.0.3 + resolution: "validate.io-number@npm:1.0.3" + checksum: 10/42418aeb6c969efa745475154fe576809b02eccd0961aad0421b090d6e7a12d23a3e28b0d5dddd2c6347c1a6bdccb82bba5048c716131cd20207244d50e07282 + languageName: node + linkType: hard + "value-equal@npm:^1.0.1": version: 1.0.1 resolution: "value-equal@npm:1.0.1" @@ -25841,6 +27155,17 @@ __metadata: languageName: node linkType: hard +"wrap-ansi@npm:^6.2.0": + version: 6.2.0 + resolution: "wrap-ansi@npm:6.2.0" + dependencies: + ansi-styles: "npm:^4.0.0" + string-width: "npm:^4.1.0" + strip-ansi: "npm:^6.0.0" + checksum: 10/0d64f2d438e0b555e693b95aee7b2689a12c3be5ac458192a1ce28f542a6e9e59ddfecc37520910c2c88eb1f82a5411260566dba5064e8f9895e76e169e76187 + languageName: node + linkType: hard + "wrap-ansi@npm:^8.0.1, wrap-ansi@npm:^8.1.0": version: 8.1.0 resolution: "wrap-ansi@npm:8.1.0" @@ -25943,7 +27268,7 @@ __metadata: languageName: node linkType: hard -"ws@npm:^7.3.1": +"ws@npm:^7, ws@npm:^7.3.1": version: 7.5.11 resolution: "ws@npm:7.5.11" peerDependencies: @@ -26056,6 +27381,20 @@ __metadata: languageName: node linkType: hard +"yaml-ast-parser@npm:0.0.43": + version: 0.0.43 + resolution: "yaml-ast-parser@npm:0.0.43" + checksum: 10/a54d00c8e0716a392c6e76eee965b3b4bba434494196490946e416fc47f20a1d89820461afacd9431edbb8209e28fce33bcff1fb42dd83f90e51fc31e80251c9 + languageName: node + linkType: hard + +"yaml@npm:^1.10.0": + version: 1.10.3 + resolution: "yaml@npm:1.10.3" + checksum: 10/e2ef2feb92c708138f016c69777a0f1e45f6d3c5e7cbcda30807a98a37eda2e008bd4fa57352b043c65245a4c799d0c99d1f9b3425de40e70929e26d2ea38215 + languageName: node + linkType: hard + "yaml@npm:^2.2.2, yaml@npm:^2.3.4, yaml@npm:^2.9.0": version: 2.9.0 resolution: "yaml@npm:2.9.0" @@ -26094,13 +27433,20 @@ __metadata: languageName: node linkType: hard -"yocto-queue@npm:^1.0.0": +"yocto-queue@npm:^1.0.0, yocto-queue@npm:^1.2.1": version: 1.2.2 resolution: "yocto-queue@npm:1.2.2" checksum: 10/92dd9880c324dbc94ff4b677b7d350ba8d835619062b7102f577add7a59ab4d87f40edc5a03d77d369dfa9d11175b1b2ec4a06a6f8a5d8ce5d1306713f66ee41 languageName: node linkType: hard +"yoctocolors-cjs@npm:^2.1.3": + version: 2.1.3 + resolution: "yoctocolors-cjs@npm:2.1.3" + checksum: 10/b2144b38807673a4254dae06fe1a212729550609e606289c305e45c585b36fab1dbba44fe6cde90db9b28be465ec63f4c2a50867aeec6672f6bc36b6c9a361a0 + languageName: node + linkType: hard + "zod@npm:^4.1.11": version: 4.4.3 resolution: "zod@npm:4.4.3" From 7e20ea1232556393b3684c292dea802c2abc1bdc Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 9 Jul 2026 12:19:07 +0000 Subject: [PATCH 2/5] fix(core-backend): lint compliance, msw/faker version pins, deterministic formatted codegen - Pin msw to ~2.10.5 (2.11+ depends on ESM-only rettime, breaking Jest CJS) and @faker-js/faker to ^9 (v10 is ESM-only) - Add HttpHandler annotations to generated MSW handlers (fixes TS2742 declaration emit) - Format generated output with oxfmt as part of yarn codegen - Register the core-backend build script variant in yarn constraints - Fix ESLint violations in the codegen plugins and tests Co-authored-by: Prithpal Sooriya --- .../generators/queryCoreGenerator.ts | 6 +- .../codegen/kubb-plugin-query-core/plugin.ts | 21 +- .../codegen/kubb-plugin-query-core/types.ts | 26 +- .../generators/superstructGenerator.ts | 12 +- .../codegen/kubb-plugin-superstruct/parser.ts | 57 +++- .../codegen/kubb-plugin-superstruct/plugin.ts | 265 +++++++++--------- .../codegen/kubb-plugin-superstruct/types.ts | 26 +- packages/core-backend/package.json | 6 +- .../src/api/prices/query-client.test.ts | 32 ++- .../src/api/prices/query-client.ts | 3 + .../mocks/createCoinGeckoSpotPrice.ts | 45 ++- .../mocks/createCoinGeckoSpotPrices.ts | 25 +- .../price-api/mocks/createExchangeRateInfo.ts | 32 ++- .../price-api/mocks/createExchangeRates.ts | 23 +- .../mocks/createGetV1ExchangeRates.ts | 49 ++-- .../mocks/createGetV1FiatExchangeRates.ts | 36 ++- .../mocks/createGetV1HistoricalPrices.ts | 68 +++-- .../mocks/createGetV1SpotPriceByCoinId.ts | 67 +++-- .../mocks/createGetV1SpotPricesByCoinIds.ts | 56 ++-- .../mocks/createGetV1SupportedNetworks.ts | 36 ++- .../price-api/mocks/createGetV2SpotPrices.ts | 67 +++-- .../mocks/createGetV2SupportedNetworks.ts | 36 ++- .../price-api/mocks/createGetV2TopTokens.ts | 69 +++-- .../mocks/createGetV3HistoricalPrices.ts | 73 +++-- .../price-api/mocks/createGetV3SpotPrices.ts | 55 ++-- .../price-api/mocks/createHistoricalPrices.ts | 30 +- .../price-api/mocks/createMarketData.ts | 41 ++- .../mocks/createMarketDataSpotPrices.ts | 25 +- .../price-api/mocks/createPricePoint.ts | 17 +- .../mocks/createSupportedNetworks.ts | 28 +- .../price-api/mocks/createTopToken.ts | 27 +- .../mocks/createV3HistoricalPrices.ts | 36 ++- .../price-api/mocks/createV3SpotPrice.ts | 26 +- .../price-api/mocks/createV3SpotPrices.ts | 21 +- .../price-api/mocks/createVsCurrency.ts | 78 +++++- .../src/generated/price-api/mocks/index.ts | 96 +++++-- .../msw/getV1ExchangeRatesHandler.ts | 60 ++-- .../msw/getV1FiatExchangeRatesHandler.ts | 60 ++-- .../msw/getV1HistoricalPricesHandler.ts | 60 ++-- .../msw/getV1SpotPriceByCoinIdHandler.ts | 60 ++-- .../msw/getV1SpotPricesByCoinIdsHandler.ts | 62 ++-- .../msw/getV1SupportedNetworksHandler.ts | 60 ++-- .../price-api/msw/getV2SpotPricesHandler.ts | 60 ++-- .../msw/getV2SupportedNetworksHandler.ts | 60 ++-- .../price-api/msw/getV2TopTokensHandler.ts | 60 ++-- .../msw/getV3HistoricalPricesHandler.ts | 60 ++-- .../price-api/msw/getV3SpotPricesHandler.ts | 60 ++-- .../src/generated/price-api/msw/handlers.ts | 45 +-- .../src/generated/price-api/msw/index.ts | 57 +++- .../price-api/queries/getV1ExchangeRates.ts | 43 ++- .../queries/getV1FiatExchangeRates.ts | 31 +- .../queries/getV1HistoricalPrices.ts | 51 +++- .../queries/getV1SpotPriceByCoinId.ts | 51 +++- .../queries/getV1SpotPricesByCoinIds.ts | 43 ++- .../queries/getV1SupportedNetworks.ts | 31 +- .../price-api/queries/getV2SpotPrices.ts | 45 ++- .../queries/getV2SupportedNetworks.ts | 31 +- .../price-api/queries/getV2TopTokens.ts | 51 +++- .../queries/getV3HistoricalPrices.ts | 51 +++- .../price-api/queries/getV3SpotPrices.ts | 40 ++- .../src/generated/price-api/queries/index.ts | 66 ++++- .../schemas/coinGeckoSpotPriceStruct.ts | 48 ++-- .../schemas/coinGeckoSpotPricesStruct.ts | 16 +- .../schemas/exchangeRateInfoStruct.ts | 18 +- .../price-api/schemas/exchangeRatesStruct.ts | 13 +- .../schemas/getV1ExchangeRatesStruct.ts | 16 +- .../schemas/getV1FiatExchangeRatesStruct.ts | 11 +- .../schemas/getV1HistoricalPricesStruct.ts | 30 +- .../schemas/getV1SpotPriceByCoinIdStruct.ts | 20 +- .../schemas/getV1SpotPricesByCoinIdsStruct.ts | 20 +- .../schemas/getV1SupportedNetworksStruct.ts | 11 +- .../schemas/getV2SpotPricesStruct.ts | 30 +- .../schemas/getV2SupportedNetworksStruct.ts | 11 +- .../price-api/schemas/getV2TopTokensStruct.ts | 29 +- .../schemas/getV3HistoricalPricesStruct.ts | 37 ++- .../schemas/getV3SpotPricesStruct.ts | 29 +- .../schemas/historicalPricesStruct.ts | 15 +- .../src/generated/price-api/schemas/index.ts | 96 +++++-- .../schemas/marketDataSpotPricesStruct.ts | 13 +- .../price-api/schemas/marketDataStruct.ts | 48 ++-- .../price-api/schemas/pricePointStruct.ts | 10 +- .../schemas/supportedNetworksStruct.ts | 14 +- .../price-api/schemas/topTokenStruct.ts | 20 +- .../schemas/v3HistoricalPricesStruct.ts | 19 +- .../price-api/schemas/v3SpotPriceStruct.ts | 18 +- .../price-api/schemas/v3SpotPricesStruct.ts | 16 +- .../price-api/schemas/vsCurrencyStruct.ts | 71 ++++- .../price-api/types/CoinGeckoSpotPrice.ts | 201 +++++++------ .../price-api/types/CoinGeckoSpotPrices.ts | 14 +- .../price-api/types/ExchangeRateInfo.ts | 58 ++-- .../price-api/types/ExchangeRates.ts | 14 +- .../price-api/types/GetV1ExchangeRates.ts | 28 +- .../price-api/types/GetV1FiatExchangeRates.ts | 16 +- .../price-api/types/GetV1HistoricalPrices.ts | 64 ++--- .../price-api/types/GetV1SpotPriceByCoinId.ts | 44 +-- .../types/GetV1SpotPricesByCoinIds.ts | 42 +-- .../price-api/types/GetV1SupportedNetworks.ts | 16 +- .../price-api/types/GetV2SpotPrices.ts | 66 ++--- .../price-api/types/GetV2SupportedNetworks.ts | 16 +- .../price-api/types/GetV2TopTokens.ts | 60 ++-- .../price-api/types/GetV3HistoricalPrices.ts | 103 +++---- .../price-api/types/GetV3SpotPrices.ts | 66 ++--- .../price-api/types/HistoricalPrices.ts | 22 +- .../generated/price-api/types/MarketData.ts | 201 +++++++------ .../price-api/types/MarketDataSpotPrices.ts | 14 +- .../generated/price-api/types/PricePoint.ts | 14 +- .../price-api/types/SupportedNetworks.ts | 31 +- .../src/generated/price-api/types/TopToken.ts | 61 ++-- .../price-api/types/V3HistoricalPrices.ts | 42 +-- .../generated/price-api/types/V3SpotPrice.ts | 51 ++-- .../generated/price-api/types/V3SpotPrices.ts | 14 +- .../generated/price-api/types/VsCurrency.ts | 128 ++++----- .../src/generated/price-api/types/index.ts | 117 ++++++-- yarn.config.cjs | 15 + yarn.lock | 43 +-- 115 files changed, 3130 insertions(+), 2024 deletions(-) diff --git a/packages/core-backend/codegen/kubb-plugin-query-core/generators/queryCoreGenerator.ts b/packages/core-backend/codegen/kubb-plugin-query-core/generators/queryCoreGenerator.ts index 706e5578de..36007a3e61 100644 --- a/packages/core-backend/codegen/kubb-plugin-query-core/generators/queryCoreGenerator.ts +++ b/packages/core-backend/codegen/kubb-plugin-query-core/generators/queryCoreGenerator.ts @@ -119,7 +119,7 @@ export const queryCoreGenerator = createGenerator({ })}.ts`, pluginKey: [pluginTsName], options: { type: 'file' }, - }) as KubbFile.Path, + }), }); /** @@ -143,7 +143,7 @@ export const queryCoreGenerator = createGenerator({ })}.ts`, pluginKey: [pluginSuperstructName], options: { type: 'file' }, - }) as KubbFile.Path, + }), }); const response = resolveType(operationSchemas.response.name); @@ -172,7 +172,7 @@ export const queryCoreGenerator = createGenerator({ // Parameters shared by all three generated functions (minus `client`, // which the query key factory does not need). - const parameterEntries: Array<{ signature: string; forward: string }> = []; + const parameterEntries: { signature: string; forward: string }[] = []; if (pathParams) { parameterEntries.push({ signature: `pathParams: ${pathParams.name}`, diff --git a/packages/core-backend/codegen/kubb-plugin-query-core/plugin.ts b/packages/core-backend/codegen/kubb-plugin-query-core/plugin.ts index 0ccf8a03c0..5e55a2dda8 100644 --- a/packages/core-backend/codegen/kubb-plugin-query-core/plugin.ts +++ b/packages/core-backend/codegen/kubb-plugin-query-core/plugin.ts @@ -1,15 +1,15 @@ -import path from 'node:path'; - import { definePlugin, getBarrelFiles, getMode } from '@kubb/core'; import { OperationGenerator, pluginOasName } from '@kubb/plugin-oas'; import { pluginTsName } from '@kubb/plugin-ts'; +import path from 'node:path'; -import { queryCoreGenerator } from './generators/queryCoreGenerator'; -import type { PluginQueryCore } from './types'; import { pluginSuperstructName } from '../kubb-plugin-superstruct'; import { camelCase, pascalCase } from '../utils/casing'; +import { queryCoreGenerator } from './generators/queryCoreGenerator'; +import type { PluginQueryCore } from './types'; -export const pluginQueryCoreName = 'plugin-query-core' satisfies PluginQueryCore['name']; +export const pluginQueryCoreName = + 'plugin-query-core' satisfies PluginQueryCore['name']; /** * Kubb plugin that generates framework-agnostic TanStack `query-core` @@ -53,7 +53,7 @@ export const pluginQueryCore = definePlugin((options = {}) => { transformers, }, pre: [pluginOasName, pluginTsName, pluginSuperstructName], - resolvePath(baseName, pathMode) { + resolvePath(baseName, pathMode): string { const root = path.resolve(this.config.root, this.config.output.path); const mode = pathMode ?? getMode(path.resolve(root, output.path)); @@ -63,17 +63,16 @@ export const pluginQueryCore = definePlugin((options = {}) => { return path.resolve(root, output.path, baseName); }, - resolveName(name, type) { - const resolvedName = - type === 'type' ? pascalCase(name) : camelCase(name); + resolveName(name, type): string { + const resolvedName = type === 'type' ? pascalCase(name) : camelCase(name); if (type) { - return transformers?.name?.(resolvedName, type) || resolvedName; + return transformers?.name?.(resolvedName, type) ?? resolvedName; } return resolvedName; }, - async install() { + async install(): Promise { const root = path.resolve(this.config.root, this.config.output.path); const mode = getMode(path.resolve(root, output.path)); const oas = await this.getOas(); diff --git a/packages/core-backend/codegen/kubb-plugin-query-core/types.ts b/packages/core-backend/codegen/kubb-plugin-query-core/types.ts index a0f565348e..c227c5aaaf 100644 --- a/packages/core-backend/codegen/kubb-plugin-query-core/types.ts +++ b/packages/core-backend/codegen/kubb-plugin-query-core/types.ts @@ -1,7 +1,16 @@ -import type { Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'; +import type { + Output, + PluginFactoryOptions, + ResolveNameParams, +} from '@kubb/core'; import type { Oas, contentType } from '@kubb/oas'; -import type { Exclude, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas'; -import type { Generator } from '@kubb/plugin-oas/generators'; +import type { + Exclude as OasExclude, + Include as OasInclude, + Override, + ResolvePathOptions, +} from '@kubb/plugin-oas'; +import type { Generator as OasGenerator } from '@kubb/plugin-oas/generators'; /** * User-facing options for the TanStack `query-core` Kubb plugin. @@ -10,6 +19,7 @@ export type Options = { /** * Specify the export location for the files and define the behavior of the * output. + * * @default { path: 'queries', barrelType: 'named' } */ output?: Output; @@ -22,19 +32,20 @@ export type Options = { * Array containing exclude parameters to exclude/skip * tags/operations/methods/paths. */ - exclude?: Array; + exclude?: OasExclude[]; /** * Array containing include parameters to include tags/operations/methods/paths. */ - include?: Array; + include?: OasInclude[]; /** * Array containing override parameters to override `options` based on * tags/operations/methods/paths. */ - override?: Array>; + override?: Override[]; /** * The first element of every generated query key, scoping the generated * queries in the QueryClient cache (e.g. `'prices'`). + * * @default 'api' */ queryKeyPrefix?: string; @@ -43,6 +54,7 @@ export type Options = { * runtime from (`ApiRequestClient`, `FetchOptions` and * `getQueryOptionsOverrides`). Relative specifiers are resolved from the * generated query files. + * * @default '../../../api/query-runtime' */ runtimeImportPath?: string; @@ -58,7 +70,7 @@ export type Options = { /** * Define some generators next to the query-core generators. */ - generators?: Array>; + generators?: OasGenerator[]; }; /** diff --git a/packages/core-backend/codegen/kubb-plugin-superstruct/generators/superstructGenerator.ts b/packages/core-backend/codegen/kubb-plugin-superstruct/generators/superstructGenerator.ts index 9eecb879e8..6f0c44fc2f 100644 --- a/packages/core-backend/codegen/kubb-plugin-superstruct/generators/superstructGenerator.ts +++ b/packages/core-backend/codegen/kubb-plugin-superstruct/generators/superstructGenerator.ts @@ -1,4 +1,4 @@ -import type { Plugin, PluginManager } from '@kubb/core'; +import type { Plugin as KubbPlugin, PluginManager } from '@kubb/core'; import type { KubbFile } from '@kubb/fabric-core/types'; import type { OperationSchema, Schema } from '@kubb/plugin-oas'; import { SchemaGenerator } from '@kubb/plugin-oas'; @@ -14,7 +14,7 @@ import type { PluginSuperstruct } from '../types'; */ type NamedSchemaTree = { name: string; - tree: Array; + tree: Schema[]; description?: string; }; @@ -29,10 +29,10 @@ type NamedSchemaTree = { * @returns The rendered sources and the helpers that must be imported. */ function renderStructs( - trees: Array, + trees: NamedSchemaTree[], pluginManager: PluginManager, - plugin: Plugin, -): { sources: Array; usedHelpers: Set } { + plugin: KubbPlugin, +): { sources: KubbFile.Source[]; usedHelpers: Set } { const usedHelpers = new Set(); const sources = trees.map(({ name, tree, description }): KubbFile.Source => { @@ -146,7 +146,7 @@ export const superstructGenerator = createGenerator({ operationSchemas.response, ].filter( (operationSchema): operationSchema is OperationSchema => - operationSchema !== undefined && operationSchema.schema !== undefined, + operationSchema?.schema !== undefined, ); const trees = namedSchemas.map( diff --git a/packages/core-backend/codegen/kubb-plugin-superstruct/parser.ts b/packages/core-backend/codegen/kubb-plugin-superstruct/parser.ts index b1a351a873..222fc04f11 100644 --- a/packages/core-backend/codegen/kubb-plugin-superstruct/parser.ts +++ b/packages/core-backend/codegen/kubb-plugin-superstruct/parser.ts @@ -94,7 +94,11 @@ function formatLiteral( * @param args - The source code of the arguments. * @returns The call expression, e.g. `string()`. */ -function call(options: ParserOptions, helper: string, ...args: string[]): string { +function call( + options: ParserOptions, + helper: string, + ...args: string[] +): string { options.usedHelpers.add(helper); return `${helper}(${args.join(', ')})`; } @@ -120,7 +124,11 @@ function parseBase( if (isKeyword(current, schemaKeywords.array)) { // Kubb represents the array item type as a list of sibling keywords. const item = parse(current.args.items, options); - return call(options, 'array', item === '' ? call(options, 'unknown') : item); + return call( + options, + 'array', + item === '' ? call(options, 'unknown') : item, + ); } if (isKeyword(current, schemaKeywords.tuple)) { @@ -147,7 +155,7 @@ function parseBase( .map((member) => parse([member], options)) .filter(Boolean); if (members.length === 1) { - return members[0] as string; + return members[0]; } return call(options, 'union', `[${members.join(', ')}]`); } @@ -158,7 +166,7 @@ function parseBase( .map((member) => parse([member], options)) .filter(Boolean); if (members.length === 1) { - return members[0] as string; + return members[0]; } return call(options, 'intersection', `[${members.join(', ')}]`); } @@ -189,27 +197,48 @@ function parseBase( return call(options, 'string'); } - if (isKeyword(current, schemaKeywords.number) || isKeyword(current, schemaKeywords.integer)) { + if ( + isKeyword(current, schemaKeywords.number) || + isKeyword(current, schemaKeywords.integer) + ) { let output = isKeyword(current, schemaKeywords.integer) ? call(options, 'integer') : call(options, 'number'); const minimum = findKeyword(siblings, schemaKeywords.min)?.args; const maximum = findKeyword(siblings, schemaKeywords.max)?.args; - const exclusiveMinimum = findKeyword(siblings, schemaKeywords.exclusiveMinimum)?.args; - const exclusiveMaximum = findKeyword(siblings, schemaKeywords.exclusiveMaximum)?.args; + const exclusiveMinimum = findKeyword( + siblings, + schemaKeywords.exclusiveMinimum, + )?.args; + const exclusiveMaximum = findKeyword( + siblings, + schemaKeywords.exclusiveMaximum, + )?.args; if (minimum !== undefined) { output = call(options, 'min', output, String(minimum)); } if (exclusiveMinimum !== undefined) { - output = call(options, 'min', output, String(exclusiveMinimum), '{ exclusive: true }'); + output = call( + options, + 'min', + output, + String(exclusiveMinimum), + '{ exclusive: true }', + ); } if (maximum !== undefined) { output = call(options, 'max', output, String(maximum)); } if (exclusiveMaximum !== undefined) { - output = call(options, 'max', output, String(exclusiveMaximum), '{ exclusive: true }'); + output = call( + options, + 'max', + output, + String(exclusiveMaximum), + '{ exclusive: true }', + ); } return output; } @@ -329,11 +358,15 @@ export function parse(schemas: Schema[], options: ParserOptions): string { output = call(options, 'defaulted', output, String(defaultSchema.args)); } - const isNullish = schemas.some((schema) => isKeyword(schema, schemaKeywords.nullish)); + const isNullish = schemas.some((schema) => + isKeyword(schema, schemaKeywords.nullish), + ); const isNullable = - isNullish || schemas.some((schema) => isKeyword(schema, schemaKeywords.nullable)); + isNullish || + schemas.some((schema) => isKeyword(schema, schemaKeywords.nullable)); const isOptional = - isNullish || schemas.some((schema) => isKeyword(schema, schemaKeywords.optional)); + isNullish || + schemas.some((schema) => isKeyword(schema, schemaKeywords.optional)); if (isNullable) { output = call(options, 'nullable', output); diff --git a/packages/core-backend/codegen/kubb-plugin-superstruct/plugin.ts b/packages/core-backend/codegen/kubb-plugin-superstruct/plugin.ts index 5a2c2f59cc..cc4aa5c9b8 100644 --- a/packages/core-backend/codegen/kubb-plugin-superstruct/plugin.ts +++ b/packages/core-backend/codegen/kubb-plugin-superstruct/plugin.ts @@ -1,14 +1,18 @@ -import path from 'node:path'; - import { definePlugin, getBarrelFiles, getMode } from '@kubb/core'; import type { Group } from '@kubb/core'; -import { OperationGenerator, SchemaGenerator, pluginOasName } from '@kubb/plugin-oas'; +import { + OperationGenerator, + SchemaGenerator, + pluginOasName, +} from '@kubb/plugin-oas'; +import path from 'node:path'; +import { camelCase, pascalCase } from '../utils/casing'; import { superstructGenerator } from './generators/superstructGenerator'; import type { PluginSuperstruct } from './types'; -import { camelCase, pascalCase } from '../utils/casing'; -export const pluginSuperstructName = 'plugin-superstruct' satisfies PluginSuperstruct['name']; +export const pluginSuperstructName = + 'plugin-superstruct' satisfies PluginSuperstruct['name']; /** * Kubb plugin that generates `@metamask/superstruct` structs from an OpenAPI @@ -18,133 +22,138 @@ export const pluginSuperstructName = 'plugin-superstruct' satisfies PluginSupers * request body and response) a `Struct` is generated, following the * naming convention used across MetaMask packages. */ -export const pluginSuperstruct = definePlugin((options = {}) => { - const { - output = { path: 'schemas', barrelType: 'named' }, - group, - exclude = [], - include, - override = [], - transformers = {}, - importPath = '@metamask/superstruct', - contentType, - generators = [superstructGenerator], - } = options; - - return { - name: pluginSuperstructName, - options: { - output, +export const pluginSuperstruct = definePlugin( + (options = {}) => { + const { + output = { path: 'schemas', barrelType: 'named' }, group, - contentType, + exclude = [], include, - exclude, - override, - importPath, - transformers, - // Options consumed by Kubb's SchemaGenerator. Dates, times and other - // string formats are all treated as strings on the wire. - dateType: 'string', - unknownType: 'unknown', - emptySchemaType: 'unknown', - usedEnumNames: {}, - }, - pre: [pluginOasName], - resolvePath(baseName, pathMode, resolvePathOptions) { - const root = path.resolve(this.config.root, this.config.output.path); - const mode = pathMode ?? getMode(path.resolve(root, output.path)); - - if (mode === 'single') { - return path.resolve(root, output.path); - } - - if (group && (resolvePathOptions?.group?.path || resolvePathOptions?.group?.tag)) { - const groupName: Group['name'] = group.name - ? group.name - : (context) => { + override = [], + transformers = {}, + importPath = '@metamask/superstruct', + contentType, + generators = [superstructGenerator], + } = options; + + return { + name: pluginSuperstructName, + options: { + output, + group, + contentType, + include, + exclude, + override, + importPath, + transformers, + // Options consumed by Kubb's SchemaGenerator. Dates, times and other + // string formats are all treated as strings on the wire. + dateType: 'string', + unknownType: 'unknown', + emptySchemaType: 'unknown', + usedEnumNames: {}, + }, + pre: [pluginOasName], + resolvePath(baseName, pathMode, resolvePathOptions): string { + const root = path.resolve(this.config.root, this.config.output.path); + const mode = pathMode ?? getMode(path.resolve(root, output.path)); + + if (mode === 'single') { + return path.resolve(root, output.path); + } + + if ( + group && + (resolvePathOptions?.group?.path || resolvePathOptions?.group?.tag) + ) { + const groupName: Group['name'] = + group.name ?? + ((context): string => { if (group.type === 'path') { return `${context.group.split('/')[1]}`; } return `${camelCase(context.group)}Controller`; - }; - - return path.resolve( + }); + + return path.resolve( + root, + output.path, + groupName({ + group: + group.type === 'path' + ? (resolvePathOptions.group.path as string) + : (resolvePathOptions.group.tag as string), + }), + baseName, + ); + } + + return path.resolve(root, output.path, baseName); + }, + resolveName(name, type): string { + // Structs follow the `Struct` convention used across + // MetaMask packages; files use the camelCase variant. References + // between structs are resolved with `type: 'function'`, so those must + // match the exported (PascalCase) names. + const resolvedName = + type === 'file' + ? camelCase(`${name}Struct`) + : pascalCase(`${name}Struct`); + + if (type) { + return transformers?.name?.(resolvedName, type) ?? resolvedName; + } + + return resolvedName; + }, + async install(): Promise { + const root = path.resolve(this.config.root, this.config.output.path); + const mode = getMode(path.resolve(root, output.path)); + const oas = await this.getOas(); + + const schemaGenerator = new SchemaGenerator(this.plugin.options, { + fabric: this.fabric, + oas, + pluginManager: this.pluginManager, + events: this.events, + plugin: this.plugin, + contentType, + include: undefined, + override, + mode, + output: output.path, + }); + + const schemaFiles = await schemaGenerator.build(...generators); + await this.upsertFile(...schemaFiles); + + const operationGenerator = new OperationGenerator(this.plugin.options, { + fabric: this.fabric, + oas, + pluginManager: this.pluginManager, + events: this.events, + plugin: this.plugin, + contentType, + exclude, + include, + override, + mode, + }); + + const operationFiles = await operationGenerator.build(...generators); + await this.upsertFile(...operationFiles); + + const barrelFiles = await getBarrelFiles(this.fabric.files, { root, - output.path, - groupName({ - group: - group.type === 'path' - ? (resolvePathOptions.group.path as string) - : (resolvePathOptions.group.tag as string), - }), - baseName, - ); - } - - return path.resolve(root, output.path, baseName); - }, - resolveName(name, type) { - // Structs follow the `Struct` convention used across - // MetaMask packages; files use the camelCase variant. References - // between structs are resolved with `type: 'function'`, so those must - // match the exported (PascalCase) names. - const resolvedName = - type === 'file' - ? camelCase(`${name}Struct`) - : pascalCase(`${name}Struct`); - - if (type) { - return transformers?.name?.(resolvedName, type) || resolvedName; - } - - return resolvedName; - }, - async install() { - const root = path.resolve(this.config.root, this.config.output.path); - const mode = getMode(path.resolve(root, output.path)); - const oas = await this.getOas(); - - const schemaGenerator = new SchemaGenerator(this.plugin.options, { - fabric: this.fabric, - oas, - pluginManager: this.pluginManager, - events: this.events, - plugin: this.plugin, - contentType, - include: undefined, - override, - mode, - output: output.path, - }); - - const schemaFiles = await schemaGenerator.build(...generators); - await this.upsertFile(...schemaFiles); - - const operationGenerator = new OperationGenerator(this.plugin.options, { - fabric: this.fabric, - oas, - pluginManager: this.pluginManager, - events: this.events, - plugin: this.plugin, - contentType, - exclude, - include, - override, - mode, - }); - - const operationFiles = await operationGenerator.build(...generators); - await this.upsertFile(...operationFiles); - - const barrelFiles = await getBarrelFiles(this.fabric.files, { - root, - output, - meta: { - pluginKey: this.plugin.key, - }, - }); - - await this.upsertFile(...barrelFiles); - }, - }; -}); + output, + meta: { + pluginKey: this.plugin.key, + }, + }); + + await this.upsertFile(...barrelFiles); + }, + }; + }, +); diff --git a/packages/core-backend/codegen/kubb-plugin-superstruct/types.ts b/packages/core-backend/codegen/kubb-plugin-superstruct/types.ts index 0dde4a348f..fed0623395 100644 --- a/packages/core-backend/codegen/kubb-plugin-superstruct/types.ts +++ b/packages/core-backend/codegen/kubb-plugin-superstruct/types.ts @@ -1,7 +1,17 @@ -import type { Group, Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core'; +import type { + Group, + Output, + PluginFactoryOptions, + ResolveNameParams, +} from '@kubb/core'; import type { Oas, contentType } from '@kubb/oas'; -import type { Exclude, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas'; -import type { Generator } from '@kubb/plugin-oas/generators'; +import type { + Exclude as OasExclude, + Include as OasInclude, + Override, + ResolvePathOptions, +} from '@kubb/plugin-oas'; +import type { Generator as OasGenerator } from '@kubb/plugin-oas/generators'; /** * User-facing options for the `@metamask/superstruct` Kubb plugin. @@ -10,6 +20,7 @@ export type Options = { /** * Specify the export location for the files and define the behavior of the * output. + * * @default { path: 'schemas', barrelType: 'named' } */ output?: Output; @@ -26,18 +37,19 @@ export type Options = { * Array containing exclude parameters to exclude/skip * tags/operations/methods/paths. */ - exclude?: Array; + exclude?: OasExclude[]; /** * Array containing include parameters to include tags/operations/methods/paths. */ - include?: Array; + include?: OasInclude[]; /** * Array containing override parameters to override `options` based on * tags/operations/methods/paths. */ - override?: Array>; + override?: Override[]; /** * The module that structs are imported from. + * * @default '@metamask/superstruct' */ importPath?: string; @@ -53,7 +65,7 @@ export type Options = { /** * Define some generators next to the superstruct generators. */ - generators?: Array>; + generators?: OasGenerator[]; }; /** diff --git a/packages/core-backend/package.json b/packages/core-backend/package.json index 2561b27756..7df563a6cf 100644 --- a/packages/core-backend/package.json +++ b/packages/core-backend/package.json @@ -64,7 +64,7 @@ "build:docs": "typedoc", "changelog:update": "../../scripts/update-changelog.sh @metamask/core-backend", "changelog:validate": "../../scripts/validate-changelog.sh @metamask/core-backend", - "codegen": "kubb generate --config codegen/kubb.config.ts && node codegen/annotate-msw-handlers.mjs", + "codegen": "kubb generate --config codegen/kubb.config.ts && node codegen/annotate-msw-handlers.mjs && yarn run -T oxfmt src/generated", "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --check", "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --generate", "since-latest-release": "../../scripts/since-latest-release.sh", @@ -79,7 +79,7 @@ "@metamask/keyring-controller": "^27.1.0", "@metamask/messenger": "^2.0.0", "@metamask/profile-sync-controller": "^28.2.0", - "@metamask/superstruct": "^3.3.0", + "@metamask/superstruct": "^3.1.0", "@metamask/utils": "^11.11.0", "@tanstack/query-core": "^5.62.16", "async-mutex": "^0.5.0", @@ -89,6 +89,8 @@ "@faker-js/faker": "^9.9.0", "@kubb/cli": "^4.39.2", "@kubb/core": "^4.39.2", + "@kubb/fabric-core": "^0.14.0", + "@kubb/oas": "^4.39.2", "@kubb/plugin-faker": "^4.39.2", "@kubb/plugin-msw": "^4.39.2", "@kubb/plugin-oas": "^4.39.2", diff --git a/packages/core-backend/src/api/prices/query-client.test.ts b/packages/core-backend/src/api/prices/query-client.test.ts index 67f33692a7..8e4ced0a6a 100644 --- a/packages/core-backend/src/api/prices/query-client.test.ts +++ b/packages/core-backend/src/api/prices/query-client.test.ts @@ -10,7 +10,6 @@ import { assert, is } from '@metamask/superstruct'; import { QueryClient } from '@tanstack/query-core'; import { getResponse } from 'msw'; -import { PricesApiRequestClient } from './query-client'; import { createCoinGeckoSpotPrice, createExchangeRateInfo, @@ -41,6 +40,7 @@ import { TopTokenStruct, V3SpotPriceStruct, } from '../../generated/price-api/schemas'; +import { PricesApiRequestClient } from './query-client'; /** * Routes all `fetch` calls through the generated MSW handlers, so requests @@ -52,18 +52,25 @@ import { function serveMswHandlers( requestHandlers: Parameters[0], ): void { - (globalThis as { fetch: unknown }).fetch = jest.fn( - async (input: string | URL): Promise => { - const response = await getResponse( - requestHandlers, - new Request(String(input)), - ); + jest + .spyOn(globalThis, 'fetch') + .mockImplementation(async (input): Promise => { + let url: string; + if (typeof input === 'string') { + url = input; + } else if (input instanceof URL) { + url = input.href; + } else { + url = input.url; + } + // eslint-disable-next-line no-restricted-globals + const request = new Request(url); + const response = await getResponse(requestHandlers, request); if (!response) { - throw new Error(`No MSW handler matched: ${String(input)}`); + throw new Error(`No MSW handler matched: ${url}`); } return response; - }, - ); + }); } /** @@ -182,7 +189,10 @@ describe('generated Price API bindings', () => { const prices = await fetchV1HistoricalPrices( client, - { chainId: 1, tokenAddress: '0x6b175474e89094c44da98b954eedeac495271d0f' }, + { + chainId: 1, + tokenAddress: '0x6b175474e89094c44da98b954eedeac495271d0f', + }, { vsCurrency: 'eur', timePeriod: '7d' }, ); diff --git a/packages/core-backend/src/api/prices/query-client.ts b/packages/core-backend/src/api/prices/query-client.ts index 361252bb1b..bc87a319b4 100644 --- a/packages/core-backend/src/api/prices/query-client.ts +++ b/packages/core-backend/src/api/prices/query-client.ts @@ -34,6 +34,9 @@ export class PricesApiRequestClient * operations are GETs. * * @param args - The request to perform. + * @param args.url - Path of the endpoint, relative to the API base URL. + * @param args.params - Query parameters to append to the URL. + * @param args.signal - Abort signal forwarded from TanStack Query. * @returns The parsed JSON response. */ async request({ diff --git a/packages/core-backend/src/generated/price-api/mocks/createCoinGeckoSpotPrice.ts b/packages/core-backend/src/generated/price-api/mocks/createCoinGeckoSpotPrice.ts index 1d496d1c55..fc5c619fe2 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createCoinGeckoSpotPrice.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createCoinGeckoSpotPrice.ts @@ -1,18 +1,41 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { CoinGeckoSpotPrice } from "../types/CoinGeckoSpotPrice"; -import { faker } from "@faker-js/faker"; +import type { CoinGeckoSpotPrice } from '../types/CoinGeckoSpotPrice'; /** * @description Spot price and market data for a CoinGecko-listed coin. */ -export function createCoinGeckoSpotPrice(data?: Partial): CoinGeckoSpotPrice { - faker.seed([220]) +export function createCoinGeckoSpotPrice( + data?: Partial, +): CoinGeckoSpotPrice { + faker.seed([220]); return { - ...{"id": faker.string.alpha(),"price": faker.number.float(),"marketCap": faker.number.float(),"allTimeHigh": faker.number.float(),"allTimeLow": faker.number.float(),"totalVolume": faker.number.float(),"high1d": faker.number.float(),"low1d": faker.number.float(),"circulatingSupply": faker.number.float(),"dilutedMarketCap": faker.number.float(),"marketCapPercentChange1d": faker.number.float(),"priceChange1d": faker.number.float(),"pricePercentChange1h": faker.number.float(),"pricePercentChange1d": faker.number.float(),"pricePercentChange7d": faker.number.float(),"pricePercentChange14d": faker.number.float(),"pricePercentChange30d": faker.number.float(),"pricePercentChange200d": faker.number.float(),"pricePercentChange1y": faker.number.float()}, - ...data || {} - } -} \ No newline at end of file + ...{ + id: faker.string.alpha(), + price: faker.number.float(), + marketCap: faker.number.float(), + allTimeHigh: faker.number.float(), + allTimeLow: faker.number.float(), + totalVolume: faker.number.float(), + high1d: faker.number.float(), + low1d: faker.number.float(), + circulatingSupply: faker.number.float(), + dilutedMarketCap: faker.number.float(), + marketCapPercentChange1d: faker.number.float(), + priceChange1d: faker.number.float(), + pricePercentChange1h: faker.number.float(), + pricePercentChange1d: faker.number.float(), + pricePercentChange7d: faker.number.float(), + pricePercentChange14d: faker.number.float(), + pricePercentChange30d: faker.number.float(), + pricePercentChange200d: faker.number.float(), + pricePercentChange1y: faker.number.float(), + }, + ...(data || {}), + }; +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createCoinGeckoSpotPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createCoinGeckoSpotPrices.ts index 7349e73929..2de88d825b 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createCoinGeckoSpotPrices.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createCoinGeckoSpotPrices.ts @@ -1,19 +1,22 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { CoinGeckoSpotPrices } from "../types/CoinGeckoSpotPrices"; -import { createCoinGeckoSpotPrice } from "./createCoinGeckoSpotPrice"; -import { faker } from "@faker-js/faker"; +import type { CoinGeckoSpotPrices } from '../types/CoinGeckoSpotPrices'; +import { createCoinGeckoSpotPrice } from './createCoinGeckoSpotPrice'; /** * @description Spot prices keyed by CoinGecko coin ID. */ -export function createCoinGeckoSpotPrices(data?: Partial): CoinGeckoSpotPrices { - faker.seed([220]) +export function createCoinGeckoSpotPrices( + data?: Partial, +): CoinGeckoSpotPrices { + faker.seed([220]); return { ...{}, - ...data || {} - } -} \ No newline at end of file + ...(data || {}), + }; +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createExchangeRateInfo.ts b/packages/core-backend/src/generated/price-api/mocks/createExchangeRateInfo.ts index 221c3ac705..61e7b3f8da 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createExchangeRateInfo.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createExchangeRateInfo.ts @@ -1,18 +1,28 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { ExchangeRateInfo } from "../types/ExchangeRateInfo"; -import { faker } from "@faker-js/faker"; +import type { ExchangeRateInfo } from '../types/ExchangeRateInfo'; /** * @description Exchange rate details for a single currency. */ -export function createExchangeRateInfo(data?: Partial): ExchangeRateInfo { - faker.seed([220]) +export function createExchangeRateInfo( + data?: Partial, +): ExchangeRateInfo { + faker.seed([220]); return { - ...{"name": faker.string.alpha(),"ticker": faker.string.alpha(),"value": faker.number.float(),"currencyType": faker.helpers.arrayElement["currencyType"]>(["crypto", "fiat"])}, - ...data || {} - } -} \ No newline at end of file + ...{ + name: faker.string.alpha(), + ticker: faker.string.alpha(), + value: faker.number.float(), + currencyType: faker.helpers.arrayElement< + NonNullable['currencyType'] + >(['crypto', 'fiat']), + }, + ...(data || {}), + }; +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createExchangeRates.ts b/packages/core-backend/src/generated/price-api/mocks/createExchangeRates.ts index 3ef865cde2..99e18261ca 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createExchangeRates.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createExchangeRates.ts @@ -1,18 +1,21 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { ExchangeRates } from "../types/ExchangeRates"; -import { faker } from "@faker-js/faker"; +import type { ExchangeRates } from '../types/ExchangeRates'; /** * @description Exchange rates keyed by currency ticker. */ -export function createExchangeRates(data?: Partial): ExchangeRates { - faker.seed([220]) +export function createExchangeRates( + data?: Partial, +): ExchangeRates { + faker.seed([220]); return { ...{}, - ...data || {} - } -} \ No newline at end of file + ...(data || {}), + }; +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV1ExchangeRates.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV1ExchangeRates.ts index 84282305cc..818783bc33 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createGetV1ExchangeRates.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV1ExchangeRates.ts @@ -1,29 +1,42 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { GetV1ExchangeRates200, GetV1ExchangeRatesQueryParams, GetV1ExchangeRatesQueryResponse } from "../types/GetV1ExchangeRates"; -import { createExchangeRates } from "./createExchangeRates"; -import { faker } from "@faker-js/faker"; +import type { + GetV1ExchangeRates200, + GetV1ExchangeRatesQueryParams, + GetV1ExchangeRatesQueryResponse, +} from '../types/GetV1ExchangeRates'; +import { createExchangeRates } from './createExchangeRates'; -export function createGetV1ExchangeRatesQueryParams(data?: Partial): GetV1ExchangeRatesQueryParams { - faker.seed([220]) +export function createGetV1ExchangeRatesQueryParams( + data?: Partial, +): GetV1ExchangeRatesQueryParams { + faker.seed([220]); return { - ...{"baseCurrency": faker.string.alpha()}, - ...data || {} - } + ...{ baseCurrency: faker.string.alpha() }, + ...(data || {}), + }; } /** * @description Exchange rates keyed by currency ticker. */ -export function createGetV1ExchangeRates200(data?: Partial): GetV1ExchangeRates200 { - faker.seed([220]) - return createExchangeRates(data) +export function createGetV1ExchangeRates200( + data?: Partial, +): GetV1ExchangeRates200 { + faker.seed([220]); + return createExchangeRates(data); } -export function createGetV1ExchangeRatesQueryResponse(data?: Partial): GetV1ExchangeRatesQueryResponse { - faker.seed([220]) - return data || faker.helpers.arrayElement([createGetV1ExchangeRates200()]) -} \ No newline at end of file +export function createGetV1ExchangeRatesQueryResponse( + data?: Partial, +): GetV1ExchangeRatesQueryResponse { + faker.seed([220]); + return ( + data || faker.helpers.arrayElement([createGetV1ExchangeRates200()]) + ); +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV1FiatExchangeRates.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV1FiatExchangeRates.ts index 8f40013c4e..189babb13f 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createGetV1FiatExchangeRates.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV1FiatExchangeRates.ts @@ -1,21 +1,31 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { GetV1FiatExchangeRates200, GetV1FiatExchangeRatesQueryResponse } from "../types/GetV1FiatExchangeRates"; -import { createExchangeRates } from "./createExchangeRates"; -import { faker } from "@faker-js/faker"; +import type { + GetV1FiatExchangeRates200, + GetV1FiatExchangeRatesQueryResponse, +} from '../types/GetV1FiatExchangeRates'; +import { createExchangeRates } from './createExchangeRates'; /** * @description Exchange rates keyed by currency ticker. */ -export function createGetV1FiatExchangeRates200(data?: Partial): GetV1FiatExchangeRates200 { - faker.seed([220]) - return createExchangeRates(data) +export function createGetV1FiatExchangeRates200( + data?: Partial, +): GetV1FiatExchangeRates200 { + faker.seed([220]); + return createExchangeRates(data); } -export function createGetV1FiatExchangeRatesQueryResponse(data?: Partial): GetV1FiatExchangeRatesQueryResponse { - faker.seed([220]) - return data || faker.helpers.arrayElement([createGetV1FiatExchangeRates200()]) -} \ No newline at end of file +export function createGetV1FiatExchangeRatesQueryResponse( + data?: Partial, +): GetV1FiatExchangeRatesQueryResponse { + faker.seed([220]); + return ( + data || faker.helpers.arrayElement([createGetV1FiatExchangeRates200()]) + ); +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV1HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV1HistoricalPrices.ts index b65497ef48..93e8935a1a 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createGetV1HistoricalPrices.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV1HistoricalPrices.ts @@ -1,35 +1,59 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { GetV1HistoricalPrices200, GetV1HistoricalPricesPathParams, GetV1HistoricalPricesQueryParams, GetV1HistoricalPricesQueryResponse } from "../types/GetV1HistoricalPrices"; -import { createHistoricalPrices } from "./createHistoricalPrices"; -import { createVsCurrency } from "./createVsCurrency"; -import { faker } from "@faker-js/faker"; +import type { + GetV1HistoricalPrices200, + GetV1HistoricalPricesPathParams, + GetV1HistoricalPricesQueryParams, + GetV1HistoricalPricesQueryResponse, +} from '../types/GetV1HistoricalPrices'; +import { createHistoricalPrices } from './createHistoricalPrices'; +import { createVsCurrency } from './createVsCurrency'; -export function createGetV1HistoricalPricesPathParams(data?: Partial): GetV1HistoricalPricesPathParams { - faker.seed([220]) +export function createGetV1HistoricalPricesPathParams( + data?: Partial, +): GetV1HistoricalPricesPathParams { + faker.seed([220]); return { - ...{"chainId": faker.number.float(),"tokenAddress": faker.string.alpha()}, - ...data || {} - } + ...{ chainId: faker.number.float(), tokenAddress: faker.string.alpha() }, + ...(data || {}), + }; } -export function createGetV1HistoricalPricesQueryParams(data?: Partial): GetV1HistoricalPricesQueryParams { - faker.seed([220]) - return { ...{get "vsCurrency"() { return createVsCurrency() },"timePeriod": faker.string.alpha(),...(data || {})} } +export function createGetV1HistoricalPricesQueryParams( + data?: Partial, +): GetV1HistoricalPricesQueryParams { + faker.seed([220]); + return { + ...{ + get vsCurrency() { + return createVsCurrency(); + }, + timePeriod: faker.string.alpha(), + ...(data || {}), + }, + }; } /** * @description The historical prices of the token. */ -export function createGetV1HistoricalPrices200(data?: Partial): GetV1HistoricalPrices200 { - faker.seed([220]) - return createHistoricalPrices(data) +export function createGetV1HistoricalPrices200( + data?: Partial, +): GetV1HistoricalPrices200 { + faker.seed([220]); + return createHistoricalPrices(data); } -export function createGetV1HistoricalPricesQueryResponse(data?: Partial): GetV1HistoricalPricesQueryResponse { - faker.seed([220]) - return data || faker.helpers.arrayElement([createGetV1HistoricalPrices200()]) -} \ No newline at end of file +export function createGetV1HistoricalPricesQueryResponse( + data?: Partial, +): GetV1HistoricalPricesQueryResponse { + faker.seed([220]); + return ( + data || faker.helpers.arrayElement([createGetV1HistoricalPrices200()]) + ); +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV1SpotPriceByCoinId.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV1SpotPriceByCoinId.ts index c9040dd185..ff3341bf71 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createGetV1SpotPriceByCoinId.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV1SpotPriceByCoinId.ts @@ -1,35 +1,58 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { GetV1SpotPriceByCoinId200, GetV1SpotPriceByCoinIdPathParams, GetV1SpotPriceByCoinIdQueryParams, GetV1SpotPriceByCoinIdQueryResponse } from "../types/GetV1SpotPriceByCoinId"; -import { createCoinGeckoSpotPrice } from "./createCoinGeckoSpotPrice"; -import { createVsCurrency } from "./createVsCurrency"; -import { faker } from "@faker-js/faker"; +import type { + GetV1SpotPriceByCoinId200, + GetV1SpotPriceByCoinIdPathParams, + GetV1SpotPriceByCoinIdQueryParams, + GetV1SpotPriceByCoinIdQueryResponse, +} from '../types/GetV1SpotPriceByCoinId'; +import { createCoinGeckoSpotPrice } from './createCoinGeckoSpotPrice'; +import { createVsCurrency } from './createVsCurrency'; -export function createGetV1SpotPriceByCoinIdPathParams(data?: Partial): GetV1SpotPriceByCoinIdPathParams { - faker.seed([220]) +export function createGetV1SpotPriceByCoinIdPathParams( + data?: Partial, +): GetV1SpotPriceByCoinIdPathParams { + faker.seed([220]); return { - ...{"coinId": faker.string.alpha()}, - ...data || {} - } + ...{ coinId: faker.string.alpha() }, + ...(data || {}), + }; } -export function createGetV1SpotPriceByCoinIdQueryParams(data?: Partial): GetV1SpotPriceByCoinIdQueryParams { - faker.seed([220]) - return { ...{get "vsCurrency"() { return createVsCurrency() },...(data || {})} } +export function createGetV1SpotPriceByCoinIdQueryParams( + data?: Partial, +): GetV1SpotPriceByCoinIdQueryParams { + faker.seed([220]); + return { + ...{ + get vsCurrency() { + return createVsCurrency(); + }, + ...(data || {}), + }, + }; } /** * @description The spot price of the coin. */ -export function createGetV1SpotPriceByCoinId200(data?: Partial): GetV1SpotPriceByCoinId200 { - faker.seed([220]) - return createCoinGeckoSpotPrice(data) +export function createGetV1SpotPriceByCoinId200( + data?: Partial, +): GetV1SpotPriceByCoinId200 { + faker.seed([220]); + return createCoinGeckoSpotPrice(data); } -export function createGetV1SpotPriceByCoinIdQueryResponse(data?: Partial): GetV1SpotPriceByCoinIdQueryResponse { - faker.seed([220]) - return data || faker.helpers.arrayElement([createGetV1SpotPriceByCoinId200()]) -} \ No newline at end of file +export function createGetV1SpotPriceByCoinIdQueryResponse( + data?: Partial, +): GetV1SpotPriceByCoinIdQueryResponse { + faker.seed([220]); + return ( + data || faker.helpers.arrayElement([createGetV1SpotPriceByCoinId200()]) + ); +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV1SpotPricesByCoinIds.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV1SpotPricesByCoinIds.ts index 0f7ecccaa7..c186fe87b0 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createGetV1SpotPricesByCoinIds.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV1SpotPricesByCoinIds.ts @@ -1,27 +1,49 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { GetV1SpotPricesByCoinIds200, GetV1SpotPricesByCoinIdsQueryParams, GetV1SpotPricesByCoinIdsQueryResponse } from "../types/GetV1SpotPricesByCoinIds"; -import { createCoinGeckoSpotPrices } from "./createCoinGeckoSpotPrices"; -import { createVsCurrency } from "./createVsCurrency"; -import { faker } from "@faker-js/faker"; +import type { + GetV1SpotPricesByCoinIds200, + GetV1SpotPricesByCoinIdsQueryParams, + GetV1SpotPricesByCoinIdsQueryResponse, +} from '../types/GetV1SpotPricesByCoinIds'; +import { createCoinGeckoSpotPrices } from './createCoinGeckoSpotPrices'; +import { createVsCurrency } from './createVsCurrency'; -export function createGetV1SpotPricesByCoinIdsQueryParams(data?: Partial): GetV1SpotPricesByCoinIdsQueryParams { - faker.seed([220]) - return { ...{"coinIds": faker.string.alpha(),get "vsCurrency"() { return createVsCurrency() },...(data || {})} } +export function createGetV1SpotPricesByCoinIdsQueryParams( + data?: Partial, +): GetV1SpotPricesByCoinIdsQueryParams { + faker.seed([220]); + return { + ...{ + coinIds: faker.string.alpha(), + get vsCurrency() { + return createVsCurrency(); + }, + ...(data || {}), + }, + }; } /** * @description Spot prices keyed by CoinGecko coin ID. */ -export function createGetV1SpotPricesByCoinIds200(data?: Partial): GetV1SpotPricesByCoinIds200 { - faker.seed([220]) - return createCoinGeckoSpotPrices(data) +export function createGetV1SpotPricesByCoinIds200( + data?: Partial, +): GetV1SpotPricesByCoinIds200 { + faker.seed([220]); + return createCoinGeckoSpotPrices(data); } -export function createGetV1SpotPricesByCoinIdsQueryResponse(data?: Partial): GetV1SpotPricesByCoinIdsQueryResponse { - faker.seed([220]) - return data || faker.helpers.arrayElement([createGetV1SpotPricesByCoinIds200()]) -} \ No newline at end of file +export function createGetV1SpotPricesByCoinIdsQueryResponse( + data?: Partial, +): GetV1SpotPricesByCoinIdsQueryResponse { + faker.seed([220]); + return ( + data || + faker.helpers.arrayElement([createGetV1SpotPricesByCoinIds200()]) + ); +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV1SupportedNetworks.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV1SupportedNetworks.ts index 6ec13376f0..c379196376 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createGetV1SupportedNetworks.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV1SupportedNetworks.ts @@ -1,21 +1,31 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { GetV1SupportedNetworks200, GetV1SupportedNetworksQueryResponse } from "../types/GetV1SupportedNetworks"; -import { createSupportedNetworks } from "./createSupportedNetworks"; -import { faker } from "@faker-js/faker"; +import type { + GetV1SupportedNetworks200, + GetV1SupportedNetworksQueryResponse, +} from '../types/GetV1SupportedNetworks'; +import { createSupportedNetworks } from './createSupportedNetworks'; /** * @description The supported networks, split by level of support. */ -export function createGetV1SupportedNetworks200(data?: Partial): GetV1SupportedNetworks200 { - faker.seed([220]) - return createSupportedNetworks(data) +export function createGetV1SupportedNetworks200( + data?: Partial, +): GetV1SupportedNetworks200 { + faker.seed([220]); + return createSupportedNetworks(data); } -export function createGetV1SupportedNetworksQueryResponse(data?: Partial): GetV1SupportedNetworksQueryResponse { - faker.seed([220]) - return data || faker.helpers.arrayElement([createGetV1SupportedNetworks200()]) -} \ No newline at end of file +export function createGetV1SupportedNetworksQueryResponse( + data?: Partial, +): GetV1SupportedNetworksQueryResponse { + faker.seed([220]); + return ( + data || faker.helpers.arrayElement([createGetV1SupportedNetworks200()]) + ); +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV2SpotPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV2SpotPrices.ts index 7cc0b45444..ed09b38539 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createGetV2SpotPrices.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV2SpotPrices.ts @@ -1,35 +1,58 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { GetV2SpotPrices200, GetV2SpotPricesPathParams, GetV2SpotPricesQueryParams, GetV2SpotPricesQueryResponse } from "../types/GetV2SpotPrices"; -import { createMarketDataSpotPrices } from "./createMarketDataSpotPrices"; -import { createVsCurrency } from "./createVsCurrency"; -import { faker } from "@faker-js/faker"; +import type { + GetV2SpotPrices200, + GetV2SpotPricesPathParams, + GetV2SpotPricesQueryParams, + GetV2SpotPricesQueryResponse, +} from '../types/GetV2SpotPrices'; +import { createMarketDataSpotPrices } from './createMarketDataSpotPrices'; +import { createVsCurrency } from './createVsCurrency'; -export function createGetV2SpotPricesPathParams(data?: Partial): GetV2SpotPricesPathParams { - faker.seed([220]) +export function createGetV2SpotPricesPathParams( + data?: Partial, +): GetV2SpotPricesPathParams { + faker.seed([220]); return { - ...{"chainId": faker.number.float()}, - ...data || {} - } + ...{ chainId: faker.number.float() }, + ...(data || {}), + }; } -export function createGetV2SpotPricesQueryParams(data?: Partial): GetV2SpotPricesQueryParams { - faker.seed([220]) - return { ...{"tokenAddresses": faker.string.alpha(),get "vsCurrency"() { return createVsCurrency() },"includeMarketData": faker.datatype.boolean(),...(data || {})} } +export function createGetV2SpotPricesQueryParams( + data?: Partial, +): GetV2SpotPricesQueryParams { + faker.seed([220]); + return { + ...{ + tokenAddresses: faker.string.alpha(), + get vsCurrency() { + return createVsCurrency(); + }, + includeMarketData: faker.datatype.boolean(), + ...(data || {}), + }, + }; } /** * @description Market data keyed by lowercased token contract address. */ -export function createGetV2SpotPrices200(data?: Partial): GetV2SpotPrices200 { - faker.seed([220]) - return createMarketDataSpotPrices(data) +export function createGetV2SpotPrices200( + data?: Partial, +): GetV2SpotPrices200 { + faker.seed([220]); + return createMarketDataSpotPrices(data); } -export function createGetV2SpotPricesQueryResponse(data?: Partial): GetV2SpotPricesQueryResponse { - faker.seed([220]) - return data || faker.helpers.arrayElement([createGetV2SpotPrices200()]) -} \ No newline at end of file +export function createGetV2SpotPricesQueryResponse( + data?: Partial, +): GetV2SpotPricesQueryResponse { + faker.seed([220]); + return data || faker.helpers.arrayElement([createGetV2SpotPrices200()]); +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV2SupportedNetworks.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV2SupportedNetworks.ts index b913aadcb2..44b056e701 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createGetV2SupportedNetworks.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV2SupportedNetworks.ts @@ -1,21 +1,31 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { GetV2SupportedNetworks200, GetV2SupportedNetworksQueryResponse } from "../types/GetV2SupportedNetworks"; -import { createSupportedNetworks } from "./createSupportedNetworks"; -import { faker } from "@faker-js/faker"; +import type { + GetV2SupportedNetworks200, + GetV2SupportedNetworksQueryResponse, +} from '../types/GetV2SupportedNetworks'; +import { createSupportedNetworks } from './createSupportedNetworks'; /** * @description The supported networks, split by level of support. */ -export function createGetV2SupportedNetworks200(data?: Partial): GetV2SupportedNetworks200 { - faker.seed([220]) - return createSupportedNetworks(data) +export function createGetV2SupportedNetworks200( + data?: Partial, +): GetV2SupportedNetworks200 { + faker.seed([220]); + return createSupportedNetworks(data); } -export function createGetV2SupportedNetworksQueryResponse(data?: Partial): GetV2SupportedNetworksQueryResponse { - faker.seed([220]) - return data || faker.helpers.arrayElement([createGetV2SupportedNetworks200()]) -} \ No newline at end of file +export function createGetV2SupportedNetworksQueryResponse( + data?: Partial, +): GetV2SupportedNetworksQueryResponse { + faker.seed([220]); + return ( + data || faker.helpers.arrayElement([createGetV2SupportedNetworks200()]) + ); +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV2TopTokens.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV2TopTokens.ts index 0fbef0cf38..2ecf0fbede 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createGetV2TopTokens.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV2TopTokens.ts @@ -1,38 +1,57 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { GetV2TopTokens200, GetV2TopTokensPathParams, GetV2TopTokensQueryParams, GetV2TopTokensQueryResponse } from "../types/GetV2TopTokens"; -import { createTopToken } from "./createTopToken"; -import { createVsCurrency } from "./createVsCurrency"; -import { faker } from "@faker-js/faker"; +import type { + GetV2TopTokens200, + GetV2TopTokensPathParams, + GetV2TopTokensQueryParams, + GetV2TopTokensQueryResponse, +} from '../types/GetV2TopTokens'; +import { createTopToken } from './createTopToken'; +import { createVsCurrency } from './createVsCurrency'; -export function createGetV2TopTokensPathParams(data?: Partial): GetV2TopTokensPathParams { - faker.seed([220]) +export function createGetV2TopTokensPathParams( + data?: Partial, +): GetV2TopTokensPathParams { + faker.seed([220]); return { - ...{"chainId": faker.number.float()}, - ...data || {} - } + ...{ chainId: faker.number.float() }, + ...(data || {}), + }; } -export function createGetV2TopTokensQueryParams(data?: Partial): GetV2TopTokensQueryParams { - faker.seed([220]) - return { ...{"limit": faker.number.float({ min: 1, max: 300 }),get "vsCurrency"() { return createVsCurrency() },...(data || {})} } +export function createGetV2TopTokensQueryParams( + data?: Partial, +): GetV2TopTokensQueryParams { + faker.seed([220]); + return { + ...{ + limit: faker.number.float({ min: 1, max: 300 }), + get vsCurrency() { + return createVsCurrency(); + }, + ...(data || {}), + }, + }; } /** * @description The top tokens ordered by market cap. */ -export function createGetV2TopTokens200(data?: GetV2TopTokens200): GetV2TopTokens200 { - faker.seed([220]) - return [ - ...faker.helpers.multiple(() => (createTopToken())), - ...data || [] - ] +export function createGetV2TopTokens200( + data?: GetV2TopTokens200, +): GetV2TopTokens200 { + faker.seed([220]); + return [...faker.helpers.multiple(() => createTopToken()), ...(data || [])]; } -export function createGetV2TopTokensQueryResponse(data?: Partial): GetV2TopTokensQueryResponse { - faker.seed([220]) - return data || faker.helpers.arrayElement([createGetV2TopTokens200()]) -} \ No newline at end of file +export function createGetV2TopTokensQueryResponse( + data?: Partial, +): GetV2TopTokensQueryResponse { + faker.seed([220]); + return data || faker.helpers.arrayElement([createGetV2TopTokens200()]); +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV3HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV3HistoricalPrices.ts index 350f47f165..6ed1ee2812 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createGetV3HistoricalPrices.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV3HistoricalPrices.ts @@ -1,35 +1,64 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { GetV3HistoricalPrices200, GetV3HistoricalPricesPathParams, GetV3HistoricalPricesQueryParams, GetV3HistoricalPricesQueryResponse } from "../types/GetV3HistoricalPrices"; -import { createV3HistoricalPrices } from "./createV3HistoricalPrices"; -import { createVsCurrency } from "./createVsCurrency"; -import { faker } from "@faker-js/faker"; +import type { + GetV3HistoricalPrices200, + GetV3HistoricalPricesPathParams, + GetV3HistoricalPricesQueryParams, + GetV3HistoricalPricesQueryResponse, +} from '../types/GetV3HistoricalPrices'; +import { createV3HistoricalPrices } from './createV3HistoricalPrices'; +import { createVsCurrency } from './createVsCurrency'; -export function createGetV3HistoricalPricesPathParams(data?: Partial): GetV3HistoricalPricesPathParams { - faker.seed([220]) +export function createGetV3HistoricalPricesPathParams( + data?: Partial, +): GetV3HistoricalPricesPathParams { + faker.seed([220]); return { - ...{"chainId": faker.string.alpha(),"assetType": faker.string.alpha()}, - ...data || {} - } + ...{ chainId: faker.string.alpha(), assetType: faker.string.alpha() }, + ...(data || {}), + }; } -export function createGetV3HistoricalPricesQueryParams(data?: Partial): GetV3HistoricalPricesQueryParams { - faker.seed([220]) - return { ...{get "vsCurrency"() { return createVsCurrency() },"timePeriod": faker.string.alpha(),"from": faker.number.float(),"to": faker.number.float(),"interval": faker.helpers.arrayElement["interval"]>(["5m", "hourly", "daily"]),...(data || {})} } +export function createGetV3HistoricalPricesQueryParams( + data?: Partial, +): GetV3HistoricalPricesQueryParams { + faker.seed([220]); + return { + ...{ + get vsCurrency() { + return createVsCurrency(); + }, + timePeriod: faker.string.alpha(), + from: faker.number.float(), + to: faker.number.float(), + interval: faker.helpers.arrayElement< + NonNullable['interval'] + >(['5m', 'hourly', 'daily']), + ...(data || {}), + }, + }; } /** * @description The historical prices of the asset. */ -export function createGetV3HistoricalPrices200(data?: Partial): GetV3HistoricalPrices200 { - faker.seed([220]) - return createV3HistoricalPrices(data) +export function createGetV3HistoricalPrices200( + data?: Partial, +): GetV3HistoricalPrices200 { + faker.seed([220]); + return createV3HistoricalPrices(data); } -export function createGetV3HistoricalPricesQueryResponse(data?: Partial): GetV3HistoricalPricesQueryResponse { - faker.seed([220]) - return data || faker.helpers.arrayElement([createGetV3HistoricalPrices200()]) -} \ No newline at end of file +export function createGetV3HistoricalPricesQueryResponse( + data?: Partial, +): GetV3HistoricalPricesQueryResponse { + faker.seed([220]); + return ( + data || faker.helpers.arrayElement([createGetV3HistoricalPrices200()]) + ); +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV3SpotPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV3SpotPrices.ts index 33eba31903..a06fbc5986 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createGetV3SpotPrices.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV3SpotPrices.ts @@ -1,27 +1,48 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { GetV3SpotPrices200, GetV3SpotPricesQueryParams, GetV3SpotPricesQueryResponse } from "../types/GetV3SpotPrices"; -import { createV3SpotPrices } from "./createV3SpotPrices"; -import { createVsCurrency } from "./createVsCurrency"; -import { faker } from "@faker-js/faker"; +import type { + GetV3SpotPrices200, + GetV3SpotPricesQueryParams, + GetV3SpotPricesQueryResponse, +} from '../types/GetV3SpotPrices'; +import { createV3SpotPrices } from './createV3SpotPrices'; +import { createVsCurrency } from './createVsCurrency'; -export function createGetV3SpotPricesQueryParams(data?: Partial): GetV3SpotPricesQueryParams { - faker.seed([220]) - return { ...{"assetIds": faker.string.alpha(),get "vsCurrency"() { return createVsCurrency() },"includeMarketData": faker.datatype.boolean(),"cacheOnly": faker.datatype.boolean(),...(data || {})} } +export function createGetV3SpotPricesQueryParams( + data?: Partial, +): GetV3SpotPricesQueryParams { + faker.seed([220]); + return { + ...{ + assetIds: faker.string.alpha(), + get vsCurrency() { + return createVsCurrency(); + }, + includeMarketData: faker.datatype.boolean(), + cacheOnly: faker.datatype.boolean(), + ...(data || {}), + }, + }; } /** * @description Spot prices keyed by CAIP-19 asset ID. Unknown assets map to null. */ -export function createGetV3SpotPrices200(data?: Partial): GetV3SpotPrices200 { - faker.seed([220]) - return createV3SpotPrices(data) +export function createGetV3SpotPrices200( + data?: Partial, +): GetV3SpotPrices200 { + faker.seed([220]); + return createV3SpotPrices(data); } -export function createGetV3SpotPricesQueryResponse(data?: Partial): GetV3SpotPricesQueryResponse { - faker.seed([220]) - return data || faker.helpers.arrayElement([createGetV3SpotPrices200()]) -} \ No newline at end of file +export function createGetV3SpotPricesQueryResponse( + data?: Partial, +): GetV3SpotPricesQueryResponse { + faker.seed([220]); + return data || faker.helpers.arrayElement([createGetV3SpotPrices200()]); +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createHistoricalPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createHistoricalPrices.ts index 2021884ddf..7f6467e977 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createHistoricalPrices.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createHistoricalPrices.ts @@ -1,16 +1,26 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { HistoricalPrices } from "../types/HistoricalPrices"; -import { createPricePoint } from "./createPricePoint"; -import { faker } from "@faker-js/faker"; +import type { HistoricalPrices } from '../types/HistoricalPrices'; +import { createPricePoint } from './createPricePoint'; /** * @description Historical prices for a token. */ -export function createHistoricalPrices(data?: Partial): HistoricalPrices { - faker.seed([220]) - return { ...{get "prices"() { return faker.helpers.multiple(() => (createPricePoint())) },...(data || {})} } -} \ No newline at end of file +export function createHistoricalPrices( + data?: Partial, +): HistoricalPrices { + faker.seed([220]); + return { + ...{ + get prices() { + return faker.helpers.multiple(() => createPricePoint()); + }, + ...(data || {}), + }, + }; +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createMarketData.ts b/packages/core-backend/src/generated/price-api/mocks/createMarketData.ts index ccf836122f..1e19dbcb32 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createMarketData.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createMarketData.ts @@ -1,18 +1,39 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { MarketData } from "../types/MarketData"; -import { faker } from "@faker-js/faker"; +import type { MarketData } from '../types/MarketData'; /** * @description Market data for a token, as returned by the v2 spot prices endpoint. */ export function createMarketData(data?: Partial): MarketData { - faker.seed([220]) + faker.seed([220]); return { - ...{"price": faker.number.float(),"currency": faker.string.alpha(),"priceChange1d": faker.number.float(),"pricePercentChange1d": faker.number.float(),"pricePercentChange1h": faker.number.float(),"pricePercentChange7d": faker.number.float(),"pricePercentChange14d": faker.number.float(),"pricePercentChange30d": faker.number.float(),"pricePercentChange200d": faker.number.float(),"pricePercentChange1y": faker.number.float(),"marketCap": faker.number.float(),"marketCapPercentChange1d": faker.number.float(),"allTimeHigh": faker.number.float(),"allTimeLow": faker.number.float(),"high1d": faker.number.float(),"low1d": faker.number.float(),"totalVolume": faker.number.float(),"circulatingSupply": faker.number.float(),"dilutedMarketCap": faker.number.float()}, - ...data || {} - } -} \ No newline at end of file + ...{ + price: faker.number.float(), + currency: faker.string.alpha(), + priceChange1d: faker.number.float(), + pricePercentChange1d: faker.number.float(), + pricePercentChange1h: faker.number.float(), + pricePercentChange7d: faker.number.float(), + pricePercentChange14d: faker.number.float(), + pricePercentChange30d: faker.number.float(), + pricePercentChange200d: faker.number.float(), + pricePercentChange1y: faker.number.float(), + marketCap: faker.number.float(), + marketCapPercentChange1d: faker.number.float(), + allTimeHigh: faker.number.float(), + allTimeLow: faker.number.float(), + high1d: faker.number.float(), + low1d: faker.number.float(), + totalVolume: faker.number.float(), + circulatingSupply: faker.number.float(), + dilutedMarketCap: faker.number.float(), + }, + ...(data || {}), + }; +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createMarketDataSpotPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createMarketDataSpotPrices.ts index bd5ed0580b..c0bdfde882 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createMarketDataSpotPrices.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createMarketDataSpotPrices.ts @@ -1,19 +1,22 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { MarketDataSpotPrices } from "../types/MarketDataSpotPrices"; -import { createMarketData } from "./createMarketData"; -import { faker } from "@faker-js/faker"; +import type { MarketDataSpotPrices } from '../types/MarketDataSpotPrices'; +import { createMarketData } from './createMarketData'; /** * @description Market data keyed by lowercased token contract address. */ -export function createMarketDataSpotPrices(data?: Partial): MarketDataSpotPrices { - faker.seed([220]) +export function createMarketDataSpotPrices( + data?: Partial, +): MarketDataSpotPrices { + faker.seed([220]); return { ...{}, - ...data || {} - } -} \ No newline at end of file + ...(data || {}), + }; +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createPricePoint.ts b/packages/core-backend/src/generated/price-api/mocks/createPricePoint.ts index 38aee8563d..5312b6e71f 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createPricePoint.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createPricePoint.ts @@ -1,15 +1,16 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { PricePoint } from "../types/PricePoint"; -import { faker } from "@faker-js/faker"; +import type { PricePoint } from '../types/PricePoint'; /** * @description A [timestamp, value] tuple. The timestamp is a Unix timestamp in milliseconds. */ export function createPricePoint(data?: PricePoint): PricePoint { - faker.seed([220]) - return [faker.number.float(), faker.number.float()] -} \ No newline at end of file + faker.seed([220]); + return [faker.number.float(), faker.number.float()]; +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createSupportedNetworks.ts b/packages/core-backend/src/generated/price-api/mocks/createSupportedNetworks.ts index 9e1035b241..3ce0a3f989 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createSupportedNetworks.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createSupportedNetworks.ts @@ -1,18 +1,24 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { SupportedNetworks } from "../types/SupportedNetworks"; -import { faker } from "@faker-js/faker"; +import type { SupportedNetworks } from '../types/SupportedNetworks'; /** * @description Networks supported by the Price API, split by level of support. */ -export function createSupportedNetworks(data?: Partial): SupportedNetworks { - faker.seed([220]) +export function createSupportedNetworks( + data?: Partial, +): SupportedNetworks { + faker.seed([220]); return { - ...{"fullSupport": faker.helpers.multiple(() => (faker.string.alpha())),"partialSupport": faker.helpers.multiple(() => (faker.string.alpha()))}, - ...data || {} - } -} \ No newline at end of file + ...{ + fullSupport: faker.helpers.multiple(() => faker.string.alpha()), + partialSupport: faker.helpers.multiple(() => faker.string.alpha()), + }, + ...(data || {}), + }; +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createTopToken.ts b/packages/core-backend/src/generated/price-api/mocks/createTopToken.ts index 85745b3ea3..15a4537249 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createTopToken.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createTopToken.ts @@ -1,18 +1,25 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { TopToken } from "../types/TopToken"; -import { faker } from "@faker-js/faker"; +import type { TopToken } from '../types/TopToken'; /** * @description A token in the top tokens list. */ export function createTopToken(data?: Partial): TopToken { - faker.seed([220]) + faker.seed([220]); return { - ...{"assetId": faker.string.alpha(),"name": faker.string.alpha(),"symbol": faker.string.alpha(),"price": faker.number.float(),"marketCap": faker.number.float()}, - ...data || {} - } -} \ No newline at end of file + ...{ + assetId: faker.string.alpha(), + name: faker.string.alpha(), + symbol: faker.string.alpha(), + price: faker.number.float(), + marketCap: faker.number.float(), + }, + ...(data || {}), + }; +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createV3HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createV3HistoricalPrices.ts index c3356fb316..7428a935e3 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createV3HistoricalPrices.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createV3HistoricalPrices.ts @@ -1,16 +1,32 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { V3HistoricalPrices } from "../types/V3HistoricalPrices"; -import { createPricePoint } from "./createPricePoint"; -import { faker } from "@faker-js/faker"; +import type { V3HistoricalPrices } from '../types/V3HistoricalPrices'; +import { createPricePoint } from './createPricePoint'; /** * @description Historical prices, market caps and total volumes for a CAIP-19 asset. */ -export function createV3HistoricalPrices(data?: Partial): V3HistoricalPrices { - faker.seed([220]) - return { ...{get "prices"() { return faker.helpers.multiple(() => (createPricePoint())) },get "marketCaps"() { return faker.helpers.multiple(() => (createPricePoint())) },get "totalVolumes"() { return faker.helpers.multiple(() => (createPricePoint())) },...(data || {})} } -} \ No newline at end of file +export function createV3HistoricalPrices( + data?: Partial, +): V3HistoricalPrices { + faker.seed([220]); + return { + ...{ + get prices() { + return faker.helpers.multiple(() => createPricePoint()); + }, + get marketCaps() { + return faker.helpers.multiple(() => createPricePoint()); + }, + get totalVolumes() { + return faker.helpers.multiple(() => createPricePoint()); + }, + ...(data || {}), + }, + }; +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createV3SpotPrice.ts b/packages/core-backend/src/generated/price-api/mocks/createV3SpotPrice.ts index ca8c32511c..58f53c5b01 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createV3SpotPrice.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createV3SpotPrice.ts @@ -1,18 +1,24 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { V3SpotPrice } from "../types/V3SpotPrice"; -import { faker } from "@faker-js/faker"; +import type { V3SpotPrice } from '../types/V3SpotPrice'; /** * @description Spot price and optional market data for a CAIP-19 asset. */ export function createV3SpotPrice(data?: Partial): V3SpotPrice { - faker.seed([220]) + faker.seed([220]); return { - ...{"price": faker.number.float(),"pricePercentChange1d": faker.number.float(),"marketCap": faker.number.float(),"totalVolume": faker.number.float()}, - ...data || {} - } -} \ No newline at end of file + ...{ + price: faker.number.float(), + pricePercentChange1d: faker.number.float(), + marketCap: faker.number.float(), + totalVolume: faker.number.float(), + }, + ...(data || {}), + }; +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createV3SpotPrices.ts b/packages/core-backend/src/generated/price-api/mocks/createV3SpotPrices.ts index 91267816f8..45bb6da163 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createV3SpotPrices.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createV3SpotPrices.ts @@ -1,19 +1,20 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { V3SpotPrices } from "../types/V3SpotPrices"; -import { createV3SpotPrice } from "./createV3SpotPrice"; -import { faker } from "@faker-js/faker"; +import type { V3SpotPrices } from '../types/V3SpotPrices'; +import { createV3SpotPrice } from './createV3SpotPrice'; /** * @description Spot prices keyed by CAIP-19 asset ID. Assets without a known price map to null. */ export function createV3SpotPrices(data?: Partial): V3SpotPrices { - faker.seed([220]) + faker.seed([220]); return { ...{}, - ...data || {} - } -} \ No newline at end of file + ...(data || {}), + }; +} diff --git a/packages/core-backend/src/generated/price-api/mocks/createVsCurrency.ts b/packages/core-backend/src/generated/price-api/mocks/createVsCurrency.ts index 27498e1522..d43b06e6b8 100644 --- a/packages/core-backend/src/generated/price-api/mocks/createVsCurrency.ts +++ b/packages/core-backend/src/generated/price-api/mocks/createVsCurrency.ts @@ -1,15 +1,77 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; -import type { VsCurrency } from "../types/VsCurrency"; -import { faker } from "@faker-js/faker"; +import type { VsCurrency } from '../types/VsCurrency'; /** * @description A currency that prices can be denominated in. */ export function createVsCurrency(data?: Partial): VsCurrency { - faker.seed([220]) - return data || faker.helpers.arrayElement(["btc", "eth", "ltc", "bch", "bnb", "eos", "xrp", "xlm", "link", "dot", "yfi", "usd", "aed", "ars", "aud", "bdt", "bhd", "bmd", "brl", "cad", "chf", "clp", "cny", "czk", "dkk", "eur", "gbp", "gel", "hkd", "huf", "idr", "ils", "inr", "jpy", "krw", "kwd", "lkr", "mmk", "mxn", "myr", "ngn", "nok", "nzd", "php", "pkr", "pln", "rub", "sar", "sek", "sgd", "thb", "try", "twd", "uah", "vef", "vnd", "zar"]) -} \ No newline at end of file + faker.seed([220]); + return ( + data || + faker.helpers.arrayElement([ + 'btc', + 'eth', + 'ltc', + 'bch', + 'bnb', + 'eos', + 'xrp', + 'xlm', + 'link', + 'dot', + 'yfi', + 'usd', + 'aed', + 'ars', + 'aud', + 'bdt', + 'bhd', + 'bmd', + 'brl', + 'cad', + 'chf', + 'clp', + 'cny', + 'czk', + 'dkk', + 'eur', + 'gbp', + 'gel', + 'hkd', + 'huf', + 'idr', + 'ils', + 'inr', + 'jpy', + 'krw', + 'kwd', + 'lkr', + 'mmk', + 'mxn', + 'myr', + 'ngn', + 'nok', + 'nzd', + 'php', + 'pkr', + 'pln', + 'rub', + 'sar', + 'sek', + 'sgd', + 'thb', + 'try', + 'twd', + 'uah', + 'vef', + 'vnd', + 'zar', + ]) + ); +} diff --git a/packages/core-backend/src/generated/price-api/mocks/index.ts b/packages/core-backend/src/generated/price-api/mocks/index.ts index 6fe910c3ae..cdd210747b 100644 --- a/packages/core-backend/src/generated/price-api/mocks/index.ts +++ b/packages/core-backend/src/generated/price-api/mocks/index.ts @@ -1,25 +1,71 @@ -export { createCoinGeckoSpotPrice } from "./createCoinGeckoSpotPrice"; -export { createCoinGeckoSpotPrices } from "./createCoinGeckoSpotPrices"; -export { createExchangeRateInfo } from "./createExchangeRateInfo"; -export { createExchangeRates } from "./createExchangeRates"; -export { createGetV1ExchangeRates200, createGetV1ExchangeRatesQueryParams, createGetV1ExchangeRatesQueryResponse } from "./createGetV1ExchangeRates"; -export { createGetV1FiatExchangeRates200, createGetV1FiatExchangeRatesQueryResponse } from "./createGetV1FiatExchangeRates"; -export { createGetV1HistoricalPrices200, createGetV1HistoricalPricesPathParams, createGetV1HistoricalPricesQueryParams, createGetV1HistoricalPricesQueryResponse } from "./createGetV1HistoricalPrices"; -export { createGetV1SpotPriceByCoinId200, createGetV1SpotPriceByCoinIdPathParams, createGetV1SpotPriceByCoinIdQueryParams, createGetV1SpotPriceByCoinIdQueryResponse } from "./createGetV1SpotPriceByCoinId"; -export { createGetV1SpotPricesByCoinIds200, createGetV1SpotPricesByCoinIdsQueryParams, createGetV1SpotPricesByCoinIdsQueryResponse } from "./createGetV1SpotPricesByCoinIds"; -export { createGetV1SupportedNetworks200, createGetV1SupportedNetworksQueryResponse } from "./createGetV1SupportedNetworks"; -export { createGetV2SpotPrices200, createGetV2SpotPricesPathParams, createGetV2SpotPricesQueryParams, createGetV2SpotPricesQueryResponse } from "./createGetV2SpotPrices"; -export { createGetV2SupportedNetworks200, createGetV2SupportedNetworksQueryResponse } from "./createGetV2SupportedNetworks"; -export { createGetV2TopTokens200, createGetV2TopTokensPathParams, createGetV2TopTokensQueryParams, createGetV2TopTokensQueryResponse } from "./createGetV2TopTokens"; -export { createGetV3HistoricalPrices200, createGetV3HistoricalPricesPathParams, createGetV3HistoricalPricesQueryParams, createGetV3HistoricalPricesQueryResponse } from "./createGetV3HistoricalPrices"; -export { createGetV3SpotPrices200, createGetV3SpotPricesQueryParams, createGetV3SpotPricesQueryResponse } from "./createGetV3SpotPrices"; -export { createHistoricalPrices } from "./createHistoricalPrices"; -export { createMarketData } from "./createMarketData"; -export { createMarketDataSpotPrices } from "./createMarketDataSpotPrices"; -export { createPricePoint } from "./createPricePoint"; -export { createSupportedNetworks } from "./createSupportedNetworks"; -export { createTopToken } from "./createTopToken"; -export { createV3HistoricalPrices } from "./createV3HistoricalPrices"; -export { createV3SpotPrice } from "./createV3SpotPrice"; -export { createV3SpotPrices } from "./createV3SpotPrices"; -export { createVsCurrency } from "./createVsCurrency"; \ No newline at end of file +export { createCoinGeckoSpotPrice } from './createCoinGeckoSpotPrice'; +export { createCoinGeckoSpotPrices } from './createCoinGeckoSpotPrices'; +export { createExchangeRateInfo } from './createExchangeRateInfo'; +export { createExchangeRates } from './createExchangeRates'; +export { + createGetV1ExchangeRates200, + createGetV1ExchangeRatesQueryParams, + createGetV1ExchangeRatesQueryResponse, +} from './createGetV1ExchangeRates'; +export { + createGetV1FiatExchangeRates200, + createGetV1FiatExchangeRatesQueryResponse, +} from './createGetV1FiatExchangeRates'; +export { + createGetV1HistoricalPrices200, + createGetV1HistoricalPricesPathParams, + createGetV1HistoricalPricesQueryParams, + createGetV1HistoricalPricesQueryResponse, +} from './createGetV1HistoricalPrices'; +export { + createGetV1SpotPriceByCoinId200, + createGetV1SpotPriceByCoinIdPathParams, + createGetV1SpotPriceByCoinIdQueryParams, + createGetV1SpotPriceByCoinIdQueryResponse, +} from './createGetV1SpotPriceByCoinId'; +export { + createGetV1SpotPricesByCoinIds200, + createGetV1SpotPricesByCoinIdsQueryParams, + createGetV1SpotPricesByCoinIdsQueryResponse, +} from './createGetV1SpotPricesByCoinIds'; +export { + createGetV1SupportedNetworks200, + createGetV1SupportedNetworksQueryResponse, +} from './createGetV1SupportedNetworks'; +export { + createGetV2SpotPrices200, + createGetV2SpotPricesPathParams, + createGetV2SpotPricesQueryParams, + createGetV2SpotPricesQueryResponse, +} from './createGetV2SpotPrices'; +export { + createGetV2SupportedNetworks200, + createGetV2SupportedNetworksQueryResponse, +} from './createGetV2SupportedNetworks'; +export { + createGetV2TopTokens200, + createGetV2TopTokensPathParams, + createGetV2TopTokensQueryParams, + createGetV2TopTokensQueryResponse, +} from './createGetV2TopTokens'; +export { + createGetV3HistoricalPrices200, + createGetV3HistoricalPricesPathParams, + createGetV3HistoricalPricesQueryParams, + createGetV3HistoricalPricesQueryResponse, +} from './createGetV3HistoricalPrices'; +export { + createGetV3SpotPrices200, + createGetV3SpotPricesQueryParams, + createGetV3SpotPricesQueryResponse, +} from './createGetV3SpotPrices'; +export { createHistoricalPrices } from './createHistoricalPrices'; +export { createMarketData } from './createMarketData'; +export { createMarketDataSpotPrices } from './createMarketDataSpotPrices'; +export { createPricePoint } from './createPricePoint'; +export { createSupportedNetworks } from './createSupportedNetworks'; +export { createTopToken } from './createTopToken'; +export { createV3HistoricalPrices } from './createV3HistoricalPrices'; +export { createV3SpotPrice } from './createV3SpotPrice'; +export { createV3SpotPrices } from './createV3SpotPrices'; +export { createVsCurrency } from './createVsCurrency'; diff --git a/packages/core-backend/src/generated/price-api/msw/getV1ExchangeRatesHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV1ExchangeRatesHandler.ts index 163393f24f..f09bfc3d55 100644 --- a/packages/core-backend/src/generated/price-api/msw/getV1ExchangeRatesHandler.ts +++ b/packages/core-backend/src/generated/price-api/msw/getV1ExchangeRatesHandler.ts @@ -1,34 +1,46 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { GetV1ExchangeRatesQueryResponse } from "../types/GetV1ExchangeRates"; -import { createGetV1ExchangeRatesQueryResponse } from "../mocks/createGetV1ExchangeRates"; -import { http } from "msw"; -import type { HttpHandler } from "msw"; +import { http } from 'msw'; +import type { HttpHandler } from 'msw'; -export function getV1ExchangeRatesHandlerResponse200(data: GetV1ExchangeRatesQueryResponse) { +import { createGetV1ExchangeRatesQueryResponse } from '../mocks/createGetV1ExchangeRates'; +import type { GetV1ExchangeRatesQueryResponse } from '../types/GetV1ExchangeRates'; - return new Response(JSON.stringify(data), { - status: 200, - headers: { - 'Content-Type': 'application/json' - }, - }) +export function getV1ExchangeRatesHandlerResponse200( + data: GetV1ExchangeRatesQueryResponse, +) { + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); } -export function getV1ExchangeRatesHandler(data?: GetV1ExchangeRatesQueryResponse | (( +export function getV1ExchangeRatesHandler( + data?: + | GetV1ExchangeRatesQueryResponse + | (( info: Parameters[1]>[0], - ) => Response | Promise)): HttpHandler { - return http.get('https://price.api.cx.metamask.io/v1/exchange-rates', function handler(info) { - if(typeof data === 'function') return data(info) + ) => Response | Promise), +): HttpHandler { + return http.get( + 'https://price.api.cx.metamask.io/v1/exchange-rates', + function handler(info) { + if (typeof data === 'function') return data(info); - return new Response(JSON.stringify(data || createGetV1ExchangeRatesQueryResponse(data)), { - status: 200, + return new Response( + JSON.stringify(data || createGetV1ExchangeRatesQueryResponse(data)), + { + status: 200, headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + }, }, - }) - }) -} \ No newline at end of file + ); + }, + ); +} diff --git a/packages/core-backend/src/generated/price-api/msw/getV1FiatExchangeRatesHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV1FiatExchangeRatesHandler.ts index 5ebc0b49c7..6e30bb9641 100644 --- a/packages/core-backend/src/generated/price-api/msw/getV1FiatExchangeRatesHandler.ts +++ b/packages/core-backend/src/generated/price-api/msw/getV1FiatExchangeRatesHandler.ts @@ -1,34 +1,46 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { GetV1FiatExchangeRatesQueryResponse } from "../types/GetV1FiatExchangeRates"; -import { createGetV1FiatExchangeRatesQueryResponse } from "../mocks/createGetV1FiatExchangeRates"; -import { http } from "msw"; -import type { HttpHandler } from "msw"; +import { http } from 'msw'; +import type { HttpHandler } from 'msw'; -export function getV1FiatExchangeRatesHandlerResponse200(data: GetV1FiatExchangeRatesQueryResponse) { +import { createGetV1FiatExchangeRatesQueryResponse } from '../mocks/createGetV1FiatExchangeRates'; +import type { GetV1FiatExchangeRatesQueryResponse } from '../types/GetV1FiatExchangeRates'; - return new Response(JSON.stringify(data), { - status: 200, - headers: { - 'Content-Type': 'application/json' - }, - }) +export function getV1FiatExchangeRatesHandlerResponse200( + data: GetV1FiatExchangeRatesQueryResponse, +) { + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); } -export function getV1FiatExchangeRatesHandler(data?: GetV1FiatExchangeRatesQueryResponse | (( +export function getV1FiatExchangeRatesHandler( + data?: + | GetV1FiatExchangeRatesQueryResponse + | (( info: Parameters[1]>[0], - ) => Response | Promise)): HttpHandler { - return http.get('https://price.api.cx.metamask.io/v1/exchange-rates/fiat', function handler(info) { - if(typeof data === 'function') return data(info) + ) => Response | Promise), +): HttpHandler { + return http.get( + 'https://price.api.cx.metamask.io/v1/exchange-rates/fiat', + function handler(info) { + if (typeof data === 'function') return data(info); - return new Response(JSON.stringify(data || createGetV1FiatExchangeRatesQueryResponse(data)), { - status: 200, + return new Response( + JSON.stringify(data || createGetV1FiatExchangeRatesQueryResponse(data)), + { + status: 200, headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + }, }, - }) - }) -} \ No newline at end of file + ); + }, + ); +} diff --git a/packages/core-backend/src/generated/price-api/msw/getV1HistoricalPricesHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV1HistoricalPricesHandler.ts index e959cb6d26..9286fc9755 100644 --- a/packages/core-backend/src/generated/price-api/msw/getV1HistoricalPricesHandler.ts +++ b/packages/core-backend/src/generated/price-api/msw/getV1HistoricalPricesHandler.ts @@ -1,34 +1,46 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { GetV1HistoricalPricesQueryResponse } from "../types/GetV1HistoricalPrices"; -import { createGetV1HistoricalPricesQueryResponse } from "../mocks/createGetV1HistoricalPrices"; -import { http } from "msw"; -import type { HttpHandler } from "msw"; +import { http } from 'msw'; +import type { HttpHandler } from 'msw'; -export function getV1HistoricalPricesHandlerResponse200(data: GetV1HistoricalPricesQueryResponse) { +import { createGetV1HistoricalPricesQueryResponse } from '../mocks/createGetV1HistoricalPrices'; +import type { GetV1HistoricalPricesQueryResponse } from '../types/GetV1HistoricalPrices'; - return new Response(JSON.stringify(data), { - status: 200, - headers: { - 'Content-Type': 'application/json' - }, - }) +export function getV1HistoricalPricesHandlerResponse200( + data: GetV1HistoricalPricesQueryResponse, +) { + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); } -export function getV1HistoricalPricesHandler(data?: GetV1HistoricalPricesQueryResponse | (( +export function getV1HistoricalPricesHandler( + data?: + | GetV1HistoricalPricesQueryResponse + | (( info: Parameters[1]>[0], - ) => Response | Promise)): HttpHandler { - return http.get('https://price.api.cx.metamask.io/v1/chains/:chainId/historical-prices/:tokenAddress', function handler(info) { - if(typeof data === 'function') return data(info) + ) => Response | Promise), +): HttpHandler { + return http.get( + 'https://price.api.cx.metamask.io/v1/chains/:chainId/historical-prices/:tokenAddress', + function handler(info) { + if (typeof data === 'function') return data(info); - return new Response(JSON.stringify(data || createGetV1HistoricalPricesQueryResponse(data)), { - status: 200, + return new Response( + JSON.stringify(data || createGetV1HistoricalPricesQueryResponse(data)), + { + status: 200, headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + }, }, - }) - }) -} \ No newline at end of file + ); + }, + ); +} diff --git a/packages/core-backend/src/generated/price-api/msw/getV1SpotPriceByCoinIdHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV1SpotPriceByCoinIdHandler.ts index a668824486..d186b6c273 100644 --- a/packages/core-backend/src/generated/price-api/msw/getV1SpotPriceByCoinIdHandler.ts +++ b/packages/core-backend/src/generated/price-api/msw/getV1SpotPriceByCoinIdHandler.ts @@ -1,34 +1,46 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { GetV1SpotPriceByCoinIdQueryResponse } from "../types/GetV1SpotPriceByCoinId"; -import { createGetV1SpotPriceByCoinIdQueryResponse } from "../mocks/createGetV1SpotPriceByCoinId"; -import { http } from "msw"; -import type { HttpHandler } from "msw"; +import { http } from 'msw'; +import type { HttpHandler } from 'msw'; -export function getV1SpotPriceByCoinIdHandlerResponse200(data: GetV1SpotPriceByCoinIdQueryResponse) { +import { createGetV1SpotPriceByCoinIdQueryResponse } from '../mocks/createGetV1SpotPriceByCoinId'; +import type { GetV1SpotPriceByCoinIdQueryResponse } from '../types/GetV1SpotPriceByCoinId'; - return new Response(JSON.stringify(data), { - status: 200, - headers: { - 'Content-Type': 'application/json' - }, - }) +export function getV1SpotPriceByCoinIdHandlerResponse200( + data: GetV1SpotPriceByCoinIdQueryResponse, +) { + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); } -export function getV1SpotPriceByCoinIdHandler(data?: GetV1SpotPriceByCoinIdQueryResponse | (( +export function getV1SpotPriceByCoinIdHandler( + data?: + | GetV1SpotPriceByCoinIdQueryResponse + | (( info: Parameters[1]>[0], - ) => Response | Promise)): HttpHandler { - return http.get('https://price.api.cx.metamask.io/v1/spot-prices/:coinId', function handler(info) { - if(typeof data === 'function') return data(info) + ) => Response | Promise), +): HttpHandler { + return http.get( + 'https://price.api.cx.metamask.io/v1/spot-prices/:coinId', + function handler(info) { + if (typeof data === 'function') return data(info); - return new Response(JSON.stringify(data || createGetV1SpotPriceByCoinIdQueryResponse(data)), { - status: 200, + return new Response( + JSON.stringify(data || createGetV1SpotPriceByCoinIdQueryResponse(data)), + { + status: 200, headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + }, }, - }) - }) -} \ No newline at end of file + ); + }, + ); +} diff --git a/packages/core-backend/src/generated/price-api/msw/getV1SpotPricesByCoinIdsHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV1SpotPricesByCoinIdsHandler.ts index 753e5cda93..baa1d44540 100644 --- a/packages/core-backend/src/generated/price-api/msw/getV1SpotPricesByCoinIdsHandler.ts +++ b/packages/core-backend/src/generated/price-api/msw/getV1SpotPricesByCoinIdsHandler.ts @@ -1,34 +1,48 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { GetV1SpotPricesByCoinIdsQueryResponse } from "../types/GetV1SpotPricesByCoinIds"; -import { createGetV1SpotPricesByCoinIdsQueryResponse } from "../mocks/createGetV1SpotPricesByCoinIds"; -import { http } from "msw"; -import type { HttpHandler } from "msw"; +import { http } from 'msw'; +import type { HttpHandler } from 'msw'; -export function getV1SpotPricesByCoinIdsHandlerResponse200(data: GetV1SpotPricesByCoinIdsQueryResponse) { +import { createGetV1SpotPricesByCoinIdsQueryResponse } from '../mocks/createGetV1SpotPricesByCoinIds'; +import type { GetV1SpotPricesByCoinIdsQueryResponse } from '../types/GetV1SpotPricesByCoinIds'; - return new Response(JSON.stringify(data), { - status: 200, - headers: { - 'Content-Type': 'application/json' - }, - }) +export function getV1SpotPricesByCoinIdsHandlerResponse200( + data: GetV1SpotPricesByCoinIdsQueryResponse, +) { + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); } -export function getV1SpotPricesByCoinIdsHandler(data?: GetV1SpotPricesByCoinIdsQueryResponse | (( +export function getV1SpotPricesByCoinIdsHandler( + data?: + | GetV1SpotPricesByCoinIdsQueryResponse + | (( info: Parameters[1]>[0], - ) => Response | Promise)): HttpHandler { - return http.get('https://price.api.cx.metamask.io/v1/spot-prices', function handler(info) { - if(typeof data === 'function') return data(info) + ) => Response | Promise), +): HttpHandler { + return http.get( + 'https://price.api.cx.metamask.io/v1/spot-prices', + function handler(info) { + if (typeof data === 'function') return data(info); - return new Response(JSON.stringify(data || createGetV1SpotPricesByCoinIdsQueryResponse(data)), { - status: 200, + return new Response( + JSON.stringify( + data || createGetV1SpotPricesByCoinIdsQueryResponse(data), + ), + { + status: 200, headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + }, }, - }) - }) -} \ No newline at end of file + ); + }, + ); +} diff --git a/packages/core-backend/src/generated/price-api/msw/getV1SupportedNetworksHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV1SupportedNetworksHandler.ts index d40da5483d..90d40a06a1 100644 --- a/packages/core-backend/src/generated/price-api/msw/getV1SupportedNetworksHandler.ts +++ b/packages/core-backend/src/generated/price-api/msw/getV1SupportedNetworksHandler.ts @@ -1,34 +1,46 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { GetV1SupportedNetworksQueryResponse } from "../types/GetV1SupportedNetworks"; -import { createGetV1SupportedNetworksQueryResponse } from "../mocks/createGetV1SupportedNetworks"; -import { http } from "msw"; -import type { HttpHandler } from "msw"; +import { http } from 'msw'; +import type { HttpHandler } from 'msw'; -export function getV1SupportedNetworksHandlerResponse200(data: GetV1SupportedNetworksQueryResponse) { +import { createGetV1SupportedNetworksQueryResponse } from '../mocks/createGetV1SupportedNetworks'; +import type { GetV1SupportedNetworksQueryResponse } from '../types/GetV1SupportedNetworks'; - return new Response(JSON.stringify(data), { - status: 200, - headers: { - 'Content-Type': 'application/json' - }, - }) +export function getV1SupportedNetworksHandlerResponse200( + data: GetV1SupportedNetworksQueryResponse, +) { + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); } -export function getV1SupportedNetworksHandler(data?: GetV1SupportedNetworksQueryResponse | (( +export function getV1SupportedNetworksHandler( + data?: + | GetV1SupportedNetworksQueryResponse + | (( info: Parameters[1]>[0], - ) => Response | Promise)): HttpHandler { - return http.get('https://price.api.cx.metamask.io/v1/supportedNetworks', function handler(info) { - if(typeof data === 'function') return data(info) + ) => Response | Promise), +): HttpHandler { + return http.get( + 'https://price.api.cx.metamask.io/v1/supportedNetworks', + function handler(info) { + if (typeof data === 'function') return data(info); - return new Response(JSON.stringify(data || createGetV1SupportedNetworksQueryResponse(data)), { - status: 200, + return new Response( + JSON.stringify(data || createGetV1SupportedNetworksQueryResponse(data)), + { + status: 200, headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + }, }, - }) - }) -} \ No newline at end of file + ); + }, + ); +} diff --git a/packages/core-backend/src/generated/price-api/msw/getV2SpotPricesHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV2SpotPricesHandler.ts index 50fd35ecab..744a155dbf 100644 --- a/packages/core-backend/src/generated/price-api/msw/getV2SpotPricesHandler.ts +++ b/packages/core-backend/src/generated/price-api/msw/getV2SpotPricesHandler.ts @@ -1,34 +1,46 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { GetV2SpotPricesQueryResponse } from "../types/GetV2SpotPrices"; -import { createGetV2SpotPricesQueryResponse } from "../mocks/createGetV2SpotPrices"; -import { http } from "msw"; -import type { HttpHandler } from "msw"; +import { http } from 'msw'; +import type { HttpHandler } from 'msw'; -export function getV2SpotPricesHandlerResponse200(data: GetV2SpotPricesQueryResponse) { +import { createGetV2SpotPricesQueryResponse } from '../mocks/createGetV2SpotPrices'; +import type { GetV2SpotPricesQueryResponse } from '../types/GetV2SpotPrices'; - return new Response(JSON.stringify(data), { - status: 200, - headers: { - 'Content-Type': 'application/json' - }, - }) +export function getV2SpotPricesHandlerResponse200( + data: GetV2SpotPricesQueryResponse, +) { + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); } -export function getV2SpotPricesHandler(data?: GetV2SpotPricesQueryResponse | (( +export function getV2SpotPricesHandler( + data?: + | GetV2SpotPricesQueryResponse + | (( info: Parameters[1]>[0], - ) => Response | Promise)): HttpHandler { - return http.get('https://price.api.cx.metamask.io/v2/chains/:chainId/spot-prices', function handler(info) { - if(typeof data === 'function') return data(info) + ) => Response | Promise), +): HttpHandler { + return http.get( + 'https://price.api.cx.metamask.io/v2/chains/:chainId/spot-prices', + function handler(info) { + if (typeof data === 'function') return data(info); - return new Response(JSON.stringify(data || createGetV2SpotPricesQueryResponse(data)), { - status: 200, + return new Response( + JSON.stringify(data || createGetV2SpotPricesQueryResponse(data)), + { + status: 200, headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + }, }, - }) - }) -} \ No newline at end of file + ); + }, + ); +} diff --git a/packages/core-backend/src/generated/price-api/msw/getV2SupportedNetworksHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV2SupportedNetworksHandler.ts index 5280750dfa..8b0961fb2e 100644 --- a/packages/core-backend/src/generated/price-api/msw/getV2SupportedNetworksHandler.ts +++ b/packages/core-backend/src/generated/price-api/msw/getV2SupportedNetworksHandler.ts @@ -1,34 +1,46 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { GetV2SupportedNetworksQueryResponse } from "../types/GetV2SupportedNetworks"; -import { createGetV2SupportedNetworksQueryResponse } from "../mocks/createGetV2SupportedNetworks"; -import { http } from "msw"; -import type { HttpHandler } from "msw"; +import { http } from 'msw'; +import type { HttpHandler } from 'msw'; -export function getV2SupportedNetworksHandlerResponse200(data: GetV2SupportedNetworksQueryResponse) { +import { createGetV2SupportedNetworksQueryResponse } from '../mocks/createGetV2SupportedNetworks'; +import type { GetV2SupportedNetworksQueryResponse } from '../types/GetV2SupportedNetworks'; - return new Response(JSON.stringify(data), { - status: 200, - headers: { - 'Content-Type': 'application/json' - }, - }) +export function getV2SupportedNetworksHandlerResponse200( + data: GetV2SupportedNetworksQueryResponse, +) { + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); } -export function getV2SupportedNetworksHandler(data?: GetV2SupportedNetworksQueryResponse | (( +export function getV2SupportedNetworksHandler( + data?: + | GetV2SupportedNetworksQueryResponse + | (( info: Parameters[1]>[0], - ) => Response | Promise)): HttpHandler { - return http.get('https://price.api.cx.metamask.io/v2/supportedNetworks', function handler(info) { - if(typeof data === 'function') return data(info) + ) => Response | Promise), +): HttpHandler { + return http.get( + 'https://price.api.cx.metamask.io/v2/supportedNetworks', + function handler(info) { + if (typeof data === 'function') return data(info); - return new Response(JSON.stringify(data || createGetV2SupportedNetworksQueryResponse(data)), { - status: 200, + return new Response( + JSON.stringify(data || createGetV2SupportedNetworksQueryResponse(data)), + { + status: 200, headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + }, }, - }) - }) -} \ No newline at end of file + ); + }, + ); +} diff --git a/packages/core-backend/src/generated/price-api/msw/getV2TopTokensHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV2TopTokensHandler.ts index 67c173b9d5..e6ce878ba5 100644 --- a/packages/core-backend/src/generated/price-api/msw/getV2TopTokensHandler.ts +++ b/packages/core-backend/src/generated/price-api/msw/getV2TopTokensHandler.ts @@ -1,34 +1,46 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { GetV2TopTokensQueryResponse } from "../types/GetV2TopTokens"; -import { createGetV2TopTokensQueryResponse } from "../mocks/createGetV2TopTokens"; -import { http } from "msw"; -import type { HttpHandler } from "msw"; +import { http } from 'msw'; +import type { HttpHandler } from 'msw'; -export function getV2TopTokensHandlerResponse200(data: GetV2TopTokensQueryResponse) { +import { createGetV2TopTokensQueryResponse } from '../mocks/createGetV2TopTokens'; +import type { GetV2TopTokensQueryResponse } from '../types/GetV2TopTokens'; - return new Response(JSON.stringify(data), { - status: 200, - headers: { - 'Content-Type': 'application/json' - }, - }) +export function getV2TopTokensHandlerResponse200( + data: GetV2TopTokensQueryResponse, +) { + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); } -export function getV2TopTokensHandler(data?: GetV2TopTokensQueryResponse | (( +export function getV2TopTokensHandler( + data?: + | GetV2TopTokensQueryResponse + | (( info: Parameters[1]>[0], - ) => Response | Promise)): HttpHandler { - return http.get('https://price.api.cx.metamask.io/v2/chains/:chainId/top-tokens', function handler(info) { - if(typeof data === 'function') return data(info) + ) => Response | Promise), +): HttpHandler { + return http.get( + 'https://price.api.cx.metamask.io/v2/chains/:chainId/top-tokens', + function handler(info) { + if (typeof data === 'function') return data(info); - return new Response(JSON.stringify(data || createGetV2TopTokensQueryResponse(data)), { - status: 200, + return new Response( + JSON.stringify(data || createGetV2TopTokensQueryResponse(data)), + { + status: 200, headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + }, }, - }) - }) -} \ No newline at end of file + ); + }, + ); +} diff --git a/packages/core-backend/src/generated/price-api/msw/getV3HistoricalPricesHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV3HistoricalPricesHandler.ts index d9bcb8045c..23019a0079 100644 --- a/packages/core-backend/src/generated/price-api/msw/getV3HistoricalPricesHandler.ts +++ b/packages/core-backend/src/generated/price-api/msw/getV3HistoricalPricesHandler.ts @@ -1,34 +1,46 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { GetV3HistoricalPricesQueryResponse } from "../types/GetV3HistoricalPrices"; -import { createGetV3HistoricalPricesQueryResponse } from "../mocks/createGetV3HistoricalPrices"; -import { http } from "msw"; -import type { HttpHandler } from "msw"; +import { http } from 'msw'; +import type { HttpHandler } from 'msw'; -export function getV3HistoricalPricesHandlerResponse200(data: GetV3HistoricalPricesQueryResponse) { +import { createGetV3HistoricalPricesQueryResponse } from '../mocks/createGetV3HistoricalPrices'; +import type { GetV3HistoricalPricesQueryResponse } from '../types/GetV3HistoricalPrices'; - return new Response(JSON.stringify(data), { - status: 200, - headers: { - 'Content-Type': 'application/json' - }, - }) +export function getV3HistoricalPricesHandlerResponse200( + data: GetV3HistoricalPricesQueryResponse, +) { + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); } -export function getV3HistoricalPricesHandler(data?: GetV3HistoricalPricesQueryResponse | (( +export function getV3HistoricalPricesHandler( + data?: + | GetV3HistoricalPricesQueryResponse + | (( info: Parameters[1]>[0], - ) => Response | Promise)): HttpHandler { - return http.get('https://price.api.cx.metamask.io/v3/historical-prices/:chainId/:assetType', function handler(info) { - if(typeof data === 'function') return data(info) + ) => Response | Promise), +): HttpHandler { + return http.get( + 'https://price.api.cx.metamask.io/v3/historical-prices/:chainId/:assetType', + function handler(info) { + if (typeof data === 'function') return data(info); - return new Response(JSON.stringify(data || createGetV3HistoricalPricesQueryResponse(data)), { - status: 200, + return new Response( + JSON.stringify(data || createGetV3HistoricalPricesQueryResponse(data)), + { + status: 200, headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + }, }, - }) - }) -} \ No newline at end of file + ); + }, + ); +} diff --git a/packages/core-backend/src/generated/price-api/msw/getV3SpotPricesHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV3SpotPricesHandler.ts index 18d1e80dd2..8fd213b134 100644 --- a/packages/core-backend/src/generated/price-api/msw/getV3SpotPricesHandler.ts +++ b/packages/core-backend/src/generated/price-api/msw/getV3SpotPricesHandler.ts @@ -1,34 +1,46 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { GetV3SpotPricesQueryResponse } from "../types/GetV3SpotPrices"; -import { createGetV3SpotPricesQueryResponse } from "../mocks/createGetV3SpotPrices"; -import { http } from "msw"; -import type { HttpHandler } from "msw"; +import { http } from 'msw'; +import type { HttpHandler } from 'msw'; -export function getV3SpotPricesHandlerResponse200(data: GetV3SpotPricesQueryResponse) { +import { createGetV3SpotPricesQueryResponse } from '../mocks/createGetV3SpotPrices'; +import type { GetV3SpotPricesQueryResponse } from '../types/GetV3SpotPrices'; - return new Response(JSON.stringify(data), { - status: 200, - headers: { - 'Content-Type': 'application/json' - }, - }) +export function getV3SpotPricesHandlerResponse200( + data: GetV3SpotPricesQueryResponse, +) { + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); } -export function getV3SpotPricesHandler(data?: GetV3SpotPricesQueryResponse | (( +export function getV3SpotPricesHandler( + data?: + | GetV3SpotPricesQueryResponse + | (( info: Parameters[1]>[0], - ) => Response | Promise)): HttpHandler { - return http.get('https://price.api.cx.metamask.io/v3/spot-prices', function handler(info) { - if(typeof data === 'function') return data(info) + ) => Response | Promise), +): HttpHandler { + return http.get( + 'https://price.api.cx.metamask.io/v3/spot-prices', + function handler(info) { + if (typeof data === 'function') return data(info); - return new Response(JSON.stringify(data || createGetV3SpotPricesQueryResponse(data)), { - status: 200, + return new Response( + JSON.stringify(data || createGetV3SpotPricesQueryResponse(data)), + { + status: 200, headers: { - 'Content-Type': 'application/json' + 'Content-Type': 'application/json', + }, }, - }) - }) -} \ No newline at end of file + ); + }, + ); +} diff --git a/packages/core-backend/src/generated/price-api/msw/handlers.ts b/packages/core-backend/src/generated/price-api/msw/handlers.ts index fb41a7cb55..6ae40e8a93 100644 --- a/packages/core-backend/src/generated/price-api/msw/handlers.ts +++ b/packages/core-backend/src/generated/price-api/msw/handlers.ts @@ -1,19 +1,32 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import { getV1ExchangeRatesHandler } from "./getV1ExchangeRatesHandler"; -import { getV1FiatExchangeRatesHandler } from "./getV1FiatExchangeRatesHandler"; -import { getV1HistoricalPricesHandler } from "./getV1HistoricalPricesHandler"; -import { getV1SpotPriceByCoinIdHandler } from "./getV1SpotPriceByCoinIdHandler"; -import { getV1SpotPricesByCoinIdsHandler } from "./getV1SpotPricesByCoinIdsHandler"; -import { getV1SupportedNetworksHandler } from "./getV1SupportedNetworksHandler"; -import { getV2SpotPricesHandler } from "./getV2SpotPricesHandler"; -import { getV2SupportedNetworksHandler } from "./getV2SupportedNetworksHandler"; -import { getV2TopTokensHandler } from "./getV2TopTokensHandler"; -import { getV3HistoricalPricesHandler } from "./getV3HistoricalPricesHandler"; -import { getV3SpotPricesHandler } from "./getV3SpotPricesHandler"; -import type { HttpHandler } from "msw"; +import type { HttpHandler } from 'msw'; -export const handlers: HttpHandler[] = [getV1SupportedNetworksHandler(),getV2SupportedNetworksHandler(),getV1ExchangeRatesHandler(),getV1FiatExchangeRatesHandler(),getV1SpotPricesByCoinIdsHandler(),getV1SpotPriceByCoinIdHandler(),getV2SpotPricesHandler(),getV3SpotPricesHandler(),getV1HistoricalPricesHandler(),getV3HistoricalPricesHandler(),getV2TopTokensHandler()] \ No newline at end of file +import { getV1ExchangeRatesHandler } from './getV1ExchangeRatesHandler'; +import { getV1FiatExchangeRatesHandler } from './getV1FiatExchangeRatesHandler'; +import { getV1HistoricalPricesHandler } from './getV1HistoricalPricesHandler'; +import { getV1SpotPriceByCoinIdHandler } from './getV1SpotPriceByCoinIdHandler'; +import { getV1SpotPricesByCoinIdsHandler } from './getV1SpotPricesByCoinIdsHandler'; +import { getV1SupportedNetworksHandler } from './getV1SupportedNetworksHandler'; +import { getV2SpotPricesHandler } from './getV2SpotPricesHandler'; +import { getV2SupportedNetworksHandler } from './getV2SupportedNetworksHandler'; +import { getV2TopTokensHandler } from './getV2TopTokensHandler'; +import { getV3HistoricalPricesHandler } from './getV3HistoricalPricesHandler'; +import { getV3SpotPricesHandler } from './getV3SpotPricesHandler'; + +export const handlers: HttpHandler[] = [ + getV1SupportedNetworksHandler(), + getV2SupportedNetworksHandler(), + getV1ExchangeRatesHandler(), + getV1FiatExchangeRatesHandler(), + getV1SpotPricesByCoinIdsHandler(), + getV1SpotPriceByCoinIdHandler(), + getV2SpotPricesHandler(), + getV3SpotPricesHandler(), + getV1HistoricalPricesHandler(), + getV3HistoricalPricesHandler(), + getV2TopTokensHandler(), +]; diff --git a/packages/core-backend/src/generated/price-api/msw/index.ts b/packages/core-backend/src/generated/price-api/msw/index.ts index 08d31fe459..7067c3d4e1 100644 --- a/packages/core-backend/src/generated/price-api/msw/index.ts +++ b/packages/core-backend/src/generated/price-api/msw/index.ts @@ -1,12 +1,45 @@ -export { getV1ExchangeRatesHandler, getV1ExchangeRatesHandlerResponse200 } from "./getV1ExchangeRatesHandler"; -export { getV1FiatExchangeRatesHandler, getV1FiatExchangeRatesHandlerResponse200 } from "./getV1FiatExchangeRatesHandler"; -export { getV1HistoricalPricesHandler, getV1HistoricalPricesHandlerResponse200 } from "./getV1HistoricalPricesHandler"; -export { getV1SpotPriceByCoinIdHandler, getV1SpotPriceByCoinIdHandlerResponse200 } from "./getV1SpotPriceByCoinIdHandler"; -export { getV1SpotPricesByCoinIdsHandler, getV1SpotPricesByCoinIdsHandlerResponse200 } from "./getV1SpotPricesByCoinIdsHandler"; -export { getV1SupportedNetworksHandler, getV1SupportedNetworksHandlerResponse200 } from "./getV1SupportedNetworksHandler"; -export { getV2SpotPricesHandler, getV2SpotPricesHandlerResponse200 } from "./getV2SpotPricesHandler"; -export { getV2SupportedNetworksHandler, getV2SupportedNetworksHandlerResponse200 } from "./getV2SupportedNetworksHandler"; -export { getV2TopTokensHandler, getV2TopTokensHandlerResponse200 } from "./getV2TopTokensHandler"; -export { getV3HistoricalPricesHandler, getV3HistoricalPricesHandlerResponse200 } from "./getV3HistoricalPricesHandler"; -export { getV3SpotPricesHandler, getV3SpotPricesHandlerResponse200 } from "./getV3SpotPricesHandler"; -export { handlers } from "./handlers"; \ No newline at end of file +export { + getV1ExchangeRatesHandler, + getV1ExchangeRatesHandlerResponse200, +} from './getV1ExchangeRatesHandler'; +export { + getV1FiatExchangeRatesHandler, + getV1FiatExchangeRatesHandlerResponse200, +} from './getV1FiatExchangeRatesHandler'; +export { + getV1HistoricalPricesHandler, + getV1HistoricalPricesHandlerResponse200, +} from './getV1HistoricalPricesHandler'; +export { + getV1SpotPriceByCoinIdHandler, + getV1SpotPriceByCoinIdHandlerResponse200, +} from './getV1SpotPriceByCoinIdHandler'; +export { + getV1SpotPricesByCoinIdsHandler, + getV1SpotPricesByCoinIdsHandlerResponse200, +} from './getV1SpotPricesByCoinIdsHandler'; +export { + getV1SupportedNetworksHandler, + getV1SupportedNetworksHandlerResponse200, +} from './getV1SupportedNetworksHandler'; +export { + getV2SpotPricesHandler, + getV2SpotPricesHandlerResponse200, +} from './getV2SpotPricesHandler'; +export { + getV2SupportedNetworksHandler, + getV2SupportedNetworksHandlerResponse200, +} from './getV2SupportedNetworksHandler'; +export { + getV2TopTokensHandler, + getV2TopTokensHandlerResponse200, +} from './getV2TopTokensHandler'; +export { + getV3HistoricalPricesHandler, + getV3HistoricalPricesHandlerResponse200, +} from './getV3HistoricalPricesHandler'; +export { + getV3SpotPricesHandler, + getV3SpotPricesHandlerResponse200, +} from './getV3SpotPricesHandler'; +export { handlers } from './handlers'; diff --git a/packages/core-backend/src/generated/price-api/queries/getV1ExchangeRates.ts b/packages/core-backend/src/generated/price-api/queries/getV1ExchangeRates.ts index 81bb94ea6e..5d4a246e19 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV1ExchangeRates.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV1ExchangeRates.ts @@ -1,20 +1,31 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { assert } from '@metamask/superstruct'; +import type { + FetchQueryOptions, + QueryFunctionContext, +} from '@tanstack/query-core'; -import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; -import type { GetV1ExchangeRatesQueryResponse, GetV1ExchangeRatesQueryParams } from "../types/GetV1ExchangeRates"; -import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; -import { getQueryOptionsOverrides } from "../../../api/query-runtime"; -import { GetV1ExchangeRatesQueryResponseStruct } from "../schemas/getV1ExchangeRatesStruct"; -import { assert } from "@metamask/superstruct"; +import type { + ApiRequestClient, + FetchOptions, +} from '../../../api/query-runtime'; +import { getQueryOptionsOverrides } from '../../../api/query-runtime'; +import { GetV1ExchangeRatesQueryResponseStruct } from '../schemas/getV1ExchangeRatesStruct'; +import type { + GetV1ExchangeRatesQueryResponse, + GetV1ExchangeRatesQueryParams, +} from '../types/GetV1ExchangeRates'; /** * Query key for `GET /v1/exchange-rates`. */ -export const getV1ExchangeRatesQueryKey = (params: GetV1ExchangeRatesQueryParams) => - ["prices", "getV1ExchangeRates", params] as const; +export const getV1ExchangeRatesQueryKey = ( + params: GetV1ExchangeRatesQueryParams, +) => ['prices', 'getV1ExchangeRates', params] as const; /** * Get exchange rates @@ -24,7 +35,8 @@ export const getV1ExchangeRatesQueryKey = (params: GetV1ExchangeRatesQueryParams * validated against {@link GetV1ExchangeRatesQueryResponseStruct} before it is returned. */ export function getV1ExchangeRatesQueryOptions( - client: ApiRequestClient, params: GetV1ExchangeRatesQueryParams, + client: ApiRequestClient, + params: GetV1ExchangeRatesQueryParams, options?: FetchOptions, ): FetchQueryOptions { return { @@ -32,7 +44,7 @@ export function getV1ExchangeRatesQueryOptions( queryFn: async ({ signal }: QueryFunctionContext) => { const data = await client.request({ method: 'get', - url: "/v1/exchange-rates", + url: '/v1/exchange-rates', params, signal, }); @@ -51,10 +63,11 @@ export function getV1ExchangeRatesQueryOptions( * concurrent calls and reusing fresh cached data. */ export async function fetchV1ExchangeRates( - client: ApiRequestClient, params: GetV1ExchangeRatesQueryParams, + client: ApiRequestClient, + params: GetV1ExchangeRatesQueryParams, options?: FetchOptions, ): Promise { return client.queryClient.fetchQuery( getV1ExchangeRatesQueryOptions(client, params, options), ); -} \ No newline at end of file +} diff --git a/packages/core-backend/src/generated/price-api/queries/getV1FiatExchangeRates.ts b/packages/core-backend/src/generated/price-api/queries/getV1FiatExchangeRates.ts index dc0b14c348..36be6e4fc5 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV1FiatExchangeRates.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV1FiatExchangeRates.ts @@ -1,20 +1,27 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { assert } from '@metamask/superstruct'; +import type { + FetchQueryOptions, + QueryFunctionContext, +} from '@tanstack/query-core'; -import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; -import type { GetV1FiatExchangeRatesQueryResponse } from "../types/GetV1FiatExchangeRates"; -import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; -import { getQueryOptionsOverrides } from "../../../api/query-runtime"; -import { GetV1FiatExchangeRatesQueryResponseStruct } from "../schemas/getV1FiatExchangeRatesStruct"; -import { assert } from "@metamask/superstruct"; +import type { + ApiRequestClient, + FetchOptions, +} from '../../../api/query-runtime'; +import { getQueryOptionsOverrides } from '../../../api/query-runtime'; +import { GetV1FiatExchangeRatesQueryResponseStruct } from '../schemas/getV1FiatExchangeRatesStruct'; +import type { GetV1FiatExchangeRatesQueryResponse } from '../types/GetV1FiatExchangeRates'; /** * Query key for `GET /v1/exchange-rates/fiat`. */ export const getV1FiatExchangeRatesQueryKey = () => - ["prices", "getV1FiatExchangeRates"] as const; + ['prices', 'getV1FiatExchangeRates'] as const; /** * Get fiat exchange rates @@ -32,7 +39,7 @@ export function getV1FiatExchangeRatesQueryOptions( queryFn: async ({ signal }: QueryFunctionContext) => { const data = await client.request({ method: 'get', - url: "/v1/exchange-rates/fiat", + url: '/v1/exchange-rates/fiat', signal, }); assert(data, GetV1FiatExchangeRatesQueryResponseStruct); @@ -56,4 +63,4 @@ export async function fetchV1FiatExchangeRates( return client.queryClient.fetchQuery( getV1FiatExchangeRatesQueryOptions(client, options), ); -} \ No newline at end of file +} diff --git a/packages/core-backend/src/generated/price-api/queries/getV1HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/queries/getV1HistoricalPrices.ts index 7c4043343f..64dd35bd33 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV1HistoricalPrices.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV1HistoricalPrices.ts @@ -1,20 +1,39 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { assert } from '@metamask/superstruct'; +import type { + FetchQueryOptions, + QueryFunctionContext, +} from '@tanstack/query-core'; -import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; -import type { GetV1HistoricalPricesQueryResponse, GetV1HistoricalPricesPathParams, GetV1HistoricalPricesQueryParams } from "../types/GetV1HistoricalPrices"; -import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; -import { getQueryOptionsOverrides } from "../../../api/query-runtime"; -import { GetV1HistoricalPricesQueryResponseStruct } from "../schemas/getV1HistoricalPricesStruct"; -import { assert } from "@metamask/superstruct"; +import type { + ApiRequestClient, + FetchOptions, +} from '../../../api/query-runtime'; +import { getQueryOptionsOverrides } from '../../../api/query-runtime'; +import { GetV1HistoricalPricesQueryResponseStruct } from '../schemas/getV1HistoricalPricesStruct'; +import type { + GetV1HistoricalPricesQueryResponse, + GetV1HistoricalPricesPathParams, + GetV1HistoricalPricesQueryParams, +} from '../types/GetV1HistoricalPrices'; /** * Query key for `GET /v1/chains/{chainId}/historical-prices/{tokenAddress}`. */ -export const getV1HistoricalPricesQueryKey = (pathParams: GetV1HistoricalPricesPathParams, params?: GetV1HistoricalPricesQueryParams) => - ["prices", "getV1HistoricalPrices", pathParams, ...(params ? [params] : [])] as const; +export const getV1HistoricalPricesQueryKey = ( + pathParams: GetV1HistoricalPricesPathParams, + params?: GetV1HistoricalPricesQueryParams, +) => + [ + 'prices', + 'getV1HistoricalPrices', + pathParams, + ...(params ? [params] : []), + ] as const; /** * Get historical prices by token address @@ -24,7 +43,9 @@ export const getV1HistoricalPricesQueryKey = (pathParams: GetV1HistoricalPricesP * validated against {@link GetV1HistoricalPricesQueryResponseStruct} before it is returned. */ export function getV1HistoricalPricesQueryOptions( - client: ApiRequestClient, pathParams: GetV1HistoricalPricesPathParams, params?: GetV1HistoricalPricesQueryParams, + client: ApiRequestClient, + pathParams: GetV1HistoricalPricesPathParams, + params?: GetV1HistoricalPricesQueryParams, options?: FetchOptions, ): FetchQueryOptions { return { @@ -51,10 +72,12 @@ export function getV1HistoricalPricesQueryOptions( * concurrent calls and reusing fresh cached data. */ export async function fetchV1HistoricalPrices( - client: ApiRequestClient, pathParams: GetV1HistoricalPricesPathParams, params?: GetV1HistoricalPricesQueryParams, + client: ApiRequestClient, + pathParams: GetV1HistoricalPricesPathParams, + params?: GetV1HistoricalPricesQueryParams, options?: FetchOptions, ): Promise { return client.queryClient.fetchQuery( getV1HistoricalPricesQueryOptions(client, pathParams, params, options), ); -} \ No newline at end of file +} diff --git a/packages/core-backend/src/generated/price-api/queries/getV1SpotPriceByCoinId.ts b/packages/core-backend/src/generated/price-api/queries/getV1SpotPriceByCoinId.ts index 613b034284..92917adad5 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV1SpotPriceByCoinId.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV1SpotPriceByCoinId.ts @@ -1,20 +1,39 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { assert } from '@metamask/superstruct'; +import type { + FetchQueryOptions, + QueryFunctionContext, +} from '@tanstack/query-core'; -import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; -import type { GetV1SpotPriceByCoinIdQueryResponse, GetV1SpotPriceByCoinIdPathParams, GetV1SpotPriceByCoinIdQueryParams } from "../types/GetV1SpotPriceByCoinId"; -import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; -import { getQueryOptionsOverrides } from "../../../api/query-runtime"; -import { GetV1SpotPriceByCoinIdQueryResponseStruct } from "../schemas/getV1SpotPriceByCoinIdStruct"; -import { assert } from "@metamask/superstruct"; +import type { + ApiRequestClient, + FetchOptions, +} from '../../../api/query-runtime'; +import { getQueryOptionsOverrides } from '../../../api/query-runtime'; +import { GetV1SpotPriceByCoinIdQueryResponseStruct } from '../schemas/getV1SpotPriceByCoinIdStruct'; +import type { + GetV1SpotPriceByCoinIdQueryResponse, + GetV1SpotPriceByCoinIdPathParams, + GetV1SpotPriceByCoinIdQueryParams, +} from '../types/GetV1SpotPriceByCoinId'; /** * Query key for `GET /v1/spot-prices/{coinId}`. */ -export const getV1SpotPriceByCoinIdQueryKey = (pathParams: GetV1SpotPriceByCoinIdPathParams, params?: GetV1SpotPriceByCoinIdQueryParams) => - ["prices", "getV1SpotPriceByCoinId", pathParams, ...(params ? [params] : [])] as const; +export const getV1SpotPriceByCoinIdQueryKey = ( + pathParams: GetV1SpotPriceByCoinIdPathParams, + params?: GetV1SpotPriceByCoinIdQueryParams, +) => + [ + 'prices', + 'getV1SpotPriceByCoinId', + pathParams, + ...(params ? [params] : []), + ] as const; /** * Get spot price by CoinGecko coin ID @@ -24,7 +43,9 @@ export const getV1SpotPriceByCoinIdQueryKey = (pathParams: GetV1SpotPriceByCoinI * validated against {@link GetV1SpotPriceByCoinIdQueryResponseStruct} before it is returned. */ export function getV1SpotPriceByCoinIdQueryOptions( - client: ApiRequestClient, pathParams: GetV1SpotPriceByCoinIdPathParams, params?: GetV1SpotPriceByCoinIdQueryParams, + client: ApiRequestClient, + pathParams: GetV1SpotPriceByCoinIdPathParams, + params?: GetV1SpotPriceByCoinIdQueryParams, options?: FetchOptions, ): FetchQueryOptions { return { @@ -51,10 +72,12 @@ export function getV1SpotPriceByCoinIdQueryOptions( * concurrent calls and reusing fresh cached data. */ export async function fetchV1SpotPriceByCoinId( - client: ApiRequestClient, pathParams: GetV1SpotPriceByCoinIdPathParams, params?: GetV1SpotPriceByCoinIdQueryParams, + client: ApiRequestClient, + pathParams: GetV1SpotPriceByCoinIdPathParams, + params?: GetV1SpotPriceByCoinIdQueryParams, options?: FetchOptions, ): Promise { return client.queryClient.fetchQuery( getV1SpotPriceByCoinIdQueryOptions(client, pathParams, params, options), ); -} \ No newline at end of file +} diff --git a/packages/core-backend/src/generated/price-api/queries/getV1SpotPricesByCoinIds.ts b/packages/core-backend/src/generated/price-api/queries/getV1SpotPricesByCoinIds.ts index c223ae83b7..02b6acf076 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV1SpotPricesByCoinIds.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV1SpotPricesByCoinIds.ts @@ -1,20 +1,31 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { assert } from '@metamask/superstruct'; +import type { + FetchQueryOptions, + QueryFunctionContext, +} from '@tanstack/query-core'; -import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; -import type { GetV1SpotPricesByCoinIdsQueryResponse, GetV1SpotPricesByCoinIdsQueryParams } from "../types/GetV1SpotPricesByCoinIds"; -import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; -import { getQueryOptionsOverrides } from "../../../api/query-runtime"; -import { GetV1SpotPricesByCoinIdsQueryResponseStruct } from "../schemas/getV1SpotPricesByCoinIdsStruct"; -import { assert } from "@metamask/superstruct"; +import type { + ApiRequestClient, + FetchOptions, +} from '../../../api/query-runtime'; +import { getQueryOptionsOverrides } from '../../../api/query-runtime'; +import { GetV1SpotPricesByCoinIdsQueryResponseStruct } from '../schemas/getV1SpotPricesByCoinIdsStruct'; +import type { + GetV1SpotPricesByCoinIdsQueryResponse, + GetV1SpotPricesByCoinIdsQueryParams, +} from '../types/GetV1SpotPricesByCoinIds'; /** * Query key for `GET /v1/spot-prices`. */ -export const getV1SpotPricesByCoinIdsQueryKey = (params: GetV1SpotPricesByCoinIdsQueryParams) => - ["prices", "getV1SpotPricesByCoinIds", params] as const; +export const getV1SpotPricesByCoinIdsQueryKey = ( + params: GetV1SpotPricesByCoinIdsQueryParams, +) => ['prices', 'getV1SpotPricesByCoinIds', params] as const; /** * Get spot prices by CoinGecko coin IDs @@ -24,7 +35,8 @@ export const getV1SpotPricesByCoinIdsQueryKey = (params: GetV1SpotPricesByCoinId * validated against {@link GetV1SpotPricesByCoinIdsQueryResponseStruct} before it is returned. */ export function getV1SpotPricesByCoinIdsQueryOptions( - client: ApiRequestClient, params: GetV1SpotPricesByCoinIdsQueryParams, + client: ApiRequestClient, + params: GetV1SpotPricesByCoinIdsQueryParams, options?: FetchOptions, ): FetchQueryOptions { return { @@ -32,7 +44,7 @@ export function getV1SpotPricesByCoinIdsQueryOptions( queryFn: async ({ signal }: QueryFunctionContext) => { const data = await client.request({ method: 'get', - url: "/v1/spot-prices", + url: '/v1/spot-prices', params, signal, }); @@ -51,10 +63,11 @@ export function getV1SpotPricesByCoinIdsQueryOptions( * concurrent calls and reusing fresh cached data. */ export async function fetchV1SpotPricesByCoinIds( - client: ApiRequestClient, params: GetV1SpotPricesByCoinIdsQueryParams, + client: ApiRequestClient, + params: GetV1SpotPricesByCoinIdsQueryParams, options?: FetchOptions, ): Promise { return client.queryClient.fetchQuery( getV1SpotPricesByCoinIdsQueryOptions(client, params, options), ); -} \ No newline at end of file +} diff --git a/packages/core-backend/src/generated/price-api/queries/getV1SupportedNetworks.ts b/packages/core-backend/src/generated/price-api/queries/getV1SupportedNetworks.ts index 16c24f9e5c..14a0f57460 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV1SupportedNetworks.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV1SupportedNetworks.ts @@ -1,20 +1,27 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { assert } from '@metamask/superstruct'; +import type { + FetchQueryOptions, + QueryFunctionContext, +} from '@tanstack/query-core'; -import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; -import type { GetV1SupportedNetworksQueryResponse } from "../types/GetV1SupportedNetworks"; -import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; -import { getQueryOptionsOverrides } from "../../../api/query-runtime"; -import { GetV1SupportedNetworksQueryResponseStruct } from "../schemas/getV1SupportedNetworksStruct"; -import { assert } from "@metamask/superstruct"; +import type { + ApiRequestClient, + FetchOptions, +} from '../../../api/query-runtime'; +import { getQueryOptionsOverrides } from '../../../api/query-runtime'; +import { GetV1SupportedNetworksQueryResponseStruct } from '../schemas/getV1SupportedNetworksStruct'; +import type { GetV1SupportedNetworksQueryResponse } from '../types/GetV1SupportedNetworks'; /** * Query key for `GET /v1/supportedNetworks`. */ export const getV1SupportedNetworksQueryKey = () => - ["prices", "getV1SupportedNetworks"] as const; + ['prices', 'getV1SupportedNetworks'] as const; /** * Get supported networks @@ -32,7 +39,7 @@ export function getV1SupportedNetworksQueryOptions( queryFn: async ({ signal }: QueryFunctionContext) => { const data = await client.request({ method: 'get', - url: "/v1/supportedNetworks", + url: '/v1/supportedNetworks', signal, }); assert(data, GetV1SupportedNetworksQueryResponseStruct); @@ -56,4 +63,4 @@ export async function fetchV1SupportedNetworks( return client.queryClient.fetchQuery( getV1SupportedNetworksQueryOptions(client, options), ); -} \ No newline at end of file +} diff --git a/packages/core-backend/src/generated/price-api/queries/getV2SpotPrices.ts b/packages/core-backend/src/generated/price-api/queries/getV2SpotPrices.ts index 640bb7bf5e..0ecc7e05e3 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV2SpotPrices.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV2SpotPrices.ts @@ -1,20 +1,33 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { assert } from '@metamask/superstruct'; +import type { + FetchQueryOptions, + QueryFunctionContext, +} from '@tanstack/query-core'; -import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; -import type { GetV2SpotPricesQueryResponse, GetV2SpotPricesPathParams, GetV2SpotPricesQueryParams } from "../types/GetV2SpotPrices"; -import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; -import { getQueryOptionsOverrides } from "../../../api/query-runtime"; -import { GetV2SpotPricesQueryResponseStruct } from "../schemas/getV2SpotPricesStruct"; -import { assert } from "@metamask/superstruct"; +import type { + ApiRequestClient, + FetchOptions, +} from '../../../api/query-runtime'; +import { getQueryOptionsOverrides } from '../../../api/query-runtime'; +import { GetV2SpotPricesQueryResponseStruct } from '../schemas/getV2SpotPricesStruct'; +import type { + GetV2SpotPricesQueryResponse, + GetV2SpotPricesPathParams, + GetV2SpotPricesQueryParams, +} from '../types/GetV2SpotPrices'; /** * Query key for `GET /v2/chains/{chainId}/spot-prices`. */ -export const getV2SpotPricesQueryKey = (pathParams: GetV2SpotPricesPathParams, params: GetV2SpotPricesQueryParams) => - ["prices", "getV2SpotPrices", pathParams, params] as const; +export const getV2SpotPricesQueryKey = ( + pathParams: GetV2SpotPricesPathParams, + params: GetV2SpotPricesQueryParams, +) => ['prices', 'getV2SpotPrices', pathParams, params] as const; /** * Get spot prices with market data by token addresses @@ -24,7 +37,9 @@ export const getV2SpotPricesQueryKey = (pathParams: GetV2SpotPricesPathParams, p * validated against {@link GetV2SpotPricesQueryResponseStruct} before it is returned. */ export function getV2SpotPricesQueryOptions( - client: ApiRequestClient, pathParams: GetV2SpotPricesPathParams, params: GetV2SpotPricesQueryParams, + client: ApiRequestClient, + pathParams: GetV2SpotPricesPathParams, + params: GetV2SpotPricesQueryParams, options?: FetchOptions, ): FetchQueryOptions { return { @@ -51,10 +66,12 @@ export function getV2SpotPricesQueryOptions( * concurrent calls and reusing fresh cached data. */ export async function fetchV2SpotPrices( - client: ApiRequestClient, pathParams: GetV2SpotPricesPathParams, params: GetV2SpotPricesQueryParams, + client: ApiRequestClient, + pathParams: GetV2SpotPricesPathParams, + params: GetV2SpotPricesQueryParams, options?: FetchOptions, ): Promise { return client.queryClient.fetchQuery( getV2SpotPricesQueryOptions(client, pathParams, params, options), ); -} \ No newline at end of file +} diff --git a/packages/core-backend/src/generated/price-api/queries/getV2SupportedNetworks.ts b/packages/core-backend/src/generated/price-api/queries/getV2SupportedNetworks.ts index bf311825d9..2ab98e7b2d 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV2SupportedNetworks.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV2SupportedNetworks.ts @@ -1,20 +1,27 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { assert } from '@metamask/superstruct'; +import type { + FetchQueryOptions, + QueryFunctionContext, +} from '@tanstack/query-core'; -import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; -import type { GetV2SupportedNetworksQueryResponse } from "../types/GetV2SupportedNetworks"; -import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; -import { getQueryOptionsOverrides } from "../../../api/query-runtime"; -import { GetV2SupportedNetworksQueryResponseStruct } from "../schemas/getV2SupportedNetworksStruct"; -import { assert } from "@metamask/superstruct"; +import type { + ApiRequestClient, + FetchOptions, +} from '../../../api/query-runtime'; +import { getQueryOptionsOverrides } from '../../../api/query-runtime'; +import { GetV2SupportedNetworksQueryResponseStruct } from '../schemas/getV2SupportedNetworksStruct'; +import type { GetV2SupportedNetworksQueryResponse } from '../types/GetV2SupportedNetworks'; /** * Query key for `GET /v2/supportedNetworks`. */ export const getV2SupportedNetworksQueryKey = () => - ["prices", "getV2SupportedNetworks"] as const; + ['prices', 'getV2SupportedNetworks'] as const; /** * Get supported networks (CAIP-2) @@ -32,7 +39,7 @@ export function getV2SupportedNetworksQueryOptions( queryFn: async ({ signal }: QueryFunctionContext) => { const data = await client.request({ method: 'get', - url: "/v2/supportedNetworks", + url: '/v2/supportedNetworks', signal, }); assert(data, GetV2SupportedNetworksQueryResponseStruct); @@ -56,4 +63,4 @@ export async function fetchV2SupportedNetworks( return client.queryClient.fetchQuery( getV2SupportedNetworksQueryOptions(client, options), ); -} \ No newline at end of file +} diff --git a/packages/core-backend/src/generated/price-api/queries/getV2TopTokens.ts b/packages/core-backend/src/generated/price-api/queries/getV2TopTokens.ts index ab83f0a21b..421d6cd93e 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV2TopTokens.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV2TopTokens.ts @@ -1,20 +1,39 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { assert } from '@metamask/superstruct'; +import type { + FetchQueryOptions, + QueryFunctionContext, +} from '@tanstack/query-core'; -import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; -import type { GetV2TopTokensQueryResponse, GetV2TopTokensPathParams, GetV2TopTokensQueryParams } from "../types/GetV2TopTokens"; -import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; -import { getQueryOptionsOverrides } from "../../../api/query-runtime"; -import { GetV2TopTokensQueryResponseStruct } from "../schemas/getV2TopTokensStruct"; -import { assert } from "@metamask/superstruct"; +import type { + ApiRequestClient, + FetchOptions, +} from '../../../api/query-runtime'; +import { getQueryOptionsOverrides } from '../../../api/query-runtime'; +import { GetV2TopTokensQueryResponseStruct } from '../schemas/getV2TopTokensStruct'; +import type { + GetV2TopTokensQueryResponse, + GetV2TopTokensPathParams, + GetV2TopTokensQueryParams, +} from '../types/GetV2TopTokens'; /** * Query key for `GET /v2/chains/{chainId}/top-tokens`. */ -export const getV2TopTokensQueryKey = (pathParams: GetV2TopTokensPathParams, params?: GetV2TopTokensQueryParams) => - ["prices", "getV2TopTokens", pathParams, ...(params ? [params] : [])] as const; +export const getV2TopTokensQueryKey = ( + pathParams: GetV2TopTokensPathParams, + params?: GetV2TopTokensQueryParams, +) => + [ + 'prices', + 'getV2TopTokens', + pathParams, + ...(params ? [params] : []), + ] as const; /** * Get top tokens by market cap @@ -24,7 +43,9 @@ export const getV2TopTokensQueryKey = (pathParams: GetV2TopTokensPathParams, par * validated against {@link GetV2TopTokensQueryResponseStruct} before it is returned. */ export function getV2TopTokensQueryOptions( - client: ApiRequestClient, pathParams: GetV2TopTokensPathParams, params?: GetV2TopTokensQueryParams, + client: ApiRequestClient, + pathParams: GetV2TopTokensPathParams, + params?: GetV2TopTokensQueryParams, options?: FetchOptions, ): FetchQueryOptions { return { @@ -51,10 +72,12 @@ export function getV2TopTokensQueryOptions( * concurrent calls and reusing fresh cached data. */ export async function fetchV2TopTokens( - client: ApiRequestClient, pathParams: GetV2TopTokensPathParams, params?: GetV2TopTokensQueryParams, + client: ApiRequestClient, + pathParams: GetV2TopTokensPathParams, + params?: GetV2TopTokensQueryParams, options?: FetchOptions, ): Promise { return client.queryClient.fetchQuery( getV2TopTokensQueryOptions(client, pathParams, params, options), ); -} \ No newline at end of file +} diff --git a/packages/core-backend/src/generated/price-api/queries/getV3HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/queries/getV3HistoricalPrices.ts index 7b82ab3b1e..89155bc7dd 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV3HistoricalPrices.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV3HistoricalPrices.ts @@ -1,20 +1,39 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { assert } from '@metamask/superstruct'; +import type { + FetchQueryOptions, + QueryFunctionContext, +} from '@tanstack/query-core'; -import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; -import type { GetV3HistoricalPricesQueryResponse, GetV3HistoricalPricesPathParams, GetV3HistoricalPricesQueryParams } from "../types/GetV3HistoricalPrices"; -import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; -import { getQueryOptionsOverrides } from "../../../api/query-runtime"; -import { GetV3HistoricalPricesQueryResponseStruct } from "../schemas/getV3HistoricalPricesStruct"; -import { assert } from "@metamask/superstruct"; +import type { + ApiRequestClient, + FetchOptions, +} from '../../../api/query-runtime'; +import { getQueryOptionsOverrides } from '../../../api/query-runtime'; +import { GetV3HistoricalPricesQueryResponseStruct } from '../schemas/getV3HistoricalPricesStruct'; +import type { + GetV3HistoricalPricesQueryResponse, + GetV3HistoricalPricesPathParams, + GetV3HistoricalPricesQueryParams, +} from '../types/GetV3HistoricalPrices'; /** * Query key for `GET /v3/historical-prices/{chainId}/{assetType}`. */ -export const getV3HistoricalPricesQueryKey = (pathParams: GetV3HistoricalPricesPathParams, params?: GetV3HistoricalPricesQueryParams) => - ["prices", "getV3HistoricalPrices", pathParams, ...(params ? [params] : [])] as const; +export const getV3HistoricalPricesQueryKey = ( + pathParams: GetV3HistoricalPricesPathParams, + params?: GetV3HistoricalPricesQueryParams, +) => + [ + 'prices', + 'getV3HistoricalPrices', + pathParams, + ...(params ? [params] : []), + ] as const; /** * Get historical prices by CAIP-19 asset ID @@ -24,7 +43,9 @@ export const getV3HistoricalPricesQueryKey = (pathParams: GetV3HistoricalPricesP * validated against {@link GetV3HistoricalPricesQueryResponseStruct} before it is returned. */ export function getV3HistoricalPricesQueryOptions( - client: ApiRequestClient, pathParams: GetV3HistoricalPricesPathParams, params?: GetV3HistoricalPricesQueryParams, + client: ApiRequestClient, + pathParams: GetV3HistoricalPricesPathParams, + params?: GetV3HistoricalPricesQueryParams, options?: FetchOptions, ): FetchQueryOptions { return { @@ -51,10 +72,12 @@ export function getV3HistoricalPricesQueryOptions( * concurrent calls and reusing fresh cached data. */ export async function fetchV3HistoricalPrices( - client: ApiRequestClient, pathParams: GetV3HistoricalPricesPathParams, params?: GetV3HistoricalPricesQueryParams, + client: ApiRequestClient, + pathParams: GetV3HistoricalPricesPathParams, + params?: GetV3HistoricalPricesQueryParams, options?: FetchOptions, ): Promise { return client.queryClient.fetchQuery( getV3HistoricalPricesQueryOptions(client, pathParams, params, options), ); -} \ No newline at end of file +} diff --git a/packages/core-backend/src/generated/price-api/queries/getV3SpotPrices.ts b/packages/core-backend/src/generated/price-api/queries/getV3SpotPrices.ts index 78a30a5864..7d48e2416d 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV3SpotPrices.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV3SpotPrices.ts @@ -1,20 +1,30 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { assert } from '@metamask/superstruct'; +import type { + FetchQueryOptions, + QueryFunctionContext, +} from '@tanstack/query-core'; -import type { ApiRequestClient, FetchOptions } from "../../../api/query-runtime"; -import type { GetV3SpotPricesQueryResponse, GetV3SpotPricesQueryParams } from "../types/GetV3SpotPrices"; -import type { FetchQueryOptions, QueryFunctionContext } from "@tanstack/query-core"; -import { getQueryOptionsOverrides } from "../../../api/query-runtime"; -import { GetV3SpotPricesQueryResponseStruct } from "../schemas/getV3SpotPricesStruct"; -import { assert } from "@metamask/superstruct"; +import type { + ApiRequestClient, + FetchOptions, +} from '../../../api/query-runtime'; +import { getQueryOptionsOverrides } from '../../../api/query-runtime'; +import { GetV3SpotPricesQueryResponseStruct } from '../schemas/getV3SpotPricesStruct'; +import type { + GetV3SpotPricesQueryResponse, + GetV3SpotPricesQueryParams, +} from '../types/GetV3SpotPrices'; /** * Query key for `GET /v3/spot-prices`. */ export const getV3SpotPricesQueryKey = (params: GetV3SpotPricesQueryParams) => - ["prices", "getV3SpotPrices", params] as const; + ['prices', 'getV3SpotPrices', params] as const; /** * Get spot prices by CAIP-19 asset IDs @@ -24,7 +34,8 @@ export const getV3SpotPricesQueryKey = (params: GetV3SpotPricesQueryParams) => * validated against {@link GetV3SpotPricesQueryResponseStruct} before it is returned. */ export function getV3SpotPricesQueryOptions( - client: ApiRequestClient, params: GetV3SpotPricesQueryParams, + client: ApiRequestClient, + params: GetV3SpotPricesQueryParams, options?: FetchOptions, ): FetchQueryOptions { return { @@ -32,7 +43,7 @@ export function getV3SpotPricesQueryOptions( queryFn: async ({ signal }: QueryFunctionContext) => { const data = await client.request({ method: 'get', - url: "/v3/spot-prices", + url: '/v3/spot-prices', params, signal, }); @@ -51,10 +62,11 @@ export function getV3SpotPricesQueryOptions( * concurrent calls and reusing fresh cached data. */ export async function fetchV3SpotPrices( - client: ApiRequestClient, params: GetV3SpotPricesQueryParams, + client: ApiRequestClient, + params: GetV3SpotPricesQueryParams, options?: FetchOptions, ): Promise { return client.queryClient.fetchQuery( getV3SpotPricesQueryOptions(client, params, options), ); -} \ No newline at end of file +} diff --git a/packages/core-backend/src/generated/price-api/queries/index.ts b/packages/core-backend/src/generated/price-api/queries/index.ts index 9f02deed4d..7d92f3a723 100644 --- a/packages/core-backend/src/generated/price-api/queries/index.ts +++ b/packages/core-backend/src/generated/price-api/queries/index.ts @@ -1,11 +1,55 @@ -export { fetchV1ExchangeRates, getV1ExchangeRatesQueryKey, getV1ExchangeRatesQueryOptions } from "./getV1ExchangeRates"; -export { fetchV1FiatExchangeRates, getV1FiatExchangeRatesQueryKey, getV1FiatExchangeRatesQueryOptions } from "./getV1FiatExchangeRates"; -export { fetchV1HistoricalPrices, getV1HistoricalPricesQueryKey, getV1HistoricalPricesQueryOptions } from "./getV1HistoricalPrices"; -export { fetchV1SpotPriceByCoinId, getV1SpotPriceByCoinIdQueryKey, getV1SpotPriceByCoinIdQueryOptions } from "./getV1SpotPriceByCoinId"; -export { fetchV1SpotPricesByCoinIds, getV1SpotPricesByCoinIdsQueryKey, getV1SpotPricesByCoinIdsQueryOptions } from "./getV1SpotPricesByCoinIds"; -export { fetchV1SupportedNetworks, getV1SupportedNetworksQueryKey, getV1SupportedNetworksQueryOptions } from "./getV1SupportedNetworks"; -export { fetchV2SpotPrices, getV2SpotPricesQueryKey, getV2SpotPricesQueryOptions } from "./getV2SpotPrices"; -export { fetchV2SupportedNetworks, getV2SupportedNetworksQueryKey, getV2SupportedNetworksQueryOptions } from "./getV2SupportedNetworks"; -export { fetchV2TopTokens, getV2TopTokensQueryKey, getV2TopTokensQueryOptions } from "./getV2TopTokens"; -export { fetchV3HistoricalPrices, getV3HistoricalPricesQueryKey, getV3HistoricalPricesQueryOptions } from "./getV3HistoricalPrices"; -export { fetchV3SpotPrices, getV3SpotPricesQueryKey, getV3SpotPricesQueryOptions } from "./getV3SpotPrices"; \ No newline at end of file +export { + fetchV1ExchangeRates, + getV1ExchangeRatesQueryKey, + getV1ExchangeRatesQueryOptions, +} from './getV1ExchangeRates'; +export { + fetchV1FiatExchangeRates, + getV1FiatExchangeRatesQueryKey, + getV1FiatExchangeRatesQueryOptions, +} from './getV1FiatExchangeRates'; +export { + fetchV1HistoricalPrices, + getV1HistoricalPricesQueryKey, + getV1HistoricalPricesQueryOptions, +} from './getV1HistoricalPrices'; +export { + fetchV1SpotPriceByCoinId, + getV1SpotPriceByCoinIdQueryKey, + getV1SpotPriceByCoinIdQueryOptions, +} from './getV1SpotPriceByCoinId'; +export { + fetchV1SpotPricesByCoinIds, + getV1SpotPricesByCoinIdsQueryKey, + getV1SpotPricesByCoinIdsQueryOptions, +} from './getV1SpotPricesByCoinIds'; +export { + fetchV1SupportedNetworks, + getV1SupportedNetworksQueryKey, + getV1SupportedNetworksQueryOptions, +} from './getV1SupportedNetworks'; +export { + fetchV2SpotPrices, + getV2SpotPricesQueryKey, + getV2SpotPricesQueryOptions, +} from './getV2SpotPrices'; +export { + fetchV2SupportedNetworks, + getV2SupportedNetworksQueryKey, + getV2SupportedNetworksQueryOptions, +} from './getV2SupportedNetworks'; +export { + fetchV2TopTokens, + getV2TopTokensQueryKey, + getV2TopTokensQueryOptions, +} from './getV2TopTokens'; +export { + fetchV3HistoricalPrices, + getV3HistoricalPricesQueryKey, + getV3HistoricalPricesQueryOptions, +} from './getV3HistoricalPrices'; +export { + fetchV3SpotPrices, + getV3SpotPricesQueryKey, + getV3SpotPricesQueryOptions, +} from './getV3SpotPrices'; diff --git a/packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPriceStruct.ts b/packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPriceStruct.ts index 4c811cc678..8a0bbad17b 100644 --- a/packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPriceStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPriceStruct.ts @@ -1,31 +1,31 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import { number, optional, string, type } from "@metamask/superstruct"; +import { number, optional, string, type } from '@metamask/superstruct'; /** * Spot price and market data for a CoinGecko-listed coin. */ export const CoinGeckoSpotPriceStruct = type({ -id: string(), -price: number(), -marketCap: optional(number()), -allTimeHigh: optional(number()), -allTimeLow: optional(number()), -totalVolume: optional(number()), -high1d: optional(number()), -low1d: optional(number()), -circulatingSupply: optional(number()), -dilutedMarketCap: optional(number()), -marketCapPercentChange1d: optional(number()), -priceChange1d: optional(number()), -pricePercentChange1h: optional(number()), -pricePercentChange1d: optional(number()), -pricePercentChange7d: optional(number()), -pricePercentChange14d: optional(number()), -pricePercentChange30d: optional(number()), -pricePercentChange200d: optional(number()), -pricePercentChange1y: optional(number()) -}); \ No newline at end of file + id: string(), + price: number(), + marketCap: optional(number()), + allTimeHigh: optional(number()), + allTimeLow: optional(number()), + totalVolume: optional(number()), + high1d: optional(number()), + low1d: optional(number()), + circulatingSupply: optional(number()), + dilutedMarketCap: optional(number()), + marketCapPercentChange1d: optional(number()), + priceChange1d: optional(number()), + pricePercentChange1h: optional(number()), + pricePercentChange1d: optional(number()), + pricePercentChange7d: optional(number()), + pricePercentChange14d: optional(number()), + pricePercentChange30d: optional(number()), + pricePercentChange200d: optional(number()), + pricePercentChange1y: optional(number()), +}); diff --git a/packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPricesStruct.ts index d7f327f23d..14b37718f0 100644 --- a/packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPricesStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPricesStruct.ts @@ -1,12 +1,16 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { record, string } from '@metamask/superstruct'; -import { CoinGeckoSpotPriceStruct } from "./coinGeckoSpotPriceStruct"; -import { record, string } from "@metamask/superstruct"; +import { CoinGeckoSpotPriceStruct } from './coinGeckoSpotPriceStruct'; /** * Spot prices keyed by CoinGecko coin ID. */ -export const CoinGeckoSpotPricesStruct = record(string(), CoinGeckoSpotPriceStruct); \ No newline at end of file +export const CoinGeckoSpotPricesStruct = record( + string(), + CoinGeckoSpotPriceStruct, +); diff --git a/packages/core-backend/src/generated/price-api/schemas/exchangeRateInfoStruct.ts b/packages/core-backend/src/generated/price-api/schemas/exchangeRateInfoStruct.ts index ab3cf90e50..d466a30cf4 100644 --- a/packages/core-backend/src/generated/price-api/schemas/exchangeRateInfoStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/exchangeRateInfoStruct.ts @@ -1,16 +1,16 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import { enums, number, string, type } from "@metamask/superstruct"; +import { enums, number, string, type } from '@metamask/superstruct'; /** * Exchange rate details for a single currency. */ export const ExchangeRateInfoStruct = type({ -name: string(), -ticker: string(), -value: number(), -currencyType: enums(["crypto", "fiat"]) -}); \ No newline at end of file + name: string(), + ticker: string(), + value: number(), + currencyType: enums(['crypto', 'fiat']), +}); diff --git a/packages/core-backend/src/generated/price-api/schemas/exchangeRatesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/exchangeRatesStruct.ts index 8cd8fa3a83..30c644bcbc 100644 --- a/packages/core-backend/src/generated/price-api/schemas/exchangeRatesStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/exchangeRatesStruct.ts @@ -1,12 +1,13 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { record, string } from '@metamask/superstruct'; -import { ExchangeRateInfoStruct } from "./exchangeRateInfoStruct"; -import { record, string } from "@metamask/superstruct"; +import { ExchangeRateInfoStruct } from './exchangeRateInfoStruct'; /** * Exchange rates keyed by currency ticker. */ -export const ExchangeRatesStruct = record(string(), ExchangeRateInfoStruct); \ No newline at end of file +export const ExchangeRatesStruct = record(string(), ExchangeRateInfoStruct); diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1ExchangeRatesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV1ExchangeRatesStruct.ts index 35c011d29e..e0c9733883 100644 --- a/packages/core-backend/src/generated/price-api/schemas/getV1ExchangeRatesStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/getV1ExchangeRatesStruct.ts @@ -1,13 +1,14 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { string, type } from '@metamask/superstruct'; -import { ExchangeRatesStruct } from "./exchangeRatesStruct"; -import { string, type } from "@metamask/superstruct"; +import { ExchangeRatesStruct } from './exchangeRatesStruct'; export const GetV1ExchangeRatesQueryParamsStruct = type({ -baseCurrency: string() + baseCurrency: string(), }); /** @@ -15,4 +16,5 @@ baseCurrency: string() */ export const GetV1ExchangeRates200Struct = ExchangeRatesStruct; -export const GetV1ExchangeRatesQueryResponseStruct = GetV1ExchangeRates200Struct; \ No newline at end of file +export const GetV1ExchangeRatesQueryResponseStruct = + GetV1ExchangeRates200Struct; diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1FiatExchangeRatesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV1FiatExchangeRatesStruct.ts index bebb78f889..1b95760865 100644 --- a/packages/core-backend/src/generated/price-api/schemas/getV1FiatExchangeRatesStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/getV1FiatExchangeRatesStruct.ts @@ -1,13 +1,14 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import { ExchangeRatesStruct } from "./exchangeRatesStruct"; +import { ExchangeRatesStruct } from './exchangeRatesStruct'; /** * Exchange rates keyed by currency ticker. */ export const GetV1FiatExchangeRates200Struct = ExchangeRatesStruct; -export const GetV1FiatExchangeRatesQueryResponseStruct = GetV1FiatExchangeRates200Struct; \ No newline at end of file +export const GetV1FiatExchangeRatesQueryResponseStruct = + GetV1FiatExchangeRates200Struct; diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1HistoricalPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV1HistoricalPricesStruct.ts index 34581941f4..600d7d1c80 100644 --- a/packages/core-backend/src/generated/price-api/schemas/getV1HistoricalPricesStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/getV1HistoricalPricesStruct.ts @@ -1,20 +1,27 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { + defaulted, + number, + optional, + string, + type, +} from '@metamask/superstruct'; -import { HistoricalPricesStruct } from "./historicalPricesStruct"; -import { VsCurrencyStruct } from "./vsCurrencyStruct"; -import { defaulted, number, optional, string, type } from "@metamask/superstruct"; +import { HistoricalPricesStruct } from './historicalPricesStruct'; +import { VsCurrencyStruct } from './vsCurrencyStruct'; export const GetV1HistoricalPricesPathParamsStruct = type({ -chainId: number(), -tokenAddress: string() + chainId: number(), + tokenAddress: string(), }); export const GetV1HistoricalPricesQueryParamsStruct = type({ -vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")), -timePeriod: optional(string()) + vsCurrency: optional(defaulted(VsCurrencyStruct, 'usd')), + timePeriod: optional(string()), }); /** @@ -22,4 +29,5 @@ timePeriod: optional(string()) */ export const GetV1HistoricalPrices200Struct = HistoricalPricesStruct; -export const GetV1HistoricalPricesQueryResponseStruct = GetV1HistoricalPrices200Struct; \ No newline at end of file +export const GetV1HistoricalPricesQueryResponseStruct = + GetV1HistoricalPrices200Struct; diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1SpotPriceByCoinIdStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV1SpotPriceByCoinIdStruct.ts index cf0446167a..d4a3d4431f 100644 --- a/packages/core-backend/src/generated/price-api/schemas/getV1SpotPriceByCoinIdStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/getV1SpotPriceByCoinIdStruct.ts @@ -1,18 +1,19 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { defaulted, optional, string, type } from '@metamask/superstruct'; -import { CoinGeckoSpotPriceStruct } from "./coinGeckoSpotPriceStruct"; -import { VsCurrencyStruct } from "./vsCurrencyStruct"; -import { defaulted, optional, string, type } from "@metamask/superstruct"; +import { CoinGeckoSpotPriceStruct } from './coinGeckoSpotPriceStruct'; +import { VsCurrencyStruct } from './vsCurrencyStruct'; export const GetV1SpotPriceByCoinIdPathParamsStruct = type({ -coinId: string() + coinId: string(), }); export const GetV1SpotPriceByCoinIdQueryParamsStruct = type({ -vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")) + vsCurrency: optional(defaulted(VsCurrencyStruct, 'usd')), }); /** @@ -20,4 +21,5 @@ vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")) */ export const GetV1SpotPriceByCoinId200Struct = CoinGeckoSpotPriceStruct; -export const GetV1SpotPriceByCoinIdQueryResponseStruct = GetV1SpotPriceByCoinId200Struct; \ No newline at end of file +export const GetV1SpotPriceByCoinIdQueryResponseStruct = + GetV1SpotPriceByCoinId200Struct; diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1SpotPricesByCoinIdsStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV1SpotPricesByCoinIdsStruct.ts index aadcd4ac3d..f605e26e17 100644 --- a/packages/core-backend/src/generated/price-api/schemas/getV1SpotPricesByCoinIdsStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/getV1SpotPricesByCoinIdsStruct.ts @@ -1,15 +1,16 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { defaulted, optional, string, type } from '@metamask/superstruct'; -import { CoinGeckoSpotPricesStruct } from "./coinGeckoSpotPricesStruct"; -import { VsCurrencyStruct } from "./vsCurrencyStruct"; -import { defaulted, optional, string, type } from "@metamask/superstruct"; +import { CoinGeckoSpotPricesStruct } from './coinGeckoSpotPricesStruct'; +import { VsCurrencyStruct } from './vsCurrencyStruct'; export const GetV1SpotPricesByCoinIdsQueryParamsStruct = type({ -coinIds: string(), -vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")) + coinIds: string(), + vsCurrency: optional(defaulted(VsCurrencyStruct, 'usd')), }); /** @@ -17,4 +18,5 @@ vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")) */ export const GetV1SpotPricesByCoinIds200Struct = CoinGeckoSpotPricesStruct; -export const GetV1SpotPricesByCoinIdsQueryResponseStruct = GetV1SpotPricesByCoinIds200Struct; \ No newline at end of file +export const GetV1SpotPricesByCoinIdsQueryResponseStruct = + GetV1SpotPricesByCoinIds200Struct; diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1SupportedNetworksStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV1SupportedNetworksStruct.ts index bdb7c84e58..d5b51c0893 100644 --- a/packages/core-backend/src/generated/price-api/schemas/getV1SupportedNetworksStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/getV1SupportedNetworksStruct.ts @@ -1,13 +1,14 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import { SupportedNetworksStruct } from "./supportedNetworksStruct"; +import { SupportedNetworksStruct } from './supportedNetworksStruct'; /** * The supported networks, split by level of support. */ export const GetV1SupportedNetworks200Struct = SupportedNetworksStruct; -export const GetV1SupportedNetworksQueryResponseStruct = GetV1SupportedNetworks200Struct; \ No newline at end of file +export const GetV1SupportedNetworksQueryResponseStruct = + GetV1SupportedNetworks200Struct; diff --git a/packages/core-backend/src/generated/price-api/schemas/getV2SpotPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV2SpotPricesStruct.ts index 484a7b26ca..67103e9355 100644 --- a/packages/core-backend/src/generated/price-api/schemas/getV2SpotPricesStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/getV2SpotPricesStruct.ts @@ -1,20 +1,28 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { + boolean, + defaulted, + number, + optional, + string, + type, +} from '@metamask/superstruct'; -import { MarketDataSpotPricesStruct } from "./marketDataSpotPricesStruct"; -import { VsCurrencyStruct } from "./vsCurrencyStruct"; -import { boolean, defaulted, number, optional, string, type } from "@metamask/superstruct"; +import { MarketDataSpotPricesStruct } from './marketDataSpotPricesStruct'; +import { VsCurrencyStruct } from './vsCurrencyStruct'; export const GetV2SpotPricesPathParamsStruct = type({ -chainId: number() + chainId: number(), }); export const GetV2SpotPricesQueryParamsStruct = type({ -tokenAddresses: string(), -vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")), -includeMarketData: optional(defaulted(boolean(), true)) + tokenAddresses: string(), + vsCurrency: optional(defaulted(VsCurrencyStruct, 'usd')), + includeMarketData: optional(defaulted(boolean(), true)), }); /** @@ -22,4 +30,4 @@ includeMarketData: optional(defaulted(boolean(), true)) */ export const GetV2SpotPrices200Struct = MarketDataSpotPricesStruct; -export const GetV2SpotPricesQueryResponseStruct = GetV2SpotPrices200Struct; \ No newline at end of file +export const GetV2SpotPricesQueryResponseStruct = GetV2SpotPrices200Struct; diff --git a/packages/core-backend/src/generated/price-api/schemas/getV2SupportedNetworksStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV2SupportedNetworksStruct.ts index bf84847373..d14d4fb41a 100644 --- a/packages/core-backend/src/generated/price-api/schemas/getV2SupportedNetworksStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/getV2SupportedNetworksStruct.ts @@ -1,13 +1,14 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import { SupportedNetworksStruct } from "./supportedNetworksStruct"; +import { SupportedNetworksStruct } from './supportedNetworksStruct'; /** * The supported networks, split by level of support. */ export const GetV2SupportedNetworks200Struct = SupportedNetworksStruct; -export const GetV2SupportedNetworksQueryResponseStruct = GetV2SupportedNetworks200Struct; \ No newline at end of file +export const GetV2SupportedNetworksQueryResponseStruct = + GetV2SupportedNetworks200Struct; diff --git a/packages/core-backend/src/generated/price-api/schemas/getV2TopTokensStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV2TopTokensStruct.ts index c77e6bd580..f7d304fe09 100644 --- a/packages/core-backend/src/generated/price-api/schemas/getV2TopTokensStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/getV2TopTokensStruct.ts @@ -1,19 +1,28 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { + array, + defaulted, + max, + min, + number, + optional, + type, +} from '@metamask/superstruct'; -import { TopTokenStruct } from "./topTokenStruct"; -import { VsCurrencyStruct } from "./vsCurrencyStruct"; -import { array, defaulted, max, min, number, optional, type } from "@metamask/superstruct"; +import { TopTokenStruct } from './topTokenStruct'; +import { VsCurrencyStruct } from './vsCurrencyStruct'; export const GetV2TopTokensPathParamsStruct = type({ -chainId: number() + chainId: number(), }); export const GetV2TopTokensQueryParamsStruct = type({ -limit: optional(defaulted(max(min(number(), 1), 300), 100)), -vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")) + limit: optional(defaulted(max(min(number(), 1), 300), 100)), + vsCurrency: optional(defaulted(VsCurrencyStruct, 'usd')), }); /** @@ -21,4 +30,4 @@ vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")) */ export const GetV2TopTokens200Struct = array(TopTokenStruct); -export const GetV2TopTokensQueryResponseStruct = GetV2TopTokens200Struct; \ No newline at end of file +export const GetV2TopTokensQueryResponseStruct = GetV2TopTokens200Struct; diff --git a/packages/core-backend/src/generated/price-api/schemas/getV3HistoricalPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV3HistoricalPricesStruct.ts index 7b9a1d9063..1cfe8a3d3f 100644 --- a/packages/core-backend/src/generated/price-api/schemas/getV3HistoricalPricesStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/getV3HistoricalPricesStruct.ts @@ -1,23 +1,31 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { + defaulted, + enums, + number, + optional, + string, + type, +} from '@metamask/superstruct'; -import { V3HistoricalPricesStruct } from "./v3HistoricalPricesStruct"; -import { VsCurrencyStruct } from "./vsCurrencyStruct"; -import { defaulted, enums, number, optional, string, type } from "@metamask/superstruct"; +import { V3HistoricalPricesStruct } from './v3HistoricalPricesStruct'; +import { VsCurrencyStruct } from './vsCurrencyStruct'; export const GetV3HistoricalPricesPathParamsStruct = type({ -chainId: string(), -assetType: string() + chainId: string(), + assetType: string(), }); export const GetV3HistoricalPricesQueryParamsStruct = type({ -vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")), -timePeriod: optional(string()), -from: optional(number()), -to: optional(number()), -interval: optional(enums(["5m", "hourly", "daily"])) + vsCurrency: optional(defaulted(VsCurrencyStruct, 'usd')), + timePeriod: optional(string()), + from: optional(number()), + to: optional(number()), + interval: optional(enums(['5m', 'hourly', 'daily'])), }); /** @@ -25,4 +33,5 @@ interval: optional(enums(["5m", "hourly", "daily"])) */ export const GetV3HistoricalPrices200Struct = V3HistoricalPricesStruct; -export const GetV3HistoricalPricesQueryResponseStruct = GetV3HistoricalPrices200Struct; \ No newline at end of file +export const GetV3HistoricalPricesQueryResponseStruct = + GetV3HistoricalPrices200Struct; diff --git a/packages/core-backend/src/generated/price-api/schemas/getV3SpotPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/getV3SpotPricesStruct.ts index df2e3dc3b2..b166a87d07 100644 --- a/packages/core-backend/src/generated/price-api/schemas/getV3SpotPricesStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/getV3SpotPricesStruct.ts @@ -1,17 +1,24 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { + boolean, + defaulted, + optional, + string, + type, +} from '@metamask/superstruct'; -import { V3SpotPricesStruct } from "./v3SpotPricesStruct"; -import { VsCurrencyStruct } from "./vsCurrencyStruct"; -import { boolean, defaulted, optional, string, type } from "@metamask/superstruct"; +import { V3SpotPricesStruct } from './v3SpotPricesStruct'; +import { VsCurrencyStruct } from './vsCurrencyStruct'; export const GetV3SpotPricesQueryParamsStruct = type({ -assetIds: string(), -vsCurrency: optional(defaulted(VsCurrencyStruct, "usd")), -includeMarketData: optional(defaulted(boolean(), false)), -cacheOnly: optional(defaulted(boolean(), false)) + assetIds: string(), + vsCurrency: optional(defaulted(VsCurrencyStruct, 'usd')), + includeMarketData: optional(defaulted(boolean(), false)), + cacheOnly: optional(defaulted(boolean(), false)), }); /** @@ -19,4 +26,4 @@ cacheOnly: optional(defaulted(boolean(), false)) */ export const GetV3SpotPrices200Struct = V3SpotPricesStruct; -export const GetV3SpotPricesQueryResponseStruct = GetV3SpotPrices200Struct; \ No newline at end of file +export const GetV3SpotPricesQueryResponseStruct = GetV3SpotPrices200Struct; diff --git a/packages/core-backend/src/generated/price-api/schemas/historicalPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/historicalPricesStruct.ts index 811505c19b..15a004aed3 100644 --- a/packages/core-backend/src/generated/price-api/schemas/historicalPricesStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/historicalPricesStruct.ts @@ -1,14 +1,15 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { array, type } from '@metamask/superstruct'; -import { PricePointStruct } from "./pricePointStruct"; -import { array, type } from "@metamask/superstruct"; +import { PricePointStruct } from './pricePointStruct'; /** * Historical prices for a token. */ export const HistoricalPricesStruct = type({ -prices: array(PricePointStruct) -}); \ No newline at end of file + prices: array(PricePointStruct), +}); diff --git a/packages/core-backend/src/generated/price-api/schemas/index.ts b/packages/core-backend/src/generated/price-api/schemas/index.ts index fae7767b22..cc47586934 100644 --- a/packages/core-backend/src/generated/price-api/schemas/index.ts +++ b/packages/core-backend/src/generated/price-api/schemas/index.ts @@ -1,25 +1,71 @@ -export { CoinGeckoSpotPriceStruct } from "./coinGeckoSpotPriceStruct"; -export { CoinGeckoSpotPricesStruct } from "./coinGeckoSpotPricesStruct"; -export { ExchangeRateInfoStruct } from "./exchangeRateInfoStruct"; -export { ExchangeRatesStruct } from "./exchangeRatesStruct"; -export { GetV1ExchangeRates200Struct, GetV1ExchangeRatesQueryParamsStruct, GetV1ExchangeRatesQueryResponseStruct } from "./getV1ExchangeRatesStruct"; -export { GetV1FiatExchangeRates200Struct, GetV1FiatExchangeRatesQueryResponseStruct } from "./getV1FiatExchangeRatesStruct"; -export { GetV1HistoricalPrices200Struct, GetV1HistoricalPricesPathParamsStruct, GetV1HistoricalPricesQueryParamsStruct, GetV1HistoricalPricesQueryResponseStruct } from "./getV1HistoricalPricesStruct"; -export { GetV1SpotPriceByCoinId200Struct, GetV1SpotPriceByCoinIdPathParamsStruct, GetV1SpotPriceByCoinIdQueryParamsStruct, GetV1SpotPriceByCoinIdQueryResponseStruct } from "./getV1SpotPriceByCoinIdStruct"; -export { GetV1SpotPricesByCoinIds200Struct, GetV1SpotPricesByCoinIdsQueryParamsStruct, GetV1SpotPricesByCoinIdsQueryResponseStruct } from "./getV1SpotPricesByCoinIdsStruct"; -export { GetV1SupportedNetworks200Struct, GetV1SupportedNetworksQueryResponseStruct } from "./getV1SupportedNetworksStruct"; -export { GetV2SpotPrices200Struct, GetV2SpotPricesPathParamsStruct, GetV2SpotPricesQueryParamsStruct, GetV2SpotPricesQueryResponseStruct } from "./getV2SpotPricesStruct"; -export { GetV2SupportedNetworks200Struct, GetV2SupportedNetworksQueryResponseStruct } from "./getV2SupportedNetworksStruct"; -export { GetV2TopTokens200Struct, GetV2TopTokensPathParamsStruct, GetV2TopTokensQueryParamsStruct, GetV2TopTokensQueryResponseStruct } from "./getV2TopTokensStruct"; -export { GetV3HistoricalPrices200Struct, GetV3HistoricalPricesPathParamsStruct, GetV3HistoricalPricesQueryParamsStruct, GetV3HistoricalPricesQueryResponseStruct } from "./getV3HistoricalPricesStruct"; -export { GetV3SpotPrices200Struct, GetV3SpotPricesQueryParamsStruct, GetV3SpotPricesQueryResponseStruct } from "./getV3SpotPricesStruct"; -export { HistoricalPricesStruct } from "./historicalPricesStruct"; -export { MarketDataSpotPricesStruct } from "./marketDataSpotPricesStruct"; -export { MarketDataStruct } from "./marketDataStruct"; -export { PricePointStruct } from "./pricePointStruct"; -export { SupportedNetworksStruct } from "./supportedNetworksStruct"; -export { TopTokenStruct } from "./topTokenStruct"; -export { V3HistoricalPricesStruct } from "./v3HistoricalPricesStruct"; -export { V3SpotPriceStruct } from "./v3SpotPriceStruct"; -export { V3SpotPricesStruct } from "./v3SpotPricesStruct"; -export { VsCurrencyStruct } from "./vsCurrencyStruct"; \ No newline at end of file +export { CoinGeckoSpotPriceStruct } from './coinGeckoSpotPriceStruct'; +export { CoinGeckoSpotPricesStruct } from './coinGeckoSpotPricesStruct'; +export { ExchangeRateInfoStruct } from './exchangeRateInfoStruct'; +export { ExchangeRatesStruct } from './exchangeRatesStruct'; +export { + GetV1ExchangeRates200Struct, + GetV1ExchangeRatesQueryParamsStruct, + GetV1ExchangeRatesQueryResponseStruct, +} from './getV1ExchangeRatesStruct'; +export { + GetV1FiatExchangeRates200Struct, + GetV1FiatExchangeRatesQueryResponseStruct, +} from './getV1FiatExchangeRatesStruct'; +export { + GetV1HistoricalPrices200Struct, + GetV1HistoricalPricesPathParamsStruct, + GetV1HistoricalPricesQueryParamsStruct, + GetV1HistoricalPricesQueryResponseStruct, +} from './getV1HistoricalPricesStruct'; +export { + GetV1SpotPriceByCoinId200Struct, + GetV1SpotPriceByCoinIdPathParamsStruct, + GetV1SpotPriceByCoinIdQueryParamsStruct, + GetV1SpotPriceByCoinIdQueryResponseStruct, +} from './getV1SpotPriceByCoinIdStruct'; +export { + GetV1SpotPricesByCoinIds200Struct, + GetV1SpotPricesByCoinIdsQueryParamsStruct, + GetV1SpotPricesByCoinIdsQueryResponseStruct, +} from './getV1SpotPricesByCoinIdsStruct'; +export { + GetV1SupportedNetworks200Struct, + GetV1SupportedNetworksQueryResponseStruct, +} from './getV1SupportedNetworksStruct'; +export { + GetV2SpotPrices200Struct, + GetV2SpotPricesPathParamsStruct, + GetV2SpotPricesQueryParamsStruct, + GetV2SpotPricesQueryResponseStruct, +} from './getV2SpotPricesStruct'; +export { + GetV2SupportedNetworks200Struct, + GetV2SupportedNetworksQueryResponseStruct, +} from './getV2SupportedNetworksStruct'; +export { + GetV2TopTokens200Struct, + GetV2TopTokensPathParamsStruct, + GetV2TopTokensQueryParamsStruct, + GetV2TopTokensQueryResponseStruct, +} from './getV2TopTokensStruct'; +export { + GetV3HistoricalPrices200Struct, + GetV3HistoricalPricesPathParamsStruct, + GetV3HistoricalPricesQueryParamsStruct, + GetV3HistoricalPricesQueryResponseStruct, +} from './getV3HistoricalPricesStruct'; +export { + GetV3SpotPrices200Struct, + GetV3SpotPricesQueryParamsStruct, + GetV3SpotPricesQueryResponseStruct, +} from './getV3SpotPricesStruct'; +export { HistoricalPricesStruct } from './historicalPricesStruct'; +export { MarketDataSpotPricesStruct } from './marketDataSpotPricesStruct'; +export { MarketDataStruct } from './marketDataStruct'; +export { PricePointStruct } from './pricePointStruct'; +export { SupportedNetworksStruct } from './supportedNetworksStruct'; +export { TopTokenStruct } from './topTokenStruct'; +export { V3HistoricalPricesStruct } from './v3HistoricalPricesStruct'; +export { V3SpotPriceStruct } from './v3SpotPriceStruct'; +export { V3SpotPricesStruct } from './v3SpotPricesStruct'; +export { VsCurrencyStruct } from './vsCurrencyStruct'; diff --git a/packages/core-backend/src/generated/price-api/schemas/marketDataSpotPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/marketDataSpotPricesStruct.ts index ff141630b2..77256cac71 100644 --- a/packages/core-backend/src/generated/price-api/schemas/marketDataSpotPricesStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/marketDataSpotPricesStruct.ts @@ -1,12 +1,13 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { record, string } from '@metamask/superstruct'; -import { MarketDataStruct } from "./marketDataStruct"; -import { record, string } from "@metamask/superstruct"; +import { MarketDataStruct } from './marketDataStruct'; /** * Market data keyed by lowercased token contract address. */ -export const MarketDataSpotPricesStruct = record(string(), MarketDataStruct); \ No newline at end of file +export const MarketDataSpotPricesStruct = record(string(), MarketDataStruct); diff --git a/packages/core-backend/src/generated/price-api/schemas/marketDataStruct.ts b/packages/core-backend/src/generated/price-api/schemas/marketDataStruct.ts index 9491ad5e2a..c417e4bcba 100644 --- a/packages/core-backend/src/generated/price-api/schemas/marketDataStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/marketDataStruct.ts @@ -1,31 +1,31 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import { number, optional, string, type } from "@metamask/superstruct"; +import { number, optional, string, type } from '@metamask/superstruct'; /** * Market data for a token, as returned by the v2 spot prices endpoint. */ export const MarketDataStruct = type({ -price: number(), -currency: string(), -priceChange1d: optional(number()), -pricePercentChange1d: optional(number()), -pricePercentChange1h: optional(number()), -pricePercentChange7d: optional(number()), -pricePercentChange14d: optional(number()), -pricePercentChange30d: optional(number()), -pricePercentChange200d: optional(number()), -pricePercentChange1y: optional(number()), -marketCap: optional(number()), -marketCapPercentChange1d: optional(number()), -allTimeHigh: optional(number()), -allTimeLow: optional(number()), -high1d: optional(number()), -low1d: optional(number()), -totalVolume: optional(number()), -circulatingSupply: optional(number()), -dilutedMarketCap: optional(number()) -}); \ No newline at end of file + price: number(), + currency: string(), + priceChange1d: optional(number()), + pricePercentChange1d: optional(number()), + pricePercentChange1h: optional(number()), + pricePercentChange7d: optional(number()), + pricePercentChange14d: optional(number()), + pricePercentChange30d: optional(number()), + pricePercentChange200d: optional(number()), + pricePercentChange1y: optional(number()), + marketCap: optional(number()), + marketCapPercentChange1d: optional(number()), + allTimeHigh: optional(number()), + allTimeLow: optional(number()), + high1d: optional(number()), + low1d: optional(number()), + totalVolume: optional(number()), + circulatingSupply: optional(number()), + dilutedMarketCap: optional(number()), +}); diff --git a/packages/core-backend/src/generated/price-api/schemas/pricePointStruct.ts b/packages/core-backend/src/generated/price-api/schemas/pricePointStruct.ts index bf13fd00dc..dfd28ebe29 100644 --- a/packages/core-backend/src/generated/price-api/schemas/pricePointStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/pricePointStruct.ts @@ -1,11 +1,11 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import { number, tuple } from "@metamask/superstruct"; +import { number, tuple } from '@metamask/superstruct'; /** * A [timestamp, value] tuple. The timestamp is a Unix timestamp in milliseconds. */ -export const PricePointStruct = tuple([number(), number()]); \ No newline at end of file +export const PricePointStruct = tuple([number(), number()]); diff --git a/packages/core-backend/src/generated/price-api/schemas/supportedNetworksStruct.ts b/packages/core-backend/src/generated/price-api/schemas/supportedNetworksStruct.ts index 4fc3b5255f..373651983b 100644 --- a/packages/core-backend/src/generated/price-api/schemas/supportedNetworksStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/supportedNetworksStruct.ts @@ -1,14 +1,14 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import { array, string, type } from "@metamask/superstruct"; +import { array, string, type } from '@metamask/superstruct'; /** * Networks supported by the Price API, split by level of support. */ export const SupportedNetworksStruct = type({ -fullSupport: array(string()), -partialSupport: array(string()) -}); \ No newline at end of file + fullSupport: array(string()), + partialSupport: array(string()), +}); diff --git a/packages/core-backend/src/generated/price-api/schemas/topTokenStruct.ts b/packages/core-backend/src/generated/price-api/schemas/topTokenStruct.ts index b21ed9e9c4..d5d1edb03e 100644 --- a/packages/core-backend/src/generated/price-api/schemas/topTokenStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/topTokenStruct.ts @@ -1,17 +1,17 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import { number, string, type } from "@metamask/superstruct"; +import { number, string, type } from '@metamask/superstruct'; /** * A token in the top tokens list. */ export const TopTokenStruct = type({ -assetId: string(), -name: string(), -symbol: string(), -price: number(), -marketCap: number() -}); \ No newline at end of file + assetId: string(), + name: string(), + symbol: string(), + price: number(), + marketCap: number(), +}); diff --git a/packages/core-backend/src/generated/price-api/schemas/v3HistoricalPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/v3HistoricalPricesStruct.ts index f87aca211d..35b77486ae 100644 --- a/packages/core-backend/src/generated/price-api/schemas/v3HistoricalPricesStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/v3HistoricalPricesStruct.ts @@ -1,16 +1,17 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { array, optional, type } from '@metamask/superstruct'; -import { PricePointStruct } from "./pricePointStruct"; -import { array, optional, type } from "@metamask/superstruct"; +import { PricePointStruct } from './pricePointStruct'; /** * Historical prices, market caps and total volumes for a CAIP-19 asset. */ export const V3HistoricalPricesStruct = type({ -prices: array(PricePointStruct), -marketCaps: optional(array(PricePointStruct)), -totalVolumes: optional(array(PricePointStruct)) -}); \ No newline at end of file + prices: array(PricePointStruct), + marketCaps: optional(array(PricePointStruct)), + totalVolumes: optional(array(PricePointStruct)), +}); diff --git a/packages/core-backend/src/generated/price-api/schemas/v3SpotPriceStruct.ts b/packages/core-backend/src/generated/price-api/schemas/v3SpotPriceStruct.ts index 386ec76a59..8224da8820 100644 --- a/packages/core-backend/src/generated/price-api/schemas/v3SpotPriceStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/v3SpotPriceStruct.ts @@ -1,16 +1,16 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import { number, optional, type } from "@metamask/superstruct"; +import { number, optional, type } from '@metamask/superstruct'; /** * Spot price and optional market data for a CAIP-19 asset. */ export const V3SpotPriceStruct = type({ -price: number(), -pricePercentChange1d: optional(number()), -marketCap: optional(number()), -totalVolume: optional(number()) -}); \ No newline at end of file + price: number(), + pricePercentChange1d: optional(number()), + marketCap: optional(number()), + totalVolume: optional(number()), +}); diff --git a/packages/core-backend/src/generated/price-api/schemas/v3SpotPricesStruct.ts b/packages/core-backend/src/generated/price-api/schemas/v3SpotPricesStruct.ts index 62169fce29..05d83f3a34 100644 --- a/packages/core-backend/src/generated/price-api/schemas/v3SpotPricesStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/v3SpotPricesStruct.ts @@ -1,12 +1,16 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { literal, record, string, union } from '@metamask/superstruct'; -import { V3SpotPriceStruct } from "./v3SpotPriceStruct"; -import { literal, record, string, union } from "@metamask/superstruct"; +import { V3SpotPriceStruct } from './v3SpotPriceStruct'; /** * Spot prices keyed by CAIP-19 asset ID. Assets without a known price map to null. */ -export const V3SpotPricesStruct = record(string(), union([V3SpotPriceStruct, literal(null)])); \ No newline at end of file +export const V3SpotPricesStruct = record( + string(), + union([V3SpotPriceStruct, literal(null)]), +); diff --git a/packages/core-backend/src/generated/price-api/schemas/vsCurrencyStruct.ts b/packages/core-backend/src/generated/price-api/schemas/vsCurrencyStruct.ts index 7b0e0167ab..eff1af6c24 100644 --- a/packages/core-backend/src/generated/price-api/schemas/vsCurrencyStruct.ts +++ b/packages/core-backend/src/generated/price-api/schemas/vsCurrencyStruct.ts @@ -1,11 +1,72 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import { defaulted, enums } from "@metamask/superstruct"; +import { defaulted, enums } from '@metamask/superstruct'; /** * A currency that prices can be denominated in. */ -export const VsCurrencyStruct = defaulted(enums(["btc", "eth", "ltc", "bch", "bnb", "eos", "xrp", "xlm", "link", "dot", "yfi", "usd", "aed", "ars", "aud", "bdt", "bhd", "bmd", "brl", "cad", "chf", "clp", "cny", "czk", "dkk", "eur", "gbp", "gel", "hkd", "huf", "idr", "ils", "inr", "jpy", "krw", "kwd", "lkr", "mmk", "mxn", "myr", "ngn", "nok", "nzd", "php", "pkr", "pln", "rub", "sar", "sek", "sgd", "thb", "try", "twd", "uah", "vef", "vnd", "zar"]), "usd"); \ No newline at end of file +export const VsCurrencyStruct = defaulted( + enums([ + 'btc', + 'eth', + 'ltc', + 'bch', + 'bnb', + 'eos', + 'xrp', + 'xlm', + 'link', + 'dot', + 'yfi', + 'usd', + 'aed', + 'ars', + 'aud', + 'bdt', + 'bhd', + 'bmd', + 'brl', + 'cad', + 'chf', + 'clp', + 'cny', + 'czk', + 'dkk', + 'eur', + 'gbp', + 'gel', + 'hkd', + 'huf', + 'idr', + 'ils', + 'inr', + 'jpy', + 'krw', + 'kwd', + 'lkr', + 'mmk', + 'mxn', + 'myr', + 'ngn', + 'nok', + 'nzd', + 'php', + 'pkr', + 'pln', + 'rub', + 'sar', + 'sek', + 'sgd', + 'thb', + 'try', + 'twd', + 'uah', + 'vef', + 'vnd', + 'zar', + ]), + 'usd', +); diff --git a/packages/core-backend/src/generated/price-api/types/CoinGeckoSpotPrice.ts b/packages/core-backend/src/generated/price-api/types/CoinGeckoSpotPrice.ts index 2e09ae10aa..f6ef0f5b79 100644 --- a/packages/core-backend/src/generated/price-api/types/CoinGeckoSpotPrice.ts +++ b/packages/core-backend/src/generated/price-api/types/CoinGeckoSpotPrice.ts @@ -1,106 +1,105 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ - + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ /** * @description Spot price and market data for a CoinGecko-listed coin. -*/ + */ export type CoinGeckoSpotPrice = { - /** - * @description CoinGecko coin ID. - * @type string - */ - id: string; - /** - * @description Current price in the requested currency. - * @type number - */ - price: number; - /** - * @description Market capitalization. - * @type number | undefined - */ - marketCap?: number; - /** - * @description All-time high price. - * @type number | undefined - */ - allTimeHigh?: number; - /** - * @description All-time low price. - * @type number | undefined - */ - allTimeLow?: number; - /** - * @description Total trading volume. - * @type number | undefined - */ - totalVolume?: number; - /** - * @description 24h high price. - * @type number | undefined - */ - high1d?: number; - /** - * @description 24h low price. - * @type number | undefined - */ - low1d?: number; - /** - * @description Circulating supply. - * @type number | undefined - */ - circulatingSupply?: number; - /** - * @description Fully diluted market cap. - * @type number | undefined - */ - dilutedMarketCap?: number; - /** - * @description Market cap 24h change percentage. - * @type number | undefined - */ - marketCapPercentChange1d?: number; - /** - * @description 24h price change amount. - * @type number | undefined - */ - priceChange1d?: number; - /** - * @description 1h price change percentage. - * @type number | undefined - */ - pricePercentChange1h?: number; - /** - * @description 24h price change percentage. - * @type number | undefined - */ - pricePercentChange1d?: number; - /** - * @description 7d price change percentage. - * @type number | undefined - */ - pricePercentChange7d?: number; - /** - * @description 14d price change percentage. - * @type number | undefined - */ - pricePercentChange14d?: number; - /** - * @description 30d price change percentage. - * @type number | undefined - */ - pricePercentChange30d?: number; - /** - * @description 200d price change percentage. - * @type number | undefined - */ - pricePercentChange200d?: number; - /** - * @description 1y price change percentage. - * @type number | undefined - */ - pricePercentChange1y?: number; -}; \ No newline at end of file + /** + * @description CoinGecko coin ID. + * @type string + */ + id: string; + /** + * @description Current price in the requested currency. + * @type number + */ + price: number; + /** + * @description Market capitalization. + * @type number | undefined + */ + marketCap?: number; + /** + * @description All-time high price. + * @type number | undefined + */ + allTimeHigh?: number; + /** + * @description All-time low price. + * @type number | undefined + */ + allTimeLow?: number; + /** + * @description Total trading volume. + * @type number | undefined + */ + totalVolume?: number; + /** + * @description 24h high price. + * @type number | undefined + */ + high1d?: number; + /** + * @description 24h low price. + * @type number | undefined + */ + low1d?: number; + /** + * @description Circulating supply. + * @type number | undefined + */ + circulatingSupply?: number; + /** + * @description Fully diluted market cap. + * @type number | undefined + */ + dilutedMarketCap?: number; + /** + * @description Market cap 24h change percentage. + * @type number | undefined + */ + marketCapPercentChange1d?: number; + /** + * @description 24h price change amount. + * @type number | undefined + */ + priceChange1d?: number; + /** + * @description 1h price change percentage. + * @type number | undefined + */ + pricePercentChange1h?: number; + /** + * @description 24h price change percentage. + * @type number | undefined + */ + pricePercentChange1d?: number; + /** + * @description 7d price change percentage. + * @type number | undefined + */ + pricePercentChange7d?: number; + /** + * @description 14d price change percentage. + * @type number | undefined + */ + pricePercentChange14d?: number; + /** + * @description 30d price change percentage. + * @type number | undefined + */ + pricePercentChange30d?: number; + /** + * @description 200d price change percentage. + * @type number | undefined + */ + pricePercentChange200d?: number; + /** + * @description 1y price change percentage. + * @type number | undefined + */ + pricePercentChange1y?: number; +}; diff --git a/packages/core-backend/src/generated/price-api/types/CoinGeckoSpotPrices.ts b/packages/core-backend/src/generated/price-api/types/CoinGeckoSpotPrices.ts index b0fcfa22e7..f63663fb53 100644 --- a/packages/core-backend/src/generated/price-api/types/CoinGeckoSpotPrices.ts +++ b/packages/core-backend/src/generated/price-api/types/CoinGeckoSpotPrices.ts @@ -1,13 +1,13 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { CoinGeckoSpotPrice } from "./CoinGeckoSpotPrice"; +import type { CoinGeckoSpotPrice } from './CoinGeckoSpotPrice'; /** * @description Spot prices keyed by CoinGecko coin ID. -*/ + */ export type CoinGeckoSpotPrices = { - [key: string]: CoinGeckoSpotPrice; -}; \ No newline at end of file + [key: string]: CoinGeckoSpotPrice; +}; diff --git a/packages/core-backend/src/generated/price-api/types/ExchangeRateInfo.ts b/packages/core-backend/src/generated/price-api/types/ExchangeRateInfo.ts index 522104fc2c..3a1142d1b0 100644 --- a/packages/core-backend/src/generated/price-api/types/ExchangeRateInfo.ts +++ b/packages/core-backend/src/generated/price-api/types/ExchangeRateInfo.ts @@ -1,38 +1,38 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ - + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ export const exchangeRateInfoCurrencyTypeEnum = { - crypto: "crypto", - fiat: "fiat" + crypto: 'crypto', + fiat: 'fiat', } as const; -export type ExchangeRateInfoCurrencyTypeEnumKey = (typeof exchangeRateInfoCurrencyTypeEnum)[keyof typeof exchangeRateInfoCurrencyTypeEnum]; +export type ExchangeRateInfoCurrencyTypeEnumKey = + (typeof exchangeRateInfoCurrencyTypeEnum)[keyof typeof exchangeRateInfoCurrencyTypeEnum]; /** * @description Exchange rate details for a single currency. -*/ + */ export type ExchangeRateInfo = { - /** - * @description Human-readable name of the currency. - * @type string - */ - name: string; - /** - * @description Ticker symbol of the currency. - * @type string - */ - ticker: string; - /** - * @description Exchange rate against the base currency. - * @type number - */ - value: number; - /** - * @description Whether the currency is a cryptocurrency or fiat currency. - * @type string - */ - currencyType: ExchangeRateInfoCurrencyTypeEnumKey; -}; \ No newline at end of file + /** + * @description Human-readable name of the currency. + * @type string + */ + name: string; + /** + * @description Ticker symbol of the currency. + * @type string + */ + ticker: string; + /** + * @description Exchange rate against the base currency. + * @type number + */ + value: number; + /** + * @description Whether the currency is a cryptocurrency or fiat currency. + * @type string + */ + currencyType: ExchangeRateInfoCurrencyTypeEnumKey; +}; diff --git a/packages/core-backend/src/generated/price-api/types/ExchangeRates.ts b/packages/core-backend/src/generated/price-api/types/ExchangeRates.ts index 2b66934ed4..7f0ad6b8e6 100644 --- a/packages/core-backend/src/generated/price-api/types/ExchangeRates.ts +++ b/packages/core-backend/src/generated/price-api/types/ExchangeRates.ts @@ -1,13 +1,13 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { ExchangeRateInfo } from "./ExchangeRateInfo"; +import type { ExchangeRateInfo } from './ExchangeRateInfo'; /** * @description Exchange rates keyed by currency ticker. -*/ + */ export type ExchangeRates = { - [key: string]: ExchangeRateInfo; -}; \ No newline at end of file + [key: string]: ExchangeRateInfo; +}; diff --git a/packages/core-backend/src/generated/price-api/types/GetV1ExchangeRates.ts b/packages/core-backend/src/generated/price-api/types/GetV1ExchangeRates.ts index eff6add9ba..57db0befbc 100644 --- a/packages/core-backend/src/generated/price-api/types/GetV1ExchangeRates.ts +++ b/packages/core-backend/src/generated/price-api/types/GetV1ExchangeRates.ts @@ -1,27 +1,27 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { ExchangeRates } from "./ExchangeRates"; +import type { ExchangeRates } from './ExchangeRates'; export type GetV1ExchangeRatesQueryParams = { - /** - * @description The base currency to convert rates against. - * @type string - */ - baseCurrency: string; + /** + * @description The base currency to convert rates against. + * @type string + */ + baseCurrency: string; }; /** * @description Exchange rates keyed by currency ticker. -*/ + */ export type GetV1ExchangeRates200 = ExchangeRates; export type GetV1ExchangeRatesQueryResponse = GetV1ExchangeRates200; export type GetV1ExchangeRatesQuery = { - Response: GetV1ExchangeRates200; - QueryParams: GetV1ExchangeRatesQueryParams; - Errors: any; -}; \ No newline at end of file + Response: GetV1ExchangeRates200; + QueryParams: GetV1ExchangeRatesQueryParams; + Errors: any; +}; diff --git a/packages/core-backend/src/generated/price-api/types/GetV1FiatExchangeRates.ts b/packages/core-backend/src/generated/price-api/types/GetV1FiatExchangeRates.ts index 69c91e12cc..9295f3db8b 100644 --- a/packages/core-backend/src/generated/price-api/types/GetV1FiatExchangeRates.ts +++ b/packages/core-backend/src/generated/price-api/types/GetV1FiatExchangeRates.ts @@ -1,18 +1,18 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { ExchangeRates } from "./ExchangeRates"; +import type { ExchangeRates } from './ExchangeRates'; /** * @description Exchange rates keyed by currency ticker. -*/ + */ export type GetV1FiatExchangeRates200 = ExchangeRates; export type GetV1FiatExchangeRatesQueryResponse = GetV1FiatExchangeRates200; export type GetV1FiatExchangeRatesQuery = { - Response: GetV1FiatExchangeRates200; - Errors: any; -}; \ No newline at end of file + Response: GetV1FiatExchangeRates200; + Errors: any; +}; diff --git a/packages/core-backend/src/generated/price-api/types/GetV1HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/types/GetV1HistoricalPrices.ts index fd5e749cff..f7fc5192bb 100644 --- a/packages/core-backend/src/generated/price-api/types/GetV1HistoricalPrices.ts +++ b/packages/core-backend/src/generated/price-api/types/GetV1HistoricalPrices.ts @@ -1,48 +1,48 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { HistoricalPrices } from "./HistoricalPrices"; -import type { VsCurrency } from "./VsCurrency"; +import type { HistoricalPrices } from './HistoricalPrices'; +import type { VsCurrency } from './VsCurrency'; export type GetV1HistoricalPricesPathParams = { - /** - * @description Decimal chain ID of the network to query. - * @type number - */ - chainId: number; - /** - * @description Contract address of the token to get prices for. - * @type string - */ - tokenAddress: string; + /** + * @description Decimal chain ID of the network to query. + * @type number + */ + chainId: number; + /** + * @description Contract address of the token to get prices for. + * @type string + */ + tokenAddress: string; }; export type GetV1HistoricalPricesQueryParams = { - /** - * @description A currency that prices can be denominated in. - * @default "usd" - * @type string | undefined - */ - vsCurrency?: VsCurrency; - /** - * @description Time period for the historical prices (e.g. 1d, 7d, 1m, 3m, 1y, 1000d). - * @type string | undefined - */ - timePeriod?: string; + /** + * @description A currency that prices can be denominated in. + * @default "usd" + * @type string | undefined + */ + vsCurrency?: VsCurrency; + /** + * @description Time period for the historical prices (e.g. 1d, 7d, 1m, 3m, 1y, 1000d). + * @type string | undefined + */ + timePeriod?: string; }; /** * @description The historical prices of the token. -*/ + */ export type GetV1HistoricalPrices200 = HistoricalPrices; export type GetV1HistoricalPricesQueryResponse = GetV1HistoricalPrices200; export type GetV1HistoricalPricesQuery = { - Response: GetV1HistoricalPrices200; - PathParams: GetV1HistoricalPricesPathParams; - QueryParams: GetV1HistoricalPricesQueryParams; - Errors: any; -}; \ No newline at end of file + Response: GetV1HistoricalPrices200; + PathParams: GetV1HistoricalPricesPathParams; + QueryParams: GetV1HistoricalPricesQueryParams; + Errors: any; +}; diff --git a/packages/core-backend/src/generated/price-api/types/GetV1SpotPriceByCoinId.ts b/packages/core-backend/src/generated/price-api/types/GetV1SpotPriceByCoinId.ts index ce7af74758..3e6f718b28 100644 --- a/packages/core-backend/src/generated/price-api/types/GetV1SpotPriceByCoinId.ts +++ b/packages/core-backend/src/generated/price-api/types/GetV1SpotPriceByCoinId.ts @@ -1,38 +1,38 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { CoinGeckoSpotPrice } from "./CoinGeckoSpotPrice"; -import type { VsCurrency } from "./VsCurrency"; +import type { CoinGeckoSpotPrice } from './CoinGeckoSpotPrice'; +import type { VsCurrency } from './VsCurrency'; export type GetV1SpotPriceByCoinIdPathParams = { - /** - * @description CoinGecko ID of the coin to get the price for. - * @type string - */ - coinId: string; + /** + * @description CoinGecko ID of the coin to get the price for. + * @type string + */ + coinId: string; }; export type GetV1SpotPriceByCoinIdQueryParams = { - /** - * @description A currency that prices can be denominated in. - * @default "usd" - * @type string | undefined - */ - vsCurrency?: VsCurrency; + /** + * @description A currency that prices can be denominated in. + * @default "usd" + * @type string | undefined + */ + vsCurrency?: VsCurrency; }; /** * @description The spot price of the coin. -*/ + */ export type GetV1SpotPriceByCoinId200 = CoinGeckoSpotPrice; export type GetV1SpotPriceByCoinIdQueryResponse = GetV1SpotPriceByCoinId200; export type GetV1SpotPriceByCoinIdQuery = { - Response: GetV1SpotPriceByCoinId200; - PathParams: GetV1SpotPriceByCoinIdPathParams; - QueryParams: GetV1SpotPriceByCoinIdQueryParams; - Errors: any; -}; \ No newline at end of file + Response: GetV1SpotPriceByCoinId200; + PathParams: GetV1SpotPriceByCoinIdPathParams; + QueryParams: GetV1SpotPriceByCoinIdQueryParams; + Errors: any; +}; diff --git a/packages/core-backend/src/generated/price-api/types/GetV1SpotPricesByCoinIds.ts b/packages/core-backend/src/generated/price-api/types/GetV1SpotPricesByCoinIds.ts index e4d7b2552e..df3db78970 100644 --- a/packages/core-backend/src/generated/price-api/types/GetV1SpotPricesByCoinIds.ts +++ b/packages/core-backend/src/generated/price-api/types/GetV1SpotPricesByCoinIds.ts @@ -1,34 +1,34 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { CoinGeckoSpotPrices } from "./CoinGeckoSpotPrices"; -import type { VsCurrency } from "./VsCurrency"; +import type { CoinGeckoSpotPrices } from './CoinGeckoSpotPrices'; +import type { VsCurrency } from './VsCurrency'; export type GetV1SpotPricesByCoinIdsQueryParams = { - /** - * @description Comma-separated CoinGecko IDs of the coins to get prices for. - * @type string - */ - coinIds: string; - /** - * @description A currency that prices can be denominated in. - * @default "usd" - * @type string | undefined - */ - vsCurrency?: VsCurrency; + /** + * @description Comma-separated CoinGecko IDs of the coins to get prices for. + * @type string + */ + coinIds: string; + /** + * @description A currency that prices can be denominated in. + * @default "usd" + * @type string | undefined + */ + vsCurrency?: VsCurrency; }; /** * @description Spot prices keyed by CoinGecko coin ID. -*/ + */ export type GetV1SpotPricesByCoinIds200 = CoinGeckoSpotPrices; export type GetV1SpotPricesByCoinIdsQueryResponse = GetV1SpotPricesByCoinIds200; export type GetV1SpotPricesByCoinIdsQuery = { - Response: GetV1SpotPricesByCoinIds200; - QueryParams: GetV1SpotPricesByCoinIdsQueryParams; - Errors: any; -}; \ No newline at end of file + Response: GetV1SpotPricesByCoinIds200; + QueryParams: GetV1SpotPricesByCoinIdsQueryParams; + Errors: any; +}; diff --git a/packages/core-backend/src/generated/price-api/types/GetV1SupportedNetworks.ts b/packages/core-backend/src/generated/price-api/types/GetV1SupportedNetworks.ts index cabe18b92e..d6ab66b9de 100644 --- a/packages/core-backend/src/generated/price-api/types/GetV1SupportedNetworks.ts +++ b/packages/core-backend/src/generated/price-api/types/GetV1SupportedNetworks.ts @@ -1,18 +1,18 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { SupportedNetworks } from "./SupportedNetworks"; +import type { SupportedNetworks } from './SupportedNetworks'; /** * @description The supported networks, split by level of support. -*/ + */ export type GetV1SupportedNetworks200 = SupportedNetworks; export type GetV1SupportedNetworksQueryResponse = GetV1SupportedNetworks200; export type GetV1SupportedNetworksQuery = { - Response: GetV1SupportedNetworks200; - Errors: any; -}; \ No newline at end of file + Response: GetV1SupportedNetworks200; + Errors: any; +}; diff --git a/packages/core-backend/src/generated/price-api/types/GetV2SpotPrices.ts b/packages/core-backend/src/generated/price-api/types/GetV2SpotPrices.ts index 8e1f96e761..f1e9aaaef5 100644 --- a/packages/core-backend/src/generated/price-api/types/GetV2SpotPrices.ts +++ b/packages/core-backend/src/generated/price-api/types/GetV2SpotPrices.ts @@ -1,49 +1,49 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { MarketDataSpotPrices } from "./MarketDataSpotPrices"; -import type { VsCurrency } from "./VsCurrency"; +import type { MarketDataSpotPrices } from './MarketDataSpotPrices'; +import type { VsCurrency } from './VsCurrency'; export type GetV2SpotPricesPathParams = { - /** - * @description Decimal chain ID of the network to query. - * @type number - */ - chainId: number; + /** + * @description Decimal chain ID of the network to query. + * @type number + */ + chainId: number; }; export type GetV2SpotPricesQueryParams = { - /** - * @description Comma-separated token contract addresses to get prices for. - * @type string - */ - tokenAddresses: string; - /** - * @description A currency that prices can be denominated in. - * @default "usd" - * @type string | undefined - */ - vsCurrency?: VsCurrency; - /** - * @description Whether to include market data in the response. - * @default true - * @type boolean | undefined - */ - includeMarketData?: boolean; + /** + * @description Comma-separated token contract addresses to get prices for. + * @type string + */ + tokenAddresses: string; + /** + * @description A currency that prices can be denominated in. + * @default "usd" + * @type string | undefined + */ + vsCurrency?: VsCurrency; + /** + * @description Whether to include market data in the response. + * @default true + * @type boolean | undefined + */ + includeMarketData?: boolean; }; /** * @description Market data keyed by lowercased token contract address. -*/ + */ export type GetV2SpotPrices200 = MarketDataSpotPrices; export type GetV2SpotPricesQueryResponse = GetV2SpotPrices200; export type GetV2SpotPricesQuery = { - Response: GetV2SpotPrices200; - PathParams: GetV2SpotPricesPathParams; - QueryParams: GetV2SpotPricesQueryParams; - Errors: any; -}; \ No newline at end of file + Response: GetV2SpotPrices200; + PathParams: GetV2SpotPricesPathParams; + QueryParams: GetV2SpotPricesQueryParams; + Errors: any; +}; diff --git a/packages/core-backend/src/generated/price-api/types/GetV2SupportedNetworks.ts b/packages/core-backend/src/generated/price-api/types/GetV2SupportedNetworks.ts index 36eb59e40e..a7ce3c8916 100644 --- a/packages/core-backend/src/generated/price-api/types/GetV2SupportedNetworks.ts +++ b/packages/core-backend/src/generated/price-api/types/GetV2SupportedNetworks.ts @@ -1,18 +1,18 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { SupportedNetworks } from "./SupportedNetworks"; +import type { SupportedNetworks } from './SupportedNetworks'; /** * @description The supported networks, split by level of support. -*/ + */ export type GetV2SupportedNetworks200 = SupportedNetworks; export type GetV2SupportedNetworksQueryResponse = GetV2SupportedNetworks200; export type GetV2SupportedNetworksQuery = { - Response: GetV2SupportedNetworks200; - Errors: any; -}; \ No newline at end of file + Response: GetV2SupportedNetworks200; + Errors: any; +}; diff --git a/packages/core-backend/src/generated/price-api/types/GetV2TopTokens.ts b/packages/core-backend/src/generated/price-api/types/GetV2TopTokens.ts index 6f7ec6637a..d41b41b6b5 100644 --- a/packages/core-backend/src/generated/price-api/types/GetV2TopTokens.ts +++ b/packages/core-backend/src/generated/price-api/types/GetV2TopTokens.ts @@ -1,46 +1,46 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { TopToken } from "./TopToken"; -import type { VsCurrency } from "./VsCurrency"; +import type { TopToken } from './TopToken'; +import type { VsCurrency } from './VsCurrency'; export type GetV2TopTokensPathParams = { - /** - * @description Decimal chain ID of the network to query. - * @type number - */ - chainId: number; + /** + * @description Decimal chain ID of the network to query. + * @type number + */ + chainId: number; }; export type GetV2TopTokensQueryParams = { - /** - * @description Maximum number of tokens to return. - * @minLength 1 - * @maxLength 300 - * @default 100 - * @type number | undefined - */ - limit?: number; - /** - * @description A currency that prices can be denominated in. - * @default "usd" - * @type string | undefined - */ - vsCurrency?: VsCurrency; + /** + * @description Maximum number of tokens to return. + * @minLength 1 + * @maxLength 300 + * @default 100 + * @type number | undefined + */ + limit?: number; + /** + * @description A currency that prices can be denominated in. + * @default "usd" + * @type string | undefined + */ + vsCurrency?: VsCurrency; }; /** * @description The top tokens ordered by market cap. -*/ + */ export type GetV2TopTokens200 = TopToken[]; export type GetV2TopTokensQueryResponse = GetV2TopTokens200; export type GetV2TopTokensQuery = { - Response: GetV2TopTokens200; - PathParams: GetV2TopTokensPathParams; - QueryParams: GetV2TopTokensQueryParams; - Errors: any; -}; \ No newline at end of file + Response: GetV2TopTokens200; + PathParams: GetV2TopTokensPathParams; + QueryParams: GetV2TopTokensQueryParams; + Errors: any; +}; diff --git a/packages/core-backend/src/generated/price-api/types/GetV3HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/types/GetV3HistoricalPrices.ts index 081693a932..67b5cf093a 100644 --- a/packages/core-backend/src/generated/price-api/types/GetV3HistoricalPrices.ts +++ b/packages/core-backend/src/generated/price-api/types/GetV3HistoricalPrices.ts @@ -1,71 +1,72 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { V3HistoricalPrices } from "./V3HistoricalPrices"; -import type { VsCurrency } from "./VsCurrency"; +import type { V3HistoricalPrices } from './V3HistoricalPrices'; +import type { VsCurrency } from './VsCurrency'; export type GetV3HistoricalPricesPathParams = { - /** - * @description CAIP-2 chain ID of the network to query (e.g. eip155:1). - * @type string - */ - chainId: string; - /** - * @description Asset type portion of the CAIP-19 asset ID (e.g. slip44:60). - * @type string - */ - assetType: string; + /** + * @description CAIP-2 chain ID of the network to query (e.g. eip155:1). + * @type string + */ + chainId: string; + /** + * @description Asset type portion of the CAIP-19 asset ID (e.g. slip44:60). + * @type string + */ + assetType: string; }; export const getV3HistoricalPricesQueryParamsIntervalEnum = { - "5m": "5m", - hourly: "hourly", - daily: "daily" + '5m': '5m', + hourly: 'hourly', + daily: 'daily', } as const; -export type GetV3HistoricalPricesQueryParamsIntervalEnumKey = (typeof getV3HistoricalPricesQueryParamsIntervalEnum)[keyof typeof getV3HistoricalPricesQueryParamsIntervalEnum]; +export type GetV3HistoricalPricesQueryParamsIntervalEnumKey = + (typeof getV3HistoricalPricesQueryParamsIntervalEnum)[keyof typeof getV3HistoricalPricesQueryParamsIntervalEnum]; export type GetV3HistoricalPricesQueryParams = { - /** - * @description A currency that prices can be denominated in. - * @default "usd" - * @type string | undefined - */ - vsCurrency?: VsCurrency; - /** - * @description Time period for the historical prices (e.g. 1d, 7d, 1m, 3m, 1y, 1000d). - * @type string | undefined - */ - timePeriod?: string; - /** - * @description Start of the time range as a Unix timestamp in seconds. - * @type number | undefined - */ - from?: number; - /** - * @description End of the time range as a Unix timestamp in seconds. - * @type number | undefined - */ - to?: number; - /** - * @description Data point interval. - * @type string | undefined - */ - interval?: GetV3HistoricalPricesQueryParamsIntervalEnumKey; + /** + * @description A currency that prices can be denominated in. + * @default "usd" + * @type string | undefined + */ + vsCurrency?: VsCurrency; + /** + * @description Time period for the historical prices (e.g. 1d, 7d, 1m, 3m, 1y, 1000d). + * @type string | undefined + */ + timePeriod?: string; + /** + * @description Start of the time range as a Unix timestamp in seconds. + * @type number | undefined + */ + from?: number; + /** + * @description End of the time range as a Unix timestamp in seconds. + * @type number | undefined + */ + to?: number; + /** + * @description Data point interval. + * @type string | undefined + */ + interval?: GetV3HistoricalPricesQueryParamsIntervalEnumKey; }; /** * @description The historical prices of the asset. -*/ + */ export type GetV3HistoricalPrices200 = V3HistoricalPrices; export type GetV3HistoricalPricesQueryResponse = GetV3HistoricalPrices200; export type GetV3HistoricalPricesQuery = { - Response: GetV3HistoricalPrices200; - PathParams: GetV3HistoricalPricesPathParams; - QueryParams: GetV3HistoricalPricesQueryParams; - Errors: any; -}; \ No newline at end of file + Response: GetV3HistoricalPrices200; + PathParams: GetV3HistoricalPricesPathParams; + QueryParams: GetV3HistoricalPricesQueryParams; + Errors: any; +}; diff --git a/packages/core-backend/src/generated/price-api/types/GetV3SpotPrices.ts b/packages/core-backend/src/generated/price-api/types/GetV3SpotPrices.ts index 4c5c31c129..c428420909 100644 --- a/packages/core-backend/src/generated/price-api/types/GetV3SpotPrices.ts +++ b/packages/core-backend/src/generated/price-api/types/GetV3SpotPrices.ts @@ -1,46 +1,46 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { V3SpotPrices } from "./V3SpotPrices"; -import type { VsCurrency } from "./VsCurrency"; +import type { V3SpotPrices } from './V3SpotPrices'; +import type { VsCurrency } from './VsCurrency'; export type GetV3SpotPricesQueryParams = { - /** - * @description Comma-separated CAIP-19 asset IDs to get prices for. - * @type string - */ - assetIds: string; - /** - * @description A currency that prices can be denominated in. - * @default "usd" - * @type string | undefined - */ - vsCurrency?: VsCurrency; - /** - * @description Whether to include market data in the response. - * @default false - * @type boolean | undefined - */ - includeMarketData?: boolean; - /** - * @description Whether to only return prices that are already cached. - * @default false - * @type boolean | undefined - */ - cacheOnly?: boolean; + /** + * @description Comma-separated CAIP-19 asset IDs to get prices for. + * @type string + */ + assetIds: string; + /** + * @description A currency that prices can be denominated in. + * @default "usd" + * @type string | undefined + */ + vsCurrency?: VsCurrency; + /** + * @description Whether to include market data in the response. + * @default false + * @type boolean | undefined + */ + includeMarketData?: boolean; + /** + * @description Whether to only return prices that are already cached. + * @default false + * @type boolean | undefined + */ + cacheOnly?: boolean; }; /** * @description Spot prices keyed by CAIP-19 asset ID. Unknown assets map to null. -*/ + */ export type GetV3SpotPrices200 = V3SpotPrices; export type GetV3SpotPricesQueryResponse = GetV3SpotPrices200; export type GetV3SpotPricesQuery = { - Response: GetV3SpotPrices200; - QueryParams: GetV3SpotPricesQueryParams; - Errors: any; -}; \ No newline at end of file + Response: GetV3SpotPrices200; + QueryParams: GetV3SpotPricesQueryParams; + Errors: any; +}; diff --git a/packages/core-backend/src/generated/price-api/types/HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/types/HistoricalPrices.ts index ca4680b3ea..7d4f390da7 100644 --- a/packages/core-backend/src/generated/price-api/types/HistoricalPrices.ts +++ b/packages/core-backend/src/generated/price-api/types/HistoricalPrices.ts @@ -1,17 +1,17 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { PricePoint } from "./PricePoint"; +import type { PricePoint } from './PricePoint'; /** * @description Historical prices for a token. -*/ + */ export type HistoricalPrices = { - /** - * @description Price data points. - * @type array - */ - prices: PricePoint[]; -}; \ No newline at end of file + /** + * @description Price data points. + * @type array + */ + prices: PricePoint[]; +}; diff --git a/packages/core-backend/src/generated/price-api/types/MarketData.ts b/packages/core-backend/src/generated/price-api/types/MarketData.ts index a76f9a45e1..8e80c5734d 100644 --- a/packages/core-backend/src/generated/price-api/types/MarketData.ts +++ b/packages/core-backend/src/generated/price-api/types/MarketData.ts @@ -1,106 +1,105 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ - + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ /** * @description Market data for a token, as returned by the v2 spot prices endpoint. -*/ + */ export type MarketData = { - /** - * @description Current price in the requested currency. - * @type number - */ - price: number; - /** - * @description Currency the price is denominated in. - * @type string - */ - currency: string; - /** - * @description 24h price change amount. - * @type number | undefined - */ - priceChange1d?: number; - /** - * @description 24h price change percentage. - * @type number | undefined - */ - pricePercentChange1d?: number; - /** - * @description 1h price change percentage. - * @type number | undefined - */ - pricePercentChange1h?: number; - /** - * @description 7d price change percentage. - * @type number | undefined - */ - pricePercentChange7d?: number; - /** - * @description 14d price change percentage. - * @type number | undefined - */ - pricePercentChange14d?: number; - /** - * @description 30d price change percentage. - * @type number | undefined - */ - pricePercentChange30d?: number; - /** - * @description 200d price change percentage. - * @type number | undefined - */ - pricePercentChange200d?: number; - /** - * @description 1y price change percentage. - * @type number | undefined - */ - pricePercentChange1y?: number; - /** - * @description Market capitalization. - * @type number | undefined - */ - marketCap?: number; - /** - * @description Market cap 24h change percentage. - * @type number | undefined - */ - marketCapPercentChange1d?: number; - /** - * @description All-time high price. - * @type number | undefined - */ - allTimeHigh?: number; - /** - * @description All-time low price. - * @type number | undefined - */ - allTimeLow?: number; - /** - * @description 24h high price. - * @type number | undefined - */ - high1d?: number; - /** - * @description 24h low price. - * @type number | undefined - */ - low1d?: number; - /** - * @description Total trading volume. - * @type number | undefined - */ - totalVolume?: number; - /** - * @description Circulating supply. - * @type number | undefined - */ - circulatingSupply?: number; - /** - * @description Fully diluted market cap. - * @type number | undefined - */ - dilutedMarketCap?: number; -}; \ No newline at end of file + /** + * @description Current price in the requested currency. + * @type number + */ + price: number; + /** + * @description Currency the price is denominated in. + * @type string + */ + currency: string; + /** + * @description 24h price change amount. + * @type number | undefined + */ + priceChange1d?: number; + /** + * @description 24h price change percentage. + * @type number | undefined + */ + pricePercentChange1d?: number; + /** + * @description 1h price change percentage. + * @type number | undefined + */ + pricePercentChange1h?: number; + /** + * @description 7d price change percentage. + * @type number | undefined + */ + pricePercentChange7d?: number; + /** + * @description 14d price change percentage. + * @type number | undefined + */ + pricePercentChange14d?: number; + /** + * @description 30d price change percentage. + * @type number | undefined + */ + pricePercentChange30d?: number; + /** + * @description 200d price change percentage. + * @type number | undefined + */ + pricePercentChange200d?: number; + /** + * @description 1y price change percentage. + * @type number | undefined + */ + pricePercentChange1y?: number; + /** + * @description Market capitalization. + * @type number | undefined + */ + marketCap?: number; + /** + * @description Market cap 24h change percentage. + * @type number | undefined + */ + marketCapPercentChange1d?: number; + /** + * @description All-time high price. + * @type number | undefined + */ + allTimeHigh?: number; + /** + * @description All-time low price. + * @type number | undefined + */ + allTimeLow?: number; + /** + * @description 24h high price. + * @type number | undefined + */ + high1d?: number; + /** + * @description 24h low price. + * @type number | undefined + */ + low1d?: number; + /** + * @description Total trading volume. + * @type number | undefined + */ + totalVolume?: number; + /** + * @description Circulating supply. + * @type number | undefined + */ + circulatingSupply?: number; + /** + * @description Fully diluted market cap. + * @type number | undefined + */ + dilutedMarketCap?: number; +}; diff --git a/packages/core-backend/src/generated/price-api/types/MarketDataSpotPrices.ts b/packages/core-backend/src/generated/price-api/types/MarketDataSpotPrices.ts index 202ee9b43c..73f3b06fe0 100644 --- a/packages/core-backend/src/generated/price-api/types/MarketDataSpotPrices.ts +++ b/packages/core-backend/src/generated/price-api/types/MarketDataSpotPrices.ts @@ -1,13 +1,13 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { MarketData } from "./MarketData"; +import type { MarketData } from './MarketData'; /** * @description Market data keyed by lowercased token contract address. -*/ + */ export type MarketDataSpotPrices = { - [key: string]: MarketData; -}; \ No newline at end of file + [key: string]: MarketData; +}; diff --git a/packages/core-backend/src/generated/price-api/types/PricePoint.ts b/packages/core-backend/src/generated/price-api/types/PricePoint.ts index 90a3382467..0b980dc993 100644 --- a/packages/core-backend/src/generated/price-api/types/PricePoint.ts +++ b/packages/core-backend/src/generated/price-api/types/PricePoint.ts @@ -1,13 +1,9 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ - + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ /** * @description A [timestamp, value] tuple. The timestamp is a Unix timestamp in milliseconds. -*/ -export type PricePoint = [ - number, - number -]; \ No newline at end of file + */ +export type PricePoint = [number, number]; diff --git a/packages/core-backend/src/generated/price-api/types/SupportedNetworks.ts b/packages/core-backend/src/generated/price-api/types/SupportedNetworks.ts index 33e280b8f2..3e4adf8b3f 100644 --- a/packages/core-backend/src/generated/price-api/types/SupportedNetworks.ts +++ b/packages/core-backend/src/generated/price-api/types/SupportedNetworks.ts @@ -1,21 +1,20 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ - + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ /** * @description Networks supported by the Price API, split by level of support. -*/ + */ export type SupportedNetworks = { - /** - * @description Chain IDs with full price support. - * @type array - */ - fullSupport: string[]; - /** - * @description Chain IDs with partial price support. - * @type array - */ - partialSupport: string[]; -}; \ No newline at end of file + /** + * @description Chain IDs with full price support. + * @type array + */ + fullSupport: string[]; + /** + * @description Chain IDs with partial price support. + * @type array + */ + partialSupport: string[]; +}; diff --git a/packages/core-backend/src/generated/price-api/types/TopToken.ts b/packages/core-backend/src/generated/price-api/types/TopToken.ts index 35946bf16e..b3296e37da 100644 --- a/packages/core-backend/src/generated/price-api/types/TopToken.ts +++ b/packages/core-backend/src/generated/price-api/types/TopToken.ts @@ -1,36 +1,35 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ - + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ /** * @description A token in the top tokens list. -*/ + */ export type TopToken = { - /** - * @description CAIP-19 asset ID of the token. - * @type string - */ - assetId: string; - /** - * @description Human-readable name of the token. - * @type string - */ - name: string; - /** - * @description Ticker symbol of the token. - * @type string - */ - symbol: string; - /** - * @description Current price in the requested currency. - * @type number - */ - price: number; - /** - * @description Market capitalization. - * @type number - */ - marketCap: number; -}; \ No newline at end of file + /** + * @description CAIP-19 asset ID of the token. + * @type string + */ + assetId: string; + /** + * @description Human-readable name of the token. + * @type string + */ + name: string; + /** + * @description Ticker symbol of the token. + * @type string + */ + symbol: string; + /** + * @description Current price in the requested currency. + * @type number + */ + price: number; + /** + * @description Market capitalization. + * @type number + */ + marketCap: number; +}; diff --git a/packages/core-backend/src/generated/price-api/types/V3HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/types/V3HistoricalPrices.ts index 2c2036ddea..ec6dc33f0e 100644 --- a/packages/core-backend/src/generated/price-api/types/V3HistoricalPrices.ts +++ b/packages/core-backend/src/generated/price-api/types/V3HistoricalPrices.ts @@ -1,27 +1,27 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { PricePoint } from "./PricePoint"; +import type { PricePoint } from './PricePoint'; /** * @description Historical prices, market caps and total volumes for a CAIP-19 asset. -*/ + */ export type V3HistoricalPrices = { - /** - * @description Price data points. - * @type array - */ - prices: PricePoint[]; - /** - * @description Market cap data points. - * @type array | undefined - */ - marketCaps?: PricePoint[]; - /** - * @description Total volume data points. - * @type array | undefined - */ - totalVolumes?: PricePoint[]; -}; \ No newline at end of file + /** + * @description Price data points. + * @type array + */ + prices: PricePoint[]; + /** + * @description Market cap data points. + * @type array | undefined + */ + marketCaps?: PricePoint[]; + /** + * @description Total volume data points. + * @type array | undefined + */ + totalVolumes?: PricePoint[]; +}; diff --git a/packages/core-backend/src/generated/price-api/types/V3SpotPrice.ts b/packages/core-backend/src/generated/price-api/types/V3SpotPrice.ts index afcd92f167..887ef62cd8 100644 --- a/packages/core-backend/src/generated/price-api/types/V3SpotPrice.ts +++ b/packages/core-backend/src/generated/price-api/types/V3SpotPrice.ts @@ -1,31 +1,30 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ - + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ /** * @description Spot price and optional market data for a CAIP-19 asset. -*/ + */ export type V3SpotPrice = { - /** - * @description Current price in the requested currency. - * @type number - */ - price: number; - /** - * @description 24h price change percentage. - * @type number | undefined - */ - pricePercentChange1d?: number; - /** - * @description Market capitalization. - * @type number | undefined - */ - marketCap?: number; - /** - * @description Total trading volume. - * @type number | undefined - */ - totalVolume?: number; -}; \ No newline at end of file + /** + * @description Current price in the requested currency. + * @type number + */ + price: number; + /** + * @description 24h price change percentage. + * @type number | undefined + */ + pricePercentChange1d?: number; + /** + * @description Market capitalization. + * @type number | undefined + */ + marketCap?: number; + /** + * @description Total trading volume. + * @type number | undefined + */ + totalVolume?: number; +}; diff --git a/packages/core-backend/src/generated/price-api/types/V3SpotPrices.ts b/packages/core-backend/src/generated/price-api/types/V3SpotPrices.ts index e586aec8e0..9164f40272 100644 --- a/packages/core-backend/src/generated/price-api/types/V3SpotPrices.ts +++ b/packages/core-backend/src/generated/price-api/types/V3SpotPrices.ts @@ -1,13 +1,13 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ -import type { V3SpotPrice } from "./V3SpotPrice"; +import type { V3SpotPrice } from './V3SpotPrice'; /** * @description Spot prices keyed by CAIP-19 asset ID. Assets without a known price map to null. -*/ + */ export type V3SpotPrices = { - [key: string]: (V3SpotPrice | null); -}; \ No newline at end of file + [key: string]: V3SpotPrice | null; +}; diff --git a/packages/core-backend/src/generated/price-api/types/VsCurrency.ts b/packages/core-backend/src/generated/price-api/types/VsCurrency.ts index 2260ec4832..b471f03b03 100644 --- a/packages/core-backend/src/generated/price-api/types/VsCurrency.ts +++ b/packages/core-backend/src/generated/price-api/types/VsCurrency.ts @@ -1,73 +1,73 @@ /** -* Generated by Kubb (https://kubb.dev/). -* Do not edit manually. -*/ - + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ export const vsCurrencyEnum = { - btc: "btc", - eth: "eth", - ltc: "ltc", - bch: "bch", - bnb: "bnb", - eos: "eos", - xrp: "xrp", - xlm: "xlm", - link: "link", - dot: "dot", - yfi: "yfi", - usd: "usd", - aed: "aed", - ars: "ars", - aud: "aud", - bdt: "bdt", - bhd: "bhd", - bmd: "bmd", - brl: "brl", - cad: "cad", - chf: "chf", - clp: "clp", - cny: "cny", - czk: "czk", - dkk: "dkk", - eur: "eur", - gbp: "gbp", - gel: "gel", - hkd: "hkd", - huf: "huf", - idr: "idr", - ils: "ils", - inr: "inr", - jpy: "jpy", - krw: "krw", - kwd: "kwd", - lkr: "lkr", - mmk: "mmk", - mxn: "mxn", - myr: "myr", - ngn: "ngn", - nok: "nok", - nzd: "nzd", - php: "php", - pkr: "pkr", - pln: "pln", - rub: "rub", - sar: "sar", - sek: "sek", - sgd: "sgd", - thb: "thb", - try: "try", - twd: "twd", - uah: "uah", - vef: "vef", - vnd: "vnd", - zar: "zar" + btc: 'btc', + eth: 'eth', + ltc: 'ltc', + bch: 'bch', + bnb: 'bnb', + eos: 'eos', + xrp: 'xrp', + xlm: 'xlm', + link: 'link', + dot: 'dot', + yfi: 'yfi', + usd: 'usd', + aed: 'aed', + ars: 'ars', + aud: 'aud', + bdt: 'bdt', + bhd: 'bhd', + bmd: 'bmd', + brl: 'brl', + cad: 'cad', + chf: 'chf', + clp: 'clp', + cny: 'cny', + czk: 'czk', + dkk: 'dkk', + eur: 'eur', + gbp: 'gbp', + gel: 'gel', + hkd: 'hkd', + huf: 'huf', + idr: 'idr', + ils: 'ils', + inr: 'inr', + jpy: 'jpy', + krw: 'krw', + kwd: 'kwd', + lkr: 'lkr', + mmk: 'mmk', + mxn: 'mxn', + myr: 'myr', + ngn: 'ngn', + nok: 'nok', + nzd: 'nzd', + php: 'php', + pkr: 'pkr', + pln: 'pln', + rub: 'rub', + sar: 'sar', + sek: 'sek', + sgd: 'sgd', + thb: 'thb', + try: 'try', + twd: 'twd', + uah: 'uah', + vef: 'vef', + vnd: 'vnd', + zar: 'zar', } as const; -export type VsCurrencyEnumKey = (typeof vsCurrencyEnum)[keyof typeof vsCurrencyEnum]; +export type VsCurrencyEnumKey = + (typeof vsCurrencyEnum)[keyof typeof vsCurrencyEnum]; /** * @description A currency that prices can be denominated in. * @default usd -*/ -export type VsCurrency = VsCurrencyEnumKey; \ No newline at end of file + */ +export type VsCurrency = VsCurrencyEnumKey; diff --git a/packages/core-backend/src/generated/price-api/types/index.ts b/packages/core-backend/src/generated/price-api/types/index.ts index 0209fc7e56..84c0376d0b 100644 --- a/packages/core-backend/src/generated/price-api/types/index.ts +++ b/packages/core-backend/src/generated/price-api/types/index.ts @@ -1,28 +1,89 @@ -export type { CoinGeckoSpotPrice } from "./CoinGeckoSpotPrice"; -export type { CoinGeckoSpotPrices } from "./CoinGeckoSpotPrices"; -export type { ExchangeRateInfo, ExchangeRateInfoCurrencyTypeEnumKey } from "./ExchangeRateInfo"; -export type { ExchangeRates } from "./ExchangeRates"; -export type { GetV1ExchangeRates200, GetV1ExchangeRatesQuery, GetV1ExchangeRatesQueryParams, GetV1ExchangeRatesQueryResponse } from "./GetV1ExchangeRates"; -export type { GetV1FiatExchangeRates200, GetV1FiatExchangeRatesQuery, GetV1FiatExchangeRatesQueryResponse } from "./GetV1FiatExchangeRates"; -export type { GetV1HistoricalPrices200, GetV1HistoricalPricesPathParams, GetV1HistoricalPricesQuery, GetV1HistoricalPricesQueryParams, GetV1HistoricalPricesQueryResponse } from "./GetV1HistoricalPrices"; -export type { GetV1SpotPriceByCoinId200, GetV1SpotPriceByCoinIdPathParams, GetV1SpotPriceByCoinIdQuery, GetV1SpotPriceByCoinIdQueryParams, GetV1SpotPriceByCoinIdQueryResponse } from "./GetV1SpotPriceByCoinId"; -export type { GetV1SpotPricesByCoinIds200, GetV1SpotPricesByCoinIdsQuery, GetV1SpotPricesByCoinIdsQueryParams, GetV1SpotPricesByCoinIdsQueryResponse } from "./GetV1SpotPricesByCoinIds"; -export type { GetV1SupportedNetworks200, GetV1SupportedNetworksQuery, GetV1SupportedNetworksQueryResponse } from "./GetV1SupportedNetworks"; -export type { GetV2SpotPrices200, GetV2SpotPricesPathParams, GetV2SpotPricesQuery, GetV2SpotPricesQueryParams, GetV2SpotPricesQueryResponse } from "./GetV2SpotPrices"; -export type { GetV2SupportedNetworks200, GetV2SupportedNetworksQuery, GetV2SupportedNetworksQueryResponse } from "./GetV2SupportedNetworks"; -export type { GetV2TopTokens200, GetV2TopTokensPathParams, GetV2TopTokensQuery, GetV2TopTokensQueryParams, GetV2TopTokensQueryResponse } from "./GetV2TopTokens"; -export type { GetV3HistoricalPrices200, GetV3HistoricalPricesPathParams, GetV3HistoricalPricesQuery, GetV3HistoricalPricesQueryParams, GetV3HistoricalPricesQueryParamsIntervalEnumKey, GetV3HistoricalPricesQueryResponse } from "./GetV3HistoricalPrices"; -export type { GetV3SpotPrices200, GetV3SpotPricesQuery, GetV3SpotPricesQueryParams, GetV3SpotPricesQueryResponse } from "./GetV3SpotPrices"; -export type { HistoricalPrices } from "./HistoricalPrices"; -export type { MarketData } from "./MarketData"; -export type { MarketDataSpotPrices } from "./MarketDataSpotPrices"; -export type { PricePoint } from "./PricePoint"; -export type { SupportedNetworks } from "./SupportedNetworks"; -export type { TopToken } from "./TopToken"; -export type { V3HistoricalPrices } from "./V3HistoricalPrices"; -export type { V3SpotPrice } from "./V3SpotPrice"; -export type { V3SpotPrices } from "./V3SpotPrices"; -export type { VsCurrency, VsCurrencyEnumKey } from "./VsCurrency"; -export { exchangeRateInfoCurrencyTypeEnum } from "./ExchangeRateInfo"; -export { getV3HistoricalPricesQueryParamsIntervalEnum } from "./GetV3HistoricalPrices"; -export { vsCurrencyEnum } from "./VsCurrency"; \ No newline at end of file +export type { CoinGeckoSpotPrice } from './CoinGeckoSpotPrice'; +export type { CoinGeckoSpotPrices } from './CoinGeckoSpotPrices'; +export type { + ExchangeRateInfo, + ExchangeRateInfoCurrencyTypeEnumKey, +} from './ExchangeRateInfo'; +export type { ExchangeRates } from './ExchangeRates'; +export type { + GetV1ExchangeRates200, + GetV1ExchangeRatesQuery, + GetV1ExchangeRatesQueryParams, + GetV1ExchangeRatesQueryResponse, +} from './GetV1ExchangeRates'; +export type { + GetV1FiatExchangeRates200, + GetV1FiatExchangeRatesQuery, + GetV1FiatExchangeRatesQueryResponse, +} from './GetV1FiatExchangeRates'; +export type { + GetV1HistoricalPrices200, + GetV1HistoricalPricesPathParams, + GetV1HistoricalPricesQuery, + GetV1HistoricalPricesQueryParams, + GetV1HistoricalPricesQueryResponse, +} from './GetV1HistoricalPrices'; +export type { + GetV1SpotPriceByCoinId200, + GetV1SpotPriceByCoinIdPathParams, + GetV1SpotPriceByCoinIdQuery, + GetV1SpotPriceByCoinIdQueryParams, + GetV1SpotPriceByCoinIdQueryResponse, +} from './GetV1SpotPriceByCoinId'; +export type { + GetV1SpotPricesByCoinIds200, + GetV1SpotPricesByCoinIdsQuery, + GetV1SpotPricesByCoinIdsQueryParams, + GetV1SpotPricesByCoinIdsQueryResponse, +} from './GetV1SpotPricesByCoinIds'; +export type { + GetV1SupportedNetworks200, + GetV1SupportedNetworksQuery, + GetV1SupportedNetworksQueryResponse, +} from './GetV1SupportedNetworks'; +export type { + GetV2SpotPrices200, + GetV2SpotPricesPathParams, + GetV2SpotPricesQuery, + GetV2SpotPricesQueryParams, + GetV2SpotPricesQueryResponse, +} from './GetV2SpotPrices'; +export type { + GetV2SupportedNetworks200, + GetV2SupportedNetworksQuery, + GetV2SupportedNetworksQueryResponse, +} from './GetV2SupportedNetworks'; +export type { + GetV2TopTokens200, + GetV2TopTokensPathParams, + GetV2TopTokensQuery, + GetV2TopTokensQueryParams, + GetV2TopTokensQueryResponse, +} from './GetV2TopTokens'; +export type { + GetV3HistoricalPrices200, + GetV3HistoricalPricesPathParams, + GetV3HistoricalPricesQuery, + GetV3HistoricalPricesQueryParams, + GetV3HistoricalPricesQueryParamsIntervalEnumKey, + GetV3HistoricalPricesQueryResponse, +} from './GetV3HistoricalPrices'; +export type { + GetV3SpotPrices200, + GetV3SpotPricesQuery, + GetV3SpotPricesQueryParams, + GetV3SpotPricesQueryResponse, +} from './GetV3SpotPrices'; +export type { HistoricalPrices } from './HistoricalPrices'; +export type { MarketData } from './MarketData'; +export type { MarketDataSpotPrices } from './MarketDataSpotPrices'; +export type { PricePoint } from './PricePoint'; +export type { SupportedNetworks } from './SupportedNetworks'; +export type { TopToken } from './TopToken'; +export type { V3HistoricalPrices } from './V3HistoricalPrices'; +export type { V3SpotPrice } from './V3SpotPrice'; +export type { V3SpotPrices } from './V3SpotPrices'; +export type { VsCurrency, VsCurrencyEnumKey } from './VsCurrency'; +export { exchangeRateInfoCurrencyTypeEnum } from './ExchangeRateInfo'; +export { getV3HistoricalPricesQueryParamsIntervalEnum } from './GetV3HistoricalPrices'; +export { vsCurrencyEnum } from './VsCurrency'; diff --git a/yarn.config.cjs b/yarn.config.cjs index 9c8b14ac4f..4d47bb91f2 100644 --- a/yarn.config.cjs +++ b/yarn.config.cjs @@ -139,8 +139,23 @@ module.exports = defineConfig({ // All non-root packages must have a "build" script. All packages that // do not exclusively deploy documentation sites must use `ts-bridge`. + // @metamask/core-backend prepends Kubb code generation to its build + // scripts so the generated API bindings are refreshed before + // compiling. if (DOCSITE_PACKAGES.includes(workspace.ident)) { expectWorkspaceField(workspace, 'scripts.build'); + } else if (workspace.ident === '@metamask/core-backend') { + expectWorkspaceField( + workspace, + 'scripts.build', + 'yarn codegen && ts-bridge --project tsconfig.build.json --verbose --clean --no-references', + ); + + expectWorkspaceField( + workspace, + 'scripts.build:all', + 'yarn codegen && ts-bridge --project tsconfig.build.json --verbose --clean', + ); } else { expectWorkspaceField( workspace, diff --git a/yarn.lock b/yarn.lock index 131ae3705c..32405908d9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5491,7 +5491,7 @@ __metadata: languageName: node linkType: hard -"@kubb/fabric-core@npm:0.14.0": +"@kubb/fabric-core@npm:0.14.0, @kubb/fabric-core@npm:^0.14.0": version: 0.14.0 resolution: "@kubb/fabric-core@npm:0.14.0" dependencies: @@ -5503,7 +5503,7 @@ __metadata: languageName: node linkType: hard -"@kubb/oas@npm:4.39.2": +"@kubb/oas@npm:4.39.2, @kubb/oas@npm:^4.39.2": version: 4.39.2 resolution: "@kubb/oas@npm:4.39.2" dependencies: @@ -6621,6 +6621,8 @@ __metadata: "@faker-js/faker": "npm:^9.9.0" "@kubb/cli": "npm:^4.39.2" "@kubb/core": "npm:^4.39.2" + "@kubb/fabric-core": "npm:^0.14.0" + "@kubb/oas": "npm:^4.39.2" "@kubb/plugin-faker": "npm:^4.39.2" "@kubb/plugin-msw": "npm:^4.39.2" "@kubb/plugin-oas": "npm:^4.39.2" @@ -6631,7 +6633,7 @@ __metadata: "@metamask/keyring-controller": "npm:^27.1.0" "@metamask/messenger": "npm:^2.0.0" "@metamask/profile-sync-controller": "npm:^28.2.0" - "@metamask/superstruct": "npm:^3.3.0" + "@metamask/superstruct": "npm:^3.1.0" "@metamask/utils": "npm:^11.11.0" "@tanstack/query-core": "npm:^5.62.16" "@ts-bridge/cli": "npm:^0.6.4" @@ -6649,7 +6651,7 @@ __metadata: uuid: "npm:^8.3.2" peerDependencies: "@faker-js/faker": ^9.9.0 - msw: ^2.14.6 + msw: ^2.0.0 peerDependenciesMeta: "@faker-js/faker": optional: true @@ -19302,18 +19304,7 @@ __metadata: languageName: node linkType: hard -"js-yaml@npm:^4.1.0": - version: 4.1.0 - resolution: "js-yaml@npm:4.1.0" - dependencies: - argparse: "npm:^2.0.1" - bin: - js-yaml: bin/js-yaml.js - checksum: 10/c138a34a3fd0d08ebaf71273ad4465569a483b8a639e0b118ff65698d257c2791d3199e3f303631f2cb98213fa7b5f5d6a4621fd0fff819421b990d30d967140 - languageName: node - linkType: hard - -"js-yaml@npm:^4.2.0": +"js-yaml@npm:^4.1.0, js-yaml@npm:^4.2.0": version: 4.3.0 resolution: "js-yaml@npm:4.3.0" dependencies: @@ -24642,16 +24633,7 @@ __metadata: languageName: node linkType: hard -"semver@npm:^7.1.1, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.3, semver@npm:^7.7.3, semver@npm:^7.8.1": - version: 7.8.2 - resolution: "semver@npm:7.8.2" - bin: - semver: bin/semver.js - checksum: 10/52221d8f1cadacda3cc3f0a2e7f7146e0442c7f4219acb25970bed055f5d0a6afbba5f22e293b078c2e93fca3dce0a08b088485e8b75d32a165f16c3627091c8 - languageName: node - linkType: hard - -"semver@npm:^7.8.2": +"semver@npm:^7.1.1, semver@npm:^7.3.5, semver@npm:^7.3.7, semver@npm:^7.5.3, semver@npm:^7.5.4, semver@npm:^7.6.3, semver@npm:^7.7.3, semver@npm:^7.8.1, semver@npm:^7.8.2": version: 7.8.5 resolution: "semver@npm:7.8.5" bin: @@ -24829,20 +24811,13 @@ __metadata: languageName: node linkType: hard -"shell-quote@npm:^1.6.1": +"shell-quote@npm:^1.6.1, shell-quote@npm:^1.8.3": version: 1.9.0 resolution: "shell-quote@npm:1.9.0" checksum: 10/c3bc91e74a469c4f96b6fd13b0c777fff16bcbda202692a4e5402d3d6b78fc6e02fe92fdf8dc0bddf992a9c6758e43207bfc5bdbefbf8a58190b1c885cbcc171 languageName: node linkType: hard -"shell-quote@npm:^1.8.3": - version: 1.8.4 - resolution: "shell-quote@npm:1.8.4" - checksum: 10/a3e3796385f2cd5cf0b78207a4439f0c7395c0833fc75b2473084b5d298c109c5c0fa687fcd1c04e4b4484866e5bb8eaae7efae443b80fff71ea7e29baf11f0c - languageName: node - linkType: hard - "shiki@npm:^0.14.7": version: 0.14.7 resolution: "shiki@npm:0.14.7" From 0c5bcf68318e68b7b7d4ff343600c8341de3209a Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 9 Jul 2026 12:27:21 +0000 Subject: [PATCH 3/5] feat(core-backend): export request-client contract, add changelog entry - Export ApiRequestClient / ApiRequestArgs and PricesApiRequestClient from the package root - Add changelog entries for the generated Price API bindings, mocks entry point and request client Co-authored-by: Prithpal Sooriya --- packages/core-backend/CHANGELOG.md | 9 +++++++++ packages/core-backend/src/api/index.ts | 5 ++++- packages/core-backend/src/api/prices/index.ts | 1 + packages/core-backend/src/index.ts | 4 ++++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/packages/core-backend/CHANGELOG.md b/packages/core-backend/CHANGELOG.md index 93ba11b934..dafc125729 100644 --- a/packages/core-backend/CHANGELOG.md +++ b/packages/core-backend/CHANGELOG.md @@ -7,6 +7,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- Add generated Price API bindings under the new `@metamask/core-backend/price-api` entry point, produced from the API's OpenAPI document by Kubb with a custom `@metamask/superstruct` plugin ([#9446](https://github.com/MetaMask/core/pull/9446)) + - TypeScript types (e.g. `GetV3SpotPricesQueryResponse`), `@metamask/superstruct` structs (e.g. `GetV3SpotPricesQueryResponseStruct`), and TanStack query-core bindings (e.g. `getV3SpotPricesQueryOptions`, `fetchV3SpotPrices`) that validate responses against the generated structs +- Add generated Price API test mocks under the new `@metamask/core-backend/mocks` entry point ([#9446](https://github.com/MetaMask/core/pull/9446)) + - Faker-based mock data builders (e.g. `createCoinGeckoSpotPrice`) and MSW request handlers (e.g. `getV3SpotPricesHandler`, `handlers`) + - Using the mocks requires the new optional peer dependencies `@faker-js/faker` (`^9.9.0`) and `msw` (`^2.0.0`) +- Add `ApiRequestClient` contract (with `ApiRequestArgs`) and `PricesApiRequestClient`, an implementation backed by the shared `BaseApiClient` transport for use with the generated query-core bindings ([#9446](https://github.com/MetaMask/core/pull/9446)) + ### Changed - Bump `@metamask/messenger` from `^1.2.0` to `^2.0.0` ([#9392](https://github.com/MetaMask/core/pull/9392)) diff --git a/packages/core-backend/src/api/index.ts b/packages/core-backend/src/api/index.ts index 02c01b9838..5d4c23f67a 100644 --- a/packages/core-backend/src/api/index.ts +++ b/packages/core-backend/src/api/index.ts @@ -50,8 +50,11 @@ export type { V2TokensResponse, } from './accounts'; +// Query runtime for generated query-core bindings +export type { ApiRequestArgs, ApiRequestClient } from './query-runtime'; + // Prices API -export { PricesApiClient } from './prices'; +export { PricesApiClient, PricesApiRequestClient } from './prices'; export type { V3SpotPricesResponse, CoinGeckoSpotPrice, diff --git a/packages/core-backend/src/api/prices/index.ts b/packages/core-backend/src/api/prices/index.ts index ca41dab519..0a1aa42635 100644 --- a/packages/core-backend/src/api/prices/index.ts +++ b/packages/core-backend/src/api/prices/index.ts @@ -3,6 +3,7 @@ */ export { PricesApiClient } from './client'; +export { PricesApiRequestClient } from './query-client'; export type { V3SpotPricesResponse, CoinGeckoSpotPrice, diff --git a/packages/core-backend/src/index.ts b/packages/core-backend/src/index.ts index f88d719373..940183ab0d 100644 --- a/packages/core-backend/src/index.ts +++ b/packages/core-backend/src/index.ts @@ -115,6 +115,7 @@ export { // Individual API clients AccountsApiClient, PricesApiClient, + PricesApiRequestClient, TokenApiClient, TokensApiClient, // Constants @@ -137,6 +138,9 @@ export type { // Client options ApiPlatformClientOptions, FetchOptions, + // Query runtime for generated query-core bindings + ApiRequestArgs, + ApiRequestClient, // Shared types PageInfo, SupportedCurrency, From 876ffa2a97e036761f1a804fb537247b17d0cd40 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 9 Jul 2026 12:46:05 +0000 Subject: [PATCH 4/5] refactor(core-backend): drop @kubb/cli, run Kubb programmatically via tsx Replaces the @kubb/cli invocation with a small tsx runner (codegen/run.ts) that imports the Kubb config directly and calls safeBuild from @kubb/core. This removes @kubb/cli and its extra dependency surface (config discovery, jiti config loading, subprocess runner) from the lockfile, addressing the Socket Security alerts that targeted @kubb/cli itself. Generated output is unchanged. Co-authored-by: Prithpal Sooriya --- knip.config.ts | 6 +- packages/core-backend/codegen/kubb.config.ts | 3 +- packages/core-backend/codegen/run.ts | 43 +++++++++++++ packages/core-backend/package.json | 3 +- yarn.lock | 63 +------------------- 5 files changed, 51 insertions(+), 67 deletions(-) create mode 100644 packages/core-backend/codegen/run.ts diff --git a/knip.config.ts b/knip.config.ts index ced3c05c10..1c322dadc7 100644 --- a/knip.config.ts +++ b/knip.config.ts @@ -72,9 +72,9 @@ const config: KnipConfig = { }, 'packages/core-backend': { // Scan the Kubb code generation tooling (`codegen/`) next to `src/` so - // the `@kubb/*` devDependencies used by `kubb.config.ts` and the custom - // plugins are seen. - entry: ['codegen/kubb.config.ts'], + // the `@kubb/*` devDependencies used by the codegen runner and the + // custom plugins are seen. + entry: ['codegen/run.ts'], project: ['src/**/*.ts', 'codegen/**/*.ts'], ignoreDependencies: ['@metamask/keyring-internal-api'], }, diff --git a/packages/core-backend/codegen/kubb.config.ts b/packages/core-backend/codegen/kubb.config.ts index 6f97866ba6..37decb3bda 100644 --- a/packages/core-backend/codegen/kubb.config.ts +++ b/packages/core-backend/codegen/kubb.config.ts @@ -18,7 +18,8 @@ import { pluginSuperstruct } from './kubb-plugin-superstruct'; * - `msw/` MSW request handlers (@kubb/plugin-msw) * - `queries/` TanStack query-core bindings (codegen/kubb-plugin-query-core) * - * Run with `yarn workspace @metamask/core-backend run codegen`. + * Run with `yarn workspace @metamask/core-backend run codegen`, which + * executes this config through `codegen/run.ts`. */ export default defineConfig({ name: 'price-api', diff --git a/packages/core-backend/codegen/run.ts b/packages/core-backend/codegen/run.ts new file mode 100644 index 0000000000..6ec9accdc8 --- /dev/null +++ b/packages/core-backend/codegen/run.ts @@ -0,0 +1,43 @@ +/** + * Runs Kubb code generation programmatically via `safeBuild` from + * `@kubb/core`, instead of through `@kubb/cli`. + * + * Invoking the build API directly keeps the dependency tree slimmer (no CLI, + * config discovery, TS config loader or subprocess runner) — the config is a + * regular TypeScript module imported below, and this script is executed with + * `tsx` as part of `yarn codegen` (see `package.json`). + */ + +import { safeBuild } from '@kubb/core'; +import process from 'node:process'; + +import config from './kubb.config'; + +/** + * Runs the Kubb build and reports the outcome. + */ +async function main(): Promise { + console.log(`Generating ${config.name ?? 'API bindings'} with Kubb...`); + + const { files, failedPlugins, error } = await safeBuild({ config }); + + for (const failedPlugin of failedPlugins) { + console.error( + `Plugin ${failedPlugin.plugin.name} failed:`, + failedPlugin.error, + ); + } + if (error) { + throw error; + } + if (failedPlugins.size > 0) { + throw new Error(`${failedPlugins.size} Kubb plugin(s) failed`); + } + + console.log(`Generated ${files.length} files in ${config.output.path}`); +} + +main().catch((error) => { + console.error(error); + process.exitCode = 1; +}); diff --git a/packages/core-backend/package.json b/packages/core-backend/package.json index 7df563a6cf..b3207b21a9 100644 --- a/packages/core-backend/package.json +++ b/packages/core-backend/package.json @@ -64,7 +64,7 @@ "build:docs": "typedoc", "changelog:update": "../../scripts/update-changelog.sh @metamask/core-backend", "changelog:validate": "../../scripts/validate-changelog.sh @metamask/core-backend", - "codegen": "kubb generate --config codegen/kubb.config.ts && node codegen/annotate-msw-handlers.mjs && yarn run -T oxfmt src/generated", + "codegen": "tsx codegen/run.ts && node codegen/annotate-msw-handlers.mjs && yarn run -T oxfmt src/generated", "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --check", "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --generate", "since-latest-release": "../../scripts/since-latest-release.sh", @@ -87,7 +87,6 @@ }, "devDependencies": { "@faker-js/faker": "^9.9.0", - "@kubb/cli": "^4.39.2", "@kubb/core": "^4.39.2", "@kubb/fabric-core": "^0.14.0", "@kubb/oas": "^4.39.2", diff --git a/yarn.lock b/yarn.lock index 32405908d9..43684f1e21 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1725,7 +1725,7 @@ __metadata: languageName: node linkType: hard -"@clack/prompts@npm:^1.1.0, @clack/prompts@npm:^1.5.1": +"@clack/prompts@npm:^1.1.0": version: 1.7.0 resolution: "@clack/prompts@npm:1.7.0" dependencies: @@ -5456,22 +5456,6 @@ __metadata: languageName: node linkType: hard -"@kubb/cli@npm:^4.39.2": - version: 4.39.2 - resolution: "@kubb/cli@npm:4.39.2" - dependencies: - "@clack/prompts": "npm:^1.5.1" - "@kubb/core": "npm:4.39.2" - chokidar: "npm:^5.0.0" - cosmiconfig: "npm:^9.0.1" - jiti: "npm:2.5.1" - tinyexec: "npm:^1.2.4" - bin: - kubb: bin/kubb.cjs - checksum: 10/f6d988090ad42b5023f5f164ad4f278071d7175d31f911d2099b3cf6ec1efe8770b5e62d56ca822ec6831fadb46e4cc1b6f27758867aa1d79a7872ed3ba08d3d - languageName: node - linkType: hard - "@kubb/core@npm:4.39.2, @kubb/core@npm:^4.39.2": version: 4.39.2 resolution: "@kubb/core@npm:4.39.2" @@ -6619,7 +6603,6 @@ __metadata: resolution: "@metamask/core-backend@workspace:packages/core-backend" dependencies: "@faker-js/faker": "npm:^9.9.0" - "@kubb/cli": "npm:^4.39.2" "@kubb/core": "npm:^4.39.2" "@kubb/fabric-core": "npm:^0.14.0" "@kubb/oas": "npm:^4.39.2" @@ -13941,15 +13924,6 @@ __metadata: languageName: node linkType: hard -"chokidar@npm:^5.0.0": - version: 5.0.0 - resolution: "chokidar@npm:5.0.0" - dependencies: - readdirp: "npm:^5.0.0" - checksum: 10/a1c2a4ee6ee81ba6409712c295a47be055fb9de1186dfbab33c1e82f28619de962ba02fc5f9d433daaedc96c35747460d8b2079ac2907de2c95e3f7cce913113 - languageName: node - linkType: hard - "chownr@npm:^1.1.1": version: 1.1.4 resolution: "chownr@npm:1.1.4" @@ -14527,23 +14501,6 @@ __metadata: languageName: node linkType: hard -"cosmiconfig@npm:^9.0.1": - version: 9.0.2 - resolution: "cosmiconfig@npm:9.0.2" - dependencies: - env-paths: "npm:^2.2.1" - import-fresh: "npm:^3.3.0" - js-yaml: "npm:^4.1.0" - parse-json: "npm:^5.2.0" - peerDependencies: - typescript: ">=4.9.5" - peerDependenciesMeta: - typescript: - optional: true - checksum: 10/e7b08c9c6ed862852bf0ed88c8fa49c57276d976901c9332c87d831926f332c32df3f5ff6a87f3823c3b7c5d6f857a7fd34336e0c2c596fa2d73e6cccbb7bf58 - languageName: node - linkType: hard - "crc-32@npm:^1.2.0": version: 1.2.2 resolution: "crc-32@npm:1.2.2" @@ -15539,7 +15496,7 @@ __metadata: languageName: node linkType: hard -"env-paths@npm:^2.2.0, env-paths@npm:^2.2.1": +"env-paths@npm:^2.2.0": version: 2.2.1 resolution: "env-paths@npm:2.2.1" checksum: 10/65b5df55a8bab92229ab2b40dad3b387fad24613263d103a97f91c9fe43ceb21965cd3392b1ccb5d77088021e525c4e0481adb309625d0cb94ade1d1fb8dc17e @@ -19210,15 +19167,6 @@ __metadata: languageName: node linkType: hard -"jiti@npm:2.5.1": - version: 2.5.1 - resolution: "jiti@npm:2.5.1" - bin: - jiti: lib/jiti-cli.mjs - checksum: 10/699f94c5c4e8952019b8d412de63a2517ed1f9e8514e61058f67de378525ec82f39c69b2d34cdebb136be95805b87367e67d1195f87897c325e3019ed3329f00 - languageName: node - linkType: hard - "jiti@npm:^1.20.0": version: 1.21.7 resolution: "jiti@npm:1.21.7" @@ -23920,13 +23868,6 @@ __metadata: languageName: node linkType: hard -"readdirp@npm:^5.0.0": - version: 5.0.0 - resolution: "readdirp@npm:5.0.0" - checksum: 10/a17a591b51d8b912083660df159e8bd17305dc1a9ef27c869c818bd95ff59e3a6496f97e91e724ef433e789d559d24e39496ea1698822eb5719606dc9c1a923d - languageName: node - linkType: hard - "readdirp@npm:~3.6.0": version: 3.6.0 resolution: "readdirp@npm:3.6.0" From 52c3ef10b21368a301ba106cc5379d233921b9d9 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 9 Jul 2026 17:11:10 +0000 Subject: [PATCH 5/5] refactor(core-backend): align Kubb spike with the codegen ADR Aligns the spike with the 'Generate Runtime Schema Validation and Mocks from OpenAPI Specs' ADR (MetaMask/decisions#234) while keeping the DX extras (MSW handlers, query-core bindings) generated from the same pipeline: - Wire generated structs into the existing PricesApiClient response path behind assert() (ADR spike step 3): supported networks, exchange rates, v1/v2/v3 spot prices, v1 single-token and v3 historical prices now reject malformed responses with StructError; unknown additional fields are still tolerated. One drifted test fixture surfaced by validation was corrected. - Move the vendored spec to specs/price-api.json (ADR layout) and add the /v1/exchange-rates/crypto endpoint so all exchange-rate methods are validated. - Rename the struct output directory from schemas/ to structs/ (ADR naming). - Add a codegen:check script (regeneration-is-clean check per the ADR's committed-output constraint). - Add response-validation tests, including one that serves generated mock data through the client to prove mocks and structs stay in sync. Co-authored-by: Prithpal Sooriya --- packages/core-backend/CHANGELOG.md | 4 +- .../codegen/kubb-plugin-superstruct/plugin.ts | 2 +- .../codegen/kubb-plugin-superstruct/types.ts | 2 +- packages/core-backend/codegen/kubb.config.ts | 33 ++++-- packages/core-backend/package.json | 1 + .../{codegen/openapi => specs}/price-api.json | 22 +++- .../src/api/prices/client.test.ts | 75 ++++++++++++- .../core-backend/src/api/prices/client.ts | 102 ++++++++++++++---- .../src/api/prices/query-client.test.ts | 2 +- .../mocks/createGetV1CryptoExchangeRates.ts | 32 ++++++ .../src/generated/price-api/mocks/index.ts | 4 + .../msw/getV1CryptoExchangeRatesHandler.ts | 48 +++++++++ .../src/generated/price-api/msw/handlers.ts | 2 + .../src/generated/price-api/msw/index.ts | 4 + .../queries/getV1CryptoExchangeRates.ts | 66 ++++++++++++ .../price-api/queries/getV1ExchangeRates.ts | 2 +- .../queries/getV1FiatExchangeRates.ts | 2 +- .../queries/getV1HistoricalPrices.ts | 2 +- .../queries/getV1SpotPriceByCoinId.ts | 2 +- .../queries/getV1SpotPricesByCoinIds.ts | 2 +- .../queries/getV1SupportedNetworks.ts | 2 +- .../price-api/queries/getV2SpotPrices.ts | 2 +- .../queries/getV2SupportedNetworks.ts | 2 +- .../price-api/queries/getV2TopTokens.ts | 2 +- .../queries/getV3HistoricalPrices.ts | 2 +- .../price-api/queries/getV3SpotPrices.ts | 2 +- .../src/generated/price-api/queries/index.ts | 5 + .../coinGeckoSpotPriceStruct.ts | 0 .../coinGeckoSpotPricesStruct.ts | 0 .../exchangeRateInfoStruct.ts | 0 .../exchangeRatesStruct.ts | 0 .../structs/getV1CryptoExchangeRatesStruct.ts | 14 +++ .../getV1ExchangeRatesStruct.ts | 0 .../getV1FiatExchangeRatesStruct.ts | 0 .../getV1HistoricalPricesStruct.ts | 0 .../getV1SpotPriceByCoinIdStruct.ts | 0 .../getV1SpotPricesByCoinIdsStruct.ts | 0 .../getV1SupportedNetworksStruct.ts | 0 .../getV2SpotPricesStruct.ts | 0 .../getV2SupportedNetworksStruct.ts | 0 .../getV2TopTokensStruct.ts | 0 .../getV3HistoricalPricesStruct.ts | 0 .../getV3SpotPricesStruct.ts | 0 .../historicalPricesStruct.ts | 0 .../price-api/{schemas => structs}/index.ts | 4 + .../marketDataSpotPricesStruct.ts | 0 .../{schemas => structs}/marketDataStruct.ts | 0 .../{schemas => structs}/pricePointStruct.ts | 0 .../supportedNetworksStruct.ts | 0 .../{schemas => structs}/topTokenStruct.ts | 0 .../v3HistoricalPricesStruct.ts | 0 .../{schemas => structs}/v3SpotPriceStruct.ts | 0 .../v3SpotPricesStruct.ts | 0 .../{schemas => structs}/vsCurrencyStruct.ts | 0 .../types/GetV1CryptoExchangeRates.ts | 18 ++++ .../src/generated/price-api/types/index.ts | 5 + packages/core-backend/src/mocks/index.ts | 13 ++- packages/core-backend/src/price-api/index.ts | 12 +-- 58 files changed, 431 insertions(+), 61 deletions(-) rename packages/core-backend/{codegen/openapi => specs}/price-api.json (96%) create mode 100644 packages/core-backend/src/generated/price-api/mocks/createGetV1CryptoExchangeRates.ts create mode 100644 packages/core-backend/src/generated/price-api/msw/getV1CryptoExchangeRatesHandler.ts create mode 100644 packages/core-backend/src/generated/price-api/queries/getV1CryptoExchangeRates.ts rename packages/core-backend/src/generated/price-api/{schemas => structs}/coinGeckoSpotPriceStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/coinGeckoSpotPricesStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/exchangeRateInfoStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/exchangeRatesStruct.ts (100%) create mode 100644 packages/core-backend/src/generated/price-api/structs/getV1CryptoExchangeRatesStruct.ts rename packages/core-backend/src/generated/price-api/{schemas => structs}/getV1ExchangeRatesStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/getV1FiatExchangeRatesStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/getV1HistoricalPricesStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/getV1SpotPriceByCoinIdStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/getV1SpotPricesByCoinIdsStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/getV1SupportedNetworksStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/getV2SpotPricesStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/getV2SupportedNetworksStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/getV2TopTokensStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/getV3HistoricalPricesStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/getV3SpotPricesStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/historicalPricesStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/index.ts (95%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/marketDataSpotPricesStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/marketDataStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/pricePointStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/supportedNetworksStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/topTokenStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/v3HistoricalPricesStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/v3SpotPriceStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/v3SpotPricesStruct.ts (100%) rename packages/core-backend/src/generated/price-api/{schemas => structs}/vsCurrencyStruct.ts (100%) create mode 100644 packages/core-backend/src/generated/price-api/types/GetV1CryptoExchangeRates.ts diff --git a/packages/core-backend/CHANGELOG.md b/packages/core-backend/CHANGELOG.md index dafc125729..4805e86483 100644 --- a/packages/core-backend/CHANGELOG.md +++ b/packages/core-backend/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- Add generated Price API bindings under the new `@metamask/core-backend/price-api` entry point, produced from the API's OpenAPI document by Kubb with a custom `@metamask/superstruct` plugin ([#9446](https://github.com/MetaMask/core/pull/9446)) +- Add generated Price API bindings under the new `@metamask/core-backend/price-api` entry point, produced from a vendored OpenAPI spec snapshot (`specs/price-api.json`) by Kubb with a custom `@metamask/superstruct` plugin ([#9446](https://github.com/MetaMask/core/pull/9446)) - TypeScript types (e.g. `GetV3SpotPricesQueryResponse`), `@metamask/superstruct` structs (e.g. `GetV3SpotPricesQueryResponseStruct`), and TanStack query-core bindings (e.g. `getV3SpotPricesQueryOptions`, `fetchV3SpotPrices`) that validate responses against the generated structs - Add generated Price API test mocks under the new `@metamask/core-backend/mocks` entry point ([#9446](https://github.com/MetaMask/core/pull/9446)) - Faker-based mock data builders (e.g. `createCoinGeckoSpotPrice`) and MSW request handlers (e.g. `getV3SpotPricesHandler`, `handlers`) @@ -18,6 +18,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- `PricesApiClient` now validates responses against the generated `@metamask/superstruct` structs for the endpoints covered by the vendored Price API spec (supported networks, exchange rates, v1/v2/v3 spot prices, v1 single-token and v3 historical prices) ([#9446](https://github.com/MetaMask/core/pull/9446)) + - Malformed responses now reject with a `StructError` instead of being returned as-is; unknown additional fields are still tolerated - Bump `@metamask/messenger` from `^1.2.0` to `^2.0.0` ([#9392](https://github.com/MetaMask/core/pull/9392)) ## [6.5.0] diff --git a/packages/core-backend/codegen/kubb-plugin-superstruct/plugin.ts b/packages/core-backend/codegen/kubb-plugin-superstruct/plugin.ts index cc4aa5c9b8..ce9928ccfe 100644 --- a/packages/core-backend/codegen/kubb-plugin-superstruct/plugin.ts +++ b/packages/core-backend/codegen/kubb-plugin-superstruct/plugin.ts @@ -25,7 +25,7 @@ export const pluginSuperstructName = export const pluginSuperstruct = definePlugin( (options = {}) => { const { - output = { path: 'schemas', barrelType: 'named' }, + output = { path: 'structs', barrelType: 'named' }, group, exclude = [], include, diff --git a/packages/core-backend/codegen/kubb-plugin-superstruct/types.ts b/packages/core-backend/codegen/kubb-plugin-superstruct/types.ts index fed0623395..073e98a485 100644 --- a/packages/core-backend/codegen/kubb-plugin-superstruct/types.ts +++ b/packages/core-backend/codegen/kubb-plugin-superstruct/types.ts @@ -21,7 +21,7 @@ export type Options = { * Specify the export location for the files and define the behavior of the * output. * - * @default { path: 'schemas', barrelType: 'named' } + * @default { path: 'structs', barrelType: 'named' } */ output?: Output; /** diff --git a/packages/core-backend/codegen/kubb.config.ts b/packages/core-backend/codegen/kubb.config.ts index 37decb3bda..c002c8503d 100644 --- a/packages/core-backend/codegen/kubb.config.ts +++ b/packages/core-backend/codegen/kubb.config.ts @@ -10,13 +10,24 @@ import { pluginSuperstruct } from './kubb-plugin-superstruct'; /** * Kubb code generation for the Price API (https://price.api.cx.metamask.io). * - * Generates, from `codegen/openapi/price-api.json` into + * Generates, from the vendored spec snapshot `specs/price-api.json` into * `src/generated/price-api`: - * - `types/` TypeScript types (@kubb/plugin-ts) - * - `schemas/` @metamask/superstruct structs (codegen/kubb-plugin-superstruct) - * - `mocks/` Faker-based mock builders (@kubb/plugin-faker) - * - `msw/` MSW request handlers (@kubb/plugin-msw) - * - `queries/` TanStack query-core bindings (codegen/kubb-plugin-query-core) + * - `types/` TypeScript types (@kubb/plugin-ts) + * - `structs/` @metamask/superstruct structs (codegen/kubb-plugin-superstruct) + * - `mocks/` Faker-based mock data builders (@kubb/plugin-faker) + * - `msw/` MSW request handlers (@kubb/plugin-msw) + * - `queries/` TanStack query-core bindings (codegen/kubb-plugin-query-core) + * + * Per the "Generate Runtime Schema Validation and Mocks from OpenAPI Specs" + * ADR (MetaMask/decisions#234): + * - Generation always runs offline against the vendored snapshot — never a + * live URL (`yarn codegen:check` verifies regeneration is clean). + * - Types, structs and mock data are the core artifacts. The MSW handlers + * and query-core bindings are generated from the same pipeline as DX + * extras: the handlers serve seeded mock data for unit/integration tests + * (e2e can feed the same mock data into mockttp), and the query bindings + * preview the ADR's "Later" item (typed request functions/queryOptions). + * - `@tanstack/react-query` hooks are explicitly not generated. * * Run with `yarn workspace @metamask/core-backend run codegen`, which * executes this config through `codegen/run.ts`. @@ -27,14 +38,15 @@ export default defineConfig({ // when run through `yarn workspace @metamask/core-backend run codegen`. root: '.', input: { - path: './codegen/openapi/price-api.json', + // Vendored spec snapshot — never a live URL. + path: './specs/price-api.json', }, output: { path: './src/generated/price-api', clean: true, // No root barrel: the package's `./price-api` and `./mocks` entry points // (`src/price-api/index.ts` and `src/mocks/index.ts`) re-export the - // per-plugin barrels, keeping the msw/faker mocks out of the runtime + // per-plugin barrels, keeping the test-only mocks out of the runtime // entry point. barrelType: false, defaultBanner: 'simple', @@ -43,7 +55,8 @@ export default defineConfig({ extension: { '.ts': '', }, - // Formatting is handled by the repo's own tooling (`yarn lint:fix`). + // Formatting is handled by the repo's own tooling (`yarn codegen` runs + // oxfmt over the output). format: false, lint: false, }, @@ -67,7 +80,7 @@ export default defineConfig({ }), pluginSuperstruct({ output: { - path: 'schemas', + path: 'structs', barrelType: 'named', }, }), diff --git a/packages/core-backend/package.json b/packages/core-backend/package.json index b3207b21a9..9ffd8d7a0a 100644 --- a/packages/core-backend/package.json +++ b/packages/core-backend/package.json @@ -65,6 +65,7 @@ "changelog:update": "../../scripts/update-changelog.sh @metamask/core-backend", "changelog:validate": "../../scripts/validate-changelog.sh @metamask/core-backend", "codegen": "tsx codegen/run.ts && node codegen/annotate-msw-handlers.mjs && yarn run -T oxfmt src/generated", + "codegen:check": "yarn codegen && git diff --exit-code -- src/generated", "messenger-action-types:check": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --check", "messenger-action-types:generate": "tsx ../../packages/messenger-cli/src/cli.ts --formatter oxfmt --generate", "since-latest-release": "../../scripts/since-latest-release.sh", diff --git a/packages/core-backend/codegen/openapi/price-api.json b/packages/core-backend/specs/price-api.json similarity index 96% rename from packages/core-backend/codegen/openapi/price-api.json rename to packages/core-backend/specs/price-api.json index 67523d855e..50bb1682f9 100644 --- a/packages/core-backend/codegen/openapi/price-api.json +++ b/packages/core-backend/specs/price-api.json @@ -2,7 +2,7 @@ "openapi": "3.1.0", "info": { "title": "Price API", - "description": "MetaMask Price API. Provides spot prices, exchange rates, historical prices and market data for tokens across networks. This document is a curated subset of https://price.api.cx.metamask.io/docs-json, enriched with response schemas (the live document does not declare response DTOs for most endpoints).", + "description": "MetaMask Price API. Provides spot prices, exchange rates, historical prices and market data for tokens across networks. Vendored spec snapshot: a curated subset of https://price.api.cx.metamask.io/docs-json, enriched with response schemas because the live document does not declare response DTOs for most endpoints (a spec-quality gap that should be fixed upstream in the API's NestJS response decorators).", "version": "1.0.0", "contact": { "name": "MetaMask", @@ -123,6 +123,26 @@ } } }, + "/v1/exchange-rates/crypto": { + "get": { + "operationId": "getV1CryptoExchangeRates", + "summary": "Get crypto exchange rates", + "description": "Returns a list of exchange rates for all supported crypto currencies.", + "tags": ["Exchange Rates"], + "responses": { + "200": { + "description": "Exchange rates keyed by currency ticker.", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ExchangeRates" + } + } + } + } + } + } + }, "/v1/spot-prices": { "get": { "operationId": "getV1SpotPricesByCoinIds", diff --git a/packages/core-backend/src/api/prices/client.test.ts b/packages/core-backend/src/api/prices/client.test.ts index 80cf8c5f09..cdf1bb6f1c 100644 --- a/packages/core-backend/src/api/prices/client.test.ts +++ b/packages/core-backend/src/api/prices/client.test.ts @@ -2,6 +2,7 @@ * Prices API Client Tests - price.api.cx.metamask.io */ +import { createGetV1SupportedNetworksQueryResponse } from '../../generated/price-api/mocks'; import type { ApiPlatformClient } from '../ApiPlatformClient'; import { API_URLS } from '../shared-types'; import type { FetchOptions } from '../shared-types'; @@ -441,7 +442,10 @@ describe('PricesApiClient', () => { describe('Default Parameter Values', () => { it('uses default currency for fetchV1SpotPriceByCoinId', async () => { - const mockResponse = { ethereum: { usd: 2500 } }; + // Note: this fixture previously returned a shape the endpoint never + // produces ({ ethereum: { usd: 2500 } }); the generated struct + // validation surfaced the drift. + const mockResponse = { id: 'ethereum', price: 2500 }; mockFetch.mockResolvedValueOnce(createMockResponse(mockResponse)); await client.prices.fetchV1SpotPriceByCoinId('ethereum'); @@ -451,7 +455,7 @@ describe('PricesApiClient', () => { }); it('uses custom currency for fetchV1SpotPriceByCoinId', async () => { - const mockResponse = { ethereum: { eth: 1 } }; + const mockResponse = { id: 'ethereum', price: 1 }; mockFetch.mockResolvedValueOnce(createMockResponse(mockResponse)); await client.prices.fetchV1SpotPriceByCoinId('ethereum', 'eth'); @@ -481,7 +485,7 @@ describe('PricesApiClient', () => { }); it('uses default options for fetchV2SpotPrices', async () => { - const mockResponse = { '0xtoken': { price: 1.5 } }; + const mockResponse = { '0xtoken': { price: 1.5, currency: 'usd' } }; mockFetch.mockResolvedValueOnce(createMockResponse(mockResponse)); await client.prices.fetchV2SpotPrices('0x1', ['0xtoken']); @@ -647,6 +651,71 @@ describe('PricesApiClient', () => { }); }); + describe('generated struct response validation', () => { + it('rejects a malformed v1 supported networks response', async () => { + mockFetch.mockResolvedValueOnce( + createMockResponse({ fullSupport: 'not-an-array' }), + ); + + await expect( + client.prices.fetchPriceV1SupportedNetworks(), + ).rejects.toThrow( + 'At path: fullSupport -- Expected an array value, but received: "not-an-array"', + ); + }); + + it('rejects a malformed v3 spot prices response', async () => { + mockFetch.mockResolvedValueOnce( + createMockResponse({ + 'eip155:1/slip44:60': { price: 'not-a-number' }, + }), + ); + + await expect( + client.prices.fetchV3SpotPrices(['eip155:1/slip44:60']), + ).rejects.toThrow( + 'At path: eip155:1/slip44:60 -- Expected the value to satisfy a union of `type | literal`, but received: [object Object]', + ); + }); + + it('rejects a malformed v1 historical prices response', async () => { + mockFetch.mockResolvedValueOnce( + createMockResponse({ prices: [[1704067200000, null]] }), + ); + + await expect( + client.prices.fetchV1HistoricalPrices('0x1', '0xtoken'), + ).rejects.toThrow( + 'At path: prices.0.1 -- Expected a number, but received: null', + ); + }); + + it('accepts responses with additional unknown fields (tolerant on additions)', async () => { + const mockResponse = { + fullSupport: ['1'], + partialSupport: [], + someNewBackendField: true, + }; + mockFetch.mockResolvedValueOnce(createMockResponse(mockResponse)); + + expect(await client.prices.fetchPriceV1SupportedNetworks()).toStrictEqual( + mockResponse, + ); + }); + + it('accepts generated mock data served as a response', async () => { + // The generated faker mocks and structs come from the same spec, so + // mock data always satisfies validation — e2e fixtures built on the + // mocks cannot drift from the contract. + const mockResponse = createGetV1SupportedNetworksQueryResponse(); + mockFetch.mockResolvedValueOnce(createMockResponse(mockResponse)); + + expect(await client.prices.fetchPriceV1SupportedNetworks()).toStrictEqual( + mockResponse, + ); + }); + }); + describe('get*QueryOptions pass-through options (select, initialPageParam)', () => { it('getPriceV1SupportedNetworksQueryOptions merges select and initialPageParam from options', () => { const select = ( diff --git a/packages/core-backend/src/api/prices/client.ts b/packages/core-backend/src/api/prices/client.ts index 0cd31afe65..0ab447ca63 100644 --- a/packages/core-backend/src/api/prices/client.ts +++ b/packages/core-backend/src/api/prices/client.ts @@ -9,11 +9,27 @@ * - Price graphs */ +import { assert } from '@metamask/superstruct'; import type { FetchQueryOptions, QueryFunctionContext, } from '@tanstack/query-core'; +// Structs generated from the vendored Price API spec (`specs/price-api.json`) +// by `yarn codegen`. Responses are validated before they are returned, so a +// malformed or malicious response throws a `StructError` here instead of +// crashing the wallet at some later property access. Endpoints not covered by +// the vendored spec yet are not validated. +import { + CoinGeckoSpotPriceStruct, + CoinGeckoSpotPricesStruct, + ExchangeRatesStruct, + HistoricalPricesStruct, + MarketDataSpotPricesStruct, + SupportedNetworksStruct, + V3HistoricalPricesStruct, + V3SpotPricesStruct, +} from '../../generated/price-api/structs'; import { BaseApiClient, API_URLS, STALE_TIMES, GC_TIMES } from '../base-client'; import { getQueryOptionsOverrides } from '../shared-types'; import type { @@ -63,12 +79,17 @@ export class PricesApiClient extends BaseApiClient { ): FetchQueryOptions { return { queryKey: ['prices', 'v1SupportedNetworks'], - queryFn: ({ signal }: QueryFunctionContext) => - this.fetch( + queryFn: async ({ + signal, + }: QueryFunctionContext): Promise => { + const data = await this.fetch( API_URLS.PRICES, '/v1/supportedNetworks', { signal }, - ), + ); + assert(data, SupportedNetworksStruct); + return data; + }, ...getQueryOptionsOverrides(options), staleTime: options?.staleTime ?? STALE_TIMES.SUPPORTED_NETWORKS, gcTime: options?.gcTime ?? GC_TIMES.EXTENDED, @@ -100,12 +121,17 @@ export class PricesApiClient extends BaseApiClient { ): FetchQueryOptions { return { queryKey: ['prices', 'v2SupportedNetworks'], - queryFn: ({ signal }: QueryFunctionContext) => - this.fetch( + queryFn: async ({ + signal, + }: QueryFunctionContext): Promise => { + const data = await this.fetch( API_URLS.PRICES, '/v2/supportedNetworks', { signal }, - ), + ); + assert(data, SupportedNetworksStruct); + return data; + }, ...getQueryOptionsOverrides(options), staleTime: options?.staleTime ?? STALE_TIMES.SUPPORTED_NETWORKS, gcTime: options?.gcTime ?? GC_TIMES.EXTENDED, @@ -149,7 +175,7 @@ export class PricesApiClient extends BaseApiClient { if (baseCurrency === '') { return {}; } - return this.fetch( + const data = await this.fetch( API_URLS.PRICES, '/v1/exchange-rates', { @@ -157,6 +183,8 @@ export class PricesApiClient extends BaseApiClient { params: { baseCurrency }, }, ); + assert(data, ExchangeRatesStruct); + return data; }, ...getQueryOptionsOverrides(options), staleTime: options?.staleTime ?? STALE_TIMES.EXCHANGE_RATES, @@ -194,12 +222,17 @@ export class PricesApiClient extends BaseApiClient { ): FetchQueryOptions { return { queryKey: ['prices', 'v1FiatExchangeRates'], - queryFn: ({ signal }: QueryFunctionContext) => - this.fetch( + queryFn: async ({ + signal, + }: QueryFunctionContext): Promise => { + const data = await this.fetch( API_URLS.PRICES, '/v1/exchange-rates/fiat', { signal }, - ), + ); + assert(data, ExchangeRatesStruct); + return data; + }, ...getQueryOptionsOverrides(options), staleTime: options?.staleTime ?? STALE_TIMES.EXCHANGE_RATES, gcTime: options?.gcTime ?? GC_TIMES.DEFAULT, @@ -231,12 +264,17 @@ export class PricesApiClient extends BaseApiClient { ): FetchQueryOptions { return { queryKey: ['prices', 'v1CryptoExchangeRates'], - queryFn: ({ signal }: QueryFunctionContext) => - this.fetch( + queryFn: async ({ + signal, + }: QueryFunctionContext): Promise => { + const data = await this.fetch( API_URLS.PRICES, '/v1/exchange-rates/crypto', { signal }, - ), + ); + assert(data, ExchangeRatesStruct); + return data; + }, ...getQueryOptionsOverrides(options), staleTime: options?.staleTime ?? STALE_TIMES.EXCHANGE_RATES, gcTime: options?.gcTime ?? GC_TIMES.DEFAULT, @@ -284,7 +322,7 @@ export class PricesApiClient extends BaseApiClient { if (coinIds.length === 0) { return {}; } - return this.fetch>( + const data = await this.fetch>( API_URLS.PRICES, '/v1/spot-prices', { @@ -292,6 +330,8 @@ export class PricesApiClient extends BaseApiClient { params: { coinIds }, }, ); + assert(data, CoinGeckoSpotPricesStruct); + return data; }, ...getQueryOptionsOverrides(options), staleTime: options?.staleTime ?? STALE_TIMES.PRICES, @@ -339,7 +379,7 @@ export class PricesApiClient extends BaseApiClient { if (coinId === '') { return { id: '', price: 0 }; } - return this.fetch( + const data = await this.fetch( API_URLS.PRICES, `/v1/spot-prices/${coinId}`, { @@ -347,6 +387,8 @@ export class PricesApiClient extends BaseApiClient { params: { vsCurrency: currency }, }, ); + assert(data, CoinGeckoSpotPriceStruct); + return data; }, ...getQueryOptionsOverrides(options), staleTime: options?.staleTime ?? STALE_TIMES.PRICES, @@ -574,7 +616,7 @@ export class PricesApiClient extends BaseApiClient { if (chainId === '' || tokenAddresses.length === 0) { return {}; } - return this.fetch>( + const data = await this.fetch>( API_URLS.PRICES, `/v2/chains/${chainIdDecimal}/spot-prices`, { @@ -586,6 +628,8 @@ export class PricesApiClient extends BaseApiClient { }, }, ); + assert(data, MarketDataSpotPricesStruct); + return data; }, ...getQueryOptionsOverrides(options), staleTime: options?.staleTime ?? STALE_TIMES.PRICES, @@ -670,7 +714,7 @@ export class PricesApiClient extends BaseApiClient { if (assetIds.length === 0) { return {}; } - return this.fetch( + const data = await this.fetch( API_URLS.PRICES, '/v3/spot-prices', { @@ -683,6 +727,8 @@ export class PricesApiClient extends BaseApiClient { }, }, ); + assert(data, V3SpotPricesStruct); + return data; }, ...getQueryOptionsOverrides(options), staleTime: options?.staleTime ?? STALE_TIMES.PRICES, @@ -916,8 +962,10 @@ export class PricesApiClient extends BaseApiClient { currency, timeRange, ], - queryFn: ({ signal }: QueryFunctionContext) => - this.fetch( + queryFn: async ({ + signal, + }: QueryFunctionContext): Promise => { + const data = await this.fetch( API_URLS.PRICES, `/v1/chains/${chainIdDecimal}/historical-prices/${tokenAddress}`, { @@ -927,7 +975,10 @@ export class PricesApiClient extends BaseApiClient { timePeriod: timeRange, }, }, - ), + ); + assert(data, HistoricalPricesStruct); + return data; + }, ...getQueryOptionsOverrides(options), staleTime: options?.staleTime ?? STALE_TIMES.PRICES, gcTime: options?.gcTime ?? GC_TIMES.DEFAULT, @@ -993,8 +1044,10 @@ export class PricesApiClient extends BaseApiClient { ): FetchQueryOptions { return { queryKey: ['prices', 'v3Historical', chainId, assetType, queryOptions], - queryFn: ({ signal }: QueryFunctionContext) => - this.fetch( + queryFn: async ({ + signal, + }: QueryFunctionContext): Promise => { + const data = await this.fetch( API_URLS.PRICES, `/v3/historical-prices/${chainId}/${assetType}`, { @@ -1007,7 +1060,10 @@ export class PricesApiClient extends BaseApiClient { interval: queryOptions?.interval, }, }, - ), + ); + assert(data, V3HistoricalPricesStruct); + return data; + }, ...getQueryOptionsOverrides(options), staleTime: options?.staleTime ?? STALE_TIMES.PRICES, gcTime: options?.gcTime ?? GC_TIMES.DEFAULT, diff --git a/packages/core-backend/src/api/prices/query-client.test.ts b/packages/core-backend/src/api/prices/query-client.test.ts index 8e4ced0a6a..6924114f1f 100644 --- a/packages/core-backend/src/api/prices/query-client.test.ts +++ b/packages/core-backend/src/api/prices/query-client.test.ts @@ -39,7 +39,7 @@ import { SupportedNetworksStruct, TopTokenStruct, V3SpotPriceStruct, -} from '../../generated/price-api/schemas'; +} from '../../generated/price-api/structs'; import { PricesApiRequestClient } from './query-client'; /** diff --git a/packages/core-backend/src/generated/price-api/mocks/createGetV1CryptoExchangeRates.ts b/packages/core-backend/src/generated/price-api/mocks/createGetV1CryptoExchangeRates.ts new file mode 100644 index 0000000000..346a801245 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/mocks/createGetV1CryptoExchangeRates.ts @@ -0,0 +1,32 @@ +/** + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { faker } from '@faker-js/faker'; + +import type { + GetV1CryptoExchangeRates200, + GetV1CryptoExchangeRatesQueryResponse, +} from '../types/GetV1CryptoExchangeRates'; +import { createExchangeRates } from './createExchangeRates'; + +/** + * @description Exchange rates keyed by currency ticker. + */ +export function createGetV1CryptoExchangeRates200( + data?: Partial, +): GetV1CryptoExchangeRates200 { + faker.seed([220]); + return createExchangeRates(data); +} + +export function createGetV1CryptoExchangeRatesQueryResponse( + data?: Partial, +): GetV1CryptoExchangeRatesQueryResponse { + faker.seed([220]); + return ( + data || + faker.helpers.arrayElement([createGetV1CryptoExchangeRates200()]) + ); +} diff --git a/packages/core-backend/src/generated/price-api/mocks/index.ts b/packages/core-backend/src/generated/price-api/mocks/index.ts index cdd210747b..52b43033f2 100644 --- a/packages/core-backend/src/generated/price-api/mocks/index.ts +++ b/packages/core-backend/src/generated/price-api/mocks/index.ts @@ -2,6 +2,10 @@ export { createCoinGeckoSpotPrice } from './createCoinGeckoSpotPrice'; export { createCoinGeckoSpotPrices } from './createCoinGeckoSpotPrices'; export { createExchangeRateInfo } from './createExchangeRateInfo'; export { createExchangeRates } from './createExchangeRates'; +export { + createGetV1CryptoExchangeRates200, + createGetV1CryptoExchangeRatesQueryResponse, +} from './createGetV1CryptoExchangeRates'; export { createGetV1ExchangeRates200, createGetV1ExchangeRatesQueryParams, diff --git a/packages/core-backend/src/generated/price-api/msw/getV1CryptoExchangeRatesHandler.ts b/packages/core-backend/src/generated/price-api/msw/getV1CryptoExchangeRatesHandler.ts new file mode 100644 index 0000000000..e788084d74 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/msw/getV1CryptoExchangeRatesHandler.ts @@ -0,0 +1,48 @@ +/** + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { http } from 'msw'; +import type { HttpHandler } from 'msw'; + +import { createGetV1CryptoExchangeRatesQueryResponse } from '../mocks/createGetV1CryptoExchangeRates'; +import type { GetV1CryptoExchangeRatesQueryResponse } from '../types/GetV1CryptoExchangeRates'; + +export function getV1CryptoExchangeRatesHandlerResponse200( + data: GetV1CryptoExchangeRatesQueryResponse, +) { + return new Response(JSON.stringify(data), { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }); +} + +export function getV1CryptoExchangeRatesHandler( + data?: + | GetV1CryptoExchangeRatesQueryResponse + | (( + info: Parameters[1]>[0], + ) => Response | Promise), +): HttpHandler { + return http.get( + 'https://price.api.cx.metamask.io/v1/exchange-rates/crypto', + function handler(info) { + if (typeof data === 'function') return data(info); + + return new Response( + JSON.stringify( + data || createGetV1CryptoExchangeRatesQueryResponse(data), + ), + { + status: 200, + headers: { + 'Content-Type': 'application/json', + }, + }, + ); + }, + ); +} diff --git a/packages/core-backend/src/generated/price-api/msw/handlers.ts b/packages/core-backend/src/generated/price-api/msw/handlers.ts index 6ae40e8a93..f54f492d4e 100644 --- a/packages/core-backend/src/generated/price-api/msw/handlers.ts +++ b/packages/core-backend/src/generated/price-api/msw/handlers.ts @@ -5,6 +5,7 @@ import type { HttpHandler } from 'msw'; +import { getV1CryptoExchangeRatesHandler } from './getV1CryptoExchangeRatesHandler'; import { getV1ExchangeRatesHandler } from './getV1ExchangeRatesHandler'; import { getV1FiatExchangeRatesHandler } from './getV1FiatExchangeRatesHandler'; import { getV1HistoricalPricesHandler } from './getV1HistoricalPricesHandler'; @@ -22,6 +23,7 @@ export const handlers: HttpHandler[] = [ getV2SupportedNetworksHandler(), getV1ExchangeRatesHandler(), getV1FiatExchangeRatesHandler(), + getV1CryptoExchangeRatesHandler(), getV1SpotPricesByCoinIdsHandler(), getV1SpotPriceByCoinIdHandler(), getV2SpotPricesHandler(), diff --git a/packages/core-backend/src/generated/price-api/msw/index.ts b/packages/core-backend/src/generated/price-api/msw/index.ts index 7067c3d4e1..60a9d3cde2 100644 --- a/packages/core-backend/src/generated/price-api/msw/index.ts +++ b/packages/core-backend/src/generated/price-api/msw/index.ts @@ -1,3 +1,7 @@ +export { + getV1CryptoExchangeRatesHandler, + getV1CryptoExchangeRatesHandlerResponse200, +} from './getV1CryptoExchangeRatesHandler'; export { getV1ExchangeRatesHandler, getV1ExchangeRatesHandlerResponse200, diff --git a/packages/core-backend/src/generated/price-api/queries/getV1CryptoExchangeRates.ts b/packages/core-backend/src/generated/price-api/queries/getV1CryptoExchangeRates.ts new file mode 100644 index 0000000000..4808d59db7 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/queries/getV1CryptoExchangeRates.ts @@ -0,0 +1,66 @@ +/** + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { assert } from '@metamask/superstruct'; +import type { + FetchQueryOptions, + QueryFunctionContext, +} from '@tanstack/query-core'; + +import type { + ApiRequestClient, + FetchOptions, +} from '../../../api/query-runtime'; +import { getQueryOptionsOverrides } from '../../../api/query-runtime'; +import { GetV1CryptoExchangeRatesQueryResponseStruct } from '../structs/getV1CryptoExchangeRatesStruct'; +import type { GetV1CryptoExchangeRatesQueryResponse } from '../types/GetV1CryptoExchangeRates'; + +/** + * Query key for `GET /v1/exchange-rates/crypto`. + */ +export const getV1CryptoExchangeRatesQueryKey = () => + ['prices', 'getV1CryptoExchangeRates'] as const; + +/** + * Get crypto exchange rates + * Returns a list of exchange rates for all supported crypto currencies. + * + * Returns the TanStack Query options for `GET /v1/exchange-rates/crypto`. The response is + * validated against {@link GetV1CryptoExchangeRatesQueryResponseStruct} before it is returned. + */ +export function getV1CryptoExchangeRatesQueryOptions( + client: ApiRequestClient, + options?: FetchOptions, +): FetchQueryOptions { + return { + queryKey: getV1CryptoExchangeRatesQueryKey(), + queryFn: async ({ signal }: QueryFunctionContext) => { + const data = await client.request({ + method: 'get', + url: '/v1/exchange-rates/crypto', + signal, + }); + assert(data, GetV1CryptoExchangeRatesQueryResponseStruct); + return data; + }, + ...getQueryOptionsOverrides(options), + }; +} + +/** + * Get crypto exchange rates + * Returns a list of exchange rates for all supported crypto currencies. + * + * Fetches `GET /v1/exchange-rates/crypto` through the client's QueryClient, deduplicating + * concurrent calls and reusing fresh cached data. + */ +export async function fetchV1CryptoExchangeRates( + client: ApiRequestClient, + options?: FetchOptions, +): Promise { + return client.queryClient.fetchQuery( + getV1CryptoExchangeRatesQueryOptions(client, options), + ); +} diff --git a/packages/core-backend/src/generated/price-api/queries/getV1ExchangeRates.ts b/packages/core-backend/src/generated/price-api/queries/getV1ExchangeRates.ts index 5d4a246e19..b7c5ae61b0 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV1ExchangeRates.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV1ExchangeRates.ts @@ -14,7 +14,7 @@ import type { FetchOptions, } from '../../../api/query-runtime'; import { getQueryOptionsOverrides } from '../../../api/query-runtime'; -import { GetV1ExchangeRatesQueryResponseStruct } from '../schemas/getV1ExchangeRatesStruct'; +import { GetV1ExchangeRatesQueryResponseStruct } from '../structs/getV1ExchangeRatesStruct'; import type { GetV1ExchangeRatesQueryResponse, GetV1ExchangeRatesQueryParams, diff --git a/packages/core-backend/src/generated/price-api/queries/getV1FiatExchangeRates.ts b/packages/core-backend/src/generated/price-api/queries/getV1FiatExchangeRates.ts index 36be6e4fc5..1c834b603c 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV1FiatExchangeRates.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV1FiatExchangeRates.ts @@ -14,7 +14,7 @@ import type { FetchOptions, } from '../../../api/query-runtime'; import { getQueryOptionsOverrides } from '../../../api/query-runtime'; -import { GetV1FiatExchangeRatesQueryResponseStruct } from '../schemas/getV1FiatExchangeRatesStruct'; +import { GetV1FiatExchangeRatesQueryResponseStruct } from '../structs/getV1FiatExchangeRatesStruct'; import type { GetV1FiatExchangeRatesQueryResponse } from '../types/GetV1FiatExchangeRates'; /** diff --git a/packages/core-backend/src/generated/price-api/queries/getV1HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/queries/getV1HistoricalPrices.ts index 64dd35bd33..9ef72cd1ef 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV1HistoricalPrices.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV1HistoricalPrices.ts @@ -14,7 +14,7 @@ import type { FetchOptions, } from '../../../api/query-runtime'; import { getQueryOptionsOverrides } from '../../../api/query-runtime'; -import { GetV1HistoricalPricesQueryResponseStruct } from '../schemas/getV1HistoricalPricesStruct'; +import { GetV1HistoricalPricesQueryResponseStruct } from '../structs/getV1HistoricalPricesStruct'; import type { GetV1HistoricalPricesQueryResponse, GetV1HistoricalPricesPathParams, diff --git a/packages/core-backend/src/generated/price-api/queries/getV1SpotPriceByCoinId.ts b/packages/core-backend/src/generated/price-api/queries/getV1SpotPriceByCoinId.ts index 92917adad5..c02564fbd4 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV1SpotPriceByCoinId.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV1SpotPriceByCoinId.ts @@ -14,7 +14,7 @@ import type { FetchOptions, } from '../../../api/query-runtime'; import { getQueryOptionsOverrides } from '../../../api/query-runtime'; -import { GetV1SpotPriceByCoinIdQueryResponseStruct } from '../schemas/getV1SpotPriceByCoinIdStruct'; +import { GetV1SpotPriceByCoinIdQueryResponseStruct } from '../structs/getV1SpotPriceByCoinIdStruct'; import type { GetV1SpotPriceByCoinIdQueryResponse, GetV1SpotPriceByCoinIdPathParams, diff --git a/packages/core-backend/src/generated/price-api/queries/getV1SpotPricesByCoinIds.ts b/packages/core-backend/src/generated/price-api/queries/getV1SpotPricesByCoinIds.ts index 02b6acf076..bc6861df07 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV1SpotPricesByCoinIds.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV1SpotPricesByCoinIds.ts @@ -14,7 +14,7 @@ import type { FetchOptions, } from '../../../api/query-runtime'; import { getQueryOptionsOverrides } from '../../../api/query-runtime'; -import { GetV1SpotPricesByCoinIdsQueryResponseStruct } from '../schemas/getV1SpotPricesByCoinIdsStruct'; +import { GetV1SpotPricesByCoinIdsQueryResponseStruct } from '../structs/getV1SpotPricesByCoinIdsStruct'; import type { GetV1SpotPricesByCoinIdsQueryResponse, GetV1SpotPricesByCoinIdsQueryParams, diff --git a/packages/core-backend/src/generated/price-api/queries/getV1SupportedNetworks.ts b/packages/core-backend/src/generated/price-api/queries/getV1SupportedNetworks.ts index 14a0f57460..2f48945f95 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV1SupportedNetworks.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV1SupportedNetworks.ts @@ -14,7 +14,7 @@ import type { FetchOptions, } from '../../../api/query-runtime'; import { getQueryOptionsOverrides } from '../../../api/query-runtime'; -import { GetV1SupportedNetworksQueryResponseStruct } from '../schemas/getV1SupportedNetworksStruct'; +import { GetV1SupportedNetworksQueryResponseStruct } from '../structs/getV1SupportedNetworksStruct'; import type { GetV1SupportedNetworksQueryResponse } from '../types/GetV1SupportedNetworks'; /** diff --git a/packages/core-backend/src/generated/price-api/queries/getV2SpotPrices.ts b/packages/core-backend/src/generated/price-api/queries/getV2SpotPrices.ts index 0ecc7e05e3..5487a4383e 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV2SpotPrices.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV2SpotPrices.ts @@ -14,7 +14,7 @@ import type { FetchOptions, } from '../../../api/query-runtime'; import { getQueryOptionsOverrides } from '../../../api/query-runtime'; -import { GetV2SpotPricesQueryResponseStruct } from '../schemas/getV2SpotPricesStruct'; +import { GetV2SpotPricesQueryResponseStruct } from '../structs/getV2SpotPricesStruct'; import type { GetV2SpotPricesQueryResponse, GetV2SpotPricesPathParams, diff --git a/packages/core-backend/src/generated/price-api/queries/getV2SupportedNetworks.ts b/packages/core-backend/src/generated/price-api/queries/getV2SupportedNetworks.ts index 2ab98e7b2d..d8a2ac7bcd 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV2SupportedNetworks.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV2SupportedNetworks.ts @@ -14,7 +14,7 @@ import type { FetchOptions, } from '../../../api/query-runtime'; import { getQueryOptionsOverrides } from '../../../api/query-runtime'; -import { GetV2SupportedNetworksQueryResponseStruct } from '../schemas/getV2SupportedNetworksStruct'; +import { GetV2SupportedNetworksQueryResponseStruct } from '../structs/getV2SupportedNetworksStruct'; import type { GetV2SupportedNetworksQueryResponse } from '../types/GetV2SupportedNetworks'; /** diff --git a/packages/core-backend/src/generated/price-api/queries/getV2TopTokens.ts b/packages/core-backend/src/generated/price-api/queries/getV2TopTokens.ts index 421d6cd93e..d193b8fbeb 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV2TopTokens.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV2TopTokens.ts @@ -14,7 +14,7 @@ import type { FetchOptions, } from '../../../api/query-runtime'; import { getQueryOptionsOverrides } from '../../../api/query-runtime'; -import { GetV2TopTokensQueryResponseStruct } from '../schemas/getV2TopTokensStruct'; +import { GetV2TopTokensQueryResponseStruct } from '../structs/getV2TopTokensStruct'; import type { GetV2TopTokensQueryResponse, GetV2TopTokensPathParams, diff --git a/packages/core-backend/src/generated/price-api/queries/getV3HistoricalPrices.ts b/packages/core-backend/src/generated/price-api/queries/getV3HistoricalPrices.ts index 89155bc7dd..0ec87b64ad 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV3HistoricalPrices.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV3HistoricalPrices.ts @@ -14,7 +14,7 @@ import type { FetchOptions, } from '../../../api/query-runtime'; import { getQueryOptionsOverrides } from '../../../api/query-runtime'; -import { GetV3HistoricalPricesQueryResponseStruct } from '../schemas/getV3HistoricalPricesStruct'; +import { GetV3HistoricalPricesQueryResponseStruct } from '../structs/getV3HistoricalPricesStruct'; import type { GetV3HistoricalPricesQueryResponse, GetV3HistoricalPricesPathParams, diff --git a/packages/core-backend/src/generated/price-api/queries/getV3SpotPrices.ts b/packages/core-backend/src/generated/price-api/queries/getV3SpotPrices.ts index 7d48e2416d..984012917b 100644 --- a/packages/core-backend/src/generated/price-api/queries/getV3SpotPrices.ts +++ b/packages/core-backend/src/generated/price-api/queries/getV3SpotPrices.ts @@ -14,7 +14,7 @@ import type { FetchOptions, } from '../../../api/query-runtime'; import { getQueryOptionsOverrides } from '../../../api/query-runtime'; -import { GetV3SpotPricesQueryResponseStruct } from '../schemas/getV3SpotPricesStruct'; +import { GetV3SpotPricesQueryResponseStruct } from '../structs/getV3SpotPricesStruct'; import type { GetV3SpotPricesQueryResponse, GetV3SpotPricesQueryParams, diff --git a/packages/core-backend/src/generated/price-api/queries/index.ts b/packages/core-backend/src/generated/price-api/queries/index.ts index 7d92f3a723..236a69f93b 100644 --- a/packages/core-backend/src/generated/price-api/queries/index.ts +++ b/packages/core-backend/src/generated/price-api/queries/index.ts @@ -1,3 +1,8 @@ +export { + fetchV1CryptoExchangeRates, + getV1CryptoExchangeRatesQueryKey, + getV1CryptoExchangeRatesQueryOptions, +} from './getV1CryptoExchangeRates'; export { fetchV1ExchangeRates, getV1ExchangeRatesQueryKey, diff --git a/packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPriceStruct.ts b/packages/core-backend/src/generated/price-api/structs/coinGeckoSpotPriceStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPriceStruct.ts rename to packages/core-backend/src/generated/price-api/structs/coinGeckoSpotPriceStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPricesStruct.ts b/packages/core-backend/src/generated/price-api/structs/coinGeckoSpotPricesStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/coinGeckoSpotPricesStruct.ts rename to packages/core-backend/src/generated/price-api/structs/coinGeckoSpotPricesStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/exchangeRateInfoStruct.ts b/packages/core-backend/src/generated/price-api/structs/exchangeRateInfoStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/exchangeRateInfoStruct.ts rename to packages/core-backend/src/generated/price-api/structs/exchangeRateInfoStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/exchangeRatesStruct.ts b/packages/core-backend/src/generated/price-api/structs/exchangeRatesStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/exchangeRatesStruct.ts rename to packages/core-backend/src/generated/price-api/structs/exchangeRatesStruct.ts diff --git a/packages/core-backend/src/generated/price-api/structs/getV1CryptoExchangeRatesStruct.ts b/packages/core-backend/src/generated/price-api/structs/getV1CryptoExchangeRatesStruct.ts new file mode 100644 index 0000000000..1c28172543 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/structs/getV1CryptoExchangeRatesStruct.ts @@ -0,0 +1,14 @@ +/** + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import { ExchangeRatesStruct } from './exchangeRatesStruct'; + +/** + * Exchange rates keyed by currency ticker. + */ +export const GetV1CryptoExchangeRates200Struct = ExchangeRatesStruct; + +export const GetV1CryptoExchangeRatesQueryResponseStruct = + GetV1CryptoExchangeRates200Struct; diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1ExchangeRatesStruct.ts b/packages/core-backend/src/generated/price-api/structs/getV1ExchangeRatesStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/getV1ExchangeRatesStruct.ts rename to packages/core-backend/src/generated/price-api/structs/getV1ExchangeRatesStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1FiatExchangeRatesStruct.ts b/packages/core-backend/src/generated/price-api/structs/getV1FiatExchangeRatesStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/getV1FiatExchangeRatesStruct.ts rename to packages/core-backend/src/generated/price-api/structs/getV1FiatExchangeRatesStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1HistoricalPricesStruct.ts b/packages/core-backend/src/generated/price-api/structs/getV1HistoricalPricesStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/getV1HistoricalPricesStruct.ts rename to packages/core-backend/src/generated/price-api/structs/getV1HistoricalPricesStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1SpotPriceByCoinIdStruct.ts b/packages/core-backend/src/generated/price-api/structs/getV1SpotPriceByCoinIdStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/getV1SpotPriceByCoinIdStruct.ts rename to packages/core-backend/src/generated/price-api/structs/getV1SpotPriceByCoinIdStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1SpotPricesByCoinIdsStruct.ts b/packages/core-backend/src/generated/price-api/structs/getV1SpotPricesByCoinIdsStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/getV1SpotPricesByCoinIdsStruct.ts rename to packages/core-backend/src/generated/price-api/structs/getV1SpotPricesByCoinIdsStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/getV1SupportedNetworksStruct.ts b/packages/core-backend/src/generated/price-api/structs/getV1SupportedNetworksStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/getV1SupportedNetworksStruct.ts rename to packages/core-backend/src/generated/price-api/structs/getV1SupportedNetworksStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/getV2SpotPricesStruct.ts b/packages/core-backend/src/generated/price-api/structs/getV2SpotPricesStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/getV2SpotPricesStruct.ts rename to packages/core-backend/src/generated/price-api/structs/getV2SpotPricesStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/getV2SupportedNetworksStruct.ts b/packages/core-backend/src/generated/price-api/structs/getV2SupportedNetworksStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/getV2SupportedNetworksStruct.ts rename to packages/core-backend/src/generated/price-api/structs/getV2SupportedNetworksStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/getV2TopTokensStruct.ts b/packages/core-backend/src/generated/price-api/structs/getV2TopTokensStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/getV2TopTokensStruct.ts rename to packages/core-backend/src/generated/price-api/structs/getV2TopTokensStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/getV3HistoricalPricesStruct.ts b/packages/core-backend/src/generated/price-api/structs/getV3HistoricalPricesStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/getV3HistoricalPricesStruct.ts rename to packages/core-backend/src/generated/price-api/structs/getV3HistoricalPricesStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/getV3SpotPricesStruct.ts b/packages/core-backend/src/generated/price-api/structs/getV3SpotPricesStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/getV3SpotPricesStruct.ts rename to packages/core-backend/src/generated/price-api/structs/getV3SpotPricesStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/historicalPricesStruct.ts b/packages/core-backend/src/generated/price-api/structs/historicalPricesStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/historicalPricesStruct.ts rename to packages/core-backend/src/generated/price-api/structs/historicalPricesStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/index.ts b/packages/core-backend/src/generated/price-api/structs/index.ts similarity index 95% rename from packages/core-backend/src/generated/price-api/schemas/index.ts rename to packages/core-backend/src/generated/price-api/structs/index.ts index cc47586934..b8b6e62c91 100644 --- a/packages/core-backend/src/generated/price-api/schemas/index.ts +++ b/packages/core-backend/src/generated/price-api/structs/index.ts @@ -2,6 +2,10 @@ export { CoinGeckoSpotPriceStruct } from './coinGeckoSpotPriceStruct'; export { CoinGeckoSpotPricesStruct } from './coinGeckoSpotPricesStruct'; export { ExchangeRateInfoStruct } from './exchangeRateInfoStruct'; export { ExchangeRatesStruct } from './exchangeRatesStruct'; +export { + GetV1CryptoExchangeRates200Struct, + GetV1CryptoExchangeRatesQueryResponseStruct, +} from './getV1CryptoExchangeRatesStruct'; export { GetV1ExchangeRates200Struct, GetV1ExchangeRatesQueryParamsStruct, diff --git a/packages/core-backend/src/generated/price-api/schemas/marketDataSpotPricesStruct.ts b/packages/core-backend/src/generated/price-api/structs/marketDataSpotPricesStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/marketDataSpotPricesStruct.ts rename to packages/core-backend/src/generated/price-api/structs/marketDataSpotPricesStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/marketDataStruct.ts b/packages/core-backend/src/generated/price-api/structs/marketDataStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/marketDataStruct.ts rename to packages/core-backend/src/generated/price-api/structs/marketDataStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/pricePointStruct.ts b/packages/core-backend/src/generated/price-api/structs/pricePointStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/pricePointStruct.ts rename to packages/core-backend/src/generated/price-api/structs/pricePointStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/supportedNetworksStruct.ts b/packages/core-backend/src/generated/price-api/structs/supportedNetworksStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/supportedNetworksStruct.ts rename to packages/core-backend/src/generated/price-api/structs/supportedNetworksStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/topTokenStruct.ts b/packages/core-backend/src/generated/price-api/structs/topTokenStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/topTokenStruct.ts rename to packages/core-backend/src/generated/price-api/structs/topTokenStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/v3HistoricalPricesStruct.ts b/packages/core-backend/src/generated/price-api/structs/v3HistoricalPricesStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/v3HistoricalPricesStruct.ts rename to packages/core-backend/src/generated/price-api/structs/v3HistoricalPricesStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/v3SpotPriceStruct.ts b/packages/core-backend/src/generated/price-api/structs/v3SpotPriceStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/v3SpotPriceStruct.ts rename to packages/core-backend/src/generated/price-api/structs/v3SpotPriceStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/v3SpotPricesStruct.ts b/packages/core-backend/src/generated/price-api/structs/v3SpotPricesStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/v3SpotPricesStruct.ts rename to packages/core-backend/src/generated/price-api/structs/v3SpotPricesStruct.ts diff --git a/packages/core-backend/src/generated/price-api/schemas/vsCurrencyStruct.ts b/packages/core-backend/src/generated/price-api/structs/vsCurrencyStruct.ts similarity index 100% rename from packages/core-backend/src/generated/price-api/schemas/vsCurrencyStruct.ts rename to packages/core-backend/src/generated/price-api/structs/vsCurrencyStruct.ts diff --git a/packages/core-backend/src/generated/price-api/types/GetV1CryptoExchangeRates.ts b/packages/core-backend/src/generated/price-api/types/GetV1CryptoExchangeRates.ts new file mode 100644 index 0000000000..ca52dba0a4 --- /dev/null +++ b/packages/core-backend/src/generated/price-api/types/GetV1CryptoExchangeRates.ts @@ -0,0 +1,18 @@ +/** + * Generated by Kubb (https://kubb.dev/). + * Do not edit manually. + */ + +import type { ExchangeRates } from './ExchangeRates'; + +/** + * @description Exchange rates keyed by currency ticker. + */ +export type GetV1CryptoExchangeRates200 = ExchangeRates; + +export type GetV1CryptoExchangeRatesQueryResponse = GetV1CryptoExchangeRates200; + +export type GetV1CryptoExchangeRatesQuery = { + Response: GetV1CryptoExchangeRates200; + Errors: any; +}; diff --git a/packages/core-backend/src/generated/price-api/types/index.ts b/packages/core-backend/src/generated/price-api/types/index.ts index 84c0376d0b..367bbae938 100644 --- a/packages/core-backend/src/generated/price-api/types/index.ts +++ b/packages/core-backend/src/generated/price-api/types/index.ts @@ -5,6 +5,11 @@ export type { ExchangeRateInfoCurrencyTypeEnumKey, } from './ExchangeRateInfo'; export type { ExchangeRates } from './ExchangeRates'; +export type { + GetV1CryptoExchangeRates200, + GetV1CryptoExchangeRatesQuery, + GetV1CryptoExchangeRatesQueryResponse, +} from './GetV1CryptoExchangeRates'; export type { GetV1ExchangeRates200, GetV1ExchangeRatesQuery, diff --git a/packages/core-backend/src/mocks/index.ts b/packages/core-backend/src/mocks/index.ts index 80d0a1ee99..bd3f0c8a76 100644 --- a/packages/core-backend/src/mocks/index.ts +++ b/packages/core-backend/src/mocks/index.ts @@ -1,17 +1,24 @@ /** * Test and development mocks for the APIs consumed by this package, - * generated from their OpenAPI documents by Kubb (`yarn codegen`). + * generated from their vendored OpenAPI spec snapshots by Kubb + * (`yarn codegen`). * * Importable as `@metamask/core-backend/mocks`: * * ```ts * import { * // Faker-based mock data builders - * createGetV3SpotPricesQueryResponse, - * // MSW request handlers + * createV3SpotPrices, + * // MSW request handlers (unit/integration tests) * getV3SpotPricesHandler, * handlers, * } from '@metamask/core-backend/mocks'; + * + * // The same mock data also feeds e2e mock servers (mockttp), so fixtures + * // regenerate with the spec instead of drifting: + * mockServer + * .forGet('https://price.api.cx.metamask.io/v3/spot-prices') + * .thenJson(200, createV3SpotPrices()); * ``` * * Using the MSW handlers requires the optional `msw` peer dependency; using diff --git a/packages/core-backend/src/price-api/index.ts b/packages/core-backend/src/price-api/index.ts index fb21e19362..c9dfed9c2c 100644 --- a/packages/core-backend/src/price-api/index.ts +++ b/packages/core-backend/src/price-api/index.ts @@ -1,6 +1,6 @@ /** - * Price API bindings, generated from the API's OpenAPI document by Kubb - * (`yarn codegen`). + * Price API bindings, generated from the vendored OpenAPI spec snapshot + * (`specs/price-api.json`) by Kubb (`yarn codegen`). * * Importable as `@metamask/core-backend/price-api`: * @@ -16,11 +16,11 @@ * } from '@metamask/core-backend/price-api'; * ``` * - * The faker mocks and MSW handlers generated from the same document are - * exposed separately through `@metamask/core-backend/mocks`, so this entry - * point stays free of test-only dependencies. + * The faker mock data builders and MSW handlers generated from the same + * document are exposed separately through `@metamask/core-backend/mocks`, so + * this entry point stays free of test-only dependencies. */ export * from '../generated/price-api/types'; -export * from '../generated/price-api/schemas'; +export * from '../generated/price-api/structs'; export * from '../generated/price-api/queries';