@sap-ux/project-access 1.9.0 → 1.10.0
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 +10 -1
- package/dist/project/cap.js +53 -5
- 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,11 +41,20 @@ 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
|
*
|
|
47
56
|
* @param capProjectPath - project root of a CAP project
|
|
48
|
-
* @returns - environment config for CAP project
|
|
57
|
+
* @returns - environment config for a CAP project
|
|
49
58
|
*/
|
|
50
59
|
export declare function getCapEnvironment(capProjectPath: string): Promise<CdsEnvironment>;
|
|
51
60
|
/**
|
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");
|
|
@@ -99,7 +99,7 @@ exports.getCapCustomPaths = getCapCustomPaths;
|
|
|
99
99
|
*/
|
|
100
100
|
function getCapModelAndServices(projectRoot) {
|
|
101
101
|
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
-
const cds = yield (
|
|
102
|
+
const cds = yield loadCdsModuleFromProject(projectRoot);
|
|
103
103
|
const capProjectPaths = yield getCapCustomPaths(projectRoot);
|
|
104
104
|
const modelPaths = [
|
|
105
105
|
(0, path_1.join)(projectRoot, capProjectPaths.app),
|
|
@@ -115,20 +115,68 @@ function getCapModelAndServices(projectRoot) {
|
|
|
115
115
|
});
|
|
116
116
|
}
|
|
117
117
|
exports.getCapModelAndServices = getCapModelAndServices;
|
|
118
|
+
/**
|
|
119
|
+
* Return the EDMX string of a CAP service.
|
|
120
|
+
*
|
|
121
|
+
* @param root - CAP project root where package.json resides
|
|
122
|
+
* @param uri - service path, e.g 'incident/'
|
|
123
|
+
* @param version - optional OData version v2 or v4
|
|
124
|
+
* @returns - string containing the edmx
|
|
125
|
+
*/
|
|
126
|
+
function readCapServiceMetadataEdmx(root, uri, version = 'v4') {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
try {
|
|
129
|
+
const { model, services } = yield getCapModelAndServices(root);
|
|
130
|
+
const service = findServiceByUri(services, uri);
|
|
131
|
+
if (!service) {
|
|
132
|
+
throw Error(`Service for uri: '${uri}' not found. Available services: ${JSON.stringify(services)}`);
|
|
133
|
+
}
|
|
134
|
+
const cds = yield loadCdsModuleFromProject(root);
|
|
135
|
+
const edmx = cds.compile.to.edmx(model, { service: service.name, version });
|
|
136
|
+
return edmx;
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
throw Error(`Error while reading CAP service metadata. Path: '${root}', service uri: '${uri}', error: '${error.toString()}'}`);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
exports.readCapServiceMetadataEdmx = readCapServiceMetadataEdmx;
|
|
144
|
+
/**
|
|
145
|
+
* Find a service in a list of services.
|
|
146
|
+
*
|
|
147
|
+
* @param services - list of services from cds.compile.to['serviceinfo'](model)
|
|
148
|
+
* @param uri - search uri (usually from data source in manifest.json)
|
|
149
|
+
* @returns - name and uri of the service, undefined if service not found
|
|
150
|
+
*/
|
|
151
|
+
function findServiceByUri(services, uri) {
|
|
152
|
+
const searchUri = uri.replace(/[\\/]/g, '/'); // replace all \ and / in service uri due to issues on Windows with backslashes
|
|
153
|
+
return services.find((srv) => srv.urlPath.replace(/[\\/]/g, '/') === searchUri);
|
|
154
|
+
}
|
|
118
155
|
/**
|
|
119
156
|
* Get CAP CDS project environment config for project root.
|
|
120
157
|
*
|
|
121
158
|
* @param capProjectPath - project root of a CAP project
|
|
122
|
-
* @returns - environment config for CAP project
|
|
159
|
+
* @returns - environment config for a CAP project
|
|
123
160
|
*/
|
|
124
161
|
function getCapEnvironment(capProjectPath) {
|
|
125
162
|
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
-
const
|
|
127
|
-
const cds = 'default' in module ? module.default : module;
|
|
163
|
+
const cds = yield loadCdsModuleFromProject(capProjectPath);
|
|
128
164
|
return cds.env.for('cds', capProjectPath);
|
|
129
165
|
});
|
|
130
166
|
}
|
|
131
167
|
exports.getCapEnvironment = getCapEnvironment;
|
|
168
|
+
/**
|
|
169
|
+
* Load CAP CDS module for a project based on its root.
|
|
170
|
+
*
|
|
171
|
+
* @param capProjectPath - project root of a CAP project
|
|
172
|
+
* @returns - CAP CDS module for a CAP project
|
|
173
|
+
*/
|
|
174
|
+
function loadCdsModuleFromProject(capProjectPath) {
|
|
175
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
176
|
+
const module = yield (0, module_loader_1.loadModuleFromProject)(capProjectPath, '@sap/cds');
|
|
177
|
+
return 'default' in module ? module.default : module;
|
|
178
|
+
});
|
|
179
|
+
}
|
|
132
180
|
/**
|
|
133
181
|
* Get absolute path to a resource.
|
|
134
182
|
*
|
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");
|