Skip to content

Conversation

@ygrishajev
Copy link
Contributor

@ygrishajev ygrishajev commented Dec 30, 2025

  • Add Swagger JSON generation script with sanitization for optional path parameters
  • Add React Query SDK generation using openapi-qraft (matching notifications app)
  • Centralize REST handlers in app/rest-handlers.ts to avoid duplication
  • Fix OpenAPI docs service to merge schemas and securitySchemes from handlers
  • Fix barrel file exports by removing .ts extensions
  • Update deploy-web to use generated console API SDK
  • Add SDK generation scripts: sdk:gen:swagger and sdk:gen:react-query

Summary by CodeRabbit

  • New Features

    • Added automatic API client generation infrastructure and npm scripts for OpenAPI and SDK generation
    • Introduced new ./api public export in react-query-sdk package with factory functions for configurable API clients
  • Refactor

    • Centralized API handler registry for improved maintainability
    • Updated web app to leverage framework-provided API hooks for streamlined data fetching

✏️ Tip: You can customize this high-level summary in your review settings.

@ygrishajev ygrishajev requested a review from a team as a code owner December 30, 2025 15:03
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 30, 2025

📝 Walkthrough

Walkthrough

This PR centralizes OpenAPI Hono handler registration, introduces Swagger generation infrastructure, and extends the React Query SDK to include an API module. It refactors handler definitions into a single registry, adds generation scripts, and updates the DI container to support separate console and notifications API clients.

Changes

Cohort / File(s) Summary
OpenAPI Handler Registry & REST App Refactoring
apps/api/src/app/rest-handlers.ts, apps/api/src/rest-app.ts
Created new centralized registry of OpenAPI Hono handlers (openApiHonoHandlers constant); refactored rest-app.ts to import and iterate over handlers instead of maintaining inline array. Removed large hard-coded handler list and associated imports.
Swagger Generation Infrastructure
apps/api/package.json, apps/api/scripts/generateSwagger.ts
Added new TypeScript script to generate OpenAPI documentation from Hono routes with sanitization of optional path parameters. Added npm scripts sdk:gen:swagger and sdk:gen:react-query with dependencies on @openapi-qraft/cli and rimraf.
OpenAPI Docs Service Enhancement
apps/api/src/core/services/openapi-docs/openapi-docs.service.ts
Extended doc generation to merge handler components (schemas and securitySchemes) alongside paths from each OpenAPI document.
Export Path Cleanup
apps/api/src/billing/services/index.ts, apps/api/src/deployment/services/index.ts
Removed .ts extension from export paths (e.g., remaining-credits.service → remaining-credits.service).
React Query SDK API Module
packages/react-query-sdk/package.json, packages/react-query-sdk/src/api/*
Added new API export entry in package.json; created API module with overloaded createAPIClient() factory, services registry (v1 and akash), and index exports for schema and operations. Extended gen script to generate SDK for API app.
Deploy Web DI & Query Hooks
apps/deploy-web/src/services/app-di-container/browser-di-container.ts, apps/deploy-web/src/queries/useManagedWalletQuery.ts
Updated DI container to instantiate separate consoleApi and notificationsApi clients using aliased factory functions. Modified useManagedWalletQuery to use consoleApi.v1.getWallets.useQuery hook instead of manual query.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • stalniy
  • baktun14

🐰 Handlers now hop through a single door,
Swagger docs flow like never before,
SDK clients breed and align,
The API gateway's architecture so fine!
No more scattered routes to explore.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add OpenAPI Swagger generation and React Query SDK' accurately summarizes the main changes: introducing Swagger generation, React Query SDK generation, and related infrastructure improvements.
✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

},
"devDependencies": {
"@akashnetwork/dev-config": "*",
"@akashnetwork/docker": "*",
Copy link
Contributor

@github-actions github-actions bot Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔄 Carefully review the package-lock.json diff

Resolve the comment if everything is ok

* node_modules/package-json-from-dist                                                      1.0.0 -> 1.0.1
+ apps/api/node_modules/glob/node_modules/minimatch                                        10.1.1  
+ apps/api/node_modules/glob                                                               13.0.0  
+ apps/api/node_modules/path-scurry                                                        2.0.1   
+ apps/api/node_modules/rimraf                                                             6.1.2   
+ node_modules/@isaacs/balanced-match                                                      4.0.1   
+ node_modules/@isaacs/brace-expansion                                                     5.0.0   

@socket-security
Copy link

socket-security bot commented Dec 30, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedrimraf@​6.1.210010010086100

View full report

- Add Swagger JSON generation script with sanitization for optional path parameters
- Add React Query SDK generation using openapi-qraft (matching notifications app)
- Centralize REST handlers in app/rest-handlers.ts to avoid duplication
- Fix OpenAPI docs service to merge schemas and securitySchemes from handlers
- Fix barrel file exports by removing .ts extensions
- Update deploy-web to use generated console API SDK
- Add SDK generation scripts: sdk:gen:swagger and sdk:gen:react-query
@codecov
Copy link

codecov bot commented Dec 30, 2025

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
1933 3 1930 0
View the top 3 failed test(s) by shortest run time
useManagedWalletQuery useManagedWalletQuery should fetch wallet when userId is provided
Stack Traces | 1.02s run time
Error: expect(jest.fn()).toHaveBeenCalledWith(...expected)

Expected: "d7a9dc32-24b5-435a-943d-b6aab27cadd3"

Number of calls: 0

Ignored nodes: comments, script, style
<html>
  <head />
  <body>
    <div />
  </body>
</html>
    at toHaveBeenCalledWith (.../src/queries/useManagedWalletQuery.spec.tsx:27:48)
    at runWithExpensiveErrorDiagnosticsDisabled (.../console/console/node_modules/@.../dom/dist/config.js:47:12)
    at checkCallback (.../console/console/node_modules/@.../dom/dist/wait-for.js:124:77)
    at checkRealTimersCallback (.../console/console/node_modules/@.../dom/dist/wait-for.js:118:16)
    at Timeout.task [as _onTimeout] (.../jsdom/browser/Window.js:579:19)
    at listOnTimeout (node:internal/timers:605:17)
    at processTimers (node:internal/timers:541:7)
LogCollectorControl updates log-collector placement when target service placement is changed
Stack Traces | 1.12s run time
Error: expect(received).toBe(expected) // Object.is equality

Expected: "vomito"
Received: undefined

Ignored nodes: comments, script, style
<html>
  <head />
  <body>
    <div>
      <div
        class="mb-2 flex items-center"
      >
        <strong
          class="text-sm"
        >
          Log Forwarding
        </strong>
        <div
          class="flex-shrink-0"
        >
          <svg
            class="ml-2 text-xs text-muted-foreground"
            color="currentColor"
            data-state="closed"
            fill="none"
            height="1.5em"
            stroke-width="1.5"
            viewBox="0 0 24 24"
            width="1.5em"
            xmlns="http://www.w3.org/2000/svg"
          >
            <path
              d="M12 11.5V16.5"
              stroke="currentColor"
              stroke-linecap="round"
              stroke-linejoin="round"
            />
            <path
              d="M12 7.51L12.01 7.49889"
              stroke="currentColor"
              stroke-linecap="round"
              stroke-linejoin="round"
            />
            <path
              d="M12 22C17.5228 22 22 17.5228 22 12C22 6.47715 17.5228 2 12 2C6.47715 2 2 6.47715 2 12C2 17.5228 6.47715 22 12 22Z"
              stroke="currentColor"
              stroke-linecap="round"
              stroke-linejoin="round"
            />
          </svg>
        </div>
      </div>
      <div
        class="flex cursor-pointer items-center space-x-2"
      >
        <div
          class="inline-flex"
        >
          <button
            aria-checked="false"
            class="border-primary ring-offset-background data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground focus-visible:ring-ring peer h-4 w-4 shrink-0 rounded-[4px] border focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50"
            data-state="unchecked"
            id=":r4s:"
            role="checkbox"
            type="button"
            value="on"
          />
        </div>
        <label
          class="cursor-pointer text-sm leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
          for=":r4s:"
        >
          Enable log forwarding for this service
        </label>
      </div>
       
    </div>
  </body>
</html>
    at toBe (.../sdl/LogCollectorControl/LogCollectorControl.spec.tsx:99:61)
    at runWithExpensiveErrorDiagnosticsDisabled (.../console/console/node_modules/@.../dom/dist/config.js:47:12)
    at checkCallback (.../console/console/node_modules/@.../dom/dist/wait-for.js:124:77)
    at checkRealTimersCallback (.../console/console/node_modules/@.../dom/dist/wait-for.js:118:16)
    at Timeout.task [as _onTimeout] (.../jsdom/browser/Window.js:579:19)
    at listOnTimeout (node:internal/timers:605:17)
    at processTimers (node:internal/timers:541:7)
API Docs GET /v1/doc returns docs with all routes expected
Stack Traces | 3.52s run time
Error: expect(received).toMatchSnapshot()

Snapshot name: `API Docs GET /v1/doc returns docs with all routes expected 1`

- Snapshot  - 1
+ Received  + 6

@@ -1,8 +1,13 @@
  {
    "components": {
-     "schemas": {},
+     "schemas": {
+       "Deployment DSEQ": {
+         "pattern": "^d+$",
+         "type": "string",
+       },
+     },
      "securitySchemes": {
        "ApiKeyAuth": {
          "description": "API key for programmatic access.",
          "in": "header",
          "name": "x-api-key",
    at Object.<anonymous> (.../test/functional/docs.spec.ts:13:20)
    at processTicksAndRejections (node:internal/process/task_queues:103:5)

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/api/src/rest-app.ts (1)

83-87: Inconsistent error message in scope validation.

The assertion message says 'Valid options: "full", "api"' but the actual valid options being checked are "full" and "console". This inconsistency could confuse API consumers.

🔎 Proposed fix
-  assert(["full", "console"].includes(scope), 403, '"scope" query is invalid. Valid options: "full", "api"');
+  assert(["full", "console"].includes(scope), 403, '"scope" query is invalid. Valid options: "full", "console"');
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab32673 and 425600b.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (17)
  • apps/api/package.json
  • apps/api/scripts/generateSwagger.ts
  • apps/api/src/app/rest-handlers.ts
  • apps/api/src/billing/services/index.ts
  • apps/api/src/core/services/openapi-docs/openapi-docs.service.ts
  • apps/api/src/deployment/services/index.ts
  • apps/api/src/rest-app.ts
  • apps/api/swagger/swagger.json
  • apps/deploy-web/src/queries/useManagedWalletQuery.ts
  • apps/deploy-web/src/services/app-di-container/browser-di-container.ts
  • packages/react-query-sdk/package.json
  • packages/react-query-sdk/src/api/create-api-client.ts
  • packages/react-query-sdk/src/api/index.ts
  • packages/react-query-sdk/src/api/schema.ts
  • packages/react-query-sdk/src/api/services/AkashService.ts
  • packages/react-query-sdk/src/api/services/V1Service.ts
  • packages/react-query-sdk/src/api/services/index.ts
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js}

📄 CodeRabbit inference engine (.cursor/rules/general.mdc)

**/*.{ts,tsx,js}: Never use type any or cast to type any. Always define the proper TypeScript types.
Never use deprecated methods from libraries.
Don't add unnecessary comments to the code.

Files:

  • apps/api/src/app/rest-handlers.ts
  • packages/react-query-sdk/src/api/services/index.ts
  • apps/api/src/billing/services/index.ts
  • apps/api/src/deployment/services/index.ts
  • apps/deploy-web/src/services/app-di-container/browser-di-container.ts
  • packages/react-query-sdk/src/api/index.ts
  • packages/react-query-sdk/src/api/create-api-client.ts
  • apps/api/src/core/services/openapi-docs/openapi-docs.service.ts
  • apps/api/scripts/generateSwagger.ts
  • apps/deploy-web/src/queries/useManagedWalletQuery.ts
  • apps/api/src/rest-app.ts
🧠 Learnings (7)
📚 Learning: 2025-11-19T15:15:07.283Z
Learnt from: ygrishajev
Repo: akash-network/console PR: 2254
File: apps/api/test/functional/sign-and-broadcast-tx.spec.ts:4-4
Timestamp: 2025-11-19T15:15:07.283Z
Learning: In the Akash Network Console project, when tests use native Node.js fetch (available in Node 18+), fetch-mock should be used for HTTP mocking instead of nock, as nock does not support intercepting native fetch calls. This applies to apps/api/test/functional/sign-and-broadcast-tx.spec.ts and any other tests using native fetch.

Applied to files:

  • apps/api/package.json
  • apps/deploy-web/src/services/app-di-container/browser-di-container.ts
📚 Learning: 2025-06-03T15:06:34.211Z
Learnt from: baktun14
Repo: akash-network/console PR: 1428
File: apps/api/src/deployment/controllers/deployment/deployment.controller.ts:0-0
Timestamp: 2025-06-03T15:06:34.211Z
Learning: The `getByOwnerAndDseq` method in `apps/api/src/deployment/controllers/deployment/deployment.controller.ts` is intentionally public without the `Protected` decorator because it serves public blockchain data from an indexer, following the pattern of public blockchain APIs.

Applied to files:

  • apps/api/src/deployment/services/index.ts
📚 Learning: 2025-11-19T16:13:43.249Z
Learnt from: stalniy
Repo: akash-network/console PR: 2255
File: apps/api/src/middlewares/privateMiddleware.ts:5-9
Timestamp: 2025-11-19T16:13:43.249Z
Learning: In the Akash Console API (apps/api), avoid resolving DI container dependencies at module scope (module initialization time) to prevent side effects. Instead, resolve dependencies inside functions/methods where they are actually used, even if this means resolving on every invocation, to maintain explicit control over when side effects occur and improve testability.

Applied to files:

  • apps/deploy-web/src/services/app-di-container/browser-di-container.ts
📚 Learning: 2025-09-04T04:27:50.638Z
Learnt from: stalniy
Repo: akash-network/console PR: 1868
File: apps/api/src/billing/services/managed-signer/managed-signer.service.ts:1-1
Timestamp: 2025-09-04T04:27:50.638Z
Learning: In the akash-network/console project, importing MsgCreateLease from "akashnetwork/akash-api/v1beta3" instead of v1beta4 is considered non-critical by the maintainers, likely due to backward compatibility or project-specific requirements.

Applied to files:

  • apps/deploy-web/src/services/app-di-container/browser-di-container.ts
📚 Learning: 2025-11-25T17:45:49.180Z
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-11-25T17:45:49.180Z
Learning: Applies to {apps/deploy-web,apps/provider-console}/**/*.spec.tsx : Use `queryBy` methods instead of `getBy` methods in test expectations

Applied to files:

  • apps/deploy-web/src/queries/useManagedWalletQuery.ts
📚 Learning: 2025-10-15T16:39:55.348Z
Learnt from: jzsfkzm
Repo: akash-network/console PR: 2039
File: apps/deploy-web/tests/ui/change-wallets.spec.ts:4-10
Timestamp: 2025-10-15T16:39:55.348Z
Learning: In the Akash Console E2E tests using the context-with-extension fixture, the first wallet is automatically created during fixture setup via `importWalletToLeap` in `apps/deploy-web/tests/ui/fixture/wallet-setup.ts`, so tests that call `frontPage.createWallet()` are creating a second wallet to test wallet switching functionality.

Applied to files:

  • apps/deploy-web/src/queries/useManagedWalletQuery.ts
📚 Learning: 2025-09-10T08:40:53.104Z
Learnt from: stalniy
Repo: akash-network/console PR: 1892
File: apps/deploy-web/src/components/new-deployment/BidCountdownTimer.tsx:20-31
Timestamp: 2025-09-10T08:40:53.104Z
Learning: In TanStack Query v5, the onSuccess and onError callbacks were removed from useQuery options. Instead, use useEffect with the data as a dependency to handle side effects when query data changes.

Applied to files:

  • apps/deploy-web/src/queries/useManagedWalletQuery.ts
🧬 Code graph analysis (5)
apps/api/src/app/rest-handlers.ts (50)
apps/api/src/core/services/open-api-hono-handler/open-api-hono-handler.ts (1)
  • OpenApiHonoHandler (11-26)
apps/api/src/billing/routes/start-trial/start-trial.router.ts (1)
  • startTrialRouter (9-9)
apps/api/src/billing/routes/get-wallet-list/get-wallet-list.router.ts (1)
  • getWalletListRouter (16-16)
apps/api/src/billing/routes/wallet-settings/wallet-settings.router.ts (1)
  • walletSettingRouter (9-9)
apps/api/src/billing/routes/sign-and-broadcast-tx/sign-and-broadcast-tx.router.ts (1)
  • signAndBroadcastTxRouter (9-9)
apps/api/src/billing/routes/checkout/checkout.router.ts (1)
  • checkoutRouter (9-9)
apps/api/src/billing/routes/stripe-webhook/stripe-webhook.router.ts (1)
  • stripeWebhook (9-9)
apps/api/src/billing/routes/stripe-prices/stripe-prices.router.ts (1)
  • stripePricesRouter (21-21)
apps/api/src/billing/routes/stripe-coupons/stripe-coupons.router.ts (1)
  • stripeCouponsRouter (9-9)
apps/api/src/billing/routes/stripe-customers/stripe-customers.router.ts (1)
  • stripeCustomersRouter (9-9)
apps/api/src/billing/routes/stripe-payment-methods/stripe-payment-methods.router.ts (1)
  • stripePaymentMethodsRouter (17-17)
apps/api/src/billing/routes/stripe-transactions/stripe-transactions.router.ts (1)
  • stripeTransactionsRouter (16-16)
apps/api/src/billing/routes/usage/usage.router.ts (1)
  • usageRouter (58-58)
apps/api/src/user/routes/create-anonymous-user/create-anonymous-user.router.ts (1)
  • createAnonymousUserRouter (28-28)
apps/api/src/user/routes/get-anonymous-user/get-anonymous-user.router.ts (1)
  • getAnonymousUserRouter (14-14)
apps/api/src/user/routes/register-user/register-user.router.ts (1)
  • registerUserRouter (49-52)
apps/api/src/user/routes/get-current-user/get-current-user.router.ts (1)
  • getCurrentUserRouter (26-28)
apps/api/src/auth/routes/send-verification-email/send-verification-email.router.ts (1)
  • sendVerificationEmailRouter (9-9)
apps/api/src/auth/routes/verify-email/verify-email.router.ts (1)
  • verifyEmailRouter (10-10)
apps/api/src/deployment/routes/deployment-setting/deployment-setting.router.ts (1)
  • deploymentSettingRouter (15-15)
apps/api/src/deployment/routes/deployments/deployments.router.ts (1)
  • deploymentsRouter (35-35)
apps/api/src/deployment/routes/leases/leases.router.ts (1)
  • leasesRouter (11-11)
apps/api/src/auth/routes/api-keys/api-keys.router.ts (1)
  • apiKeysRouter (17-17)
apps/api/src/bid/routes/bids/bids.router.ts (1)
  • bidsRouter (9-9)
apps/api/src/certificate/routes/certificate.router.ts (1)
  • certificateRouter (9-9)
apps/api/src/billing/routes/get-balances/get-balances.router.ts (1)
  • getBalancesRouter (30-33)
apps/api/src/provider/routes/providers/providers.router.ts (1)
  • providersRouter (16-16)
apps/api/src/provider/routes/auditors/auditors.router.ts (1)
  • auditorsRouter (26-26)
apps/api/src/provider/routes/provider-attributes-schema/provider-attributes-schema.router.ts (1)
  • providerAttributesSchemaRouter (27-27)
apps/api/src/provider/routes/provider-regions/provider-regions.router.ts (1)
  • providerRegionsRouter (9-9)
apps/api/src/provider/routes/provider-dashboard/provider-dashboard.router.ts (1)
  • providerDashboardRouter (34-34)
apps/api/src/provider/routes/provider-earnings/provider-earnings.router.ts (1)
  • providerEarningsRouter (35-35)
apps/api/src/provider/routes/provider-versions/provider-versions.router.ts (1)
  • providerVersionsRouter (9-9)
apps/api/src/provider/routes/provider-graph-data/provider-graph-data.router.ts (1)
  • providerGraphDataRouter (11-11)
apps/api/src/provider/routes/provider-deployments/provider-deployments.router.ts (1)
  • providerDeploymentsRouter (38-38)
apps/api/src/provider/routes/jwt-token/jwt-token.router.ts (1)
  • providerJwtTokenRouter (10-10)
apps/api/src/dashboard/routes/graph-data/graph-data.router.ts (1)
  • graphDataRouter (13-13)
apps/api/src/dashboard/routes/dashboard-data/dashboard-data.router.ts (1)
  • dashboardDataRouter (9-9)
apps/api/src/dashboard/routes/network-capacity/network-capacity.router.ts (1)
  • networkCapacityRouter (9-9)
apps/api/src/block/routes/blocks/blocks.router.ts (1)
  • blocksRouter (14-14)
apps/api/src/block/routes/block-prediction/block-prediction.router.ts (1)
  • blockPredictionRouter (15-15)
apps/api/src/transaction/routes/transactions/transactions.router.ts (1)
  • transactionsRouter (14-14)
apps/api/src/dashboard/routes/market-data/market-data.router.ts (1)
  • marketDataRouter (9-9)
apps/api/src/validator/routes/validators/validators.router.ts (1)
  • validatorsRouter (13-13)
apps/api/src/pricing/routes/pricing/pricing.router.ts (1)
  • pricingRouter (9-9)
apps/api/src/gpu/routes/gpu.router.ts (1)
  • gpuRouter (20-20)
apps/api/src/proposal/routes/proposals/proposals.router.ts (1)
  • proposalsRouter (9-9)
apps/api/src/template/routes/templates/templates.router.ts (1)
  • templatesRouter (14-14)
apps/api/src/dashboard/routes/leases-duration/leases-duration.router.ts (1)
  • leasesDurationRouter (83-83)
apps/api/src/network/routes/network/network.router.ts (1)
  • networkRouter (9-9)
apps/deploy-web/src/services/app-di-container/browser-di-container.ts (1)
apps/deploy-web/src/services/app-di-container/server-di-container.service.ts (1)
  • services (25-61)
packages/react-query-sdk/src/api/create-api-client.ts (2)
packages/react-query-sdk/src/api/index.ts (3)
  • createAPIClient (9-9)
  • Services (8-8)
  • services (7-7)
packages/react-query-sdk/src/api/services/index.ts (2)
  • Services (10-13)
  • services (14-17)
apps/api/scripts/generateSwagger.ts (1)
apps/api/src/app/rest-handlers.ts (1)
  • openApiHonoHandlers (48-99)
apps/deploy-web/src/queries/useManagedWalletQuery.ts (1)
apps/deploy-web/src/context/ServicesProvider/ServicesProvider.tsx (1)
  • useServices (33-35)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: log-collector-ci
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: test-build
  • GitHub Check: validate / validate-app
  • GitHub Check: test-build
  • GitHub Check: Validate local packages
🔇 Additional comments (14)
apps/api/src/deployment/services/index.ts (1)

1-1: LGTM! Extension-less exports follow TypeScript best practices.

Removing the .ts extension from the export path follows TypeScript module resolution best practices and improves consistency across barrel files.

apps/api/src/core/services/openapi-docs/openapi-docs.service.ts (1)

67-73: LGTM! Schema and security scheme merging enhances OpenAPI document generation.

The new merging logic for components.schemas and components.securitySchemes follows the same pattern as the existing path merging and properly integrates handler-specific components into the aggregate OpenAPI document.

apps/api/src/billing/services/index.ts (1)

7-7: LGTM! Consistent barrel file export improvement.

This change aligns with TypeScript module resolution best practices and is consistent with similar updates across the codebase.

apps/api/scripts/generateSwagger.ts (2)

30-35: LGTM! Path parameter sanitization correctly handles Hono-specific syntax.

The sanitization logic appropriately converts Hono's optional path parameter syntax {param?} to OpenAPI-compliant {param} format. The regex pattern /\{(\w+)\?}/g correctly captures the parameter name and removes the optional marker.

This addresses the comment on line 31 about preventing invalid TypeScript identifiers in generated code.


1-11: Bootstrap imports are necessary for DI container initialization.

The side-effect imports (reflect-metadata, @akashnetwork/env-loader, and ../src/app) are required to properly initialize the tsyringe DI container before resolving OpenApiDocsService.

packages/react-query-sdk/src/api/services/index.ts (1)

1-17: LGTM! Auto-generated services registry is correctly structured.

This auto-generated file properly exports the Services type and services constant that provide a type-safe registry for the API surface. The structure aligns with the OpenAPI generation workflow.

As noted in the header comment, avoid manual edits to this file.

apps/api/package.json (1)

25-26: All script paths and output directories are correctly configured and exist in the repository:

  • Output directory packages/react-query-sdk/src/api exists and is properly structured
  • Swagger generation script apps/api/scripts/generateSwagger.ts is in place
  • @openapi-qraft/cli (^2.5.0) is installed with tanstack-query-react and openapi-typescript plugins available
  • Package structure follows the expected pattern with proper exports configured
apps/deploy-web/src/services/app-di-container/browser-di-container.ts (1)

1-2: The divergence between browser and server containers is intentional and follows the correct pattern.

The server container only initializes notificationsApi while the browser container initializes both notificationsApi and consoleApi. This is expected since the server runtime has different dependencies than the browser. Both containers properly use factory functions (arrow functions) to defer dependency resolution, avoiding module-scope side effects.

packages/react-query-sdk/src/api/index.ts (1)

1-9: LGTM!

This is a clean auto-generated barrel file that properly re-exports types and runtime clients. The export structure is well-organized with clear separation between type exports and value exports.

packages/react-query-sdk/package.json (2)

8-11: LGTM!

The new ./api export entry follows the existing pattern established by ./notifications. The export structure is clean and provides proper access to the new API client surface.


15-15: LGTM!

The updated gen script appropriately chains SDK generation for both notifications and API apps before running lint and format. The sequential execution ensures consistent generation order.

apps/api/src/rest-app.ts (1)

62-64: LGTM!

Clean refactoring from static handler registration to dynamic iteration. This approach improves maintainability by centralizing handler definitions in rest-handlers.ts.

packages/react-query-sdk/src/api/create-api-client.ts (1)

1-37: This file is auto-generated by @openapi-qraft/cli and should not be manually edited. The type parameters for APIUtilityClientServices are consistent throughout the file—both the overload at line 23 and the implementation return type union at line 30 use APIUtilityClientServices<Services, AllCallbacks> with the same two type parameters.

Likely an incorrect or invalid review comment.

apps/api/src/app/rest-handlers.ts (1)

48-99: Fix type incompatibility: createAnonymousUserRouter should be instantiated as OpenApiHonoHandler.

createAnonymousUserRouter is instantiated as new OpenAPIHono<{ Variables: ClientInfoContextVariables }>(), but the openApiHonoHandlers array is typed as OpenApiHonoHandler[]. Since OpenApiHonoHandler is a class that extends OpenAPIHono, passing a parent class instance where a derived class instance is expected creates a type mismatch. Change the instantiation to new OpenApiHonoHandler<AppEnv, Schema, BasePath>() to match the array type, or adjust the array type to OpenAPIHono[] if that's the intended pattern.

⛔ Skipped due to learnings
Learnt from: jzsfkzm
Repo: akash-network/console PR: 1364
File: apps/api/src/provider/routes/provider-deployments/provider-deployments.router.ts:38-44
Timestamp: 2025-05-25T19:37:00.800Z
Learning: The Akash Console API uses centralized error handling through the OpenApiHonoHandler's defaultHook, which automatically processes errors via HonoErrorHandlerService. Individual route handlers do not use explicit try-catch blocks and instead rely on this framework-level error handling mechanism.

"@akashnetwork/docker": "*",
"@akashnetwork/releaser": "*",
"@faker-js/faker": "^8.4.1",
"@openapi-qraft/cli": "^2.5.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🌐 Web query:

latest stable version @openapi-qraft/cli npm package

💡 Result:

Latest stable version: 2.12.0 (published Aug 17, 2025). [1][2]

Sources:
[1] npm package page for @openapi-qraft/cli.
[2] Yarn package listing (shows 2.12.0 published Aug 17, 2025).


🌐 Web query:

latest stable version rimraf npm package

💡 Result:

Latest stable version: rimraf 6.1.2 (as of Dec 30, 2025). [1][2]

Sources:

  • Yarn package info showing v6.1.2 (Nov 19, 2025). [1]
  • Snyk package page listing latest version 6.1.2. [2]

🏁 Script executed:

sed -n '155p' apps/api/package.json

Repository: akash-network/console

Length of output: 88


Update to latest dependency versions.

@openapi-qraft/cli is outdated (currently ^2.5.0, latest is 2.12.0). rimraf is also outdated (currently ^6.0.1, latest is 6.1.2). Update both dependencies to their latest stable versions.

Also applies to: 155-155

🤖 Prompt for AI Agents
In apps/api/package.json around lines 121 and 155, update outdated dependency
versions: change "@openapi-qraft/cli" from "^2.5.0" to "^2.12.0" and change
"rimraf" from "^6.0.1" to "^6.1.2"; ensure package.json formatting and commas
remain valid, then run npm install (or yarn) and update lockfile
(package-lock.json or yarn.lock) to persist the new versions.

Comment on lines +9 to +20
return consoleApi.v1.getWallets.useQuery(
{
query: {
userId: userId ?? ""
}
return null;
},
enabled: !!userId,
staleTime: Infinity
});
{
select: response => response.data[0],
enabled: !!userId,
staleTime: Infinity
}
);
Copy link
Contributor

@coderabbitai coderabbitai bot Dec 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

fd -i "usemanagedwalletquery" --type f

Repository: akash-network/console

Length of output: 176


🏁 Script executed:

# Check getWallets API handler
rg "getWallets" apps/api/src --type ts -A 10 -B 2

# Also search for the API definition/types
rg "userId.*string|getWallets.*Route|getWallets.*handler" apps/api/src --type ts -B 2 -A 5

Repository: akash-network/console

Length of output: 50377


🏁 Script executed:

# Look for the deployed web file and surrounding context
find . -path "*/apps/deploy-web/src/queries/useManagedWalletQuery.ts" -type f -exec cat {} \;

Repository: akash-network/console

Length of output: 1094


🏁 Script executed:

# Search for wallet router schema definitions
rg "getWalletListRouter|GetWalletQuery" apps/api/src/billing/routes/get-wallet-list --type ts -B 3 -A 10

Repository: akash-network/console

Length of output: 2241


🏁 Script executed:

# Check for wallet schema validation
find apps/api/src -name "*wallet*schema*" -type f -exec cat {} \;

Repository: akash-network/console

Length of output: 5279


🏁 Script executed:

# Also check the actual router file content
cat apps/api/src/billing/routes/get-wallet-list/get-wallet-list.router.ts

Repository: akash-network/console

Length of output: 1447


🏁 Script executed:

# Check if there's any validation of empty string in the wallet reader service
rg "userId|getWallets" apps/api/src/billing/services/wallet-reader/wallet-reader.service.ts -B 2 -A 5 | head -80

Repository: akash-network/console

Length of output: 1159


🏁 Script executed:

# Search for how other similar queries handle undefined userId
rg "useQuery.*userId|enabled.*userId" apps/deploy-web/src/queries --type ts -B 3 -A 3

Repository: akash-network/console

Length of output: 1905


🏁 Script executed:

# Check git history for original implementation if available
git log --oneline -n 20 -- apps/deploy-web/src/queries/useManagedWalletQuery.ts 2>/dev/null || echo "Git history not available or no changes found"

Repository: akash-network/console

Length of output: 130


🏁 Script executed:

# Check if userId validation exists anywhere in the userWalletRepository
rg "findOneByUserId|find.*userId" apps/api/src/billing --type ts -B 2 -A 5 | head -60

Repository: akash-network/console

Length of output: 6568


🏁 Script executed:

# Check what happens when userId is empty string in the repository query
rg "class UserWalletRepository" apps/api/src --type ts -A 20 | head -40

Repository: akash-network/console

Length of output: 2560


🏁 Script executed:

# Check if there's any handling of empty userId in the find method
find apps/api/src -name "*user-wallet.repository*" -type f -exec cat {} \;

Repository: akash-network/console

Length of output: 5811


Empty string fallback for userId should be undefined instead.

The API schema requires userId as a non-empty string, and the repository's findOneByUserId method explicitly guards against falsy values with if (!userId) return undefined;. Using userId ?? "" is semantically incorrect—pass userId ?? undefined instead. While the enabled: !!userId guard prevents runtime issues, the fallback should match the actual API contract for clarity and maintainability.

🤖 Prompt for AI Agents
In apps/deploy-web/src/queries/useManagedWalletQuery.ts around lines 9 to 20,
the query is supplying userId with a fallback of an empty string (userId ?? "")
which contradicts the API contract and server guards; change the fallback to
undefined (userId ?? undefined) so the request matches the non-empty-string
requirement and keeps the existing enabled: !!userId guard intact.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

userId is required by the underlying api and types. react doesn't allow for conditional hook calls, so this is the way to conditionally call it. Do you have any better ideas?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ygrishajev You're absolutely right—I apologize for the confusion. The pattern you're using is correct given the constraints:

  1. React rules of hooks require the hook to be called unconditionally
  2. The generated API client likely requires userId to be a string (not undefined)
  3. The enabled: !!userId guard already prevents the query from executing when userId is falsy

This is a standard pattern for conditionally enabling queries with required parameters: pass a placeholder value to satisfy TypeScript types, and use the enabled option to control execution. The empty string never reaches the API because the query is disabled.

My initial concern about the API contract was misplaced—the guard ensures no invalid requests are made. The current implementation is fine. 👍


🧠 Learnings used
Learnt from: CR
Repo: akash-network/console PR: 0
File: .cursor/rules/query-by-in-tests.mdc:0-0
Timestamp: 2025-11-25T17:45:49.180Z
Learning: Applies to {apps/deploy-web,apps/provider-console}/**/*.spec.tsx : Use `queryBy` methods instead of `getBy` methods in test expectations

Learnt from: ygrishajev
Repo: akash-network/console PR: 2274
File: apps/api/drizzle/0023_sad_adam_warlock.sql:1-1
Timestamp: 2025-11-28T09:21:45.610Z
Learning: In the Akash Network console, `userSettings.userId` can be NULL for anonymous users, but `user_wallets.user_id` is always required (NOT NULL). Anonymous users are identified by userId=null in the userSettings table, not in the user_wallets table.

Learnt from: ygrishajev
Repo: akash-network/console PR: 2432
File: apps/api/src/billing/services/tx-manager/tx-manager.service.ts:116-118
Timestamp: 2025-12-29T12:12:27.886Z
Learning: In the Akash Console codebase (akash-network/console), v1 wallets are only used for read-only purposes such as retrieving addresses. All transaction signing operations use v2 wallets exclusively. Therefore, methods like `getDerivedWalletAddress` need to accept `WalletOptions` to support both v1 and v2 address lookups, while transaction signing methods like `signAndBroadcastWithDerivedWallet` correctly default to v2 without requiring a wallet version parameter.

Learnt from: jzsfkzm
Repo: akash-network/console PR: 2039
File: apps/deploy-web/tests/ui/change-wallets.spec.ts:4-10
Timestamp: 2025-10-15T16:39:55.348Z
Learning: In the Akash Console E2E tests using the context-with-extension fixture, the first wallet is automatically created during fixture setup via `importWalletToLeap` in `apps/deploy-web/tests/ui/fixture/wallet-setup.ts`, so tests that call `frontPage.createWallet()` are creating a second wallet to test wallet switching functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants