refactor(core): reorganize API and utils files into a core folder#159
Merged
refactor(core): reorganize API and utils files into a core folder#159
Conversation
Coverage Report
File Coverage
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
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/utilswith updated imports - Enhanced
parseOpenApi3Documentationto 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 {
9898ca2 to
94f16f5
Compare
Signed-off-by: J3m5 <5523410+J3m5@users.noreply.github.com>
…port Signed-off-by: J3m5 <5523410+J3m5@users.noreply.github.com>
Signed-off-by: J3m5 <5523410+J3m5@users.noreply.github.com>
Signed-off-by: J3m5 <5523410+J3m5@users.noreply.github.com>
…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 <5523410+J3m5@users.noreply.github.com>
- 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 <5523410+J3m5@users.noreply.github.com>
…lready present Signed-off-by: J3m5 <5523410+J3m5@users.noreply.github.com>
- 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 <5523410+J3m5@users.noreply.github.com>
- 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 <5523410+J3m5@users.noreply.github.com>
- Added concurrency settings - Implemented matrix strategy for OS and Node versions Signed-off-by: J3m5 <5523410+J3m5@users.noreply.github.com>
- Updated packageManager to include version with hash. - Changed node engine requirement from >=18 to >=20 as v18 is EOL. - Added devEngines section for packageManager and runtime. Signed-off-by: J3m5 <5523410+J3m5@users.noreply.github.com>
- Updated test files to use native Response instead of HttpResponse. - Update msw http imports to use "msw/core/http" Signed-off-by: J3m5 <5523410+J3m5@users.noreply.github.com>
Signed-off-by: J3m5 <5523410+J3m5@users.noreply.github.com>
714120b to
72398f9
Compare
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.
♻️ Created a core folder to better organize API files and utility functions.
✨ Extracted
buildEnumObjectfunction for creating objects from enum values.✨ Moved
getTypefunction into core with enhanced documentation.🐛 Fixed issue in
parseOpenApi3Documentationto prevent duplicate headers.✨ Extracted
assignResourceRelationshipsfunction.📝 Updated import paths to use a centralized index file for utilities.
🔧 Updated dependencies and npm scripts
🛠️ Updated CI configuration to support matrix builds