All the core contracts (interfaces) that should be used all over the projects to maintain consistency

0.0.4 2024-04-21 15:58 UTC

This package is auto-updated.

Last update: 2024-04-21 12:30:06 UTC


README

This is a so simple but so important packge that inclues a lot of interface files as our contracts.🔥

alt text

🗒️ Description

This package provides a comprehensive set of interfaces (contracts) that define the core functionalities and standards for various components within the application. It serves as the foundation for ensuring a consistent implementation of domain entities, services, repositories, value objects, and test cases accross all the projects.

🔍 Overview

The contracts package includes interfaces for:

  • Commands and Queries: Define standard operations for CQRS patterns.
  • Entities: Standardize core entity behaviors.
  • Repositories: Outline data access and manipulation methods.
  • Services: Define business logic and service layer interactions.
  • Value Objects: Ensure immutability and domain-specific data integrity.
  • Test Contracts: Provide a structure for unit and feature tests.

🏁 Installation

To install the Generator, first of all, you need to define this repository in you composer.json file

// composer.json
...
"repositories": [
    {
        "type": "vcs",
        "url": "https://gitlab.com/vitrin-solutions/infrastructure/laravel/contracts.git"
    }
],
"require": {
    //
}
...

then, run the following command in your Laravel project:

composer require vitrin-infrastructure/contracts

🤟 Usage

Implement these contracts in your application to enforce consistency and adherence to domain-driven design principles. For example, to create a new entity:

namespace App\Domain\Entities;

use Vitrin\Infrastructure\Contracts\Entity\EntityContract;
use Vitrin\Infrastructure\Types\ID;

class UserEntity implements EntityContract {
    // Implementation details...
}

📚 Documentation

This is the list of all the available contracts:

ContractDescription
Vitrin\Infrastructure\Contracts\Command\Create\CreateCommandContractDefines operations for creating entities, including authorization checks.
Vitrin\Infrastructure\Contracts\Command\Delete\DeleteCommandContractOutlines deletion operations for entities, including getting identifiers and authorization.
Vitrin\Infrastructure\Contracts\Command\Update\UpdateCommandContractSpecifies update operations, including data transformation to entities and authorization.
Vitrin\Infrastructure\Contracts\Entity\EntityContractDefines essential entity behaviors, like identifier retrieval and array conversion.
Vitrin\Infrastructure\Contracts\Facade\FacadeContractMarker interface for facade classes, facilitating static access to underlying logic.
Vitrin\Infrastructure\Contracts\Filter\FilterContractStandardizes data filtering across applications for dynamic query modifications.
Vitrin\Infrastructure\Contracts\Model\ModelContractEnhances model functionality with methods like dynamic query filtering.
Vitrin\Infrastructure\Contracts\Query\Find\FindQueryContractDefines the contract for find queries, including identifier retrieval and authorization.
Vitrin\Infrastructure\Contracts\Query\List\ListQueryContractOutlines the structure for list queries, including pagination details and authorization.
Vitrin\Infrastructure\Contracts\Repository\RepositoryContractSpecifies common CRUD operations and utilities for entity data storage.
Vitrin\Infrastructure\Contracts\Service\ServiceContractBase contract for service layer classes, defining business logic and service interactions.
Vitrin\Infrastructure\Contracts\ServiceProvider\ServiceProviderContractContract for defining service providers, standardizing service registration.
Vitrin\Infrastructure\Contracts\Tests\Commands\TestCreateCommandContractContract for testing create command functionalities across different user permissions.
Vitrin\Infrastructure\Contracts\Tests\Commands\TestDeleteCommandContractDefines the testing structure for delete command functionalities.
Vitrin\Infrastructure\Contracts\Tests\Commands\TestUpdateCommandContractContract for testing update command operations, including invalid data handling.
Vitrin\Infrastructure\Contracts\Tests\Queries\TestFindQueryContractOutlines testing strategies for find query operations, including authorization checks.
Vitrin\Infrastructure\Contracts\Tests\Queries\TestListQueryContractDefines the contract for testing list query functionalities and data integrity.
Vitrin\Infrastructure\Contracts\ValueObject\ValueObjectContractMarker interface for value objects, ensuring immutability and domain-specific data integrity.

🪄 Go to next level

Creating all the files and implment the correct contract is a really boring and time consuming task, instead of that, you can use Vitrin Solutions Generator to generate all the files what you need automatically 🔥.\ Link to generator documentation

👨‍💻👩‍💻 Contributing

Contributions to the Contracts Package are welcome! Please ensure your pull requests are well-documented and follow the existing coding standards.

👨‍💻 Author

This package is under active development by Amir Khadangi.

🪪 License

This project is licensed under the MIT License. See the LICENSE file for details.