Skip to content

Conversation

@UlisesGascon
Copy link
Member

@UlisesGascon UlisesGascon commented Jun 19, 2025

Related #1

Summary by CodeRabbit

  • New Features
    • Added a new CLI command to list all available compliance workflows, displaying each workflow's ID and description.
  • Tests
    • Introduced comprehensive tests for the new workflow listing command, covering successful retrieval, empty results, and error scenarios.

@UlisesGascon UlisesGascon self-assigned this Jun 19, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jun 19, 2025

Walkthrough

A new "workflow" feature was introduced to the CLI, enabling users to list compliance workflows. This includes new type definitions, API client logic, CLI command handlers, test coverage, and mock fixtures. The changes are additive and modular, affecting the CLI interface, backend API interaction, and automated tests.

Changes

File(s) Change Summary
src/types.ts Added APIWorkflowItem interface for workflow data structure.
src/api-client.ts Added getAllWorkflows function to fetch workflows from the API.
src/cli-commands.ts Added printWorkflows command to retrieve and display workflows.
src/index.ts Registered new workflow CLI command with a list subcommand calling printWorkflows.
src/tests/cli-commands.test.ts Added test suite for printWorkflows, covering success, multiple items, errors, and empty results.
src/tests/fixtures.ts Added mockAPIWorkflowResponse fixture for workflow API responses.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant CLICommands
    participant APIClient
    participant API

    User->>CLI: workflow list
    CLI->>CLICommands: printWorkflows()
    CLICommands->>APIClient: getAllWorkflows()
    APIClient->>API: GET /api/v1/workflow
    API-->>APIClient: [WorkflowItem, ...]
    APIClient-->>CLICommands: Workflow list
    CLICommands-->>CLI: CommandResult (messages, success)
    CLI-->>User: Output workflows or error message
Loading

Poem

In burrows deep, a workflow hops,
Now listed clear with CLI stops.
From types to tests, the code expands,
New commands at your furry hands.
With fixtures mocked and logic neat,
This rabbit’s work is now complete!
🐇✨


📜 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 7518567 and 1aa8fe1.

📒 Files selected for processing (6)
  • src/__tests__/cli-commands.test.ts (2 hunks)
  • src/__tests__/fixtures.ts (2 hunks)
  • src/api-client.ts (2 hunks)
  • src/cli-commands.ts (2 hunks)
  • src/index.ts (2 hunks)
  • src/types.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (5)
src/__tests__/fixtures.ts (1)
src/types.ts (1)
  • APIWorkflowItem (147-150)
src/api-client.ts (1)
src/types.ts (1)
  • APIWorkflowItem (147-150)
src/cli-commands.ts (2)
src/types.ts (1)
  • CommandResult (180-183)
src/api-client.ts (1)
  • getAllWorkflows (74-81)
src/index.ts (2)
src/cli-commands.ts (1)
  • printWorkflows (114-139)
src/utils.ts (1)
  • handleCommandResult (38-45)
src/__tests__/cli-commands.test.ts (3)
src/types.ts (2)
  • APIWorkflowItem (147-150)
  • APIErrorResponse (165-171)
src/__tests__/fixtures.ts (1)
  • mockAPIWorkflowResponse (125-128)
src/cli-commands.ts (1)
  • printWorkflows (114-139)
🔇 Additional comments (16)
src/types.ts (1)

144-150: LGTM! Well-defined workflow interface.

The APIWorkflowItem interface follows the established patterns in the codebase with proper JSDoc documentation and clear, simple structure. The string types for id and description are appropriate for workflow metadata.

src/__tests__/fixtures.ts (2)

1-1: LGTM! Import properly updated.

The import statement correctly includes the new APIWorkflowItem type needed for the mock data.


125-128: LGTM! Well-structured mock data.

The mockAPIWorkflowResponse follows the established pattern of other mock fixtures in the file and provides appropriate test data for workflow functionality.

src/api-client.ts (2)

3-3: LGTM! Import correctly updated.

The import statement properly includes the new APIWorkflowItem type for the API client function.


74-81: LGTM! Consistent API client implementation.

The getAllWorkflows function perfectly follows the established pattern of other API client functions in the file, with proper error handling, status code validation, and type safety.

src/cli-commands.ts (2)

3-3: LGTM! Import correctly updated.

The import statement properly includes the new getAllWorkflows function needed for the CLI command.


114-139: LGTM! Excellent CLI command implementation.

The printWorkflows function follows the established patterns perfectly with:

  • Consistent error handling and messaging
  • Proper async/await usage
  • Clear, user-friendly output formatting
  • Standard CommandResult return type

The implementation maintains consistency with printChecklists and printChecks functions.

src/index.ts (2)

7-7: LGTM! Import correctly updated.

The import statement properly includes the new printWorkflows function for the CLI commands.


26-36: LGTM! Well-structured CLI command integration.

The new workflow commands follow the established CLI patterns perfectly:

  • Consistent command structure and descriptions
  • Proper async/await handling
  • Integration with existing handleCommandResult utility
  • Good user experience with clear command descriptions

The implementation maintains consistency with other compliance management commands.

src/__tests__/cli-commands.test.ts (7)

3-6: LGTM! Imports properly updated for workflow functionality.

The new imports for printWorkflows and APIWorkflowItem are correctly added and follow the existing import patterns. The mock fixture import is also properly included.


384-390: Well-structured test suite setup.

The test suite follows the established pattern used by other CLI command tests in this file. The setup with beforeEach for cleaning nock and initializing mock data is consistent and appropriate.


392-408: Comprehensive test for successful workflow retrieval.

The test properly mocks the API endpoint, validates the response structure, and checks all expected message content. The assertions correctly verify both the success state and the formatted output.


410-433: Good coverage for multiple workflow items.

The test correctly handles multiple workflow items by extending the mock data and verifying that each item is properly formatted in the output. This ensures the function can handle arrays of various sizes.


435-448: Proper error handling for API failures.

The test correctly mocks a 500 error response and validates that the error is properly caught and formatted. The error message format matches the expected pattern from the function implementation.


450-464: Good network error handling.

The test uses replyWithError to simulate network failures and verifies that the error message includes the specific error details. This ensures robust error handling for network-related issues.


466-479: Appropriate edge case handling for empty responses.

The test correctly handles the empty array scenario and validates that the function returns the expected "No compliance workflows found" message. This matches the implementation logic shown in the relevant code snippets.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need 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)

  • @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 generate sequence diagram to generate a sequence diagram of the changes in 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.

@UlisesGascon UlisesGascon changed the title feat: add API Response types for workflows feat: add command workflow list Jun 19, 2025
@UlisesGascon UlisesGascon merged commit 30eed17 into main Jun 19, 2025
10 checks passed
@UlisesGascon UlisesGascon deleted the feat/workflows branch June 19, 2025 18:13
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