feat: add typed Enum DTO to Action::param()#64
Conversation
Greptile SummaryThis PR introduces a typed
Confidence Score: 5/5Safe to merge — the change is a backward-compatible addition of an optional parameter with no effect on existing call sites or runtime validation logic. The Enum DTO is a pure data carrier with no side effects; Action::param() remains fully backward-compatible; the Platform forwarding paths are consistent across all three init methods; and the updated dependency versions are stable patch or RC releases. The only gap found is in test coverage, which does not affect production behavior. No files require special attention beyond the minor test coverage gap in tests/e2e/HTTPServicesTest.php. Important Files Changed
Reviews (8): Last reviewed commit: "Update Utopia server dependencies" | 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
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