@ui5/task-adaptation 1.6.2 → 1.6.4-rc.1

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 (55) hide show
  1. package/CHANGELOG.md +42 -3
  2. package/dist/adapters/abapAdapter.d.ts +2 -4
  3. package/dist/adapters/abapAdapter.js +5 -16
  4. package/dist/adapters/adapter.d.ts +3 -1
  5. package/dist/adapters/adapter.js +15 -1
  6. package/dist/adapters/cfAdapter.js +3 -12
  7. package/dist/adapters/commands/command.d.ts +3 -8
  8. package/dist/adapters/commands/command.js +5 -7
  9. package/dist/adapters/commands/downloadAnnotationsCommand.d.ts +2 -4
  10. package/dist/adapters/commands/downloadAnnotationsCommand.js +2 -6
  11. package/dist/adapters/commands/xsAppJsonEnhanceRoutesCommand.js +5 -24
  12. package/dist/adapters/previewAdapter.d.ts +10 -2
  13. package/dist/adapters/previewAdapter.js +14 -1
  14. package/dist/annotations/abapAnnotationManager.d.ts +17 -0
  15. package/dist/{annotationManager.js → annotations/abapAnnotationManager.js} +12 -10
  16. package/dist/annotations/annotationManager.d.ts +3 -0
  17. package/dist/annotations/annotationManager.js +2 -0
  18. package/dist/annotations/localAnnotationManager.d.ts +4 -0
  19. package/dist/annotations/localAnnotationManager.js +7 -0
  20. package/dist/annotations/serviceRequestor.d.ts +3 -3
  21. package/dist/annotations/serviceRequestor.js +4 -4
  22. package/dist/bundle.js +119 -2
  23. package/dist/index.js +6 -7
  24. package/dist/landscapeConfiguration.d.ts +9 -0
  25. package/dist/landscapeConfiguration.js +65 -0
  26. package/dist/model/configuration.d.ts +2 -0
  27. package/dist/previewManager.d.ts +4 -3
  28. package/dist/previewManager.js +15 -15
  29. package/dist/repositories/{abapRepoManager.d.ts → abapRepository.d.ts} +5 -3
  30. package/dist/repositories/{abapRepoManager.js → abapRepository.js} +17 -4
  31. package/dist/repositories/html5Repository.d.ts +18 -0
  32. package/dist/repositories/{html5RepoManager.js → html5Repository.js} +58 -27
  33. package/dist/repositories/localRepository.d.ts +16 -0
  34. package/dist/repositories/localRepository.js +62 -0
  35. package/dist/repositories/repository.d.ts +8 -0
  36. package/dist/repositories/repository.js +2 -0
  37. package/dist/util/cf/xsAppJsonUtil.d.ts +2 -1
  38. package/dist/util/cf/xsAppJsonUtil.js +19 -0
  39. package/dist/util/commonUtil.d.ts +1 -0
  40. package/dist/util/commonUtil.js +3 -0
  41. package/dist/util/fsUtil.d.ts +2 -0
  42. package/dist/util/fsUtil.js +34 -0
  43. package/package.json +6 -3
  44. package/scripts/publish.ts +256 -0
  45. package/scripts/test-integration-prep.sh +4 -0
  46. package/dist/annotationManager.d.ts +0 -17
  47. package/dist/processors/abapProcessor.d.ts +0 -18
  48. package/dist/processors/abapProcessor.js +0 -43
  49. package/dist/processors/cfProcessor.d.ts +0 -14
  50. package/dist/processors/cfProcessor.js +0 -46
  51. package/dist/processors/previewProcessor.d.ts +0 -8
  52. package/dist/processors/previewProcessor.js +0 -11
  53. package/dist/processors/processor.d.ts +0 -10
  54. package/dist/processors/processor.js +0 -39
  55. package/dist/repositories/html5RepoManager.d.ts +0 -12
package/dist/bundle.js CHANGED
@@ -2352,6 +2352,31 @@ var SetMinUI5Version = {
2352
2352
  }
2353
2353
  };
2354
2354
 
2355
+ const rSemver = /^(0|[1-9]\d*)\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*))?(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;
2356
+ const SetUI5VersionNumber = {
2357
+ applyChange(oManifest, oChange) {
2358
+ if (!oChange.getContent().hasOwnProperty("ui5VersionNumber")) {
2359
+ throw new Error("No ui5VersionNumber in change content provided");
2360
+ }
2361
+ const sUI5VersionNumber = oChange.getContent().ui5VersionNumber;
2362
+ if (typeof sUI5VersionNumber !== "string") {
2363
+ throw new Error(`The current change value type of property ui5VersionNumber is '${typeof sUI5VersionNumber}'. Only allowed type for property ui5VersionNumber is string`);
2364
+ }
2365
+ const aSemverMatch = rSemver.exec(sUI5VersionNumber);
2366
+ if (!aSemverMatch) {
2367
+ throw new Error(`The value of property ui5VersionNumber ('${sUI5VersionNumber}') is not a valid semantic version (MAJOR.MINOR or MAJOR.MINOR.PATCH)`);
2368
+ }
2369
+ const aPropertyPath = ["sap.platform.cf", "ui5VersionNumber"];
2370
+ const oNewVersion = new Version(sUI5VersionNumber);
2371
+ const oCurrVersionString = ObjectPath.get(aPropertyPath, oManifest);
2372
+ const oCurrVersion = oCurrVersionString ? new Version(oCurrVersionString) : null;
2373
+ if (!oCurrVersion || oCurrVersion.compareTo(oNewVersion) < 0) {
2374
+ ObjectPath.set(aPropertyPath, sUI5VersionNumber, oManifest);
2375
+ }
2376
+ return oManifest;
2377
+ }
2378
+ };
2379
+
2355
2380
  var SetRegistrationIds = {
2356
2381
  applyChange(oManifest, oChange) {
2357
2382
  ObjectPath.set(["sap.fiori", "registrationIds"], oChange.getContent().registrationIds, oManifest);
@@ -4020,6 +4045,7 @@ const RegistrationBuild = {
4020
4045
  appdescr_ui5_addComponentUsages: () => Promise.resolve(AddComponentUsages),
4021
4046
  appdescr_ui5_changeModel: () => Promise.resolve(ChangeModel),
4022
4047
  appdescr_ui5_setMinUI5Version: () => Promise.resolve(SetMinUI5Version),
4048
+ appdescr_platform_cf_setUI5VersionNumber: () => Promise.resolve(SetUI5VersionNumber),
4023
4049
  appdescr_fiori_setRegistrationIds: () => Promise.resolve(SetRegistrationIds),
4024
4050
  appdescr_ui5_setFlexExtensionPointEnabled: () => Promise.resolve(SetFlexExtensionPointEnabled),
4025
4051
  appdescr_ui5_addNewModel: () => Promise.resolve(AddNewModel),
@@ -5799,15 +5825,18 @@ var Filter = BaseObject.extend("sap.ui.model.Filter", {
5799
5825
  if (!this.aFilters.every(isFilter)) {
5800
5826
  Log.error("Filter in aggregation of multi filter has to be instance of" + " sap.ui.model.Filter");
5801
5827
  }
5802
- } else if (!this.aFilters && this.sPath !== undefined && (this.sOperator && this.oValue1 !== undefined || this.fnTest)) {
5828
+ } else if (!this.aFilters && this.sPath !== undefined && (this.sOperator && this.hasOwnProperty("oValue1") || this.fnTest)) {
5803
5829
  this._bMultiFilter = false;
5804
5830
  } else {
5805
5831
  Log.error("Wrong parameters defined for filter.");
5806
5832
  }
5807
5833
  this.sFractionalSeconds1 = undefined;
5808
5834
  this.sFractionalSeconds2 = undefined;
5835
+ this.bBound = undefined;
5836
+ this.bResolved = undefined;
5809
5837
  }
5810
5838
  });
5839
+ Filter.generated = Symbol("generated");
5811
5840
  Filter.NONE = new Filter({
5812
5841
  path: "/",
5813
5842
  test: () => false
@@ -5834,6 +5863,44 @@ Filter.prototype.appendFractionalSeconds1 = function (sFractionalSeconds) {
5834
5863
  Filter.prototype.appendFractionalSeconds2 = function (sFractionalSeconds) {
5835
5864
  this.sFractionalSeconds2 = sFractionalSeconds;
5836
5865
  };
5866
+ Filter.prototype.cloneWithValues = function (vNewValue1, vNewValue2) {
5867
+ if (this._bMultiFilter) {
5868
+ throw new Error("Cannot clone multi-filter");
5869
+ }
5870
+ const oClone = new Filter({
5871
+ path: this.sPath,
5872
+ operator: this.sOperator,
5873
+ value1: vNewValue1,
5874
+ value2: vNewValue2,
5875
+ variable: this.sVariable,
5876
+ condition: this.oCondition,
5877
+ and: this.bAnd,
5878
+ test: this.fnTest?.[Filter.generated] ? undefined : this.fnTest,
5879
+ comparator: this.fnCompare,
5880
+ caseSensitive: this.bCaseSensitive
5881
+ });
5882
+ oClone.bResolved = this.bResolved;
5883
+ oClone.bBound = this.bBound;
5884
+ if (oClone.bResolved === false) {
5885
+ oClone.bResolved = true;
5886
+ }
5887
+ return oClone;
5888
+ };
5889
+ Filter.prototype.cloneIfContained = function (oFilter, oFilterClone) {
5890
+ if (!this._bMultiFilter) {
5891
+ return this === oFilter ? oFilterClone : this;
5892
+ }
5893
+ let bReplaced = false;
5894
+ const aFilters = this.aFilters.map(oFilterElement => {
5895
+ const oClonedFilterElement = oFilterElement.cloneIfContained(oFilter, oFilterClone);
5896
+ bReplaced ||= oClonedFilterElement !== oFilterElement;
5897
+ return oClonedFilterElement;
5898
+ });
5899
+ return bReplaced ? new Filter({
5900
+ filters: aFilters,
5901
+ and: this.bAnd
5902
+ }) : this;
5903
+ };
5837
5904
  var Type = {
5838
5905
  Logical: "Logical",
5839
5906
  Binary: "Binary",
@@ -6031,9 +6098,58 @@ Filter.prototype.getVariable = function () {
6031
6098
  Filter.prototype.isAnd = function () {
6032
6099
  return !!this.bAnd;
6033
6100
  };
6101
+ Filter.prototype.isBound = function () {
6102
+ return !!this.bBound;
6103
+ };
6034
6104
  Filter.prototype.isCaseSensitive = function () {
6035
6105
  return this.bCaseSensitive;
6036
6106
  };
6107
+ Filter.prototype.isMultiFilter = function () {
6108
+ return this._bMultiFilter;
6109
+ };
6110
+ Filter.prototype.isNeutral = function () {
6111
+ if (this._bMultiFilter) {
6112
+ throw new Error("Multi-filter unsupported");
6113
+ }
6114
+ if (this.bResolved === undefined) {
6115
+ return false;
6116
+ }
6117
+ if (this.bResolved === false) {
6118
+ return true;
6119
+ }
6120
+ const nullish = oValue => oValue === undefined || oValue === null;
6121
+ return this.sOperator === FilterOperator.BT || this.sOperator === FilterOperator.NB ? nullish(this.oValue1) || nullish(this.oValue2) : nullish(this.oValue1);
6122
+ };
6123
+ Filter.prototype.isResolved = function () {
6124
+ return this._bMultiFilter ? this.aFilters.every(oFilter => oFilter.isResolved()) : this.bResolved !== false;
6125
+ };
6126
+ Filter.prototype.removeAllNeutrals = function () {
6127
+ if (!this._bMultiFilter) {
6128
+ return this.isNeutral() ? undefined : this;
6129
+ }
6130
+ const aFilters = [];
6131
+ this.aFilters.forEach(oFilter => {
6132
+ const oNewFilter = oFilter.removeAllNeutrals();
6133
+ if (oNewFilter) {
6134
+ aFilters.push(oNewFilter);
6135
+ }
6136
+ });
6137
+ if (aFilters.length === this.aFilters.length) {
6138
+ return this;
6139
+ } else if (!aFilters.length) {
6140
+ return undefined;
6141
+ }
6142
+ return new Filter({
6143
+ filters: aFilters,
6144
+ and: this.bAnd
6145
+ });
6146
+ };
6147
+ Filter.prototype.setBound = function () {
6148
+ this.bBound = true;
6149
+ };
6150
+ Filter.prototype.setResolved = function (bResolved) {
6151
+ this.bResolved = !!bResolved;
6152
+ };
6037
6153
  Filter.defaultComparator = function (a, b) {
6038
6154
  if (a == b) {
6039
6155
  return 0;
@@ -6437,7 +6553,8 @@ _Helper = {
6437
6553
  var oSyncPromise = this[sFetch].apply(this, arguments);
6438
6554
  if (oSyncPromise.isFulfilled()) {
6439
6555
  return oSyncPromise.getResult();
6440
- } else if (bThrow) {
6556
+ }
6557
+ if (bThrow) {
6441
6558
  if (oSyncPromise.isRejected()) {
6442
6559
  oSyncPromise.caught();
6443
6560
  throw oSyncPromise.getResult();
package/dist/index.js CHANGED
@@ -3,9 +3,9 @@ import { logBuilderVersion } from "./util/commonUtil.js";
3
3
  import AppVariant from "./appVariantManager.js";
4
4
  import BaseApp from "./baseAppManager.js";
5
5
  import ResourceUtil from "./util/resourceUtil.js";
6
- import { determineProcessor } from "./processors/processor.js";
7
6
  import FilesUtil from "./util/filesUtil.js";
8
7
  import PreviewManager from "./previewManager.js";
8
+ import { initialize } from "./landscapeConfiguration.js";
9
9
  /**
10
10
  * Creates an appVariant bundle from the provided resources.
11
11
  */
@@ -13,11 +13,10 @@ export default ({ workspace, options, taskUtil }) => {
13
13
  dotenv.config();
14
14
  async function process(workspace, taskUtil) {
15
15
  logBuilderVersion();
16
- const processor = determineProcessor(options.configuration);
17
- const adapter = processor.getAdapter();
16
+ const { repository, adapter } = initialize(options.configuration);
18
17
  const adaptationProject = await AppVariant.fromWorkspace(workspace, options.projectNamespace);
19
- const previewManagerPromise = PreviewManager.createFromRoot(adaptationProject.reference, processor);
20
- const appVariantIdHierarchy = await processor.getAppVariantIdHierarchy(adaptationProject.reference);
18
+ const previewManagerPromise = PreviewManager.createFromRoot(adaptationProject.reference, repository, options.configuration);
19
+ const appVariantIdHierarchy = await repository.getAppVariantIdHierarchy(adaptationProject.reference);
21
20
  if (appVariantIdHierarchy.length === 0) {
22
21
  throw new Error(`No app variant found for reference ${adaptationProject.reference}`);
23
22
  }
@@ -25,7 +24,7 @@ export default ({ workspace, options, taskUtil }) => {
25
24
  // latest app variant on top. We reverse the list to process original
26
25
  // application first and then app variants in chronological order.
27
26
  const reversedHierarchy = appVariantIdHierarchy.toReversed();
28
- const fetchFilesPromises = reversedHierarchy.map(({ repoName, cachebusterToken }) => processor.fetch(repoName, cachebusterToken));
27
+ const fetchFilesPromises = reversedHierarchy.map(({ repoName, cachebusterToken }) => repository.fetch(repoName, cachebusterToken));
29
28
  fetchFilesPromises.push(Promise.resolve(adaptationProject.files));
30
29
  const appVariants = new Array();
31
30
  const adapt = async (baseAppFiles, appVariantFiles) => {
@@ -40,7 +39,7 @@ export default ({ workspace, options, taskUtil }) => {
40
39
  const adaptCommandChain = adapter.createAdaptCommandChain(baseApp, appVariant);
41
40
  const mergeCommandChain = adapter.createMergeCommandChain(baseApp, appVariant);
42
41
  const adaptedFiles = await adaptCommandChain.execute();
43
- const mergedFiles = await mergeCommandChain.execute(adaptedFiles, appVariant.getProcessedFiles());
42
+ const mergedFiles = await mergeCommandChain.execute(adaptedFiles);
44
43
  return mergedFiles;
45
44
  };
46
45
  let files = await fetchFilesPromises.reduce(async (previousFiles, currentFiles) => adapt(await previousFiles, await currentFiles), fetchFilesPromises.shift());
@@ -0,0 +1,9 @@
1
+ import { IConfiguration } from "./model/types.js";
2
+ import { IAdapter } from "./adapters/adapter.js";
3
+ import IRepository from "./repositories/repository.js";
4
+ import IAnnotationManager from "./annotations/annotationManager.js";
5
+ export declare function initialize(configuration: IConfiguration): {
6
+ adapter: IAdapter;
7
+ repository: IRepository;
8
+ annotationManager: IAnnotationManager;
9
+ };
@@ -0,0 +1,65 @@
1
+ import AbapAdapter from "./adapters/abapAdapter.js";
2
+ import CFAdapter from "./adapters/cfAdapter.js";
3
+ import PreviewAdapter from "./adapters/previewAdapter.js";
4
+ import AbapRepository from "./repositories/abapRepository.js";
5
+ import HTML5Repository from "./repositories/html5Repository.js";
6
+ import LocalRepository from "./repositories/localRepository.js";
7
+ import AbapAnnotationManager from "./annotations/abapAnnotationManager.js";
8
+ import LocalAnnotationManager from "./annotations/localAnnotationManager.js";
9
+ import { validateObject } from "./util/commonUtil.js";
10
+ export function initialize(configuration) {
11
+ validateObject(configuration, ["type"], "should be specified in ui5.yaml configuration: 'cf' or 'abap'");
12
+ const repository = getRepository(configuration);
13
+ const annotationManager = getAnnotationManager(configuration, repository);
14
+ return {
15
+ adapter: getAdapter(configuration, annotationManager),
16
+ repository,
17
+ annotationManager
18
+ };
19
+ }
20
+ function getAdapter(configuration, annotationManager) {
21
+ if (isPreview(configuration)) {
22
+ return new PreviewAdapter(configuration);
23
+ }
24
+ switch (configuration.type) {
25
+ case "abap":
26
+ return new AbapAdapter(annotationManager);
27
+ case "cf":
28
+ return new CFAdapter(configuration);
29
+ default:
30
+ throw new Error(`No adapter found for the given configuration type '${configuration.type}'`);
31
+ }
32
+ }
33
+ function getRepository(configuration) {
34
+ if (isLocal(configuration)) {
35
+ return new LocalRepository(configuration);
36
+ }
37
+ switch (configuration.type) {
38
+ case "abap":
39
+ return new AbapRepository(configuration);
40
+ case "cf":
41
+ return new HTML5Repository(configuration);
42
+ default:
43
+ throw new Error(`No repository found for the given configuration type '${configuration.type}'`);
44
+ }
45
+ }
46
+ function getAnnotationManager(configuration, repository) {
47
+ if (isLocal(configuration)) {
48
+ return new LocalAnnotationManager();
49
+ }
50
+ switch (configuration.type) {
51
+ case "abap":
52
+ return new AbapAnnotationManager(configuration, repository);
53
+ case "cf":
54
+ return new LocalAnnotationManager();
55
+ default:
56
+ throw new Error(`No annotation manager found for the given configuration type '${configuration.type}'`);
57
+ }
58
+ }
59
+ function isLocal(configuration) {
60
+ return process.env.ADP_BUILDER_MODE === "local" || configuration.mode === "local";
61
+ }
62
+ function isPreview(configuration) {
63
+ return process.env.ADP_BUILDER_MODE === "preview" || configuration.mode === "preview";
64
+ }
65
+ //# sourceMappingURL=landscapeConfiguration.js.map
@@ -9,12 +9,14 @@ export interface IConfiguration {
9
9
  sapCloudService?: string;
10
10
  destination?: string;
11
11
  type?: "cf" | "abap";
12
+ mode?: "preview" | "local" | "default";
12
13
  languages?: any[] | undefined;
13
14
  enableAnnotationCache?: boolean;
14
15
  enableBetaFeatures?: boolean;
15
16
  writeTempFiles?: any;
16
17
  target?: AbapTarget & IAbapTargetMeta;
17
18
  serviceInstanceName?: string;
19
+ adpDir?: string;
18
20
  }
19
21
  export interface IAbapTargetMeta {
20
22
  name?: string;
@@ -1,13 +1,14 @@
1
- import IProcessor from "./processors/processor.js";
1
+ import { IConfiguration } from "./model/types.js";
2
+ import IRepository from "./repositories/repository.js";
2
3
  export default class PreviewManager {
3
4
  private readonly fetchLibsPromises;
4
- static createFromRoot(appId: string, processor: IProcessor): Promise<PreviewManager>;
5
+ private readonly configuration;
6
+ static createFromRoot(appId: string, repository: IRepository, configuration: IConfiguration): Promise<PreviewManager>;
5
7
  static isPreviewRequested(): boolean;
6
8
  private constructor();
7
9
  processPreviewResources(baseAppFiles: ReadonlyMap<string, string>): Promise<void>;
8
10
  private preReadLibs;
9
11
  private searchBaseAppXsAppJsonFile;
10
- private mergeXsAppJsonFiles;
11
12
  private static moveLibraryFiles;
12
13
  private static modifyRoutes;
13
14
  }
@@ -1,7 +1,7 @@
1
1
  import { getLogger } from "@ui5/logger";
2
2
  import ResourceUtil from "./util/resourceUtil.js";
3
3
  import path from "path";
4
- import { merge } from "./util/cf/xsAppJsonUtil.js";
4
+ import { fetchCredentialsAndEnhanceRoutes, merge } from "./util/cf/xsAppJsonUtil.js";
5
5
  import FsUtil from "./util/fsUtil.js";
6
6
  const log = getLogger("@ui5/task-adaptation::PreviewManager");
7
7
  const REUSE_DIR = ".adp/reuse";
@@ -9,7 +9,8 @@ const APP_INFO_FILE = "ui5AppInfo.json";
9
9
  const XS_APP_JSON_FILE = "xs-app.json";
10
10
  export default class PreviewManager {
11
11
  fetchLibsPromises = new Map();
12
- static async createFromRoot(appId, processor) {
12
+ configuration;
13
+ static async createFromRoot(appId, repository, configuration) {
13
14
  let ui5AppInfo = "";
14
15
  if (PreviewManager.isPreviewRequested()) {
15
16
  try {
@@ -22,12 +23,13 @@ export default class PreviewManager {
22
23
  else {
23
24
  log.verbose("Preview mode not requested (env variable ADP_BUILDER_MODE=preview is not set), skipping preview resources processing.");
24
25
  }
25
- return new PreviewManager(appId, ui5AppInfo, processor);
26
+ return new PreviewManager(appId, ui5AppInfo, repository, configuration);
26
27
  }
27
28
  static isPreviewRequested() {
28
29
  return process.env.ADP_BUILDER_MODE === "preview";
29
30
  }
30
- constructor(appId, ui5AppInfo, processor) {
31
+ constructor(appId, ui5AppInfo, repository, configuration) {
32
+ this.configuration = configuration;
31
33
  // If no ui5AppInfo is provided, no preview processing is needed
32
34
  if (!ui5AppInfo) {
33
35
  log.verbose("No ui5AppInfo provided, skipping preview resources processing.");
@@ -39,7 +41,7 @@ export default class PreviewManager {
39
41
  }
40
42
  const reuseLibs = appInfo.asyncHints.libs.filter(lib => lib.html5AppHostId && lib.html5AppName && lib.html5AppVersion);
41
43
  if (reuseLibs.length > 0) {
42
- this.fetchLibsPromises = this.preReadLibs(reuseLibs, processor);
44
+ this.fetchLibsPromises = this.preReadLibs(reuseLibs, repository);
43
45
  }
44
46
  const logMap = {
45
47
  Error: log.error,
@@ -74,16 +76,20 @@ export default class PreviewManager {
74
76
  }
75
77
  }
76
78
  this.searchBaseAppXsAppJsonFile(xsAppFiles, baseAppFiles);
77
- this.mergeXsAppJsonFiles(xsAppFiles, mergedFiles);
79
+ let xsAppJson = merge(xsAppFiles);
80
+ if (xsAppJson) {
81
+ xsAppJson = await fetchCredentialsAndEnhanceRoutes(xsAppJson, this.configuration);
82
+ mergedFiles.set(XS_APP_JSON_FILE, xsAppJson);
83
+ }
78
84
  await ResourceUtil.writeInProject(REUSE_DIR, mergedFiles);
79
85
  }
80
- preReadLibs(reuseLibs, processor) {
86
+ preReadLibs(reuseLibs, repository) {
81
87
  const promises = new Map();
82
88
  reuseLibs.forEach(lib => {
83
89
  log.info(`Downloading reuse library '${lib.html5AppName}' version '${lib.html5AppVersion}'`);
84
- const promise = processor
90
+ const promise = repository
85
91
  .fetchReuseLib(lib.html5AppName, lib.html5CacheBusterToken, lib)
86
- .then(libFiles => PreviewManager.moveLibraryFiles(libFiles, lib.html5AppName, lib.name));
92
+ .then((libFiles) => PreviewManager.moveLibraryFiles(libFiles, lib.html5AppName, lib.name));
87
93
  promises.set(lib.html5AppName, promise);
88
94
  });
89
95
  return promises;
@@ -97,12 +103,6 @@ export default class PreviewManager {
97
103
  log.warn("xs-app.json is missing in the downloaded base app files for preview");
98
104
  }
99
105
  }
100
- mergeXsAppJsonFiles(xsAppFiles, files) {
101
- const mergedXsAppJson = merge(xsAppFiles);
102
- if (mergedXsAppJson) {
103
- files.set(XS_APP_JSON_FILE, mergedXsAppJson);
104
- }
105
- }
106
106
  static moveLibraryFiles(inputFiles, libraryName, libId) {
107
107
  const files = new Map();
108
108
  inputFiles.forEach((content, filename) => {
@@ -1,13 +1,15 @@
1
- import { IConfiguration, IMetadata } from "../model/types.js";
1
+ import { IConfiguration, IMetadata, IReuseLibInfo } from "../model/types.js";
2
2
  import AbapProvider from "./abapProvider.js";
3
3
  import { IAppVariantIdHierarchyItem } from "../model/appVariantIdHierarchyItem.js";
4
- export default class AbapRepoManager {
4
+ import IRepository from "./repository.js";
5
+ export default class AbapRepository implements IRepository {
5
6
  private configuration;
6
7
  private abapProvider;
7
8
  constructor(configuration: IConfiguration, abapProvider?: AbapProvider);
9
+ fetchReuseLib(_libName: string, _cachebusterToken: string, _lib: IReuseLibInfo): Promise<Map<string, string>>;
8
10
  getAppVariantIdHierarchy(id: string): Promise<IAppVariantIdHierarchyItem[]>;
9
11
  getAnnotationMetadata(uri: string): Promise<IMetadata>;
10
12
  downloadAnnotationFile(uri: string): Promise<Map<string, any>>;
11
13
  getMetadata(id: string): Promise<IMetadata>;
12
- fetch(repoName: string): Promise<Map<string, string>>;
14
+ fetch(repoName: string, _cachebusterToken: string): Promise<Map<string, string>>;
13
15
  }
@@ -1,7 +1,14 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
1
7
  import AbapProvider from "./abapProvider.js";
2
8
  import { getLogger } from "@ui5/logger";
3
9
  import { unzipZipEntries } from "../util/zipUtil.js";
4
- const log = getLogger("@ui5/task-adaptation::AbapRepoManager");
10
+ import { cached } from "../cache/cacheHolder.js";
11
+ const log = getLogger("@ui5/task-adaptation::AbapRepository");
5
12
  const REQUEST_OPTIONS_XML = {
6
13
  responseType: "text",
7
14
  headers: {
@@ -13,13 +20,16 @@ const REQUEST_OPTIONS_JSON = {
13
20
  "Accept": "application/json"
14
21
  }
15
22
  };
16
- export default class AbapRepoManager {
23
+ export default class AbapRepository {
17
24
  configuration;
18
25
  abapProvider;
19
26
  constructor(configuration, abapProvider) {
20
27
  this.configuration = configuration;
21
28
  this.abapProvider = abapProvider ? abapProvider : new AbapProvider();
22
29
  }
30
+ fetchReuseLib(_libName, _cachebusterToken, _lib) {
31
+ throw new Error("Preview is not available on SAP S/4HANA On-Premise or Cloud Systems. Please create a ticket on CA-UI5-FL-ADP-BAS component.");
32
+ }
23
33
  async getAppVariantIdHierarchy(id) {
24
34
  const provider = await this.abapProvider.get(this.configuration);
25
35
  const lrep = provider.getLayeredRepository();
@@ -68,7 +78,7 @@ export default class AbapRepoManager {
68
78
  id
69
79
  };
70
80
  }
71
- async fetch(repoName) {
81
+ async fetch(repoName, _cachebusterToken) {
72
82
  const encodedRepoName = encodeURIComponent(repoName);
73
83
  const provider = await this.abapProvider.get(this.configuration);
74
84
  const ui5Repo = provider.getUi5AbapRepository();
@@ -87,4 +97,7 @@ export default class AbapRepoManager {
87
97
  throw new Error(`App '${repoName}' doesn't contain files`);
88
98
  }
89
99
  }
90
- //# sourceMappingURL=abapRepoManager.js.map
100
+ __decorate([
101
+ cached()
102
+ ], AbapRepository.prototype, "fetch", null);
103
+ //# sourceMappingURL=abapRepository.js.map
@@ -0,0 +1,18 @@
1
+ import { IConfiguration, IReuseLibInfo } from "./../model/types.js";
2
+ import IRepository from "./repository.js";
3
+ import { IAppVariantIdHierarchyItem } from "../model/appVariantIdHierarchyItem.js";
4
+ export default class HTML5Repository implements IRepository {
5
+ private configuration;
6
+ constructor(configuration: IConfiguration);
7
+ getAppVariantIdHierarchy(appId: string): Promise<IAppVariantIdHierarchyItem[]>;
8
+ fetch(_repoName: string, _cachebusterToken: string): Promise<Map<string, string>>;
9
+ fetchReuseLib(_libName: string, _cachebusterToken: string, lib: IReuseLibInfo): Promise<Map<string, string>>;
10
+ getMetadata(): Promise<any>;
11
+ private getHtml5RepoInfo;
12
+ private getHTML5Credentials;
13
+ private getToken;
14
+ private requestMetadata;
15
+ private getAppZipEntries;
16
+ private download;
17
+ downloadAnnotationFile(_uri: string): Promise<Map<string, string>>;
18
+ }
@@ -1,24 +1,41 @@
1
- import CFUtil from "./../util/cfUtil.js";
2
- import RequestUtil from "./../util/requestUtil.js";
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import CFUtil from "../util/cfUtil.js";
8
+ import RequestUtil from "../util/requestUtil.js";
3
9
  import { getLogger } from "@ui5/logger";
4
- import { unzipZipEntries } from "./../util/zipUtil.js";
5
- const log = getLogger("@ui5/task-adaptation::HTML5RepoManager");
6
- export default class HTML5RepoManager {
7
- static async getBaseAppFiles(configuration) {
8
- const { token, baseUri } = await this.getHtml5RepoInfo(configuration);
9
- const app = {
10
- appName: configuration.appName,
11
- appVersion: configuration.appVersion,
12
- appHostId: configuration.appHostId
13
- };
14
- return this.getAppZipEntries(app, baseUri, token);
10
+ import { unzipZipEntries } from "../util/zipUtil.js";
11
+ import { cached } from "../cache/cacheHolder.js";
12
+ import { validateConfiguration } from "../util/commonUtil.js";
13
+ const log = getLogger("@ui5/task-adaptation::HTML5Repository");
14
+ export default class HTML5Repository {
15
+ configuration;
16
+ constructor(configuration) {
17
+ this.configuration = configuration;
18
+ validateConfiguration(configuration, ["appHostId", "appName", "appVersion"]);
19
+ }
20
+ async getAppVariantIdHierarchy(appId) {
21
+ const metadata = await this.getMetadata();
22
+ return [{
23
+ repoName: this.configuration.appName,
24
+ appVariantId: appId,
25
+ cachebusterToken: metadata.changedOn
26
+ }];
15
27
  }
16
- static async getMetadata(configuration) {
17
- const { token, baseUri } = await this.getHtml5RepoInfo(configuration);
18
- return this.requestMetadata(configuration, baseUri, token);
28
+ async fetch(_repoName, _cachebusterToken) {
29
+ const { token, baseUri } = await this.getHtml5RepoInfo();
30
+ const appData = {
31
+ appName: this.configuration.appName,
32
+ appVersion: this.configuration.appVersion,
33
+ appHostId: this.configuration.appHostId
34
+ };
35
+ return this.getAppZipEntries(appData, baseUri, token);
19
36
  }
20
- static async getReuseLibFiles(configuration, lib) {
21
- const { token, baseUri } = await this.getHtml5RepoInfo(configuration);
37
+ async fetchReuseLib(_libName, _cachebusterToken, lib) {
38
+ const { token, baseUri } = await this.getHtml5RepoInfo();
22
39
  const libAppData = {
23
40
  appName: lib.html5AppName,
24
41
  appVersion: lib.html5AppVersion,
@@ -26,8 +43,12 @@ export default class HTML5RepoManager {
26
43
  };
27
44
  return this.getAppZipEntries(libAppData, baseUri, token);
28
45
  }
29
- static async getHtml5RepoInfo(configuration) {
30
- const spaceGuid = await CFUtil.getSpaceGuid(configuration?.space);
46
+ async getMetadata() {
47
+ const { token, baseUri } = await this.getHtml5RepoInfo();
48
+ return this.requestMetadata(baseUri, token);
49
+ }
50
+ async getHtml5RepoInfo() {
51
+ const spaceGuid = await CFUtil.getSpaceGuid(this.configuration?.space);
31
52
  const credentials = await this.getHTML5Credentials(spaceGuid);
32
53
  const token = await this.getToken(credentials);
33
54
  if (!token || token.length === 0) {
@@ -41,7 +62,7 @@ export default class HTML5RepoManager {
41
62
  baseUri: credentials.uri
42
63
  };
43
64
  }
44
- static async getHTML5Credentials(spaceGuid) {
65
+ async getHTML5Credentials(spaceGuid) {
45
66
  log.verbose("Getting HTML5 Repo Runtime credentials from space " + spaceGuid);
46
67
  const PLAN_NAME = "app-runtime";
47
68
  const SERVIСE_INSTANCE_NAME = "html5-apps-repo-runtime";
@@ -60,7 +81,7 @@ export default class HTML5RepoManager {
60
81
  const serviceKeys = await CFUtil.getServiceInstanceKeys(getParams, createParams);
61
82
  return serviceKeys.credentials;
62
83
  }
63
- static async getToken({ uaa }) {
84
+ async getToken({ uaa }) {
64
85
  log.verbose("Getting HTML5 Repo token");
65
86
  const auth = Buffer.from(uaa.clientid + ":" + uaa.clientsecret);
66
87
  const options = {
@@ -72,8 +93,8 @@ export default class HTML5RepoManager {
72
93
  const uri = `${uaa.url}/oauth/token?grant_type=client_credentials`;
73
94
  return RequestUtil.get(uri, options).then((json) => json["access_token"]);
74
95
  }
75
- static async requestMetadata(options, html5RepoBaseUri, token) {
76
- const { appHostId, appName, appVersion } = options;
96
+ async requestMetadata(html5RepoBaseUri, token) {
97
+ const { appHostId, appName, appVersion } = this.configuration;
77
98
  const uri = `${html5RepoBaseUri}/applications/metadata/`;
78
99
  const requestOptions = {
79
100
  headers: {
@@ -85,12 +106,12 @@ export default class HTML5RepoManager {
85
106
  const metadata = await RequestUtil.get(uri, requestOptions);
86
107
  return metadata.find((item) => item.appHostId === appHostId && item.applicationName === appName && item.applicationVersion === appVersion);
87
108
  }
88
- static async getAppZipEntries(app, html5RepoBaseUri, token) {
109
+ async getAppZipEntries(app, html5RepoBaseUri, token) {
89
110
  const uri = `${html5RepoBaseUri}/applications/content/${app.appName}-${app.appVersion}/`;
90
111
  const zip = await this.download(token, app.appHostId, uri);
91
112
  return unzipZipEntries(zip);
92
113
  }
93
- static async download(token, appHostId, uri) {
114
+ async download(token, appHostId, uri) {
94
115
  if (!token) {
95
116
  throw new Error("HTML5 token is undefined");
96
117
  }
@@ -103,5 +124,15 @@ export default class HTML5RepoManager {
103
124
  }
104
125
  });
105
126
  }
127
+ downloadAnnotationFile(_uri) {
128
+ log.verbose("No annotation processing in CF");
129
+ return Promise.resolve(new Map());
130
+ }
106
131
  }
107
- //# sourceMappingURL=html5RepoManager.js.map
132
+ __decorate([
133
+ cached()
134
+ ], HTML5Repository.prototype, "fetch", null);
135
+ __decorate([
136
+ cached()
137
+ ], HTML5Repository.prototype, "fetchReuseLib", null);
138
+ //# sourceMappingURL=html5Repository.js.map
@@ -0,0 +1,16 @@
1
+ import { IAppVariantIdHierarchyItem } from "../model/appVariantIdHierarchyItem.js";
2
+ import { IConfiguration } from "../model/configuration.js";
3
+ import { IReuseLibInfo } from "../model/types.js";
4
+ import IRepository from "./repository.js";
5
+ export default class LocalRepository implements IRepository {
6
+ private configuration;
7
+ constructor(configuration: IConfiguration);
8
+ downloadAnnotationFile(_uri: string): Promise<Map<string, string>>;
9
+ getAppVariantIdHierarchy(appId: string): Promise<IAppVariantIdHierarchyItem[]>;
10
+ fetch(appId: string, _cachebusterToken: string): Promise<Map<string, string>>;
11
+ fetchReuseLib(libName: string, _cachebusterToken: string, _lib: IReuseLibInfo): Promise<Map<string, string>>;
12
+ private collectAppVariantIdHierarchyItems;
13
+ private getExistingManifestPath;
14
+ private readFilesInBaseAppDir;
15
+ private getLocalFilesDirectory;
16
+ }