@sap-ux/fe-fpm-writer 0.18.6 → 0.18.8
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/column/index.js +2 -2
- package/dist/common/validate.js +1 -1
- package/dist/controller-extension/index.js +5 -0
- package/dist/page/common.d.ts +9 -1
- package/dist/page/common.js +24 -1
- package/dist/page/custom.js +2 -1
- package/dist/page/list.js +6 -9
- package/dist/page/object.js +1 -4
- package/dist/page/types.d.ts +32 -21
- package/dist/section/index.js +2 -2
- package/package.json +2 -2
- package/templates/controller-extension/Controller.ts +6 -17
- package/templates/controller-extension/ControllerExtension.d.ts +11 -0
- package/templates/page/custom/1.84/manifest.json +1 -4
- package/templates/page/custom/1.94/manifest.json +1 -5
package/dist/column/index.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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 {
|
package/dist/common/validate.js
CHANGED
|
@@ -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.
|
|
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;
|
|
@@ -198,6 +198,11 @@ function generateControllerExtension(basePath, controllerConfig, fs) {
|
|
|
198
198
|
}
|
|
199
199
|
if (controllerConfig.typescript) {
|
|
200
200
|
(0, utils_1.addExtensionTypes)(basePath, controllerConfig.minUI5Version, fs);
|
|
201
|
+
// Typescript - add declaration ts file for 'sap/ui/core/mvc/ControllerExtension', which allows access to `this.base.getExtensionAPI()` within Controller extension classes
|
|
202
|
+
const declarationFilePath = (0, path_1.join)(basePath, '/webapp/ext/controller/ControllerExtension.d.ts');
|
|
203
|
+
if (!fs.exists(declarationFilePath)) {
|
|
204
|
+
fs.copy((0, templates_1.getTemplatePath)('controller-extension/ControllerExtension.d.ts'), declarationFilePath);
|
|
205
|
+
}
|
|
201
206
|
}
|
|
202
207
|
return fs;
|
|
203
208
|
}
|
package/dist/page/common.d.ts
CHANGED
|
@@ -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
|
*
|
package/dist/page/common.js
CHANGED
|
@@ -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
|
*
|
package/dist/page/custom.js
CHANGED
|
@@ -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.
|
|
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
|
-
|
|
15
|
-
|
|
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
|
-
|
|
25
|
-
config.settings.controlConfiguration
|
|
26
|
-
|
|
27
|
-
|
|
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;
|
package/dist/page/object.js
CHANGED
|
@@ -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:
|
|
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`;
|
package/dist/page/types.d.ts
CHANGED
|
@@ -16,28 +16,43 @@ export interface Navigation {
|
|
|
16
16
|
*/
|
|
17
17
|
navKey?: boolean;
|
|
18
18
|
}
|
|
19
|
-
export
|
|
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
|
|
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
|
-
*
|
|
34
|
+
* Common settings for any page supporting the Fiori elements flexible programming model.
|
|
35
35
|
*/
|
|
36
|
-
export interface
|
|
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 &
|
|
105
|
-
export type InternalListReport = ListReport &
|
|
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 &
|
|
122
|
+
export type InternalObjectPage = ObjectPage & InternalFpmPage & {
|
|
111
123
|
name: 'ObjectPage';
|
|
112
|
-
settings: any;
|
|
113
124
|
};
|
|
114
125
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/section/index.js
CHANGED
|
@@ -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.
|
|
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.
|
|
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.
|
|
4
|
+
"version": "0.18.8",
|
|
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.
|
|
32
|
+
"@sap-ux/project-access": "1.3.0",
|
|
33
33
|
"@types/ejs": "3.1.0",
|
|
34
34
|
"@types/mem-fs": "1.1.2",
|
|
35
35
|
"@types/mem-fs-editor": "7.0.1",
|
|
@@ -2,30 +2,19 @@ import ControllerExtension from 'sap/ui/core/mvc/ControllerExtension';
|
|
|
2
2
|
import ExtensionAPI from 'sap/fe/<%- typeof extension === "object" ? `templates/${extension.pageType}` : "core" -%>/ExtensionAPI';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* @namespace <%- ns %>.<%- name %>
|
|
6
|
+
* @controller
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
base: {
|
|
10
|
-
getExtensionAPI(): ExtensionAPI;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Cannot change to class syntax until https://github.com/SAP/ui5-typescript/issues/332 is fixed.
|
|
17
|
-
*/
|
|
18
|
-
export default ControllerExtension.extend('<%- ns %>.<%- name %>', {
|
|
19
|
-
// this section allows to extend lifecycle hooks or hooks provided by Fiori elements
|
|
20
|
-
override: {
|
|
8
|
+
export default class <%- name %> extends ControllerExtension<ExtensionAPI> {
|
|
9
|
+
static override = {
|
|
21
10
|
/**
|
|
22
11
|
* Called when a controller is instantiated and its View controls (if available) are already created.
|
|
23
12
|
* Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
|
|
24
13
|
* @memberOf <%- ns %>.<%- name %>
|
|
25
14
|
*/
|
|
26
|
-
onInit(this:
|
|
15
|
+
onInit(this: <%- name %>) {
|
|
27
16
|
// you can access the Fiori elements extensionAPI via this.base.getExtensionAPI
|
|
28
17
|
const model = this.base.getExtensionAPI().getModel();
|
|
29
18
|
}
|
|
30
19
|
}
|
|
31
|
-
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper to be able to define how to get the page specific extension API when writing a controller extension.
|
|
3
|
+
*/
|
|
4
|
+
declare module 'sap/ui/core/mvc/ControllerExtension' {
|
|
5
|
+
export default class ControllerExtension<API> {
|
|
6
|
+
static override: unknown;
|
|
7
|
+
base: {
|
|
8
|
+
getExtensionAPI(): API;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -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 %>": {
|
|
@@ -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 %>": {
|