-
-
Notifications
You must be signed in to change notification settings - Fork 75
refactor(core): reorganize API and utils files into a core folder #159
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: main
Are you sure you want to change the base?
Conversation
Coverage Report
File Coverage
|
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.
Pull Request Overview
This PR reorganizes shared API and utility code under a new core
directory, extracts and centralizes helper functions, and improves request header handling.
- Consolidated core classes and types in
src/core
- Extracted utilities (
buildEnumObject
,getType
,assignResourceRelationships
) intosrc/core/utils
with updated imports - Enhanced
parseOpenApi3Documentation
to only append the Accept header once
Reviewed Changes
Copilot reviewed 26 out of 29 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/swagger/parseSwaggerDocumentation.ts | Updated imports of Api and removeTrailingSlash to point at core |
src/swagger/handleJson.ts | Swapped manual enum creation for buildEnumObject , moved imports to core utils |
src/openapi3/parseOpenApi3Documentation.ts | Refactored header setup to avoid duplicate Accept entries, centralized imports |
src/openapi3/handleJson.ts | Introduced assignResourceRelationships , optimized operation destructuring |
src/openapi3/handleJson.test.ts | Updated parsedJsonReplacer import to core utils |
src/openapi3/getType.ts | Removed local getType (moved to core utils) |
src/index.ts | Replaced individual exports with consolidated core export |
src/hydra/parseHydraDocumentation.ts | Removed duplicate removeTrailingSlash , migrated imports to core |
src/hydra/parseHydraDocumentation.test.ts | Updated parsedJsonReplacer import to core utils |
src/hydra/getType.ts | Updated FieldType import to core index |
src/hydra/getParameters.ts | Migrated Resource , Parameter , RequestInitExtended imports to core |
src/hydra/fetchResource.ts | Updated RequestInitExtended import to core types |
src/hydra/fetchJsonLd.ts | Updated RequestInitExtended import to core types |
src/graphql/parseGraphQl.ts | Pointed Api , Field , Resource imports at core index |
src/core/utils/removeTrailingSlash.ts | Added new removeTrailingSlash utility |
src/core/utils/parsedJsonReplacer.ts | Converted to named export |
src/core/utils/index.ts | Exposed all core utilities via single index |
src/core/utils/getType.ts | Introduced shared getType helper |
src/core/utils/getResources.test.ts | Updated test import for getResourcePaths |
src/core/utils/getResourcePaths.ts | Renamed and exported path utility |
src/core/utils/buildEnumObject.ts | Introduced new buildEnumObject helper |
src/core/index.ts | Aggregated core exports |
src/core/{Resource,Operation,Field,Api}.ts | Updated assignSealed imports to use utils index |
Comments suppressed due to low confidence (3)
src/core/utils/buildEnumObject.ts:11
- Add unit tests for buildEnumObject to verify correct mapping of enum values and that it returns null for empty or undefined inputs.
export function buildEnumObject(
src/openapi3/handleJson.ts:26
- Add tests for assignResourceRelationships to ensure fields are correctly classified as embedded or referenced based on type and naming patterns.
function assignResourceRelationships(resources: Resource[]) {
src/core/utils/getType.ts:14
- Introduce unit tests for getType to cover format mappings (e.g., int32→integer) and default fallback behavior.
export function getType(openApiType: string, format?: string): FieldType {
Signed-off-by: J3m5 <[email protected]>
…port Signed-off-by: J3m5 <[email protected]>
Signed-off-by: J3m5 <[email protected]>
Signed-off-by: J3m5 <[email protected]>
…update paths - Moved utility imports to a centralized index file in the utils directory. - Updated import paths across various modules to use the new index file. - Removed redundant utility functions and adjusted related code accordingly. Signed-off-by: J3m5 <[email protected]>
- Implement buildEnumObject to create an object from enum values. - Update openapi and swagger handleJson to use buildEnumObject. - Refactor inflection imports to use named imports instead of default import - Small refactors - Add TSDoc for the getTYpe util function Signed-off-by: J3m5 <[email protected]>
…lready present Signed-off-by: J3m5 <[email protected]>
- Extracted assignResourceRelationships function to assign embedded and reference properties to resource fields. - Refactored handleJson to utilize the new relationship assignment function. Signed-off-by: J3m5 <[email protected]>
- Updated @types/node from 22.15.34 to 22.16.3 - Updated msw from 2.10.2 to 2.10.4 - Updated oxlint from 1.4.0 to 1.6.0 - Adjusted test script to use 'vitest run' and added 'test:watch' Signed-off-by: J3m5 <[email protected]>
- Added concurrency settings - Implemented matrix strategy for OS and Node versions Signed-off-by: J3m5 <[email protected]>
♻️ Created a core folder to better organize API files and utility functions.
✨ Extracted
buildEnumObject
function for creating objects from enum values.✨ Moved
getType
function into core with enhanced documentation.🐛 Fixed issue in
parseOpenApi3Documentation
to prevent duplicate headers.✨ Extracted
assignResourceRelationships
function.📝 Updated import paths to use a centralized index file for utilities.
🔧 Updated dependencies and npm scripts
🛠️ Updated CI configuration to support matrix builds