Templates Filters ordered alphabetically#2434
Templates Filters ordered alphabetically#2434AQIB-NAWAB wants to merge 6 commits intounkeyed:mainfrom AQIB-NAWAB:filters-ordered-alphabetically
Conversation
|
|
@AQIB-NAWAB is attempting to deploy a commit to the Unkey Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📝 Walkthrough📝 WalkthroughWalkthroughThe changes in this pull request focus on enhancing error handling in the Changes
Possibly related issues
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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 (
|
|
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Details: |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Outside diff range and nitpick comments (15)
apps/dashboard/app/(app)/settings/user/update-user-email.tsx (1)
190-190: Improved error handling for email promotion.The change to use
ClerkErrorinstead ofErrorprovides more specific error information, which is a good improvement. This aligns well with the PR objective of enhancing error handling.For consistency, consider using optional chaining here as well, similar to the change in the VerificationForm component:
toast.error((e as ClerkError)?.errors.at(0)?.longMessage ?? "Error promoting email");This would provide a fallback message in case the expected error structure is not present.
apps/www/app/templates/data.ts (3)
Line range hint
74-74: Typo in 'framework' in the 'rust-axum' template description.In line 74, the word "framwork" is misspelled in the description of the 'rust-axum' template. It should be "framework".
Apply this diff to correct the typo:
- description: "A Rust API service using Unkey for API key validation with the Axum framwork.", + description: "A Rust API service using Unkey for API key validation with the Axum framework.",
18-18: Consistent casing for 'TypeScript' in 'languages' array.In the 'languages' array, "Typescript" should be capitalized as "TypeScript" to match the official casing.
Apply this diff to update the casing:
- export const languages = ["Typescript", "Python", "Golang", "Rust", "Elixir"] as const; + export const languages = ["TypeScript", "Python", "Golang", "Rust", "Elixir"] as const;Ensure that all occurrences of "Typescript" in the file are updated to "TypeScript" for consistency.
Line range hint
153-165: Inconsistent 'authors' field formatting across templates.There is inconsistency in how 'authors' are listed in the templates. Some templates use GitHub usernames, while others use personal names. For consistency, consider standardizing the format.
- Decide on a standard (e.g., always use GitHub usernames) and update the 'authors' fields accordingly.
Example diff for the 'nextjs-expiration' template:
- authors: ["ethan-stone"], + authors: ["ethanstone"], // Replace with the correct GitHub usernamepackages/api/src/openapi.d.ts (11)
599-613: Refactor the ratelimit configuration for consistency.The
ratelimitsproperty in theV1KeysVerifyKeyRequestinterface has been updated to use a more consistent and clear structure for defining ratelimits. The changes include:
- Using
costinstead oftokensfor specifying the cost of the operation.- Using
durationinstead ofwindowfor specifying the duration of the ratelimit window.- Removing the
refillRateandrefillIntervalproperties as they are not used in this context.To further improve consistency, consider applying similar changes to other places where ratelimits are defined, such as in the
createKeyandupdateKeyrequest bodies.
Line range hint
1294-1326: Refactor the ratelimit configuration for consistency.The
ratelimitproperty in theupdateKeyrequest body has been updated to use a more consistent and clear structure for defining ratelimits. The changes include:
- Using
asyncinstead oftypefor specifying the ratelimiting mode.- Using
durationinstead ofrefillIntervalfor specifying the duration of the ratelimit window.- Deprecating the
refillRateandrefillIntervalproperties in favor oflimitandduration.To further improve consistency, consider applying similar changes to other places where ratelimits are defined, such as in the
createKeyrequest body and theV1KeysVerifyKeyRequestinterface.
1370-1379: Added support for creating roles and permissions during key update.The
rolesproperty in theupdateKeyrequest body has been updated to allow specifying roles using either theiridorname. Additionally, a newcreateproperty has been introduced to enable automatically creating roles if they don't exist when specifying them by name.Consider adding a comment to clarify that the
createproperty only works when specifying roles by name and that it requires therbac.*.create_rolepermission.
1397-1406: Added support for creating permissions during key update.The
permissionsproperty in theupdateKeyrequest body has been updated to allow specifying permissions using either theiridorname. Additionally, a newcreateproperty has been introduced to enable automatically creating permissions if they don't exist when specifying them by name.Consider adding a comment to clarify that the
createproperty only works when specifying permissions by name and that it requires therbac.*.create_permissionpermission.
1632-1641: Added support for creating permissions when adding them to a key.The
permissionsproperty in the request body of theaddPermissionsoperation has been updated to allow specifying permissions using either theiridorname. Additionally, a newcreateproperty has been introduced to enable automatically creating permissions if they don't exist when specifying them by name.Consider adding a comment to clarify that the
createproperty only works when specifying permissions by name and that it requires therbac.*.create_permissionpermission.
1905-1914: Added support for creating roles when adding them to a key.The
rolesproperty in the request body of theaddRolesoperation has been updated to allow specifying roles using either theiridorname. Additionally, a newcreateproperty has been introduced to enable automatically creating roles if they don't exist when specifying them by name.Consider adding a comment to clarify that the
createproperty only works when specifying roles by name and that it requires therbac.*.create_rolepermission.
2080-2089: Added support for creating roles when setting them on a key.The
rolesproperty in the request body of thesetRolesoperation has been updated to allow specifying roles using either theiridorname. Additionally, a newcreateproperty has been introduced to enable automatically creating roles if they don't exist when specifying them by name.Consider adding a comment to clarify that the
createproperty only works when specifying roles by name and that it requires therbac.*.create_rolepermission.
Line range hint
2654-2801: Improved structure for bulk key creation.The request body of the
v1.migrations.createKeysoperation has been updated to accept an array of key configurations. This allows for bulk creation of keys in a single request. Each key configuration object includes properties for specifying the API ID, prefix, name, plaintext or hash, owner ID, metadata, roles, permissions, expiration, remaining requests, refill settings, ratelimit settings, enabled status, and environment.Consider adding comments to clarify the purpose and usage of each property in the key configuration object.
2864-3016: Added support for bulk key enqueuing.The
v1.migrations.enqueueKeysoperation has been introduced to allow enqueuing keys for migration. The request body accepts a migration ID, API ID, and an array of key configurations. Each key configuration object includes properties for specifying the prefix, name, plaintext or hash, start characters, owner ID, metadata, roles, permissions, expiration, remaining requests, refill settings, ratelimit settings, enabled status, and environment.Consider adding comments to clarify the purpose and usage of each property in the key configuration object.
3656-3671: Added support for attaching ratelimits to identities.The
ratelimitsproperty has been added to the request body of thecreateIdentityoperation. This allows attaching ratelimits to an identity during creation. Each ratelimit object includes properties for specifying the name, limit, and duration of the ratelimit window.Consider adding comments to clarify the purpose and usage of each property in the ratelimit object.
3947-3962: Added support for updating ratelimits on identities.The
ratelimitsproperty has been added to the request body of theupdateIdentityoperation. This allows updating the ratelimits associated with an identity. Setting an empty array will delete all existing ratelimits. Each ratelimit object includes properties for specifying the name, limit, and duration of the ratelimit window.Consider adding comments to clarify the purpose and usage of each property in the ratelimit object.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
- apps/dashboard/app/(app)/settings/user/update-user-email.tsx (2 hunks)
- apps/www/app/templates/data.ts (5 hunks)
- packages/api/src/openapi.d.ts (33 hunks)
🧰 Additional context used
🔇 Additional comments (22)
apps/dashboard/app/(app)/settings/user/update-user-email.tsx (2)
345-345: Improved error handling for email verification.This change enhances the error handling by using
ClerkErrorfor more specific error information. The addition of optional chaining and a fallback message improves the robustness of the error handling. This is a good improvement that aligns well with the PR objectives.
Line range hint
1-385: Overall assessment of changes in update-user-email.tsxThe changes made in this file successfully improve the error handling for both email promotion and verification processes. These enhancements align well with the PR objectives and contribute to a better user experience by providing more specific and robust error messages.
No other significant changes or issues were observed in the file. The modifications are focused and effective in addressing the intended improvements.
apps/www/app/templates/data.ts (1)
198-198: 🛠️ Refactor suggestionUse GitHub username in 'authors' field for consistency.
In the 'unkey-trpc-ratelimit' template, the 'authors' field is set to ["Michael"]. For consistency with other templates, consider using the GitHub username instead of the personal name.
If the GitHub username is known, apply this diff:
- authors: ["Michael"], + authors: ["github_username"], // Replace 'github_username' with the actual usernameLikely invalid or redundant comment.
packages/api/src/openapi.d.ts (19)
6-6: LGTM!The empty line is fine and improves readability.
9-10: Improved formatting for better readability.The changes to the
XORandOneOftype definitions improve the formatting and readability of the code. The use of parentheses in theXORtype and the consistent indentation in theOneOftype enhance clarity.
550-554: Improved formatting for better readability.The changes to the
PermissionQuerytype definition improve the formatting and readability of the code. The consistent indentation and line breaks enhance clarity.
1339-1347: Improved typing for therefillproperty.The
refillproperty in theupdateKeyrequest body has been updated to use a more precise type definition. Theintervalproperty now explicitly specifies the allowed values using an enum, and theamountproperty is marked as required.
1556-1576: Improved structure for usage data.The
verificationsproperty in the response of thegetVerificationsoperation has been updated to use a more structured format for representing usage data. Each item in the array now includes properties for the timestamp, successful requests, rate-limited requests, and usage-exceeded requests.
1650-1660: Improved structure for returned permissions.The response of the
addPermissionsoperation has been updated to return an array of permissions with a more consistent structure. Each permission object now includes anidproperty for the internal permission ID and anameproperty for the permission name.
1725-1729: Improved structure for specifying permissions to remove.The
permissionsproperty in the request body of theremovePermissionsoperation has been updated to allow specifying permissions using either theiridorname. This provides more flexibility when removing permissions from a key.
1825-1835: Improved structure for returned permissions.The response of the
setPermissionsoperation has been updated to return an array of permissions with a more consistent structure. Each permission object now includes anidproperty for the internal permission ID and anameproperty for the permission name.
1923-1933: Improved structure for returned roles.The response of the
addRolesoperation has been updated to return an array of roles with a more consistent structure. Each role object now includes anidproperty for the internal role ID and anameproperty for the role name.
1998-2002: Improved structure for specifying roles to remove.The
rolesproperty in the request body of theremoveRolesoperation has been updated to allow specifying roles using either theiridorname. This provides more flexibility when removing roles from a key.
2098-2108: Improved structure for returned roles.The response of the
setRolesoperation has been updated to return an array of roles with a more consistent structure. Each role object now includes anidproperty for the internal role ID and anameproperty for the role name.
2804-2818: Improved response structure for bulk key creation.The response of the
v1.migrations.createKeysoperation has been updated to return an array of key IDs for the created keys. This provides a clear and concise way to retrieve the IDs of the newly created keys.
3287-3302: Improved structure for returned permissions.The response of the
listPermissionsoperation has been updated to return an array of permissions with a more consistent structure. Each permission object now includes anidproperty for the internal permission ID, anameproperty for the permission name, and an optionaldescriptionproperty for the permission description.
3565-3580: Improved structure for returned roles.The response of the
listRolesoperation has been updated to return an array of roles with a more consistent structure. Each role object now includes anidproperty for the internal role ID, anameproperty for the role name, and an optionaldescriptionproperty for the role description.
3754-3769: Improved structure for returned ratelimits.The response of the
getIdentityoperation has been updated to include aratelimitsproperty, which is an array of ratelimit objects. Each ratelimit object includes properties for the name, limit, and duration of the ratelimit window.
3832-3853: Improved structure for returned identities.The response of the
listIdentitiesoperation has been updated to return an array of identities with a more consistent structure. Each identity object now includes anidproperty for the internal identity ID, anexternalIdproperty for the external identity ID, and aratelimitsproperty for the associated ratelimits.
3991-4006: Improved structure for returned ratelimits.The response of the
updateIdentityoperation has been updated to include aratelimitsproperty, which is an array of ratelimit objects. Each ratelimit object includes properties for the name, limit, and duration of the ratelimit window.
524-524: Verify the addition of new verification result codes.The
codeproperty in theV1KeysVerifyKeyResponseinterface has been updated to include new possible values such asDISABLED,INSUFFICIENT_PERMISSIONS, andEXPIRED.Ensure that the backend implementation correctly returns these new codes in the appropriate scenarios and that the frontend handles them properly.
#!/bin/bash # Description: Verify the backend returns the new codes and the frontend handles them. # Test: Search for the usage of the new codes in the backend. Expect: Should find relevant occurrences. rg --type go $'DISABLED|INSUFFICIENT_PERMISSIONS|EXPIRED' # Test: Search for the handling of the new codes in the frontend. Expect: Should find relevant occurrences. rg --type typescript $'DISABLED|INSUFFICIENT_PERMISSIONS|EXPIRED'
4368-4368: Verify the addition of new verification result codes.The
codeproperty in the response of the deprecatedverifyKeyoperation has been updated to include new possible values such asDISABLED,INSUFFICIENT_PERMISSIONS, andEXPIRED.Ensure that the backend implementation correctly returns these new codes in the appropriate scenarios and that the frontend handles them properly.
✅ Verification successful
Verification Successful: New verification result codes are properly implemented and handled in both backend and frontend.
- Backend implementations correctly return
DISABLED,INSUFFICIENT_PERMISSIONS, andEXPIREDcodes.- Frontend components and handlers appropriately manage the new codes.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the backend returns the new codes and the frontend handles them. # Test: Search for the usage of the new codes in the backend. Expect: Should find relevant occurrences. rg --type go $'DISABLED|INSUFFICIENT_PERMISSIONS|EXPIRED' # Test: Search for the handling of the new codes in the frontend. Expect: Should find relevant occurrences. rg --type typescript $'DISABLED|INSUFFICIENT_PERMISSIONS|EXPIRED'Length of output: 258
Script:
#!/bin/bash # Description: Re-verify the backend and frontend for the new verification result codes. # Test: Search for the usage of the new codes in the backend without type restriction. rg 'DISABLED|INSUFFICIENT_PERMISSIONS|EXPIRED' --type go # Test: Search for the handling of the new codes in the frontend using correct TypeScript file types. rg 'DISABLED|INSUFFICIENT_PERMISSIONS|EXPIRED' --type ts --type tsxLength of output: 254
Script:
#!/bin/bash # Description: Re-verify the backend and frontend for the new verification result codes with adjusted search parameters. # Test: Search for the usage of the new codes in the backend without type restriction. rg 'DISABLED|INSUFFICIENT_PERMISSIONS|EXPIRED' # Test: Search for the handling of the new codes in the frontend by specifying file extensions explicitly. rg 'DISABLED|INSUFFICIENT_PERMISSIONS|EXPIRED' --glob '*.ts' --glob '*.tsx'Length of output: 13428
apps/www/app/templates/data.ts
Outdated
| title: "Unkey + Elixir Mix Supervision", | ||
| description: "A simple example of using the Unkey Elixir SDK.", | ||
| authors: ["glamboyosa"], | ||
| repository: "https://github.com/unkeyed/unkey/examples/main/elixir_mix_supervision_example", |
There was a problem hiding this comment.
Incorrect repository URL in 'elixir-mix-supervision' template.
The 'repository' URL for the 'elixir-mix-supervision' template appears to be incorrect. It currently points to:
https://github.com/unkeyed/unkey/examples/main/elixir_mix_supervision_example
It should likely be:
https://github.com/unkeyed/examples/tree/main/elixir_mix_supervision_example
Apply this diff to fix the repository URL:
- repository: "https://github.com/unkeyed/unkey/examples/main/elixir_mix_supervision_example",
+ repository: "https://github.com/unkeyed/examples/tree/main/elixir_mix_supervision_example",
apps/www/app/templates/data.ts
Outdated
| "cost-ratelimit": { | ||
| title: "Cost based Ratelimiting", | ||
| description: "Ratelimit your AI application based on estimated cost", | ||
| authors: ["hashsbhat"], |
There was a problem hiding this comment.
Typo in 'authors' field in 'cost-ratelimit' template.
The 'authors' field has a typo in the username. It's written as "hashsbhat" but should be "harshsbhat", matching the username in the repository URL.
Apply this diff to correct the author's username:
- authors: ["hashsbhat"],
+ authors: ["harshsbhat"],📝 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.
| authors: ["hashsbhat"], | |
| authors: ["harshsbhat"], |
0xJaskeerat
left a comment
There was a problem hiding this comment.
Do resolve the merge conflicts after you are done with changes
Do leme know if you need any help
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
apps/www/app/templates/client.tsx (1)
Line range hint
58-83: LGTM! Consider a minor optimization for framework sorting.The changes to the
frameworksvariable declaration and sorting look good. The transition fromconsttolet, addition of type annotation, and the alphabetical sorting of frameworks align well with the PR objective.Consider combining the initial reduction and sorting into a single operation for slightly improved efficiency:
const frameworks: Partial<Record<Framework, number>> = Object.fromEntries( Object.entries( Object.values(templates).reduce( (acc, { framework }) => { if (framework) { acc[framework] = (acc[framework] || 0) + 1; } return acc; }, {} as Record<Framework, number> ) ).sort(([a], [b]) => a.localeCompare(b)) );This approach eliminates the need for the
letdeclaration and performs the sorting in a single pass.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
apps/www/public/images/templates/nextjs-supabase-payasyougo.pngis excluded by!**/*.png
📒 Files selected for processing (2)
- apps/dashboard/app/(app)/settings/user/update-user-email.tsx (1 hunks)
- apps/www/app/templates/client.tsx (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- apps/dashboard/app/(app)/settings/user/update-user-email.tsx
🧰 Additional context used
🔇 Additional comments (1)
apps/www/app/templates/client.tsx (1)
Line range hint
58-83: Positive impact on user interface noted.The alphabetical sorting of frameworks will improve the user experience by presenting the framework filter checkboxes in a more organized and easily navigable order. This change aligns well with the PR objective of enhancing the ordering of template filters.
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
apps/www/app/templates/data.ts (1)
Line range hint
4-19: Frameworks array is not sorted alphabetically and contains duplicatesThe
frameworksarray should be sorted alphabetically to improve readability and maintainability, as indicated by the comment on line 3. Additionally, there's a duplicate entry for"Django"in the array.Apply this diff to sort the array alphabetically and remove the duplicate:
export const frameworks = [ - "Django", - "Next.js", - "Svelte", - "Express", - "Bun", - "Echo", - "Flask", - "Django", - "Axum", - "Actix", - "Rocket", - "Oak", - "FastAPI", - "NestJS", + "Actix", + "Axum", + "Bun", + "Django", + "Echo", + "Express", + "FastAPI", + "Flask", + "NestJS", + "Next.js", + "Oak", + "Rocket", + "Svelte", ] as const;
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- apps/www/app/templates/data.ts (1 hunks)
🧰 Additional context used
🔇 Additional comments (3)
apps/www/app/templates/data.ts (3)
Line range hint
89-91: Duplicate comment from previous reviewThe 'authors' field in the
'cost-ratelimit'template still contains a typo. The username is written as"hashsbhat"but should be"harshsbhat"to match the correct GitHub username.
Line range hint
135-147: Duplicate comment from previous reviewThere's a typo in the template key
'nextjs-boilderplate'; it should be'nextjs-boilerplate'to match the standard spelling.
Line range hint
241-252: Duplicate comment from previous reviewThe repository URL in the
'elixir-mix-supervision'template appears to be incorrect. It should likely be:https://github.com/unkeyed/examples/tree/main/elixir_mix_supervision_exampleinstead of the current URL.
|
@0xJaskeerat i dynamically ordered the templates |
What does this PR do?
Templates Filters ordered alphabetically
Fixes # #2432
Type of change
Templates Filters ordered alphabetically
How should this be tested?
Visit the https://www.unkey.com/templates
Checklist
Required
pnpm buildpnpm fmtconsole.logsgit pull origin mainAppreciated
Summary by CodeRabbit
New Features
Improvements
Bug Fixes