@sap-ux/project-access 1.9.1 → 1.10.1
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.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/project/cap.d.ts +9 -0
- package/dist/project/cap.js +56 -2
- package/dist/project/index.d.ts +1 -1
- package/dist/project/index.js +2 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { FileName } from './constants';
|
|
2
|
-
export { findAllApps, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath, getAppProgrammingLanguage, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapProjectType, getWebappPath, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readUi5Yaml } from './project';
|
|
2
|
+
export { findAllApps, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath, getAppProgrammingLanguage, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapProjectType, getWebappPath, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readCapServiceMetadataEdmx, readUi5Yaml } from './project';
|
|
3
3
|
export { getFilePaths } from './file';
|
|
4
4
|
export * from './types';
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.getFilePaths = exports.readUi5Yaml = exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getWebappPath = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapEnvironment = exports.getCapCustomPaths = exports.getAppProgrammingLanguage = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findAllApps = exports.FileName = void 0;
|
|
17
|
+
exports.getFilePaths = exports.readUi5Yaml = exports.readCapServiceMetadataEdmx = exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getWebappPath = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapEnvironment = exports.getCapCustomPaths = exports.getAppProgrammingLanguage = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findAllApps = exports.FileName = void 0;
|
|
18
18
|
var constants_1 = require("./constants");
|
|
19
19
|
Object.defineProperty(exports, "FileName", { enumerable: true, get: function () { return constants_1.FileName; } });
|
|
20
20
|
var project_1 = require("./project");
|
|
@@ -31,6 +31,7 @@ Object.defineProperty(exports, "getWebappPath", { enumerable: true, get: functio
|
|
|
31
31
|
Object.defineProperty(exports, "isCapJavaProject", { enumerable: true, get: function () { return project_1.isCapJavaProject; } });
|
|
32
32
|
Object.defineProperty(exports, "isCapNodeJsProject", { enumerable: true, get: function () { return project_1.isCapNodeJsProject; } });
|
|
33
33
|
Object.defineProperty(exports, "loadModuleFromProject", { enumerable: true, get: function () { return project_1.loadModuleFromProject; } });
|
|
34
|
+
Object.defineProperty(exports, "readCapServiceMetadataEdmx", { enumerable: true, get: function () { return project_1.readCapServiceMetadataEdmx; } });
|
|
34
35
|
Object.defineProperty(exports, "readUi5Yaml", { enumerable: true, get: function () { return project_1.readUi5Yaml; } });
|
|
35
36
|
var file_1 = require("./file");
|
|
36
37
|
Object.defineProperty(exports, "getFilePaths", { enumerable: true, get: function () { return file_1.getFilePaths; } });
|
package/dist/project/cap.d.ts
CHANGED
|
@@ -41,6 +41,15 @@ export declare function getCapModelAndServices(projectRoot: string): Promise<{
|
|
|
41
41
|
model: csn;
|
|
42
42
|
services: ServiceInfo[];
|
|
43
43
|
}>;
|
|
44
|
+
/**
|
|
45
|
+
* Return the EDMX string of a CAP service.
|
|
46
|
+
*
|
|
47
|
+
* @param root - CAP project root where package.json resides
|
|
48
|
+
* @param uri - service path, e.g 'incident/'
|
|
49
|
+
* @param version - optional OData version v2 or v4
|
|
50
|
+
* @returns - string containing the edmx
|
|
51
|
+
*/
|
|
52
|
+
export declare function readCapServiceMetadataEdmx(root: string, uri: string, version?: 'v2' | 'v4'): Promise<string>;
|
|
44
53
|
/**
|
|
45
54
|
* Get CAP CDS project environment config for project root.
|
|
46
55
|
*
|
package/dist/project/cap.js
CHANGED
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.toReferenceUri = exports.toAbsoluteUri = exports.getCapEnvironment = exports.getCapModelAndServices = exports.getCapCustomPaths = exports.getCapProjectType = exports.isCapJavaProject = exports.isCapNodeJsProject = void 0;
|
|
12
|
+
exports.toReferenceUri = exports.toAbsoluteUri = exports.getCapEnvironment = exports.readCapServiceMetadataEdmx = exports.getCapModelAndServices = exports.getCapCustomPaths = exports.getCapProjectType = exports.isCapJavaProject = exports.isCapNodeJsProject = void 0;
|
|
13
13
|
const path_1 = require("path");
|
|
14
14
|
const constants_1 = require("../constants");
|
|
15
15
|
const file_1 = require("../file");
|
|
@@ -107,7 +107,15 @@ function getCapModelAndServices(projectRoot) {
|
|
|
107
107
|
(0, path_1.join)(projectRoot, capProjectPaths.db)
|
|
108
108
|
];
|
|
109
109
|
const model = yield cds.load(modelPaths);
|
|
110
|
-
|
|
110
|
+
let services = cds.compile.to['serviceinfo'](model, { root: projectRoot });
|
|
111
|
+
if (services === null || services === void 0 ? void 0 : services.map) {
|
|
112
|
+
services = services === null || services === void 0 ? void 0 : services.map((value) => {
|
|
113
|
+
return {
|
|
114
|
+
name: value.name,
|
|
115
|
+
urlPath: uniformUrl(value.urlPath)
|
|
116
|
+
};
|
|
117
|
+
});
|
|
118
|
+
}
|
|
111
119
|
return {
|
|
112
120
|
model,
|
|
113
121
|
services
|
|
@@ -115,6 +123,52 @@ function getCapModelAndServices(projectRoot) {
|
|
|
115
123
|
});
|
|
116
124
|
}
|
|
117
125
|
exports.getCapModelAndServices = getCapModelAndServices;
|
|
126
|
+
/**
|
|
127
|
+
* Remove rogue '\\' - cds windows if needed.
|
|
128
|
+
*
|
|
129
|
+
* @param url - url to uniform
|
|
130
|
+
* @returns - uniform url
|
|
131
|
+
*/
|
|
132
|
+
function uniformUrl(url) {
|
|
133
|
+
return url.replace(/\\/g, '/').replace(/\/\//g, '/');
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Return the EDMX string of a CAP service.
|
|
137
|
+
*
|
|
138
|
+
* @param root - CAP project root where package.json resides
|
|
139
|
+
* @param uri - service path, e.g 'incident/'
|
|
140
|
+
* @param version - optional OData version v2 or v4
|
|
141
|
+
* @returns - string containing the edmx
|
|
142
|
+
*/
|
|
143
|
+
function readCapServiceMetadataEdmx(root, uri, version = 'v4') {
|
|
144
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
145
|
+
try {
|
|
146
|
+
const { model, services } = yield getCapModelAndServices(root);
|
|
147
|
+
const service = findServiceByUri(services, uri);
|
|
148
|
+
if (!service) {
|
|
149
|
+
throw Error(`Service for uri: '${uri}' not found. Available services: ${JSON.stringify(services)}`);
|
|
150
|
+
}
|
|
151
|
+
const cds = yield loadCdsModuleFromProject(root);
|
|
152
|
+
const edmx = cds.compile.to.edmx(model, { service: service.name, version });
|
|
153
|
+
return edmx;
|
|
154
|
+
}
|
|
155
|
+
catch (error) {
|
|
156
|
+
throw Error(`Error while reading CAP service metadata. Path: '${root}', service uri: '${uri}', error: '${error.toString()}'}`);
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
exports.readCapServiceMetadataEdmx = readCapServiceMetadataEdmx;
|
|
161
|
+
/**
|
|
162
|
+
* Find a service in a list of services ignoring leading and trailing slashes.
|
|
163
|
+
*
|
|
164
|
+
* @param services - list of services from cds.compile.to['serviceinfo'](model)
|
|
165
|
+
* @param uri - search uri (usually from data source in manifest.json)
|
|
166
|
+
* @returns - name and uri of the service, undefined if service not found
|
|
167
|
+
*/
|
|
168
|
+
function findServiceByUri(services, uri) {
|
|
169
|
+
const searchUri = uniformUrl(uri).replace(/(?:^\/)|(?:\/$)/g, '');
|
|
170
|
+
return services.find((srv) => srv.urlPath.replace(/(?:^\/)|(?:\/$)/g, '') === searchUri);
|
|
171
|
+
}
|
|
118
172
|
/**
|
|
119
173
|
* Get CAP CDS project environment config for project root.
|
|
120
174
|
*
|
package/dist/project/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { getCapCustomPaths, getCapModelAndServices, getCapProjectType, isCapJavaProject, isCapNodeJsProject, getCapEnvironment } from './cap';
|
|
1
|
+
export { getCapCustomPaths, getCapModelAndServices, getCapProjectType, isCapJavaProject, isCapNodeJsProject, getCapEnvironment, readCapServiceMetadataEdmx } from './cap';
|
|
2
2
|
export { getAppProgrammingLanguage } from './info';
|
|
3
3
|
export { loadModuleFromProject } from './module-loader';
|
|
4
4
|
export { findAllApps, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath } from './search';
|
package/dist/project/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readUi5Yaml = exports.getWebappPath = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findAllApps = exports.loadModuleFromProject = exports.getAppProgrammingLanguage = exports.getCapEnvironment = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapCustomPaths = void 0;
|
|
3
|
+
exports.readUi5Yaml = exports.getWebappPath = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findAllApps = exports.loadModuleFromProject = exports.getAppProgrammingLanguage = exports.readCapServiceMetadataEdmx = exports.getCapEnvironment = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapCustomPaths = void 0;
|
|
4
4
|
var cap_1 = require("./cap");
|
|
5
5
|
Object.defineProperty(exports, "getCapCustomPaths", { enumerable: true, get: function () { return cap_1.getCapCustomPaths; } });
|
|
6
6
|
Object.defineProperty(exports, "getCapModelAndServices", { enumerable: true, get: function () { return cap_1.getCapModelAndServices; } });
|
|
@@ -8,6 +8,7 @@ Object.defineProperty(exports, "getCapProjectType", { enumerable: true, get: fun
|
|
|
8
8
|
Object.defineProperty(exports, "isCapJavaProject", { enumerable: true, get: function () { return cap_1.isCapJavaProject; } });
|
|
9
9
|
Object.defineProperty(exports, "isCapNodeJsProject", { enumerable: true, get: function () { return cap_1.isCapNodeJsProject; } });
|
|
10
10
|
Object.defineProperty(exports, "getCapEnvironment", { enumerable: true, get: function () { return cap_1.getCapEnvironment; } });
|
|
11
|
+
Object.defineProperty(exports, "readCapServiceMetadataEdmx", { enumerable: true, get: function () { return cap_1.readCapServiceMetadataEdmx; } });
|
|
11
12
|
var info_1 = require("./info");
|
|
12
13
|
Object.defineProperty(exports, "getAppProgrammingLanguage", { enumerable: true, get: function () { return info_1.getAppProgrammingLanguage; } });
|
|
13
14
|
var module_loader_1 = require("./module-loader");
|