ComponentContract
Machine-readable runtime contract for a live component. This is intentionally separate from @milpa/design visual contracts. A runtime component may reference a visual contract, but it does not own design tokens.
ComponentContract::__construct()
public function __construct(string $name, string $contractVersion, string $summary = '', ?string $designContract = null, ?string $defaultTemplate = null, array $propsSchema = [], array $stateSchema = [], array $actions = [], array $dataSources = [], ?Milpa\Live\ValueObjects\ComponentPresentation $presentation = null):Parameters
| Name | Type | Description |
|---|---|---|
| $name | string | |
| $contractVersion | string | |
| $summary | string | |
| $designContract | ?string | |
| $defaultTemplate | ?string | |
| $propsSchema | array<string, mixed> | |
| $stateSchema | array<string, mixed> | |
| $actions | array<string, mixed> | |
| $dataSources | array<string, mixed> | |
| $presentation | ?Milpa\Live\ValueObjects\ComponentPresentation |
ComponentContract::presentation()
public function presentation(): Milpa\Live\ValueObjects\ComponentPresentationWhat this component needs on the page besides its markup, or an empty declaration. Never null, so a consumer asks one question and gets one answer instead of branching on whether the component bothered to declare — the same reason {@see action()} normalises its two shapes here rather than in every caller.
ComponentContract::action()
public function action(string $name): ?Milpa\Live\ValueObjects\ActionContractOne action, as a declaration, whichever form the component wrote. `$actions` carries two shapes on purpose and forever: the bare payload array every component has written since this contract existed, and an {@see ActionContract} for one that declares what it is FOR. Reading them here — rather than letting each consumer branch — is what makes the richer form additive: the authorizer, the catalogue and any renderer ask one question and get one answer, and a component that never migrates keeps working unchanged. A bare array becomes an ActionContract with nothing declared: `summary` empty, `mutating` false, `effects` null. That is not a claim that the action is harmless — it is the honest record that nobody said, which is what {@see ActionContract::declaresEffects()} exists to ask about.
Parameters
| Name | Type | Description |
|---|---|---|
| $name | string |