-
Notifications
You must be signed in to change notification settings - Fork 6
feat(ENG-823): setup and config field validation #183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
chandrajeet-singh
wants to merge
4
commits into
StackOneHQ:main
Choose a base branch
from
chandrajeet-singh:feat(eng-821)/setup-and-config-field-validation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f8ac050
feat(eng-823): Setup and config field validation
af7d29b
Merge branch 'main' of github.com:StackOneHQ/hub into feat(eng-821)/s…
56aa5c4
fix(eng-823): fix change requests
0b701b3
fix(eng-823): tighten url format pattern (reject degenerate hosts)
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| /** | ||
| * Asserts the local FORMAT_PATTERNS copy against the canonical format accept/reject | ||
| * vectors — copied from `@stackone/core` `FORMAT_PATTERN_TEST_VECTORS` (connect repo, | ||
| * `packages/core/src/connector/specs/formatPatterns.vectors.ts`). | ||
| * | ||
| * The canonical registry and this local copy must pass exactly these vectors, so | ||
| * `stackone validate` and this hub can never disagree about what a format accepts. | ||
| * Keep both the registry copy (utils/zodSchema.ts) and these vectors in sync when a | ||
| * format changes. Run via `npm test`. | ||
| */ | ||
| import { FORMAT_PATTERNS } from '../src/modules/integration-picker/utils/zodSchema'; | ||
|
|
||
| const FORMAT_PATTERN_TEST_VECTORS: Record<string, { accepts: string[]; rejects: string[] }> = { | ||
| email: { | ||
| accepts: ['john@example.com', 'a.b+tag@sub.domain.co'], | ||
| rejects: ['not-an-email', 'a b@example.com', '@example.com', 'john@'], | ||
| }, | ||
| url: { | ||
| accepts: [ | ||
| 'https://api.example.com', | ||
| 'http://x.io/path?q=1', | ||
| 'http://localhost:3000', | ||
| 'https://1.2.3.4/p?q=1', | ||
| 'https://x.io/a?b=c#d', | ||
| ], | ||
| rejects: [ | ||
| 'example.com', | ||
| 'ftp://host', | ||
| '', | ||
| 'https://api.example.com extra text', | ||
| 'https://foo bar/baz', | ||
| 'https://', | ||
| 'https://?q=1', | ||
| 'https:///path', | ||
| 'https://#frag', | ||
| 'https://a b', | ||
| ], | ||
| }, | ||
| uri: { | ||
| accepts: ['https://api.example.com', 'mailto:x@y.z', 'urn:isbn:0451450523'], | ||
| rejects: ['no-scheme-here', '://missing', ''], | ||
| }, | ||
| uuid: { | ||
| accepts: ['123e4567-e89b-12d3-a456-426614174000', '123E4567-E89B-12D3-A456-426614174000'], | ||
| rejects: ['123e4567', 'zzze4567-e89b-12d3-a456-426614174000', ''], | ||
| }, | ||
| date: { | ||
| accepts: ['2026-07-06', '1999-12-31'], | ||
| rejects: ['06-07-2026', '2026/07/06', '2026-7-6', ''], | ||
| }, | ||
| datetime: { | ||
| accepts: [ | ||
| '2026-07-06T10:30:00', | ||
| '2026-07-06T10:30:00Z', | ||
| '2026-07-06T10:30:00+01:00', | ||
| '2026-07-06T10:30:00.123Z', | ||
| '2026-07-06T10:30:00z', | ||
| '2026-07-06T10:30:00+0100', | ||
| '2026-07-06T10:30:00+01', | ||
| ], | ||
| rejects: [ | ||
| '2026-07-06', | ||
| '10:30:00', | ||
| '', | ||
| '2026-07-06T10:30:00banana', | ||
| '2026-07-06T10:30:00Zzz', | ||
| ], | ||
| }, | ||
| }; | ||
|
|
||
| let failures = 0; | ||
|
|
||
| for (const [format, vectors] of Object.entries(FORMAT_PATTERN_TEST_VECTORS)) { | ||
| const pattern = FORMAT_PATTERNS[format as keyof typeof FORMAT_PATTERNS]; | ||
| if (!pattern) { | ||
| failures++; | ||
| console.error(`FAIL: registry is missing format "${format}"`); | ||
| continue; | ||
| } | ||
| for (const value of vectors.accepts) { | ||
| if (!pattern.test(value)) { | ||
| failures++; | ||
| console.error(`FAIL: ${format} should accept "${value}"`); | ||
| } | ||
| } | ||
| for (const value of vectors.rejects) { | ||
| if (pattern.test(value)) { | ||
| failures++; | ||
| console.error(`FAIL: ${format} should reject "${value}"`); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Reverse coverage: a format added to the registry (mirroring a new core format) with no | ||
| // vectors here would otherwise pass silently — the exact drift D3 exists to catch (a field | ||
| // with an unrecognised format renders unvalidated). Fail if any registry key lacks vectors. | ||
| for (const format of Object.keys(FORMAT_PATTERNS)) { | ||
| if (!FORMAT_PATTERN_TEST_VECTORS[format]) { | ||
| failures++; | ||
| console.error(`FAIL: no vectors for registry format "${format}"`); | ||
| } | ||
| } | ||
|
|
||
| if (failures > 0) { | ||
| console.error(`${failures} format vector failure(s)`); | ||
| process.exit(1); | ||
| } | ||
|
|
||
| console.log('All format vectors pass'); |
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.