@sap-ux/preview-middleware 0.26.11 → 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.
Files changed (196) hide show
  1. package/dist/base/cdm.d.ts +2 -2
  2. package/dist/base/cdm.js +10 -11
  3. package/dist/base/config.d.ts +1 -1
  4. package/dist/base/config.js +60 -72
  5. package/dist/base/flex.js +16 -23
  6. package/dist/base/flp.d.ts +2 -2
  7. package/dist/base/flp.js +96 -96
  8. package/dist/base/index.d.ts +3 -3
  9. package/dist/base/index.js +3 -12
  10. package/dist/base/remote-url.js +14 -24
  11. package/dist/base/test.d.ts +1 -1
  12. package/dist/base/test.js +2 -6
  13. package/dist/base/utils/cards.d.ts +1 -1
  14. package/dist/base/utils/cards.js +3 -9
  15. package/dist/client/adp/add-fragment.js +4 -4
  16. package/dist/client/adp/add-fragment.ts +2 -2
  17. package/dist/client/adp/api-handler.js +2 -2
  18. package/dist/client/adp/api-handler.ts +1 -1
  19. package/dist/client/adp/command-executor.js +3 -3
  20. package/dist/client/adp/command-executor.ts +2 -2
  21. package/dist/client/adp/controllers/AddActionFragment.controller.js +5 -5
  22. package/dist/client/adp/controllers/AddActionFragment.controller.ts +7 -7
  23. package/dist/client/adp/controllers/AddCustomFragment.controller.js +7 -7
  24. package/dist/client/adp/controllers/AddCustomFragment.controller.ts +9 -9
  25. package/dist/client/adp/controllers/AddFragment.controller.js +7 -7
  26. package/dist/client/adp/controllers/AddFragment.controller.ts +11 -11
  27. package/dist/client/adp/controllers/AddSubpage.controller.js +4 -4
  28. package/dist/client/adp/controllers/AddSubpage.controller.ts +7 -7
  29. package/dist/client/adp/controllers/AddTableColumnFragments.controller.js +7 -7
  30. package/dist/client/adp/controllers/AddTableColumnFragments.controller.ts +11 -11
  31. package/dist/client/adp/controllers/BaseDialog.controller.js +3 -3
  32. package/dist/client/adp/controllers/BaseDialog.controller.ts +6 -6
  33. package/dist/client/adp/controllers/ControllerExtension.controller.js +14 -14
  34. package/dist/client/adp/controllers/ControllerExtension.controller.ts +12 -12
  35. package/dist/client/adp/controllers/ExtensionPoint.controller.js +4 -4
  36. package/dist/client/adp/controllers/ExtensionPoint.controller.ts +5 -5
  37. package/dist/client/adp/controllers/FileExistsDialog.controller.js +2 -2
  38. package/dist/client/adp/controllers/FileExistsDialog.controller.ts +2 -2
  39. package/dist/client/adp/dialog-factory.js +2 -2
  40. package/dist/client/adp/dialog-factory.ts +16 -16
  41. package/dist/client/adp/extend-controller.js +4 -4
  42. package/dist/client/adp/extend-controller.ts +2 -2
  43. package/dist/client/adp/extension-point.js +5 -5
  44. package/dist/client/adp/extension-point.ts +4 -4
  45. package/dist/client/adp/init-dialogs.js +6 -6
  46. package/dist/client/adp/init-dialogs.ts +6 -6
  47. package/dist/client/adp/init.js +13 -13
  48. package/dist/client/adp/init.ts +9 -9
  49. package/dist/client/adp/quick-actions/add-new-subpage-quick-action-base.js +8 -8
  50. package/dist/client/adp/quick-actions/add-new-subpage-quick-action-base.ts +10 -10
  51. package/dist/client/adp/quick-actions/common/add-controller-to-page.js +13 -13
  52. package/dist/client/adp/quick-actions/common/add-controller-to-page.ts +11 -11
  53. package/dist/client/adp/quick-actions/common/add-new-annotation-file.js +11 -11
  54. package/dist/client/adp/quick-actions/common/add-new-annotation-file.ts +10 -10
  55. package/dist/client/adp/quick-actions/common/create-page-action.js +8 -8
  56. package/dist/client/adp/quick-actions/common/create-page-action.ts +7 -7
  57. package/dist/client/adp/quick-actions/common/op-add-custom-section.js +6 -6
  58. package/dist/client/adp/quick-actions/common/op-add-custom-section.ts +5 -5
  59. package/dist/client/adp/quick-actions/common/op-add-header-field.js +7 -7
  60. package/dist/client/adp/quick-actions/common/op-add-header-field.ts +7 -7
  61. package/dist/client/adp/quick-actions/common/utils.ts +1 -1
  62. package/dist/client/adp/quick-actions/dialog-enablement-validator.js +3 -3
  63. package/dist/client/adp/quick-actions/dialog-enablement-validator.ts +3 -3
  64. package/dist/client/adp/quick-actions/fe-v2/add-new-subpage.js +6 -6
  65. package/dist/client/adp/quick-actions/fe-v2/add-new-subpage.ts +5 -5
  66. package/dist/client/adp/quick-actions/fe-v2/change-table-actions.js +5 -5
  67. package/dist/client/adp/quick-actions/fe-v2/change-table-actions.ts +5 -5
  68. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.js +7 -7
  69. package/dist/client/adp/quick-actions/fe-v2/change-table-columns.ts +5 -5
  70. package/dist/client/adp/quick-actions/fe-v2/create-table-action.js +11 -11
  71. package/dist/client/adp/quick-actions/fe-v2/create-table-action.ts +6 -6
  72. package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.js +13 -13
  73. package/dist/client/adp/quick-actions/fe-v2/create-table-custom-column.ts +7 -7
  74. package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.js +9 -9
  75. package/dist/client/adp/quick-actions/fe-v2/lr-enable-semantic-date-range-filter-bar.ts +6 -6
  76. package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.js +11 -11
  77. package/dist/client/adp/quick-actions/fe-v2/lr-enable-table-filtering.ts +6 -6
  78. package/dist/client/adp/quick-actions/fe-v2/lr-enable-variant-management.js +4 -4
  79. package/dist/client/adp/quick-actions/fe-v2/lr-enable-variant-management.ts +3 -3
  80. package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.js +4 -4
  81. package/dist/client/adp/quick-actions/fe-v2/lr-toggle-clear-filter-bar.ts +4 -4
  82. package/dist/client/adp/quick-actions/fe-v2/op-enable-empty-row-mode.js +12 -12
  83. package/dist/client/adp/quick-actions/fe-v2/op-enable-empty-row-mode.ts +8 -8
  84. package/dist/client/adp/quick-actions/fe-v2/op-enable-variant-management.js +6 -6
  85. package/dist/client/adp/quick-actions/fe-v2/op-enable-variant-management.ts +5 -5
  86. package/dist/client/adp/quick-actions/fe-v2/registry.js +18 -18
  87. package/dist/client/adp/quick-actions/fe-v2/registry.ts +18 -18
  88. package/dist/client/adp/quick-actions/fe-v2/utils.js +4 -4
  89. package/dist/client/adp/quick-actions/fe-v2/utils.ts +2 -2
  90. package/dist/client/adp/quick-actions/fe-v4/add-new-subpage.js +7 -7
  91. package/dist/client/adp/quick-actions/fe-v4/add-new-subpage.ts +5 -5
  92. package/dist/client/adp/quick-actions/fe-v4/change-table-actions.js +9 -9
  93. package/dist/client/adp/quick-actions/fe-v4/change-table-actions.ts +7 -7
  94. package/dist/client/adp/quick-actions/fe-v4/change-table-columns.js +6 -6
  95. package/dist/client/adp/quick-actions/fe-v4/change-table-columns.ts +6 -6
  96. package/dist/client/adp/quick-actions/fe-v4/create-page-action.js +11 -11
  97. package/dist/client/adp/quick-actions/fe-v4/create-page-action.ts +9 -9
  98. package/dist/client/adp/quick-actions/fe-v4/create-table-action-config-change.js +13 -13
  99. package/dist/client/adp/quick-actions/fe-v4/create-table-action-config-change.ts +11 -11
  100. package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column-config-change.js +16 -16
  101. package/dist/client/adp/quick-actions/fe-v4/create-table-custom-column-config-change.ts +9 -9
  102. package/dist/client/adp/quick-actions/fe-v4/enable-variant-management.js +5 -5
  103. package/dist/client/adp/quick-actions/fe-v4/enable-variant-management.ts +4 -4
  104. package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.js +5 -5
  105. package/dist/client/adp/quick-actions/fe-v4/lr-enable-semantic-date-range-filter-bar.ts +5 -5
  106. package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.js +7 -7
  107. package/dist/client/adp/quick-actions/fe-v4/lr-enable-table-filtering.ts +6 -6
  108. package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.js +5 -5
  109. package/dist/client/adp/quick-actions/fe-v4/lr-toggle-clear-filter-bar.ts +5 -5
  110. package/dist/client/adp/quick-actions/fe-v4/op-add-custom-section.js +8 -8
  111. package/dist/client/adp/quick-actions/fe-v4/op-add-custom-section.ts +8 -8
  112. package/dist/client/adp/quick-actions/fe-v4/op-enable-empty-row-mode.js +12 -12
  113. package/dist/client/adp/quick-actions/fe-v4/op-enable-empty-row-mode.ts +8 -8
  114. package/dist/client/adp/quick-actions/fe-v4/registry.js +17 -17
  115. package/dist/client/adp/quick-actions/fe-v4/registry.ts +17 -17
  116. package/dist/client/adp/quick-actions/fe-v4/utils.js +6 -6
  117. package/dist/client/adp/quick-actions/fe-v4/utils.ts +3 -3
  118. package/dist/client/adp/quick-actions/load.ts +2 -2
  119. package/dist/client/adp/quick-actions/quick-action-base.js +2 -2
  120. package/dist/client/adp/quick-actions/quick-action-base.ts +3 -3
  121. package/dist/client/adp/quick-actions/simple-quick-action-base.js +3 -3
  122. package/dist/client/adp/quick-actions/simple-quick-action-base.ts +4 -4
  123. package/dist/client/adp/quick-actions/table-quick-action-base.js +17 -17
  124. package/dist/client/adp/quick-actions/table-quick-action-base.ts +9 -9
  125. package/dist/client/adp/sync-views-utils.js +4 -4
  126. package/dist/client/adp/sync-views-utils.ts +3 -3
  127. package/dist/client/adp/utils.js +3 -3
  128. package/dist/client/adp/utils.ts +2 -2
  129. package/dist/client/cpe/additional-change-info/add-xml-additional-info.js +7 -7
  130. package/dist/client/cpe/additional-change-info/add-xml-additional-info.ts +2 -2
  131. package/dist/client/cpe/changes/flex-change.js +3 -3
  132. package/dist/client/cpe/changes/flex-change.ts +3 -3
  133. package/dist/client/cpe/changes/generic-change.js +5 -5
  134. package/dist/client/cpe/changes/generic-change.ts +4 -4
  135. package/dist/client/cpe/changes/index.js +2 -2
  136. package/dist/client/cpe/changes/index.ts +1 -1
  137. package/dist/client/cpe/changes/service.js +12 -12
  138. package/dist/client/cpe/changes/service.ts +9 -9
  139. package/dist/client/cpe/changes/validator.js +2 -2
  140. package/dist/client/cpe/changes/validator.ts +1 -1
  141. package/dist/client/cpe/communication-service.js +2 -2
  142. package/dist/client/cpe/communication-service.ts +2 -2
  143. package/dist/client/cpe/connector-service.js +3 -3
  144. package/dist/client/cpe/connector-service.ts +3 -3
  145. package/dist/client/cpe/context-menu-service.js +6 -6
  146. package/dist/client/cpe/context-menu-service.ts +6 -6
  147. package/dist/client/cpe/control-data.js +3 -3
  148. package/dist/client/cpe/control-data.ts +5 -5
  149. package/dist/client/cpe/documentation.js +4 -4
  150. package/dist/client/cpe/documentation.ts +5 -5
  151. package/dist/client/cpe/init.js +15 -15
  152. package/dist/client/cpe/init.ts +16 -16
  153. package/dist/client/cpe/odata-health/odata-health-checker.js +5 -5
  154. package/dist/client/cpe/odata-health/odata-health-checker.ts +10 -10
  155. package/dist/client/cpe/outline/editable.js +4 -4
  156. package/dist/client/cpe/outline/editable.ts +4 -4
  157. package/dist/client/cpe/outline/nodes.js +7 -7
  158. package/dist/client/cpe/outline/nodes.ts +7 -7
  159. package/dist/client/cpe/outline/service.js +3 -3
  160. package/dist/client/cpe/outline/service.ts +4 -4
  161. package/dist/client/cpe/quick-actions/quick-action-service.js +5 -5
  162. package/dist/client/cpe/quick-actions/quick-action-service.ts +10 -10
  163. package/dist/client/cpe/quick-actions/registry.js +3 -3
  164. package/dist/client/cpe/quick-actions/registry.ts +4 -4
  165. package/dist/client/cpe/quick-actions/utils.js +3 -3
  166. package/dist/client/cpe/quick-actions/utils.ts +2 -2
  167. package/dist/client/cpe/rta-service.ts +1 -1
  168. package/dist/client/cpe/selection.js +8 -8
  169. package/dist/client/cpe/selection.ts +7 -7
  170. package/dist/client/cpe/utils.js +2 -2
  171. package/dist/client/cpe/utils.ts +2 -2
  172. package/dist/client/flp/WorkspaceConnector.js +6 -6
  173. package/dist/client/flp/WorkspaceConnector.ts +4 -4
  174. package/dist/client/flp/enableFakeConnector.js +4 -4
  175. package/dist/client/flp/enableFakeConnector.ts +3 -3
  176. package/dist/client/flp/init.js +6 -6
  177. package/dist/client/flp/init.ts +5 -5
  178. package/dist/client/flp/initConnectors.js +3 -3
  179. package/dist/client/flp/initConnectors.ts +1 -1
  180. package/dist/client/thirdparty/@sap-ux-private/control-property-editor-common.js +397 -477
  181. package/dist/client/utils/additional-change-info.js +2 -2
  182. package/dist/client/utils/additional-change-info.ts +2 -2
  183. package/dist/client/utils/core.js +2 -2
  184. package/dist/client/utils/core.ts +1 -1
  185. package/dist/client/utils/fe-v4.js +3 -3
  186. package/dist/client/utils/fe-v4.ts +2 -2
  187. package/dist/client/utils/info-center-message.js +3 -3
  188. package/dist/client/utils/info-center-message.ts +2 -2
  189. package/dist/client/utils/version.js +2 -2
  190. package/dist/client/utils/version.ts +1 -1
  191. package/dist/index.d.ts +3 -3
  192. package/dist/index.js +2 -25
  193. package/dist/types/index.js +1 -4
  194. package/dist/ui5/middleware.d.ts +11 -1
  195. package/dist/ui5/middleware.js +13 -15
  196. package/package.json +18 -16
@@ -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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateCdm = generateCdm;
4
- const node_fs_1 = require("node:fs");
5
- const node_path_1 = require("node:path");
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((0, node_fs_1.readFileSync)((0, node_path_1.join)(__dirname, '../../templates/flp/cdm.base.json'), 'utf-8'));
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[types_1.FLPHomePageDefaults.catalogId].payload.viz.push(vizId);
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[types_1.FLPHomePageDefaults.pageName].payload.sections[types_1.FLPHomePageDefaults.sectionId].layout.vizOrder.push(appId);
80
- cdm.pages[types_1.FLPHomePageDefaults.pageName].payload.sections[types_1.FLPHomePageDefaults.sectionId].viz[appId] = {
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
  };
@@ -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';
@@ -1,39 +1,27 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DEFAULT_INTENT = exports.DEFAULT_PATH = exports.DEFAULT_THEME = exports.CARD_GENERATOR_DEFAULT = exports.PREVIEW_URL = void 0;
4
- exports.isFlexConnector = isFlexConnector;
5
- exports.getFlpConfigWithDefaults = getFlpConfigWithDefaults;
6
- exports.sanitizeConfig = sanitizeConfig;
7
- exports.sanitizeRtaConfig = sanitizeRtaConfig;
8
- exports.addApp = addApp;
9
- exports.getAppName = getAppName;
10
- exports.remapResourcesForPath = remapResourcesForPath;
11
- exports.createFlpTemplateConfig = createFlpTemplateConfig;
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
- exports.PREVIEW_URL = {
15
+ export const PREVIEW_URL = {
28
16
  client: {
29
17
  path: '/preview/client',
30
- getUrl: (basePath) => node_path_1.posix.join(basePath, 'preview', 'client'),
31
- local: (0, node_path_1.join)(__dirname, '../../dist/client'),
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
- exports.CARD_GENERATOR_DEFAULT = {
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
- exports.DEFAULT_THEME = 'sap_horizon';
32
+ export const DEFAULT_THEME = 'sap_horizon';
45
33
  /**
46
34
  * Default path for mounting the local FLP.
47
35
  */
48
- exports.DEFAULT_PATH = '/test/flp.html';
36
+ export const DEFAULT_PATH = '/test/flp.html';
49
37
  /**
50
38
  * Default intent
51
39
  */
52
- exports.DEFAULT_INTENT = {
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 ?? exports.DEFAULT_PATH,
121
- intent: config.intent ?? exports.DEFAULT_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 = (0, i18n_1.extractDoubleCurlyBracketsKey)(propertyValue ?? '');
232
+ const propertyI18nKey = extractDoubleCurlyBracketsKey(propertyValue ?? '');
245
233
  if (!projectRoot || !propertyI18nKey) {
246
234
  return propertyValue;
247
235
  }
248
- const absolutePath = (0, node_path_1.resolve)(process.cwd(), projectRoot);
236
+ const absolutePath = resolve(process.cwd(), projectRoot);
249
237
  try {
250
- const projectAccess = await (0, project_access_1.createProjectAccess)(absolutePath);
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 = node_path_1.posix.relative(node_path_1.posix.dirname(newPagePath), '/') || '.';
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[exports.PREVIEW_URL.client.ns] = exports.PREVIEW_URL.client.getUrl(newBasePath);
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 ?? [exports.DEFAULT_THEME];
298
- const ui5Theme = config.theme ?? (supportedThemes.includes(exports.DEFAULT_THEME) ? exports.DEFAULT_THEME : supportedThemes[0]);
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 = node_path_1.posix.relative(node_path_1.posix.dirname(config.path), '/') ?? '.';
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
- [exports.PREVIEW_URL.client.ns]: exports.PREVIEW_URL.client.getUrl(basePath)
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: node_path_1.posix.relative(node_path_1.posix.dirname(config.path), '/') ?? '.',
340
- initPath: node_path_1.posix.relative(node_path_1.posix.dirname(config.path), config.init),
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 logger_1.ToolsLogger()) {
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 = (0, test_1.mergeTestConfigDefaults)(test);
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 = (0, node_path_1.join)(__dirname, '../../templates');
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 = (0, test_1.mergeTestConfigDefaults)(test);
380
+ const testConfig = mergeTestConfigDefaults(test);
393
381
  if (['QUnit', 'OPA5'].includes(test.framework)) {
394
- const testTemplate = (0, node_fs_1.readFileSync)((0, node_path_1.join)(TEMPLATE_PATH, 'test/qunit.ejs'), 'utf-8');
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((0, node_path_1.join)(webappPath, testConfig.path), (0, ejs_1.render)(testTemplate, testTemplateConfig));
384
+ fs.write(join(webappPath, testConfig.path), render(testTemplate, testTemplateConfig));
397
385
  }
398
386
  else if (test.framework === 'Testsuite') {
399
- const testTemplate = (0, node_fs_1.readFileSync)((0, node_path_1.join)(TEMPLATE_PATH, 'test/testsuite.qunit.ejs'), 'utf-8');
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((0, node_path_1.join)(webappPath, testConfig.path), (0, ejs_1.render)(testTemplate, testTemplateConfig));
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 logger_1.ToolsLogger()) {
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 ??= (0, mem_fs_editor_1.create)((0, mem_fs_1.create)());
409
+ fs ??= create(createStorage());
422
410
  // generate FLP configuration
423
- const flpTemplate = (0, node_fs_1.readFileSync)((0, node_path_1.join)(TEMPLATE_PATH, 'flp/sandbox.ejs'), 'utf-8');
411
+ const flpTemplate = readFileSync(join(TEMPLATE_PATH, 'flp/sandbox.ejs'), 'utf-8');
424
412
  const flpConfig = getFlpConfigWithDefaults(config.flp);
425
- const webappPath = await (0, project_access_1.getWebappPath)(basePath, fs);
413
+ const webappPath = await getWebappPath(basePath, fs);
426
414
  let manifest;
427
- if (fs.exists((0, node_path_1.join)(webappPath, 'manifest.json'))) {
428
- manifest = (await fs.readJSON((0, node_path_1.join)(webappPath, 'manifest.json')));
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 = (0, node_path_1.join)(webappPath, flpConfig.path);
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 = (0, node_path_1.join)(basePath, flpConfig.path);
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 (0, project_access_1.getWebappPath)((0, node_path_1.join)(basePath, app.local), fs);
450
- if (fs.exists((0, node_path_1.join)(appPath, 'manifest.json'))) {
451
- const appManifest = (await fs.readJSON((0, node_path_1.join)(appPath, 'manifest.json')));
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, (0, ejs_1.render)(flpTemplate, flpTemplConfig));
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
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
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.${(0, node_path_1.parse)(file.getName()).name}`] = JSON.parse(await file.getString());
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 = (0, node_path_1.join)(webappPath, 'changes', fileName + '.' + fileType);
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 = (0, node_path_1.join)(webappPath, 'changes');
272
- if ((0, node_fs_1.existsSync)(path)) {
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(node_path_1.sep).pop();
271
+ const fileNameWithExt = filePath.split(sep).pop();
279
272
  logger.debug(`Write change ${fileNameWithExt}`);
280
- (0, node_fs_1.unlinkSync)(filePath);
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 = (0, node_fs_1.readdirSync)(path);
287
+ const items = readdirSync(path);
295
288
  items.forEach((item) => {
296
- const fullPath = (0, node_path_1.join)(path, item);
297
- const stats = (0, node_fs_1.statSync)(fullPath);
289
+ const fullPath = join(path, item);
290
+ const stats = statSync(fullPath);
298
291
  if (stats.isDirectory()) {
299
292
  readDirectoriesRecursively(fullPath, files);
300
293
  }
@@ -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
  */