@sap-ux/fe-fpm-writer
Advanced tools
Comparing version 0.8.0 to 0.9.0
@@ -1,3 +0,3 @@ | ||
export { CustomPage } from './page/types'; | ||
export { generateCustomPage } from './page'; | ||
export { CustomPage, ObjectPage, ListReport } from './page/types'; | ||
export { generateCustomPage, generateObjectPage, generateListReport } from './page'; | ||
export { CustomAction, TargetControl } from './action/types'; | ||
@@ -4,0 +4,0 @@ export { generateCustomAction } from './action'; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.validateVersion = exports.validateBasePath = exports.enableFPM = exports.generateCustomView = exports.generateCustomSection = exports.generateCustomColumn = exports.generateCustomAction = exports.TargetControl = exports.generateCustomPage = void 0; | ||
exports.validateVersion = exports.validateBasePath = exports.enableFPM = exports.generateCustomView = exports.generateCustomSection = exports.generateCustomColumn = exports.generateCustomAction = exports.TargetControl = exports.generateListReport = exports.generateObjectPage = exports.generateCustomPage = void 0; | ||
var page_1 = require("./page"); | ||
Object.defineProperty(exports, "generateCustomPage", { enumerable: true, get: function () { return page_1.generateCustomPage; } }); | ||
Object.defineProperty(exports, "generateObjectPage", { enumerable: true, get: function () { return page_1.generateObjectPage; } }); | ||
Object.defineProperty(exports, "generateListReport", { enumerable: true, get: function () { return page_1.generateListReport; } }); | ||
var types_1 = require("./action/types"); | ||
@@ -7,0 +9,0 @@ Object.defineProperty(exports, "TargetControl", { enumerable: true, get: function () { return types_1.TargetControl; } }); |
@@ -1,28 +0,7 @@ | ||
import type { Editor } from 'mem-fs-editor'; | ||
import type { CustomPage } from './types'; | ||
/** | ||
* Validate the UI5 version and if valid return the root folder for the templates to be used. | ||
* | ||
* @param ui5Version - optional minimum required UI5 version | ||
* @returns root folder containg the templates if the version is supported otherwise throws an error | ||
*/ | ||
export declare function getTemplateRoot(ui5Version?: number): string; | ||
/** | ||
* Validate the input parameters for the execution of generateCustomAction. | ||
* | ||
* @param {string} basePath - the base path | ||
* @param {CustomPage} config - the custom page configuration | ||
* @param {Editor} [fs] - the memfs editor instance | ||
* @returns {Promise<Editor>} the updated memfs editor instance | ||
*/ | ||
export declare function validateCustomPageConfig(basePath: string, config: CustomPage, fs?: Editor): Editor; | ||
/** | ||
* Add a custom page to an existing UI5 application. | ||
* | ||
* @param {string} basePath - the base path | ||
* @param {CustomPage} data - the custom page configuration | ||
* @param {Editor} [fs] - the memfs editor instance | ||
* @returns {Promise<Editor>} the updated memfs editor instance | ||
*/ | ||
export declare function generateCustomPage(basePath: string, data: CustomPage, fs?: Editor): Editor; | ||
import type { CustomPage, ObjectPage, ListReport, Navigation } from './types'; | ||
import { validatePageConfig } from './common'; | ||
import { generate as generateCustomPage } from './custom'; | ||
import { generate as generateObjectPage } from './object'; | ||
import { generate as generateListReport } from './list'; | ||
export { validatePageConfig, generateCustomPage, generateObjectPage, generateListReport, CustomPage, ObjectPage, ListReport, Navigation }; | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.generateCustomPage = exports.validateCustomPageConfig = exports.getTemplateRoot = void 0; | ||
const path_1 = require("path"); | ||
const mem_fs_1 = require("mem-fs"); | ||
const mem_fs_editor_1 = require("mem-fs-editor"); | ||
const ejs_1 = require("ejs"); | ||
const defaults_1 = require("./defaults"); | ||
const validate_1 = require("../common/validate"); | ||
/** | ||
* Validate the UI5 version and if valid return the root folder for the templates to be used. | ||
* | ||
* @param ui5Version - optional minimum required UI5 version | ||
* @returns root folder containg the templates if the version is supported otherwise throws an error | ||
*/ | ||
function getTemplateRoot(ui5Version) { | ||
if (ui5Version === undefined || ui5Version >= 1.94) { | ||
return path_1.join(__dirname, '../../templates/page/1.94'); | ||
} | ||
else { | ||
return path_1.join(__dirname, '../../templates/page/1.84'); | ||
} | ||
} | ||
exports.getTemplateRoot = getTemplateRoot; | ||
/** | ||
* Add a new route to the provided route array, and update existing routes if necessary (e.g. if targets are defined as arrays for FCL). | ||
* | ||
* @param routes existing application routes (from the manifest) | ||
* @param config configuration object | ||
*/ | ||
function updateRoutes(routes, config) { | ||
var _a, _b; | ||
const newRoute = { | ||
name: `${config.entity}${config.name}` | ||
}; | ||
if (config.navigation) { | ||
const sourceRoute = routes.find((route) => { var _a; return route.name === ((_a = config.navigation) === null || _a === void 0 ? void 0 : _a.sourcePage); }); | ||
const pattern = { | ||
base: (_a = sourceRoute === null || sourceRoute === void 0 ? void 0 : sourceRoute.pattern) === null || _a === void 0 ? void 0 : _a.replace(':?query:', ''), | ||
navEntity: config.navigation.navEntity, | ||
navKey: config.navigation.navKey ? `({${config.navigation.navEntity}Key})` : '' | ||
}; | ||
newRoute.pattern = `${pattern.base}/${pattern.navEntity}${pattern.navKey}:?query:`; | ||
if (((_b = sourceRoute === null || sourceRoute === void 0 ? void 0 : sourceRoute.target) === null || _b === void 0 ? void 0 : _b.constructor) === Array) { | ||
const pages = sourceRoute.target; | ||
// FCL only supports 3 columns, therefore, show the page in fullscreen if it is the 4th level of navigation | ||
newRoute.target = | ||
pages.length > 2 | ||
? [newRoute.name] | ||
: [...pages, newRoute.name]; | ||
} | ||
else { | ||
newRoute.target = config.fcl ? [newRoute.name] : newRoute.name; | ||
} | ||
} | ||
else { | ||
newRoute.pattern = routes.length > 0 ? `${config.entity}:?query:` : ':?query:'; | ||
newRoute.target = config.fcl ? [newRoute.name] : newRoute.name; | ||
} | ||
routes.push(newRoute); | ||
} | ||
/** | ||
* Validate the input parameters for the execution of generateCustomAction. | ||
* | ||
* @param {string} basePath - the base path | ||
* @param {CustomPage} config - the custom page configuration | ||
* @param {Editor} [fs] - the memfs editor instance | ||
* @returns {Promise<Editor>} the updated memfs editor instance | ||
*/ | ||
function validateCustomPageConfig(basePath, config, fs) { | ||
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; | ||
// common validators | ||
validate_1.validateVersion(config.ui5Version); | ||
if (!fs) { | ||
fs = mem_fs_editor_1.create(mem_fs_1.create()); | ||
} | ||
validate_1.validateBasePath(basePath, fs); | ||
// validate config against the manifest | ||
const manifest = fs.readJSON(path_1.join(basePath, 'webapp/manifest.json')); | ||
if (config.navigation) { | ||
if (!((_c = (_b = (_a = manifest['sap.ui5']) === null || _a === void 0 ? void 0 : _a.routing) === null || _b === void 0 ? void 0 : _b.targets) === null || _c === void 0 ? void 0 : _c[config.navigation.sourcePage])) { | ||
throw new Error(`Could not find navigation source ${config.navigation.sourcePage}!`); | ||
} | ||
const routes = {}; | ||
if (((_f = (_e = (_d = manifest['sap.ui5']) === null || _d === void 0 ? void 0 : _d.routing) === null || _e === void 0 ? void 0 : _e.routes) === null || _f === void 0 ? void 0 : _f.constructor) === Array) { | ||
manifest['sap.ui5'].routing.routes.forEach((routeWithName) => { | ||
routes[routeWithName.name] = routeWithName; | ||
}); | ||
} | ||
else { | ||
Object.assign(routes, (_j = (_h = (_g = manifest['sap.ui5']) === null || _g === void 0 ? void 0 : _g.routing) === null || _h === void 0 ? void 0 : _h.routes) !== null && _j !== void 0 ? _j : {}); | ||
} | ||
const route = routes[(_k = config.navigation) === null || _k === void 0 ? void 0 : _k.sourcePage]; | ||
if (!route || !route.pattern || !route.target) { | ||
throw new Error(`Missing or invalid routing configuration for navigation source ${config.navigation.sourcePage}!`); | ||
} | ||
} | ||
return fs; | ||
} | ||
exports.validateCustomPageConfig = validateCustomPageConfig; | ||
/** | ||
* Add a custom page to an existing UI5 application. | ||
* | ||
* @param {string} basePath - the base path | ||
* @param {CustomPage} data - the custom page configuration | ||
* @param {Editor} [fs] - the memfs editor instance | ||
* @returns {Promise<Editor>} the updated memfs editor instance | ||
*/ | ||
function generateCustomPage(basePath, data, fs) { | ||
fs = validateCustomPageConfig(basePath, data, fs); | ||
const manifestPath = path_1.join(basePath, 'webapp/manifest.json'); | ||
const config = defaults_1.enhanceData(data, manifestPath, fs); | ||
// merge content into existing files | ||
const root = getTemplateRoot(data.ui5Version); | ||
// enhance manifest.json | ||
fs.extendJSON(manifestPath, JSON.parse(ejs_1.render(fs.read(path_1.join(root, `manifest.json`)), config)), (key, value) => { | ||
var _a; | ||
switch (key) { | ||
case 'routing': | ||
value.routes = (_a = value.routes) !== null && _a !== void 0 ? _a : []; | ||
break; | ||
case 'routes': | ||
updateRoutes(value, config); | ||
break; | ||
default: | ||
break; | ||
} | ||
return value; | ||
}); | ||
// add extension content | ||
const viewPath = path_1.join(config.path, `${config.name}.view.xml`); | ||
if (!fs.exists(viewPath)) { | ||
fs.copyTpl(path_1.join(root, 'ext/View.xml'), viewPath, config); | ||
} | ||
const controllerPath = path_1.join(config.path, `${config.name}.controller.js`); | ||
if (!fs.exists(controllerPath)) { | ||
fs.copyTpl(path_1.join(root, 'ext/Controller.js'), controllerPath, config); | ||
} | ||
return fs; | ||
} | ||
exports.generateCustomPage = generateCustomPage; | ||
exports.generateListReport = exports.generateObjectPage = exports.generateCustomPage = exports.validatePageConfig = void 0; | ||
const common_1 = require("./common"); | ||
Object.defineProperty(exports, "validatePageConfig", { enumerable: true, get: function () { return common_1.validatePageConfig; } }); | ||
const custom_1 = require("./custom"); | ||
Object.defineProperty(exports, "generateCustomPage", { enumerable: true, get: function () { return custom_1.generate; } }); | ||
const object_1 = require("./object"); | ||
Object.defineProperty(exports, "generateObjectPage", { enumerable: true, get: function () { return object_1.generate; } }); | ||
const list_1 = require("./list"); | ||
Object.defineProperty(exports, "generateListReport", { enumerable: true, get: function () { return list_1.generate; } }); | ||
//# sourceMappingURL=index.js.map |
import type { CustomElement, InternalCustomElement } from '../common/types'; | ||
/** | ||
* Incoming navigation configuration. | ||
*/ | ||
export interface Navigation { | ||
/** | ||
* Source of the navigation to the custom page | ||
*/ | ||
sourcePage: string; | ||
/** | ||
* Source entity that is use as the base part of the route | ||
*/ | ||
sourceEntity: string; | ||
/** | ||
* Name of the navigation entity | ||
*/ | ||
navEntity: string; | ||
/** | ||
* If set to true, then the generated route will point to a specific entity, otherwise, it will point to a list of the entities. | ||
*/ | ||
navKey?: boolean; | ||
} | ||
export interface StandardPageSettings { | ||
enhanceI18n?: string | true; | ||
variantManagement?: 'Page' | 'None'; | ||
} | ||
/** | ||
* Support list of settings for a ListReport page | ||
*/ | ||
export interface ListReportSettings extends StandardPageSettings { | ||
tableSettings?: { | ||
type?: 'ResponsiveTable' | 'GridTable'; | ||
selectionMode?: 'None' | 'Single' | 'Multi' | 'Auto'; | ||
condensedTableLayout?: boolean; | ||
}; | ||
} | ||
/** | ||
* Configuration options for adding a list report page. | ||
*/ | ||
export interface ListReport { | ||
/** | ||
* Name of the entity used for the custom page. | ||
*/ | ||
entity: string; | ||
/** | ||
* Optional settings for the ListReport page | ||
*/ | ||
settings?: ListReportSettings; | ||
} | ||
/** | ||
* Configuration options for adding an object page. | ||
*/ | ||
export interface ObjectPage { | ||
/** | ||
* Name of the entity used for the custom page. | ||
*/ | ||
entity: string; | ||
/** | ||
* Optional settings for the object page | ||
*/ | ||
settings?: StandardPageSettings; | ||
/** | ||
* Optional incoming navigation configuration. If provided then a navigation configuration is added to an existing page navigating to this custom page. | ||
*/ | ||
navigation?: Navigation; | ||
} | ||
/** | ||
* Configuration options for adding a custom page. | ||
@@ -13,16 +78,4 @@ */ | ||
*/ | ||
navigation?: { | ||
navigation?: Navigation & { | ||
/** | ||
* Source of the navigation to the custom page | ||
*/ | ||
sourcePage: string; | ||
/** | ||
* Source entity that is use as the base part of the route | ||
*/ | ||
sourceEntity: string; | ||
/** | ||
* Name of the navigation entity | ||
*/ | ||
navEntity: string; | ||
/** | ||
* If set to true, then the generated route will point to a specific entity, otherwise, it will point to a list of the entities. | ||
@@ -42,10 +95,7 @@ */ | ||
} | ||
/** | ||
* Additional internal configuration options that will be calculated based on the provided input as well as the target application. | ||
*/ | ||
export declare type InternalCustomPage = CustomPage & InternalCustomElement & { | ||
export interface FCL { | ||
/** | ||
* The FLC flag is calculated to true if the existing app is configured to use the flexible column layout | ||
* The FCL flag is calculated to true if the existing app is configured to use the flexible column layout | ||
*/ | ||
fcl: boolean; | ||
fcl?: boolean; | ||
/** | ||
@@ -56,3 +106,16 @@ * Represents the name of the control aggregation to be used for the custom page. | ||
controlAggregation?: 'beginColumnPages' | 'midColumnPages' | 'endColumnPages'; | ||
} | ||
/** | ||
* Additional internal configuration options that will be calculated based on the provided input as well as the target application. | ||
*/ | ||
export declare type InternalCustomPage = CustomPage & InternalCustomElement & FCL; | ||
export declare type InternalListReport = ListReport & FCL & { | ||
name: 'ListReport'; | ||
navigation?: Navigation; | ||
settings: any; | ||
}; | ||
export declare type InternalObjectPage = ObjectPage & FCL & { | ||
name: 'ObjectPage'; | ||
settings: any; | ||
}; | ||
//# sourceMappingURL=types.d.ts.map |
{ | ||
"name": "@sap-ux/fe-fpm-writer", | ||
"description": "SAP Fiori elements flexible programming model writer", | ||
"version": "0.8.0", | ||
"version": "0.9.0", | ||
"repository": { | ||
@@ -6,0 +6,0 @@ "type": "git", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
132672
98
1921