Conversation
WalkthroughRefactors numerous import statements across API modules to use TypeScript type-only imports. Changes are limited to import declarations (types vs. value imports); runtime behavior, control flow, and public APIs are unchanged. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Suggested reviewers
Poem
Tip 🔌 Remote MCP (Model Context Protocol) integration is now available!Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats. ✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
🔭 Outside diff range comments (9)
apps/api/src/user/repositories/user/user.repository.ts (1)
2-3: Convert Drizzle types to type-only imports for full consistency with PR goalBoth SQL and PgUpdateSetSource are types and should be imported via import type to avoid pulling runtime code.
Apply:
-import { and, desc, eq, isNull, lt, lte, SQL, sql } from "drizzle-orm"; +import { and, desc, eq, isNull, lt, lte, sql } from "drizzle-orm"; +import type { SQL } from "drizzle-orm"; -import { PgUpdateSetSource } from "drizzle-orm/pg-core"; +import type { PgUpdateSetSource } from "drizzle-orm/pg-core";apps/api/src/provider/services/provider/provider.service.ts (1)
69-75: Avoidanyin catch; useunknownand narrow safelyGuideline: never use
any. Replace withunknownand narrow viainstanceof/property checks.Apply:
- } catch (err: any) { - if (err.message?.includes("no lease for deployment") && i < this.MANIFEST_SEND_MAX_RETRIES) { + } catch (err: unknown) { + if (err instanceof Error && err.message.includes("no lease for deployment") && i < this.MANIFEST_SEND_MAX_RETRIES) { await delay(this.MANIFEST_SEND_RETRY_DELAY); continue; } - throw new Error(err?.response?.data || err); + const responseData = + typeof err === "object" && + err !== null && + "response" in err && + typeof (err as { response?: { data?: unknown } }).response === "object" && + (err as { response?: { data?: unknown } }).response !== null + ? (err as { response?: { data?: unknown } }).response?.data + : undefined; + const message = + typeof responseData === "string" ? responseData : err instanceof Error ? err.message : String(err); + throw new Error(message); }apps/api/src/core/services/tx/tx.service.ts (1)
3-3: Make PostgresJsQueryResultHKT a type-only importIt’s a type parameter only; avoid pulling any runtime from drizzle.
Apply:
-import { PostgresJsQueryResultHKT } from "drizzle-orm/postgres-js/session"; +import type { PostgresJsQueryResultHKT } from "drizzle-orm/postgres-js/session";apps/api/src/core/services/analytics/analytics.service.ts (1)
21-21: Avoid usinganyin public method signaturePer our TS guidelines, replace
Record<string, any>with a safer alternative.Apply this diff:
- track(userId: string, eventName: AnalyticsEvent, eventProperties: Record<string, any> = {}) { + track(userId: string, eventName: AnalyticsEvent, eventProperties: Record<string, unknown> = {}) {If you can define a stricter schema (e.g., string | number | boolean | null), even better:
type AnalyticsProps = Record<string, string | number | boolean | null>;apps/api/src/billing/repositories/checkout-session/checkout-session.repository.ts (1)
41-46: Don’t useanyincatch; narrow fromunknownReplace
catch (error: any)withunknownand narrow to Error to satisfy our TS guideline.Apply this diff:
- } catch (error: any) { - if (error.message === "Session is still active") { + } catch (error: unknown) { + if (error instanceof Error && error.message === "Session is still active") { this.logger.warn({ event: "SESSION_STILL_ACTIVE", sessionId }); return; } }apps/api/src/deployment/repositories/deployment-setting/deployment-setting.repository.ts (1)
64-69: LEFT JOIN allows null walletId; remove unsafe cast or strengthen JOINs
walletIdcan be null due to LEFT JOINs, yet results are cast toAutoTopUpDeployment[](which requires a non-null walletId). This is unsound and can lead to runtime issues downstream.Recommended fix: use INNER JOINs to guarantee presence of
UsersandUserWalletsrows.Apply this diff:
- .leftJoin(Users, eq(this.table.userId, Users.id)) - .leftJoin(UserWallets, eq(Users.id, UserWallets.userId)) + .innerJoin(Users, eq(this.table.userId, Users.id)) + .innerJoin(UserWallets, eq(Users.id, UserWallets.userId))Alternative if LEFT JOINs are required by business logic: filter out nulls before yielding and drop the unsafe cast.
- if (items.length) { - // BUGALERT: walletId may be null because of LEFT JOIN. should be INNER JOIN? - yield items as AutoTopUpDeployment[]; - } + if (items.length) { + const safeItems = items.filter((i): i is AutoTopUpDeployment => i.walletId != null); + if (safeItems.length) { + yield safeItems; + } + }apps/api/src/billing/controllers/checkout/checkout.controller.ts (1)
37-45: Avoidanyin catch blocks; useunknownand narrowThe coding guidelines prohibit
any. Useunknownand narrow to Error to read message safely.- } catch (error: any) { - if (error.message === "Price invalid") { - return c.redirect(`${redirectUrl}?invalid-price=true`); - } - - this.logger.error(error); - - return c.redirect(`${redirectUrl}?unknown-error=true`); - } + } catch (error: unknown) { + const message = error instanceof Error ? error.message : String(error); + if (message === "Price invalid") { + return c.redirect(`${redirectUrl}?invalid-price=true`); + } + this.logger.error(error instanceof Error ? error : new Error(message)); + return c.redirect(`${redirectUrl}?unknown-error=true`); + }apps/api/src/billing/services/managed-user-wallet/managed-user-wallet.service.ts (1)
108-111: Replaceanywith the proper options typeThe guidelines disallow
any. This function expects the full SpendingAuthorizationMsgOptions (includes denom and limit).- private async authorizeDeploymentSpending(options: any) { + private async authorizeDeploymentSpending(options: SpendingAuthorizationMsgOptions) { const deploymentAllowanceMsg = this.rpcMessageService.getDepositDeploymentGrantMsg(options); return await this.managedSignerService.executeRootTx([deploymentAllowanceMsg]); }apps/api/src/billing/services/provider-cleanup/provider-cleanup.service.ts (1)
62-76: Replaceanyin catch withunknownand narrow the errorCoding guidelines disallow
any. Narrow the error safely before accessing.message.Apply this diff:
- } catch (error: any) { - if (error.message.includes("not allowed to pay fees")) { + } catch (error: unknown) { + if (error instanceof Error && error.message.includes("not allowed to pay fees")) { if (!options.dryRun) { await this.managedUserWalletService.authorizeSpending({ address: wallet.address!, limits: { fees: this.config.FEE_ALLOWANCE_REFILL_AMOUNT } }); await this.managedSignerService.executeManagedTx(wallet.id, [message]); this.logger.info({ event: "PROVIDER_CLEAN_UP_SUCCESS" }); } } else { throw error; }
🧹 Nitpick comments (7)
apps/api/src/provider/services/provider/provider.service.ts (1)
15-15: Import ProviderIdentity as a type-only importUsed strictly for typing local constants; no runtime usage.
Apply:
-import { ProviderIdentity } from "@src/provider/services/provider/provider-proxy.service"; +import type { ProviderIdentity } from "@src/provider/services/provider/provider-proxy.service";apps/api/src/billing/repositories/payment-method/payment-method.repository.ts (1)
41-43: Minor: remove redundant await
deleteBypresumably returns a Promise; returning it directly avoids an unnecessaryawait.- async deleteByFingerprint(fingerprint: string, paymentMethodId: string, userId: string) { - return await this.deleteBy({ fingerprint, paymentMethodId, userId }); - } + async deleteByFingerprint(fingerprint: string, paymentMethodId: string, userId: string) { + return this.deleteBy({ fingerprint, paymentMethodId, userId }); + }apps/api/src/billing/services/balances/balances.service.ts (2)
1-1: Import DeploymentInfo as a type-only importDeploymentInfo is only used in type positions (reduce callback). Make it a type-only import to match the PR’s goal.
-import { AuthzHttpService, DeploymentHttpService, DeploymentInfo } from "@akashnetwork/http-sdk"; +import { AuthzHttpService, DeploymentHttpService, type DeploymentInfo } from "@akashnetwork/http-sdk";
4-4: Also import Wallet as a type-only importWallet is used purely as a type annotation in the constructor parameter. Importing it as type reduces runtime imports and aligns with the PR changes. The injection relies on the @InjectWallet token, not the type.
-import { Wallet } from "@src/billing/lib/wallet/wallet"; +import { type Wallet } from "@src/billing/lib/wallet/wallet";apps/api/src/billing/services/managed-user-wallet/managed-user-wallet.service.ts (2)
4-4: Make EncodeObject a type-only importEncodeObject is used only as a type (messages arrays). Import it as a type.
-import { DirectSecp256k1HdWallet, EncodeObject } from "@cosmjs/proto-signing"; +import { DirectSecp256k1HdWallet, type EncodeObject } from "@cosmjs/proto-signing";
13-13: Import SpendingAuthorizationMsgOptions as a type-only importIt’s used purely in type positions; keep it out of runtime bundles.
-import { RpcMessageService, SpendingAuthorizationMsgOptions } from "../rpc-message-service/rpc-message.service"; +import { RpcMessageService, type SpendingAuthorizationMsgOptions } from "../rpc-message-service/rpc-message.service";apps/api/src/provider/services/provider-graph-data/provider-graph-data.service.ts (1)
106-112: Fix typo in variable name for readabilityRename isFirstFifteenMinuesOfDay to isFirstFifteenMinutesOfDay. Keeps code clear and avoids future confusion.
- const isFirstFifteenMinuesOfDay = now.getHours() === 0 && now.getMinutes() <= 15; + const isFirstFifteenMinutesOfDay = now.getHours() === 0 && now.getMinutes() <= 15; const lastItem = stats.length > 0 ? stats[stats.length - 1] : null; const lastItemIsForToday = lastItem && isSameDay(lastItem.date, now); - if (isFirstFifteenMinuesOfDay && lastItemIsForToday) { + if (isFirstFifteenMinutesOfDay && lastItemIsForToday) { return stats.slice(0, stats.length - 1); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (21)
apps/api/src/auth/repositories/api-key/api-key.repository.ts(1 hunks)apps/api/src/billing/controllers/checkout/checkout.controller.ts(1 hunks)apps/api/src/billing/repositories/checkout-session/checkout-session.repository.ts(1 hunks)apps/api/src/billing/repositories/payment-method/payment-method.repository.ts(1 hunks)apps/api/src/billing/repositories/user-wallet/user-wallet.repository.ts(1 hunks)apps/api/src/billing/services/balances/balances.service.ts(1 hunks)apps/api/src/billing/services/financial-stats/financial-stats.service.ts(1 hunks)apps/api/src/billing/services/managed-user-wallet/managed-user-wallet.service.ts(1 hunks)apps/api/src/billing/services/provider-cleanup/provider-cleanup.service.ts(1 hunks)apps/api/src/billing/services/refill/refill.service.ts(1 hunks)apps/api/src/core/services/analytics/analytics.service.ts(1 hunks)apps/api/src/core/services/tx/tx.service.ts(1 hunks)apps/api/src/deployment/controllers/deployment-setting/deployment-setting.controller.ts(1 hunks)apps/api/src/deployment/controllers/lease/lease.controller.ts(1 hunks)apps/api/src/deployment/repositories/deployment-setting/deployment-setting.repository.ts(1 hunks)apps/api/src/deployment/services/sdl/sdl.service.ts(1 hunks)apps/api/src/gpu/services/gpu.service.ts(1 hunks)apps/api/src/healthz/services/healthz/healthz.service.ts(1 hunks)apps/api/src/provider/services/provider-graph-data/provider-graph-data.service.ts(1 hunks)apps/api/src/provider/services/provider/provider.service.ts(1 hunks)apps/api/src/user/repositories/user/user.repository.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/general.mdc)
Never use type any or cast to type any. Always define the proper TypeScript types.
Files:
apps/api/src/billing/services/balances/balances.service.tsapps/api/src/gpu/services/gpu.service.tsapps/api/src/healthz/services/healthz/healthz.service.tsapps/api/src/billing/services/financial-stats/financial-stats.service.tsapps/api/src/billing/services/refill/refill.service.tsapps/api/src/billing/repositories/payment-method/payment-method.repository.tsapps/api/src/deployment/services/sdl/sdl.service.tsapps/api/src/provider/services/provider/provider.service.tsapps/api/src/provider/services/provider-graph-data/provider-graph-data.service.tsapps/api/src/billing/controllers/checkout/checkout.controller.tsapps/api/src/core/services/analytics/analytics.service.tsapps/api/src/user/repositories/user/user.repository.tsapps/api/src/deployment/repositories/deployment-setting/deployment-setting.repository.tsapps/api/src/deployment/controllers/lease/lease.controller.tsapps/api/src/billing/services/managed-user-wallet/managed-user-wallet.service.tsapps/api/src/billing/repositories/checkout-session/checkout-session.repository.tsapps/api/src/auth/repositories/api-key/api-key.repository.tsapps/api/src/core/services/tx/tx.service.tsapps/api/src/deployment/controllers/deployment-setting/deployment-setting.controller.tsapps/api/src/billing/services/provider-cleanup/provider-cleanup.service.tsapps/api/src/billing/repositories/user-wallet/user-wallet.repository.ts
**/*.{js,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/general.mdc)
**/*.{js,ts,tsx}: Never use deprecated methods from libraries.
Don't add unnecessary comments to the code
Files:
apps/api/src/billing/services/balances/balances.service.tsapps/api/src/gpu/services/gpu.service.tsapps/api/src/healthz/services/healthz/healthz.service.tsapps/api/src/billing/services/financial-stats/financial-stats.service.tsapps/api/src/billing/services/refill/refill.service.tsapps/api/src/billing/repositories/payment-method/payment-method.repository.tsapps/api/src/deployment/services/sdl/sdl.service.tsapps/api/src/provider/services/provider/provider.service.tsapps/api/src/provider/services/provider-graph-data/provider-graph-data.service.tsapps/api/src/billing/controllers/checkout/checkout.controller.tsapps/api/src/core/services/analytics/analytics.service.tsapps/api/src/user/repositories/user/user.repository.tsapps/api/src/deployment/repositories/deployment-setting/deployment-setting.repository.tsapps/api/src/deployment/controllers/lease/lease.controller.tsapps/api/src/billing/services/managed-user-wallet/managed-user-wallet.service.tsapps/api/src/billing/repositories/checkout-session/checkout-session.repository.tsapps/api/src/auth/repositories/api-key/api-key.repository.tsapps/api/src/core/services/tx/tx.service.tsapps/api/src/deployment/controllers/deployment-setting/deployment-setting.controller.tsapps/api/src/billing/services/provider-cleanup/provider-cleanup.service.tsapps/api/src/billing/repositories/user-wallet/user-wallet.repository.ts
⏰ 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). (2)
- GitHub Check: validate / validate-app
- GitHub Check: test-build
🔇 Additional comments (23)
apps/api/src/user/repositories/user/user.repository.ts (1)
6-7: Good: converted DB/table/ability imports to type-only while keeping decorators as value importsThis aligns with tsup-friendly type elision and preserves runtime decorators.
apps/api/src/healthz/services/healthz/healthz.service.ts (1)
7-7: LGTM: ApiPgDatabase switched to type-only importConstructor param is injected via @InjectPg, so no runtime reliance on the type value. Matches the PR’s objective.
apps/api/src/provider/services/provider/provider.service.ts (1)
10-10: LGTM: BillingConfig is now a type-only import, decorator remains a value import@InJECTBillingConfig supplies the runtime token; the type is only used for annotation, so this change is safe and compliant.
apps/api/src/core/services/tx/tx.service.ts (1)
7-7: LGTM: ApiPgDatabase/ApiPgTables as type-only, InjectPg as value importMatches tsup-friendly pattern; only annotations depend on the types.
apps/api/src/core/services/analytics/analytics.service.ts (1)
3-4: Type-only imports for DI types: correct and safeSwitching Amplitude and Hasher to type-only imports while keeping AMPLITUDE and HASHER as value tokens is correct and keeps DI working. This also helps tsup by removing unused runtime imports.
apps/api/src/billing/repositories/checkout-session/checkout-session.repository.ts (1)
5-6: Type-only imports applied correctlyConverting ApiPgDatabase, ApiPgTables, and AbilityParams to type-only while keeping InjectPg/InjectPgTable and BaseRepository as value imports is correct. All usages are in type positions.
apps/api/src/billing/services/financial-stats/financial-stats.service.ts (1)
9-9: Type-only import for BillingConfig: correctKeeping InjectBillingConfig as a value import and BillingConfig as a type-only import aligns with the PR goal and maintains runtime behavior.
apps/api/src/billing/repositories/user-wallet/user-wallet.repository.ts (1)
4-5: Type-only imports for DB types and AbilityParams: correctApiPgDatabase, ApiPgTables, and AbilityParams are only used in type positions; keeping InjectPg/InjectPgTable and BaseRepository as value imports is correct.
apps/api/src/billing/services/refill/refill.service.ts (1)
5-6: Type-only imports for BillingConfig and UserWalletOutput: correctThis cleanly separates type and value imports and should help tsup with tree-shaking. Runtime behavior remains unchanged.
apps/api/src/deployment/controllers/lease/lease.controller.ts (1)
6-7: Type-only schema imports are correct and reduce runtime depsThese are used purely in type positions (method signature/return), so switching to
import typeis safe and aligns with the PR goal.If
CreateLeaseRequestfollows the common{ data: ... }shape used elsewhere, consider verifying whether the parameter should beCreateLeaseRequest["data"]for consistency. If its schema differs, keep as-is.apps/api/src/deployment/repositories/deployment-setting/deployment-setting.repository.ts (1)
6-8: Type-only DB and ability imports: ✅
ApiPgDatabase,ApiPgTables, andAbilityParamsare used only in type positions, soimport typeis appropriate. Decorator-based injections (@InjectPg,@InjectPgTable) remain unaffected at runtime.apps/api/src/deployment/services/sdl/sdl.service.ts (2)
6-6: Type-only BillingConfig import is safe with explicit injectorUsing
import typeforBillingConfigis correct here; runtime resolution is handled via@InjectBillingConfig(), so no reflection on the type is required.
31-35: Potential double-stringify of manifest when asString = trueIf
sdl.manifest(true)already returns a string (common in such APIs),JSON.stringifywill produce an extra quoted string. Verify and simplify accordingly.Apply this diff if
manifest(true)returns a string:- const manifest = sdl.manifest(asString); - return asString ? (JSON.stringify(manifest) as string) : manifest; + const manifest = sdl.manifest(asString); + return asString ? (manifest as string) : manifest;apps/api/src/deployment/controllers/deployment-setting/deployment-setting.controller.ts (1)
6-10: Type-only schema imports are correct and consistentAll four imports are used purely for typing in method signatures; converting them to
import typeis correct and matches the PR’s objective.apps/api/src/billing/repositories/payment-method/payment-method.repository.ts (1)
4-5: Type-only DB and ability imports: ✅
ApiPgDatabase,ApiPgTables, andAbilityParamsare used only for typing;import typereduces bundled runtime deps without behavior changes. Decorator-based injections remain intact.apps/api/src/billing/services/balances/balances.service.ts (1)
5-5: Type-only imports applied correctlySwitching BillingConfig, UserWalletInput, and UserWalletOutput to type-only imports is correct and keeps runtime bundles clean. No runtime references to these identifiers in this file.
Also applies to: 7-7
apps/api/src/billing/controllers/checkout/checkout.controller.ts (1)
6-6: Type-only BillingConfig import is correctGood change. Keeps DI token InjectBillingConfig as a runtime import and BillingConfig as type-only.
apps/api/src/billing/services/managed-user-wallet/managed-user-wallet.service.ts (1)
9-9: Type-only BillingConfig import is correctMatches the PR aim and keeps runtime import surface minimal.
apps/api/src/provider/services/provider-graph-data/provider-graph-data.service.ts (1)
8-8: Type-only imports for ProviderStats/ProviderStatsKey are correctThese are used exclusively in type positions; good change.
apps/api/src/auth/repositories/api-key/api-key.repository.ts (1)
5-6: Type-only imports look goodApiPgDatabase, ApiPgTables, and AbilityParams are now type-only, while DI tokens remain value imports. This matches the PR objective without affecting runtime.
apps/api/src/billing/services/provider-cleanup/provider-cleanup.service.ts (3)
4-4: Type-only import for BillingConfig is correct and safe hereBillingConfig is used purely as a type annotation for
this.config, andInjectBillingConfigremains a value import for DI. This aligns with tsup’s requirements and won’t affect runtime.
5-5: Good separation of type vs value for repository layerUsing
import typeforUserWalletOutputwhile keepingUserWalletRepositoryas a value import is appropriate and preserves runtime behavior.
8-8: Type-only import for ProviderCleanupParams is appropriate
ProviderCleanupParamsis used only in method signatures; making it a type-only import eliminates unnecessary runtime imports.
| import { type GpuVendor, ProviderConfigGpusType } from "@src/types/gpu"; | ||
| import { type GpuBreakdownQuery } from "../http-schemas/gpu.schema"; | ||
| import { GpuRepository } from "../repositories/gpu.repository"; |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Also import ProviderConfigGpusType as a type-only import
ProviderConfigGpusType is used only in type positions (axios generic). Importing it as a value keeps an unnecessary runtime dependency.
Apply:
-import { type GpuVendor, ProviderConfigGpusType } from "@src/types/gpu";
+import type { GpuVendor, ProviderConfigGpusType } from "@src/types/gpu";
import { type GpuBreakdownQuery } from "../http-schemas/gpu.schema";📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import { type GpuVendor, ProviderConfigGpusType } from "@src/types/gpu"; | |
| import { type GpuBreakdownQuery } from "../http-schemas/gpu.schema"; | |
| import { GpuRepository } from "../repositories/gpu.repository"; | |
| import type { GpuVendor, ProviderConfigGpusType } from "@src/types/gpu"; | |
| import { type GpuBreakdownQuery } from "../http-schemas/gpu.schema"; | |
| import { GpuRepository } from "../repositories/gpu.repository"; |
🤖 Prompt for AI Agents
In apps/api/src/gpu/services/gpu.service.ts around lines 6 to 8,
ProviderConfigGpusType is only used as a type so change its import to a
type-only import to avoid a runtime dependency; update the import statement to
use the TypeScript "import type" form for ProviderConfigGpusType while keeping
the other imports unchanged.
| import { BillingConfig, InjectBillingConfig } from "@src/billing/providers"; | ||
| import { type BillingConfig, InjectBillingConfig } from "@src/billing/providers"; | ||
| import { AUDITOR, TRIAL_ATTRIBUTE } from "@src/deployment/config/provider.config"; | ||
| import { LeaseStatusResponse } from "@src/deployment/http-schemas/lease.schema"; |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Import LeaseStatusResponse as a type-only import
It’s only used for typing (return type and generics). Switching prevents unnecessary runtime import.
Apply:
-import { LeaseStatusResponse } from "@src/deployment/http-schemas/lease.schema";
+import type { LeaseStatusResponse } from "@src/deployment/http-schemas/lease.schema";📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import { LeaseStatusResponse } from "@src/deployment/http-schemas/lease.schema"; | |
| import type { LeaseStatusResponse } from "@src/deployment/http-schemas/lease.schema"; |
🤖 Prompt for AI Agents
In apps/api/src/provider/services/provider/provider.service.ts around line 12,
the LeaseStatusResponse symbol is only used for typing, so change the runtime
import to a type-only import: replace the current import with a TypeScript
"import type { LeaseStatusResponse } from
'@src/deployment/http-schemas/lease.schema';" so the compiler erases the import
at runtime and avoids unnecessary module loading.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1810 +/- ##
==========================================
- Coverage 42.78% 42.49% -0.30%
==========================================
Files 940 935 -5
Lines 26476 26299 -177
Branches 6958 6943 -15
==========================================
- Hits 11329 11176 -153
+ Misses 13989 13965 -24
Partials 1158 1158
*This pull request uses carry forward flags. Click here to find out more.
🚀 New features to boost your workflow:
|
c40eb58 to
131b157
Compare
131b157 to
beed109
Compare
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
apps/api/src/billing/services/balances/balances.service.ts (4)
1-1: Make DeploymentInfo a type-only import; keep services as value imports
DeploymentInfois only used in type positions. Convert it to a type-only import while keepingAuthzHttpServiceandDeploymentHttpServiceas value imports to preserve DI metadata.-import { AuthzHttpService, DeploymentHttpService, DeploymentInfo } from "@akashnetwork/http-sdk"; +import { AuthzHttpService, DeploymentHttpService } from "@akashnetwork/http-sdk"; +import type { DeploymentInfo } from "@akashnetwork/http-sdk";
4-4: Optionally import Wallet as type-only (DI uses InjectWallet token)
Walletis only used for typing the injected param and DI uses@InjectWallet("MANAGED"). You can avoid a runtime import by switching to a type-only import.-import { Wallet } from "@src/billing/lib/wallet/wallet"; +import type { Wallet } from "@src/billing/lib/wallet/wallet";Please confirm this doesn’t affect tsyringe resolution in your setup (it shouldn’t, since the token decorator is used).
61-61: Specify radix for parseInt to avoid implicit baseExplicitly pass radix 10 for clarity and to avoid edge cases.
- return feeAllowance.allowance.spend_limit.reduce((acc, { denom, amount }) => (denom === "uakt" ? acc + parseInt(amount) : acc), 0); + return feeAllowance.allowance.spend_limit.reduce( + (acc, { denom, amount }) => (denom === "uakt" ? acc + Number.parseInt(amount, 10) : acc), + 0 + );
72-72: Specify radix for parseInt here as wellSame rationale as above.
- return parseInt(depositDeploymentGrant.authorization.spend_limit.amount); + return Number.parseInt(depositDeploymentGrant.authorization.spend_limit.amount, 10);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (21)
apps/api/src/auth/repositories/api-key/api-key.repository.ts(1 hunks)apps/api/src/billing/controllers/checkout/checkout.controller.ts(1 hunks)apps/api/src/billing/repositories/checkout-session/checkout-session.repository.ts(1 hunks)apps/api/src/billing/repositories/payment-method/payment-method.repository.ts(1 hunks)apps/api/src/billing/repositories/user-wallet/user-wallet.repository.ts(1 hunks)apps/api/src/billing/services/balances/balances.service.ts(1 hunks)apps/api/src/billing/services/financial-stats/financial-stats.service.ts(1 hunks)apps/api/src/billing/services/managed-user-wallet/managed-user-wallet.service.ts(1 hunks)apps/api/src/billing/services/provider-cleanup/provider-cleanup.service.ts(1 hunks)apps/api/src/billing/services/refill/refill.service.ts(1 hunks)apps/api/src/core/services/analytics/analytics.service.ts(1 hunks)apps/api/src/core/services/tx/tx.service.ts(1 hunks)apps/api/src/deployment/controllers/deployment-setting/deployment-setting.controller.ts(1 hunks)apps/api/src/deployment/controllers/lease/lease.controller.ts(1 hunks)apps/api/src/deployment/repositories/deployment-setting/deployment-setting.repository.ts(1 hunks)apps/api/src/deployment/services/sdl/sdl.service.ts(1 hunks)apps/api/src/gpu/services/gpu.service.ts(1 hunks)apps/api/src/healthz/services/healthz/healthz.service.ts(1 hunks)apps/api/src/provider/services/provider-graph-data/provider-graph-data.service.ts(1 hunks)apps/api/src/provider/services/provider/provider.service.ts(1 hunks)apps/api/src/user/repositories/user/user.repository.ts(1 hunks)
✅ Files skipped from review due to trivial changes (1)
- apps/api/src/gpu/services/gpu.service.ts
🚧 Files skipped from review as they are similar to previous changes (19)
- apps/api/src/core/services/tx/tx.service.ts
- apps/api/src/billing/repositories/payment-method/payment-method.repository.ts
- apps/api/src/billing/services/managed-user-wallet/managed-user-wallet.service.ts
- apps/api/src/provider/services/provider-graph-data/provider-graph-data.service.ts
- apps/api/src/deployment/services/sdl/sdl.service.ts
- apps/api/src/billing/controllers/checkout/checkout.controller.ts
- apps/api/src/deployment/repositories/deployment-setting/deployment-setting.repository.ts
- apps/api/src/core/services/analytics/analytics.service.ts
- apps/api/src/billing/services/financial-stats/financial-stats.service.ts
- apps/api/src/billing/repositories/user-wallet/user-wallet.repository.ts
- apps/api/src/billing/services/refill/refill.service.ts
- apps/api/src/billing/repositories/checkout-session/checkout-session.repository.ts
- apps/api/src/healthz/services/healthz/healthz.service.ts
- apps/api/src/deployment/controllers/deployment-setting/deployment-setting.controller.ts
- apps/api/src/deployment/controllers/lease/lease.controller.ts
- apps/api/src/billing/services/provider-cleanup/provider-cleanup.service.ts
- apps/api/src/provider/services/provider/provider.service.ts
- apps/api/src/user/repositories/user/user.repository.ts
- apps/api/src/auth/repositories/api-key/api-key.repository.ts
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/general.mdc)
Never use type any or cast to type any. Always define the proper TypeScript types.
Files:
apps/api/src/billing/services/balances/balances.service.ts
**/*.{js,ts,tsx}
📄 CodeRabbit Inference Engine (.cursor/rules/general.mdc)
**/*.{js,ts,tsx}: Never use deprecated methods from libraries.
Don't add unnecessary comments to the code
Files:
apps/api/src/billing/services/balances/balances.service.ts
⏰ 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). (2)
- GitHub Check: validate / validate-app
- GitHub Check: test-build
🔇 Additional comments (2)
apps/api/src/billing/services/balances/balances.service.ts (2)
5-5: Good: Type-only import for BillingConfig matches DI usageUsing
import typeforBillingConfigis correct here since@InjectBillingConfig()provides the runtime token and no runtime reference toBillingConfigis needed.
7-7: Good: DTOs as type-only, repository as value import
UserWalletInput/UserWalletOutputare correctly imported as types while keepingUserWalletRepositoryas a runtime import for DI. This aligns with the PR goal without affecting behavior.
Why
This is needed for tsup to compile our app. Basically every type should be imported as type
Summary by CodeRabbit
No user-facing changes in this release.