Skip to content
Merged
Show file tree
Hide file tree
Changes from 57 commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
3f6f432
[#.x] - added more tests
niden Nov 30, 2025
d67e9b5
[#.x] - fixing issuer filter
niden Nov 30, 2025
973b481
[#.x] - adjusted test
niden Nov 30, 2025
9d4e868
[#.x] - adjusting shared services
niden Nov 30, 2025
f41ddc0
[#.x] - support for 8.5
niden Dec 24, 2025
ed45040
[#.x] - moving files to new locations
niden Dec 27, 2025
b31e81a
[#.x] - simplifying validators; adjusting test; moving enum to its ne…
niden Dec 27, 2025
eb37f52
[#.x] - adjusting user mapper with new interface
niden Dec 27, 2025
5c1eb65
[#.x] - adjusting docblocks
niden Dec 27, 2025
e1a6e63
[#.x] - new abstract value objects
niden Dec 27, 2025
c7f4054
[#.x] - adjusting dtos
niden Dec 27, 2025
4e2c011
[#.x] - moving common code in
niden Dec 27, 2025
b9d31f3
[#.x] - added companies test migration
niden Dec 27, 2025
68d5608
[#.x] - migration for companies table
niden Dec 27, 2025
fcdfc44
[#.x] - adjusting dto
niden Dec 27, 2025
14565be
[#.x] - docblock correction
niden Dec 27, 2025
717d8c4
[#.x] - added auth transformer
niden Dec 27, 2025
3ee1555
[#.x] - handlers using the transformer now
niden Dec 27, 2025
1a40079
[#.x] - adjusting definitions to add the transformer
niden Dec 27, 2025
8a03a93
[#.x] - adding the transformer
niden Dec 27, 2025
931bd13
[#.x] - docblock
niden Dec 27, 2025
5ec8a24
[#.x] - scope changes
niden Dec 27, 2025
06ab4ec
[#.x] - added transformer in the container
niden Dec 27, 2025
08c820d
[#.x] - added transformer in the container
niden Dec 27, 2025
1d2518f
[#.x] - added transformer class
niden Dec 27, 2025
feb1384
[#.x] - new vo interface
niden Dec 27, 2025
4e0d0cf
[#.x] - updating sanitizers and validators
niden Dec 27, 2025
75e3c63
[#.x] - removing common code
niden Dec 27, 2025
f6437ef
[#.x] - updating docblock
niden Dec 27, 2025
f94f97d
[#.x] - scope changes
niden Dec 27, 2025
fc513f8
[#.x] - adding transformer in the definitions
niden Dec 27, 2025
2cdcd7b
[#.x] - adding the transformer
niden Dec 27, 2025
c524e3e
[#.x] - new listener for pdo errors
niden Dec 27, 2025
9e7eab3
[#.x] - adjusting test
niden Dec 27, 2025
bf5e218
[#.x] - updating handler with transformer
niden Dec 27, 2025
ec85fcf
[#.x] - new routes for company
niden Dec 27, 2025
b66a29f
[#.x] - new shape for company
niden Dec 27, 2025
22dfe06
[#.x] - company di definitions
niden Dec 27, 2025
6b87a4c
[#.x] - new auth enum tests
niden Dec 27, 2025
679eff2
[#.x] - new company collection
niden Dec 27, 2025
b25cc3c
[#.x] - new company dtos
niden Dec 27, 2025
460b2d8
[#.x] - new sanitizers, mapper and validators
niden Dec 27, 2025
2d6603b
[#.x] - new company validators
niden Dec 27, 2025
cee5d53
[#.x] - new company validators
niden Dec 27, 2025
de6ea27
[#.x] - new company types for stan
niden Dec 27, 2025
294cae9
[#.x] - new company command factory
niden Dec 27, 2025
f27fd7e
[#.x] - new company command dtos
niden Dec 27, 2025
678c662
[#.x] - new company command repository
niden Dec 27, 2025
f6b113f
[#.x] - new company services
niden Dec 27, 2025
f60ee63
[#.x] - new company facade
niden Dec 27, 2025
df19f2f
[#.x] - company services and mapper test
niden Dec 27, 2025
da85f2b
[#.x] - company dto test
niden Dec 27, 2025
8b089ee
[#.x] - company validator tests
niden Dec 27, 2025
a5a1634
[#.x] - added company handlers and tests
niden Dec 27, 2025
c4ea841
[#.x] - added company criteria dto
niden Dec 27, 2025
aca8ecc
[#.x] - added company dispatch get test
niden Dec 27, 2025
8ec4ab6
[#.x] - added more tests
niden Dec 27, 2025
172ca5c
[#.x] - correcting tests
niden Dec 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
- '8.2'
- '8.3'
- '8.4'
- '8.5'
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -81,6 +82,7 @@ jobs:
- '8.2'
- '8.3'
- '8.4'
- '8.5'

services:
mariadb:
Expand Down
29 changes: 28 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,34 @@ services:
networks:
- app-network
environment:
- PHP_IDE_CONFIG=serverName=rest-api-app-83
- PHP_IDE_CONFIG=serverName=rest-api-app-84
- APP_ENV=development
- APP_ENV_ADAPTER=dotenv
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost/fpm-ping"]
interval: 30s
timeout: 3s
retries: 3
start_period: 5s

app-8.5:
build:
dockerfile: ./resources/docker/Dockerfile
args:
PHP_VERSION: 8.5
hostname: rest-api-app-85
container_name: "${PROJECT_NAME}-api-8.5"
tty: true
working_dir: /app
volumes:
- ./:/app
depends_on:
- app-db
- app-cache
networks:
- app-network
environment:
- PHP_IDE_CONFIG=serverName=rest-api-app-85
- APP_ENV=development
- APP_ENV_ADAPTER=dotenv
healthcheck:
Expand Down
190 changes: 190 additions & 0 deletions resources/db/migrations/20251226161244_add_companies_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
<?php

declare(strict_types=1);

use Phinx\Migration\AbstractMigration;

final class AddCompaniesTable extends AbstractMigration
{
public function down(): void
{
$this->table('co_companies')->drop()->save();
}

public function up(): void
{
$table = $this->table(
'co_companies',
[
'id' => 'com_id',
'signed' => false,
]
);

$table
->addColumn(
'com_name',
'string',
[
'limit' => 128,
'null' => false,
'default' => '',
]
)
->addColumn(
'com_phone',
'string',
[
'limit' => 32,
'null' => false,
'default' => '',
]
)
->addColumn(
'com_email',
'string',
[
'limit' => 128,
'null' => false,
'default' => '',
]
)
->addColumn(
'com_website',
'string',
[
'limit' => 128,
'null' => false,
'default' => '',
]
)
->addColumn(
'com_address_line_1',
'string',
[
'limit' => 128,
'null' => false,
'default' => '',
]
)
->addColumn(
'com_address_line_2',
'string',
[
'limit' => 128,
'null' => false,
'default' => '',
]
)
->addColumn(
'com_city',
'string',
[
'limit' => 128,
'null' => false,
'default' => '',
]
)
->addColumn(
'com_state_province',
'string',
[
'limit' => 64,
'null' => false,
'default' => '',
]
)
->addColumn(
'com_zip_code',
'string',
[
'limit' => 32,
'null' => false,
'default' => '',
]
)
->addColumn(
'com_country',
'string',
[
'limit' => 8,
'null' => false,
'default' => '',
]
)
->addColumn(
'com_created_date',
'timestamp',
[
'timezone' => true,
'default' => 'CURRENT_TIMESTAMP',
]
)
->addColumn(
'com_created_usr_id',
'biginteger',
[
'null' => false,
'default' => 0,
]
)
->addColumn(
'com_updated_date',
'timestamp',
[
'timezone' => true,
'default' => null,
]
)
->addColumn(
'com_updated_usr_id',
'biginteger',
[
'null' => false,
'default' => 0,
]
)
->addIndex(
[
'com_name',
],
[
'name' => 'i_name',
]
)
->addIndex(
[
'com_email',
],
[
'name' => 'i_email',
]
)
->addIndex(
[
'com_city',
],
[
'name' => 'i_city',
]
)
->addIndex(
[
'com_state_province',
],
[
'name' => 'i_state_province',
]
)
->addIndex(
[
'com_country',
],
[
'name' => 'i_country',
]
)
->save()
;
}
}
20 changes: 20 additions & 0 deletions src/Domain/ADR/InputTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@
* token?: string
* }
*
* @phpstan-type TCompanyInput array{
* id?: int,
* name?: string,
* phone?: string,
* email?: string,
* website?: string,
* addressLine1?: string,
* addressLine2?: string,
* city?: string,
* stateProvince?: string,
* zipCode?: string,
* country?: string,
* createdDate?: string,
* createdUserId?: int,
* updatedDate?: string,
* updatedUserId?: int,
* page?: int,
* perPage?: int
* }
*
* @phpstan-type TUserInput array{
* id?: int,
* status?: int,
Expand Down
3 changes: 2 additions & 1 deletion src/Domain/Application/Auth/Facade/AuthFacade.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
final readonly class AuthFacade
{
/**
* @param CommandBusInterface $bus
* @param CommandBusInterface $bus
* @param AuthCommandFactoryInterface $factory
*/
public function __construct(
private CommandBusInterface $bus,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use Phalcon\Api\Domain\ADR\InputTypes;
use Phalcon\Api\Domain\Infrastructure\CommandBus\HandlerInterface;
use Phalcon\Api\Domain\Infrastructure\DataSource\Auth\Transformer\AuthTransformer;
use Phalcon\Api\Domain\Infrastructure\DataSource\Validation\ValidatorInterface;
use Phalcon\Api\Domain\Infrastructure\Encryption\TokenManagerInterface;

Expand All @@ -25,10 +26,12 @@ abstract class AbstractAuthLogoutRefreshHandler implements HandlerInterface
{
/**
* @param TokenManagerInterface $tokenManager
* @param AuthTransformer $transformer
* @param ValidatorInterface $validator
*/
public function __construct(
protected readonly TokenManagerInterface $tokenManager,
protected readonly AuthTransformer $transformer,
protected readonly ValidatorInterface $validator,
) {
}
Expand Down
31 changes: 9 additions & 22 deletions src/Domain/Application/Auth/Handler/AuthLoginPostHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Phalcon\Api\Domain\Application\Auth\Command\AuthLoginPostCommand;
use Phalcon\Api\Domain\Infrastructure\CommandBus\CommandInterface;
use Phalcon\Api\Domain\Infrastructure\CommandBus\HandlerInterface;
use Phalcon\Api\Domain\Infrastructure\DataSource\Auth\Transformer\AuthTransformer;
use Phalcon\Api\Domain\Infrastructure\DataSource\User\Repository\UserRepositoryInterface;
use Phalcon\Api\Domain\Infrastructure\DataSource\Validation\ValidatorInterface;
use Phalcon\Api\Domain\Infrastructure\Encryption\Security;
Expand All @@ -27,19 +28,21 @@
/**
* @phpstan-import-type TAuthLoginInput from InputTypes
*/
final class AuthLoginPostHandler implements HandlerInterface
final readonly class AuthLoginPostHandler implements HandlerInterface
{
/**
* @param UserRepositoryInterface $repository
* @param TokenManagerInterface $tokenManager
* @param AuthTransformer $transformer
* @param Security $security
* @param ValidatorInterface $validator
*/
public function __construct(
private readonly UserRepositoryInterface $repository,
private readonly TokenManagerInterface $tokenManager,
private readonly Security $security,
private readonly ValidatorInterface $validator
private UserRepositoryInterface $repository,
private TokenManagerInterface $tokenManager,
private AuthTransformer $transformer,
private Security $security,
private ValidatorInterface $validator
) {
}

Expand Down Expand Up @@ -87,22 +90,6 @@ public function __invoke(CommandInterface $command): Payload
*/
$tokens = $this->tokenManager->issue($domainUser);

/**
* Construct the response
*/
$results = [
'authenticated' => true,
'user' => [
'id' => $domainUser->id,
'name' => $domainUser->fullName(),
'email' => $domainUser->email,
],
'jwt' => [
'token' => $tokens['token'],
'refreshToken' => $tokens['refreshToken'],
],
];

return Payload::success($results);
return Payload::success($this->transformer->login($domainUser, $tokens));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ public function __invoke(CommandInterface $command): Payload

$this->tokenManager->revoke($domainUser);

return Payload::success(['authenticated' => false]);
return Payload::success($this->transformer->logout());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ public function __invoke(CommandInterface $command): Payload

$tokens = $this->tokenManager->refresh($domainUser);

return Payload::success([
'token' => $tokens['token'],
'refreshToken' => $tokens['refreshToken'],
]);
return Payload::success($this->transformer->refresh($tokens));
}
}
Loading
Loading