Search by

adachsoft / dynamic-tables-form-contract

Arkadiusz Adach

Framework-agnostic contracts and data types for dynamic table form schemas

Package info

gitlab.com/a.adach/dynamic-tables-form-contract

Issues

pkg:composer/adachsoft/dynamic-tables-form-contract

Statistics

Installs: 22

Dependents: 1

Suggesters: 0

Stars: 0

v0.1.1 2026-11-26 13:18 UTC

This package is auto-updated.

Last update: 2026-11-26 12:18:46 UTC


README

Framework-agnostic public contract for the dynamic-tables form-schema system.

This package defines the stable API surface used by all other form-related packages: interfaces, readonly DTOs, value objects, enums, typed collections, and exception interfaces. It contains no business implementation.

Namespace: AdachSoft\DynamicTablesFormContract

Requirements

Installation

When used from the monorepo root (recommended during development):

composer install

The root composer.json maps:

AdachSoft\DynamicTablesFormContract\       → packages/dynamic-tables-form-contract/src/
AdachSoft\DynamicTablesFormContract\Tests\ → packages/dynamic-tables-form-contract/tests/

As a standalone library (when published):

composer require adachsoft/dynamic-tables-form-contract

Package structure

src/
├── Collection/     Typed immutable collections (adachsoft/collection)
├── Dto/            Input and response DTOs (readonly)
├── Enum/           WidgetEnum and related enums
├── Exception/      Exception marker interfaces (+ package-local concrete where needed)
├── Facade/         Public entry-point interfaces
├── Repository/     Persistence contracts
├── Service/        Domain service contracts
└── Vo/             Value objects (FormNameVo, LabelTemplateVo)

Main facades

InterfaceResponsibility
Facade\DynamicFormFacadeInterfaceForm definition CRUD and schema generation
Facade\LookupFacadeInterfaceLookup endpoint for relation fields
Facade\DisplayConfigFacadeInterfaceTable display config (label template + searchable fields)

DynamicFormFacadeInterface

  • getAllDefinitions() / getDefinition(string $formName)
  • createDefinition(CreateFormDefinitionDto) / updateDefinition(...) / deleteDefinition(...)
  • getSchemaForTable(string $tableId)
  • getSchemaForView(string $viewName)
  • getSchemaForForm(string $formName)

LookupFacadeInterface

  • lookup(string $tableId, LookupQueryDto $query): LookupResponseDto

DisplayConfigFacadeInterface

  • find / get / save / delete for per-table display configuration

Usage

Depend on the facade interfaces in your application layer and provide their implementations in the package or application that owns the behavior. This library contains contracts and data types only; it does not register services or provide persistence. See the usage examples for value-object validation and facade integration.

Integration

Depend on the facade interfaces in your application layer and provide their implementations in the package or application that owns the behavior. This library contains contracts and data types only; it does not register services or provide persistence.

use AdachSoft\DynamicTablesFormContract\Dto\FormSchemaResponseDto;
use AdachSoft\DynamicTablesFormContract\Facade\DynamicFormFacadeInterface;
use AdachSoft\DynamicTablesFormContract\Vo\FormNameVo;

function loadFormSchema(DynamicFormFacadeInterface $forms, string $formName): FormSchemaResponseDto
{
    return $forms->getSchemaForForm((new FormNameVo($formName))->value);
}

See the usage examples for value-object validation and facade integration.

Value objects

FormNameVo

Form definition name in snake_case.

  • Pattern: ^[a-z][a-z0-9_]*$
  • Throws \InvalidArgumentException on empty or invalid input

LabelTemplateVo

Label template with {placeholder} syntax (e.g. {name} ({city})).

  • Validates non-empty value and balanced {...} placeholders
  • Throws InvalidLabelTemplateExceptionInterface on invalid input
  • placeholders(): string[] returns unique placeholder names in order of first occurrence

Collections

All collections extend AdachSoft\Collection\AbstractImmutableCollection and reject invalid item types.

CollectionItem typeExtra API
FieldSchemaCollectionFieldSchemaResponseDtofindByName(string): ?FieldSchemaResponseDto
FieldOverrideCollectionFieldOverrideDtofindByFieldName(string): ?FieldOverrideDto
SectionCollectionSectionDto—
LookupItemCollectionLookupItemDto—
SearchableFieldCollectionstring—

Widgets

Enum\WidgetEnum (string-backed):

text, textarea, number, checkbox, checkbox-group, radio, select, autocomplete, date, datetime, json, money

Exception interfaces

Form-related:

  • FormExceptionInterface
  • FormDefinitionNotFoundExceptionInterface
  • DuplicateFormDefinitionExceptionInterface
  • InvalidFormDefinitionExceptionInterface
  • FormSchemaUnavailableForUnionViewExceptionInterface
  • TableNotConfiguredForLookupExceptionInterface
  • InvalidLabelTemplateExceptionInterface

Display-config-related:

  • DisplayConfigExceptionInterface
  • DisplayConfigNotFoundExceptionInterface
  • InvalidDisplayConfigExceptionInterface

Concrete exception classes that implement these interfaces live in implementation packages (e.g. form-core), except for package-local helpers required by VO construction.

Design rules

  1. Contract only — no application or infrastructure logic in this package.
  2. DTOs are readonly — plain data carriers for input/output boundaries.
  3. Single enforcement point — VO validation happens in constructors; collections enforce item types via isValidItem().
  4. Framework-agnostic — no Symfony/Laravel/Doctrine types in the public API.

Development

Run package tests from the monorepo root:

./vendor/bin/phpunit packages/dynamic-tables-form-contract/tests

Static analysis / style (from monorepo root, paths limited to this package):

./vendor/bin/phpstan analyse packages/dynamic-tables-form-contract/src packages/dynamic-tables-form-contract/tests
./vendor/bin/rector process packages/dynamic-tables-form-contract/src packages/dynamic-tables-form-contract/tests
./vendor/bin/php-cs-fixer fix packages/dynamic-tables-form-contract/src packages/dynamic-tables-form-contract/tests

License

MIT

Author

Arkadiusz Adach