Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ✨ initial tasks application/domain/interface-adapters #98

Merged
merged 1 commit into from
Dec 7, 2024

Conversation

zhumeisongsong
Copy link
Owner

@zhumeisongsong zhumeisongsong commented Dec 7, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced new libraries: tasks-application, tasks-domain, and tasks-interface-adapters with basic functionalities.
    • Each library now has a README file with instructions for running unit tests.
    • New functions added: tasksApplication and tasksDomain returning respective string literals.
  • Testing Enhancements

    • New test suites created for tasksApplication, tasksDomain, and tasksInterfaceAdapters functions to ensure expected behavior.
  • Configuration Updates

    • Added ESLint and Jest configuration files for each library to streamline development and testing processes.
    • Introduced TypeScript configuration files to enforce strict type-checking and coding standards across libraries.
    • Updated tsconfig.base.json with new path mappings for easier imports.

Copy link

coderabbitai bot commented Dec 7, 2024

Walkthrough

This pull request introduces several new files and configurations for three libraries: tasks-application, tasks-domain, and tasks-interface-adapters. Each library receives a README file, ESLint configuration, Jest configuration, project configuration in JSON format, TypeScript configuration files, and an index file for exports. Additionally, new functions are added to each library, along with corresponding test suites to validate their functionality. The TypeScript base configuration is also updated with path mappings for easier module resolution.

Changes

File Path Change Summary
libs/tasks/application/README.md New README file created.
libs/tasks/application/eslint.config.js New ESLint configuration file created.
libs/tasks/application/jest.config.ts New Jest configuration file created.
libs/tasks/application/project.json New project configuration file created.
libs/tasks/application/src/index.ts Exported all entities from ./lib/tasks-application.
libs/tasks/application/src/lib/tasks-application.spec.ts New test suite for tasksApplication function created.
libs/tasks/application/src/lib/tasks-application.ts New tasksApplication function added.
libs/tasks/application/tsconfig.json New TypeScript configuration file created.
libs/tasks/application/tsconfig.lib.json New TypeScript library configuration file created.
libs/tasks/application/tsconfig.spec.json New TypeScript test configuration file created.
libs/tasks/domain/README.md New README file created.
libs/tasks/domain/eslint.config.js New ESLint configuration file created.
libs/tasks/domain/jest.config.ts New Jest configuration file created.
libs/tasks/domain/project.json New project configuration file created.
libs/tasks/domain/src/index.ts Exported all entities from lib/tasks-domain.
libs/tasks/domain/src/lib/tasks-domain.spec.ts New test suite for tasksDomain function created.
libs/tasks/domain/src/lib/tasks-domain.ts New tasksDomain function added.
libs/tasks/domain/tsconfig.json New TypeScript configuration file created.
libs/tasks/domain/tsconfig.lib.json New TypeScript library configuration file created.
libs/tasks/domain/tsconfig.spec.json New TypeScript test configuration file created.
libs/tasks/interface-adapters/README.md New README file created.
libs/tasks/interface-adapters/eslint.config.js New ESLint configuration file created.
libs/tasks/interface-adapters/jest.config.ts New Jest configuration file created.
libs/tasks/interface-adapters/project.json New project configuration file created.
libs/tasks/interface-adapters/src/index.ts Exported all entities from lib/tasks-interface-adapters.
libs/tasks/interface-adapters/src/lib/tasks-interface-adapters.spec.ts New test suite for tasksInterfaceAdapters function created.
libs/tasks/interface-adapters/src/lib/tasks-interface-adapters.ts New tasksInterfaceAdapters function added.
libs/tasks/interface-adapters/tsconfig.json New TypeScript configuration file created.
libs/tasks/interface-adapters/tsconfig.lib.json New TypeScript library configuration file created.
libs/tasks/interface-adapters/tsconfig.spec.json New TypeScript test configuration file created.
tsconfig.base.json New path mappings added for @tasks/application, @tasks/domain, and @tasks/interface-adapters.

Possibly related PRs

🐇 In a world of tasks, we hop and play,
With new libraries brightening the way.
README and tests, all set to explore,
TypeScript and Jest, we couldn't ask for more!
So let’s code with joy, let our functions sing,
For in the land of tasks, we’re the coding kings! 🐇


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 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (8)
libs/tasks/interface-adapters/src/lib/tasks-interface-adapters.ts (2)

1-3: Add JSDoc documentation to explain the function's purpose

The function appears to be part of an interface adapters pattern, but its purpose and usage are not clear. Consider adding documentation to explain its role in the architecture.

+/**
+ * Interface adapter for tasks module.
+ * @returns A string identifier for the tasks interface adapter
+ */
export function tasksInterfaceAdapters(): string {
  return 'tasks-interface-adapters';
}

1-3: Consider implementing a proper interface adapter pattern

The current implementation appears to be a placeholder. In a typical interface adapters pattern (from Clean Architecture), this module should be responsible for converting data between the use cases and external agencies.

Consider:

  1. Defining proper interfaces for the domain and external layers
  2. Implementing conversion logic between these interfaces
  3. Adding error handling for conversion failures
libs/tasks/interface-adapters/src/lib/tasks-interface-adapters.spec.ts (2)

4-6: Improve test description and coverage

The current test description "should work" is not descriptive enough. Consider making the test suite more comprehensive.

-  it('should work', () => {
+  it('should return the tasks interface adapter identifier', () => {
     expect(tasksInterfaceAdapters()).toEqual('tasks-interface-adapters');
   });
+
+  // Add more test cases as the implementation grows
+  // For example:
+  // - Test data conversion methods
+  // - Test error handling
+  // - Test interface compliance

3-7: Consider organizing tests using nested describe blocks

As the interface adapter grows in complexity, consider organizing tests using nested describe blocks for better structure.

 describe('tasksInterfaceAdapters', () => {
-  it('should work', () => {
-    expect(tasksInterfaceAdapters()).toEqual('tasks-interface-adapters');
-  });
+  describe('initialization', () => {
+    it('should return the tasks interface adapter identifier', () => {
+      expect(tasksInterfaceAdapters()).toEqual('tasks-interface-adapters');
+    });
+  });
+
+  // Future test categories
+  // describe('data conversion', () => {});
+  // describe('error handling', () => {});
 });
libs/tasks/domain/src/lib/tasks-domain.ts (1)

1-3: Consider enhancing domain layer with proper business entities

The current implementation appears to be a placeholder. As part of the domain layer, this module should contain core business rules, entities, and value objects. Consider expanding this to include:

  • Task entity with relevant properties (e.g., id, title, status)
  • Task-related value objects
  • Domain interfaces/ports for repository access

Example structure:

export interface Task {
  id: string;
  title: string;
  status: TaskStatus;
  createdAt: Date;
}

export enum TaskStatus {
  TODO = 'TODO',
  IN_PROGRESS = 'IN_PROGRESS',
  DONE = 'DONE'
}

export interface TaskRepository {
  save(task: Task): Promise<Task>;
  findById(id: string): Promise<Task | null>;
}
libs/tasks/application/src/lib/tasks-application.ts (1)

1-3: Implement application use cases

The application layer should contain use cases that orchestrate domain logic. Consider implementing proper use cases instead of the current placeholder:

Example structure:

import { Task, TaskRepository } from '@your-org/tasks-domain';

export class CreateTaskUseCase {
  constructor(private taskRepository: TaskRepository) {}

  async execute(title: string): Promise<Task> {
    const task: Task = {
      id: generateId(),
      title,
      status: TaskStatus.TODO,
      createdAt: new Date()
    };
    
    return this.taskRepository.save(task);
  }
}
libs/tasks/domain/tsconfig.spec.json (1)

1-14: LGTM! Consider organizing test files consistently.

The test configuration is well-structured and includes all necessary compiler options for Jest testing.

Consider maintaining a consistent test file organization by choosing either .spec.ts or .test.ts as the standard test file extension throughout the project. Currently, both are included in the configuration.

libs/tasks/application/src/lib/tasks-application.spec.ts (1)

4-6: Consider adding type checking in tests.

Since this is a TypeScript project, it would be beneficial to add type assertions in the test.

Apply this diff to add type checking:

   it('should work', () => {
-    expect(tasksApplication()).toEqual('tasks-application');
+    const result = tasksApplication();
+    expect(typeof result).toBe('string');
+    expect(result).toEqual('tasks-application');
   });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 8efd840 and f035696.

📒 Files selected for processing (31)
  • libs/tasks/application/README.md (1 hunks)
  • libs/tasks/application/eslint.config.js (1 hunks)
  • libs/tasks/application/jest.config.ts (1 hunks)
  • libs/tasks/application/project.json (1 hunks)
  • libs/tasks/application/src/index.ts (1 hunks)
  • libs/tasks/application/src/lib/tasks-application.spec.ts (1 hunks)
  • libs/tasks/application/src/lib/tasks-application.ts (1 hunks)
  • libs/tasks/application/tsconfig.json (1 hunks)
  • libs/tasks/application/tsconfig.lib.json (1 hunks)
  • libs/tasks/application/tsconfig.spec.json (1 hunks)
  • libs/tasks/domain/README.md (1 hunks)
  • libs/tasks/domain/eslint.config.js (1 hunks)
  • libs/tasks/domain/jest.config.ts (1 hunks)
  • libs/tasks/domain/project.json (1 hunks)
  • libs/tasks/domain/src/index.ts (1 hunks)
  • libs/tasks/domain/src/lib/tasks-domain.spec.ts (1 hunks)
  • libs/tasks/domain/src/lib/tasks-domain.ts (1 hunks)
  • libs/tasks/domain/tsconfig.json (1 hunks)
  • libs/tasks/domain/tsconfig.lib.json (1 hunks)
  • libs/tasks/domain/tsconfig.spec.json (1 hunks)
  • libs/tasks/interface-adapters/README.md (1 hunks)
  • libs/tasks/interface-adapters/eslint.config.js (1 hunks)
  • libs/tasks/interface-adapters/jest.config.ts (1 hunks)
  • libs/tasks/interface-adapters/project.json (1 hunks)
  • libs/tasks/interface-adapters/src/index.ts (1 hunks)
  • libs/tasks/interface-adapters/src/lib/tasks-interface-adapters.spec.ts (1 hunks)
  • libs/tasks/interface-adapters/src/lib/tasks-interface-adapters.ts (1 hunks)
  • libs/tasks/interface-adapters/tsconfig.json (1 hunks)
  • libs/tasks/interface-adapters/tsconfig.lib.json (1 hunks)
  • libs/tasks/interface-adapters/tsconfig.spec.json (1 hunks)
  • tsconfig.base.json (1 hunks)
✅ Files skipped from review due to trivial changes (23)
  • libs/tasks/application/eslint.config.js
  • libs/tasks/application/src/index.ts
  • libs/tasks/domain/eslint.config.js
  • libs/tasks/domain/README.md
  • libs/tasks/domain/src/index.ts
  • libs/tasks/interface-adapters/jest.config.ts
  • libs/tasks/application/project.json
  • libs/tasks/domain/jest.config.ts
  • libs/tasks/interface-adapters/src/index.ts
  • libs/tasks/domain/tsconfig.lib.json
  • libs/tasks/application/tsconfig.lib.json
  • libs/tasks/application/tsconfig.spec.json
  • libs/tasks/domain/project.json
  • libs/tasks/application/tsconfig.json
  • libs/tasks/interface-adapters/tsconfig.json
  • libs/tasks/interface-adapters/tsconfig.spec.json
  • libs/tasks/interface-adapters/project.json
  • libs/tasks/interface-adapters/README.md
  • libs/tasks/application/jest.config.ts
  • libs/tasks/domain/tsconfig.json
  • libs/tasks/application/README.md
  • libs/tasks/interface-adapters/eslint.config.js
  • libs/tasks/interface-adapters/tsconfig.lib.json
🔇 Additional comments (1)
tsconfig.base.json (1)

28-32: LGTM! Verify path mappings are correctly set up.

The new path mappings follow the established pattern and clean architecture structure. The paths are properly aligned with the new tasks libraries.

Let's verify the path mappings are correctly set up:

✅ Verification successful

Path mappings are correctly configured and all index files exist

All specified index.ts files are present at their respective paths in the tasks libraries:

  • libs/tasks/application/src/index.ts
  • libs/tasks/domain/src/index.ts
  • libs/tasks/interface-adapters/src/index.ts
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the existence of index.ts files at the specified paths

echo "Verifying index.ts files exist at specified paths..."
for path in \
  "libs/tasks/application/src/index.ts" \
  "libs/tasks/domain/src/index.ts" \
  "libs/tasks/interface-adapters/src/index.ts"
do
  if [ -f "$path" ]; then
    echo "✓ Found: $path"
  else
    echo "✗ Missing: $path"
  fi
done

Length of output: 954

@zhumeisongsong zhumeisongsong merged commit 86beb78 into main Dec 7, 2024
5 checks passed
@zhumeisongsong zhumeisongsong deleted the feature/add-task-module branch December 7, 2024 01:46
Copy link

github-actions bot commented Dec 7, 2024

🎉 This PR is included in version 1.12.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant