Skip to content

Add employee apis#96

Merged
Marfuen merged 4 commits into
mainfrom
mariano/employee_api
Mar 4, 2025
Merged

Add employee apis#96
Marfuen merged 4 commits into
mainfrom
mariano/employee_api

Conversation

@Marfuen
Copy link
Copy Markdown
Contributor

@Marfuen Marfuen commented Mar 4, 2025

Summary by CodeRabbit

  • New Features
    • Launched a new API Keys management section in Settings, providing a dedicated dashboard to create, view, and revoke API keys with customizable expiration options.
    • Introduced an intuitive dialog interface for API key generation, complete with copy-to-clipboard functionality and real-time feedback.
    • Expanded localization support for API key management across multiple languages, improving the overall user experience.

Marfuen and others added 4 commits March 4, 2025 13:31
- Introduce OrganizationApiKey model in Prisma schema
- Create API key schema and validation in actions
- Update ActionResponse type to support more detailed error handling
- Add API keys section to settings layout and translations
- Prepare groundwork for API key creation, management, and security features
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
app ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 4, 2025 7:01pm
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
comp-portal ⬜️ Skipped (Inspect) Mar 4, 2025 7:01pm
web ⬜️ Skipped (Inspect) Mar 4, 2025 7:01pm

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 4, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update implements a comprehensive API key management system. New actions allow creating, retrieving, and revoking API keys with proper input validation, key generation, hashing, and expiration handling. The changes introduce new API endpoints, UI components, and a settings page with updated navigation. Localization files are extended with API key-related strings, and database migrations add a dedicated table with the necessary indexes and constraints. Additional endpoints for employee management and updates to common types ensure consistency across the application.

Changes

File(s) Change Summary
apps/app/src/actions/organization/{create,get,revoke}-api-key-action.ts Added actions for creating, retrieving, and revoking API keys with validations and error handling.
apps/app/src/actions/schema.ts Introduced new apiKeySchema for input validation and minor formatting changes.
apps/app/src/actions/types.ts Updated interfaces (ActionResponse, DomainVerificationResponse) for enhanced error and optional verification structures.
apps/app/src/app/[locale]/(...)/settings/{api-keys/page.tsx,layout.tsx} Added API keys settings page with metadata generation and a new navigation menu item for API key management.
apps/app/src/app/api/v1/api-keys/route.ts Implemented GET, POST, and DELETE endpoints for API key operations, including authentication and error handling.
apps/app/src/app/api/v1/employees/{add/route.ts,route.ts} Added endpoints for employee creation and retrieval with input validation using Zod.
apps/app/src/components/tables/api-keys/{create-api-key-dialog.tsx,index.tsx} New UI components for API key creation dialog and table display, including copy-to-clipboard and revocation features.
apps/app/src/hooks/use-api-keys.ts Introduced a custom SWR hook for fetching API key data with translation support.
apps/app/src/lib/api-key.ts Added functions for API key generation, salt creation, hashing, validation, and middleware integration.
apps/app/src/locales/{en,es,fr,no,pt}.ts Updated localization files by adding new sections and strings for managing API keys.
packages/db/prisma/migrations/{20250304160745_add_api_keys,20250304165547_add_salt}/migration.sql Added migrations to create the OrganizationApiKey table and to add a salt column, including indexes and constraints.
packages/db/prisma/schema.prisma Introduced the OrganizationApiKey model and updated the Organization model to include an API keys relation.

Sequence Diagram(s)

sequenceDiagram
    participant U as User
    participant D as CreateApiKeyDialog
    participant A as createApiKeyAction
    participant DB as Database

    U->>D: Submit API key form (name, expiresAt)
    D->>A: Invoke createApiKeyAction
    A->>A: Validate input & generate key, salt, hash
    A->>DB: Store API key record
    DB-->>A: Return stored record
    A-->>D: Return plain text API key
    D->>U: Display key and copy option
Loading
sequenceDiagram
    participant U as User
    participant T as ApiKeysTable
    participant R as revokeApiKeyAction
    participant DB as Database

    U->>T: Click "Revoke" on API key
    T->>R: Invoke revokeApiKeyAction(apiKeyId)
    R->>DB: Update API key (set isActive = false)
    DB-->>R: Confirmation/Error response
    R-->>T: Return status message
    T->>U: Display revocation result
Loading

Possibly related PRs

  • add baseline migrations #48: Introduces modifications to the database schema with the OrganizationApiKey table structure, aligning closely with the API key management changes in this PR.

Poem

I’m a bouncy rabbit in a code-filled glen,
Hopping through migrations and endpoints again.
New keys I create with a twitch of delight,
Revoking old ones with a swift hop in flight.
With dialogs and tables, my code garden grows,
Celebrating new routes where safe API flows!
🐇💻 Hop on the changes, let the updates glow!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e160593 and 5a07694.

⛔ Files ignored due to path filters (1)
  • apps/app/languine.lock is excluded by !**/*.lock
📒 Files selected for processing (22)
  • apps/app/src/actions/organization/create-api-key-action.ts (1 hunks)
  • apps/app/src/actions/organization/get-api-keys-action.ts (1 hunks)
  • apps/app/src/actions/organization/revoke-api-key-action.ts (1 hunks)
  • apps/app/src/actions/schema.ts (2 hunks)
  • apps/app/src/actions/types.ts (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/settings/api-keys/page.tsx (1 hunks)
  • apps/app/src/app/[locale]/(app)/(dashboard)/settings/layout.tsx (1 hunks)
  • apps/app/src/app/api/v1/api-keys/route.ts (1 hunks)
  • apps/app/src/app/api/v1/employees/add/route.ts (1 hunks)
  • apps/app/src/app/api/v1/employees/route.ts (1 hunks)
  • apps/app/src/components/tables/api-keys/create-api-key-dialog.tsx (1 hunks)
  • apps/app/src/components/tables/api-keys/index.tsx (1 hunks)
  • apps/app/src/hooks/use-api-keys.ts (1 hunks)
  • apps/app/src/lib/api-key.ts (1 hunks)
  • apps/app/src/locales/en.ts (1 hunks)
  • apps/app/src/locales/es.ts (1 hunks)
  • apps/app/src/locales/fr.ts (1 hunks)
  • apps/app/src/locales/no.ts (1 hunks)
  • apps/app/src/locales/pt.ts (1 hunks)
  • packages/db/prisma/migrations/20250304160745_add_api_keys/migration.sql (1 hunks)
  • packages/db/prisma/migrations/20250304165547_add_salt_to_api_keys/migration.sql (1 hunks)
  • packages/db/prisma/schema.prisma (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@Marfuen Marfuen merged commit 71a6727 into main Mar 4, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Apr 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants