@sap-ux/preview-middleware 0.8.3 → 0.8.4

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.
@@ -1,9 +1,10 @@
1
1
  import type { ReaderCollection } from '@ui5/fs';
2
2
  import type { Router } from 'express';
3
3
  import type { App, FlpConfig, MiddlewareConfig, RtaConfig } from '../types';
4
- import type { Logger } from '@sap-ux/logger';
4
+ import type { Logger, ToolsLogger } from '@sap-ux/logger';
5
5
  import type { MiddlewareUtils } from '@ui5/server';
6
6
  import type { Manifest, UI5FlexLayer } from '@sap-ux/project-access';
7
+ import { type AdpPreviewConfig } from '@sap-ux/adp-tooling';
7
8
  /**
8
9
  * Enhanced request handler that exposes a list of endpoints for the cds-plugin-ui5.
9
10
  */
@@ -115,4 +116,14 @@ export declare class FlpSandbox {
115
116
  */
116
117
  addApp(manifest: Manifest, app: App): void;
117
118
  }
119
+ /**
120
+ * Initialize the preview for an adaptation project.
121
+ *
122
+ * @param rootProject reference to the project
123
+ * @param config configuration from the ui5.yaml
124
+ * @param flp FlpSandbox instance
125
+ * @param util middleware utilities provided by the UI5 CLI
126
+ * @param logger logger instance
127
+ */
128
+ export declare function initAdp(rootProject: ReaderCollection, config: AdpPreviewConfig, flp: FlpSandbox, util: MiddlewareUtils, logger: ToolsLogger): Promise<void>;
118
129
  //# sourceMappingURL=flp.d.ts.map
package/dist/base/flp.js CHANGED
@@ -9,12 +9,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.FlpSandbox = void 0;
12
+ exports.initAdp = exports.FlpSandbox = void 0;
13
13
  const ejs_1 = require("ejs");
14
14
  const fs_1 = require("fs");
15
15
  const path_1 = require("path");
16
16
  const express_1 = require("express");
17
17
  const flex_1 = require("./flex");
18
+ const adp_tooling_1 = require("@sap-ux/adp-tooling");
18
19
  const DEVELOPER_MODE_CONFIG = new Map([
19
20
  // Run application in design time mode
20
21
  // Adds bindingString to BindingInfo objects. Required to create and read PropertyBinding changes
@@ -334,4 +335,41 @@ function serializeDataAttributes(attributes, indent = '', prefix = 'data') {
334
335
  function serializeUi5Configuration(config) {
335
336
  return '\n' + serializeDataAttributes(config, ' ', 'data-sap-ui');
336
337
  }
338
+ /**
339
+ * Initialize the preview for an adaptation project.
340
+ *
341
+ * @param rootProject reference to the project
342
+ * @param config configuration from the ui5.yaml
343
+ * @param flp FlpSandbox instance
344
+ * @param util middleware utilities provided by the UI5 CLI
345
+ * @param logger logger instance
346
+ */
347
+ function initAdp(rootProject, config, flp, util, logger) {
348
+ var _a;
349
+ return __awaiter(this, void 0, void 0, function* () {
350
+ const appVariant = yield rootProject.byPath('/manifest.appdescr_variant');
351
+ if (appVariant) {
352
+ const adp = new adp_tooling_1.AdpPreview(config, rootProject, util, logger);
353
+ const variant = JSON.parse(yield appVariant.getString());
354
+ const layer = yield adp.init(variant);
355
+ if (flp.rta) {
356
+ flp.rta.layer = layer;
357
+ flp.rta.options = {
358
+ projectId: variant.id,
359
+ scenario: 'ADAPTATION_PROJECT'
360
+ };
361
+ for (const editor of flp.rta.editors) {
362
+ (_a = editor.pluginScript) !== null && _a !== void 0 ? _a : (editor.pluginScript = 'open/ux/preview/client/adp/init');
363
+ }
364
+ }
365
+ yield flp.init(adp.descriptor.manifest, adp.descriptor.name, adp.resources);
366
+ flp.router.use(adp.descriptor.url, adp.proxy.bind(adp));
367
+ adp.addApis(flp.router);
368
+ }
369
+ else {
370
+ throw new Error('ADP configured but no manifest.appdescr_variant found.');
371
+ }
372
+ });
373
+ }
374
+ exports.initAdp = initAdp;
337
375
  //# sourceMappingURL=flp.js.map
@@ -1,2 +1,2 @@
1
- export { FlpSandbox } from './flp';
1
+ export { FlpSandbox, initAdp } from './flp';
2
2
  //# sourceMappingURL=index.d.ts.map
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FlpSandbox = void 0;
3
+ exports.initAdp = exports.FlpSandbox = void 0;
4
4
  var flp_1 = require("./flp");
5
5
  Object.defineProperty(exports, "FlpSandbox", { enumerable: true, get: function () { return flp_1.FlpSandbox; } });
6
+ Object.defineProperty(exports, "initAdp", { enumerable: true, get: function () { return flp_1.initAdp; } });
6
7
  //# sourceMappingURL=index.js.map
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export * from './ui5/middleware';
2
- export { FlpSandbox } from './base';
2
+ export { FlpSandbox, initAdp } from './base';
3
3
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -14,8 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.FlpSandbox = void 0;
17
+ exports.initAdp = exports.FlpSandbox = void 0;
18
18
  __exportStar(require("./ui5/middleware"), exports);
19
19
  var base_1 = require("./base");
20
20
  Object.defineProperty(exports, "FlpSandbox", { enumerable: true, get: function () { return base_1.FlpSandbox; } });
21
+ Object.defineProperty(exports, "initAdp", { enumerable: true, get: function () { return base_1.initAdp; } });
21
22
  //# sourceMappingURL=index.js.map
@@ -11,43 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const logger_1 = require("@sap-ux/logger");
13
13
  const flp_1 = require("../base/flp");
14
- const adp_tooling_1 = require("@sap-ux/adp-tooling");
15
- /**
16
- * Initialize the preview for an adaptation project.
17
- *
18
- * @param rootProject reference to the project
19
- * @param config configuration from the ui5.yaml
20
- * @param flp FlpSandbox instance
21
- * @param util middleware utilities provided by the UI5 CLI
22
- * @param logger logger instance
23
- */
24
- function initAdp(rootProject, config, flp, util, logger) {
25
- var _a;
26
- return __awaiter(this, void 0, void 0, function* () {
27
- const appVariant = yield rootProject.byPath('/manifest.appdescr_variant');
28
- if (appVariant) {
29
- const adp = new adp_tooling_1.AdpPreview(config, rootProject, util, logger);
30
- const variant = JSON.parse(yield appVariant.getString());
31
- const layer = yield adp.init(variant);
32
- if (flp.rta) {
33
- flp.rta.layer = layer;
34
- flp.rta.options = {
35
- projectId: variant.id,
36
- scenario: 'ADAPTATION_PROJECT'
37
- };
38
- for (const editor of flp.rta.editors) {
39
- (_a = editor.pluginScript) !== null && _a !== void 0 ? _a : (editor.pluginScript = 'open/ux/preview/client/adp/init');
40
- }
41
- }
42
- yield flp.init(adp.descriptor.manifest, adp.descriptor.name, adp.resources);
43
- flp.router.use(adp.descriptor.url, adp.proxy.bind(adp));
44
- adp.addApis(flp.router);
45
- }
46
- else {
47
- throw new Error('ADP configured but no manifest.appdescr_variant found.');
48
- }
49
- });
50
- }
51
14
  /**
52
15
  * The developer mode is only supported for adaptation projects, therefore, notify the user if it is wrongly configured and then disable it.
53
16
  *
@@ -85,7 +48,7 @@ function createRouter({ resources, options, middlewareUtil }, logger) {
85
48
  // configure the FLP sandbox based on information from the manifest
86
49
  const flp = new flp_1.FlpSandbox(config, resources.rootProject, middlewareUtil, logger);
87
50
  if (config.adp) {
88
- yield initAdp(resources.rootProject, config.adp, flp, middlewareUtil, logger);
51
+ yield (0, flp_1.initAdp)(resources.rootProject, config.adp, flp, middlewareUtil, logger);
89
52
  }
90
53
  else {
91
54
  const manifest = yield resources.rootProject.byPath('/manifest.json');
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
11
11
  },
12
- "version": "0.8.3",
12
+ "version": "0.8.4",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",