Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Caution Review failedThe pull request is closed. WalkthroughThis update transitions the application from a direct server action and utility-based architecture to a modular oRPC-based structure. It removes legacy server action files, introduces orpc routers, hooks, and context, and refactors components to use the new query/mutation hooks. Prisma schemas are updated for explicit table mapping, and new utility functions and DTO schemas are added for strong typing and modularity. Changes
Sequence Diagram(s)sequenceDiagram
participant UI as React Component
participant Hook as orpc Hook (useX)
participant orpc as orpc Client/Router
participant DB as Database
UI->>Hook: Call useQuery/useMutation
Hook->>orpc: Send request (query/mutation)
orpc->>DB: Perform CRUD operation (with auth/context)
DB-->>orpc: Return data/result
orpc-->>Hook: Return typed response
Hook-->>UI: Provide data, status, errors
Poem
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
orpc/routers/credential.tsOops! Something went wrong! :( ESLint: 9.26.0 ESLint couldn't find the plugin "eslint-plugin-react-hooks". (The package "eslint-plugin-react-hooks" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following: The plugin "eslint-plugin-react-hooks" was referenced from the config file in " » eslint-config-next/core-web-vitals » /node_modules/.pnpm/eslint-config-next@15.3.2_eslint@9.26.0_jiti@2.4.2__typescript@5.8.3/node_modules/eslint-config-next/index.js". If you still can't figure out the problem, please see https://eslint.org/docs/latest/use/troubleshooting. app/(marketing)/page.tsxOops! Something went wrong! :( ESLint: 9.26.0 ESLint couldn't find the plugin "eslint-plugin-react-hooks". (The package "eslint-plugin-react-hooks" was not found when loaded as a Node module from the directory "".) It's likely that the plugin isn't installed correctly. Try reinstalling by running the following: The plugin "eslint-plugin-react-hooks" was referenced from the config file in " » eslint-config-next/core-web-vitals » /node_modules/.pnpm/eslint-config-next@15.3.2_eslint@9.26.0_jiti@2.4.2__typescript@5.8.3/node_modules/eslint-config-next/index.js". If you still can't figure out the problem, please see https://eslint.org/docs/latest/use/troubleshooting. ✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 10
🔭 Outside diff range comments (1)
prisma/schema/migrations/20250616192028_usage_of_map/migration.sql (1)
1-430:⚠️ CRITICAL: This migration will DELETE ALL DATA!This migration drops all existing tables before recreating them, which will result in complete data loss. This is extremely dangerous for production environments.
If you need to rename tables while preserving data, use
ALTER TABLEstatements instead:-- Example of safe table renaming ALTER TABLE "Card" RENAME TO "card"; ALTER TABLE "CardMetadata" RENAME TO "card_metadata"; -- ... etc for all tablesIf this is intentionally destructive (e.g., for initial setup only), please:
- Add a clear warning comment at the top of the migration
- Ensure this migration is never run on production
- Consider adding a safety check or requiring explicit confirmation
🧹 Nitpick comments (12)
TODO.md (1)
54-56: Add priority label to the new TODO item.
To maintain the established format, append|| Low(or an appropriate priority) after the new taskUse services instead of \lib` files`.orpc/context.ts (1)
7-24: Consider structured logging for production environments.The context creation function is well-implemented with proper error handling and appropriate fallback values. However, consider replacing
console.errorwith structured logging for production environments to improve observability and error tracking.For production, consider using a logging library:
} catch (error) { - console.error("Failed to get session:", error) + // Use your preferred logging library (e.g., winston, pino) + logger.error("Failed to get session", { error: error.message, stack: error.stack }) return { session: null, user: null, } }app/api/orpc/[[...rest]]/route.ts (1)
10-10: Consider caching context creation for performance.Creating context on every request might be expensive, especially if
createContext()performs database queries or external API calls. Consider implementing request-level caching or memoization if appropriate.lib/utils/encryption-helpers.ts (1)
23-23: Consider structured logging for production.While console.error works for development, consider using a structured logging solution for production environments.
- console.error("Error creating encrypted data:", error) + console.error("Error creating encrypted data:", { + error: error instanceof Error ? error.message : String(error), + stack: error instanceof Error ? error.stack : undefined, + })middleware/auth.ts (1)
14-31: Consider simplifying context object construction in authMiddleware.The middleware correctly enforces authentication and narrows the context type. However, the context reconstruction could be simplified.
Instead of spreading the entire context and then explicitly setting session and user, consider using type assertion since we've already validated their presence:
return next({ - context: { - session: context.session, - user: context.user, - }, + context: context as AuthenticatedContext, })This approach is more efficient and leverages TypeScript's type system effectively.
schemas/credential/credential-with-metadata.ts (1)
12-17: Consider clarifying the distinction betweenerrorandissuesfields.Having both
errorandissuesas optional fields in the output schema could be confusing. Consider documenting when each field is used, or combining them into a single field for consistency.export const createCredentialWithMetadataOutputSchema = z.object({ success: z.boolean(), credential: credentialOutputSchema.optional(), - error: z.string().optional(), - issues: z.array(z.string()).optional(), + error: z.string().optional(), // For general errors + issues: z.array(z.string()).optional(), // For validation errors })components/app/dashboard-add-credential-dialog.tsx (2)
150-159: Remove redundant validation checks.These validation checks for identifier and password are redundant since the form already uses
zodResolver(credentialDtoSchema)which should handle this validation. The form'strigger()method on line 172 will catch these validation errors.- if (!sensitiveData.identifier.trim()) { - toast("Identifier is required", "error") - return - } - - if (!sensitiveData.password.trim()) { - toast("Password is required", "error") - return - } - try {
326-330: Simplify the tag mapping.Explicitly setting optional fields to
undefinedis unnecessary. TypeScript already treats missing optional properties as undefined.- availableTags={availableTags.map((tag) => ({ - name: tag.name, - containerId: tag.containerId || undefined, - color: tag.color || undefined, - }))} + availableTags={availableTags}orpc/routers/user.ts (1)
67-67: Consider usingz.void()for procedures without input.For procedures that don't require any input, using
z.void()is cleaner thanz.object({}).- .input(z.object({})) + .input(z.void())Also applies to: 76-76, 85-85
orpc/hooks/use-containers.ts (1)
161-164: Consider usingsetQueryDatainstead ofremoveQueriesfor better UX.Using
removeQueriescompletely removes the cached data, which might cause loading states to appear. Consider setting the data tonullorundefinedinstead to maintain smoother UI transitions.- // Optimistically remove from cache - queryClient.removeQueries({ - queryKey: orpc.containers.get.key({ input: { id: input.id } }), - }) + // Optimistically mark as deleted in cache + queryClient.setQueryData( + orpc.containers.get.queryKey({ input: { id: input.id } }), + null + )orpc/routers/secret.ts (1)
55-59: Consider the implications of updatinglastViewedon every get operation.Updating the
lastViewedtimestamp on every GET request is a side effect that might not be expected from a read operation. This could also impact performance with frequent reads and may not align with RESTful principles where GET operations should be idempotent.Consider either:
- Making this update optional via a query parameter
- Moving this to a separate "markAsViewed" procedure
- Documenting this behavior clearly for API consumers
- // Update last viewed timestamp - await database.secret.update({ - where: { id: input.id }, - data: { lastViewed: new Date() }, - }) + // Optionally update last viewed timestamp + if (input.updateLastViewed !== false) { + await database.secret.update({ + where: { id: input.id }, + data: { lastViewed: new Date() }, + }) + }orpc/hooks/use-credentials.ts (1)
35-56: Consider more robust error handling.The current error handling only logs to console. Consider exposing errors to the UI for better user feedback.
You could enhance error handling by:
- Using toast notifications to display errors to users
- Returning the error from the hook for component-level handling
- Implementing a global error boundary
Example with toast:
onError: (error) => { console.error("Failed to create credential:", error) + // toast.error("Failed to create credential. Please try again.") },
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (82)
TODO.md(1 hunks)actions/card/card-metadata.ts(0 hunks)actions/card/card.ts(0 hunks)actions/card/index.ts(0 hunks)actions/credential/credential-metadata.ts(0 hunks)actions/credential/credential.ts(0 hunks)actions/credential/index.ts(0 hunks)actions/encryption/card-encryption.ts(0 hunks)actions/encryption/credential-encryption.ts(0 hunks)actions/encryption/encrypted-data.ts(0 hunks)actions/encryption/index.ts(0 hunks)actions/encryption/secret-encryption.ts(0 hunks)actions/secrets/index.ts(0 hunks)actions/secrets/secret-metadata.ts(0 hunks)actions/secrets/secret.ts(0 hunks)actions/user/index.ts(0 hunks)actions/user/user.ts(0 hunks)actions/user/waitlist.ts(0 hunks)actions/utils/container.ts(0 hunks)actions/utils/index.ts(0 hunks)actions/utils/platform.ts(0 hunks)actions/utils/tag.ts(0 hunks)app/(dashboard)/dashboard/page.tsx(3 hunks)app/(marketing)/page.tsx(1 hunks)app/api/orpc/[[...rest]]/route.ts(1 hunks)components/app/dashboard-add-card-dialog.tsx(5 hunks)components/app/dashboard-add-card-form.tsx(1 hunks)components/app/dashboard-add-credential-dialog.tsx(8 hunks)components/app/dashboard-add-secret-dialog.tsx(5 hunks)components/app/dashboard-overview-stats.tsx(0 hunks)components/app/marketing-waitlist-form.tsx(5 hunks)components/layout/layout-wrapper.tsx(1 hunks)hooks/use-platforms.ts(0 hunks)hooks/use-tags.ts(0 hunks)lib/utils/encryption-helpers.ts(1 hunks)lib/utils/index.ts(2 hunks)lib/utils/tag-helpers.ts(1 hunks)middleware/auth.ts(1 hunks)middleware/index.ts(1 hunks)orpc/client/index.ts(1 hunks)orpc/client/query.ts(1 hunks)orpc/client/rpc.ts(1 hunks)orpc/client/server.ts(1 hunks)orpc/client/utils.ts(1 hunks)orpc/context.ts(1 hunks)orpc/hooks/index.ts(1 hunks)orpc/hooks/use-cards.ts(1 hunks)orpc/hooks/use-containers.ts(1 hunks)orpc/hooks/use-credentials.ts(1 hunks)orpc/hooks/use-platforms.ts(1 hunks)orpc/hooks/use-secrets.ts(1 hunks)orpc/hooks/use-tags.ts(1 hunks)orpc/hooks/use-users.ts(1 hunks)orpc/routers/card.ts(1 hunks)orpc/routers/container.ts(1 hunks)orpc/routers/credential.ts(1 hunks)orpc/routers/index.ts(1 hunks)orpc/routers/platform.ts(1 hunks)orpc/routers/secret.ts(1 hunks)orpc/routers/tag.ts(1 hunks)orpc/routers/user.ts(1 hunks)orpc/types.ts(1 hunks)package.json(3 hunks)prettier.config.js(1 hunks)prisma/schema/cards.prisma(2 hunks)prisma/schema/credential.prisma(3 hunks)prisma/schema/encryption.prisma(1 hunks)prisma/schema/migrations/20250616192028_usage_of_map/migration.sql(1 hunks)prisma/schema/secrets.prisma(2 hunks)prisma/schema/utils.prisma(3 hunks)schemas/card/card.ts(1 hunks)schemas/card/dto.ts(1 hunks)schemas/credential/credential-with-metadata.ts(1 hunks)schemas/credential/dto.ts(1 hunks)schemas/credential/index.ts(1 hunks)schemas/secrets/dto.ts(1 hunks)schemas/user/index.ts(1 hunks)schemas/user/statistics.ts(1 hunks)schemas/user/waitlist.ts(1 hunks)schemas/utils/container-with-secrets.ts(1 hunks)schemas/utils/dto.ts(1 hunks)schemas/utils/index.ts(1 hunks)
💤 Files with no reviewable changes (24)
- actions/user/index.ts
- actions/secrets/index.ts
- actions/encryption/index.ts
- components/app/dashboard-overview-stats.tsx
- actions/utils/index.ts
- actions/card/index.ts
- hooks/use-platforms.ts
- actions/encryption/credential-encryption.ts
- actions/credential/index.ts
- actions/encryption/secret-encryption.ts
- hooks/use-tags.ts
- actions/secrets/secret-metadata.ts
- actions/encryption/card-encryption.ts
- actions/credential/credential-metadata.ts
- actions/encryption/encrypted-data.ts
- actions/utils/platform.ts
- actions/card/card-metadata.ts
- actions/user/user.ts
- actions/credential/credential.ts
- actions/utils/container.ts
- actions/user/waitlist.ts
- actions/utils/tag.ts
- actions/card/card.ts
- actions/secrets/secret.ts
🧰 Additional context used
🧬 Code Graph Analysis (27)
orpc/client/utils.ts (2)
orpc/client/index.ts (2)
orpc(1-1)rpcClient(2-2)orpc/client/rpc.ts (1)
rpcClient(16-16)
orpc/routers/index.ts (7)
orpc/routers/card.ts (1)
cardRouter(292-298)orpc/routers/credential.ts (1)
credentialRouter(352-359)orpc/routers/secret.ts (1)
secretRouter(215-221)orpc/routers/container.ts (1)
containerRouter(278-285)orpc/routers/platform.ts (1)
platformRouter(82-84)orpc/routers/tag.ts (1)
tagRouter(77-79)orpc/routers/user.ts (1)
userRouter(93-98)
app/(dashboard)/dashboard/page.tsx (6)
schemas/card/dto.ts (1)
ListCardsOutput(44-44)schemas/secrets/dto.ts (1)
ListSecretsOutput(44-44)schemas/credential/dto.ts (1)
ListCredentialsOutput(45-45)orpc/context.ts (1)
createContext(7-24)orpc/client/server.ts (1)
createServerClient(11-17)config/consts.ts (1)
MAX_RECENT_ITEMS(10-10)
orpc/types.ts (1)
types/dashboard.d.ts (1)
User(1-9)
orpc/client/rpc.ts (2)
orpc/client/index.ts (1)
rpcClient(2-2)orpc/routers/index.ts (1)
AppRouter(19-19)
orpc/routers/platform.ts (3)
orpc/types.ts (1)
ORPCContext(3-6)schemas/utils/dto.ts (3)
listPlatformsInputSchema(53-57)listPlatformsOutputSchema(61-67)ListPlatformsOutput(109-109)prisma/client/index.ts (1)
database(31-31)
orpc/client/server.ts (2)
orpc/types.ts (1)
ORPCContext(3-6)orpc/routers/index.ts (1)
appRouter(9-17)
orpc/hooks/use-users.ts (1)
orpc/client/utils.ts (1)
orpc(6-8)
lib/utils/encryption-helpers.ts (2)
schemas/encryption/encryption.ts (1)
EncryptedDataDto(9-9)prisma/client/index.ts (1)
database(31-31)
lib/utils/tag-helpers.ts (2)
schemas/utils/tag.ts (1)
TagDto(9-9)prisma/client/index.ts (1)
database(31-31)
app/api/orpc/[[...rest]]/route.ts (2)
orpc/routers/index.ts (1)
appRouter(9-17)orpc/context.ts (1)
createContext(7-24)
orpc/context.ts (2)
orpc/types.ts (1)
ORPCContext(3-6)lib/auth/server.ts (1)
auth(9-21)
schemas/secrets/dto.ts (1)
schemas/secrets/secret.ts (5)
secretDtoSchema(6-14)getSecretByIdDtoSchema(35-37)updateSecretDtoSchema(41-43)deleteSecretDtoSchema(47-49)secretSimpleRoSchema(18-31)
schemas/card/dto.ts (1)
schemas/card/card.ts (5)
cardDtoSchema(61-79)getCardByIdDtoSchema(110-112)updateCardDtoSchema(116-118)deleteCardDtoSchema(122-124)cardSimpleRoSchema(83-106)
middleware/auth.ts (2)
middleware/index.ts (2)
publicMiddleware(1-1)authMiddleware(1-1)orpc/types.ts (2)
PublicContext(13-13)AuthenticatedContext(8-11)
orpc/routers/tag.ts (3)
orpc/types.ts (1)
ORPCContext(3-6)schemas/utils/dto.ts (3)
listTagsInputSchema(75-80)listTagsOutputSchema(84-90)ListTagsOutput(118-118)prisma/client/index.ts (1)
database(31-31)
app/(marketing)/page.tsx (1)
orpc/client/server.ts (1)
createServerClient(11-17)
schemas/credential/dto.ts (1)
schemas/credential/credential.ts (5)
credentialDtoSchema(17-29)getCredentialByIdDtoSchema(52-54)updateCredentialDtoSchema(58-60)deleteCredentialDtoSchema(64-66)credentialSimpleRoSchema(33-48)
schemas/utils/container-with-secrets.ts (3)
schemas/utils/dto.ts (2)
createContainerInputSchema(26-26)containerOutputSchema(37-37)schemas/encryption/encryption.ts (1)
encryptedDataDtoSchema(3-7)schemas/secrets/dto.ts (1)
secretOutputSchema(26-26)
schemas/credential/credential-with-metadata.ts (2)
schemas/credential/dto.ts (2)
createCredentialInputSchema(12-12)credentialOutputSchema(27-27)schemas/credential/credential-metadata.ts (1)
credentialMetadataDtoSchema(3-11)
orpc/hooks/use-containers.ts (2)
orpc/client/utils.ts (1)
orpc(6-8)schemas/utils/dto.ts (2)
ListContainersInput(97-97)ContainerOutput(99-99)
orpc/hooks/use-credentials.ts (3)
orpc/client/index.ts (1)
orpc(1-1)orpc/client/utils.ts (1)
orpc(6-8)schemas/credential/dto.ts (2)
ListCredentialsInput(42-42)CredentialOutput(44-44)
orpc/routers/user.ts (4)
orpc/types.ts (1)
ORPCContext(3-6)schemas/user/waitlist.ts (5)
joinWaitlistInputSchema(4-6)joinWaitlistOutputSchema(8-11)JoinWaitlistOutput(19-19)getWaitlistCountOutputSchema(13-15)GetWaitlistCountOutput(20-22)prisma/client/index.ts (1)
database(31-31)schemas/user/statistics.ts (4)
getUserCountOutputSchema(4-6)GetUserCountOutput(13-13)getEncryptedDataCountOutputSchema(8-10)GetEncryptedDataCountOutput(14-16)
orpc/routers/container.ts (5)
orpc/types.ts (1)
ORPCContext(3-6)schemas/utils/dto.ts (7)
getContainerInputSchema(27-27)containerOutputSchema(37-37)listContainersInputSchema(31-35)listContainersOutputSchema(39-45)createContainerInputSchema(26-26)updateContainerInputSchema(28-28)deleteContainerInputSchema(29-29)entities/utils/container/entity.ts (1)
ContainerEntity(7-63)lib/utils/tag-helpers.ts (1)
createTagsAndGetConnections(5-42)schemas/utils/container-with-secrets.ts (3)
createContainerWithSecretsInputSchema(8-17)createContainerWithSecretsOutputSchema(19-24)CreateContainerWithSecretsOutput(29-31)
schemas/utils/dto.ts (3)
schemas/utils/container.ts (5)
containerDtoSchema(6-14)getContainerByIdDtoSchema(35-37)updateContainerDtoSchema(41-43)deleteContainerDtoSchema(47-49)containerSimpleRoSchema(18-31)schemas/utils/platform.ts (5)
platformDtoSchema(4-14)getPlatformByIdDtoSchema(36-38)updatePlatformDtoSchema(42-44)deletePlatformDtoSchema(48-50)platformSimpleRoSchema(18-32)schemas/utils/tag.ts (5)
tagDtoSchema(3-7)getTagByIdDtoSchema(23-25)updateTagDtoSchema(29-31)deleteTagDtoSchema(35-37)tagSimpleRoSchema(11-19)
orpc/hooks/use-secrets.ts (2)
orpc/client/utils.ts (1)
orpc(6-8)schemas/secrets/dto.ts (2)
ListSecretsInput(41-41)SecretOutput(43-43)
orpc/hooks/use-cards.ts (3)
schemas/card/dto.ts (2)
ListCardsInput(41-41)CardOutput(43-43)orpc/client/index.ts (1)
orpc(1-1)orpc/client/utils.ts (1)
orpc(6-8)
🔇 Additional comments (80)
prettier.config.js (1)
27-27: Approve removal of deprecated import order pattern.
The legacy@/actions/(.*)grouping is obsolete after migrating to ORPC routers and has been rightly removed.schemas/card/card.ts (1)
5-5: Approve updated import path for card expiry utilities.
This change aligns with the relocated helper inlib/utilsand ensures the schema’s expiry validation continues to work.components/app/dashboard-add-card-form.tsx (1)
12-12: Approve import path update for expiry helpers.
The component now correctly references the movedcard-expiry-helpers, preserving expiry field handling.schemas/utils/index.ts (1)
2-2: Approve export ofcontainer-with-secrets.
Re-exporting this schema supports the new ORPCcreateContainerWithSecretsrouter and hook.schemas/user/index.ts (1)
2-3: Verify that the exported modules exist.Ensure that the
./waitlistand./statisticsmodules exist in the schemas/user directory to prevent import errors.#!/bin/bash # Description: Verify that the waitlist and statistics modules exist in the schemas/user directory # Expected: Both waitlist.ts and statistics.ts files should exist fd -t f "waitlist\.(ts|js)" schemas/user/ fd -t f "statistics\.(ts|js)" schemas/user/middleware/index.ts (1)
1-1: Verify that the auth module exists and exports the expected functions.Ensure that the
./authmodule exists and exports bothpublicMiddlewareandauthMiddlewarefunctions to prevent import errors.#!/bin/bash # Description: Verify that the auth module exists and exports the expected middleware functions # Expected: auth.ts file should exist and export publicMiddleware and authMiddleware # Check if auth module exists fd -t f "auth\.(ts|js)" middleware/ # Check for the exported functions in the auth module if [ -f "middleware/auth.ts" ]; then echo "=== Checking exports in middleware/auth.ts ===" rg -A 3 "export.*publicMiddleware|export.*authMiddleware" middleware/auth.ts elif [ -f "middleware/auth.js" ]; then echo "=== Checking exports in middleware/auth.js ===" rg -A 3 "export.*publicMiddleware|export.*authMiddleware" middleware/auth.js fiprisma/schema/encryption.prisma (1)
35-35: LGTM! Good practice for explicit table mapping.Adding the
@@map("encrypted_data")attribute ensures explicit mapping to the database table name, which is a good practice for maintaining clear naming conventions and avoiding potential issues with Prisma's default table naming.components/layout/layout-wrapper.tsx (2)
3-3: LGTM! Proper React import for useState.Adding the
useStateimport is necessary for the QueryClient initialization pattern.
10-20: LGTM! Excellent QueryClient setup following React Query best practices.The lazy initialization pattern using
useState(() => new QueryClient(...))ensures the QueryClient instance remains stable across renders. The configuration options are well-chosen:
staleTime: 60 * 1000prevents unnecessary refetches for 1 minuterefetchOnWindowFocus: falseprevents automatic refetching when the window regains focusThis implementation follows React Query best practices for client-side QueryClient instantiation.
schemas/credential/index.ts (1)
2-2: Verify that the exported module exists.Ensure that the
./credential-with-metadatamodule exists in the schemas/credential directory to prevent import errors.#!/bin/bash # Description: Verify that the credential-with-metadata module exists in the schemas/credential directory # Expected: credential-with-metadata.ts file should exist fd -t f "credential-with-metadata\.(ts|js)" schemas/credential/orpc/client/index.ts (1)
1-3: Centralized ORPC client exports
This index file cleanly consolidates the core RPC client and query utilities for easy imports across the app.lib/utils/index.ts (2)
1-2: Clarify server-only utilities
The added comments clearly indicate thatencryption-helpersandtag-helpersare server-only, improving maintainability.
27-28: Re-export new helper modules
Centralizingcard-expiry-helpersandpassword-helperssimplifies imports and maintains consistency with other utility exports.orpc/client/utils.ts (1)
1-8: Instantiate Tanstack Query utilities
Creating and exporting theorpcinstance withcreateTanstackQueryUtilsand the RPC client correctly sets up typed, cache-aware RPC hooks.prisma/schema/cards.prisma (2)
65-65: Explicit table mapping for Card model
Mapping theCardmodel to thecardtable ensures alignment with the existing database naming conventions and migrations.
105-105: Explicit table mapping for CardMetadata model
MappingCardMetadatatocard_metadatakeeps the schema and migration in sync.prisma/schema/secrets.prisma (2)
41-41: Explicit table mapping for Secret model
Adding@@map("secret")correctly aligns the Prisma model with the underlyingsecrettable.
68-68: Explicit table mapping for SecretMetadata model
The@@map("secret_metadata")directive ensures the metadata model matches the renamed table.orpc/hooks/use-tags.ts (1)
1-15: Well-implemented React Query hook with proper defaults.The hook implementation follows React Query best practices with appropriate default pagination values, proper TypeScript typing, and placeholder data handling for UI stability during refetches.
orpc/client/rpc.ts (1)
8-16: Verify environment variable configuration.The RPC client setup is well-implemented with proper typing. However, ensure that
NEXT_PUBLIC_APP_URLis properly configured in your environment variables since this is critical for the client to connect to the correct API endpoint.#!/bin/bash # Description: Check if NEXT_PUBLIC_APP_URL is defined in environment files # Expected: Find the environment variable definition fd -e env -e local | xargs grep -l "NEXT_PUBLIC_APP_URL" || echo "Environment variable not found in .env files"prisma/schema/credential.prisma (3)
54-54: Good practice: Explicit table mapping for Credential model.Adding explicit
@@map("credential")directive improves clarity and ensures consistent table naming across environments.
85-85: Consistent table mapping for CredentialHistory.The
@@map("credential_history")mapping maintains consistency with the database naming convention.
112-112: Consistent table mapping for CredentialMetadata.The
@@map("credential_metadata")mapping completes the consistent explicit table naming pattern.orpc/hooks/index.ts (1)
1-7: Clean barrel export pattern for centralized hook imports.The barrel export provides a convenient centralized import point for all orpc hooks, following consistent naming conventions across all domain entities.
orpc/hooks/use-platforms.ts (2)
8-17: LGTM! Well-structured React Query hook with good UX considerations.The hook implementation follows React Query best practices:
- Sensible default pagination parameters
placeholderDatamaintains UI stability during refetches- Proper integration with oRPC client
4-4: Verify the DTO schema import path.Ensure that the
ListPlatformsInputtype is correctly exported from the specified schema path and matches the expected structure for the oRPC router.#!/bin/bash # Description: Verify that ListPlatformsInput is properly exported from the schema file # Expected: The type should be exported and match pagination structure # Check if the schema file exists and exports ListPlatformsInput fd "dto.ts" --exec grep -l "ListPlatformsInput" {} \; # Look for the actual type definition ast-grep --pattern 'export type ListPlatformsInput = $_'schemas/user/waitlist.ts (3)
4-6: LGTM! Proper email validation with clear error message.The input schema correctly validates email format with a user-friendly error message.
8-11: Good error handling structure in output schema.The output schema properly handles both success and error states with optional error messaging.
13-15: Appropriate constraints for waitlist count.Using
int().min(0)ensures the count is a non-negative integer, which is logically correct for a count value.package.json (3)
88-88: Good addition of superjson for RPC serialization.Adding superjson is appropriate for handling complex data serialization in oRPC calls, supporting dates, undefined values, and other JavaScript types.
29-33: Verify oRPC package versions are latest and secure.The oRPC packages are added with specific version constraints. Ensure these are the latest stable versions and check for any known security vulnerabilities.
What are the latest stable versions of @orpc/client, @orpc/server, @orpc/next, @orpc/react-query, and @orpc/tanstack-query packages?
63-64: Verify React Query version compatibility.The React Query version was upgraded to ^5.80.7. Ensure this version is compatible with the oRPC React Query integration and check for any breaking changes.
Are there any breaking changes in @tanstack/react-query version 5.80.7 that might affect the oRPC integration?prisma/schema/utils.prisma (3)
39-39: Good practice: Explicit table mapping added.Adding
@@map("platform")provides explicit control over the database table name and improves schema clarity.
68-68: Consistent table mapping for Tag model.The explicit mapping to
"tag"table maintains consistency with the Platform model changes.
110-110: Consistent table mapping for Container model.The explicit mapping to
"container"table completes the consistent approach across all utility models.app/(marketing)/page.tsx (3)
1-1: LGTM! Correct import for server client.The import follows the new oRPC client architecture pattern.
11-14: Appropriate server client creation for public marketing page.Creating the server client with
nullsession and user is correct for a public marketing page that doesn't require authentication.
17-19: Let's inspect how the results are used inapp/(marketing)/page.tsxto confirm property access:#!/bin/bash set -e # Show surrounding lines where each method is called rg -n -C3 "serverClient.users.getWaitlistCount" --glob "app/(marketing)/page.tsx" rg -n -C3 "serverClient.users.getUserCount" --glob "app/(marketing)/page.tsx" rg -n -C3 "serverClient.users.getEncryptedDataCount" --glob "app/(marketing)/page.tsx" # Check property access in this file rg -n -C3 "\.total" --glob "app/(marketing)/page.tsx" rg -n -C3 "\.count" --glob "app/(marketing)/page.tsx"orpc/client/server.ts (1)
7-17: LGTM! Clean and well-documented SSR client implementation.The server client factory is well-designed with:
- Clear JSDoc documentation explaining the SSR optimization purpose
- Proper type safety with RouterClient generic
- Correct context callback pattern for oRPC
orpc/routers/index.ts (1)
9-17: LGTM! Clean router aggregation with consistent naming.The router consolidation follows good practices:
- Consistent naming between imports and exported properties
- Clean aggregation pattern
- Proper type export for strong typing
components/app/marketing-waitlist-form.tsx (1)
22-44: LGTM! Well-executed refactor to use oRPC mutation hook.The migration from direct action calls to the
useJoinWaitlisthook is well-implemented:
- Proper error handling for both success with error and actual errors
- Consistent toast notifications for user feedback
- Correct usage of mutation state for loading indicators
orpc/hooks/use-users.ts (2)
10-25: LGTM! Well-implemented mutation hook with proper cache management.The
useJoinWaitlisthook demonstrates good practices:
- Proper cache invalidation to keep data fresh
- Error logging for debugging
- Clean integration with React Query patterns
28-55: LGTM! Consistent query hooks with appropriate caching strategy.The query hooks are well-implemented with:
- Consistent 5-minute stale time across all count queries
- Proper empty input objects for parameterless queries
- Clean, predictable API surface
lib/utils/tag-helpers.ts (1)
5-9: Add error handling and consider transaction management.The function lacks proper error handling and doesn't use database transactions, which could lead to inconsistent state if operations fail partway through.
Consider wrapping the database operations in a transaction:
export async function createTagsAndGetConnections( tags: TagDto[], userId: string, containerId?: string -): Promise<Prisma.TagCreateNestedManyWithoutContainerInput> { +): Promise<Prisma.TagCreateNestedManyWithoutContainerInput> { + try { + return await database.$transaction(async (tx) => { // ... database operations using tx instead of database + }) + } catch (error) { + console.error("Error in createTagsAndGetConnections:", error) + throw error + }Likely an incorrect or invalid review comment.
orpc/routers/platform.ts (3)
21-33: Well-implemented authentication middleware.The authentication procedure correctly validates session and user presence, ensuring type safety by narrowing the context types.
53-61: Good use of Promise.all for concurrent queries.Efficiently fetches both the data and total count concurrently, which improves performance compared to sequential queries.
48-50: Verify case-insensitive search behavior.The search uses
mode: "insensitive"which works well for PostgreSQL, but ensure this behaves as expected across all supported database providers.#!/bin/bash # Description: Check database provider and search behavior # Expected: Confirm database provider supports case-insensitive search # Check the database provider in Prisma schema fd -e prisma | xargs grep -n "provider"lib/utils/encryption-helpers.ts (1)
4-29: Clean implementation with proper error handling.The function follows good practices with structured return types and comprehensive error handling.
schemas/user/statistics.ts (1)
4-16: Well-structured schema definitions.The schemas correctly validate statistics outputs with appropriate constraints (min(0) for counts) and provide proper TypeScript type exports.
app/(dashboard)/dashboard/page.tsx (3)
2-6: Clean migration to ORPC architecture.The imports have been properly updated to use the new ORPC client and explicit DTO types, improving type safety.
77-78: Proper context and client initialization.The server client is correctly initialized with the authentication context, following the ORPC pattern.
82-93: Explicit pagination parameters improve clarity.The refactored calls now explicitly specify pagination parameters instead of relying on defaults, making the behavior more predictable and maintainable.
orpc/types.ts (1)
1-14: Well-structured context type definitions for ORPC architecture.The context interfaces are cleanly designed with proper separation between public and authenticated contexts. The type hierarchy correctly ensures that
AuthenticatedContextguarantees non-null session and user properties whileORPCContextallows them to be nullable.middleware/auth.ts (1)
4-12: LGTM: Public middleware correctly passes through context.The
publicMiddlewarefunction properly passes the public context unchanged to the next middleware in the chain.schemas/card/dto.ts (3)
11-23: Well-designed DTO schemas with proper validation constraints.The input schemas are correctly aliased from the base schemas, and the
listCardsInputSchemaincludes appropriate pagination constraints (max limit of 100) and optional filtering parameters.
25-34: Consistent output schema structure for API responses.The output schemas follow a consistent pattern with proper pagination metadata including
hasMoreflag, which is helpful for UI implementations.
36-44: Complete type exports for strong typing.All schemas have corresponding TypeScript type exports, ensuring type safety throughout the application.
schemas/secrets/dto.ts (2)
11-34: Consistent DTO schema pattern across domains.The secret DTO schemas follow the same well-established pattern as the card schemas, maintaining consistency in pagination limits, validation constraints, and output structure. This uniformity is excellent for API predictability.
36-44: Complete type safety with proper exports.All schemas have corresponding TypeScript type exports, maintaining the same type safety standards across the application.
orpc/routers/tag.ts (2)
36-74: Well-implemented paginated listing with proper optimization.The
listTagsprocedure demonstrates good practices:
- Proper input validation with Zod schemas
- Efficient parallel database queries using
Promise.all- Correct pagination logic with
hasMorecalculation- Safe query construction preventing SQL injection
- Case-insensitive search implementation
77-79: Clean router export structure.The router object export follows a clear naming convention that will integrate well with the overall application router.
orpc/client/query.ts (1)
39-51: LGTM! Solid singleton pattern implementation.The singleton pattern is properly implemented with server-side fresh instances and client-side reuse. The
typeof window === "undefined"check correctly identifies the server environment.schemas/credential/dto.ts (2)
18-24: LGTM! Well-structured pagination schema.The pagination schema correctly enforces constraints with sensible defaults:
- Page starts at 1 with minimum validation
- Limit is capped at 100 to prevent abuse
- Optional filtering parameters for search, container, and platform
29-35: LGTM! Comprehensive output schema for paginated results.The output schema includes all necessary pagination metadata (total, hasMore, page, limit) which enables proper client-side pagination handling.
components/app/dashboard-add-card-dialog.tsx (3)
32-32: LGTM! Proper migration to mutation hook.The migration from direct server action calls to the
useCreateCardmutation hook follows the correct oRPC pattern.
116-160: LGTM! Well-structured mutation with proper callbacks.The mutation implementation correctly:
- Uses the
mutatemethod with proper data structure- Handles success with toast notifications and conditional dialog closure
- Resets form state appropriately for "create more" functionality
- Provides detailed error handling with the
handleErrorsutility
191-191: LGTM! Proper loading state integration.The
isPendingproperty from the mutation hook correctly replaces the previous manualisSubmittingstate management.schemas/utils/container-with-secrets.ts (2)
8-17: LGTM! Well-structured input schema for atomic operations.The schema correctly combines container and secrets creation:
- Reuses existing
createContainerInputSchemafor consistency- Properly validates encrypted secret data using
encryptedDataDtoSchema- Enforces required fields with appropriate error messages
19-24: LGTM! Comprehensive output schema for transaction results.The output schema provides:
- Success boolean for operation status
- Optional container and secrets data for successful operations
- Error message for failure cases
- Proper use of optional fields for different response scenarios
components/app/dashboard-add-secret-dialog.tsx (4)
29-29: LGTM! Proper migration to container with secrets hook.The component correctly uses the
useCreateContainerWithSecretsmutation hook, which aligns with the new atomic operation pattern for creating containers with associated secrets.
65-70: LGTM! Proper validation for key-value pairs.The validation correctly ensures that parsed key-value pairs are not empty before proceeding with encryption and submission.
92-156: LGTM! Well-structured batch secret creation with proper error handling.The mutation implementation correctly:
- Creates container and secrets atomically using the
createContainerWithSecretsoperation- Handles success with dynamic toast messages based on created secrets count
- Provides comprehensive error handling for both operation success/failure and exceptions
- Maintains proper form state management for "create more" functionality
189-189: LGTM! Proper loading state integration.The
isPendingproperty from the mutation hook correctly replaces manual loading state management.orpc/hooks/use-credentials.ts (1)
4-10: Remove unused import.The
ListCardsOutputtype is imported but never used in this file.import type { CreateCredentialInput, CredentialOutput, DeleteCredentialInput, ListCredentialsInput, UpdateCredentialInput, } from "@/schemas/credential/dto"Likely an incorrect or invalid review comment.
orpc/routers/card.ts (1)
201-204: Fix incorrect property assignment for container update.The code incorrectly assigns to
updatePayload.containerinstead ofupdatePayload.containerId.if (updateData.containerId !== undefined) - updatePayload.container = updateData.containerId + updatePayload.containerId = updateData.containerId ? { connect: { id: updateData.containerId } } : { disconnect: true }However, based on Prisma's relation handling, the entire approach should use the relation field:
if (updateData.containerId !== undefined) - updatePayload.container = updateData.containerId + updatePayload.container = updateData.containerId ? { connect: { id: updateData.containerId } } : { disconnect: true }Likely an incorrect or invalid review comment.
orpc/hooks/use-secrets.ts (1)
1-151: LGTM! Consistent implementation with other resource hooks.The implementation follows the established patterns for CRUD operations with React Query, including proper cache management and optimistic updates.
schemas/utils/dto.ts (1)
1-119: Well-structured DTO schema organization.The centralized DTO module provides consistent schema definitions and TypeScript types for containers, platforms, and tags with proper pagination support.
orpc/hooks/use-cards.ts (1)
86-93: Good handling of date conversion in optimistic update.The special handling of
expiryDateconversion from string to Date object ensures type consistency in the cache.orpc/routers/credential.ts (1)
30-46: Well-structured authentication middleware.The authentication setup correctly validates session and user presence before allowing access to protected procedures.
orpc/routers/container.ts (1)
108-112: To confirm how tags are scoped whencontainerIdisundefined, let’s inspect the helper’s logic around that parameter:#!/bin/bash # Show the full createTagsAndGetConnections implementation sed -n '1,200p' lib/utils/tag-helpers.tsThis will clarify whether passing
undefinedintentionally omits the container scope (making them user-scoped) or if it’s an oversight.
Docstrings generation was requested by @FindMalek. * #6 (comment) The following files were modified: * `app/(dashboard)/dashboard/page.tsx` * `app/(marketing)/page.tsx` * `app/api/orpc/[[...rest]]/route.ts` * `components/app/dashboard-add-card-dialog.tsx` * `components/app/dashboard-add-credential-dialog.tsx` * `components/app/dashboard-add-secret-dialog.tsx` * `components/app/dashboard-overview-stats.tsx` * `components/app/marketing-waitlist-form.tsx` * `components/layout/layout-wrapper.tsx` * `lib/utils/encryption-helpers.ts` * `lib/utils/index.ts` * `lib/utils/tag-helpers.ts` * `orpc/client/server.ts` * `orpc/context.ts` * `orpc/hooks/use-cards.ts` * `orpc/hooks/use-containers.ts` * `orpc/hooks/use-credentials.ts` * `orpc/hooks/use-platforms.ts` * `orpc/hooks/use-secrets.ts` * `orpc/hooks/use-tags.ts` * `orpc/hooks/use-users.ts`
|
Note Generated docstrings for this pull request at #7 |
Summary by CodeRabbit
New Features
Refactor
Bug Fixes
Chores
Documentation