-
Notifications
You must be signed in to change notification settings - Fork 657
Enforce absolute or root paths for extension src props #4882
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
base: next
Are you sure you want to change the base?
Conversation
Co-authored-by: adrians5j <[email protected]>
Co-authored-by: adrians5j <[email protected]>
Co-authored-by: adrians5j <[email protected]>
Co-authored-by: adrians5j <[email protected]>
adrians5j
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| export * from "./defineApiExtension.js"; | ||
| export * from "./models/index.js"; | ||
| export * from "./zodTypes/zodPathToAbstraction.js"; | ||
| export * from "./zodTypes/zodPathToFile.js"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see you've added new zodAbsoluteOrRootPath.
My idea was to basically adjust existing zodPathToFile. We don't need two of these.
Finally, let's do another refactor.
Instead of having zodPathToAbstraction and zodPathToFile, let's just have single src type, which optionally takes abstraction param. If provided, then we do the exported abstraction validation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! I've refactored the code to use a single zodSrcPath function that takes an optional abstraction parameter. The function now:
- Replaces all three validators (
zodPathToFile,zodPathToAbstraction,zodAbsoluteOrRootPath) - Handles both cases: with and without abstraction validation
- Enforces absolute or root-relative paths in all cases
Updated in commit 8a4574c.
Co-authored-by: adrians5j <[email protected]>
Co-authored-by: adrians5j <[email protected]>
Implementation Plan
defineApiExtension.tsto use the new validatorAdminExtension.tsto use the new validatorProjectDecorator.tsto use the new validatorProjectImplementation.tsto use the new validatorextensions/graphql/MySchemaExtension.tsxto use the correct path formatextensions/_wip/idp/MyIdpExtension.tsxto use the correct path formatChanges Made
Created unified
zodSrcPath.tsvalidator that:zodPathToFile,zodPathToAbstraction, andzodAbsoluteOrRootPathabstractionparameter - when provided, validates the exported implementationpath.isAbsolute())/(from project root)./file.ts,../folder/file.tsfolder/file.ts/before joining with rootFolderUpdated all extension definitions to use the new unified validator (34 files total):
defineApiExtension.ts- simplified to single zodSrcPath callAdminExtension.ts- uses zodSrcPathProjectDecorator.ts- uses zodSrcPathProjectImplementation.ts- uses zodSrcPathRemoved old validator files:
zodPathToFile.tszodPathToAbstraction.tszodAbsoluteOrRootPath.tsUpdated example files to use paths from project root:
extensions/graphql/MySchemaExtension.tsx- changed to/extensions/graphql/MyGraphQLSchema.tsextensions/_wip/idp/MyIdpExtension.tsx- changed to/extensions/_wip/idp/MyIdp.tsThis refactoring provides a cleaner, more maintainable API with all path validation logic consolidated in a single function.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.