@ui5/task-adaptation 1.3.2 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,7 +2,10 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
4
4
 
5
- A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task-adaptation/compare/v1.3.2...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task-adaptation/compare/v1.3.3...HEAD).
6
+
7
+ <a name="v1.3.3"></a>
8
+ ## [v1.3.3] - 2024-09-11
6
9
 
7
10
  <a name="v1.3.2"></a>
8
11
  ## [v1.3.2] - 2024-06-04
@@ -94,6 +97,7 @@ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task
94
97
  <a name="v1.0.0"></a>
95
98
  ## v1.0.0 - 2020-12-09
96
99
 
100
+ [v1.3.3]: https://github.com/SAP/ui5-task-adaptation/compare/v1.3.2...v1.3.3
97
101
  [v1.3.2]: https://github.com/SAP/ui5-task-adaptation/compare/v1.3.1...v1.3.2
98
102
  [v1.3.1]: https://github.com/SAP/ui5-task-adaptation/compare/v1.3.0...v1.3.1
99
103
  [v1.3.0]: https://github.com/SAP/ui5-task-adaptation/compare/v1.2.0...v1.3.0
package/README.md CHANGED
@@ -6,6 +6,24 @@
6
6
  ## Description
7
7
  A custom task for [ui5-builder](https://github.com/SAP/ui5-builder) that allows building SAPUI5 adaptation projects for [SAP S/4HANA Cloud](https://help.sap.com/docs/bas/584e0bcbfd4a4aff91c815cefa0bce2d/6fc4e11a4b1941efa8e37a428d046f8f.html?locale=en-US&state=PRODUCTION&version=Cloud) and [SAP BTP, Cloud Foundry environment](https://help.sap.com/viewer/584e0bcbfd4a4aff91c815cefa0bce2d/Cloud/en-US/019b0c38a6b043d1a66b11d992eed290.html).
8
8
 
9
+ ### Configuration
10
+ #### ABAP Connection
11
+ The following connection configuration format is used to connect to ABAP repository on SAP BAS and IDE:
12
+ ```yaml
13
+ connections:
14
+ - url: example.com,
15
+ authenticationType: basic | reentranceTicket,
16
+ ignoreCertErrors: true | false
17
+ - destination: abc
18
+ ```
19
+ In case multiple connection configuration are present, then the current environment configuration will be used. For example in above case `destination` for SAP BAS or `url` for IDE will be automaticaly used.
20
+ OnPremise ABAP repository requires `authenticationType: basic`, credentials should be provided in project root `.env` file:
21
+ ```
22
+ FIORI_TOOLS_USER=<username>
23
+ FIORI_TOOLS_PASSWORD=<password>
24
+ ```
25
+ Whereas S4/Hana uses `authenticationType: reentranceTicket` to authentificate. A browser window will be opened.
26
+
9
27
  ## How to obtain support
10
28
  In case you need any support, please create a [GitHub issue](https://github.com/SAP/ui5-task-adaptation/issues).
11
29
 
package/dist/bundle.js CHANGED
@@ -1870,7 +1870,7 @@ Change.prototype.getTexts = function () {
1870
1870
  };
1871
1871
 
1872
1872
  var ObjectPath = {};
1873
- var defaultRootContext = window;
1873
+ var defaultRootContext = globalThis;
1874
1874
  function getObjectPathArray(vObjectPath) {
1875
1875
  return Array.isArray(vObjectPath) ? vObjectPath.slice() : vObjectPath.split(".");
1876
1876
  }
@@ -1904,9 +1904,19 @@ ObjectPath.set = function (vObjectPath, vValue, oRootContext) {
1904
1904
  oObject[sPropertyName] = vValue;
1905
1905
  };
1906
1906
 
1907
+ function splitEscapePath(sPropertyPath) {
1908
+ const sReplaceEscapeWithDummy = sPropertyPath.replaceAll("\\/", "*");
1909
+ const aPath = sReplaceEscapeWithDummy.split("/");
1910
+ return aPath.map(element => element.replaceAll("*", "/"));
1911
+ }
1907
1912
  function setPropValueByPath(oEntityProp, oRoot) {
1908
- var aPath = oEntityProp.propertyPath.split("/");
1909
- var valueByPath = ObjectPath.get(aPath, oRoot);
1913
+ let aPath;
1914
+ if (oEntityProp.propertyPath.includes("\\")) {
1915
+ aPath = splitEscapePath(oEntityProp.propertyPath);
1916
+ } else {
1917
+ aPath = oEntityProp.propertyPath.split("/");
1918
+ }
1919
+ const valueByPath = ObjectPath.get(aPath, oRoot);
1910
1920
  if (valueByPath && oEntityProp.operation === "INSERT") {
1911
1921
  throw new Error("Path has already a value. 'INSERT' operation is not appropriate.");
1912
1922
  }
@@ -2036,14 +2046,14 @@ var DescriptorChangeCheck = {
2036
2046
  isGenericPropertyPathSupported
2037
2047
  };
2038
2048
 
2039
- var SUPPORTED_OPERATIONS$1 = ["UPDATE", "UPSERT"];
2040
- var SUPPORTED_PROPERTIES$1 = ["uri", "settings/maxAge"];
2041
- var PROPERTIES_PATTERNS$1 = {};
2049
+ var SUPPORTED_OPERATIONS$2 = ["UPDATE", "UPSERT"];
2050
+ var SUPPORTED_PROPERTIES$2 = ["uri", "settings/maxAge"];
2051
+ var PROPERTIES_PATTERNS$2 = {};
2042
2052
  var ChangeDataSource = {
2043
2053
  applyChange(oManifest, oChange) {
2044
2054
  var oDataSources = oManifest["sap.app"].dataSources;
2045
2055
  var oChangeContent = oChange.getContent();
2046
- DescriptorChangeCheck.checkEntityPropertyChange(oChangeContent, SUPPORTED_PROPERTIES$1, SUPPORTED_OPERATIONS$1, PROPERTIES_PATTERNS$1);
2056
+ DescriptorChangeCheck.checkEntityPropertyChange(oChangeContent, SUPPORTED_PROPERTIES$2, SUPPORTED_OPERATIONS$2, PROPERTIES_PATTERNS$2);
2047
2057
  if (oDataSources) {
2048
2058
  var oDataSource = oDataSources[oChangeContent.dataSourceId];
2049
2059
  if (oDataSource) {
@@ -2058,20 +2068,56 @@ var ChangeDataSource = {
2058
2068
  }
2059
2069
  };
2060
2070
 
2061
- var AddNewModelEnhanceWith = {
2071
+ function hasBundleUrlAndNotBundleName(oChangeContent) {
2072
+ const sErrorMessage = "A schema violation has been identified. Either bundleName or bundleUrl property must be used.";
2073
+ if (oChangeContent.bundleUrl) {
2074
+ if (oChangeContent.bundleName) {
2075
+ throw Error(sErrorMessage);
2076
+ }
2077
+ return true;
2078
+ }
2079
+ return false;
2080
+ }
2081
+ function processTerminologies(oChangeContent, sAppId) {
2082
+ const aTermoinologiesKeys = Object.keys(oChangeContent.terminologies || ({}));
2083
+ if (aTermoinologiesKeys.length > 0) {
2084
+ aTermoinologiesKeys.forEach(sTerminology => {
2085
+ const oTerminologyObject = oChangeContent.terminologies[sTerminology];
2086
+ if (hasBundleUrlAndNotBundleName(oTerminologyObject)) {
2087
+ oTerminologyObject.bundleName = ApplyUtil.formatBundleName(sAppId, oTerminologyObject.bundleUrl);
2088
+ delete oTerminologyObject.bundleUrl;
2089
+ }
2090
+ });
2091
+ }
2092
+ }
2093
+ const AddNewModelEnhanceWith = {
2062
2094
  applyChange(oManifest, oChange) {
2063
- var sModelId = oChange.getContent().modelId;
2064
- var sI18N = ApplyUtil.formatBundleName(oManifest["sap.app"].id, oChange.getTexts().i18n);
2065
- var oModel = oManifest["sap.ui5"].models[sModelId];
2095
+ const oChangeContent = oChange.getContent();
2096
+ const sModelId = oChangeContent.modelId;
2097
+ const oModel = oManifest["sap.ui5"].models[sModelId];
2066
2098
  if (oModel) {
2067
2099
  if (oModel.type && oModel.type === "sap.ui.model.resource.ResourceModel") {
2068
2100
  if (!(oModel.settings && oModel.settings.enhanceWith)) {
2069
2101
  ObjectPath.set("settings.enhanceWith", [], oModel);
2070
2102
  }
2071
- var oEnhanceWith = oModel.settings.enhanceWith;
2072
- oEnhanceWith.push({
2073
- bundleName: sI18N
2074
- });
2103
+ const sAppId = oManifest["sap.app"].id;
2104
+ const sI18n = oChange.getTexts()?.i18n;
2105
+ const oEnhanceWith = oModel.settings.enhanceWith;
2106
+ if (sI18n) {
2107
+ oEnhanceWith.push({
2108
+ bundleName: ApplyUtil.formatBundleName(sAppId, sI18n)
2109
+ });
2110
+ return oManifest;
2111
+ }
2112
+ if (hasBundleUrlAndNotBundleName(oChangeContent)) {
2113
+ oChangeContent.bundleName = ApplyUtil.formatBundleName(sAppId, oChangeContent.bundleUrl);
2114
+ delete oChangeContent.bundleUrl;
2115
+ }
2116
+ processTerminologies(oChangeContent, sAppId);
2117
+ delete oChangeContent.modelId;
2118
+ if (Object.keys(oChangeContent).length > 0) {
2119
+ oEnhanceWith.push(oChangeContent);
2120
+ }
2075
2121
  }
2076
2122
  }
2077
2123
  return oManifest;
@@ -2446,9 +2492,9 @@ var RemoveAllInboundsExceptOne = {
2446
2492
  }
2447
2493
  };
2448
2494
 
2449
- var SUPPORTED_OPERATIONS = ["UPDATE", "UPSERT"];
2450
- var SUPPORTED_PROPERTIES = ["semanticObject", "action", "title", "subTitle", "icon", "signature/parameters/*"];
2451
- var PROPERTIES_PATTERNS = {
2495
+ var SUPPORTED_OPERATIONS$1 = ["UPDATE", "UPSERT"];
2496
+ var SUPPORTED_PROPERTIES$1 = ["semanticObject", "action", "title", "subTitle", "icon", "signature/parameters/*"];
2497
+ var PROPERTIES_PATTERNS$1 = {
2452
2498
  semanticObject: "^[\\w\\*]{0,30}$",
2453
2499
  action: "^[\\w\\*]{0,60}$"
2454
2500
  };
@@ -2456,7 +2502,7 @@ var ChangeInbound = {
2456
2502
  applyChange(oManifest, oChange) {
2457
2503
  var oCrossNavigation = oManifest["sap.app"].crossNavigation;
2458
2504
  var oChangeContent = oChange.getContent();
2459
- DescriptorChangeCheck.checkEntityPropertyChange(oChangeContent, SUPPORTED_PROPERTIES, SUPPORTED_OPERATIONS, PROPERTIES_PATTERNS);
2505
+ DescriptorChangeCheck.checkEntityPropertyChange(oChangeContent, SUPPORTED_PROPERTIES$1, SUPPORTED_OPERATIONS$1, PROPERTIES_PATTERNS$1);
2460
2506
  if (oCrossNavigation && oCrossNavigation.inbounds) {
2461
2507
  var oInbound = oCrossNavigation.inbounds[oChangeContent.inboundId];
2462
2508
  if (oInbound) {
@@ -2471,6 +2517,32 @@ var ChangeInbound = {
2471
2517
  }
2472
2518
  };
2473
2519
 
2520
+ const SUPPORTED_OPERATIONS = ["UPDATE", "UPSERT"];
2521
+ const SUPPORTED_PROPERTIES = ["semanticObject", "action", "additionalParameters", "parameters/*"];
2522
+ const PROPERTIES_PATTERNS = {
2523
+ semanticObject: "^[\\w\\*]{0,30}$",
2524
+ action: "^[\\w\\*]{0,60}$",
2525
+ additionalParameters: "^(ignored|allowed|notallowed)$"
2526
+ };
2527
+ const ChangeOutbound = {
2528
+ applyChange(oManifest, oChange) {
2529
+ const oCrossNavigation = oManifest["sap.app"].crossNavigation;
2530
+ const oChangeContent = oChange.getContent();
2531
+ DescriptorChangeCheck.checkEntityPropertyChange(oChangeContent, SUPPORTED_PROPERTIES, SUPPORTED_OPERATIONS, PROPERTIES_PATTERNS);
2532
+ if (oCrossNavigation && oCrossNavigation.outbounds) {
2533
+ const oOutbound = oCrossNavigation.outbounds[oChangeContent.outboundId];
2534
+ if (oOutbound) {
2535
+ changePropertyValueByPath(oChangeContent.entityPropertyChange, oOutbound);
2536
+ } else {
2537
+ throw new Error(`Nothing to update. outbound with ID "${oChangeContent.outboundId}" does not exist.`);
2538
+ }
2539
+ } else {
2540
+ throw new Error("sap.app/crossNavigation or sap.app/crossNavigation/outbounds sections have not been found in manifest.json");
2541
+ }
2542
+ return oManifest;
2543
+ }
2544
+ };
2545
+
2474
2546
  function getAndCheckInboundId(oChangeContent) {
2475
2547
  var aInbounds = Object.keys(oChangeContent.inbound);
2476
2548
  if (aInbounds.length > 1) {
@@ -2501,6 +2573,49 @@ var AddNewInbound = {
2501
2573
  }
2502
2574
  };
2503
2575
 
2576
+ const regex$1 = new RegExp("^([a-zA-Z0-9]{2,3})(-[a-zA-Z0-9]{1,6})*$");
2577
+ const SetAch = {
2578
+ applyChange(oManifest, oChange) {
2579
+ if (!oChange.getContent().hasOwnProperty("ach")) {
2580
+ throw new Error("No 'Application Component Hierarchy' (ACH) in change content provided");
2581
+ }
2582
+ if (typeof oChange.getContent().ach !== "string") {
2583
+ throw new Error(`The current change value type of property ach is '${typeof oChange.getContent().ach}'. Only allowed type for poperty ach is string`);
2584
+ }
2585
+ if (!regex$1.test(oChange.getContent().ach)) {
2586
+ throw new Error(`The current change value of property ach is '${oChange.getContent().ach}'. Supported values for property ach is the regular expression ${regex$1}`);
2587
+ }
2588
+ ObjectPath.set(["sap.app", "ach"], oChange.getContent().ach, oManifest);
2589
+ return oManifest;
2590
+ }
2591
+ };
2592
+
2593
+ const regex = new RegExp("^[A-Z0-9_\\-\\/]+$");
2594
+ const AddTechnicalAttributes = {
2595
+ applyChange(oManifest, oChange) {
2596
+ oManifest["sap.app"] ||= {};
2597
+ oManifest["sap.app"].tags ||= {};
2598
+ const oTags = oManifest["sap.app"].tags;
2599
+ oTags.technicalAttributes ||= [];
2600
+ const aManifestTechnicalAttributes = oTags.technicalAttributes;
2601
+ const aTechnicalAttributes = oChange.getContent().technicalAttributes;
2602
+ if (!oChange.getContent().hasOwnProperty("technicalAttributes")) {
2603
+ throw new Error("Property 'technicalAttributes' in change content is not provided");
2604
+ }
2605
+ if (!Array.isArray(aTechnicalAttributes)) {
2606
+ throw new Error(`The property 'technicalAttributes' has type '${typeof aTechnicalAttributes}'. Only allowed types for property 'technicalAttributes' is 'array'`);
2607
+ }
2608
+ if (!aTechnicalAttributes.every(element => typeof element === "string")) {
2609
+ throw new Error(`The array for the property 'technicalAttributes' does not only consist of strings. Only allowed values for the array is string`);
2610
+ }
2611
+ if (!aTechnicalAttributes.every(element => regex.test(element))) {
2612
+ throw new Error(`The array contains disallowed values. Supported values for 'technicalAttributes' should adhere to the regular expression ${regex}`);
2613
+ }
2614
+ oTags.technicalAttributes = Array.from(new Set(aManifestTechnicalAttributes.concat(aTechnicalAttributes)));
2615
+ return oManifest;
2616
+ }
2617
+ };
2618
+
2504
2619
  var SetAbstract = {
2505
2620
  applyChange(oManifest, oChange) {
2506
2621
  if (!oChange.getContent().hasOwnProperty("abstract")) {
@@ -2514,6 +2629,23 @@ var SetAbstract = {
2514
2629
  }
2515
2630
  };
2516
2631
 
2632
+ const SUPPORTED_STATUS = ["released", "deprecated", "obsolete"];
2633
+ var SetCloudDevAdaptationStatus = {
2634
+ applyChange(oManifest, oChange) {
2635
+ if (!oChange.getContent().hasOwnProperty("cloudDevAdaptationStatus")) {
2636
+ throw new Error("No cloudDevAdaptationStatus in change content provided");
2637
+ }
2638
+ if (typeof oChange.getContent().cloudDevAdaptationStatus !== "string") {
2639
+ throw new Error(`The current change value type of property cloudDevAdaptationStatus is '${typeof oChange.getContent().cloudDevAdaptationStatus}'. Only allowed type for poperty cloudDevAdaptationStatus is string`);
2640
+ }
2641
+ if (!SUPPORTED_STATUS.includes(oChange.getContent().cloudDevAdaptationStatus)) {
2642
+ throw new Error(`The current change value of property cloudDevAdaptationStatus is '${oChange.getContent().cloudDevAdaptationStatus}'. Supported values for property cloudDevAdaptationStatus are ${SUPPORTED_STATUS.join("|")}`);
2643
+ }
2644
+ ObjectPath.set(["sap.fiori", "cloudDevAdaptationStatus"], oChange.getContent().cloudDevAdaptationStatus, oManifest);
2645
+ return oManifest;
2646
+ }
2647
+ };
2648
+
2517
2649
  function _mergeExistingLibrary(oManifestLib, oChangeLib) {
2518
2650
  var oUpdatedLibrary = {};
2519
2651
  if (oChangeLib.minVersion) {
@@ -2548,6 +2680,13 @@ var SetTitle = {
2548
2680
  }
2549
2681
  };
2550
2682
 
2683
+ const SetDescription = {
2684
+ applyChange(oManifest) {
2685
+ oManifest["sap.app"].description = `{{${oManifest["sap.app"].id}_sap.app.description}}`;
2686
+ return oManifest;
2687
+ }
2688
+ };
2689
+
2551
2690
  var ChangeCard = {
2552
2691
  applyChange(oManifest, oChange) {
2553
2692
  var oChangedCard = oChange.getContent();
@@ -2602,17 +2741,6 @@ var fnAssert = function (bResult, vMessage) {
2602
2741
  }
2603
2742
  };
2604
2743
 
2605
- class config {
2606
- static get Type() {
2607
- return {
2608
- String: "string"
2609
- };
2610
- }
2611
- static get({name}) {
2612
- return name === "sapUiLogLevel" ? "Error" : undefined;
2613
- }
2614
- }
2615
-
2616
2744
  var fnNow = function now() {
2617
2745
  return performance.timeOrigin + performance.now();
2618
2746
  };
@@ -2857,17 +2985,6 @@ Log.getLogger = function (sComponent, iDefaultLogLevel) {
2857
2985
  }
2858
2986
  return new Logger(sComponent);
2859
2987
  };
2860
- const sLogLevel = config.get({
2861
- name: "sapUiLogLevel",
2862
- type: config.Type.String,
2863
- defaultValue: undefined,
2864
- external: true
2865
- });
2866
- if (sLogLevel) {
2867
- Log.setLevel(Log.Level[sLogLevel.toUpperCase()] || parseInt(sLogLevel));
2868
- } else if (!globalThis["sap-ui-optimized"]) {
2869
- Log.setLevel(Log.Level.DEBUG);
2870
- }
2871
2988
 
2872
2989
  var fnUniqueSort = function (aArray) {
2873
2990
  fnAssert(Array.isArray(aArray), "uniqueSort: input parameter must be an Array");
@@ -3419,9 +3536,17 @@ function applyChange(manifest, change) {
3419
3536
  }
3420
3537
  _exports.applyChange = applyChange;
3421
3538
  function changeConfiguration(manifest, pageId, path, value, lateChange) {
3422
- const pageSettings = getPageSettings(manifest, pageId);
3539
+ const pageSAPfe = "sap.fe";
3540
+ let propertyPath;
3541
+ let pageSettings;
3542
+ if (pageId === pageSAPfe) {
3543
+ propertyPath = [pageSAPfe, path];
3544
+ pageSettings = manifest;
3545
+ } else {
3546
+ pageSettings = getPageSettings(manifest, pageId);
3547
+ propertyPath = retrievePropertyPath(path);
3548
+ }
3423
3549
  if (pageSettings) {
3424
- const propertyPath = retrievePropertyPath(path);
3425
3550
  ObjectPath.set(propertyPath, value, pageSettings);
3426
3551
  if (lateChange) {
3427
3552
  pageConfigurationChanges[pageId] = pageConfigurationChanges[pageId] || [];
@@ -3479,6 +3604,7 @@ _exports.cleanPageConfigurationChanges = cleanPageConfigurationChanges;
3479
3604
  var Registration = {
3480
3605
  appdescr_ui5_addLibraries: () => Promise.resolve(AddLibrary),
3481
3606
  appdescr_app_setTitle: () => Promise.resolve(SetTitle),
3607
+ appdescr_app_setDescription: () => Promise.resolve(SetDescription),
3482
3608
  appdescr_ovp_changeCard: () => Promise.resolve(ChangeCard),
3483
3609
  appdescr_ovp_addNewCard: () => Promise.resolve(AddNewCard),
3484
3610
  appdescr_ovp_removeCard: () => Promise.resolve(DeleteCard),
@@ -3498,8 +3624,12 @@ var RegistrationBuild = {
3498
3624
  appdescr_app_addAnnotationsToOData: () => Promise.resolve(AddAnnotationsToOData),
3499
3625
  appdescr_app_removeAllInboundsExceptOne: () => Promise.resolve(RemoveAllInboundsExceptOne),
3500
3626
  appdescr_app_changeInbound: () => Promise.resolve(ChangeInbound),
3627
+ appdescr_app_changeOutbound: () => Promise.resolve(ChangeOutbound),
3501
3628
  appdescr_app_addNewInbound: () => Promise.resolve(AddNewInbound),
3502
- appdescr_fiori_setAbstract: () => Promise.resolve(SetAbstract)
3629
+ appdescr_app_setAch: () => Promise.resolve(SetAch),
3630
+ appdescr_app_addTechnicalAttributes: () => Promise.resolve(AddTechnicalAttributes),
3631
+ appdescr_fiori_setAbstract: () => Promise.resolve(SetAbstract),
3632
+ appdescr_fiori_setCloudDevAdaptationStatus: () => Promise.resolve(SetCloudDevAdaptationStatus)
3503
3633
  };
3504
3634
  var RegistrationCopy = Object.assign({}, Registration);
3505
3635
  var RegistrationBuild$1 = Object.assign(RegistrationCopy, RegistrationBuild);
@@ -3832,7 +3962,7 @@ _Helper = {
3832
3962
  });
3833
3963
  },
3834
3964
  adjustTargets: function (oMessage, oOperationMetadata, sParameterContextPath, sContextPath) {
3835
- var sAdditionalTargetsKey = _Helper.getAnnotationKey(oMessage, ".additionalTargets"), aTargets;
3965
+ var sAdditionalTargetsKey = ("additionalTargets" in oMessage) ? "additionalTargets" : _Helper.getAnnotationKey(oMessage, ".additionalTargets"), aTargets;
3836
3966
  aTargets = [oMessage.target].concat(oMessage[sAdditionalTargetsKey]).map(function (sTarget) {
3837
3967
  return sTarget && _Helper.getAdjustedTarget(sTarget, oOperationMetadata, sParameterContextPath, sContextPath);
3838
3968
  }).filter(function (sTarget) {
@@ -3882,7 +4012,7 @@ _Helper = {
3882
4012
  }
3883
4013
  return sPath;
3884
4014
  },
3885
- buildQuery: function (mParameters) {
4015
+ buildQuery: function (mParameters, bSortSystemQueryOptions) {
3886
4016
  var aKeys, aQuery;
3887
4017
  if (!mParameters) {
3888
4018
  return "";
@@ -3891,6 +4021,9 @@ _Helper = {
3891
4021
  if (aKeys.length === 0) {
3892
4022
  return "";
3893
4023
  }
4024
+ if (bSortSystemQueryOptions) {
4025
+ aKeys = aKeys.filter(sKey => sKey[0] !== "$").concat(aKeys.filter(sKey => sKey[0] === "$").sort());
4026
+ }
3894
4027
  aQuery = [];
3895
4028
  aKeys.forEach(function (sKey) {
3896
4029
  var vValue = mParameters[sKey];
@@ -3952,8 +4085,8 @@ _Helper = {
3952
4085
  return bAsString ? sStringified : JSON.parse(sStringified);
3953
4086
  },
3954
4087
  cloneNo$: function cloneNo$(vValue) {
3955
- return _Helper.clone(vValue, function (sKey, vValue) {
3956
- return sKey[0] === "$" ? undefined : vValue;
4088
+ return _Helper.clone(vValue, function (sKey, vValue0) {
4089
+ return sKey[0] === "$" ? undefined : vValue0;
3957
4090
  });
3958
4091
  },
3959
4092
  convertExpandSelectToPaths: function (mQueryOptions) {
@@ -3981,6 +4114,11 @@ _Helper = {
3981
4114
  _Helper.setPrivateAnnotation(oTarget, sAnnotation, _Helper.getPrivateAnnotation(oSource, sAnnotation));
3982
4115
  }
3983
4116
  },
4117
+ copySelected: function (oSource, oTarget) {
4118
+ if (oSource["@$ui5.context.isSelected"]) {
4119
+ oTarget["@$ui5.context.isSelected"] = true;
4120
+ }
4121
+ },
3984
4122
  createError: function (jqXHR, sMessage, sRequestUrl, sResourcePath) {
3985
4123
  var sBody = jqXHR.responseText, sContentType = jqXHR.getResponseHeader("Content-Type"), sPreference, oResult = new Error(sMessage + ": " + jqXHR.status + " " + jqXHR.statusText), sRetryAfter = jqXHR.getResponseHeader("Retry-After"), iRetryAfter;
3986
4124
  oResult.status = jqXHR.status;
@@ -4154,6 +4292,18 @@ _Helper = {
4154
4292
  encodePair: function (sKey, sValue) {
4155
4293
  return _Helper.encode(sKey, true) + "=" + _Helper.encode(sValue, false);
4156
4294
  },
4295
+ extractMergeableQueryOptions: function (mQueryOptions) {
4296
+ var mExtractedQueryOptions = {};
4297
+ if (("$expand" in mQueryOptions)) {
4298
+ mExtractedQueryOptions.$expand = mQueryOptions.$expand;
4299
+ mQueryOptions.$expand = "~";
4300
+ }
4301
+ if (("$select" in mQueryOptions)) {
4302
+ mExtractedQueryOptions.$select = mQueryOptions.$select;
4303
+ mQueryOptions.$select = "~";
4304
+ }
4305
+ return mExtractedQueryOptions;
4306
+ },
4157
4307
  extractMessages: function (oError) {
4158
4308
  var aMessages = [];
4159
4309
  function addMessage(oMessage, iNumericSeverity, bTechnical) {
@@ -4199,18 +4349,6 @@ _Helper = {
4199
4349
  }
4200
4350
  return aMessages;
4201
4351
  },
4202
- extractMergeableQueryOptions: function (mQueryOptions) {
4203
- var mExtractedQueryOptions = {};
4204
- if (("$expand" in mQueryOptions)) {
4205
- mExtractedQueryOptions.$expand = mQueryOptions.$expand;
4206
- mQueryOptions.$expand = "~";
4207
- }
4208
- if (("$select" in mQueryOptions)) {
4209
- mExtractedQueryOptions.$select = mQueryOptions.$select;
4210
- mQueryOptions.$select = "~";
4211
- }
4212
- return mExtractedQueryOptions;
4213
- },
4214
4352
  fetchPropertyAndType: function (fnFetchMetadata, sMetaPath) {
4215
4353
  return fnFetchMetadata(sMetaPath).then(function (oProperty) {
4216
4354
  if (oProperty && oProperty.$kind === "NavigationProperty") {
@@ -4296,6 +4434,9 @@ _Helper = {
4296
4434
  sTarget = _Helper.buildPath(sContextPath, aSegments.join("/"));
4297
4435
  return sTarget;
4298
4436
  }
4437
+ if (!sParameterContextPath) {
4438
+ return sTarget;
4439
+ }
4299
4440
  bIsParameterName = oOperationMetadata.$Parameter.some(function (oParameter) {
4300
4441
  return sParameterName === oParameter.$Name;
4301
4442
  });
@@ -4386,6 +4527,13 @@ _Helper = {
4386
4527
  return _Helper.isMissingProperty(vEntityOrCollection, sPath);
4387
4528
  });
4388
4529
  },
4530
+ getPredicateIndex: function (sPath) {
4531
+ var iPredicateIndex = sPath ? sPath.indexOf("(", sPath.lastIndexOf("/")) : -1;
4532
+ if (iPredicateIndex < 0 || !sPath.endsWith(")")) {
4533
+ throw new Error("Not a list context path to an entity: " + sPath);
4534
+ }
4535
+ return iPredicateIndex;
4536
+ },
4389
4537
  getPredicates: function (aContexts) {
4390
4538
  var bMissingPredicate, aPredicates = aContexts.map(getPredicate);
4391
4539
  function getPredicate(oContext) {
@@ -4397,13 +4545,6 @@ _Helper = {
4397
4545
  }
4398
4546
  return bMissingPredicate ? null : aPredicates;
4399
4547
  },
4400
- getPredicateIndex: function (sPath) {
4401
- var iPredicateIndex = sPath ? sPath.indexOf("(", sPath.lastIndexOf("/")) : -1;
4402
- if (iPredicateIndex < 0 || !sPath.endsWith(")")) {
4403
- throw new Error("Not a list context path to an entity: " + sPath);
4404
- }
4405
- return iPredicateIndex;
4406
- },
4407
4548
  getPrivateAnnotation: function (oObject, sAnnotation, vDefault) {
4408
4549
  const vResult = oObject["@$ui5._"]?.[sAnnotation];
4409
4550
  return vResult === undefined ? vDefault : vResult;
@@ -4479,6 +4620,13 @@ _Helper = {
4479
4620
  }
4480
4621
  });
4481
4622
  },
4623
+ insert: function (aElements, iIndex, vElement) {
4624
+ if (iIndex >= aElements.length) {
4625
+ aElements[iIndex] = vElement;
4626
+ } else {
4627
+ aElements.splice(iIndex, 0, vElement);
4628
+ }
4629
+ },
4482
4630
  intersectQueryOptions: function (mCacheQueryOptions, aPaths, fnFetchMetadata, sRootMetaPath, sPrefix, bWithMessages) {
4483
4631
  var aExpands = [], mExpands = {}, sMessagesPath = bWithMessages && fnFetchMetadata(sRootMetaPath + "/@com.sap.vocabularies.Common.v1.Messages/$Path").getResult(), mResult, oRootMetaData, aSelects, mSelects = {};
4484
4632
  function filterStructural(bSkipFirstSegment, sMetaPath) {
@@ -4664,13 +4812,35 @@ _Helper = {
4664
4812
  throw new Error(sPath + ": Unsupported type: " + sType);
4665
4813
  }
4666
4814
  },
4815
+ parseRawHeaders: function (sRawHeaders) {
4816
+ return sRawHeaders.split("\r\n").slice(0, -1).reduce((mHeaders, sRawLine) => {
4817
+ const iColon = sRawLine.indexOf(": ");
4818
+ if (iColon < 0) {
4819
+ mHeaders[sRawLine] = "";
4820
+ } else {
4821
+ mHeaders[sRawLine.slice(0, iColon).toLowerCase()] = sRawLine.slice(iColon + 2);
4822
+ }
4823
+ return mHeaders;
4824
+ }, {});
4825
+ },
4667
4826
  publicClone: function (vValue, bRemoveClientAnnotations, bAsString) {
4668
- return _Helper.clone(vValue, function (sKey, vValue) {
4827
+ if (Array.isArray(vValue)) {
4828
+ vValue = vValue.slice();
4829
+ }
4830
+ return _Helper.clone(vValue, function (sKey, vValue0) {
4669
4831
  if (bRemoveClientAnnotations ? !sKey.startsWith("@$ui5.") : sKey !== "@$ui5._") {
4670
- return vValue;
4832
+ return vValue0;
4671
4833
  }
4672
4834
  }, bAsString);
4673
4835
  },
4836
+ registerChangeListener: function (oOwner, sPath, oListener) {
4837
+ if (oListener) {
4838
+ _Helper.addByPath(oOwner.mChangeListeners, sPath, oListener);
4839
+ oListener.setDeregisterChangeListener(function () {
4840
+ _Helper.removeByPath(oOwner.mChangeListeners, sPath, oListener);
4841
+ });
4842
+ }
4843
+ },
4674
4844
  removeByPath: function (mMap, sPath, oItem) {
4675
4845
  var aItems = mMap[sPath], iIndex;
4676
4846
  if (aItems) {
@@ -4797,8 +4967,10 @@ _Helper = {
4797
4967
  _Helper.setPrivateAnnotation(oTarget, "predicate", _Helper.getPrivateAnnotation(oSource, "predicate"));
4798
4968
  } else if (Array.isArray(vSourceProperty)) {
4799
4969
  oTarget[sProperty] = vSourceProperty;
4970
+ _Helper.fireChange(mChangeListeners, sPropertyPath, vSourceProperty);
4800
4971
  } else if (vSourceProperty && typeof vSourceProperty === "object") {
4801
- oTarget[sProperty] = _Helper.updateAll(mChangeListeners, sPropertyPath, vTargetProperty || ({}), vSourceProperty);
4972
+ vTargetProperty = oTarget[sProperty] = _Helper.updateAll(mChangeListeners, sPropertyPath, vTargetProperty || ({}), vSourceProperty);
4973
+ _Helper.fireChange(mChangeListeners, sPropertyPath, vTargetProperty);
4802
4974
  } else if (vTargetProperty !== vSourceProperty) {
4803
4975
  oTarget[sProperty] = vSourceProperty;
4804
4976
  if (vTargetProperty && typeof vTargetProperty === "object") {
@@ -4819,9 +4991,11 @@ _Helper = {
4819
4991
  if ((sProperty in oNewObject) || sProperty[0] === "#") {
4820
4992
  if (Array.isArray(vNewProperty)) {
4821
4993
  oOldObject[sProperty] = vNewProperty;
4994
+ _Helper.fireChange(mChangeListeners, sPropertyPath, vNewProperty);
4822
4995
  } else if (vNewProperty && typeof vNewProperty === "object") {
4823
4996
  if (vOldProperty) {
4824
4997
  _Helper.updateExisting(mChangeListeners, sPropertyPath, vOldProperty, vNewProperty);
4998
+ _Helper.fireChange(mChangeListeners, sPropertyPath, vOldProperty);
4825
4999
  } else {
4826
5000
  oOldObject[sProperty] = vNewProperty;
4827
5001
  _Helper.fireChanges(mChangeListeners, sPropertyPath, vNewProperty, false);
@@ -4940,9 +5114,11 @@ _Helper = {
4940
5114
  } else if (Array.isArray(vSourceProperty)) {
4941
5115
  if (!(vTargetProperty && vTargetProperty.$postBodyCollection)) {
4942
5116
  oTarget[sProperty] = vSourceProperty;
5117
+ _Helper.fireChange(mChangeListeners, sPropertyPath, vSourceProperty);
4943
5118
  }
4944
5119
  } else if (vSourceProperty && typeof vSourceProperty === "object" && !sProperty.includes("@")) {
4945
5120
  oTarget[sProperty] = update(sPropertyPath, vSelected, vTargetProperty || ({}), vSourceProperty);
5121
+ _Helper.fireChange(mChangeListeners, sPropertyPath, vSourceProperty);
4946
5122
  } else if (vTargetProperty !== vSourceProperty && !oTarget[sProperty + "@$ui5.updating"]) {
4947
5123
  oTarget[sProperty] = vSourceProperty;
4948
5124
  if (vTargetProperty && typeof vTargetProperty === "object") {
@@ -4974,11 +5150,6 @@ _Helper = {
4974
5150
  }
4975
5151
  }
4976
5152
  },
4977
- copySelected: function (oSource, oTarget) {
4978
- if (oSource["@$ui5.context.isSelected"] === true) {
4979
- oTarget["@$ui5.context.isSelected"] = true;
4980
- }
4981
- },
4982
5153
  wrapChildQueryOptions: function (sBaseMetaPath, sChildMetaPath, mChildQueryOptions, fnFetchMetadata) {
4983
5154
  var sExpandSelectPath = "", aMetaPathSegments = sChildMetaPath.split("/"), oProperty, sPropertyMetaPath = sBaseMetaPath, mQueryOptions = {}, mQueryOptionsForPathPrefix = mQueryOptions, i;
4984
5155
  if (sChildMetaPath === "") {
@@ -6040,6 +6211,20 @@ _V2MetadataConverter.prototype.processAssociationSetEnd = function (oElement) {
6040
6211
  roleName: oElement.getAttribute("Role")
6041
6212
  });
6042
6213
  };
6214
+ _V2MetadataConverter.prototype.processBoundOperations = function () {
6215
+ var that = this;
6216
+ this.aBoundOperations.forEach(function (oOperation) {
6217
+ var oEntityType = that.result[oOperation.$Parameter[0].$Type];
6218
+ oEntityType.$Key.forEach(function (sKeyName) {
6219
+ oOperation.$Parameter.some(function (oParameter, i) {
6220
+ if (oParameter.$Name === sKeyName) {
6221
+ oOperation.$Parameter.splice(i, 1);
6222
+ return true;
6223
+ }
6224
+ });
6225
+ });
6226
+ });
6227
+ };
6043
6228
  _V2MetadataConverter.prototype.processComplexType = function (oElement) {
6044
6229
  this.processType(oElement, {
6045
6230
  $kind: "ComplexType"
@@ -6364,20 +6549,6 @@ _V2MetadataConverter.prototype.processTypeProperty = function (oElement) {
6364
6549
  pushPropertyPath("@Org.OData.Capabilities.V1.SortRestrictions", "NonSortableProperties", "sortable");
6365
6550
  }
6366
6551
  };
6367
- _V2MetadataConverter.prototype.processBoundOperations = function () {
6368
- var that = this;
6369
- this.aBoundOperations.forEach(function (oOperation) {
6370
- var oEntityType = that.result[oOperation.$Parameter[0].$Type];
6371
- oEntityType.$Key.forEach(function (sKeyName) {
6372
- oOperation.$Parameter.some(function (oParameter, i) {
6373
- if (oParameter.$Name === sKeyName) {
6374
- oOperation.$Parameter.splice(i, 1);
6375
- return true;
6376
- }
6377
- });
6378
- });
6379
- });
6380
- };
6381
6552
  _V2MetadataConverter.prototype.processUnitConversion = function () {
6382
6553
  var that = this;
6383
6554
  Object.keys(this.mProperty2Unit).forEach(function (sPropertyPath) {
@@ -6468,8 +6639,8 @@ _V2MetadataConverter.prototype.v2annotatable = function (sName, fnProcessV2Annot
6468
6639
  this.oAnnotatable = oAnnotatable;
6469
6640
  if (fnProcessV2Annotatable) {
6470
6641
  fnProcessV2Annotatable = fnProcessV2Annotatable.bind(this);
6471
- Object.keys(this.mSapAnnotations).forEach(function (sName) {
6472
- fnProcessV2Annotatable(oAnnotatable, sName);
6642
+ Object.keys(this.mSapAnnotations).forEach(function (sName0) {
6643
+ fnProcessV2Annotatable(oAnnotatable, sName0);
6473
6644
  });
6474
6645
  }
6475
6646
  return oAnnotatable;
@@ -0,0 +1,21 @@
1
+ import { AbapTarget } from "@sap-ux/system-access";
2
+ export interface IConfiguration {
3
+ appHostId?: string;
4
+ appId?: string;
5
+ appName?: string;
6
+ appVersion?: string;
7
+ spaceGuid?: string;
8
+ orgGuid?: string;
9
+ sapCloudService?: string;
10
+ destination?: string;
11
+ type?: "cf" | "abap";
12
+ languages?: any[] | undefined;
13
+ enableAnnotationCache?: boolean;
14
+ enableBetaFeatures?: boolean;
15
+ writeTempFiles?: any;
16
+ connections?: (AbapTarget & IAbapTargetMeta)[];
17
+ }
18
+ export interface IAbapTargetMeta {
19
+ name?: string;
20
+ ignoreCertErrors?: boolean;
21
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=configuration.js.map
@@ -1,20 +1,5 @@
1
+ import { IConfiguration } from "./configuration.js";
1
2
  import Language from "./language.js";
2
- export interface IConfiguration {
3
- writeTempFiles?: any;
4
- appHostId?: string;
5
- appId?: string;
6
- appName?: string;
7
- appVersion?: string;
8
- spaceGuid?: string;
9
- orgGuid?: string;
10
- sapCloudService?: string;
11
- destination?: string;
12
- credentials?: IAuth;
13
- type?: "cf" | "abap";
14
- languages?: any[] | undefined;
15
- enableAnnotationCache?: boolean;
16
- enableBetaFeatures?: boolean;
17
- }
18
3
  export interface IProjectOptions {
19
4
  configuration: IConfiguration;
20
5
  projectNamespace: string;
@@ -117,3 +102,4 @@ export interface IJsonPromisePerLanguage {
117
102
  language: Language;
118
103
  json: Promise<any>;
119
104
  }
105
+ export { IConfiguration };
@@ -1,5 +1,5 @@
1
- import { validateObject } from "../util/commonUtil.js";
2
1
  import Language from "../model/language.js";
2
+ import { validateObject } from "../util/commonUtil.js";
3
3
  export default class AbapProcessor {
4
4
  abapRepoManager;
5
5
  configuration;
@@ -15,7 +15,9 @@ export default class AbapProcessor {
15
15
  return this.cacheManager.getFiles(() => this.abapRepoManager.getMetadata(baseAppId), () => this.abapRepoManager.downloadBaseAppFiles());
16
16
  }
17
17
  validateConfiguration() {
18
- validateObject(this.configuration, ["destination", "appName"], "should be specified in ui5.yaml configuration");
18
+ // validate general app config
19
+ const properties = ["appName"];
20
+ validateObject(this.configuration, properties, "should be specified in ui5.yaml configuration");
19
21
  }
20
22
  async updateLandscapeSpecificContent(renamedBaseAppManifest, baseAppFiles) {
21
23
  const files = await this.annotationManager.process(renamedBaseAppManifest, (Language.create(this.configuration.languages)));
@@ -0,0 +1,9 @@
1
+ import type { AbapServiceProvider } from "@sap-ux/axios-extension";
2
+ import { IConfiguration } from "../model/types.js";
3
+ export default class AbapProvider {
4
+ private provider;
5
+ get({ connections, destination }: IConfiguration): Promise<AbapServiceProvider>;
6
+ private static validateAndGetTargetConfiguration;
7
+ private static validateConnectionConfiguration;
8
+ private createProvider;
9
+ }
@@ -0,0 +1,69 @@
1
+ import { createAbapServiceProvider } from "@sap-ux/system-access";
2
+ import BtpUtils from "@sap-ux/btp-utils";
3
+ import { getLogger } from "@ui5/logger";
4
+ import { validateObject } from "../util/commonUtil.js";
5
+ const log = getLogger("@ui5/task-adaptation::AbapProvider");
6
+ export default class AbapProvider {
7
+ provider = null;
8
+ async get({ connections, destination }) {
9
+ if (!this.provider) {
10
+ AbapProvider.validateConnectionConfiguration(connections, destination);
11
+ // we try to detect is it either destination for BAS or url for IDE
12
+ let targetConfiguration = AbapProvider.validateAndGetTargetConfiguration(connections);
13
+ if (targetConfiguration) {
14
+ this.provider = await this.createProvider(targetConfiguration);
15
+ }
16
+ else if (destination) {
17
+ // still if no suitable connections found, we assume that it's
18
+ // old config with destination
19
+ this.provider = await this.createProvider({ destination });
20
+ }
21
+ else {
22
+ // if no suitible configs found - throw error
23
+ const environment = BtpUtils.isAppStudio() ? "SAP Business Application Studio" : "local IDE";
24
+ throw new Error(`ABAP connection configuration for ${environment} is not provided`);
25
+ }
26
+ }
27
+ return this.provider;
28
+ }
29
+ static validateAndGetTargetConfiguration(connections) {
30
+ // we're trying to detect is it destination for BAS or url for IDE
31
+ const abapTargetProperties = BtpUtils.isAppStudio() ? ["destination"] : ["url"];
32
+ if (connections) {
33
+ for (const connection of connections) {
34
+ try {
35
+ validateObject(connection, abapTargetProperties, "should be specified in ui5.yaml configuration/target");
36
+ }
37
+ catch (error) {
38
+ continue;
39
+ }
40
+ return connection;
41
+ }
42
+ }
43
+ }
44
+ static validateConnectionConfiguration(connections, destination) {
45
+ // then abap connection config either old destination propery, or new
46
+ // connections/destination for BAS or connections/url for IDE
47
+ if (!connections && !destination) {
48
+ throw new Error("ABAP connections should be specified in ui5.yaml configuration");
49
+ }
50
+ if (destination) {
51
+ log.warn("Deprecated, use connections/destination configuration instead, see README.md");
52
+ }
53
+ // if connections configuration appears, we validate that it should be
54
+ // either connections/destination for BAS or connections/url for IDE
55
+ if (connections && !AbapProvider.validateAndGetTargetConfiguration(connections)) {
56
+ throw new Error("ABAP connection settings should be specified in ui5.yaml configuration");
57
+ }
58
+ // no connections and destination the same time to avoid ambiguity
59
+ if (connections && destination) {
60
+ throw new Error("Either destination or connections should be presented in configuration, not both");
61
+ }
62
+ }
63
+ createProvider(abapTarget) {
64
+ // createAbapServiceProvider requires log.debug, which is not implemented in ui5 logger.
65
+ log.debug = (message) => log.verbose(message);
66
+ return createAbapServiceProvider(abapTarget, { ignoreCertErrors: abapTarget.ignoreCertErrors }, true, log);
67
+ }
68
+ }
69
+ //# sourceMappingURL=abapProvider.js.map
@@ -1,13 +1,11 @@
1
1
  import { IConfiguration, IMetadata } from "../model/types.js";
2
+ import AbapProvider from "./abapProvider.js";
2
3
  export default class AbapRepoManager {
3
- private auth?;
4
4
  private configuration;
5
- constructor(configuration: IConfiguration);
5
+ private abapProvider;
6
+ constructor(configuration: IConfiguration, abapProvider?: AbapProvider);
6
7
  getAnnotationMetadata(uri: string): Promise<IMetadata>;
7
- downloadAnnotationFile(uri: string): Promise<Map<string, string>>;
8
- getMetadata(baseAppId: string): Promise<IMetadata>;
8
+ downloadAnnotationFile(uri: string): Promise<Map<string, any>>;
9
+ getMetadata(id: string): Promise<IMetadata>;
9
10
  downloadBaseAppFiles(): Promise<Map<string, string>>;
10
- private getMetadataRequest;
11
- private downloadBaseAppFilesRequest;
12
- private getAuth;
13
11
  }
@@ -1,4 +1,4 @@
1
- import RequestUtil from "../util/requestUtil.js";
1
+ import AbapProvider from "./abapProvider.js";
2
2
  import { getLogger } from "@ui5/logger";
3
3
  import { unzipZipEntries } from "../util/zipUtil.js";
4
4
  const log = getLogger("@ui5/task-adaptation::AbapRepoManager");
@@ -14,69 +14,58 @@ const REQUEST_OPTIONS_JSON = {
14
14
  }
15
15
  };
16
16
  export default class AbapRepoManager {
17
- auth;
18
17
  configuration;
19
- constructor(configuration) {
18
+ abapProvider;
19
+ constructor(configuration, abapProvider) {
20
20
  this.configuration = configuration;
21
+ this.abapProvider = abapProvider ? abapProvider : new AbapProvider();
21
22
  }
22
23
  async getAnnotationMetadata(uri) {
23
- const header = await RequestUtil.retryWithAuth(() => RequestUtil.head(uri), () => RequestUtil.head(uri, this.getAuth()));
24
- return { changedOn: header.modified };
24
+ const provider = await this.abapProvider.get(this.configuration);
25
+ const response = await provider.head(uri);
26
+ return { changedOn: response.data.modified };
25
27
  }
26
28
  async downloadAnnotationFile(uri) {
27
- const annotationUri = `https://${this.configuration.destination}.dest${uri}`;
28
- const annotation = await RequestUtil.retryWithAuth(() => RequestUtil.get(annotationUri, REQUEST_OPTIONS_XML), () => RequestUtil.get(annotationUri, REQUEST_OPTIONS_XML, this.getAuth()));
29
- return new Map([["annotation.xml", annotation]]);
29
+ const provider = await this.abapProvider.get(this.configuration);
30
+ const response = await provider.get(uri, {
31
+ headers: REQUEST_OPTIONS_XML.headers
32
+ });
33
+ return new Map([["annotation.xml", response.data]]);
30
34
  }
31
- getMetadata(baseAppId) {
32
- return RequestUtil.retryWithAuth(() => this.getMetadataRequest(baseAppId), () => this.getMetadataRequest(baseAppId, this.getAuth()));
33
- }
34
- downloadBaseAppFiles() {
35
- return RequestUtil.retryWithAuth(() => this.downloadBaseAppFilesRequest(), () => this.downloadBaseAppFilesRequest(this.getAuth()));
36
- }
37
- async getMetadataRequest(id, auth) {
38
- let uri = `https://${this.configuration.destination}.dest/sap/bc/ui2/app_index/ui5_app_info_json?id=${id}`;
39
- const data = await RequestUtil.get(uri, REQUEST_OPTIONS_JSON, auth);
40
- if (data && data[id]) {
41
- return {
42
- changedOn: data[id].url,
43
- id
44
- };
35
+ async getMetadata(id) {
36
+ const provider = await this.abapProvider.get(this.configuration);
37
+ const appIndex = provider.getAppIndex();
38
+ const response = await appIndex.get("/ui5_app_info_json", {
39
+ params: { id },
40
+ headers: REQUEST_OPTIONS_JSON.headers
41
+ });
42
+ const data = JSON.parse(response.data);
43
+ if (!data || !data[id]) {
44
+ log.warn(`UI5AppInfoJson request doesn't contain cache buster token for sap.app/id '${id}'. Fallback to download.`);
45
45
  }
46
- log.warn(`UI5AppInfoJson request doesn't contain cache buster token for sap.app/id '${id}'. Fallback to download.`);
46
+ return {
47
+ changedOn: data && data[id] && data[id].url,
48
+ id
49
+ };
47
50
  }
48
- async downloadBaseAppFilesRequest(auth) {
51
+ async downloadBaseAppFiles() {
49
52
  const { destination, appName } = this.configuration;
50
53
  const encodedAppName = encodeURIComponent(appName);
51
- const uri = `https://${destination}.dest/sap/opu/odata/UI5/ABAP_REPOSITORY_SRV/Repositories('${encodedAppName}')?DownloadFiles=RUNTIME&CodePage=UTF8`;
52
- const data = await RequestUtil.get(uri, {}, auth);
53
- if (data?.d?.ZipArchive.length > 0) {
54
+ const provider = await this.abapProvider.get(this.configuration);
55
+ const ui5Repo = provider.getUi5AbapRepository();
56
+ const response = await ui5Repo.get(`/Repositories('${encodedAppName}')`, {
57
+ params: {
58
+ DownloadFiles: "RUNTIME",
59
+ CodePage: "UTF8",
60
+ "$format": "json"
61
+ }
62
+ });
63
+ const data = JSON.parse(response.data);
64
+ if (data.d?.ZipArchive.length > 0) {
54
65
  const buffer = Buffer.from(data.d.ZipArchive, "base64");
55
66
  return unzipZipEntries(buffer);
56
67
  }
57
- throw new Error(`App '${appName}' from destination '${destination}' doesn't contain files`);
58
- }
59
- getAuth() {
60
- if (!this.auth) {
61
- if (this.configuration?.credentials) {
62
- let { username, password } = this.configuration?.credentials;
63
- if (username && password) {
64
- const ENV_PREFIX = "env:";
65
- username = username.substring(ENV_PREFIX.length);
66
- password = password.substring(ENV_PREFIX.length);
67
- if (process.env[username] && process.env[password]) {
68
- this.auth = {
69
- username: process.env[username],
70
- password: process.env[password]
71
- };
72
- }
73
- }
74
- }
75
- }
76
- if (!this.auth) {
77
- throw new Error("Please provide ABAP System credentials in .env file of the project: https://help.sap.com/docs/SAP_FIORI_tools/17d50220bcd848aa854c9c182d65b699/1c859274b511435ab6bd45f70e7f9af2.html.");
78
- }
79
- return this.auth;
68
+ throw new Error(`App '${appName}' from '${destination}' doesn't contain files`);
80
69
  }
81
70
  }
82
71
  //# sourceMappingURL=abapRepoManager.js.map
@@ -1,8 +1,6 @@
1
- import { IAuth } from "../model/types.js";
2
1
  export default class RequestUtil {
3
- static head(url: string, auth?: IAuth): Promise<any>;
4
- static get(url: string, options?: any, auth?: IAuth): Promise<any>;
5
- static request(url: string, method: Function, auth?: IAuth, options?: any): Promise<any>;
2
+ static head(url: string): Promise<any>;
3
+ static get(url: string, options?: any): Promise<any>;
4
+ static request(url: string, method: Function, options?: any): Promise<any>;
6
5
  private static handleError;
7
- static retryWithAuth<T>(requestWithoutAuth: Function, requestWithAuth: Function): Promise<T>;
8
6
  }
@@ -1,17 +1,15 @@
1
1
  import axios from "axios";
2
- import NoAuthorizationProvidedError from "../model/noAuthorizationProvidedError.js";
3
2
  import ServerError from "../model/serverError.js";
4
3
  export default class RequestUtil {
5
- static async head(url, auth) {
6
- return this.request(url, axios.head, auth);
4
+ static async head(url) {
5
+ return this.request(url, axios.head);
7
6
  }
8
- static async get(url, options, auth) {
9
- return this.request(url, axios.get, auth, options);
7
+ static async get(url, options) {
8
+ return this.request(url, axios.get, options);
10
9
  }
11
- static async request(url, method, auth, options) {
10
+ static async request(url, method, options) {
12
11
  try {
13
- return await method(url, { auth, ...options })
14
- .then((response) => response.data);
12
+ return await method(url, options);
15
13
  }
16
14
  catch (error) {
17
15
  this.handleError(error, url);
@@ -20,10 +18,7 @@ export default class RequestUtil {
20
18
  static handleError(error, uri) {
21
19
  if (error.response) {
22
20
  // HTTP Status Code > 2xx
23
- if (error.response.status === 401) {
24
- throw new NoAuthorizationProvidedError(uri);
25
- }
26
- else if (error.response.status >= 500) {
21
+ if (error.response.status >= 500) {
27
22
  throw new ServerError(uri, error);
28
23
  }
29
24
  else {
@@ -37,18 +32,5 @@ export default class RequestUtil {
37
32
  throw new Error(`Error sending request to '${uri}': ${error.code}`);
38
33
  }
39
34
  }
40
- static async retryWithAuth(requestWithoutAuth, requestWithAuth) {
41
- try {
42
- return await requestWithoutAuth();
43
- }
44
- catch (error) {
45
- if (error instanceof NoAuthorizationProvidedError) {
46
- return await requestWithAuth();
47
- }
48
- else {
49
- throw error;
50
- }
51
- }
52
- }
53
35
  }
54
36
  //# sourceMappingURL=requestUtil.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/task-adaptation",
3
- "version": "1.3.2",
3
+ "version": "1.3.3",
4
4
  "description": "Custom task for ui5-builder which allows building UI5 Flexibility Adaptation Projects for SAP BTP, Cloud Foundry environment",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -9,7 +9,7 @@
9
9
  "dev": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx --loader=esmock 'test/**/*.spec.ts'",
10
10
  "perf": "UI5_LOG_LVL=error mocha --no-timeouts --no-warnings --import=tsx --loader=esmock 'test/**/*.perf.ts'",
11
11
  "coverage": "npx c8 npm run dev",
12
- "preversion": "npm run build",
12
+ "preversion": "npm test",
13
13
  "version": "git-chglog --next-tag v$npm_package_version -o CHANGELOG.md && git add CHANGELOG.md",
14
14
  "prepublishOnly": "git push --follow-tags",
15
15
  "release-note": "git-chglog -c .chglog/release-config.yml v$npm_package_version",
@@ -33,6 +33,10 @@
33
33
  "author": "SAP SE",
34
34
  "license": "Apache-2.0",
35
35
  "dependencies": {
36
+ "@sap-ux/axios-extension": "^1.13.1",
37
+ "@sap-ux/btp-utils": "^0.14.4",
38
+ "@sap-ux/store": "^0.6.0",
39
+ "@sap-ux/system-access": "^0.4.2",
36
40
  "@sap/cf-tools": "^3.2.0",
37
41
  "@ui5/fs": "^3.0.5",
38
42
  "@ui5/logger": "^3.0.0",
@@ -104,7 +108,8 @@
104
108
  "scripts/git/octokitUtil.ts",
105
109
  "*/**/*.d.ts",
106
110
  "src/annotations/comparator/diffCase.ts",
107
- "src/annotations/transformers/transformer.ts"
111
+ "src/annotations/transformers/transformer.ts",
112
+ "src/model/configuration.ts"
108
113
  ],
109
114
  "check-coverage": true,
110
115
  "statements": 85,
@@ -1,3 +0,0 @@
1
- export default class NoAuthorizationProvidedError extends Error {
2
- constructor(uri: string);
3
- }
@@ -1,6 +0,0 @@
1
- export default class NoAuthorizationProvidedError extends Error {
2
- constructor(uri) {
3
- super(`Request requires authorization: '${uri}'`);
4
- }
5
- }
6
- //# sourceMappingURL=noAuthorizationProvidedError.js.map