refactor: add ownerId to create key for backward compat#3312
Conversation
|
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
📝 WalkthroughWalkthroughThe key creation mutation now assigns Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ExternalIdField
participant GeneralSetupForm
participant TRPC Router
participant Database
User->>ExternalIdField: Select or create identity (identityId, externalId)
ExternalIdField->>GeneralSetupForm: onChange(identityId, externalId)
GeneralSetupForm->>FormState: Update identityId and externalId fields
User->>GeneralSetupForm: Submit form
GeneralSetupForm->>TRPC Router: createKey(input with identityId and externalId)
TRPC Router->>Database: Insert key (identityId = input.identityId, ownerId = input.externalId)
Database-->>TRPC Router: Key creation result
TRPC Router-->>GeneralSetupForm: Response with key details
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🧰 Additional context used🧠 Learnings (1)apps/dashboard/lib/trpc/routers/key/updateOwnerId.ts (1)⏰ Context from checks skipped due to timeout of 90000ms (8)
🔇 Additional comments (1)
✨ 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 (
|
|
Thank you for following the naming conventions for pull request titles! 🙏 |
|
dont dont |
|
dont merge it |
|
lol that was like 10 min ago |
|
I got baited by slack :pepeout: |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field.tsx(3 hunks)apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/general-setup.tsx(2 hunks)apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.schema.ts(2 hunks)apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.utils.ts(2 hunks)apps/dashboard/lib/trpc/routers/key/create.ts(1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/dashboard/lib/trpc/routers/key/create.ts
🧰 Additional context used
🧬 Code Graph Analysis (1)
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/general-setup.tsx (1)
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field.tsx (1)
ExternalIdField(17-158)
⏰ Context from checks skipped due to timeout of 90000ms (6)
- GitHub Check: Test Packages / Test ./packages/cache
- GitHub Check: Test Packages / Test ./packages/nextjs
- GitHub Check: Test Packages / Test ./packages/hono
- GitHub Check: Test Packages / Test ./internal/clickhouse
- GitHub Check: autofix
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (8)
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.utils.ts (2)
23-23: LGTM! Consistent addition of identityId field.The addition of
identityIdto the API input follows the same pattern asexternalIdwith proper null handling.
80-83: LGTM! Improved code readability.The multi-line type assertion format improves readability without changing functionality.
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/create-key.schema.ts (2)
63-68: LGTM! Consistent schema definition for identityId.The
identityIdfield definition mirrors theexternalIdvalidation rules appropriately.
323-326: LGTM! Consistent API schema definition.The
identityIdfield in the API schema maintains consistency with the form schema validation.apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/general-setup.tsx (1)
11-11: LGTM! Added setValue for dual field management.The addition of
setValueenables proper management of bothidentityIdandexternalIdfields.apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/external-id-field.tsx (3)
12-12: LGTM! Enhanced onChange signature for dual field handling.The updated onChange prop type correctly accepts both
identityIdandexternalIdparameters to support the new data flow.
27-27: LGTM! Consistent callback update.The createIdentity callback correctly passes both
identityIdandexternalIdto the onChange handler.
100-100: LGTM! Proper dual parameter handling.The onSelect handler correctly extracts and passes both the identity ID and external ID to the onChange callback.
| name="identityId" | ||
| control={control} | ||
| defaultValue="" | ||
| render={({ field }) => ( | ||
| <ExternalIdField | ||
| value={field.value ?? null} | ||
| onChange={field.onChange} | ||
| onChange={(identityId: string | null, externalId: string | null) => { | ||
| field.onChange(identityId); | ||
| setValue("externalId", externalId); | ||
| }} |
There was a problem hiding this comment.
Fix error handling inconsistency.
The Controller now manages identityId but the error handling on line 50 still references errors.externalId?.message. This could display the wrong error message.
<ExternalIdField
value={field.value ?? null}
onChange={(identityId: string | null, externalId: string | null) => {
field.onChange(identityId);
setValue("externalId", externalId);
}}
- error={errors.externalId?.message}
+ error={errors.identityId?.message}
/>📝 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.
| name="identityId" | |
| control={control} | |
| defaultValue="" | |
| render={({ field }) => ( | |
| <ExternalIdField | |
| value={field.value ?? null} | |
| onChange={field.onChange} | |
| onChange={(identityId: string | null, externalId: string | null) => { | |
| field.onChange(identityId); | |
| setValue("externalId", externalId); | |
| }} | |
| name="identityId" | |
| control={control} | |
| defaultValue="" | |
| render={({ field }) => ( | |
| <ExternalIdField | |
| value={field.value ?? null} | |
| onChange={(identityId: string | null, externalId: string | null) => { | |
| field.onChange(identityId); | |
| setValue("externalId", externalId); | |
| }} | |
| error={errors.identityId?.message} | |
| /> | |
| )} |
🤖 Prompt for AI Agents
In
apps/dashboard/app/(app)/apis/[apiId]/_components/create-key/components/general-setup.tsx
around lines 40 to 49, the error handling for the Controller managing identityId
incorrectly references errors.externalId?.message. Update the error reference to
errors.identityId?.message to ensure the correct error message is displayed for
the identityId field.
|
Okay should be good to go now |
What does this PR do?
This PR adds selected
externalIddata toowner_idcolumn in ourkeystable for backward compat.Fixes # (issue)
If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists
Type of change
How should this be tested?
Checklist
Required
pnpm buildpnpm fmtconsole.logsgit pull origin mainAppreciated
Summary by CodeRabbit