feat: add typed Enum DTO to Action::param()#64
Conversation
Greptile SummaryThis PR introduces a typed
Confidence Score: 4/5The logic changes are sound, but the PR cannot safely land on main while utopia-php/servers is pinned to an unmerged feature branch. The Enum DTO, Action changes, and Platform forwarding are all clean and backward-compatible. The blocking concern is that utopia-php/servers is pointing at a dev branch commit rather than a released version — the feature works today but the branch could drift or be deleted, and the dev stability flag it introduces could affect downstream consumers. composer.json — the dev-branch servers dependency must be replaced with a stable release version before merging. Important Files Changed
Reviews (6): Last reviewed commit: "chore: pin utopia-php/servers to feat-pa..." | Re-trigger Greptile |
c2e140e to
77e2792
Compare
77e2792 to
2e3d957
Compare
Pulls in utopia-php/servers#11 which adds the enum field on Hook params, so initHttp can forward the Enum DTO through to Route params.
2e3d957 to
c490c9a
Compare
| "utopia-php/http": "^2.0@RC", | ||
| "utopia-php/queue": "0.18.*", | ||
| "utopia-php/servers": "0.4.*" | ||
| "utopia-php/servers": "dev-feat-param-enum-metadata as 0.4.0" |
There was a problem hiding this comment.
Dev-branch dependency should not be merged to main
utopia-php/servers is pinned to dev-feat-param-enum-metadata as 0.4.0, an unmerged feature branch. While the composer.lock pins to a specific commit today (333e93c5), the stability-flags entry forces minimum-stability: dev for this package. If this PR is merged before the utopia-php/servers feature branch is itself merged and a stable version tagged, any downstream consumer that runs composer update could pull unexpected dev-channel releases, and the branch ref could disappear or be force-pushed. This PR should wait for the servers PR to land and a stable release be cut, then update composer.json back to a stable version constraint (e.g. "utopia-php/servers": "0.5.*").
What does this PR do?
Adds an optional typed
EnumDTO parameter toUtopia\Platform\Action::param()for attaching SDK enum metadata to whitelist-backed parameters.Instead of a generic
metabag (which risks becoming a junk drawer for unrelated data), the parameter accepts a scopedUtopia\Platform\Enumvalue:Enumcontains:$name— generated enum name$map— mapping of whitelist values to case names (array<string, string>)$exclude— whitelist values to omit from generated enumsUtopia stores and forwards the DTO but does not interpret it. Enforcement (e.g. "whitelist must have enum") is left to consumer generators.
Why not a generic
metaarray?A generic
metaarray would couple Utopia to consumer-specific concepts and invite abuse as a catch-all dump for unrelated data. A typed, scoped DTO keeps the API clean and forces intentional design for future metadata needs.Test Plan
param()remain valid (backward-compatible).enumdefaults tonullwhen not provided.enumis stored in both$this->params[$key]and$this->options['param:'.$key].enumis intentionally not forwarded to Route/CLI/Worker hooks.enumpresence on Action params and absence on Route params.Related PRs and Issues
N/A — small framework-level API expansion.
Checklist