@sap-ux/preview-middleware 0.26.12 → 1.0.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.
- package/dist/base/cdm.d.ts +2 -2
- package/dist/base/cdm.js +10 -11
- package/dist/base/config.d.ts +1 -1
- package/dist/base/config.js +60 -72
- package/dist/base/flex.js +16 -23
- package/dist/base/flp.d.ts +2 -2
- package/dist/base/flp.js +96 -96
- package/dist/base/index.d.ts +3 -3
- package/dist/base/index.js +3 -12
- package/dist/base/remote-url.js +14 -24
- package/dist/base/test.d.ts +1 -1
- package/dist/base/test.js +2 -6
- package/dist/base/utils/cards.d.ts +1 -1
- package/dist/base/utils/cards.js +3 -9
- package/dist/client/adp/add-fragment.js +4 -4
- package/dist/client/adp/add-fragment.ts +2 -2
- package/dist/client/adp/api-handler.js +2 -2
- package/dist/client/adp/api-handler.ts +1 -1
- package/dist/client/adp/command-executor.js +3 -3
- package/dist/client/adp/command-executor.ts +2 -2
- package/dist/client/adp/controllers/AddActionFragment.controller.js +5 -5
- package/dist/client/adp/controllers/AddActionFragment.controller.ts +7 -7
- package/dist/client/adp/controllers/AddCustomFragment.controller.js +7 -7
- package/dist/client/adp/controllers/AddCustomFragment.controller.ts +9 -9
- package/dist/client/adp/controllers/AddFragment.controller.js +7 -7
- package/dist/client/adp/controllers/AddFragment.controller.ts +11 -11
- package/dist/client/adp/controllers/AddSubpage.controller.js +4 -4
- package/dist/client/adp/controllers/AddSubpage.controller.ts +7 -7
- package/dist/client/adp/controllers/AddTableColumnFragments.controller.js +7 -7
- package/dist/client/adp/controllers/AddTableColumnFragments.controller.ts +11 -11
- package/dist/client/adp/controllers/BaseDialog.controller.js +3 -3
- package/dist/client/adp/controllers/BaseDialog.controller.ts +6 -6
- package/dist/client/adp/controllers/ControllerExtension.controller.js +14 -14
- package/dist/client/adp/controllers/ControllerExtension.controller.ts +12 -12
- package/dist/client/adp/controllers/ExtensionPoint.controller.js +4 -4
- package/dist/client/adp/controllers/ExtensionPoint.controller.ts +5 -5
- package/dist/client/adp/controllers/FileExistsDialog.controller.js +2 -2
- package/dist/client/adp/controllers/FileExistsDialog.controller.ts +2 -2
- package/dist/client/adp/dialog-factory.js +2 -2
- package/dist/client/adp/dialog-factory.ts +16 -16
- package/dist/client/adp/extend-controller.js +4 -4
- package/dist/client/adp/extend-controller.ts +2 -2
- package/dist/client/adp/extension-point.js +5 -5
- package/dist/client/adp/extension-point.ts +4 -4
- package/dist/client/adp/init-dialogs.js +6 -6
- package/dist/client/adp/init-dialogs.ts +6 -6
- package/dist/client/adp/init.js +13 -13
- package/dist/client/adp/init.ts +9 -9
- package/dist/client/adp/quick-actions/add-new-subpage-quick-action-base.js +8 -8
- package/dist/client/adp/quick-actions/add-new-subpage-quick-action-base.ts +10 -10
- package/dist/client/adp/quick-actions/common/add-controller-to-page.js +13 -13
- package/dist/client/adp/quick-actions/common/add-controller-to-page.ts +11 -11
- package/dist/client/adp/quick-actions/common/add-new-annotation-file.js +11 -11
- package/dist/client/adp/quick-actions/common/add-new-annotation-file.ts +10 -10
- package/dist/client/adp/quick-actions/common/create-page-action.js +8 -8
- package/dist/client/adp/quick-actions/common/create-page-action.ts +7 -7
- package/dist/client/adp/quick-actions/common/op-add-custom-section.js +6 -6
- package/dist/client/adp/quick-actions/common/op-add-custom-section.ts +5 -5
- package/dist/client/adp/quick-actions/common/op-add-header-field.js +7 -7
- package/dist/client/adp/quick-actions/common/op-add-header-field.ts +7 -7
- package/dist/client/adp/quick-actions/common/utils.ts +1 -1
- package/dist/client/adp/quick-actions/dialog-enablement-validator.js +3 -3
- package/dist/client/adp/quick-actions/dialog-enablement-validator.ts +3 -3
- package/dist/client/adp/quick-actions/fe-v2/add-new-subpage.js +6 -6
- package/dist/client/adp/quick-actions/fe-v2/add-new-subpage.ts +5 -5
- package/dist/client/adp/quick-actions/fe-v2/change-table-actions.js +5 -5
- package/dist/client/adp/quick-actions/fe-v2/change-table-actions.ts +5 -5
- package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +7 -7
- package/dist/client/adp/quick-actions/fe-v2/change-table-columns.ts +5 -5
- package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +11 -11
- package/dist/client/adp/quick-actions/fe-v2/create-table-action.ts +6 -6
- package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +13 -13
- package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.ts +7 -7
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.js +9 -9
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.ts +6 -6
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.js +11 -11
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.ts +6 -6
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-variant-management.js +4 -4
- package/dist/client/adp/quick-actions/fe-v2/lr-enable-variant-management.ts +3 -3
- package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +4 -4
- package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.ts +4 -4
- package/dist/client/adp/quick-actions/fe-v2/op-enable-empty-row-mode.js +12 -12
- package/dist/client/adp/quick-actions/fe-v2/op-enable-empty-row-mode.ts +8 -8
- package/dist/client/adp/quick-actions/fe-v2/op-enable-variant-management.js +6 -6
- package/dist/client/adp/quick-actions/fe-v2/op-enable-variant-management.ts +5 -5
- package/dist/client/adp/quick-actions/fe-v2/registry.js +18 -18
- package/dist/client/adp/quick-actions/fe-v2/registry.ts +18 -18
- package/dist/client/adp/quick-actions/fe-v2/utils.js +4 -4
- package/dist/client/adp/quick-actions/fe-v2/utils.ts +2 -2
- package/dist/client/adp/quick-actions/fe-v4/add-new-subpage.js +7 -7
- package/dist/client/adp/quick-actions/fe-v4/add-new-subpage.ts +5 -5
- package/dist/client/adp/quick-actions/fe-v4/change-table-actions.js +9 -9
- package/dist/client/adp/quick-actions/fe-v4/change-table-actions.ts +7 -7
- package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +6 -6
- package/dist/client/adp/quick-actions/fe-v4/change-table-columns.ts +6 -6
- package/dist/client/adp/quick-actions/fe-v4/create-page-action.js +11 -11
- package/dist/client/adp/quick-actions/fe-v4/create-page-action.ts +9 -9
- package/dist/client/adp/quick-actions/fe-v4/create-table-action-config-change.js +13 -13
- package/dist/client/adp/quick-actions/fe-v4/create-table-action-config-change.ts +11 -11
- package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column-config-change.js +16 -16
- package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column-config-change.ts +9 -9
- package/dist/client/adp/quick-actions/fe-v4/enable-variant-management.js +5 -5
- package/dist/client/adp/quick-actions/fe-v4/enable-variant-management.ts +4 -4
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.js +5 -5
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.ts +5 -5
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.js +7 -7
- package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.ts +6 -6
- package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +5 -5
- package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.ts +5 -5
- package/dist/client/adp/quick-actions/fe-v4/op-add-custom-section.js +8 -8
- package/dist/client/adp/quick-actions/fe-v4/op-add-custom-section.ts +8 -8
- package/dist/client/adp/quick-actions/fe-v4/op-enable-empty-row-mode.js +12 -12
- package/dist/client/adp/quick-actions/fe-v4/op-enable-empty-row-mode.ts +8 -8
- package/dist/client/adp/quick-actions/fe-v4/registry.js +17 -17
- package/dist/client/adp/quick-actions/fe-v4/registry.ts +17 -17
- package/dist/client/adp/quick-actions/fe-v4/utils.js +6 -6
- package/dist/client/adp/quick-actions/fe-v4/utils.ts +3 -3
- package/dist/client/adp/quick-actions/load.ts +2 -2
- package/dist/client/adp/quick-actions/quick-action-base.js +2 -2
- package/dist/client/adp/quick-actions/quick-action-base.ts +3 -3
- package/dist/client/adp/quick-actions/simple-quick-action-base.js +3 -3
- package/dist/client/adp/quick-actions/simple-quick-action-base.ts +4 -4
- package/dist/client/adp/quick-actions/table-quick-action-base.js +17 -17
- package/dist/client/adp/quick-actions/table-quick-action-base.ts +9 -9
- package/dist/client/adp/sync-views-utils.js +4 -4
- package/dist/client/adp/sync-views-utils.ts +3 -3
- package/dist/client/adp/utils.js +3 -3
- package/dist/client/adp/utils.ts +2 -2
- package/dist/client/cpe/additional-change-info/add-xml-additional-info.js +7 -7
- package/dist/client/cpe/additional-change-info/add-xml-additional-info.ts +2 -2
- package/dist/client/cpe/changes/flex-change.js +3 -3
- package/dist/client/cpe/changes/flex-change.ts +3 -3
- package/dist/client/cpe/changes/generic-change.js +5 -5
- package/dist/client/cpe/changes/generic-change.ts +4 -4
- package/dist/client/cpe/changes/index.js +2 -2
- package/dist/client/cpe/changes/index.ts +1 -1
- package/dist/client/cpe/changes/service.js +12 -12
- package/dist/client/cpe/changes/service.ts +9 -9
- package/dist/client/cpe/changes/validator.js +2 -2
- package/dist/client/cpe/changes/validator.ts +1 -1
- package/dist/client/cpe/communication-service.js +2 -2
- package/dist/client/cpe/communication-service.ts +2 -2
- package/dist/client/cpe/connector-service.js +3 -3
- package/dist/client/cpe/connector-service.ts +3 -3
- package/dist/client/cpe/context-menu-service.js +6 -6
- package/dist/client/cpe/context-menu-service.ts +6 -6
- package/dist/client/cpe/control-data.js +3 -3
- package/dist/client/cpe/control-data.ts +5 -5
- package/dist/client/cpe/documentation.js +4 -4
- package/dist/client/cpe/documentation.ts +5 -5
- package/dist/client/cpe/init.js +15 -15
- package/dist/client/cpe/init.ts +16 -16
- package/dist/client/cpe/odata-health/odata-health-checker.js +5 -5
- package/dist/client/cpe/odata-health/odata-health-checker.ts +10 -10
- package/dist/client/cpe/outline/editable.js +4 -4
- package/dist/client/cpe/outline/editable.ts +4 -4
- package/dist/client/cpe/outline/nodes.js +7 -7
- package/dist/client/cpe/outline/nodes.ts +7 -7
- package/dist/client/cpe/outline/service.js +3 -3
- package/dist/client/cpe/outline/service.ts +4 -4
- package/dist/client/cpe/quick-actions/quick-action-service.js +5 -5
- package/dist/client/cpe/quick-actions/quick-action-service.ts +10 -10
- package/dist/client/cpe/quick-actions/registry.js +3 -3
- package/dist/client/cpe/quick-actions/registry.ts +4 -4
- package/dist/client/cpe/quick-actions/utils.js +3 -3
- package/dist/client/cpe/quick-actions/utils.ts +2 -2
- package/dist/client/cpe/rta-service.ts +1 -1
- package/dist/client/cpe/selection.js +8 -8
- package/dist/client/cpe/selection.ts +7 -7
- package/dist/client/cpe/utils.js +2 -2
- package/dist/client/cpe/utils.ts +2 -2
- package/dist/client/flp/WorkspaceConnector.js +6 -6
- package/dist/client/flp/WorkspaceConnector.ts +4 -4
- package/dist/client/flp/enableFakeConnector.js +4 -4
- package/dist/client/flp/enableFakeConnector.ts +3 -3
- package/dist/client/flp/init.js +6 -6
- package/dist/client/flp/init.ts +5 -5
- package/dist/client/flp/initConnectors.js +3 -3
- package/dist/client/flp/initConnectors.ts +1 -1
- package/dist/client/thirdparty/@sap-ux-private/control-property-editor-common.js +397 -477
- package/dist/client/utils/additional-change-info.js +2 -2
- package/dist/client/utils/additional-change-info.ts +2 -2
- package/dist/client/utils/core.js +2 -2
- package/dist/client/utils/core.ts +1 -1
- package/dist/client/utils/fe-v4.js +3 -3
- package/dist/client/utils/fe-v4.ts +2 -2
- package/dist/client/utils/info-center-message.js +3 -3
- package/dist/client/utils/info-center-message.ts +2 -2
- package/dist/client/utils/version.js +2 -2
- package/dist/client/utils/version.ts +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -25
- package/dist/types/index.js +1 -4
- package/dist/ui5/middleware.d.ts +11 -1
- package/dist/ui5/middleware.js +13 -15
- package/package.json +18 -16
package/dist/base/cdm.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { TemplateConfig } from './config';
|
|
2
|
-
import { type FLPCdmConfig } from '../types';
|
|
1
|
+
import type { TemplateConfig } from './config.js';
|
|
2
|
+
import { type FLPCdmConfig } from '../types/index.js';
|
|
3
3
|
/**
|
|
4
4
|
* Generates a CDM by embedding the provided app tiles into the FLP homepage.
|
|
5
5
|
*
|
package/dist/base/cdm.js
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const types_1 = require("../types");
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname, join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { FLPHomePageDefaults } from '../types/index.js';
|
|
5
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
6
|
/**
|
|
8
7
|
* Generates a CDM by embedding the provided app tiles into the FLP homepage.
|
|
9
8
|
*
|
|
10
9
|
* @param apps - A list of app to be embedded.
|
|
11
10
|
* @returns The generated CDM configuration
|
|
12
11
|
*/
|
|
13
|
-
function generateCdm(apps = {}) {
|
|
14
|
-
const cdm = JSON.parse(
|
|
12
|
+
export function generateCdm(apps = {}) {
|
|
13
|
+
const cdm = JSON.parse(readFileSync(join(__dirname, '../../templates/flp/cdm.base.json'), 'utf-8'));
|
|
15
14
|
// add apps
|
|
16
15
|
Object.keys(apps).forEach((id) => {
|
|
17
16
|
const appId = apps[id].additionalInformation.split('=')[1];
|
|
@@ -19,7 +18,7 @@ function generateCdm(apps = {}) {
|
|
|
19
18
|
const [object, action] = id.split('-');
|
|
20
19
|
const { title, description, url } = apps[id];
|
|
21
20
|
// add app to default catalog
|
|
22
|
-
cdm.catalogs[
|
|
21
|
+
cdm.catalogs[FLPHomePageDefaults.catalogId].payload.viz.push(vizId);
|
|
23
22
|
// create flp visualization
|
|
24
23
|
cdm.visualizations[vizId] = {
|
|
25
24
|
'vizType': 'sap.ushell.StaticAppLauncher',
|
|
@@ -76,8 +75,8 @@ function generateCdm(apps = {}) {
|
|
|
76
75
|
}
|
|
77
76
|
};
|
|
78
77
|
// add app to default section
|
|
79
|
-
cdm.pages[
|
|
80
|
-
cdm.pages[
|
|
78
|
+
cdm.pages[FLPHomePageDefaults.pageName].payload.sections[FLPHomePageDefaults.sectionId].layout.vizOrder.push(appId);
|
|
79
|
+
cdm.pages[FLPHomePageDefaults.pageName].payload.sections[FLPHomePageDefaults.sectionId].viz[appId] = {
|
|
81
80
|
id: appId,
|
|
82
81
|
vizId
|
|
83
82
|
};
|
package/dist/base/config.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ToolsLogger, type Logger } from '@sap-ux/logger';
|
|
2
|
-
import type { App, DefaultFlpPath, DefaultIntent, FlpConfig, Intent, CompleteTestConfig, MiddlewareConfig, RtaConfig, TestConfig } from '../types';
|
|
2
|
+
import type { App, DefaultFlpPath, DefaultIntent, FlpConfig, Intent, CompleteTestConfig, MiddlewareConfig, RtaConfig, TestConfig } from '../types/index.js';
|
|
3
3
|
import { type Manifest, type UI5FlexLayer } from '@sap-ux/project-access';
|
|
4
4
|
import { type Editor } from 'mem-fs-editor';
|
|
5
5
|
import type { MergedAppDescriptor } from '@sap-ux/axios-extension';
|
package/dist/base/config.js
CHANGED
|
@@ -1,39 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
exports.createTestTemplateConfig = createTestTemplateConfig;
|
|
13
|
-
exports.getPreviewPaths = getPreviewPaths;
|
|
14
|
-
exports.generatePreviewFiles = generatePreviewFiles;
|
|
15
|
-
const logger_1 = require("@sap-ux/logger");
|
|
16
|
-
const ejs_1 = require("ejs");
|
|
17
|
-
const node_path_1 = require("node:path");
|
|
18
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
19
|
-
const i18n_1 = require("@sap-ux/i18n");
|
|
20
|
-
const node_fs_1 = require("node:fs");
|
|
21
|
-
const test_1 = require("./test");
|
|
22
|
-
const mem_fs_editor_1 = require("mem-fs-editor");
|
|
23
|
-
const mem_fs_1 = require("mem-fs");
|
|
1
|
+
import { ToolsLogger } from '@sap-ux/logger';
|
|
2
|
+
import { render } from 'ejs';
|
|
3
|
+
import { dirname, join, posix, resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { createProjectAccess, getWebappPath } from '@sap-ux/project-access';
|
|
6
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
7
|
+
import { extractDoubleCurlyBracketsKey } from '@sap-ux/i18n';
|
|
8
|
+
import { readFileSync } from 'node:fs';
|
|
9
|
+
import { mergeTestConfigDefaults } from './test.js';
|
|
10
|
+
import { create } from 'mem-fs-editor';
|
|
11
|
+
import { create as createStorage } from 'mem-fs';
|
|
24
12
|
/**
|
|
25
13
|
* Static settings
|
|
26
14
|
*/
|
|
27
|
-
|
|
15
|
+
export const PREVIEW_URL = {
|
|
28
16
|
client: {
|
|
29
17
|
path: '/preview/client',
|
|
30
|
-
getUrl: (basePath) =>
|
|
31
|
-
local:
|
|
18
|
+
getUrl: (basePath) => posix.join(basePath, 'preview', 'client'),
|
|
19
|
+
local: join(__dirname, '../../dist/client'),
|
|
32
20
|
ns: 'open.ux.preview.client'
|
|
33
21
|
},
|
|
34
22
|
api: '/preview/api'
|
|
35
23
|
};
|
|
36
|
-
|
|
24
|
+
export const CARD_GENERATOR_DEFAULT = {
|
|
37
25
|
previewGeneratorSandbox: '/test/flpCardGeneratorSandbox.html',
|
|
38
26
|
cardsStore: '/cards/store',
|
|
39
27
|
i18nStore: '/editor/i18n'
|
|
@@ -41,15 +29,15 @@ exports.CARD_GENERATOR_DEFAULT = {
|
|
|
41
29
|
/**
|
|
42
30
|
* Default theme
|
|
43
31
|
*/
|
|
44
|
-
|
|
32
|
+
export const DEFAULT_THEME = 'sap_horizon';
|
|
45
33
|
/**
|
|
46
34
|
* Default path for mounting the local FLP.
|
|
47
35
|
*/
|
|
48
|
-
|
|
36
|
+
export const DEFAULT_PATH = '/test/flp.html';
|
|
49
37
|
/**
|
|
50
38
|
* Default intent
|
|
51
39
|
*/
|
|
52
|
-
|
|
40
|
+
export const DEFAULT_INTENT = {
|
|
53
41
|
object: 'app',
|
|
54
42
|
action: 'preview'
|
|
55
43
|
};
|
|
@@ -86,7 +74,7 @@ const UI5_LIBS = [
|
|
|
86
74
|
* @param connector - the connector to check
|
|
87
75
|
* @returns true if the connector is a FlexConnector, false otherwise
|
|
88
76
|
*/
|
|
89
|
-
function isFlexConnector(connector) {
|
|
77
|
+
export function isFlexConnector(connector) {
|
|
90
78
|
return 'connector' in connector;
|
|
91
79
|
}
|
|
92
80
|
/**
|
|
@@ -115,10 +103,10 @@ function getUI5Libs(manifest) {
|
|
|
115
103
|
* @param config partial configuration
|
|
116
104
|
* @returns a full configuration with default values
|
|
117
105
|
*/
|
|
118
|
-
function getFlpConfigWithDefaults(config = {}) {
|
|
106
|
+
export function getFlpConfigWithDefaults(config = {}) {
|
|
119
107
|
const flpConfig = {
|
|
120
|
-
path: config.path ??
|
|
121
|
-
intent: config.intent ??
|
|
108
|
+
path: config.path ?? DEFAULT_PATH,
|
|
109
|
+
intent: config.intent ?? DEFAULT_INTENT,
|
|
122
110
|
apps: config.apps ?? [],
|
|
123
111
|
libs: config.libs,
|
|
124
112
|
theme: config.theme,
|
|
@@ -136,7 +124,7 @@ function getFlpConfigWithDefaults(config = {}) {
|
|
|
136
124
|
* @param config configurations from the ui5.yaml
|
|
137
125
|
* @param logger logger instance
|
|
138
126
|
*/
|
|
139
|
-
function sanitizeConfig(config, logger) {
|
|
127
|
+
export function sanitizeConfig(config, logger) {
|
|
140
128
|
//prettier-ignore
|
|
141
129
|
if (config.rta) { //NOSONAR
|
|
142
130
|
config.editors ??= {};
|
|
@@ -164,7 +152,7 @@ function sanitizeConfig(config, logger) {
|
|
|
164
152
|
* @returns sanitized RTA configuration
|
|
165
153
|
*/
|
|
166
154
|
//prettier-ignore
|
|
167
|
-
function sanitizeRtaConfig(deprecatedRtaConfig, logger) {
|
|
155
|
+
export function sanitizeRtaConfig(deprecatedRtaConfig, logger) {
|
|
168
156
|
let rtaConfig;
|
|
169
157
|
if (deprecatedRtaConfig) {
|
|
170
158
|
const { editors, ...rta } = deprecatedRtaConfig;
|
|
@@ -198,7 +186,7 @@ function getFlexSettings() {
|
|
|
198
186
|
* @param app configuration for the preview
|
|
199
187
|
* @param logger logger instance
|
|
200
188
|
*/
|
|
201
|
-
async function addApp(templateConfig, manifest, app, logger) {
|
|
189
|
+
export async function addApp(templateConfig, manifest, app, logger) {
|
|
202
190
|
const id = manifest['sap.app']?.id ?? '';
|
|
203
191
|
if (manifest['sap.app']?.type === 'component') {
|
|
204
192
|
logger.debug(`No application added for id '${id}' because its type is 'component'`);
|
|
@@ -223,7 +211,7 @@ async function addApp(templateConfig, manifest, app, logger) {
|
|
|
223
211
|
* @param intent - The app configuration.
|
|
224
212
|
* @returns The application name.
|
|
225
213
|
*/
|
|
226
|
-
function getAppName(manifest, intent) {
|
|
214
|
+
export function getAppName(manifest, intent) {
|
|
227
215
|
const id = manifest['sap.app']?.id ?? '';
|
|
228
216
|
intent ??= {
|
|
229
217
|
object: id.replace(/\./g, ''),
|
|
@@ -241,13 +229,13 @@ function getAppName(manifest, intent) {
|
|
|
241
229
|
* @returns i18n text of the property
|
|
242
230
|
*/
|
|
243
231
|
async function getI18nTextFromProperty(projectRoot, propertyValue, appId, logger) {
|
|
244
|
-
const propertyI18nKey =
|
|
232
|
+
const propertyI18nKey = extractDoubleCurlyBracketsKey(propertyValue ?? '');
|
|
245
233
|
if (!projectRoot || !propertyI18nKey) {
|
|
246
234
|
return propertyValue;
|
|
247
235
|
}
|
|
248
|
-
const absolutePath =
|
|
236
|
+
const absolutePath = resolve(process.cwd(), projectRoot);
|
|
249
237
|
try {
|
|
250
|
-
const projectAccess = await
|
|
238
|
+
const projectAccess = await createProjectAccess(absolutePath);
|
|
251
239
|
const appPath = await projectAccess.getApplicationIdByManifestAppId(appId ?? '');
|
|
252
240
|
const applicationAccess = projectAccess.getApplication(appPath ?? '');
|
|
253
241
|
const bundle = (await applicationAccess.getI18nBundles())['sap.app'];
|
|
@@ -273,10 +261,10 @@ async function getI18nTextFromProperty(projectRoot, propertyValue, appId, logger
|
|
|
273
261
|
* @param newPagePath - the path of the HTML page that will serve the resources (e.g. `editor.path`)
|
|
274
262
|
* @param appId - the `sap.app.id` used as resource-root key for the primary application
|
|
275
263
|
*/
|
|
276
|
-
function remapResourcesForPath(config, newPagePath, appId) {
|
|
277
|
-
const newBasePath =
|
|
264
|
+
export function remapResourcesForPath(config, newPagePath, appId) {
|
|
265
|
+
const newBasePath = posix.relative(posix.dirname(newPagePath), '/') || '.';
|
|
278
266
|
// Update the well-known client namespace to be relative to the new page path
|
|
279
|
-
config.ui5.resources[
|
|
267
|
+
config.ui5.resources[PREVIEW_URL.client.ns] = PREVIEW_URL.client.getUrl(newBasePath);
|
|
280
268
|
// Update the primary app's resource root (was set to basePath for the main app)
|
|
281
269
|
if (appId && appId in config.ui5.resources) {
|
|
282
270
|
config.ui5.resources[appId] = newBasePath;
|
|
@@ -292,13 +280,13 @@ function remapResourcesForPath(config, newPagePath, appId) {
|
|
|
292
280
|
* @param resources additional resources
|
|
293
281
|
* @returns configuration object for the sandbox.html template
|
|
294
282
|
*/
|
|
295
|
-
function createFlpTemplateConfig(config, manifest, resources = {}) {
|
|
283
|
+
export function createFlpTemplateConfig(config, manifest, resources = {}) {
|
|
296
284
|
const flex = getFlexSettings();
|
|
297
|
-
const supportedThemes = manifest['sap.ui5']?.supportedThemes ?? [
|
|
298
|
-
const ui5Theme = config.theme ?? (supportedThemes.includes(
|
|
285
|
+
const supportedThemes = manifest['sap.ui5']?.supportedThemes ?? [DEFAULT_THEME];
|
|
286
|
+
const ui5Theme = config.theme ?? (supportedThemes.includes(DEFAULT_THEME) ? DEFAULT_THEME : supportedThemes[0]);
|
|
299
287
|
const id = manifest['sap.app']?.id ?? '';
|
|
300
288
|
const ns = id.replace(/\./g, '/');
|
|
301
|
-
const basePath =
|
|
289
|
+
const basePath = posix.relative(posix.dirname(config.path), '/') ?? '.';
|
|
302
290
|
let initPath;
|
|
303
291
|
if (config.init) {
|
|
304
292
|
const separator = config.init.startsWith('/') ? '' : '/';
|
|
@@ -315,7 +303,7 @@ function createFlpTemplateConfig(config, manifest, resources = {}) {
|
|
|
315
303
|
flex,
|
|
316
304
|
resources: {
|
|
317
305
|
...resources,
|
|
318
|
-
[
|
|
306
|
+
[PREVIEW_URL.client.ns]: PREVIEW_URL.client.getUrl(basePath)
|
|
319
307
|
},
|
|
320
308
|
bootstrapOptions: ''
|
|
321
309
|
},
|
|
@@ -332,12 +320,12 @@ function createFlpTemplateConfig(config, manifest, resources = {}) {
|
|
|
332
320
|
* @param theme theme to be used
|
|
333
321
|
* @returns configuration object for the test template
|
|
334
322
|
*/
|
|
335
|
-
function createTestTemplateConfig(config, id, theme) {
|
|
323
|
+
export function createTestTemplateConfig(config, id, theme) {
|
|
336
324
|
return {
|
|
337
325
|
id,
|
|
338
326
|
framework: config.framework,
|
|
339
|
-
basePath:
|
|
340
|
-
initPath:
|
|
327
|
+
basePath: posix.relative(posix.dirname(config.path), '/') ?? '.',
|
|
328
|
+
initPath: posix.relative(posix.dirname(config.path), config.init),
|
|
341
329
|
theme
|
|
342
330
|
};
|
|
343
331
|
}
|
|
@@ -348,7 +336,7 @@ function createTestTemplateConfig(config, id, theme) {
|
|
|
348
336
|
* @param logger logger instance
|
|
349
337
|
* @returns an array of preview paths
|
|
350
338
|
*/
|
|
351
|
-
function getPreviewPaths(config, logger = new
|
|
339
|
+
export function getPreviewPaths(config, logger = new ToolsLogger()) {
|
|
352
340
|
const urls = [];
|
|
353
341
|
// remove incorrect configurations
|
|
354
342
|
sanitizeConfig(config, logger);
|
|
@@ -371,13 +359,13 @@ function getPreviewPaths(config, logger = new logger_1.ToolsLogger()) {
|
|
|
371
359
|
// add test urls if configured
|
|
372
360
|
if (config.test) {
|
|
373
361
|
config.test.forEach((test) => {
|
|
374
|
-
const testConfig =
|
|
362
|
+
const testConfig = mergeTestConfigDefaults(test);
|
|
375
363
|
urls.push({ path: testConfig.path, type: 'test' });
|
|
376
364
|
});
|
|
377
365
|
}
|
|
378
366
|
return urls;
|
|
379
367
|
}
|
|
380
|
-
const TEMPLATE_PATH =
|
|
368
|
+
const TEMPLATE_PATH = join(__dirname, '../../templates');
|
|
381
369
|
/**
|
|
382
370
|
* Generate test runners.
|
|
383
371
|
*
|
|
@@ -389,19 +377,19 @@ const TEMPLATE_PATH = (0, node_path_1.join)(__dirname, '../../templates');
|
|
|
389
377
|
*/
|
|
390
378
|
function generateTestRunners(configs, manifest, fs, webappPath, flpTemplConfig) {
|
|
391
379
|
for (const test of configs ?? []) {
|
|
392
|
-
const testConfig =
|
|
380
|
+
const testConfig = mergeTestConfigDefaults(test);
|
|
393
381
|
if (['QUnit', 'OPA5'].includes(test.framework)) {
|
|
394
|
-
const testTemplate =
|
|
382
|
+
const testTemplate = readFileSync(join(TEMPLATE_PATH, 'test/qunit.ejs'), 'utf-8');
|
|
395
383
|
const testTemplateConfig = createTestTemplateConfig(testConfig, manifest['sap.app'].id, flpTemplConfig.ui5.theme);
|
|
396
|
-
fs.write(
|
|
384
|
+
fs.write(join(webappPath, testConfig.path), render(testTemplate, testTemplateConfig));
|
|
397
385
|
}
|
|
398
386
|
else if (test.framework === 'Testsuite') {
|
|
399
|
-
const testTemplate =
|
|
387
|
+
const testTemplate = readFileSync(join(TEMPLATE_PATH, 'test/testsuite.qunit.ejs'), 'utf-8');
|
|
400
388
|
const testTemplateConfig = {
|
|
401
389
|
basePath: flpTemplConfig.basePath,
|
|
402
390
|
initPath: testConfig.init
|
|
403
391
|
};
|
|
404
|
-
fs.write(
|
|
392
|
+
fs.write(join(webappPath, testConfig.path), render(testTemplate, testTemplateConfig));
|
|
405
393
|
}
|
|
406
394
|
}
|
|
407
395
|
}
|
|
@@ -414,24 +402,24 @@ function generateTestRunners(configs, manifest, fs, webappPath, flpTemplConfig)
|
|
|
414
402
|
* @param logger logger instance
|
|
415
403
|
* @returns a mem-fs editor with the preview files
|
|
416
404
|
*/
|
|
417
|
-
async function generatePreviewFiles(basePath, config, fs, logger = new
|
|
405
|
+
export async function generatePreviewFiles(basePath, config, fs, logger = new ToolsLogger()) {
|
|
418
406
|
// remove incorrect configurations
|
|
419
407
|
sanitizeConfig(config, logger);
|
|
420
408
|
// create file system if not provided
|
|
421
|
-
fs ??=
|
|
409
|
+
fs ??= create(createStorage());
|
|
422
410
|
// generate FLP configuration
|
|
423
|
-
const flpTemplate =
|
|
411
|
+
const flpTemplate = readFileSync(join(TEMPLATE_PATH, 'flp/sandbox.ejs'), 'utf-8');
|
|
424
412
|
const flpConfig = getFlpConfigWithDefaults(config.flp);
|
|
425
|
-
const webappPath = await
|
|
413
|
+
const webappPath = await getWebappPath(basePath, fs);
|
|
426
414
|
let manifest;
|
|
427
|
-
if (fs.exists(
|
|
428
|
-
manifest = (await fs.readJSON(
|
|
415
|
+
if (fs.exists(join(webappPath, 'manifest.json'))) {
|
|
416
|
+
manifest = (await fs.readJSON(join(webappPath, 'manifest.json')));
|
|
429
417
|
}
|
|
430
418
|
let flpTemplConfig;
|
|
431
419
|
let flpPath;
|
|
432
420
|
if (manifest) {
|
|
433
421
|
flpTemplConfig = createFlpTemplateConfig(flpConfig, manifest);
|
|
434
|
-
flpPath =
|
|
422
|
+
flpPath = join(webappPath, flpConfig.path);
|
|
435
423
|
await addApp(flpTemplConfig, manifest, {
|
|
436
424
|
target: flpTemplConfig.basePath,
|
|
437
425
|
local: '.',
|
|
@@ -441,14 +429,14 @@ async function generatePreviewFiles(basePath, config, fs, logger = new logger_1.
|
|
|
441
429
|
}
|
|
442
430
|
else {
|
|
443
431
|
flpTemplConfig = createFlpTemplateConfig(flpConfig, {});
|
|
444
|
-
flpPath =
|
|
432
|
+
flpPath = join(basePath, flpConfig.path);
|
|
445
433
|
}
|
|
446
434
|
if (flpConfig.apps.length > 0) {
|
|
447
435
|
for (const app of flpConfig.apps) {
|
|
448
436
|
if (app.local) {
|
|
449
|
-
const appPath = await
|
|
450
|
-
if (fs.exists(
|
|
451
|
-
const appManifest = (await fs.readJSON(
|
|
437
|
+
const appPath = await getWebappPath(join(basePath, app.local), fs);
|
|
438
|
+
if (fs.exists(join(appPath, 'manifest.json'))) {
|
|
439
|
+
const appManifest = (await fs.readJSON(join(appPath, 'manifest.json')));
|
|
452
440
|
await addApp(flpTemplConfig, appManifest, app, logger);
|
|
453
441
|
}
|
|
454
442
|
else {
|
|
@@ -457,7 +445,7 @@ async function generatePreviewFiles(basePath, config, fs, logger = new logger_1.
|
|
|
457
445
|
}
|
|
458
446
|
}
|
|
459
447
|
}
|
|
460
|
-
fs.write(flpPath,
|
|
448
|
+
fs.write(flpPath, render(flpTemplate, flpTemplConfig));
|
|
461
449
|
return fs;
|
|
462
450
|
}
|
|
463
451
|
//# sourceMappingURL=config.js.map
|
package/dist/base/flex.js
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.readChanges = readChanges;
|
|
4
|
-
exports.readLocalModulePaths = readLocalModulePaths;
|
|
5
|
-
exports.stripLocalModulesFromLrepResponse = stripLocalModulesFromLrepResponse;
|
|
6
|
-
exports.writeChange = writeChange;
|
|
7
|
-
exports.deleteChange = deleteChange;
|
|
8
|
-
const node_fs_1 = require("node:fs");
|
|
9
|
-
const node_path_1 = require("node:path");
|
|
1
|
+
import { existsSync, readdirSync, statSync, unlinkSync } from 'node:fs';
|
|
2
|
+
import { join, parse, sep } from 'node:path';
|
|
10
3
|
/**
|
|
11
4
|
* Read changes from the file system and return them.
|
|
12
5
|
*
|
|
@@ -14,12 +7,12 @@ const node_path_1 = require("node:path");
|
|
|
14
7
|
* @param logger logger instance
|
|
15
8
|
* @returns object with the file name as key and the file content as value
|
|
16
9
|
*/
|
|
17
|
-
async function readChanges(project, logger) {
|
|
10
|
+
export async function readChanges(project, logger) {
|
|
18
11
|
const changes = {};
|
|
19
12
|
const files = await project.byGlob('/**/changes/**/*.{change,variant,ctrl_variant,ctrl_variant_change,ctrl_variant_management_change}');
|
|
20
13
|
for (const file of files) {
|
|
21
14
|
try {
|
|
22
|
-
changes[`sap.ui.fl.${
|
|
15
|
+
changes[`sap.ui.fl.${parse(file.getName()).name}`] = JSON.parse(await file.getString());
|
|
23
16
|
logger.debug(`Read change from ${file.getPath()}`);
|
|
24
17
|
}
|
|
25
18
|
catch (error) {
|
|
@@ -51,7 +44,7 @@ function extractLocalModulePath(changeType, content) {
|
|
|
51
44
|
* @param logger logger instance
|
|
52
45
|
* @returns LocalModuleState with `active` and `orphaned` sets of relative paths under /changes/
|
|
53
46
|
*/
|
|
54
|
-
async function readLocalModulePaths(project, logger) {
|
|
47
|
+
export async function readLocalModulePaths(project, logger) {
|
|
55
48
|
const active = new Set();
|
|
56
49
|
const orphaned = new Set();
|
|
57
50
|
const changeFiles = await project.byGlob('/**/changes/**/*.{change,variant,ctrl_variant,ctrl_variant_change,ctrl_variant_management_change}');
|
|
@@ -215,7 +208,7 @@ function processChanges(result, state, logger) {
|
|
|
215
208
|
* @param logger logger instance
|
|
216
209
|
* @returns the (possibly patched) response data
|
|
217
210
|
*/
|
|
218
|
-
function stripLocalModulesFromLrepResponse(responseData, localModuleState, logger) {
|
|
211
|
+
export function stripLocalModulesFromLrepResponse(responseData, localModuleState, logger) {
|
|
219
212
|
if (localModuleState.active.size === 0 && localModuleState.orphaned.size === 0) {
|
|
220
213
|
return responseData;
|
|
221
214
|
}
|
|
@@ -242,12 +235,12 @@ function stripLocalModulesFromLrepResponse(responseData, localModuleState, logge
|
|
|
242
235
|
* @param logger logger instance
|
|
243
236
|
* @returns object with success flag and optional message
|
|
244
237
|
*/
|
|
245
|
-
function writeChange(data, webappPath, fs, logger) {
|
|
238
|
+
export function writeChange(data, webappPath, fs, logger) {
|
|
246
239
|
const fileName = data.fileName;
|
|
247
240
|
const fileType = data.fileType;
|
|
248
241
|
if (fileName && fileType) {
|
|
249
242
|
logger.debug(`Write change ${fileName}.${fileType}`);
|
|
250
|
-
const filePath =
|
|
243
|
+
const filePath = join(webappPath, 'changes', fileName + '.' + fileType);
|
|
251
244
|
fs.writeJSON(filePath, data);
|
|
252
245
|
const message = `FILE_CREATED ${fileName}.${fileType}`;
|
|
253
246
|
return { success: true, message };
|
|
@@ -265,19 +258,19 @@ function writeChange(data, webappPath, fs, logger) {
|
|
|
265
258
|
* @param logger logger instance
|
|
266
259
|
* @returns object with success flag and optional message
|
|
267
260
|
*/
|
|
268
|
-
function deleteChange(data, webappPath, logger) {
|
|
261
|
+
export function deleteChange(data, webappPath, logger) {
|
|
269
262
|
const fileName = data.fileName?.replace('sap.ui.fl.', '');
|
|
270
263
|
if (fileName) {
|
|
271
|
-
const path =
|
|
272
|
-
if (
|
|
264
|
+
const path = join(webappPath, 'changes');
|
|
265
|
+
if (existsSync(path)) {
|
|
273
266
|
// Changes can be in subfolders of changes directory. For eg: New Annotation File Change
|
|
274
267
|
const files = [];
|
|
275
268
|
readDirectoriesRecursively(path, files);
|
|
276
269
|
const filePath = files.find((element) => element.includes(fileName));
|
|
277
270
|
if (filePath) {
|
|
278
|
-
const fileNameWithExt = filePath.split(
|
|
271
|
+
const fileNameWithExt = filePath.split(sep).pop();
|
|
279
272
|
logger.debug(`Write change ${fileNameWithExt}`);
|
|
280
|
-
|
|
273
|
+
unlinkSync(filePath);
|
|
281
274
|
return { success: true, message: `FILE_DELETED ${fileNameWithExt}` };
|
|
282
275
|
}
|
|
283
276
|
}
|
|
@@ -291,10 +284,10 @@ function deleteChange(data, webappPath, logger) {
|
|
|
291
284
|
* @param files all files in the given folder and subfolders.
|
|
292
285
|
*/
|
|
293
286
|
function readDirectoriesRecursively(path, files = []) {
|
|
294
|
-
const items =
|
|
287
|
+
const items = readdirSync(path);
|
|
295
288
|
items.forEach((item) => {
|
|
296
|
-
const fullPath =
|
|
297
|
-
const stats =
|
|
289
|
+
const fullPath = join(path, item);
|
|
290
|
+
const stats = statSync(fullPath);
|
|
298
291
|
if (stats.isDirectory()) {
|
|
299
292
|
readDirectoriesRecursively(fullPath, files);
|
|
300
293
|
}
|
package/dist/base/flp.d.ts
CHANGED
|
@@ -5,8 +5,8 @@ import type { Logger } from '@sap-ux/logger';
|
|
|
5
5
|
import type { MiddlewareUtils } from '@ui5/server';
|
|
6
6
|
import { type Manifest } from '@sap-ux/project-access';
|
|
7
7
|
import { AdpPreview, type AdpPreviewConfig, type CommonChangeProperties, type OperationType, type CommonAdditionalChangeInfoProperties } from '@sap-ux/adp-tooling';
|
|
8
|
-
import type { FlpConfig, MiddlewareConfig, RtaConfig, TestConfig } from '../types';
|
|
9
|
-
import { type TemplateConfig } from './config';
|
|
8
|
+
import type { FlpConfig, MiddlewareConfig, RtaConfig, TestConfig } from '../types/index.js';
|
|
9
|
+
import { type TemplateConfig } from './config.js';
|
|
10
10
|
/**
|
|
11
11
|
* Enhanced request handler that exposes a list of endpoints for the cds-plugin-ui5.
|
|
12
12
|
*/
|