@cap-js-community/odata-v2-adapter
Advanced tools
Comparing version 1.12.5 to 1.12.6
@@ -8,2 +8,14 @@ # Changelog | ||
## Version 1.12.6 - 2024-03-04 | ||
### Fixed | ||
- Support OData V2 CDS protocol annotation via (`@protocol: [{ kind: 'odata-v2', path: '<path>' }]`) | ||
- Expose OData V2 service at specified `odata-v2` protocol path, in addition to default endpoint | ||
- Make pipeline stream errors only warnings as root cause is already logged | ||
- Serve OData V2 Adapter routes always after CDS listening (also for non-plugin case) | ||
- Fix build task in case of compilation errors | ||
- Fix build task to also include pre-compiled OData V2 EDMX files in `srv` | ||
- Fix build task for Java | ||
## Version 1.12.5 - 2024-02-09 | ||
@@ -10,0 +22,0 @@ |
{ | ||
"name": "@cap-js-community/odata-v2-adapter", | ||
"version": "1.12.5", | ||
"version": "1.12.6", | ||
"description": "OData V2 adapter for CDS", | ||
@@ -57,3 +57,3 @@ "homepage": "https://cap.cloud.sap/", | ||
"body-parser-xml": "^2.0.5", | ||
"express": "^4.18.2", | ||
"express": "^4.18.3", | ||
"express-fileupload": "^1.4.3", | ||
@@ -64,12 +64,12 @@ "http-proxy-middleware": "^2.0.6", | ||
"devDependencies": { | ||
"@cap-js/sqlite": "^1.5.0", | ||
"@cap-js/sqlite": "^1.5.1", | ||
"@cap-js-community/odata-v2-adapter": "./", | ||
"@sap/cds": "^7.6.2", | ||
"@sap/cds-dk": "^7.6.0", | ||
"@sap/cds": "^7.7.0", | ||
"@sap/cds-dk": "^7.7.0", | ||
"@sap/cds-hana": "^2.0.0", | ||
"@types/express": "^4.17.21", | ||
"compression": "^1.7.4", | ||
"eslint": "^8.56.0", | ||
"eslint": "^8.57.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"eslint-plugin-jest": "^27.6.3", | ||
"eslint-plugin-jest": "^27.9.0", | ||
"jest": "^29.7.0", | ||
@@ -76,0 +76,0 @@ "prettier": "^3.2.5", |
@@ -170,2 +170,4 @@ # @cap-js-community/odata-v2-adapter (cov2ap) | ||
- `@protocol: [{ kind: 'odata-v2', path: '<path>' }]`: Specifies an additional custom relative OData V2 protocol service path (prepending OData V2 protocol prefix) | ||
- `@protocol: [{ kind: 'odata-v2', path: '/<path>' }]`: Specifies an additional custom absolute OData V2 protocol service path (ignoring OData V2 protocol prefix) | ||
- `@cov2ap.ignore`: Exclude service from OData V2 adapter conversion (service is not exposed as OData V2 service) | ||
@@ -253,2 +255,8 @@ | ||
### Build Task | ||
CDS OData V2 Adapter includes an CDS build task, that allows to prepare the OData V2 EDMX files for MTX sidecar app. | ||
The build task is automatically active, in case project is running in multi-tenant context including MTX sidecar. | ||
It can be deactivated using option `cds.cov2ap.build: false`. | ||
### Unit-Tests | ||
@@ -255,0 +263,0 @@ |
"use strict"; | ||
const cds = require("@sap/cds"); | ||
const { path } = cds.utils; | ||
const DEFAULT_MAIN_FOLDER = "_main"; | ||
module.exports = class COV2APBuildPlugin extends cds.build.BuildPlugin { | ||
@@ -12,25 +13,8 @@ static hasTask() { | ||
cds.env.cov2ap.build = cds.env.cov2ap.build === undefined ? true : cds.env.cov2ap.build; | ||
return ( | ||
cds.env.cov2ap.plugin && | ||
cds.env.cov2ap.build && | ||
(cds.env.profiles?.includes("with-mtx-sidecar") || !!cds.env.requires["cds.xt.ModelProviderService"]) | ||
); | ||
return cds.env.cov2ap.plugin && cds.env.cov2ap.build; | ||
} | ||
init() { | ||
const mtxBuildTask = this.context.tasks.find((task) => task.for === "mtx-sidecar"); | ||
this.mtxSidecar = !!mtxBuildTask; | ||
if (!this.mtxSidecar) { | ||
return; | ||
} | ||
this.task.src = mtxBuildTask.src; | ||
const sidecarEnv = cds.env.for("cds", mtxBuildTask.src); | ||
const modelProviderService = sidecarEnv.requires["cds.xt.ModelProviderService"]; | ||
this.task.dest = path.join(mtxBuildTask.dest, modelProviderService.root, cds.env.folders.srv, "odata/v2"); | ||
} | ||
init() {} | ||
async build() { | ||
if (!this.mtxSidecar) { | ||
return; | ||
} | ||
const model = await this.model(); // TODO: Use this.baseModel(), when available | ||
@@ -40,2 +24,32 @@ if (!model) { | ||
} | ||
// srv | ||
const srvBuildTask = this.context.tasks.find((task) => ["nodejs", "java"].includes(task.for)); | ||
if (srvBuildTask) { | ||
this.task.src = srvBuildTask.src; | ||
const compileDest = | ||
(srvBuildTask.options && srvBuildTask.options.compileDest) ?? path.join(srvBuildTask.dest, cds.env.folders.srv); | ||
this.task.dest = path.join(compileDest, "odata/v2"); | ||
await this.generateEdmx(model); | ||
// mtx/sidecar | ||
if (cds.env.profiles?.includes("with-mtx-sidecar") || !!cds.env.requires["cds.xt.ModelProviderService"]) { | ||
const mtxBuildTask = this.context.tasks.find((task) => task.for === "mtx-sidecar"); | ||
if (mtxBuildTask) { | ||
this.task.src = mtxBuildTask.src; | ||
const sidecarEnv = cds.env.for("cds", mtxBuildTask.src); | ||
const modelProviderService = sidecarEnv.requires["cds.xt.ModelProviderService"]; | ||
let main = modelProviderService.root; | ||
const profiles = cds.env.profiles ?? []; | ||
if (!profiles.includes("production") && !profiles.includes("prod")) { | ||
main = DEFAULT_MAIN_FOLDER; | ||
} | ||
const mtxSidecarDest = path.join(mtxBuildTask.dest, main, cds.env.folders.srv, "odata/v2"); | ||
await this.copy(this.task.dest).to(mtxSidecarDest); | ||
} | ||
} | ||
} | ||
} | ||
async generateEdmx(model) { | ||
const services = cds.reflect(model).services.filter((service) => this.isServedViaOData(service)); | ||
@@ -51,7 +65,7 @@ for (const service of services) { | ||
}); | ||
this.write(result).to(`${service.name}.xml`); | ||
await this.write(result).to(`${service.name}.xml`); | ||
} catch (err) { | ||
this._logger.info( | ||
`EDMX V2 compilation failed. Service '${service.name}' is (probably) not compatible with OData V2`, | ||
err, | ||
this.pushMessage( | ||
`EDMX V2 compilation failed. Service '${service.name}' is (probably) not compatible with OData V2: ` + err, | ||
COV2APBuildPlugin.INFO, | ||
); | ||
@@ -58,0 +72,0 @@ } |
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
251209
4886
494
Updatedexpress@^4.18.3