@cap-js-community/odata-v2-adapter
Advanced tools
Comparing version 1.12.10 to 1.12.11
@@ -16,7 +16,4 @@ "use strict"; | ||
if (cds.env.cov2ap.build && cds.build && cds.build.register) { | ||
cds.build.register("cov2ap", { | ||
impl: "@cap-js-community/odata-v2-adapter/src/build.js", | ||
taskDefaults: { src: "srv" }, | ||
}); | ||
cds.build.register("cov2ap", require("./src/build")); | ||
} | ||
} |
@@ -8,2 +8,12 @@ # Changelog | ||
## Version 1.12.11 - 2024-06-24 | ||
### Fixed | ||
- Improve expand/select handling and support `*` notation | ||
- Expose CDS OData V2 Adapter singleton instance from CDS plugin at `cds.cov2ap` | ||
- Allow to register `before` express routes for CDS OData V2 Adapter router via `cds.cov2ap.before` | ||
- Option to cache and stream generated EDMX from disk instead of keeping it in memory | ||
- Use new `cds.build.register` API version | ||
## Version 1.12.10 - 2024-06-05 | ||
@@ -10,0 +20,0 @@ |
{ | ||
"name": "@cap-js-community/odata-v2-adapter", | ||
"version": "1.12.10", | ||
"version": "1.12.11", | ||
"description": "OData V2 adapter for CDS", | ||
@@ -65,17 +65,17 @@ "homepage": "https://cap.cloud.sap/", | ||
"@cap-js-community/odata-v2-adapter": "./", | ||
"@cap-js/hana": "^0.4.0", | ||
"@cap-js/sqlite": "^1.7.1", | ||
"@cap-js/hana": "^1.0.0", | ||
"@cap-js/sqlite": "^1.7.2", | ||
"@sap/cds": "^7.9.2", | ||
"@sap/cds-dk": "^7.9.2", | ||
"@sap/cds-dk": "^7.9.4", | ||
"@sap/cds-hana": "^2.0.0", | ||
"@types/express": "^4.17.21", | ||
"@types/jest": "29.5.12", | ||
"@typescript-eslint/eslint-plugin": "^7.12.0", | ||
"@typescript-eslint/parser": "^7.12.0", | ||
"@typescript-eslint/eslint-plugin": "^7.13.1", | ||
"@typescript-eslint/parser": "^7.13.1", | ||
"compression": "^1.7.4", | ||
"eslint": "^8.57.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-jest": "^28.5.0", | ||
"eslint-plugin-jest": "^28.6.0", | ||
"jest": "^29.7.0", | ||
"prettier": "^3.3.0", | ||
"prettier": "^3.3.2", | ||
"supertest": "^7.0.0" | ||
@@ -82,0 +82,0 @@ }, |
128
README.md
@@ -26,22 +26,22 @@ # @cap-js-community/odata-v2-adapter (cov2ap) | ||
- **plugin:** OData V2 adapter is instantiated as part of CDS plugin. Default is `true`. | ||
- **build:** In case of plugin scenario, a build step is registered to prepare the OData V2 metadata. Default is `true`. | ||
- **base:** Base path under which the service is reachable. Default is `''`. | ||
- **path:** Path under which the service is reachable. Default is `'odata/v2'`. Default path is `'v2'` for CDS <7 or `middlewares` deactivated. | ||
- **model:** CDS service model (path(s) or CSN). Default is `'all'`. | ||
- **port:** Target port which points to OData V4 backend port. Default is process.env.PORT or `4004`. | ||
- **target:** Target which points to OData V4 backend host:port. Use `'auto'` to infer the target from server url after listening. Default is e.g. `'http://localhost:4004'`. | ||
- **targetPath:** Target path to which is redirected. Default is `'odata/v4'`. Default path is `''` for CDS <7 or `middlewares` deactivated. | ||
- **services:** Service mapping object from url path name to service name. Default is `{}`. | ||
- **mtxRemote:** CDS model is retrieved remotely via MTX endpoint for multitenant scenario (classic MTX only). Default is `false`. | ||
- **mtxEndpoint:** Endpoint to retrieve MTX metadata when option 'mtxRemote' is active (classic MTX only). Default is `'/mtx/v1'`. | ||
- **ieee754Compatible:** Edm.Decimal and Edm.Int64 are serialized IEEE754 compatible. Default is `true`. | ||
- **fileUploadSizeLimit:** File upload file size limit (in bytes) for multipart/form-data requests. Default is `10485760` (10 MB). | ||
- **continueOnError:** Indicates to OData V4 backend to continue on error. Default is `false`. | ||
- **isoTime:** Use ISO 8601 format for type cds.Time (Edm.Time). Default is `false`. | ||
- **isoDate:** Use ISO 8601 format for type cds.Date (Edm.DateTime). Default is `false`. | ||
- **isoDateTime:** Use ISO 8601 format for type cds.DateTime (Edm.DateTimeOffset). Default is `false`. | ||
- **isoTimestamp:** Use ISO 8601 format for type cds.Timestamp (Edm.DateTimeOffset). Default is `false`. | ||
- **isoDateTimeOffset:** Use ISO 8601 format for type Edm.DateTimeOffset (cds.DateTime, cds.Timestamp). Default is `false`. | ||
- **bodyParserLimit:** Request and response body parser size limit. Default is `'100mb'`. | ||
- **plugin**: OData V2 adapter is instantiated as part of CDS plugin. Default is `true`. | ||
- **build**: In case of plugin scenario, a build step is registered to prepare the OData V2 metadata. Default is `true`. | ||
- **base**: Base path under which the service is reachable. Default is `''`. | ||
- **path**: Path under which the service is reachable. Default is `'odata/v2'`. Default path is `'v2'` for CDS <7 or `middlewares` deactivated. | ||
- **model**: CDS service model (path(s) or CSN). Default is `'all'`. | ||
- **port**: Target port which points to OData V4 backend port. Default is process.env.PORT or `4004`. | ||
- **target**: Target which points to OData V4 backend host:port. Use `'auto'` to infer the target from server url after listening. Default is e.g. `'http://localhost:4004'`. | ||
- **targetPath**: Target path to which is redirected. Default is `'odata/v4'`. Default path is `''` for CDS <7 or `middlewares` deactivated. | ||
- **services**: Service mapping object from url path name to service name. Default is `{}`. | ||
- **mtxRemote**: CDS model is retrieved remotely via MTX endpoint for multitenant scenario (classic MTX only). Default is `false`. | ||
- **mtxEndpoint**: Endpoint to retrieve MTX metadata when option 'mtxRemote' is active (classic MTX only). Default is `'/mtx/v1'`. | ||
- **ieee754Compatible**: Edm.Decimal and Edm.Int64 are serialized IEEE754 compatible. Default is `true`. | ||
- **fileUploadSizeLimit**: File upload file size limit (in bytes) for multipart/form-data requests. Default is `10485760` (10 MB). | ||
- **continueOnError**: Indicates to OData V4 backend to continue on error. Default is `false`. | ||
- **isoTime**: Use ISO 8601 format for type cds.Time (Edm.Time). Default is `false`. | ||
- **isoDate**: Use ISO 8601 format for type cds.Date (Edm.DateTime). Default is `false`. | ||
- **isoDateTime**: Use ISO 8601 format for type cds.DateTime (Edm.DateTimeOffset). Default is `false`. | ||
- **isoTimestamp**: Use ISO 8601 format for type cds.Timestamp (Edm.DateTimeOffset). Default is `false`. | ||
- **isoDateTimeOffset**: Use ISO 8601 format for type Edm.DateTimeOffset (cds.DateTime, cds.Timestamp). Default is `false`. | ||
- **bodyParserLimit**: Request and response body parser size limit. Default is `'100mb'`. | ||
- **returnCollectionNested**: Collection of entity type is returned nested into a results section. Default is `true`. | ||
@@ -54,3 +54,3 @@ - **returnComplexNested**: Function import return structure of complex type (non collection) is nested using function import name. Default is `true`. | ||
- **propagateMessageToDetails**: Propagates root error or message always to details section. Default is `false`. | ||
- **contentDisposition**: Default content disposition for media streams (inline, attachment), if not available or calculated. Default is `'attachment'`. | ||
- **contentDisposition**: Default content disposition for media streams, if not available or calculated. Options are `inline`, `attachment`. Default is `'attachment'`. | ||
- **calcContentDisposition**: Calculate content disposition for media streams even if already available. Default is `false`. | ||
@@ -61,4 +61,5 @@ - **quoteSearch**: Specifies if search expression is quoted automatically. Default is `true`. | ||
- **defaultFormat**: Specifies the default entity response format (json, atom). Default is `'json'`. | ||
- **processForwardedHeaders** Specifies if the `x-forwarded` headers are processed. Default is `true`. | ||
- **cacheDefinitions** Specifies if the definition elements are cached. Default is `true`. | ||
- **processForwardedHeaders**: Specifies if the `x-forwarded` headers are processed. Default is `true`. | ||
- **cacheDefinitions**: Specifies if the definition elements are cached. Default is `true`. | ||
- **cacheMetadata**: Specifies the caching and provisioning strategy of metadata (e.g. edmx) (memory, disk, stream). Default is `memory`. | ||
@@ -76,2 +77,55 @@ > All OData V2 adapter for CDS options can also be specified as part of CDS project-specific configuration | ||
## Singleton | ||
CDS OData V2 Adapter is instantiated via CDS plugin as singleton, which is exposed at: | ||
```js | ||
const cds = require("@sap/cds"); | ||
cds.cov2ap; | ||
``` | ||
The singleton can also be instantiated manually and accessed in custom server via: | ||
```js | ||
const cov2ap = require("@cap-js-community/odata-v2-adapter"); | ||
cov2ap.singleton(); | ||
``` | ||
### Before Middleware Routes | ||
Before middleware routes can be registered on the OData V2 adapter for CDS singleton, to be executed before the main route processing. | ||
The before middleware routes can be registered as single function or as array of route functions. | ||
Single before route can be registered as follows: | ||
```js | ||
const cds = require("@sap/cds"); | ||
cds.on("bootstrap", (app) => { | ||
cds.cov2ap.before = (req, res, next) => { | ||
// custom route processing | ||
next(); | ||
}; | ||
}); | ||
``` | ||
Multiple before routes can be registered as follows: | ||
```js | ||
const cds = require("@sap/cds"); | ||
cds.on("bootstrap", (app) => { | ||
cds.cov2ap.before = [ | ||
(req, res, next) => { | ||
// custom route processing | ||
next(); | ||
}, | ||
(req, res, next) => { | ||
// custom route processing | ||
next(); | ||
}, | ||
]; | ||
}); | ||
``` | ||
## Advanced | ||
@@ -109,4 +163,4 @@ | ||
- **Request:** url, headers, body | ||
- **Response:** status code/message, headers, body | ||
- **Request** url, headers, body | ||
- **Response**: status code/message, headers, body | ||
@@ -199,6 +253,6 @@ Debug log level can be activated | ||
- **Singletons:** Usage of annotation `@odata.singleton` is not supported in combination with OData V2 | ||
- **Structured Types:** Usage of `cds.odata.structs: true` is not supported in combination with OData V2 | ||
- **Arrayed Types:** Usages of `array of` or `many` in entity element definitions lead to CDS compilation error: `Element must not be an "array of" for OData V2` | ||
- **Managed Compositions:** The usage of managed composition (currently) produces Format Exception in Fiori Elements V2 for Date/Time data types | ||
- **Singletons**: Usage of annotation `@odata.singleton` is not supported in combination with OData V2 | ||
- **Structured Types**: Usage of `cds.odata.structs: true` is not supported in combination with OData V2 | ||
- **Arrayed Types**: Usages of `array of` or `many` in entity element definitions lead to CDS compilation error: `Element must not be an "array of" for OData V2` | ||
- **Managed Compositions**: The usage of managed composition (currently) produces Format Exception in Fiori Elements V2 for Date/Time data types | ||
@@ -250,7 +304,9 @@ To provide an OData V2 service based on the OData V2 adapter for CDS, those CDS modelling features must not be used. | ||
const cds = require("@sap/cds"); | ||
cds.on("bootstrap", (app) => | ||
app.use((req, res, next) => { | ||
req.features = req.features || ["advanced"]; | ||
next(); | ||
}), | ||
cds.on( | ||
"bootstrap", | ||
(app) => | ||
(cds.cov2ap.before = (req, res, next) => { | ||
req.features = req.features || ["advanced"]; | ||
next(); | ||
}), | ||
); | ||
@@ -323,8 +379,6 @@ ``` | ||
const cds = require("@sap/cds"); | ||
const cov2ap = require("@cap-js-community/odata-v2-adapter"); | ||
const compression = require("compression"); | ||
cds.on("bootstrap", (app) => { | ||
app.use(compression({ filter: shouldCompress })); | ||
app.use(cov2ap()); | ||
cds.cov2ap.before = [compression({ filter: shouldCompress })]; | ||
}); | ||
@@ -331,0 +385,0 @@ |
@@ -8,3 +8,5 @@ "use strict"; | ||
module.exports = class COV2APBuildPlugin extends cds.build.BuildPlugin { | ||
module.exports = class COV2APBuildPlugin extends cds.build.Plugin { | ||
static taskDefaults = { src: "srv" }; // used by build plugin | ||
static hasTask() { | ||
@@ -17,4 +19,2 @@ cds.env.cov2ap = cds.env.cov2ap || {}; | ||
init() {} | ||
async build() { | ||
@@ -21,0 +21,0 @@ const model = await this.model(); // TODO: Use this.baseModel(), when available |
@@ -178,2 +178,7 @@ import { RequestHandler } from "express"; | ||
cacheDefinitions?: boolean | true; | ||
/** | ||
* Specifies the caching and provisioning strategy of metadata (e.g. edmx) (memory, disk, stream). Default is 'memory'. | ||
*/ | ||
cacheMetadata?: string | "memory" | "disk" | "stream"; | ||
}; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
256879
4980
546