@sap-ux/project-access 1.16.2 → 1.17.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.
@@ -13,4 +13,7 @@ export declare const FileName: {
13
13
  readonly Ui5MockYaml: "ui5-mock.yaml";
14
14
  readonly UI5DeployYaml: "ui5-deploy.yaml";
15
15
  };
16
+ export declare const DirName: {
17
+ readonly Changes: "changes";
18
+ };
16
19
  //# sourceMappingURL=constants.d.ts.map
package/dist/constants.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FileName = void 0;
3
+ exports.DirName = exports.FileName = void 0;
4
4
  exports.FileName = {
5
5
  AdaptationConfig: 'config.json',
6
6
  CapJavaApplicationYaml: 'application.yaml',
@@ -16,4 +16,7 @@ exports.FileName = {
16
16
  Ui5MockYaml: 'ui5-mock.yaml',
17
17
  UI5DeployYaml: 'ui5-deploy.yaml'
18
18
  };
19
+ exports.DirName = {
20
+ Changes: 'changes'
21
+ };
19
22
  //# sourceMappingURL=constants.js.map
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { FileName } from './constants';
2
- export { findAllApps, findCapProjects, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath, getAppProgrammingLanguage, getAppType, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapProjectType, getCdsFiles, getCdsRoots, getCdsServices, getMtaPath, getNodeModulesPath, getProjectType, getWebappPath, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readCapServiceMetadataEdmx, readUi5Yaml } from './project';
3
2
  export { getFilePaths } from './file';
3
+ export { findAllApps, findCapProjects, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath, getAppProgrammingLanguage, getAppType, getCapCustomPaths, getCapEnvironment, getCapModelAndServices, getCapProjectType, getCdsFiles, getCdsRoots, getCdsServices, getI18nPropertiesPaths, getMtaPath, getNodeModulesPath, getProject, getProjectType, getWebappPath, isCapJavaProject, isCapNodeJsProject, loadModuleFromProject, readCapServiceMetadataEdmx, readUi5Yaml } from './project';
4
4
  export * from './types';
5
5
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -14,9 +14,11 @@ 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.readCapServiceMetadataEdmx = exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getWebappPath = exports.getProjectType = exports.getNodeModulesPath = exports.getMtaPath = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapEnvironment = exports.getCapCustomPaths = exports.getAppType = exports.getAppProgrammingLanguage = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findAllApps = exports.FileName = void 0;
17
+ exports.readUi5Yaml = exports.readCapServiceMetadataEdmx = exports.loadModuleFromProject = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getWebappPath = exports.getProjectType = exports.getProject = exports.getNodeModulesPath = exports.getMtaPath = exports.getI18nPropertiesPaths = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapEnvironment = exports.getCapCustomPaths = exports.getAppType = exports.getAppProgrammingLanguage = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findAllApps = exports.getFilePaths = 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
+ var file_1 = require("./file");
21
+ Object.defineProperty(exports, "getFilePaths", { enumerable: true, get: function () { return file_1.getFilePaths; } });
20
22
  var project_1 = require("./project");
21
23
  Object.defineProperty(exports, "findAllApps", { enumerable: true, get: function () { return project_1.findAllApps; } });
22
24
  Object.defineProperty(exports, "findCapProjects", { enumerable: true, get: function () { return project_1.findCapProjects; } });
@@ -32,8 +34,10 @@ Object.defineProperty(exports, "getCapProjectType", { enumerable: true, get: fun
32
34
  Object.defineProperty(exports, "getCdsFiles", { enumerable: true, get: function () { return project_1.getCdsFiles; } });
33
35
  Object.defineProperty(exports, "getCdsRoots", { enumerable: true, get: function () { return project_1.getCdsRoots; } });
34
36
  Object.defineProperty(exports, "getCdsServices", { enumerable: true, get: function () { return project_1.getCdsServices; } });
37
+ Object.defineProperty(exports, "getI18nPropertiesPaths", { enumerable: true, get: function () { return project_1.getI18nPropertiesPaths; } });
35
38
  Object.defineProperty(exports, "getMtaPath", { enumerable: true, get: function () { return project_1.getMtaPath; } });
36
39
  Object.defineProperty(exports, "getNodeModulesPath", { enumerable: true, get: function () { return project_1.getNodeModulesPath; } });
40
+ Object.defineProperty(exports, "getProject", { enumerable: true, get: function () { return project_1.getProject; } });
37
41
  Object.defineProperty(exports, "getProjectType", { enumerable: true, get: function () { return project_1.getProjectType; } });
38
42
  Object.defineProperty(exports, "getWebappPath", { enumerable: true, get: function () { return project_1.getWebappPath; } });
39
43
  Object.defineProperty(exports, "isCapJavaProject", { enumerable: true, get: function () { return project_1.isCapJavaProject; } });
@@ -41,7 +45,5 @@ Object.defineProperty(exports, "isCapNodeJsProject", { enumerable: true, get: fu
41
45
  Object.defineProperty(exports, "loadModuleFromProject", { enumerable: true, get: function () { return project_1.loadModuleFromProject; } });
42
46
  Object.defineProperty(exports, "readCapServiceMetadataEdmx", { enumerable: true, get: function () { return project_1.readCapServiceMetadataEdmx; } });
43
47
  Object.defineProperty(exports, "readUi5Yaml", { enumerable: true, get: function () { return project_1.readUi5Yaml; } });
44
- var file_1 = require("./file");
45
- Object.defineProperty(exports, "getFilePaths", { enumerable: true, get: function () { return file_1.getFilePaths; } });
46
48
  __exportStar(require("./types"), exports);
47
49
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,18 @@
1
+ import type { I18nPropertiesPaths, Manifest } from '../../types';
2
+ /**
3
+ * Return absolute paths to i18n.properties files from manifest.
4
+ *
5
+ * @param manifestPath - path to manifest.json; used to parse manifest.json if not provided as second argument and to resolve absolute paths
6
+ * @param manifest - optionally, parsed content of manifest.json, pass to avoid reading it again.
7
+ * @returns - absolute paths to i18n.properties
8
+ */
9
+ export declare function getI18nPropertiesPaths(manifestPath: string, manifest?: Manifest): Promise<I18nPropertiesPaths>;
10
+ /**
11
+ * Return paths to i18n.properties files from manifest,
12
+ * relative to the manifest.json.
13
+ *
14
+ * @param manifest - parsed content of manifest.json
15
+ * @returns - paths to i18n.properties files from sap.app and models
16
+ */
17
+ export declare function getRelativeI18nPropertiesPaths(manifest: Manifest): I18nPropertiesPaths;
18
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1,127 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getRelativeI18nPropertiesPaths = exports.getI18nPropertiesPaths = void 0;
13
+ const path_1 = require("path");
14
+ const file_1 = require("../../file");
15
+ /**
16
+ * Return absolute paths to i18n.properties files from manifest.
17
+ *
18
+ * @param manifestPath - path to manifest.json; used to parse manifest.json if not provided as second argument and to resolve absolute paths
19
+ * @param manifest - optionally, parsed content of manifest.json, pass to avoid reading it again.
20
+ * @returns - absolute paths to i18n.properties
21
+ */
22
+ function getI18nPropertiesPaths(manifestPath, manifest) {
23
+ return __awaiter(this, void 0, void 0, function* () {
24
+ const parsedManifest = manifest !== null && manifest !== void 0 ? manifest : (yield (0, file_1.readJSON)(manifestPath));
25
+ const manifestFolder = (0, path_1.dirname)(manifestPath);
26
+ const relativeI18nPropertiesPaths = getRelativeI18nPropertiesPaths(parsedManifest);
27
+ const i18nPropertiesPaths = {
28
+ 'sap.app': (0, path_1.join)(manifestFolder, relativeI18nPropertiesPaths['sap.app']),
29
+ models: {}
30
+ };
31
+ for (const modelKey in relativeI18nPropertiesPaths.models) {
32
+ i18nPropertiesPaths.models[modelKey] = {
33
+ path: (0, path_1.join)(manifestFolder, relativeI18nPropertiesPaths.models[modelKey].path)
34
+ };
35
+ }
36
+ return i18nPropertiesPaths;
37
+ });
38
+ }
39
+ exports.getI18nPropertiesPaths = getI18nPropertiesPaths;
40
+ /**
41
+ * Return paths to i18n.properties files from manifest,
42
+ * relative to the manifest.json.
43
+ *
44
+ * @param manifest - parsed content of manifest.json
45
+ * @returns - paths to i18n.properties files from sap.app and models
46
+ */
47
+ function getRelativeI18nPropertiesPaths(manifest) {
48
+ return {
49
+ 'sap.app': getI18nAppPath(manifest),
50
+ models: getI18nModelPaths(manifest)
51
+ };
52
+ }
53
+ exports.getRelativeI18nPropertiesPaths = getRelativeI18nPropertiesPaths;
54
+ /**
55
+ * Get the i18n path from sap.app.i18n part of the manifest.
56
+ *
57
+ * 1. from `sap.app.i18n` if `i18n` is string
58
+ * 2. from `sap.app.bundleName` as `bundleName` wins over `bundleUrl`
59
+ * 3. from `sap.app.bundleUrl`
60
+ * 4. default which is `'i18n/i18n.properties'`
61
+ *
62
+ * @param manifest - parsed content of manifest.json
63
+ * @returns - path to i18n.properties file
64
+ */
65
+ function getI18nAppPath(manifest) {
66
+ var _a, _b;
67
+ const defaultPath = (0, path_1.join)('i18n/i18n.properties');
68
+ if (typeof ((_a = manifest === null || manifest === void 0 ? void 0 : manifest['sap.app']) === null || _a === void 0 ? void 0 : _a.i18n) === 'string') {
69
+ return (0, path_1.join)(manifest['sap.app'].i18n);
70
+ }
71
+ if (typeof ((_b = manifest === null || manifest === void 0 ? void 0 : manifest['sap.app']) === null || _b === void 0 ? void 0 : _b.i18n) === 'object') {
72
+ // bundleName wins over `bundleUrl`
73
+ if ('bundleName' in manifest['sap.app'].i18n) {
74
+ // module name is in dot notation
75
+ const withoutAppId = manifest['sap.app'].i18n.bundleName.replace(manifest['sap.app'].id, '');
76
+ const i18nPath = `${(0, path_1.join)(...withoutAppId.split('.'))}.properties`;
77
+ return (0, path_1.join)(i18nPath);
78
+ }
79
+ if ('bundleUrl' in manifest['sap.app'].i18n) {
80
+ return (0, path_1.join)(manifest['sap.app'].i18n.bundleUrl);
81
+ }
82
+ }
83
+ // default
84
+ return defaultPath;
85
+ }
86
+ /**
87
+ * Get the i18n path from UI5 resource models declared in sap.ui5.models part of the manifest.
88
+ * By default the model used for internationalization in the UI is 'i18n'. For
89
+ * internationalization of annotations the model is '@18n'.
90
+ *
91
+ * for For `sap.ui5` namespace
92
+ * 1. from `sap.ui5.models.{resource model key}.bundleName` as `bundleName` wins over `bundleUrl`
93
+ * 2. from `sap.ui5.models.{resource model key}.bundleUrl`
94
+ * 3. from `sap.ui5.models.{resource model key}.uri`
95
+ *
96
+ * @param manifest - parsed content of manifest.json
97
+ * @returns - paths to i18n.properties file from models
98
+ */
99
+ function getI18nModelPaths(manifest) {
100
+ var _a, _b;
101
+ const result = {};
102
+ const models = (_b = (_a = manifest === null || manifest === void 0 ? void 0 : manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.models) !== null && _b !== void 0 ? _b : {};
103
+ const resourceModelKeys = Object.keys(models).filter((key) => models[key].type === 'sap.ui.model.resource.ResourceModel');
104
+ for (const modelKey of resourceModelKeys) {
105
+ const i18nModel = models[modelKey];
106
+ // settings wins over `uri`
107
+ if (i18nModel.settings) {
108
+ // bundleName wins over `bundleUrl`
109
+ if (i18nModel.settings.bundleName) {
110
+ // module name is in dot notation
111
+ const withoutAppId = i18nModel.settings.bundleName.replace(manifest['sap.app'].id, '');
112
+ const i18nPath = `${(0, path_1.join)(...withoutAppId.split('.'))}.properties`;
113
+ result[modelKey] = { path: (0, path_1.join)(i18nPath) };
114
+ continue;
115
+ }
116
+ if (i18nModel.settings.bundleUrl) {
117
+ result[modelKey] = { path: (0, path_1.join)(i18nModel.settings.bundleUrl) };
118
+ continue;
119
+ }
120
+ }
121
+ if (i18nModel.uri) {
122
+ result[modelKey] = { path: (0, path_1.join)(i18nModel.uri) };
123
+ }
124
+ }
125
+ return result;
126
+ }
127
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1,2 @@
1
+ export { getI18nPropertiesPaths } from './i18n';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getI18nPropertiesPaths = void 0;
4
+ var i18n_1 = require("./i18n");
5
+ Object.defineProperty(exports, "getI18nPropertiesPaths", { enumerable: true, get: function () { return i18n_1.getI18nPropertiesPaths; } });
6
+ //# sourceMappingURL=index.js.map
@@ -1,6 +1,7 @@
1
1
  export { getCapCustomPaths, getCapModelAndServices, getCapProjectType, getCdsFiles, getCdsRoots, getCdsServices, isCapJavaProject, isCapNodeJsProject, getCapEnvironment, readCapServiceMetadataEdmx } from './cap';
2
2
  export { getNodeModulesPath } from './dependencies';
3
- export { getAppProgrammingLanguage, getAppType, getProjectType } from './info';
3
+ export { getI18nPropertiesPaths } from './i18n';
4
+ export { getAppProgrammingLanguage, getAppType, getProject, getProjectType } from './info';
4
5
  export { loadModuleFromProject } from './module-loader';
5
6
  export { findAllApps, findCapProjects, findFioriArtifacts, findProjectRoot, getAppRootFromWebappPath } from './search';
6
7
  export { getWebappPath, readUi5Yaml } from './ui5-config';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getMtaPath = exports.readUi5Yaml = exports.getWebappPath = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findAllApps = exports.loadModuleFromProject = exports.getProjectType = exports.getAppType = exports.getAppProgrammingLanguage = exports.getNodeModulesPath = exports.readCapServiceMetadataEdmx = exports.getCapEnvironment = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = exports.getCapProjectType = exports.getCapModelAndServices = exports.getCapCustomPaths = void 0;
3
+ exports.getMtaPath = exports.readUi5Yaml = exports.getWebappPath = exports.getAppRootFromWebappPath = exports.findProjectRoot = exports.findFioriArtifacts = exports.findCapProjects = exports.findAllApps = exports.loadModuleFromProject = exports.getProjectType = exports.getProject = exports.getAppType = exports.getAppProgrammingLanguage = exports.getI18nPropertiesPaths = exports.getNodeModulesPath = exports.readCapServiceMetadataEdmx = exports.getCapEnvironment = exports.isCapNodeJsProject = exports.isCapJavaProject = exports.getCdsServices = exports.getCdsRoots = exports.getCdsFiles = 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; } });
@@ -14,9 +14,12 @@ Object.defineProperty(exports, "getCapEnvironment", { enumerable: true, get: fun
14
14
  Object.defineProperty(exports, "readCapServiceMetadataEdmx", { enumerable: true, get: function () { return cap_1.readCapServiceMetadataEdmx; } });
15
15
  var dependencies_1 = require("./dependencies");
16
16
  Object.defineProperty(exports, "getNodeModulesPath", { enumerable: true, get: function () { return dependencies_1.getNodeModulesPath; } });
17
+ var i18n_1 = require("./i18n");
18
+ Object.defineProperty(exports, "getI18nPropertiesPaths", { enumerable: true, get: function () { return i18n_1.getI18nPropertiesPaths; } });
17
19
  var info_1 = require("./info");
18
20
  Object.defineProperty(exports, "getAppProgrammingLanguage", { enumerable: true, get: function () { return info_1.getAppProgrammingLanguage; } });
19
21
  Object.defineProperty(exports, "getAppType", { enumerable: true, get: function () { return info_1.getAppType; } });
22
+ Object.defineProperty(exports, "getProject", { enumerable: true, get: function () { return info_1.getProject; } });
20
23
  Object.defineProperty(exports, "getProjectType", { enumerable: true, get: function () { return info_1.getProjectType; } });
21
24
  var module_loader_1 = require("./module-loader");
22
25
  Object.defineProperty(exports, "loadModuleFromProject", { enumerable: true, get: function () { return module_loader_1.loadModuleFromProject; } });
@@ -1,5 +1,12 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
- import type { AppProgrammingLanguage, AppType, ProjectType } from '../types';
2
+ import type { AppProgrammingLanguage, AppType, Project, ProjectType } from '../types';
3
+ /**
4
+ * Returns the project structure for a given Fiori project.
5
+ *
6
+ * @param root - project root folder
7
+ * @returns - project structure with project info like project type, apps, root folder
8
+ */
9
+ export declare function getProject(root: string): Promise<Project>;
3
10
  /**
4
11
  * Get the used programming language of an application.
5
12
  *
@@ -9,13 +9,98 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getProjectType = exports.getAppType = exports.getAppProgrammingLanguage = void 0;
12
+ exports.getProjectType = exports.getAppType = exports.getAppProgrammingLanguage = exports.getProject = void 0;
13
13
  const path_1 = require("path");
14
14
  const constants_1 = require("../constants");
15
15
  const file_1 = require("../file");
16
16
  const cap_1 = require("./cap");
17
- const ui5_config_1 = require("./ui5-config");
17
+ const i18n_1 = require("./i18n/i18n");
18
18
  const search_1 = require("./search");
19
+ const service_1 = require("./service");
20
+ const ui5_config_1 = require("./ui5-config");
21
+ /**
22
+ * Returns the project structure for a given Fiori project.
23
+ *
24
+ * @param root - project root folder
25
+ * @returns - project structure with project info like project type, apps, root folder
26
+ */
27
+ function getProject(root) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const checkCapType = yield (0, cap_1.getCapProjectType)(root);
30
+ const projectType = checkCapType !== null && checkCapType !== void 0 ? checkCapType : 'EDMXBackend';
31
+ const packageJson = yield (0, file_1.readJSON)((0, path_1.join)(root, constants_1.FileName.Package));
32
+ const appFolders = getAppFolders(packageJson);
33
+ const apps = yield getApps(root, appFolders);
34
+ return {
35
+ root,
36
+ projectType,
37
+ apps
38
+ };
39
+ });
40
+ }
41
+ exports.getProject = getProject;
42
+ /**
43
+ * Returns the application folders from sapux flag of the package.json. For single app
44
+ * projects, this is just an array with one empty string. For CAP projects, this is an
45
+ * array of operating system specific relative paths to the apps.
46
+ *
47
+ * @param packageJson - parsed package.json
48
+ * @returns - array of operating specific application folders
49
+ */
50
+ function getAppFolders(packageJson) {
51
+ return Array.isArray(packageJson.sapux)
52
+ ? packageJson.sapux.map((appFolder) => (0, path_1.join)(...appFolder.split(/[/\\]/)))
53
+ : [''];
54
+ }
55
+ /**
56
+ * Get the application structure for each application in the project.
57
+ *
58
+ * @param root - project root folder
59
+ * @param appFolders - array of relative application folders
60
+ * @returns - map of application structures
61
+ */
62
+ function getApps(root, appFolders) {
63
+ return __awaiter(this, void 0, void 0, function* () {
64
+ const apps = {};
65
+ for (const appFolder of appFolders) {
66
+ const applicationStructure = yield getApplicationStructure(root, appFolder);
67
+ if (applicationStructure) {
68
+ apps[appFolder] = applicationStructure;
69
+ }
70
+ }
71
+ return apps;
72
+ });
73
+ }
74
+ /**
75
+ * Get the application structure for a given application.
76
+ *
77
+ * @param root - project root folder
78
+ * @param appFolder - relative application folder
79
+ * @returns - application structure with application info like manifest, changes, main service, services, annotations
80
+ */
81
+ function getApplicationStructure(root, appFolder) {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ const appRoot = (0, path_1.join)(root, appFolder);
84
+ const absoluteWebappPath = yield (0, ui5_config_1.getWebappPath)(appRoot);
85
+ const manifest = (0, path_1.join)(absoluteWebappPath, constants_1.FileName.Manifest);
86
+ if (!(yield (0, file_1.fileExists)(manifest))) {
87
+ return undefined;
88
+ }
89
+ const manifestObject = yield (0, file_1.readJSON)(manifest);
90
+ const changes = (0, path_1.join)(absoluteWebappPath, constants_1.DirName.Changes);
91
+ const i18n = yield (0, i18n_1.getI18nPropertiesPaths)(manifest, manifestObject);
92
+ const mainService = (0, service_1.getMainService)(manifestObject);
93
+ const services = yield (0, service_1.getServicesAndAnnotations)(manifest, manifestObject);
94
+ return {
95
+ appRoot,
96
+ manifest,
97
+ changes,
98
+ i18n,
99
+ mainService,
100
+ services
101
+ };
102
+ });
103
+ }
19
104
  /**
20
105
  * Get the used programming language of an application.
21
106
  *
@@ -176,20 +176,22 @@ function findRootsForPath(path) {
176
176
  // in root -> not supported
177
177
  return null;
178
178
  }
179
- // Now we have the app root folder. Check for freestyle non CAP
180
- if ((yield (0, file_1.fileExists)((0, path_1.join)(appRoot, constants_1.FileName.Ui5LocalYaml))) &&
181
- (0, dependencies_1.hasDependency)(appPckJson, '@sap/ux-ui5-tooling')) {
179
+ // Check if app is included in CAP project
180
+ const projectRoot = yield findCapProjectRoot(appRoot);
181
+ if (projectRoot) {
182
+ // App included in CAP
182
183
  return {
183
184
  appRoot,
184
- projectRoot: appRoot
185
+ projectRoot
185
186
  };
186
187
  }
187
- // Project must be CAP, find project root
188
- const projectRoot = yield findCapProjectRoot(appRoot);
189
- if (projectRoot) {
188
+ else if (
189
+ // Check for freestyle non CAP
190
+ (yield (0, file_1.fileExists)((0, path_1.join)(appRoot, constants_1.FileName.Ui5LocalYaml))) &&
191
+ (0, dependencies_1.hasDependency)(appPckJson, '@sap/ux-ui5-tooling')) {
190
192
  return {
191
193
  appRoot,
192
- projectRoot
194
+ projectRoot: appRoot
193
195
  };
194
196
  }
195
197
  }
@@ -0,0 +1,21 @@
1
+ import type { Manifest, ServiceSpecification } from '../types';
2
+ /**
3
+ * Get the main service name from the manifest.
4
+ * LROP: by definition the service name can be read from the UI5 model with "" as name.
5
+ * OVP: the main model needs to be read from the sap.ovp config and then the service can be derived.
6
+ *
7
+ * @param manifest - application manifest
8
+ * @returns - main service name
9
+ */
10
+ export declare function getMainService(manifest: Manifest): string | undefined;
11
+ /**
12
+ * Return the service annotation specification for a specific app.
13
+ *
14
+ * @param manifestPath - path to manifest.json
15
+ * @param manifest - optionally, parsed content of manifest.json, pass to avoid reading it again.
16
+ * @returns - service and annotation specification
17
+ */
18
+ export declare function getServicesAndAnnotations(manifestPath: string, manifest: Manifest): Promise<{
19
+ [index: string]: ServiceSpecification;
20
+ }>;
21
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getServicesAndAnnotations = exports.getMainService = void 0;
13
+ const path_1 = require("path");
14
+ const file_1 = require("../file");
15
+ /**
16
+ * Get the main service name from the manifest.
17
+ * LROP: by definition the service name can be read from the UI5 model with "" as name.
18
+ * OVP: the main model needs to be read from the sap.ovp config and then the service can be derived.
19
+ *
20
+ * @param manifest - application manifest
21
+ * @returns - main service name
22
+ */
23
+ function getMainService(manifest) {
24
+ var _a, _b, _c, _d;
25
+ const model = typeof ((_a = manifest === null || manifest === void 0 ? void 0 : manifest['sap.ovp']) === null || _a === void 0 ? void 0 : _a.globalFilterModel) === 'string' ? manifest['sap.ovp'].globalFilterModel : '';
26
+ return typeof ((_d = (_c = (_b = manifest === null || manifest === void 0 ? void 0 : manifest['sap.ui5']) === null || _b === void 0 ? void 0 : _b.models) === null || _c === void 0 ? void 0 : _c[model]) === null || _d === void 0 ? void 0 : _d.dataSource) === 'string'
27
+ ? manifest['sap.ui5'].models[model].dataSource
28
+ : undefined;
29
+ }
30
+ exports.getMainService = getMainService;
31
+ /**
32
+ * Return the service annotation specification for a specific app.
33
+ *
34
+ * @param manifestPath - path to manifest.json
35
+ * @param manifest - optionally, parsed content of manifest.json, pass to avoid reading it again.
36
+ * @returns - service and annotation specification
37
+ */
38
+ function getServicesAndAnnotations(manifestPath, manifest) {
39
+ var _a, _b;
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ const parsedManifest = manifest !== null && manifest !== void 0 ? manifest : (yield (0, file_1.readJSON)(manifestPath));
42
+ const manifestFolder = (0, path_1.dirname)(manifestPath);
43
+ const services = {};
44
+ const dataSources = (_b = (_a = parsedManifest === null || parsedManifest === void 0 ? void 0 : parsedManifest['sap.app']) === null || _a === void 0 ? void 0 : _a.dataSources) !== null && _b !== void 0 ? _b : {};
45
+ for (const name in dataSources) {
46
+ if (dataSources[name].type !== 'OData') {
47
+ continue;
48
+ }
49
+ services[name] = getServiceSpecification(manifestFolder, name, dataSources);
50
+ }
51
+ return services;
52
+ });
53
+ }
54
+ exports.getServicesAndAnnotations = getServicesAndAnnotations;
55
+ /**
56
+ * Get the service specification for a given service.
57
+ *
58
+ * @param webappFolder - relative path to webapp folder from project root
59
+ * @param name - name of the service
60
+ * @param dataSources - dataSources from manifest
61
+ * @returns - service specification
62
+ */
63
+ function getServiceSpecification(webappFolder, name, dataSources) {
64
+ var _a, _b, _c, _d, _e;
65
+ const dataSource = dataSources[name];
66
+ const uri = dataSource.uri;
67
+ const local = typeof ((_a = dataSource.settings) === null || _a === void 0 ? void 0 : _a.localUri) === 'string'
68
+ ? (0, path_1.join)(webappFolder, dataSource.settings.localUri)
69
+ : '';
70
+ const odataVersion = (_c = (_b = dataSource.settings) === null || _b === void 0 ? void 0 : _b.odataVersion) !== null && _c !== void 0 ? _c : '2.0';
71
+ const annotations = [];
72
+ const annotationNames = (_d = dataSource.settings) === null || _d === void 0 ? void 0 : _d.annotations;
73
+ if (Array.isArray(annotationNames)) {
74
+ for (const annotationName of annotationNames) {
75
+ const annotation = dataSources[annotationName];
76
+ if (annotation) {
77
+ annotations.push({
78
+ uri: annotation.uri,
79
+ local: ((_e = annotation.settings) === null || _e === void 0 ? void 0 : _e.localUri) ? (0, path_1.join)(webappFolder, annotation.settings.localUri) : undefined
80
+ });
81
+ }
82
+ }
83
+ }
84
+ return {
85
+ uri,
86
+ local,
87
+ odataVersion,
88
+ annotations
89
+ };
90
+ }
91
+ //# sourceMappingURL=service.js.map
@@ -1,4 +1,77 @@
1
1
  import type { CapProjectType } from '../cap';
2
+ import type { ManifestNamespace } from '../webapp';
3
+ export interface Project {
4
+ /**
5
+ * Absolute path to the project root.
6
+ */
7
+ root: string;
8
+ /**
9
+ * Project type like 'EDMXBackend' | 'CAPJava' | 'CAPNodejs', see ProjectType.
10
+ */
11
+ projectType: ProjectType;
12
+ /**
13
+ * Applications in the project. For CAP projects the index is relative
14
+ * path to the app, like apps/myapp. For single app projects the index
15
+ * is an empty string ''.
16
+ */
17
+ apps: {
18
+ [index: string]: ApplicationStructure;
19
+ };
20
+ }
21
+ export interface ApplicationStructure {
22
+ /**
23
+ * Absolute path to the application root.
24
+ */
25
+ appRoot: string;
26
+ /**
27
+ * Absolute path to the manifest.json.
28
+ */
29
+ manifest: string;
30
+ /**
31
+ * Absolute path to the folder containing changes.
32
+ */
33
+ changes: string;
34
+ /**
35
+ * Absolute paths to i18n files.
36
+ */
37
+ i18n: I18nPropertiesPaths;
38
+ /**
39
+ * Main service of the application.
40
+ */
41
+ mainService?: string;
42
+ /**
43
+ * Service information with annotation references and local annotation files.
44
+ */
45
+ services: {
46
+ [index: string]: ServiceSpecification;
47
+ };
48
+ }
49
+ export interface I18nPropertiesPaths {
50
+ /**
51
+ * Absolute path to the i18n.properties file from sap.app namespace.
52
+ */
53
+ 'sap.app': string;
54
+ models: {
55
+ [modelKey: string]: {
56
+ /**
57
+ * Absolute path to the i18n.properties files.
58
+ */
59
+ path: string;
60
+ };
61
+ };
62
+ }
63
+ export interface ServiceSpecification {
64
+ uri?: string;
65
+ local?: string;
66
+ odataVersion?: ManifestNamespace.Setting['odataVersion'];
67
+ annotations?: {
68
+ uri?: string;
69
+ /**
70
+ * Absolute path to the local annotation file
71
+ */
72
+ local?: string;
73
+ }[];
74
+ }
2
75
  export type AppProgrammingLanguage = 'JavaScript' | 'TypeScript' | '';
3
76
  export type ProjectType = 'EDMXBackend' | CapProjectType;
4
77
  export type AppType = 'SAP Fiori elements' | 'SAPUI5 freestyle' | 'SAPUI5 Extension' | 'Fiori Reuse' | 'Fiori Adaptation';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sap-ux/project-access",
3
- "version": "1.16.2",
3
+ "version": "1.17.0",
4
4
  "description": "Library to access SAP Fiori tools projects",
5
5
  "repository": {
6
6
  "type": "git",