Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions IMPROVEMENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,29 @@ This document outlines the improvements made to the @cap-js/openapi repository t
- Added Jest configuration for TypeScript
- Implemented build scripts with watch mode

### 3. Modularization (In Progress) 🚧
### 3. Modularization
- Created module structure:
```
lib/compile/modules/
├── constants/ # Extracted constants and configuration
├── constants/ # Extracted constants and configuration
├── utils/ # Utility functions
│ ├── naming.js # Name processing utilities
│ ├── errors.js # Error handling utilities
│ └── logger.js # Logging utilities
├── validators/ # Validation functions
├── converters/ # Type conversion functions
│ ├── naming.js # Name processing utilities
│ ├── errors.js # Error handling utilities
│ └── logger.js # Logging utilities
├── validators/ # Validation functions
├── converters/ # Type conversion functions (planned)
└── builders/ # OpenAPI builders
├── paths.js # Path building functions ✅
├── parameters.js # Parameter building functions ✅
├── responses.js # Response building functions ✅
└── schemas.js # Schema building functions (in progress)
```
- Successfully extracted and modularized:
- Path building functions (navigationPaths, pathValuePrefix/Suffix, etc.)
- Parameter building functions (query options, component parameters)
- Response building functions (collection/entity/operation responses)
- Removed duplicate function definitions from main file
- All tests passing after refactoring

### 4. Error Handling Improvements ✅
- Created custom error classes:
Expand Down
2 changes: 1 addition & 1 deletion dist/lib/compile/csdl2openapi.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 10 additions & 65 deletions dist/lib/compile/csdl2openapi.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/lib/compile/csdl2openapi.js.map

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions dist/lib/compile/modules/builders/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
declare const _exports: {
collectionResponse: typeof responses.collectionResponse;
entityResponse: typeof responses.entityResponse;
operationResponse: typeof responses.operationResponse;
errorResponse: typeof responses.errorResponse;
countResponse: typeof responses.countResponse;
batchResponse: typeof responses.batchResponse;
buildStandardResponses: typeof responses.buildStandardResponses;
getTypeSchema: typeof responses.getTypeSchema;
getEdmTypeSchema: typeof responses.getEdmTypeSchema;
withETag: typeof responses.withETag;
addQueryOptions: typeof parameters.addQueryOptions;
optionTop: typeof parameters.optionTop;
optionSkip: typeof parameters.optionSkip;
optionCount: typeof parameters.optionCount;
optionFilter: typeof parameters.optionFilter;
optionOrderBy: typeof parameters.optionOrderBy;
optionSearch: typeof parameters.optionSearch;
optionSelect: typeof parameters.optionSelect;
optionExpand: typeof parameters.optionExpand;
buildComponentParameters: typeof parameters.buildComponentParameters;
pathValuePrefix: typeof paths.pathValuePrefix;
pathValueSuffix: typeof paths.pathValueSuffix;
navigationPropertyPath: typeof paths.navigationPropertyPath;
propertyPath: typeof paths.propertyPath;
navigationPaths: typeof paths.navigationPaths;
navigationPathMap: typeof paths.navigationPathMap;
primitivePaths: typeof paths.primitivePaths;
entryToProperty: typeof paths.entryToProperty;
buildKeyParameters: typeof paths.buildKeyParameters;
buildPathWithKeys: typeof paths.buildPathWithKeys;
};
export = _exports;
import responses = require("./responses");
import parameters = require("./parameters");
import paths = require("./paths");
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions dist/lib/compile/modules/builders/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions dist/lib/compile/modules/builders/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions dist/lib/compile/modules/builders/index.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

96 changes: 96 additions & 0 deletions dist/lib/compile/modules/builders/parameters.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**
* Add standard OData query parameters to a path
* @param {Array} parameters - Array of parameters to augment
* @param {object} element - Model element
* @param {object} modelElement - Function to get model element
* @param {object} propertiesOfStructuredType - Function to get properties
* @param {object} root - Root entity set
* @param {string} navigationPath - Navigation path for restrictions
* @param {object} target - Target container child
* @param {object} restrictions - Navigation restrictions
* @param {object} options - Options including queryOptionPrefix
*/
export function addQueryOptions(parameters: any[], element: object, modelElement: object, propertiesOfStructuredType: object, root: object, navigationPath: string, target: object, restrictions: object, options?: object): void;
/**
* Add parameter for query option $top
* @param {Array} parameters - Array of parameters to augment
* @param {object} restrictions - Navigation property restrictions
* @param {string} queryOptionPrefix - Query option prefix
*/
export function optionTop(parameters: any[], restrictions: object, queryOptionPrefix?: string): void;
/**
* Add parameter for query option $skip
* @param {Array} parameters - Array of parameters to augment
* @param {object} restrictions - Navigation property restrictions
* @param {string} queryOptionPrefix - Query option prefix
*/
export function optionSkip(parameters: any[], restrictions: object, queryOptionPrefix?: string): void;
/**
* Add parameter for query option $count
* @param {Array} parameters - Array of parameters to augment
* @param {object} restrictions - Navigation property restrictions
* @param {string} target - Target container child
* @param {string} queryOptionPrefix - Query option prefix
*/
export function optionCount(parameters: any[], restrictions: object, target: string, queryOptionPrefix?: string): void;
/**
* Add parameter for query option $filter
* @param {Array} parameters - Array of parameters to augment
* @param {object} element - Model element
* @param {Function} modelElement - Function to get model element
* @param {Function} propertiesOfStructuredType - Function to get properties
* @param {string} target - Target container child
* @param {object} restrictions - Navigation property restrictions
* @param {string} queryOptionPrefix - Query option prefix
*/
export function optionFilter(parameters: any[], element: object, modelElement: Function, propertiesOfStructuredType: Function, target: string, restrictions: object, queryOptionPrefix?: string): void;
/**
* Add parameter for query option $orderby
* @param {Array} parameters - Array of parameters to augment
* @param {object} element - Model element of navigation segment
* @param {Function} modelElement - Function to get model element
* @param {Function} propertiesOfStructuredType - Function to get properties
* @param {string} target - Target container child of path
* @param {object} restrictions - Navigation property restrictions of navigation segment
* @param {string} queryOptionPrefix - Query option prefix
*/
export function optionOrderBy(parameters: any[], element: object, modelElement: Function, propertiesOfStructuredType: Function, target: string, restrictions: object, queryOptionPrefix?: string): void;
/**
* Add parameter for query option $search
* @param {Array} parameters - Array of parameters to augment
* @param {string} target - Target container child of path
* @param {object} restrictions - Navigation property restrictions of navigation segment
* @param {string} queryOptionPrefix - Query option prefix
*/
export function optionSearch(parameters: any[], target: string, restrictions: object, queryOptionPrefix?: string): void;
/**
* Add parameter for query option $select
* @param {Array} parameters - Array of parameters to augment
* @param {object} element - Model element
* @param {Function} modelElement - Function to get model element
* @param {Function} propertiesOfStructuredType - Function to get properties
* @param {object} restrictions - Navigation property restrictions
* @param {object} nonExpandable - Non-expandable properties
* @param {string} queryOptionPrefix - Query option prefix
*/
export function optionSelect(parameters: any[], element: object, modelElement: Function, propertiesOfStructuredType: Function, restrictions: object, nonExpandable: object, queryOptionPrefix?: string): void;
/**
* Add parameter for query option $expand
* @param {Array} parameters - Array of parameters to augment
* @param {object} element - Model element
* @param {Function} modelElement - Function to get model element
* @param {Function} navigationPaths - Function to get navigation paths
* @param {object} restrictions - Navigation property restrictions
* @param {object} nonExpandable - Non-expandable properties
* @param {number} level - Navigation level
* @param {number} maxLevels - Maximum levels
* @param {string} queryOptionPrefix - Query option prefix
*/
export function optionExpand(parameters: any[], element: object, modelElement: Function, navigationPaths: Function, restrictions: object, nonExpandable: object, level: number, maxLevels: number, queryOptionPrefix?: string): void;
/**
* Build standard OData component parameters
* @param {object} options - Options including queryOptionPrefix
* @return {object} Component parameters object
*/
export function buildComponentParameters(options?: object): object;
//# sourceMappingURL=parameters.d.ts.map
1 change: 1 addition & 0 deletions dist/lib/compile/modules/builders/parameters.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading