@sap-ux/adp-tooling 0.15.37 → 0.16.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.
Files changed (54) hide show
  1. package/dist/cf/app/discovery.d.ts +19 -0
  2. package/dist/cf/app/discovery.js +42 -0
  3. package/dist/cf/app/html5-repo.d.ts +36 -0
  4. package/dist/cf/app/html5-repo.js +137 -0
  5. package/dist/cf/app/index.d.ts +3 -0
  6. package/dist/cf/app/index.js +19 -0
  7. package/dist/cf/core/auth.d.ts +18 -0
  8. package/dist/cf/core/auth.js +38 -0
  9. package/dist/cf/core/config.d.ts +10 -0
  10. package/dist/cf/core/config.js +68 -0
  11. package/dist/cf/core/index.d.ts +3 -0
  12. package/dist/cf/core/index.js +19 -0
  13. package/dist/cf/index.d.ts +6 -0
  14. package/dist/cf/index.js +22 -0
  15. package/dist/cf/project/index.d.ts +4 -0
  16. package/dist/cf/project/index.js +20 -0
  17. package/dist/cf/project/mta.d.ts +57 -0
  18. package/dist/cf/project/mta.js +175 -0
  19. package/dist/cf/project/yaml-loader.d.ts +24 -0
  20. package/dist/cf/project/yaml-loader.js +54 -0
  21. package/dist/cf/project/yaml.d.ts +51 -0
  22. package/dist/cf/project/yaml.js +436 -0
  23. package/dist/cf/services/api.d.ts +65 -0
  24. package/dist/cf/services/api.js +291 -0
  25. package/dist/cf/services/cli.d.ts +31 -0
  26. package/dist/cf/services/cli.js +93 -0
  27. package/dist/cf/services/index.d.ts +3 -0
  28. package/dist/cf/services/index.js +19 -0
  29. package/dist/cf/utils/index.d.ts +2 -0
  30. package/dist/cf/utils/index.js +18 -0
  31. package/dist/cf/utils/validation.d.ts +37 -0
  32. package/dist/cf/utils/validation.js +134 -0
  33. package/dist/index.d.ts +2 -0
  34. package/dist/index.js +2 -0
  35. package/dist/source/manifest.d.ts +7 -0
  36. package/dist/source/manifest.js +10 -0
  37. package/dist/translations/adp-tooling.i18n.json +33 -0
  38. package/dist/types.d.ts +410 -1
  39. package/dist/types.js +15 -1
  40. package/dist/writer/cf.d.ts +14 -0
  41. package/dist/writer/cf.js +65 -0
  42. package/dist/writer/changes/writers/component-usages-writer.js +1 -1
  43. package/dist/writer/project-utils.d.ts +24 -1
  44. package/dist/writer/project-utils.js +104 -0
  45. package/dist/writer/writer-config.d.ts +8 -1
  46. package/dist/writer/writer-config.js +47 -0
  47. package/package.json +13 -8
  48. package/templates/cf/_gitignore +6 -0
  49. package/templates/cf/approuter/package.json +13 -0
  50. package/templates/cf/approuter/xs-app.json +15 -0
  51. package/templates/cf/i18n/i18n.properties +3 -0
  52. package/templates/cf/package.json +30 -0
  53. package/templates/cf/ui5.yaml +19 -0
  54. package/templates/cf/xs-security.json +7 -0
@@ -0,0 +1,175 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getApprouterType = getApprouterType;
37
+ exports.getModuleNames = getModuleNames;
38
+ exports.getServicesForFile = getServicesForFile;
39
+ exports.hasApprouter = hasApprouter;
40
+ exports.getMtaServices = getMtaServices;
41
+ exports.getResources = getResources;
42
+ exports.readMta = readMta;
43
+ const path = __importStar(require("node:path"));
44
+ const i18n_1 = require("../../i18n");
45
+ const yaml_1 = require("./yaml");
46
+ const yaml_loader_1 = require("./yaml-loader");
47
+ const cli_1 = require("../services/cli");
48
+ /**
49
+ * Get the approuter type.
50
+ *
51
+ * @param {string} mtaProjectPath - The path to the mta project.
52
+ * @returns {AppRouterType} The approuter type.
53
+ */
54
+ function getApprouterType(mtaProjectPath) {
55
+ const yamlContent = (0, yaml_loader_1.getYamlContent)(path.join(mtaProjectPath, 'mta.yaml'));
56
+ return (0, yaml_1.getRouterType)(yamlContent);
57
+ }
58
+ /**
59
+ * Get the module names.
60
+ *
61
+ * @param {string} mtaProjectPath - The path to the mta project.
62
+ * @returns {string[]} The module names.
63
+ */
64
+ function getModuleNames(mtaProjectPath) {
65
+ const yamlContent = (0, yaml_loader_1.getYamlContent)(path.join(mtaProjectPath, 'mta.yaml'));
66
+ return yamlContent?.modules?.map((module) => module.name) ?? [];
67
+ }
68
+ /**
69
+ * Get the services for the file.
70
+ *
71
+ * @param {string} mtaFilePath - The path to the mta file.
72
+ * @param {ToolsLogger} logger - The logger.
73
+ * @returns {BusinessServiceResource[]} The services.
74
+ */
75
+ function getServicesForFile(mtaFilePath, logger) {
76
+ const serviceNames = [];
77
+ const parsed = (0, yaml_loader_1.getYamlContent)(mtaFilePath);
78
+ if (parsed?.resources && Array.isArray(parsed.resources)) {
79
+ for (const resource of parsed.resources) {
80
+ const name = resource?.parameters?.['service-name'] ?? resource.name;
81
+ const label = resource?.parameters?.service;
82
+ if (name) {
83
+ serviceNames.push({ name, label });
84
+ if (!label) {
85
+ logger?.log(`Service '${name}' will be ignored without 'service' parameter`);
86
+ }
87
+ }
88
+ }
89
+ }
90
+ return serviceNames;
91
+ }
92
+ /**
93
+ * Check if the project has an approuter.
94
+ *
95
+ * @param {string} projectName - The project name.
96
+ * @param {string[]} moduleNames - The module names.
97
+ * @returns {boolean} Whether the project has an approuter.
98
+ */
99
+ function hasApprouter(projectName, moduleNames) {
100
+ return moduleNames.some((name) => name === `${projectName.toLowerCase()}-destination-content` ||
101
+ name === `${projectName.toLowerCase()}-approuter`);
102
+ }
103
+ /**
104
+ * Filter services based on the business services.
105
+ *
106
+ * @param {BusinessServiceResource[]} businessServices - The business services.
107
+ * @param {ToolsLogger} logger - The logger.
108
+ * @returns {Promise<string[]>} The filtered services.
109
+ */
110
+ async function filterServices(businessServices, logger) {
111
+ const serviceLabels = businessServices.map((service) => service.label).filter(Boolean);
112
+ if (serviceLabels.length === 0) {
113
+ throw new Error((0, i18n_1.t)('error.noBusinessServicesFound'));
114
+ }
115
+ const url = `/v3/service_offerings?names=${serviceLabels.join(',')}`;
116
+ const json = await (0, cli_1.requestCfApi)(url);
117
+ logger?.log(`Filtering services. Request to: ${url}, result: ${JSON.stringify(json)}`);
118
+ const businessServiceNames = new Set(businessServices.map((service) => service.label));
119
+ const result = [];
120
+ for (const resource of json?.resources ?? []) {
121
+ if (businessServiceNames.has(resource.name)) {
122
+ const sapService = resource?.['broker_catalog']?.metadata?.sapservice;
123
+ if (sapService && ['v2', 'v4'].includes(sapService?.odataversion ?? '')) {
124
+ result.push(businessServices?.find((service) => resource.name === service.label)?.name ?? '');
125
+ }
126
+ else {
127
+ logger?.log(`Service '${resource.name}' doesn't support V2/V4 Odata and will be ignored`);
128
+ }
129
+ }
130
+ }
131
+ if (result.length === 0) {
132
+ throw new Error((0, i18n_1.t)('error.noBusinessServicesFound'));
133
+ }
134
+ return result;
135
+ }
136
+ /**
137
+ * Get the services for the MTA project.
138
+ *
139
+ * @param {string} projectPath - The path to the project.
140
+ * @param {ToolsLogger} logger - The logger.
141
+ * @returns {Promise<string[]>} The services.
142
+ */
143
+ async function getMtaServices(projectPath, logger) {
144
+ const services = await readMta(projectPath, logger);
145
+ logger?.log(`Available services defined in mta.yaml: ${JSON.stringify(services)}`);
146
+ return services;
147
+ }
148
+ /**
149
+ * Get the resources for the MTA file.
150
+ *
151
+ * @param {string} mtaFilePath - The path to the mta file.
152
+ * @param {ToolsLogger} logger - The logger.
153
+ * @returns {Promise<string[]>} The resources.
154
+ */
155
+ async function getResources(mtaFilePath, logger) {
156
+ const servicesList = getServicesForFile(mtaFilePath, logger);
157
+ const oDataFilteredServices = await filterServices(servicesList, logger);
158
+ return oDataFilteredServices;
159
+ }
160
+ /**
161
+ * Read the MTA file.
162
+ *
163
+ * @param {string} projectPath - The path to the project.
164
+ * @param {ToolsLogger} logger - The logger.
165
+ * @returns {Promise<string[]>} The resources.
166
+ */
167
+ async function readMta(projectPath, logger) {
168
+ if (!projectPath) {
169
+ throw new Error((0, i18n_1.t)('error.mtaProjectPathMissing'));
170
+ }
171
+ const mtaFilePath = path.resolve(projectPath, 'mta.yaml');
172
+ const resources = await getResources(mtaFilePath, logger);
173
+ return resources;
174
+ }
175
+ //# sourceMappingURL=mta.js.map
@@ -0,0 +1,24 @@
1
+ import type { MtaYaml } from '../../types';
2
+ /**
3
+ * Parses the MTA file.
4
+ *
5
+ * @param {string} filePath - The file to parse.
6
+ * @returns {MtaYaml} The parsed YAML content.
7
+ */
8
+ export declare function getYamlContent<T = MtaYaml>(filePath: string): T;
9
+ /**
10
+ * Gets the project name from YAML content.
11
+ *
12
+ * @param {MtaYaml} yamlContent - The YAML content.
13
+ * @returns {string | null} The project name or null if not found.
14
+ */
15
+ export declare function getProjectName(yamlContent: MtaYaml): string | null;
16
+ /**
17
+ * Gets the project name for XS security from YAML content.
18
+ *
19
+ * @param {MtaYaml} yamlContent - The YAML content.
20
+ * @param {string} timestamp - The timestamp to append.
21
+ * @returns {string | null} The project name for XS security or null if not available.
22
+ */
23
+ export declare function getProjectNameForXsSecurity(yamlContent: MtaYaml, timestamp: string): string | undefined;
24
+ //# sourceMappingURL=yaml-loader.d.ts.map
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getYamlContent = getYamlContent;
7
+ exports.getProjectName = getProjectName;
8
+ exports.getProjectNameForXsSecurity = getProjectNameForXsSecurity;
9
+ const node_fs_1 = __importDefault(require("node:fs"));
10
+ const js_yaml_1 = __importDefault(require("js-yaml"));
11
+ /**
12
+ * Parses the MTA file.
13
+ *
14
+ * @param {string} filePath - The file to parse.
15
+ * @returns {MtaYaml} The parsed YAML content.
16
+ */
17
+ function getYamlContent(filePath) {
18
+ if (!node_fs_1.default.existsSync(filePath)) {
19
+ throw new Error(`Could not find file ${filePath}`);
20
+ }
21
+ const content = node_fs_1.default.readFileSync(filePath, 'utf-8');
22
+ let parsed;
23
+ try {
24
+ parsed = js_yaml_1.default.load(content);
25
+ return parsed;
26
+ }
27
+ catch (e) {
28
+ throw new Error(`Error parsing file ${filePath}: ${e.message}`);
29
+ }
30
+ }
31
+ /**
32
+ * Gets the project name from YAML content.
33
+ *
34
+ * @param {MtaYaml} yamlContent - The YAML content.
35
+ * @returns {string | null} The project name or null if not found.
36
+ */
37
+ function getProjectName(yamlContent) {
38
+ return yamlContent?.ID || null;
39
+ }
40
+ /**
41
+ * Gets the project name for XS security from YAML content.
42
+ *
43
+ * @param {MtaYaml} yamlContent - The YAML content.
44
+ * @param {string} timestamp - The timestamp to append.
45
+ * @returns {string | null} The project name for XS security or null if not available.
46
+ */
47
+ function getProjectNameForXsSecurity(yamlContent, timestamp) {
48
+ const projectName = getProjectName(yamlContent);
49
+ if (!projectName || !timestamp) {
50
+ return undefined;
51
+ }
52
+ return `${projectName.toLowerCase().replaceAll('.', '_')}_${timestamp}`;
53
+ }
54
+ //# sourceMappingURL=yaml-loader.js.map
@@ -0,0 +1,51 @@
1
+ import type { Editor } from 'mem-fs-editor';
2
+ import type { ToolsLogger } from '@sap-ux/logger';
3
+ import type { AppParamsExtended, MtaYaml } from '../../types';
4
+ import { AppRouterType } from '../../types';
5
+ interface AdjustMtaYamlParams {
6
+ projectPath: string;
7
+ moduleName: string;
8
+ appRouterType: AppRouterType;
9
+ businessSolutionName: string;
10
+ businessService: string;
11
+ spaceGuid: string;
12
+ }
13
+ /**
14
+ * Checks if the selected path is a MTA project.
15
+ *
16
+ * @param {string} selectedPath - The selected path.
17
+ * @returns {boolean} True if the selected path is a MTA project, false otherwise.
18
+ */
19
+ export declare function isMtaProject(selectedPath: string): boolean;
20
+ /**
21
+ * Gets the SAP Cloud Service.
22
+ *
23
+ * @param {MtaYaml} yamlContent - The YAML content.
24
+ * @returns {string} The SAP Cloud Service.
25
+ */
26
+ export declare function getSAPCloudService(yamlContent: MtaYaml): string;
27
+ /**
28
+ * Gets the router type.
29
+ *
30
+ * @param {MtaYaml} yamlContent - The YAML content.
31
+ * @returns {AppRouterType} The router type.
32
+ */
33
+ export declare function getRouterType(yamlContent: MtaYaml): AppRouterType;
34
+ /**
35
+ * Gets the app params from the UI5 YAML file.
36
+ *
37
+ * @param {string} projectPath - The project path.
38
+ * @returns {AppParamsExtended} The app params.
39
+ */
40
+ export declare function getAppParamsFromUI5Yaml(projectPath: string): AppParamsExtended;
41
+ /**
42
+ * Adjusts the MTA YAML.
43
+ *
44
+ * @param {AdjustMtaYamlParams} params - The parameters.
45
+ * @param {Editor} memFs - The mem-fs editor instance.
46
+ * @param {ToolsLogger} logger - The logger.
47
+ * @returns {Promise<void>} The promise.
48
+ */
49
+ export declare function adjustMtaYaml({ projectPath, moduleName, appRouterType, businessSolutionName, businessService, spaceGuid }: AdjustMtaYamlParams, memFs: Editor, logger?: ToolsLogger): Promise<void>;
50
+ export {};
51
+ //# sourceMappingURL=yaml.d.ts.map