@sap-ux/fiori-elements-writer 2.0.8 → 2.1.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.
@@ -37,6 +37,14 @@ type TemplateAttributes = {
37
37
  minimumUi5Version: {
38
38
  [V in OdataVersion]?: string;
39
39
  };
40
+ /**
41
+ * Checks whether annotations can be generated for a given template type and OData version.
42
+ * Annotation generation is supported for template types: lrop, worklist, or formEntryObject
43
+ * when using OData version 4.
44
+ */
45
+ annotationGenerationSupport?: {
46
+ [V in OdataVersion]?: boolean;
47
+ };
40
48
  };
41
49
  };
42
50
  export declare const TemplateTypeAttributes: TemplateAttributes;
@@ -116,6 +116,9 @@ exports.TemplateTypeAttributes = {
116
116
  minimumUi5Version: {
117
117
  [types_1.OdataVersion.v2]: exports.minSupportedUI5Version,
118
118
  [types_1.OdataVersion.v4]: '1.99.0'
119
+ },
120
+ annotationGenerationSupport: {
121
+ [types_1.OdataVersion.v4]: true
119
122
  }
120
123
  },
121
124
  [types_1.TemplateType.ListReportObjectPage]: {
@@ -123,6 +126,9 @@ exports.TemplateTypeAttributes = {
123
126
  minimumUi5Version: {
124
127
  [types_1.OdataVersion.v2]: exports.minSupportedUI5Version,
125
128
  [types_1.OdataVersion.v4]: '1.84.0'
129
+ },
130
+ annotationGenerationSupport: {
131
+ [types_1.OdataVersion.v4]: true
126
132
  }
127
133
  },
128
134
  [types_1.TemplateType.AnalyticalListPage]: {
@@ -143,6 +149,9 @@ exports.TemplateTypeAttributes = {
143
149
  supportedODataVersions: [types_1.OdataVersion.v4],
144
150
  minimumUi5Version: {
145
151
  [types_1.OdataVersion.v4]: '1.90.0'
152
+ },
153
+ annotationGenerationSupport: {
154
+ [types_1.OdataVersion.v4]: true
146
155
  }
147
156
  },
148
157
  [types_1.TemplateType.FlexibleProgrammingModel]: {
package/dist/index.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { Editor } from 'mem-fs-editor';
2
2
  import type { App } from '@sap-ux/ui5-application-writer';
3
3
  import type { FioriElementsApp } from './types';
4
4
  import { TemplateTypeAttributes, minSupportedUI5Version, minSupportedUI5VersionV4 } from './data/templateAttributes';
5
+ import type { Logger } from '@sap-ux/logger';
5
6
  export declare const V2_FE_TYPES_AVAILABLE = "1.108.0";
6
7
  /**
7
8
  * Generate a UI5 application based on the specified Fiori Elements floorplan template.
@@ -9,9 +10,10 @@ export declare const V2_FE_TYPES_AVAILABLE = "1.108.0";
9
10
  * @param basePath - the absolute target path where the application will be generated
10
11
  * @param data - configuration to generate the Fiori elements application
11
12
  * @param fs - an optional reference to a mem-fs editor
13
+ * @param log - optional logger instance
12
14
  * @returns Reference to a mem-fs-editor
13
15
  */
14
- declare function generate<T extends {}>(basePath: string, data: FioriElementsApp<T>, fs?: Editor): Promise<Editor>;
16
+ declare function generate<T extends {}>(basePath: string, data: FioriElementsApp<T>, fs?: Editor, log?: Logger): Promise<Editor>;
15
17
  export { generate, FioriElementsApp, App, TemplateTypeAttributes, minSupportedUI5Version, minSupportedUI5VersionV4 };
16
18
  export * from './types';
17
19
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -38,6 +38,7 @@ const i18n_1 = require("./i18n");
38
38
  const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
39
39
  const fpmConfig_1 = require("./fpmConfig");
40
40
  const cap_config_writer_1 = require("@sap-ux/cap-config-writer");
41
+ const writeAnnotations_1 = require("./writeAnnotations");
41
42
  exports.V2_FE_TYPES_AVAILABLE = '1.108.0';
42
43
  /**
43
44
  * Get TypeScript Ignore Glob Pattern.
@@ -73,9 +74,10 @@ function getTypeScriptIgnoreGlob(feApp, coercedUI5Version) {
73
74
  * @param basePath - the absolute target path where the application will be generated
74
75
  * @param data - configuration to generate the Fiori elements application
75
76
  * @param fs - an optional reference to a mem-fs editor
77
+ * @param log - optional logger instance
76
78
  * @returns Reference to a mem-fs-editor
77
79
  */
78
- async function generate(basePath, data, fs) {
80
+ async function generate(basePath, data, fs, log) {
79
81
  // Load i18n translations asynchronously to ensure proper initialization.
80
82
  // This addresses occasional issues where i18n is not initialized in time, causing tests to fail.
81
83
  await (0, i18n_1.initI18n)();
@@ -192,6 +194,9 @@ async function generate(basePath, data, fs) {
192
194
  // apply cap updates when service is cap
193
195
  await (0, cap_config_writer_1.applyCAPUpdates)(fs, feApp.service.capService, settings);
194
196
  }
197
+ if (feApp.appOptions?.addAnnotations) {
198
+ await (0, writeAnnotations_1.writeAnnotations)(basePath, feApp, fs, log);
199
+ }
195
200
  return fs;
196
201
  }
197
202
  __exportStar(require("./types"), exports);
@@ -2,6 +2,9 @@
2
2
  "info": {
3
3
  "mockOnlyWarning": "This application was generated with a local metadata file and does not reference a live server. Please add the required server configuration or start this application with mock data using the target: npm run start-mock"
4
4
  },
5
+ "warn": {
6
+ "invalidTypeForAnnotationGeneration": "The provided option addAnnotations is not supported for the specified template '{{ templateType }}' and odata version '{{ odataVersion }}'. Generation will continue but additional annotations will not added."
7
+ },
5
8
  "error": {
6
9
  "unsupportedOdataVersion": "OData Version of the specified service: {{ serviceVersion }}, is not supported by the template type: {{ templateType }}",
7
10
  "unsupportedUI5Version": "Specified UI5 property '{{ versionProperty }}': {{ ui5Version }}, is not supported by the template type: {{ templateType }}. Please specify {{minRequiredUI5Version}} or above.",
package/dist/types.d.ts CHANGED
@@ -100,6 +100,11 @@ export interface FioriElementsApp<T> extends Ui5App {
100
100
  * This will eventually move up to {@link Ui5App.appOptions}
101
101
  */
102
102
  addTests?: boolean;
103
+ /**
104
+ * If addAnnotations is true, annotations are enabled.
105
+ * However, annotations will only be written if the template type is lrop, worklist, or formEntryObject; annotation generation is unspported for other project types.
106
+ */
107
+ addAnnotations?: boolean;
103
108
  };
104
109
  }
105
110
  export { OdataVersion } from '@sap-ux/odata-service-writer';
@@ -0,0 +1,13 @@
1
+ import { type FioriElementsApp } from './types';
2
+ import type { Editor } from 'mem-fs-editor';
3
+ import type { Logger } from '@sap-ux/logger';
4
+ /**
5
+ * Writes annotation files for the given application configuration.
6
+ *
7
+ * @param basePath - The base directory path of the project.
8
+ * @param feApp - to generate the Fiori elements application
9
+ * @param fs - The file system editor instance.
10
+ * @param log - The logger instance.
11
+ */
12
+ export declare function writeAnnotations<T extends {}>(basePath: string, feApp: FioriElementsApp<T>, fs: Editor, log?: Logger): Promise<void>;
13
+ //# sourceMappingURL=writeAnnotations.d.ts.map
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeAnnotations = writeAnnotations;
4
+ const path_1 = require("path");
5
+ const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
6
+ const types_1 = require("./types");
7
+ const annotation_generator_1 = require("@sap-ux/annotation-generator");
8
+ const templateAttributes_1 = require("./data/templateAttributes");
9
+ const i18n_1 = require("./i18n");
10
+ /**
11
+ * Generates the annotation file path based on whether the CAP service is available.
12
+ *
13
+ * @param {string} [appName] - The name of the application.
14
+ * @param {CapServiceCdsInfo} [capService] - The CAP service info.
15
+ * @returns {string} The annotation file path based on whether the CAP service is available.
16
+ */
17
+ function getAnnotationFilePath(appName, capService) {
18
+ if (capService) {
19
+ const appPath = capService.appPath ?? (0, fiori_generator_shared_1.getCapFolderPathsSync)(capService.projectPath).app;
20
+ return `${appPath}${path_1.sep}${appName}${path_1.sep}annotations.cds`;
21
+ }
22
+ return `webapp${path_1.sep}annotations${path_1.sep}annotation.xml`;
23
+ }
24
+ /**
25
+ * Writes annotation files for the given application configuration.
26
+ *
27
+ * @param basePath - The base directory path of the project.
28
+ * @param feApp - to generate the Fiori elements application
29
+ * @param fs - The file system editor instance.
30
+ * @param log - The logger instance.
31
+ */
32
+ async function writeAnnotations(basePath, feApp, fs, log) {
33
+ if (templateAttributes_1.TemplateTypeAttributes[feApp.template.type]?.annotationGenerationSupport?.[feApp.service.version]) {
34
+ const { settings } = feApp.template;
35
+ const { capService } = feApp.service;
36
+ const { name: packageName } = feApp.package ?? {};
37
+ const entitySetName = settings?.entityConfig?.mainEntityName ?? '';
38
+ const addLineItems = feApp.template.type === types_1.TemplateType.ListReportObjectPage || feApp.template.type === types_1.TemplateType.Worklist;
39
+ let serviceName = 'mainService';
40
+ let projectPath = basePath;
41
+ if (capService) {
42
+ serviceName = capService.serviceName;
43
+ projectPath = capService.projectPath;
44
+ }
45
+ const options = {
46
+ entitySetName: entitySetName,
47
+ annotationFilePath: getAnnotationFilePath(packageName, capService),
48
+ addFacets: true,
49
+ addLineItems,
50
+ addValueHelps: !!capService
51
+ };
52
+ const serviceParameters = {
53
+ serviceName,
54
+ appName: packageName,
55
+ project: projectPath
56
+ };
57
+ await (0, annotation_generator_1.generateAnnotations)(fs, serviceParameters, options);
58
+ }
59
+ else {
60
+ log?.warn((0, i18n_1.t)('warn.invalidTypeForAnnotationGeneration', {
61
+ templateType: feApp.template.type,
62
+ odataVersion: feApp.service.version
63
+ }));
64
+ }
65
+ }
66
+ //# sourceMappingURL=writeAnnotations.js.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/fiori-elements-writer",
3
3
  "description": "SAP Fiori elements application writer",
4
- "version": "2.0.8",
4
+ "version": "2.1.0",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -29,11 +29,13 @@
29
29
  "semver": "7.5.4",
30
30
  "@sap-ux/odata-service-writer": "0.25.5",
31
31
  "@sap-ux/ui5-application-writer": "1.2.9",
32
- "@sap-ux/fe-fpm-writer": "0.32.2",
32
+ "@sap-ux/fe-fpm-writer": "0.32.3",
33
33
  "@sap-ux/ui5-config": "0.26.1",
34
34
  "@sap-ux/ui5-test-writer": "0.4.1",
35
- "@sap-ux/fiori-generator-shared": "0.7.23",
36
- "@sap-ux/cap-config-writer": "0.9.2"
35
+ "@sap-ux/fiori-generator-shared": "0.7.25",
36
+ "@sap-ux/cap-config-writer": "0.9.4",
37
+ "@sap-ux/annotation-generator": "0.3.3",
38
+ "@sap-ux/logger": "0.6.0"
37
39
  },
38
40
  "devDependencies": {
39
41
  "@types/ejs": "3.1.2",