feat(coerce): add domain coercers and route 12factor-env's validators through them - #1721
Merged
Merged
Conversation
… through them Strip hand-written footers from package READMEs; makage appends FOOTER.md.
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@constructive-io/coerceonly had the primitive shapes, so the named shapes still lived as envalid validators — meaningport,url,host,emailcould vetprocess.envbut not a request body, anduuidexisted nowhere (a regex in@pgpmjs/server-utils). This adds them as runtime coercers and makes 12factor-env's validators thin envalid wrappers over them, so a variable and a request body agree on what each shape accepts:list/num/int/duration/enumeratedkeep their own bounds,choicesand error text — the parsing underneath is nowasStringList/asNumeric/asNumberIn/asDuration/asOneOf, and the duplicatedDURATION_UNITS_MStable and theNumber(input)/String(input).split()bodies are gone.port/url/host/emailare no longer re-exported from envalid; they resolve to the house versions, anduuidis new. Env semantics are unchanged (unset resolves the default, set-but-invalid throws into the consolidated report), with 5 new tests pinning the shapes and their rejections.New coercers, each with a
require*twin:asNumeric,asNumericIntegerasNumberasNumberIn,asIntegerIn{ min, max }; out-of-range is a miss, not a clampasPort1..65535asBigIntbigint/ integer / digit string — a 64-bit id crossing JSONasUrl'example.com'(a path) is not a URLasHostname'localhost:5432'in aPGHOSTis how a port reaches a DNS lookupasEmail,asUuidasDuration'500ms'/'30s'/'5m'/'2h'/'1d'/'1w'→ ms; unit-less is msasJsonThe line the package draws:
asNumber/asIntegerstay strict ('5'is not a number) so a JSON body cannot smuggle a string past a declared number; the coercers that do read text say so in their names, because an env var carries nothing else.READMEs
Package READMEs were hand-rolling their own footer —
## License / MIT, or codegen's---\nBuilt by the Constructive team.\n## Disclaimer …— while makage already appends the rootFOOTER.mdat build time (copy.js:${readme}\n\n---\n\n${footer}). 101 READMEs lose that duplicated tail; the generator that emitted it is fixed at the source (getReadmeFooter()deleted fromgraphql/codegen, snapshots updated) rather than patched in its output.agentic/*'s## Creditsstay — those attribute the upstream pi agent, not us. The rootREADME.mdis untouched: nothing appends the footer to it.Link to Devin session: https://app.devin.ai/sessions/4283bbf118594207ad8b1ef1ce856ce8
Requested by: @pyramation