@sap-ux/fe-fpm-writer 0.18.7 → 0.18.9

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.
@@ -19,10 +19,10 @@ const semver_1 = require("semver");
19
19
  */
20
20
  function getManifestRoot(ui5Version) {
21
21
  const minVersion = (0, semver_1.coerce)(ui5Version);
22
- if (!minVersion || minVersion.minor >= 86) {
22
+ if (!minVersion || (0, semver_1.gte)(minVersion, '1.86.0')) {
23
23
  return (0, templates_1.getTemplatePath)('/column/1.86');
24
24
  }
25
- else if (minVersion.minor >= 85) {
25
+ else if ((0, semver_1.gte)(minVersion, '1.85.0')) {
26
26
  return (0, templates_1.getTemplatePath)('/column/1.85');
27
27
  }
28
28
  else {
@@ -13,7 +13,7 @@ const semver_1 = require("semver");
13
13
  */
14
14
  function validateVersion(ui5Version) {
15
15
  const minVersion = (0, semver_1.coerce)(ui5Version);
16
- if (minVersion && minVersion.minor < 84) {
16
+ if (minVersion && (0, semver_1.lt)(minVersion, '1.84.0')) {
17
17
  throw new Error('SAP Fiori elements for OData v4 is only supported starting with SAPUI5 1.84.');
18
18
  }
19
19
  return true;
@@ -1,6 +1,6 @@
1
1
  import type { Editor } from 'mem-fs-editor';
2
2
  import type { ManifestNamespace } from '@sap-ux/project-access';
3
- import type { CustomPage, FCL, InternalCustomPage, InternalObjectPage, ObjectPage, ListReport, Navigation, InternalListReport } from './types';
3
+ import type { CustomPage, FCL, FpmPage, InternalCustomPage, InternalObjectPage, ObjectPage, ListReport, Navigation, InternalListReport } from './types';
4
4
  import type { Manifest } from '../common/types';
5
5
  type EnhancePageConfigFunction = (data: ObjectPage | ListReport, manifest: Manifest) => InternalObjectPage | InternalListReport;
6
6
  /**
@@ -41,6 +41,14 @@ export declare function getManifestJsonExtensionHelper(config: InternalCustomPag
41
41
  * @returns fcl configuration
42
42
  */
43
43
  export declare function getFclConfig(manifest: Manifest, navigation?: Navigation): FCL;
44
+ /**
45
+ * Create target settings for a Fiori elements page.
46
+ *
47
+ * @param data - incoming configuration
48
+ * @param addSettings - optional arbitrary settings
49
+ * @returns version aware settings object
50
+ */
51
+ export declare function initializeTargetSettings(data: FpmPage, addSettings?: Record<string, unknown>): Record<string, unknown>;
44
52
  /**
45
53
  * Validate the input parameters for the generation of a custom or an object page.
46
54
  *
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.extendPageJSON = exports.validatePageConfig = exports.getFclConfig = exports.getManifestJsonExtensionHelper = exports.generateRouteTarget = exports.generateRoutePattern = exports.PATTERN_SUFFIX = void 0;
3
+ exports.extendPageJSON = exports.validatePageConfig = exports.initializeTargetSettings = exports.getFclConfig = exports.getManifestJsonExtensionHelper = exports.generateRouteTarget = exports.generateRoutePattern = exports.PATTERN_SUFFIX = void 0;
4
4
  const mem_fs_1 = require("mem-fs");
5
5
  const mem_fs_editor_1 = require("mem-fs-editor");
6
6
  const path_1 = require("path");
@@ -9,6 +9,7 @@ const validate_1 = require("../common/validate");
9
9
  const defaults_1 = require("../common/defaults");
10
10
  const file_1 = require("../common/file");
11
11
  const templates_1 = require("../templates");
12
+ const semver_1 = require("semver");
12
13
  /**
13
14
  * Suffix for patterns to support arbitrary paramters
14
15
  */
@@ -124,6 +125,28 @@ function getFclConfig(manifest, navigation) {
124
125
  return config;
125
126
  }
126
127
  exports.getFclConfig = getFclConfig;
128
+ /**
129
+ * Create target settings for a Fiori elements page.
130
+ *
131
+ * @param data - incoming configuration
132
+ * @param addSettings - optional arbitrary settings
133
+ * @returns version aware settings object
134
+ */
135
+ function initializeTargetSettings(data, addSettings) {
136
+ var _a, _b;
137
+ const settings = addSettings ? Object.assign({}, addSettings) : {};
138
+ (_a = settings.navigation) !== null && _a !== void 0 ? _a : (settings.navigation = {});
139
+ // starting with UI5 v1.94.0, contextPath is the preferred setting
140
+ const minVersion = (0, semver_1.coerce)(data.minUI5Version);
141
+ if (!minVersion || (0, semver_1.gte)(minVersion, '1.94.0')) {
142
+ settings.contextPath = (_b = data.contextPath) !== null && _b !== void 0 ? _b : `/${data.entity}`;
143
+ }
144
+ else {
145
+ settings.entitySet = data.entity;
146
+ }
147
+ return settings;
148
+ }
149
+ exports.initializeTargetSettings = initializeTargetSettings;
127
150
  /**
128
151
  * Validate the input parameters for the generation of a custom or an object page.
129
152
  *
@@ -24,6 +24,7 @@ function enhanceData(data, manifestPath, fs) {
24
24
  const manifest = fs.readJSON(manifestPath);
25
25
  // set common defaults
26
26
  const config = (0, defaults_1.setCommonDefaults)(data, manifestPath, manifest);
27
+ config.settings = (0, common_1.initializeTargetSettings)(data);
27
28
  // set FCL configuration
28
29
  const fclConfig = (0, common_1.getFclConfig)(manifest, config.navigation);
29
30
  config.fcl = fclConfig.fcl;
@@ -44,7 +45,7 @@ exports.enhanceData = enhanceData;
44
45
  */
45
46
  function getTemplateRoot(ui5Version) {
46
47
  const minVersion = (0, semver_1.coerce)(ui5Version);
47
- if (!minVersion || minVersion.minor >= 94) {
48
+ if (!minVersion || (0, semver_1.gte)(minVersion, '1.94.0')) {
48
49
  return (0, templates_1.getTemplatePath)('/page/custom/1.94');
49
50
  }
50
51
  else {
package/dist/page/list.js CHANGED
@@ -11,21 +11,18 @@ const common_1 = require("./common");
11
11
  */
12
12
  function enhanceData(data, manifest) {
13
13
  var _a, _b;
14
- const config = Object.assign(Object.assign(Object.assign({ settings: {} }, data), { name: 'ListReport' }), (0, common_1.getFclConfig)(manifest));
15
- // move settings into correct possition in the manifest
16
- config.settings.entitySet = data.entity;
17
- config.settings.navigation = {};
14
+ var _c;
15
+ const config = Object.assign(Object.assign(Object.assign({}, data), { settings: (0, common_1.initializeTargetSettings)(data, data.settings), name: 'ListReport' }), (0, common_1.getFclConfig)(manifest));
18
16
  // use standard file name if i18n enhancement required
19
17
  if (config.settings.enhanceI18n === true) {
20
18
  config.settings.enhanceI18n = `i18n/custom${config.entity}${config.name}.properties`;
21
19
  }
22
20
  // move table settings into the correct structure
23
21
  if (config.settings.tableSettings) {
24
- config.settings.controlConfiguration = (_a = config.settings.controlConfiguration) !== null && _a !== void 0 ? _a : {};
25
- config.settings.controlConfiguration['@com.sap.vocabularies.UI.v1.LineItem'] =
26
- (_b = config.settings.controlConfiguration['@com.sap.vocabularies.UI.v1.LineItem']) !== null && _b !== void 0 ? _b : {};
27
- config.settings.controlConfiguration['@com.sap.vocabularies.UI.v1.LineItem'].tableSettings =
28
- config.settings.tableSettings;
22
+ (_a = (_c = config.settings).controlConfiguration) !== null && _a !== void 0 ? _a : (_c.controlConfiguration = {});
23
+ const controlConfig = config.settings.controlConfiguration;
24
+ (_b = controlConfig['@com.sap.vocabularies.UI.v1.LineItem']) !== null && _b !== void 0 ? _b : (controlConfig['@com.sap.vocabularies.UI.v1.LineItem'] = {});
25
+ controlConfig['@com.sap.vocabularies.UI.v1.LineItem'].tableSettings = config.settings.tableSettings;
29
26
  delete config.settings.tableSettings;
30
27
  }
31
28
  return config;
@@ -10,10 +10,7 @@ const common_1 = require("./common");
10
10
  * @returns enhanced configuration
11
11
  */
12
12
  function enhanceData(data, manifest) {
13
- const config = Object.assign(Object.assign(Object.assign({ settings: {} }, data), { name: 'ObjectPage' }), (0, common_1.getFclConfig)(manifest));
14
- // move settings into correct possition in the manifest
15
- config.settings.entitySet = data.entity;
16
- config.settings.navigation = {};
13
+ const config = Object.assign(Object.assign(Object.assign({}, data), { settings: (0, common_1.initializeTargetSettings)(data, data.settings), name: 'ObjectPage' }), (0, common_1.getFclConfig)(manifest));
17
14
  // use standard file name if i18n enhancement required
18
15
  if (config.settings.enhanceI18n === true) {
19
16
  config.settings.enhanceI18n = `i18n/custom${config.entity}${config.name}.properties`;
@@ -16,28 +16,43 @@ export interface Navigation {
16
16
  */
17
17
  navKey?: boolean;
18
18
  }
19
- export interface StandardPageSettings {
19
+ export type StandardPageSettings = {
20
20
  enhanceI18n?: string | true;
21
21
  variantManagement?: 'Page' | 'None';
22
- }
22
+ };
23
23
  /**
24
24
  * Support list of settings for a ListReport page
25
25
  */
26
- export interface ListReportSettings extends StandardPageSettings {
26
+ export type ListReportSettings = StandardPageSettings & {
27
27
  tableSettings?: {
28
28
  type?: 'ResponsiveTable' | 'GridTable';
29
29
  selectionMode?: 'None' | 'Single' | 'Multi' | 'Auto';
30
30
  condensedTableLayout?: boolean;
31
31
  };
32
- }
32
+ };
33
33
  /**
34
- * Configuration options for adding a list report page.
34
+ * Common settings for any page supporting the Fiori elements flexible programming model.
35
35
  */
36
- export interface ListReport extends WriterConfig {
36
+ export interface FpmPage {
37
37
  /**
38
38
  * Name of the entity used for the custom page.
39
39
  */
40
40
  entity: string;
41
+ /**
42
+ * With template or UI5 version 1.94 you can alternatively specify a contextPath that shall be inserted as page option, instead of the entitySet.
43
+ */
44
+ contextPath?: string;
45
+ /**
46
+ * Optional property to define the minimum UI5 version that the generated code must support.
47
+ * If undefined then the latest version of the template is used.
48
+ * If nothing can be generated for the given version then an exception is thrown.
49
+ */
50
+ minUI5Version?: string;
51
+ }
52
+ /**
53
+ * Configuration options for adding a list report page.
54
+ */
55
+ export interface ListReport extends FpmPage, WriterConfig {
41
56
  /**
42
57
  * Optional settings for the ListReport page
43
58
  */
@@ -46,11 +61,7 @@ export interface ListReport extends WriterConfig {
46
61
  /**
47
62
  * Configuration options for adding an object page.
48
63
  */
49
- export interface ObjectPage extends WriterConfig {
50
- /**
51
- * Name of the entity used for the custom page.
52
- */
53
- entity: string;
64
+ export interface ObjectPage extends FpmPage, WriterConfig {
54
65
  /**
55
66
  * Optional settings for the object page
56
67
  */
@@ -63,11 +74,7 @@ export interface ObjectPage extends WriterConfig {
63
74
  /**
64
75
  * Configuration options for adding a custom page.
65
76
  */
66
- export interface CustomPage extends CustomElement {
67
- /**
68
- * Name of the entity used for the custom page.
69
- */
70
- entity: string;
77
+ export interface CustomPage extends FpmPage, CustomElement {
71
78
  /**
72
79
  * Optional incoming navigation configuration. If provided then a navigation configuration is added to an existing page navigating to this custom page.
73
80
  */
@@ -98,17 +105,21 @@ export interface FCL {
98
105
  */
99
106
  controlAggregation?: 'beginColumnPages' | 'midColumnPages' | 'endColumnPages';
100
107
  }
108
+ /**
109
+ * Common settings for Fiori elements pages
110
+ */
111
+ export type InternalFpmPage = FCL & {
112
+ settings: Record<string, unknown | undefined>;
113
+ };
101
114
  /**
102
115
  * Additional internal configuration options that will be calculated based on the provided input as well as the target application.
103
116
  */
104
- export type InternalCustomPage = CustomPage & InternalCustomElement & FCL;
105
- export type InternalListReport = ListReport & FCL & {
117
+ export type InternalCustomPage = CustomPage & InternalFpmPage & InternalCustomElement;
118
+ export type InternalListReport = ListReport & InternalFpmPage & {
106
119
  name: 'ListReport';
107
120
  navigation?: Navigation;
108
- settings: any;
109
121
  };
110
- export type InternalObjectPage = ObjectPage & FCL & {
122
+ export type InternalObjectPage = ObjectPage & InternalFpmPage & {
111
123
  name: 'ObjectPage';
112
- settings: any;
113
124
  };
114
125
  //# sourceMappingURL=types.d.ts.map
@@ -19,7 +19,7 @@ const semver_1 = require("semver");
19
19
  */
20
20
  function getManifestRoot(ui5Version) {
21
21
  const minVersion = (0, semver_1.coerce)(ui5Version);
22
- if (!minVersion || minVersion.minor >= 86) {
22
+ if (!minVersion || (0, semver_1.gte)(minVersion, '1.86.0')) {
23
23
  return (0, templates_1.getTemplatePath)('/section/1.86');
24
24
  }
25
25
  else {
@@ -35,7 +35,7 @@ exports.getManifestRoot = getManifestRoot;
35
35
  */
36
36
  function getAdditionalDependencies(ui5Version) {
37
37
  const minVersion = (0, semver_1.coerce)(ui5Version);
38
- return !minVersion || minVersion.minor >= 90 ? { 'xmlns:macros': 'sap.fe.macros' } : undefined;
38
+ return !minVersion || (0, semver_1.gte)(minVersion, '1.90.0') ? { 'xmlns:macros': 'sap.fe.macros' } : undefined;
39
39
  }
40
40
  /**
41
41
  * Enhances the provided custom section configuration with additonal data.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sap-ux/fe-fpm-writer",
3
3
  "description": "SAP Fiori elements flexible programming model writer",
4
- "version": "0.18.7",
4
+ "version": "0.18.9",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "https://github.com/SAP/open-ux-tools.git",
@@ -29,7 +29,7 @@
29
29
  "xpath": "0.0.32"
30
30
  },
31
31
  "devDependencies": {
32
- "@sap-ux/project-access": "1.1.3",
32
+ "@sap-ux/project-access": "1.3.1",
33
33
  "@types/ejs": "3.1.0",
34
34
  "@types/mem-fs": "1.1.2",
35
35
  "@types/mem-fs-editor": "7.0.1",
@@ -21,7 +21,7 @@ export default class <%- name %> extends Controller {
21
21
  */
22
22
  // public onBeforeRendering(): void {
23
23
  //
24
- // },
24
+ // }
25
25
 
26
26
  /**
27
27
  * Called when the View has been rendered (so its HTML is part of the document). Post-rendering manipulations of the HTML could be done here.
@@ -30,7 +30,7 @@ export default class <%- name %> extends Controller {
30
30
  */
31
31
  // public onAfterRendering(): void {
32
32
  //
33
- // },
33
+ // }
34
34
 
35
35
  /**
36
36
  * Called when the Controller is destroyed. Use this one to free resources and finalize activities.
@@ -7,10 +7,7 @@
7
7
  "viewName": "<%- ns %>.<%- name %>",<%if (locals.controlAggregation) {%>
8
8
  "controlAggregation": "<%- locals.controlAggregation %>",<% } %>
9
9
  "options": {
10
- "settings": {
11
- "entitySet": "<%- entity %>",
12
- "navigation": { }
13
- }
10
+ "settings": <%- JSON.stringify(settings) %>
14
11
  }
15
12
  }<%if (locals.navigation) {%>,
16
13
  "<%- navigation.sourcePage %>": {
@@ -21,7 +21,7 @@ export default class <%- name %> extends Controller {
21
21
  */
22
22
  // public onBeforeRendering(): void {
23
23
  //
24
- // },
24
+ // }
25
25
 
26
26
  /**
27
27
  * Called when the View has been rendered (so its HTML is part of the document). Post-rendering manipulations of the HTML could be done here.
@@ -30,7 +30,7 @@ export default class <%- name %> extends Controller {
30
30
  */
31
31
  // public onAfterRendering(): void {
32
32
  //
33
- // },
33
+ // }
34
34
 
35
35
  /**
36
36
  * Called when the Controller is destroyed. Use this one to free resources and finalize activities.
@@ -8,11 +8,7 @@
8
8
  "name": "sap.fe.core.fpm",<%if (locals.controlAggregation) {%>
9
9
  "controlAggregation": "<%- locals.controlAggregation %>",<% } %>
10
10
  "options": {
11
- "settings": {
12
- "viewName": "<%- ns %>.<%- name %>",
13
- "entitySet": "<%- entity %>",
14
- "navigation": { }
15
- }
11
+ "settings": <%- JSON.stringify({ ...settings, viewName: `${ns}.${name}`}) %>
16
12
  }
17
13
  }<%if (locals.navigation) {%>,
18
14
  "<%- navigation.sourcePage %>": {