@ui5/task-adaptation 1.6.5-rc.2 → 1.6.5-rc.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.
Files changed (82) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/REUSE.toml +1 -1
  3. package/dist/adapters/abapAdapter.d.ts +7 -5
  4. package/dist/adapters/abapAdapter.js +9 -11
  5. package/dist/adapters/adapter.d.ts +9 -5
  6. package/dist/adapters/adapter.js +20 -0
  7. package/dist/adapters/cfAdapter.d.ts +8 -5
  8. package/dist/adapters/cfAdapter.js +16 -10
  9. package/dist/adapters/commands/command.d.ts +26 -23
  10. package/dist/adapters/commands/command.js +73 -46
  11. package/dist/adapters/commands/fetchEndpointsCommand.d.ts +9 -0
  12. package/dist/adapters/commands/fetchEndpointsCommand.js +21 -0
  13. package/dist/adapters/commands/fetchPreviewResourcesCommand.d.ts +15 -0
  14. package/dist/adapters/commands/fetchPreviewResourcesCommand.js +103 -0
  15. package/dist/adapters/commands/filterFilesCommand.d.ts +4 -0
  16. package/dist/adapters/commands/filterFilesCommand.js +22 -0
  17. package/dist/adapters/commands/omitDeletedResourcesCommand.d.ts +10 -0
  18. package/dist/adapters/commands/omitDeletedResourcesCommand.js +31 -0
  19. package/dist/adapters/commands/processPreviewResourcesCommand.d.ts +9 -0
  20. package/dist/adapters/commands/processPreviewResourcesCommand.js +55 -0
  21. package/dist/adapters/commands/renameFilesCommand.d.ts +20 -0
  22. package/dist/{util/filesUtil.js → adapters/commands/renameFilesCommand.js} +34 -43
  23. package/dist/adapters/commands/writeResourcesCommand.d.ts +7 -0
  24. package/dist/adapters/commands/writeResourcesCommand.js +20 -0
  25. package/dist/adapters/commands/xsAppJsonEnhanceRoutesCommand.d.ts +3 -3
  26. package/dist/adapters/commands/xsAppJsonEnhanceRoutesCommand.js +4 -4
  27. package/dist/adapters/previewAdapter.d.ts +12 -6
  28. package/dist/adapters/previewAdapter.js +28 -7
  29. package/dist/annotations/abapAnnotationManager.js +1 -1
  30. package/dist/annotations/dataSource/dataSourceManager.d.ts +2 -1
  31. package/dist/annotations/dataSource/dataSourceManager.js +16 -7
  32. package/dist/{appVariantManager.d.ts → appVariant.d.ts} +2 -9
  33. package/dist/{appVariantManager.js → appVariant.js} +16 -28
  34. package/dist/{baseAppManager.js → baseApp.js} +6 -12
  35. package/dist/bundle.js +53 -12
  36. package/dist/cache/cacheHolder.d.ts +3 -3
  37. package/dist/cache/cacheHolder.js +8 -7
  38. package/dist/cache/cachedResource.d.ts +4 -0
  39. package/dist/cache/cachedResource.js +2 -0
  40. package/dist/index.d.ts +1 -1
  41. package/dist/index.js +44 -69
  42. package/dist/landscapeConfiguration.d.ts +2 -2
  43. package/dist/landscapeConfiguration.js +39 -37
  44. package/dist/model/configuration.d.ts +1 -4
  45. package/dist/model/configuration.js +1 -1
  46. package/dist/model/types.d.ts +9 -2
  47. package/dist/repositories/abapProvider.js +2 -2
  48. package/dist/repositories/abapRepository.d.ts +6 -5
  49. package/dist/repositories/abapRepository.js +10 -11
  50. package/dist/repositories/html5Repository.d.ts +8 -5
  51. package/dist/repositories/html5Repository.js +18 -30
  52. package/dist/repositories/localRepository.d.ts +8 -12
  53. package/dist/repositories/localRepository.js +53 -43
  54. package/dist/repositories/repository.d.ts +3 -5
  55. package/dist/util/cf/xsAppJsonUtil.d.ts +16 -3
  56. package/dist/util/cf/xsAppJsonUtil.js +7 -18
  57. package/dist/util/commonUtil.d.ts +6 -0
  58. package/dist/util/commonUtil.js +17 -0
  59. package/dist/util/fsUtil.d.ts +2 -3
  60. package/dist/util/fsUtil.js +12 -33
  61. package/dist/util/renamingUtil.js +50 -82
  62. package/dist/util/resourceUtil.d.ts +21 -5
  63. package/dist/util/resourceUtil.js +52 -11
  64. package/dist/util/validator/abapConnectionValidator.d.ts +5 -0
  65. package/dist/util/validator/abapConnectionValidator.js +22 -0
  66. package/dist/util/validator/abapValidator.d.ts +2 -4
  67. package/dist/util/validator/abapValidator.js +4 -16
  68. package/dist/util/validator/validator.d.ts +1 -0
  69. package/dist/util/validator/validator.js +11 -0
  70. package/dist/util/workspaceManager.d.ts +9 -0
  71. package/dist/util/workspaceManager.js +46 -0
  72. package/dist/util/zipUtil.d.ts +1 -1
  73. package/dist/util/zipUtil.js +1 -1
  74. package/package.json +13 -13
  75. package/.hyperspace/pull_request_bot.json +0 -19
  76. package/dist/previewManager.d.ts +0 -14
  77. package/dist/previewManager.js +0 -141
  78. package/dist/util/filesUtil.d.ts +0 -19
  79. package/scripts/metadataDownloadHelper.ts +0 -88
  80. package/scripts/publish.ts +0 -256
  81. package/scripts/test-integration-prep.sh +0 -4
  82. /package/dist/{baseAppManager.d.ts → baseApp.d.ts} +0 -0
package/dist/bundle.js CHANGED
@@ -6301,7 +6301,7 @@ class _URL extends URL {
6301
6301
  }
6302
6302
  }
6303
6303
 
6304
- var rAmpersand = /&/g, rApplicationGroupID = /^\w+$/, sClassName$2 = "sap.ui.model.odata.v4.lib._Helper", rEquals = /\=/g, rGroupID = /^(\$auto(\.\w+)?|\$direct|\w+)$/, rHash = /#/g, rNotMetaContext = /\([^/]*|\/-?\d+/g, rPlus = /\+/g, rSingleQuote = /'/g, rSingleQuoteTwice = /''/g, rWhitespace = /\s+/g, _Helper;
6304
+ var rAmpersand = /&/g, rApplicationGroupID = /^\w+$/, sClassName$2 = "sap.ui.model.odata.v4.lib._Helper", rEndsWithTransientPredicate = /\(\$uid=[-\w]+\)$/, rEquals = /\=/g, rGroupID = /^(\$auto(\.\w+)?|\$direct|\w+)$/, rHash = /#/g, rNotMetaContext = /\([^/]*|\/-?\d+/g, rPlus = /\+/g, rSingleQuote = /'/g, rSingleQuoteTwice = /''/g, rWhitespace = /\s+/g, _Helper;
6305
6305
  _Helper = {
6306
6306
  addByPath: function (mMap, sPath, oItem) {
6307
6307
  if (oItem) {
@@ -6495,6 +6495,19 @@ _Helper = {
6495
6495
  convert(mQueryOptions, "");
6496
6496
  return aPaths;
6497
6497
  },
6498
+ copyETags: function (oSource, oTarget) {
6499
+ if (_Helper.getPrivateAnnotation(oSource, "predicate") !== _Helper.getPrivateAnnotation(oTarget, "predicate")) {
6500
+ return;
6501
+ }
6502
+ oTarget["@odata.etag"] = oSource["@odata.etag"];
6503
+ for (const sKey in oSource) {
6504
+ const vSourceProperty = oSource[sKey];
6505
+ const vTargetProperty = oTarget[sKey];
6506
+ if (vSourceProperty && vTargetProperty && typeof vSourceProperty === "object" && !Array.isArray(vSourceProperty)) {
6507
+ _Helper.copyETags(vSourceProperty, vTargetProperty);
6508
+ }
6509
+ }
6510
+ },
6498
6511
  copyPrivateAnnotation: function (oSource, sAnnotation, oTarget, bAllowSame) {
6499
6512
  if (_Helper.hasPrivateAnnotation(oSource, sAnnotation)) {
6500
6513
  if (_Helper.hasPrivateAnnotation(oTarget, sAnnotation)) {
@@ -6540,6 +6553,10 @@ _Helper = {
6540
6553
  if (typeof oResult.message === "object") {
6541
6554
  oResult.message = oResult.error.message.value;
6542
6555
  }
6556
+ const oClone = oResult.error["@$ui5.originalMessage"] = _Helper.clone(oResult.error);
6557
+ oResult.error.details?.forEach(function (oDetail, i) {
6558
+ oDetail["@$ui5.originalMessage"] = oClone.details[i];
6559
+ });
6543
6560
  } catch (e) {
6544
6561
  Log.warning(e.toString(), sBody, sClassName$2);
6545
6562
  }
@@ -6583,7 +6600,7 @@ _Helper = {
6583
6600
  };
6584
6601
  },
6585
6602
  createTechnicalDetails: function (oMessage) {
6586
- var oClonedMessage, oError = oMessage["@$ui5.error"], oOriginalMessage = oMessage["@$ui5.originalMessage"] || oMessage, oTechnicalDetails = {};
6603
+ var oClonedMessage, oError = oMessage["@$ui5.error"], oOriginalMessage = oMessage["@$ui5.originalMessage"], oTechnicalDetails = {};
6587
6604
  if (oError && (oError.status || oError.cause)) {
6588
6605
  oError = oError.cause || oError;
6589
6606
  oTechnicalDetails.httpStatus = oError.status;
@@ -6594,7 +6611,7 @@ _Helper = {
6594
6611
  oTechnicalDetails.retryAfter = oError.retryAfter;
6595
6612
  }
6596
6613
  }
6597
- if (!(oOriginalMessage instanceof Error)) {
6614
+ if (oOriginalMessage) {
6598
6615
  Object.defineProperty(oTechnicalDetails, "originalMessage", {
6599
6616
  enumerable: true,
6600
6617
  get: function () {
@@ -6709,9 +6726,11 @@ _Helper = {
6709
6726
  message: oMessage.message,
6710
6727
  numericSeverity: iNumericSeverity,
6711
6728
  technical: bTechnical || oMessage.technical,
6712
- "@$ui5.error": oError,
6713
- "@$ui5.originalMessage": oMessage
6729
+ "@$ui5.error": oError
6714
6730
  };
6731
+ if (!(oMessage instanceof Error)) {
6732
+ oRawMessage["@$ui5.originalMessage"] = oMessage["@$ui5.originalMessage"] ?? oMessage;
6733
+ }
6715
6734
  Object.keys(oMessage).forEach(function (sProperty) {
6716
6735
  if (sProperty[0] === "@") {
6717
6736
  if (sProperty.endsWith(".numericSeverity")) {
@@ -7016,6 +7035,28 @@ _Helper = {
7016
7035
  }
7017
7036
  return mURLParameters;
7018
7037
  },
7038
+ getUsedPaths: function (aPaths, mQueryOptions) {
7039
+ function isRelated(sPath0, sPath1) {
7040
+ return _Helper.hasPathPrefix(sPath0, sPath1) || _Helper.hasPathPrefix(sPath1, sPath0);
7041
+ }
7042
+ function isUsed(sPath, mQueryOptionsForPath) {
7043
+ let bPathMatchedExpand = false;
7044
+ const aSelect = mQueryOptionsForPath.$select || ["*"];
7045
+ const mExpand = mQueryOptionsForPath.$expand || ({});
7046
+ return sPath === "*" || (sPath in mExpand) || aSelect.includes(sPath) || aSelect.some(sSelect => isRelated(sPath, sSelect)) || Object.keys(mExpand).some(sExpand => {
7047
+ if (_Helper.hasPathPrefix(sPath, sExpand)) {
7048
+ bPathMatchedExpand = true;
7049
+ return isUsed(sPath.slice(sExpand.length + 1), mExpand[sExpand]);
7050
+ }
7051
+ if (_Helper.hasPathPrefix(sExpand, sPath)) {
7052
+ bPathMatchedExpand = true;
7053
+ return true;
7054
+ }
7055
+ return false;
7056
+ }) || !bPathMatchedExpand && aSelect.includes("*");
7057
+ }
7058
+ return aPaths.filter(sPath => isUsed(sPath, mQueryOptions));
7059
+ },
7019
7060
  hasPathPrefix: function (sPath, sBasePath) {
7020
7061
  return _Helper.getRelativePath(sPath, sBasePath) !== undefined;
7021
7062
  },
@@ -7134,6 +7175,9 @@ _Helper = {
7134
7175
  }
7135
7176
  return mResult;
7136
7177
  },
7178
+ isAffectedBy: function (sPropertyPath, sSideEffectsPath) {
7179
+ return _Helper.hasPathPrefix(sPropertyPath, sSideEffectsPath.endsWith("/*") ? sSideEffectsPath.slice(0, -2) : sSideEffectsPath);
7180
+ },
7137
7181
  isDataAggregation: function (mParameters) {
7138
7182
  return mParameters && mParameters.$$aggregation && !mParameters.$$aggregation.hierarchyQualifier;
7139
7183
  },
@@ -7190,13 +7234,7 @@ _Helper = {
7190
7234
  return oURL.origin === new URL(document.baseURI).origin ? oURL.toString().slice(oURL.origin.length) : oURL.toString();
7191
7235
  },
7192
7236
  makeAbsoluteLongtextUrl: function (oMessage, sBase) {
7193
- if (oMessage.longtextUrl) {
7194
- const sAbsoluteLongtextURL = _Helper.makeAbsolute(oMessage.longtextUrl, sBase);
7195
- if (oMessage.longtextUrl !== sAbsoluteLongtextURL) {
7196
- oMessage["@$ui5.originalMessage"] ??= _Helper.clone(oMessage);
7197
- oMessage.longtextUrl = sAbsoluteLongtextURL;
7198
- }
7199
- }
7237
+ oMessage.longtextUrl &&= _Helper.makeAbsolute(oMessage.longtextUrl, sBase);
7200
7238
  },
7201
7239
  makeRelativePath: function (sPath, sBase) {
7202
7240
  return new _URL(sPath).relativeTo(new _URL(sBase));
@@ -7212,6 +7250,9 @@ _Helper = {
7212
7250
  return oResult;
7213
7251
  }, vValue);
7214
7252
  },
7253
+ matchEndsWithTransientPredicate: function (sPath) {
7254
+ return rEndsWithTransientPredicate.exec(sPath);
7255
+ },
7215
7256
  merge: fnMerge,
7216
7257
  mergeQueryOptions: function (mQueryOptions, sOrderby, aFilters) {
7217
7258
  var mResult;
@@ -1,8 +1,8 @@
1
1
  export default class CacheHolder {
2
2
  private static TEMP_TASK_DIR;
3
- private static getTempDir;
4
- static read(repoName: string, token: string): Promise<Map<string, string>>;
5
- static write(repoName: string, token: string, files: Map<string, string>): Promise<void>;
3
+ static getTempDir(...paths: string[]): string;
4
+ static read(repoName: string, token: string): Promise<Map<string, Buffer>>;
5
+ static write(repoName: string, token: string, files: Map<string, Buffer>): Promise<void>;
6
6
  private static isValid;
7
7
  /**
8
8
  * Clears cached files by repo name and token
@@ -68,17 +68,18 @@ export function cached() {
68
68
  return function (_target, _propertyKey, descriptor) {
69
69
  const originalValue = descriptor.value;
70
70
  descriptor.value = async function (...args) {
71
- const repoName = args[0];
72
- const cachebusterToken = args[1];
73
- let files = await CacheHolder.read(repoName, cachebusterToken);
74
- CacheHolder.clearOutdatedExcept(repoName);
71
+ const cachedResource = args[0];
72
+ const { appName, cacheBusterToken: cachebusterToken } = cachedResource;
73
+ const token = await cachebusterToken;
74
+ let files = await CacheHolder.read(appName, token);
75
+ CacheHolder.clearOutdatedExcept(appName);
75
76
  if (files.size === 0) {
76
- log.verbose(`No cache for repo '${repoName}' with token '${cachebusterToken}'. Fetching from HTML5 Repository.`);
77
+ log.verbose(`No cache for repo '${appName}' with token '${token}'. Fetching from HTML5 Repository.`);
77
78
  files = await originalValue.apply(this, args);
78
- await CacheHolder.write(repoName, cachebusterToken, files);
79
+ await CacheHolder.write(appName, token, files);
79
80
  }
80
81
  else {
81
- log.verbose(`Using cached files for repo '${repoName}' with token '${cachebusterToken}'.`);
82
+ log.verbose(`Using cached files for repo '${appName}' with token '${token}'.`);
82
83
  }
83
84
  return files;
84
85
  };
@@ -0,0 +1,4 @@
1
+ export default interface ICachedResource {
2
+ appName: string;
3
+ cacheBusterToken: Promise<string>;
4
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=cachedResource.js.map
package/dist/index.d.ts CHANGED
@@ -2,5 +2,5 @@ import { ITaskParameters } from "./model/types.js";
2
2
  /**
3
3
  * Creates an appVariant bundle from the provided resources.
4
4
  */
5
- declare const _default: ({ workspace, options, taskUtil }: ITaskParameters) => Promise<void>;
5
+ declare const _default: ({ workspace, options, taskUtil }: ITaskParameters) => Promise<ReadonlyMap<string, string>>;
6
6
  export default _default;
package/dist/index.js CHANGED
@@ -1,79 +1,54 @@
1
1
  import * as dotenv from "dotenv";
2
- import { logBuilderVersion } from "./util/commonUtil.js";
3
- import AppVariant from "./appVariantManager.js";
4
- import BaseApp from "./baseAppManager.js";
5
- import ResourceUtil from "./util/resourceUtil.js";
6
- import FilesUtil from "./util/filesUtil.js";
7
- import PreviewManager from "./previewManager.js";
2
+ import { getReferences, logBuilderVersion } from "./util/commonUtil.js";
3
+ import AppVariant from "./appVariant.js";
4
+ import BaseApp from "./baseApp.js";
8
5
  import { initialize } from "./landscapeConfiguration.js";
6
+ import WorkspaceManager from "./util/workspaceManager.js";
9
7
  /**
10
8
  * Creates an appVariant bundle from the provided resources.
11
9
  */
12
- export default ({ workspace, options, taskUtil }) => {
10
+ export default async ({ workspace, options, taskUtil }) => {
11
+ const ui5BuilderTools = {
12
+ workspace,
13
+ projectNamespace: options.projectNamespace,
14
+ taskUtil,
15
+ };
13
16
  dotenv.config();
14
- async function process(workspace, taskUtil) {
15
- logBuilderVersion();
16
- const { repository, adapter } = initialize(options.configuration);
17
- const adaptationProject = await AppVariant.fromWorkspace(workspace, options.projectNamespace);
18
- const previewManagerPromise = PreviewManager.createFromRoot(adaptationProject.reference, repository, options.configuration);
19
- const appVariantIdHierarchy = await repository.getAppVariantIdHierarchy(adaptationProject.reference);
20
- if (appVariantIdHierarchy.length === 0) {
21
- throw new Error(`No app variant found for reference ${adaptationProject.reference}`);
22
- }
23
- // appVariantIdHierarchy contains original application on bottom and the
24
- // latest app variant on top. We reverse the list to process original
25
- // application first and then app variants in chronological order.
26
- const reversedHierarchy = appVariantIdHierarchy.toReversed();
27
- const fetchFilesPromises = reversedHierarchy.map(({ repoName, cachebusterToken }) => repository.fetch(repoName, cachebusterToken));
28
- fetchFilesPromises.push(Promise.resolve(adaptationProject.files));
29
- const appVariants = new Array();
30
- const adapt = async (baseAppFiles, appVariantFiles) => {
31
- let baseApp = BaseApp.fromFiles(baseAppFiles);
32
- let appVariant = AppVariant.fromFiles(appVariantFiles);
33
- // If the app variant is the same as the adaptation project, we use the
34
- // adaptation project because it contains resources that should be updated.
35
- if (appVariant.id === adaptationProject.id) {
36
- appVariant = adaptationProject;
37
- }
38
- appVariants.push(appVariant);
39
- const adaptCommandChain = adapter.createAdaptCommandChain(baseApp, appVariant);
40
- const mergeCommandChain = adapter.createMergeCommandChain(baseApp, appVariant);
41
- const adaptedFiles = await adaptCommandChain.execute();
42
- const mergedFiles = await mergeCommandChain.execute(adaptedFiles);
43
- return mergedFiles;
44
- };
45
- let files = await fetchFilesPromises.reduce(async (previousFiles, currentFiles) => adapt(await previousFiles, await currentFiles), fetchFilesPromises.shift());
46
- files = await adapter.createPostCommandChain().execute(files);
47
- const references = getReferences(appVariants, adaptationProject.id);
48
- files = FilesUtil.filter(files);
49
- files = FilesUtil.rename(files, references);
50
- adaptationProject.omitDeletedResources(files, options.projectNamespace, taskUtil);
51
- // Read libs for preview
52
- const previewManager = await previewManagerPromise;
53
- const writePromises = new Array(previewManager.processPreviewResources(files));
54
- files.forEach((content, filename) => {
55
- const resource = ResourceUtil.createResource(filename, options.projectNamespace, content);
56
- writePromises.push(workspace.write(resource));
57
- });
58
- await Promise.all(writePromises);
17
+ logBuilderVersion();
18
+ // We write original app files and appVariant files to workspace as they
19
+ // fetched, in this case these files will overwrite the adaptation project
20
+ // files, so we create a snapshot to later on overwrite the workspace files
21
+ // with adapatation project files again to make sure they are on top
22
+ const workspaceManager = new WorkspaceManager(workspace, options.projectNamespace);
23
+ await workspaceManager.createSnapshot();
24
+ const { repository, adapter } = await initialize(options.configuration);
25
+ const adaptationProject = await AppVariant.fromWorkspace(workspace, options.projectNamespace);
26
+ const setupCommandChain = adapter.createSetupCommandChain(adaptationProject.reference, repository);
27
+ await setupCommandChain.execute();
28
+ const appVariantIdHierarchy = await repository.getAppVariantIdHierarchy(adaptationProject.reference);
29
+ if (appVariantIdHierarchy.length === 0) {
30
+ throw new Error(`No app variant found for reference ${adaptationProject.reference}`);
59
31
  }
60
- return process(workspace, taskUtil);
61
- /**
62
- * 4p. Reference map contains searchTerm as key and replacement as value. Base
63
- * id and app variant ids are renamed to adaptation project id.
64
- */
65
- function getReferences(appVariants, adaptationProjectId) {
66
- const references = new Map();
67
- appVariants.forEach((variant, i) => {
68
- if (i === 0) {
69
- references.set(variant.reference, adaptationProjectId);
70
- }
71
- if (variant.id !== adaptationProjectId) {
72
- references.set(variant.id, adaptationProjectId);
73
- }
74
- variant.getRenamingForMovedFiles().forEach((value, key) => references.set(key, value));
75
- });
76
- return references;
32
+ // appVariantIdHierarchy contains original application on bottom and the
33
+ // latest app variant on top. We reverse the list to process original
34
+ // application first and then app variants in chronological order.
35
+ const reversedHierarchy = appVariantIdHierarchy.toReversed();
36
+ const fetchFilesPromises = reversedHierarchy.map(variant => repository.fetch(variant));
37
+ const appVariants = new Array();
38
+ const adapt = async (baseFiles, appVariant) => {
39
+ appVariants.push(appVariant);
40
+ const baseApp = BaseApp.fromFiles(baseFiles);
41
+ return adapter.createAdaptCommandChain(baseApp, appVariant).execute();
42
+ };
43
+ let files = await workspaceManager.saveAndConvert(fetchFilesPromises.shift()); // original app files
44
+ for (const appVariantFilesPromise of fetchFilesPromises) {
45
+ const appVariantFiles = await workspaceManager.saveAndConvert(appVariantFilesPromise);
46
+ files = await adapt(files, AppVariant.fromFiles(appVariantFiles));
77
47
  }
48
+ // We need to overwrite base files with the adaptation project files
49
+ await workspaceManager.restoreSnapshot();
50
+ files = await adapt(files, adaptationProject);
51
+ const references = getReferences(appVariants, adaptationProject.id);
52
+ return adapter.createPostCommandChain(references, adaptationProject, ui5BuilderTools).execute(files);
78
53
  };
79
54
  //# sourceMappingURL=index.js.map
@@ -2,8 +2,8 @@ import { IConfiguration } from "./model/types.js";
2
2
  import { IAdapter } from "./adapters/adapter.js";
3
3
  import IRepository from "./repositories/repository.js";
4
4
  import IAnnotationManager from "./annotations/annotationManager.js";
5
- export declare function initialize(configuration: IConfiguration): {
5
+ export declare function initialize(configuration: IConfiguration): Promise<{
6
6
  adapter: IAdapter;
7
7
  repository: IRepository;
8
8
  annotationManager: IAnnotationManager;
9
- };
9
+ }>;
@@ -1,39 +1,31 @@
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 CFAnnotationManager from "./annotations/cfAnnotationManager.js";
9
1
  import CFValidator from "./util/validator/cfValidator.js";
10
- import AbapValidator from "./util/validator/abapValidator.js";
11
2
  import { isOneOf } from "./util/validator/validator.js";
12
3
  import { LANDSCAPE_TYPES } from "./model/configuration.js";
13
4
  import { getLogger } from "@ui5/logger";
5
+ import AbapValidator from "./util/validator/abapValidator.js";
14
6
  import LocalAnnotationManager from "./annotations/localAnnotationManager.js";
15
7
  const log = getLogger("@ui5/task-adaptation::LandscapeConfiguration");
16
- export function initialize(configuration) {
17
- const type = getTypeByConfiguration(configuration);
8
+ export async function initialize(configuration) {
9
+ const type = await getTypeByConfiguration(configuration);
18
10
  const enhancedConfig = { ...configuration, type };
19
- const repository = getRepository(enhancedConfig);
20
- const annotationManager = getAnnotationManager(enhancedConfig, repository);
11
+ const repository = await getRepository(enhancedConfig);
12
+ const annotationManager = await getAnnotationManager(enhancedConfig, repository);
21
13
  return {
22
- adapter: getAdapter(enhancedConfig, annotationManager),
14
+ adapter: await getAdapter(enhancedConfig, annotationManager),
23
15
  repository,
24
16
  annotationManager
25
17
  };
26
18
  }
27
- function getTypeByConfiguration(configuration) {
28
- const validators = [
29
- new CFValidator(),
30
- new AbapValidator(),
31
- ];
19
+ async function getTypeByConfiguration(configuration) {
32
20
  if (isOneOf(LANDSCAPE_TYPES, configuration.type)) {
33
21
  return configuration.type;
34
22
  }
35
23
  else {
36
24
  log.warn("Deprecated behavior: type is not specified or invalid. Should be either 'cf' or 'abap'. Trying to detect the type based on provided configuration");
25
+ const validators = [
26
+ new CFValidator(),
27
+ new AbapValidator(),
28
+ ];
37
29
  for (const validator of validators) {
38
30
  try {
39
31
  validator.validateConfiguration(configuration);
@@ -46,49 +38,59 @@ function getTypeByConfiguration(configuration) {
46
38
  throw new Error("'type' should be specified in ui5.yaml configuration: 'cf' or 'abap'");
47
39
  }
48
40
  }
49
- function getAdapter(configuration, annotationManager) {
50
- if (isPreview(configuration)) {
41
+ async function getAdapter(configuration, annotationManager) {
42
+ if (isPreview()) {
43
+ const { default: PreviewAdapter } = await import("./adapters/previewAdapter.js");
51
44
  return new PreviewAdapter(configuration);
52
45
  }
53
46
  switch (configuration.type) {
54
- case "abap":
47
+ case "abap": {
48
+ const { default: AbapAdapter } = await import("./adapters/abapAdapter.js");
55
49
  return new AbapAdapter(annotationManager);
56
- case "cf":
50
+ }
51
+ case "cf": {
52
+ const { default: CFAdapter } = await import("./adapters/cfAdapter.js");
57
53
  return new CFAdapter(configuration);
54
+ }
58
55
  default:
59
56
  throw new Error(`No adapter found for the given configuration type '${configuration.type}'`);
60
57
  }
61
58
  }
62
- function getRepository(configuration) {
63
- if (isLocal(configuration)) {
64
- return new LocalRepository(configuration);
65
- }
59
+ async function getRepository(configuration) {
66
60
  switch (configuration.type) {
67
- case "abap":
61
+ case "abap": {
62
+ const { default: AbapRepository } = await import("./repositories/abapRepository.js");
68
63
  return new AbapRepository(configuration);
69
- case "cf":
64
+ }
65
+ case "cf": {
66
+ const { default: HTML5Repository } = await import("./repositories/html5Repository.js");
70
67
  return new HTML5Repository(configuration);
68
+ }
71
69
  default:
72
70
  throw new Error(`No repository found for the given configuration type '${configuration.type}'`);
73
71
  }
74
72
  }
75
- function getAnnotationManager(configuration, repository) {
76
- if (isLocal(configuration)) {
73
+ async function getAnnotationManager(configuration, repository) {
74
+ if (isLocal()) {
77
75
  return new LocalAnnotationManager();
78
76
  }
79
77
  switch (configuration.type) {
80
- case "abap":
78
+ case "abap": {
79
+ const { default: AbapAnnotationManager } = await import("./annotations/abapAnnotationManager.js");
81
80
  return new AbapAnnotationManager(configuration, repository);
82
- case "cf":
81
+ }
82
+ case "cf": {
83
+ const { default: CFAnnotationManager } = await import("./annotations/cfAnnotationManager.js");
83
84
  return new CFAnnotationManager();
85
+ }
84
86
  default:
85
87
  throw new Error(`No annotation manager found for the given configuration type '${configuration.type}'`);
86
88
  }
87
89
  }
88
- function isLocal(configuration) {
89
- return process.env.ADP_BUILDER_MODE === "local" || configuration.mode === "local";
90
+ function isLocal() {
91
+ return process.env.ADP_BUILDER_MODE === "local";
90
92
  }
91
- function isPreview(configuration) {
92
- return process.env.ADP_BUILDER_MODE === "preview" || configuration.mode === "preview";
93
+ function isPreview() {
94
+ return process.env.ADP_BUILDER_MODE === "preview";
93
95
  }
94
96
  //# sourceMappingURL=landscapeConfiguration.js.map
@@ -9,20 +9,17 @@ export interface IConfiguration {
9
9
  sapCloudService?: string;
10
10
  destination?: string;
11
11
  type?: LandscapeType;
12
- mode?: LandscapeMode;
13
12
  languages?: any[] | undefined;
14
13
  enableAnnotationCache?: boolean;
15
14
  enableBetaFeatures?: boolean;
16
15
  writeTempFiles?: any;
17
16
  target?: AbapTarget & IAbapTargetMeta;
18
17
  serviceInstanceName?: string;
19
- adpDir?: string;
20
18
  }
21
19
  export declare const LANDSCAPE_TYPES: readonly ["cf", "abap"];
22
20
  export type LandscapeType = typeof LANDSCAPE_TYPES[number];
23
- export declare const LANDSCAPE_MODES: readonly ["preview", "local", "default"];
24
- export type LandscapeMode = typeof LANDSCAPE_MODES[number];
25
21
  export interface IAbapTargetMeta {
26
22
  name?: string;
27
23
  ignoreCertErrors?: boolean;
28
24
  }
25
+ export declare const REUSE_DIR = ".adp/reuse";
@@ -1,3 +1,3 @@
1
1
  export const LANDSCAPE_TYPES = ["cf", "abap"];
2
- export const LANDSCAPE_MODES = ["preview", "local", "default"];
2
+ export const REUSE_DIR = ".adp/reuse";
3
3
  //# sourceMappingURL=configuration.js.map
@@ -1,3 +1,4 @@
1
+ import TaskUtil from "@ui5/project/build/helpers/TaskUtil";
1
2
  import { IConfiguration } from "./configuration.js";
2
3
  import Language from "./language.js";
3
4
  export interface IProjectOptions {
@@ -74,9 +75,14 @@ export interface IChangeContent {
74
75
  supportedLocales?: string[];
75
76
  }
76
77
  export interface ITaskParameters {
77
- workspace: any;
78
+ workspace: IWorkspace;
78
79
  options: IProjectOptions;
79
- taskUtil: any;
80
+ taskUtil: TaskUtil;
81
+ }
82
+ export interface UI5BuilderTools {
83
+ workspace: IWorkspace;
84
+ projectNamespace: string;
85
+ taskUtil: TaskUtil;
80
86
  }
81
87
  export interface IBaseAppInfo {
82
88
  filepath: string;
@@ -123,4 +129,5 @@ export type ServiceCredentials = {
123
129
  } | string>;
124
130
  "sap.cloud.service"?: string;
125
131
  };
132
+ export type FetchFilesPromise = Map<string, Promise<ReadonlyMap<string, Buffer>>>;
126
133
  export { IConfiguration };
@@ -1,11 +1,11 @@
1
1
  import { createAbapServiceProvider } from "@sap-ux/system-access";
2
2
  import { getLogger } from "@ui5/logger";
3
- import AbapValidator from "../util/validator/abapValidator.js";
3
+ import AbapConnectionValidator from "../util/validator/abapConnectionValidator.js";
4
4
  const log = getLogger("@ui5/task-adaptation::AbapProvider");
5
5
  log.debug = (message) => log.verbose(message);
6
6
  export default class AbapProvider {
7
7
  provider = null;
8
- abapValidator = new AbapValidator();
8
+ abapValidator = new AbapConnectionValidator();
9
9
  async get({ target, destination }) {
10
10
  if (!this.provider) {
11
11
  const abapTarget = this.abapValidator.validateAndGetAbapTarget(target, destination);
@@ -1,15 +1,16 @@
1
- import { IConfiguration, IMetadata, IReuseLibInfo } from "../model/types.js";
1
+ import { IConfiguration, IMetadata } from "../model/types.js";
2
2
  import AbapProvider from "./abapProvider.js";
3
- import { IAppVariantIdHierarchyItem } from "../model/appVariantIdHierarchyItem.js";
4
3
  import IRepository from "./repository.js";
4
+ import ICachedResource from "../cache/cachedResource.js";
5
+ type IAbapResource = ICachedResource;
5
6
  export default class AbapRepository implements IRepository {
6
7
  private configuration;
7
8
  private abapProvider;
8
9
  constructor(configuration: IConfiguration, abapProvider?: AbapProvider);
9
- fetchReuseLib(_libName: string, _cachebusterToken: string, _lib: IReuseLibInfo): Promise<Map<string, string>>;
10
- getAppVariantIdHierarchy(id: string): Promise<IAppVariantIdHierarchyItem[]>;
10
+ getAppVariantIdHierarchy(id: string): Promise<IAbapResource[]>;
11
11
  getAnnotationMetadata(uri: string): Promise<IMetadata>;
12
12
  downloadAnnotationFile(uri: string): Promise<Map<string, any>>;
13
13
  getMetadata(id: string): Promise<IMetadata>;
14
- fetch(repoName: string, _cachebusterToken: string): Promise<Map<string, string>>;
14
+ fetch(resource: IAbapResource): Promise<Map<string, Buffer>>;
15
15
  }
16
+ export {};
@@ -27,9 +27,6 @@ export default class AbapRepository {
27
27
  this.configuration = configuration;
28
28
  this.abapProvider = abapProvider ? abapProvider : new AbapProvider();
29
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
- }
33
30
  async getAppVariantIdHierarchy(id) {
34
31
  const provider = await this.abapProvider.get(this.configuration);
35
32
  const lrep = provider.getLayeredRepository();
@@ -37,15 +34,17 @@ export default class AbapRepository {
37
34
  params: { id }
38
35
  });
39
36
  if (response.status === 200) {
40
- return JSON.parse(response.data)?.appVariantIdHierarchy;
37
+ const hierarchy = JSON.parse(response.data)?.appVariantIdHierarchy;
38
+ return hierarchy.map(item => ({
39
+ appName: item.repoName,
40
+ cacheBusterToken: Promise.resolve(item.cachebusterToken)
41
+ }));
41
42
  }
42
43
  else if (this.configuration.appName) {
43
44
  // Fallback to old API on old ABAP backend or CF for backward compatibility
44
- const metadataResponse = await this.getMetadata(id);
45
45
  return [{
46
- repoName: this.configuration.appName,
47
- appVariantId: id,
48
- cachebusterToken: metadataResponse.changedOn
46
+ appName: this.configuration.appName,
47
+ cacheBusterToken: this.getMetadata(id).then(metadata => metadata.changedOn),
49
48
  }];
50
49
  }
51
50
  throw new Error(`App variant id hierarchy for app id '${id}' is not provided`);
@@ -78,8 +77,8 @@ export default class AbapRepository {
78
77
  id
79
78
  };
80
79
  }
81
- async fetch(repoName, _cachebusterToken) {
82
- const encodedRepoName = encodeURIComponent(repoName);
80
+ async fetch(resource) {
81
+ const encodedRepoName = encodeURIComponent(resource.appName);
83
82
  const provider = await this.abapProvider.get(this.configuration);
84
83
  const ui5Repo = provider.getUi5AbapRepository();
85
84
  const response = await ui5Repo.get(`/Repositories('${encodedRepoName}')`, {
@@ -94,7 +93,7 @@ export default class AbapRepository {
94
93
  const buffer = Buffer.from(data.d.ZipArchive, "base64");
95
94
  return unzipZipEntries(buffer);
96
95
  }
97
- throw new Error(`App '${repoName}' doesn't contain files`);
96
+ throw new Error(`App '${resource.appName}' doesn't contain files`);
98
97
  }
99
98
  }
100
99
  __decorate([
@@ -1,13 +1,16 @@
1
- import { IConfiguration, IReuseLibInfo } from "./../model/types.js";
1
+ import { IConfiguration } from "./../model/types.js";
2
2
  import IRepository from "./repository.js";
3
- import { IAppVariantIdHierarchyItem } from "../model/appVariantIdHierarchyItem.js";
3
+ import ICachedResource from "../cache/cachedResource.js";
4
+ export interface IHtml5Resource extends ICachedResource {
5
+ appVersion: string;
6
+ appHostId: string;
7
+ }
4
8
  export default class HTML5Repository implements IRepository {
5
9
  private configuration;
6
10
  private validator;
7
11
  constructor(configuration: IConfiguration);
8
- getAppVariantIdHierarchy(appId: string): Promise<IAppVariantIdHierarchyItem[]>;
9
- fetch(_repoName: string, _cachebusterToken: string): Promise<Map<string, string>>;
10
- fetchReuseLib(_libName: string, _cachebusterToken: string, lib: IReuseLibInfo): Promise<Map<string, string>>;
12
+ getAppVariantIdHierarchy(_appId: string): Promise<IHtml5Resource[]>;
13
+ fetch(resource: IHtml5Resource): Promise<Map<string, Buffer>>;
11
14
  getMetadata(): Promise<any>;
12
15
  private getHtml5RepoInfo;
13
16
  private getHTML5Credentials;