@sap-ux/adp-tooling 0.18.93 → 0.18.94
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -13,7 +13,9 @@ export declare const enum ApiRoutes {
|
|
|
13
13
|
FRAGMENT = "/adp/api/fragment",
|
|
14
14
|
CONTROLLER = "/adp/api/controller",
|
|
15
15
|
CODE_EXT = "/adp/api/code_ext",
|
|
16
|
-
ANNOTATION = "/adp/api/annotation"
|
|
16
|
+
ANNOTATION = "/adp/api/annotation",
|
|
17
|
+
OVP_DATA_SOURCES = "/adp/api/ovp/datasources",
|
|
18
|
+
OVP_METAMODEL = "/adp/api/ovp/metamodel"
|
|
17
19
|
}
|
|
18
20
|
/**
|
|
19
21
|
* Instance of an adaptation project handling requests and data transformation.
|
|
@@ -35,6 +37,10 @@ export declare class AdpPreview {
|
|
|
35
37
|
* Routes handler class to handle API requests
|
|
36
38
|
*/
|
|
37
39
|
private routesHandler;
|
|
40
|
+
/**
|
|
41
|
+
* Routes handler for OVP bridge functions
|
|
42
|
+
*/
|
|
43
|
+
private ovpRoutesHandler;
|
|
38
44
|
private lrep;
|
|
39
45
|
private descriptorVariantId;
|
|
40
46
|
private projectTypeValue?;
|
|
@@ -7,6 +7,7 @@ exports.AdpPreview = void 0;
|
|
|
7
7
|
const adm_zip_1 = __importDefault(require("adm-zip"));
|
|
8
8
|
const system_access_1 = require("@sap-ux/system-access");
|
|
9
9
|
const routes_handler_1 = __importDefault(require("./routes-handler"));
|
|
10
|
+
const ovp_routes_handler_1 = __importDefault(require("./ovp-routes-handler"));
|
|
10
11
|
const change_handler_1 = require("./change-handler");
|
|
11
12
|
const descriptor_change_handler_1 = require("./descriptor-change-handler");
|
|
12
13
|
const helper_1 = require("../base/helper");
|
|
@@ -31,6 +32,10 @@ class AdpPreview {
|
|
|
31
32
|
* Routes handler class to handle API requests
|
|
32
33
|
*/
|
|
33
34
|
routesHandler;
|
|
35
|
+
/**
|
|
36
|
+
* Routes handler for OVP bridge functions
|
|
37
|
+
*/
|
|
38
|
+
ovpRoutesHandler;
|
|
34
39
|
lrep;
|
|
35
40
|
descriptorVariantId;
|
|
36
41
|
projectTypeValue;
|
|
@@ -102,6 +107,7 @@ class AdpPreview {
|
|
|
102
107
|
this.descriptorVariantId = descriptorVariant.id;
|
|
103
108
|
this.provider = await (0, system_access_1.createAbapServiceProvider)(this.config.target, { ignoreCertErrors: this.config.ignoreCertErrors }, true, this.logger);
|
|
104
109
|
this.routesHandler = new routes_handler_1.default(this.project, this.util, this.provider, this.logger);
|
|
110
|
+
this.ovpRoutesHandler = new ovp_routes_handler_1.default(this.provider, this.logger);
|
|
105
111
|
this.lrep = this.provider.getLayeredRepository();
|
|
106
112
|
// fetch a merged descriptor from the backend
|
|
107
113
|
await this.lrep.getCsrfToken();
|
|
@@ -205,6 +211,10 @@ class AdpPreview {
|
|
|
205
211
|
router.post("/adp/api/controller" /* ApiRoutes.CONTROLLER */, this.routesHandler.handleWriteControllerExt);
|
|
206
212
|
router.get("/adp/api/code_ext" /* ApiRoutes.CODE_EXT */, this.routesHandler.handleGetControllerExtensionData);
|
|
207
213
|
router.get("/adp/api/annotation" /* ApiRoutes.ANNOTATION */, this.routesHandler.handleGetAllAnnotationFilesMappedByDataSource);
|
|
214
|
+
if (this.ovpRoutesHandler) {
|
|
215
|
+
router.get("/adp/api/ovp/datasources" /* ApiRoutes.OVP_DATA_SOURCES */, this.ovpRoutesHandler.handleGetDataSources);
|
|
216
|
+
router.post("/adp/api/ovp/metamodel" /* ApiRoutes.OVP_METAMODEL */, this.ovpRoutesHandler.handleGetMetaModel);
|
|
217
|
+
}
|
|
208
218
|
}
|
|
209
219
|
/**
|
|
210
220
|
* Handles different types of change requests to project files.
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ToolsLogger } from '@sap-ux/logger';
|
|
2
|
+
import type { NextFunction, Request, Response } from 'express';
|
|
3
|
+
import type { AbapServiceProvider } from '@sap-ux/axios-extension';
|
|
4
|
+
/**
|
|
5
|
+
* Server-side handler for OVP bridge function API routes.
|
|
6
|
+
* Provides data source catalog and service metadata endpoints
|
|
7
|
+
* consumed by the client-side OVP bridge functions.
|
|
8
|
+
*/
|
|
9
|
+
export default class OvpRoutesHandler {
|
|
10
|
+
private readonly provider;
|
|
11
|
+
private readonly logger;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of OvpRoutesHandler.
|
|
14
|
+
*
|
|
15
|
+
* @param provider AbapServiceProvider instance for backend communication
|
|
16
|
+
* @param logger Logger instance
|
|
17
|
+
*/
|
|
18
|
+
constructor(provider: AbapServiceProvider, logger: ToolsLogger);
|
|
19
|
+
/**
|
|
20
|
+
* Handler for fetching available OData V2 services from the catalog.
|
|
21
|
+
*
|
|
22
|
+
* @param _req Request
|
|
23
|
+
* @param res Response
|
|
24
|
+
* @param next Next function
|
|
25
|
+
*/
|
|
26
|
+
handleGetDataSources: (_req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Handler for fetching service info and annotation URLs for a selected data source.
|
|
29
|
+
* Returns the service URL and annotation details so the client can create
|
|
30
|
+
* a real UI5 ODataModel with annotations merged for full metamodel support.
|
|
31
|
+
*
|
|
32
|
+
* @param req Request containing dataSource in body
|
|
33
|
+
* @param res Response
|
|
34
|
+
* @param next Next function
|
|
35
|
+
*/
|
|
36
|
+
handleGetMetaModel: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=ovp-routes-handler.d.ts.map
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const axios_extension_1 = require("@sap-ux/axios-extension");
|
|
4
|
+
/**
|
|
5
|
+
* Converts an absolute URL to a relative path.
|
|
6
|
+
* Annotation URIs from the catalog service are absolute (e.g. https://host/sap/opu/...).
|
|
7
|
+
* The client needs relative paths so requests go through the backend proxy.
|
|
8
|
+
*
|
|
9
|
+
* @param uri Absolute or relative URI
|
|
10
|
+
* @returns Relative path
|
|
11
|
+
*/
|
|
12
|
+
function toRelativePath(uri) {
|
|
13
|
+
try {
|
|
14
|
+
return new URL(uri).pathname;
|
|
15
|
+
}
|
|
16
|
+
catch {
|
|
17
|
+
return uri;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Server-side handler for OVP bridge function API routes.
|
|
22
|
+
* Provides data source catalog and service metadata endpoints
|
|
23
|
+
* consumed by the client-side OVP bridge functions.
|
|
24
|
+
*/
|
|
25
|
+
class OvpRoutesHandler {
|
|
26
|
+
provider;
|
|
27
|
+
logger;
|
|
28
|
+
/**
|
|
29
|
+
* Creates an instance of OvpRoutesHandler.
|
|
30
|
+
*
|
|
31
|
+
* @param provider AbapServiceProvider instance for backend communication
|
|
32
|
+
* @param logger Logger instance
|
|
33
|
+
*/
|
|
34
|
+
constructor(provider, logger) {
|
|
35
|
+
this.provider = provider;
|
|
36
|
+
this.logger = logger;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Handler for fetching available OData V2 services from the catalog.
|
|
40
|
+
*
|
|
41
|
+
* @param _req Request
|
|
42
|
+
* @param res Response
|
|
43
|
+
* @param next Next function
|
|
44
|
+
*/
|
|
45
|
+
handleGetDataSources = async (_req, res, next) => {
|
|
46
|
+
try {
|
|
47
|
+
const catalogService = this.provider.catalog(axios_extension_1.ODataVersion.v2);
|
|
48
|
+
const response = await catalogService.get('/ServiceCollection', {
|
|
49
|
+
params: { $format: 'json' }
|
|
50
|
+
});
|
|
51
|
+
const services = response.odata();
|
|
52
|
+
res.status(200 /* HttpStatusCodes.OK */).json({ results: services });
|
|
53
|
+
this.logger.debug(`OVP: Fetched ${services.length} data sources from catalog`);
|
|
54
|
+
}
|
|
55
|
+
catch (e) {
|
|
56
|
+
this.logger.error(`OVP: Failed to fetch data sources: ${e.message}`);
|
|
57
|
+
res.status(500 /* HttpStatusCodes.INTERNAL_SERVER_ERROR */).json({
|
|
58
|
+
message: `Failed to fetch data sources: ${e.message}`
|
|
59
|
+
});
|
|
60
|
+
next(e);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Handler for fetching service info and annotation URLs for a selected data source.
|
|
65
|
+
* Returns the service URL and annotation details so the client can create
|
|
66
|
+
* a real UI5 ODataModel with annotations merged for full metamodel support.
|
|
67
|
+
*
|
|
68
|
+
* @param req Request containing dataSource in body
|
|
69
|
+
* @param res Response
|
|
70
|
+
* @param next Next function
|
|
71
|
+
*/
|
|
72
|
+
handleGetMetaModel = async (req, res, next) => {
|
|
73
|
+
try {
|
|
74
|
+
const { dataSource } = req.body;
|
|
75
|
+
this.logger.debug(`OVP: getMetaModel called for service ${dataSource?.Title ?? 'unknown'}`);
|
|
76
|
+
if (!dataSource?.Title) {
|
|
77
|
+
res.status(400 /* HttpStatusCodes.BAD_REQUEST */).json({ message: 'dataSource with Title is required' });
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const catalogService = this.provider.catalog(axios_extension_1.ODataVersion.v2);
|
|
81
|
+
const filterOptions = dataSource.ID ? { id: dataSource.ID } : { title: dataSource.Title };
|
|
82
|
+
const annotations = await catalogService.getAnnotations(filterOptions);
|
|
83
|
+
if (annotations.length === 0) {
|
|
84
|
+
res.status(200 /* HttpStatusCodes.OK */).json(null);
|
|
85
|
+
this.logger.debug(`OVP: No annotations found for service ${dataSource.Title}`);
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const serviceURI = `/sap/opu/odata/sap/${dataSource.Title}`;
|
|
89
|
+
res.status(200 /* HttpStatusCodes.OK */).json({
|
|
90
|
+
serviceUrl: `${serviceURI}/`,
|
|
91
|
+
annotations: annotations.map((a) => ({
|
|
92
|
+
TechnicalName: a.TechnicalName,
|
|
93
|
+
Uri: toRelativePath(a.Uri)
|
|
94
|
+
})),
|
|
95
|
+
modelInformation: {
|
|
96
|
+
serviceURI,
|
|
97
|
+
serviceAnnotation: annotations[0].TechnicalName,
|
|
98
|
+
serviceAnnotationURI: toRelativePath(annotations[0].Uri)
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
this.logger.debug(`OVP: Fetched service info for ${dataSource.Title} with ${annotations.length} annotations`);
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
this.logger.error(`OVP: Failed to fetch metamodel: ${e.message}`);
|
|
105
|
+
res.status(500 /* HttpStatusCodes.INTERNAL_SERVER_ERROR */).json({
|
|
106
|
+
message: `Failed to fetch metamodel: ${e.message}`
|
|
107
|
+
});
|
|
108
|
+
next(e);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
exports.default = OvpRoutesHandler;
|
|
113
|
+
//# sourceMappingURL=ovp-routes-handler.js.map
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aadp-tooling"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.18.
|
|
12
|
+
"version": "0.18.94",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|