@ui5/task-adaptation 1.0.8 → 1.0.11
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 +13 -1
- package/README.md +27 -1
- package/dist/baseAppManager.d.ts +4 -3
- package/dist/baseAppManager.js +32 -18
- package/dist/bundle.js +904 -58
- package/dist/index.js +2 -21
- package/dist/model/types.d.ts +2 -1
- package/dist/updateCache.d.ts +1 -1
- package/dist/updateCache.js +6 -4
- package/dist/util/requestUtil.js +5 -10
- package/package.json +32 -26
- package/scripts/rollup/bundleDefinition.js +11 -0
- package/scripts/rollup/overrides/sap/ui/fl/Change.js +72 -0
- package/scripts/rollup/overrides/sap/ui/thirdparty/URI.js +16 -0
- package/scripts/rollup/project/package.json +3 -0
- package/scripts/rollup/project/ui5.yaml +13 -0
- package/scripts/rollup/project/webapp/manifest.json +5 -0
- package/scripts/rollup/ui5Resolve.ts +134 -0
- package/scripts/rollup.ts +111 -0
package/dist/bundle.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
//1.99.0
|
|
2
|
+
var window = {};
|
|
3
|
+
'use strict';
|
|
2
4
|
|
|
3
5
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
6
|
|
|
@@ -34,6 +36,9 @@ Change.prototype.getChangeType = function () {
|
|
|
34
36
|
return this._oDefinition.changeType;
|
|
35
37
|
}
|
|
36
38
|
};
|
|
39
|
+
Change.prototype.getLayer = function () {
|
|
40
|
+
return this._oDefinition.layer;
|
|
41
|
+
};
|
|
37
42
|
Change.prototype.getContent = function () {
|
|
38
43
|
return this._oDefinition.content;
|
|
39
44
|
};
|
|
@@ -52,7 +57,7 @@ var Applier = {
|
|
|
52
57
|
applyChanges: function (oUpdatedManifest, aAppDescriptorChanges, mStrategy) {
|
|
53
58
|
return mStrategy.registry().then(function (Registry) {
|
|
54
59
|
var aChangeHandlerPromises = aAppDescriptorChanges.map(function (oChange) {
|
|
55
|
-
return Registry[oChange.getChangeType()];
|
|
60
|
+
return Registry[oChange.getChangeType()] && Registry[oChange.getChangeType()]();
|
|
56
61
|
});
|
|
57
62
|
return Promise.all(aChangeHandlerPromises);
|
|
58
63
|
}).then(function (aChangeHandlers) {
|
|
@@ -154,13 +159,13 @@ function setPropValueByPath(oEntityProp, oRoot) {
|
|
|
154
159
|
}
|
|
155
160
|
ObjectPath.set(aPath, oEntityProp.propertyValue, oRoot);
|
|
156
161
|
}
|
|
157
|
-
function changePropertyValueByPath (
|
|
158
|
-
if (Array.isArray(
|
|
159
|
-
|
|
162
|
+
function changePropertyValueByPath (vChanges, oRootPath) {
|
|
163
|
+
if (Array.isArray(vChanges)) {
|
|
164
|
+
vChanges.forEach(function (oEntityProp) {
|
|
160
165
|
setPropValueByPath(oEntityProp, oRootPath);
|
|
161
166
|
});
|
|
162
167
|
} else {
|
|
163
|
-
setPropValueByPath(
|
|
168
|
+
setPropValueByPath(vChanges, oRootPath);
|
|
164
169
|
}
|
|
165
170
|
}
|
|
166
171
|
|
|
@@ -168,50 +173,33 @@ var fnValues = function values(mObject) {
|
|
|
168
173
|
if (typeof mObject === "undefined" || mObject === null || mObject !== mObject) {
|
|
169
174
|
return [];
|
|
170
175
|
}
|
|
171
|
-
|
|
172
|
-
return Object.values(mObject);
|
|
173
|
-
}
|
|
174
|
-
if (typeof mObject === "string") {
|
|
175
|
-
return mObject.split("");
|
|
176
|
-
}
|
|
177
|
-
if (typeof mObject !== "object") {
|
|
178
|
-
return [];
|
|
179
|
-
}
|
|
180
|
-
return Object.keys(mObject).map(function (vValue) {
|
|
181
|
-
return mObject[vValue];
|
|
182
|
-
});
|
|
176
|
+
return Object.values(mObject);
|
|
183
177
|
};
|
|
184
178
|
|
|
185
|
-
function equals(a, b) {
|
|
186
|
-
return a === b || a !== a && b !== b;
|
|
187
|
-
}
|
|
188
179
|
var fnIncludes = function (vCollection, vValue, iFromIndex) {
|
|
189
180
|
if (typeof iFromIndex !== "number") {
|
|
190
181
|
iFromIndex = 0;
|
|
191
182
|
}
|
|
192
|
-
if (Array.isArray(vCollection)) {
|
|
193
|
-
if (
|
|
194
|
-
|
|
183
|
+
if (Array.isArray(vCollection) || typeof vCollection === "string") {
|
|
184
|
+
if (iFromIndex < 0) {
|
|
185
|
+
iFromIndex = vCollection.length + iFromIndex < 0 ? 0 : vCollection.length + iFromIndex;
|
|
195
186
|
}
|
|
196
|
-
|
|
197
|
-
iFromIndex = iFromIndex < 0 ? 0 : iFromIndex;
|
|
198
|
-
for (var i = iFromIndex; i < vCollection.length; i++) {
|
|
199
|
-
if (equals(vCollection[i], vValue)) {
|
|
200
|
-
return true;
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
return false;
|
|
204
|
-
} else if (typeof vCollection === "string") {
|
|
205
|
-
iFromIndex = iFromIndex < 0 ? vCollection.length + iFromIndex : iFromIndex;
|
|
206
|
-
if (typeof vCollection.includes === "function") {
|
|
207
|
-
return vCollection.includes(vValue, iFromIndex);
|
|
208
|
-
}
|
|
209
|
-
return vCollection.indexOf(vValue, iFromIndex) !== -1;
|
|
187
|
+
return vCollection.includes(vValue, iFromIndex);
|
|
210
188
|
} else {
|
|
211
189
|
return fnIncludes(fnValues(vCollection), vValue, iFromIndex);
|
|
212
190
|
}
|
|
213
191
|
};
|
|
214
192
|
|
|
193
|
+
var Layer = {
|
|
194
|
+
USER: "USER",
|
|
195
|
+
PUBLIC: "PUBLIC",
|
|
196
|
+
CUSTOMER: "CUSTOMER",
|
|
197
|
+
CUSTOMER_BASE: "CUSTOMER_BASE",
|
|
198
|
+
PARTNER: "PARTNER",
|
|
199
|
+
VENDOR: "VENDOR",
|
|
200
|
+
BASE: "BASE"
|
|
201
|
+
};
|
|
202
|
+
|
|
215
203
|
function checkChange(oEntityPropertyChange, aSupportedProperties, aSupportedOperations) {
|
|
216
204
|
if (Array.isArray(oEntityPropertyChange)) {
|
|
217
205
|
oEntityPropertyChange.forEach(function (change) {
|
|
@@ -238,7 +226,7 @@ function formatEntityCheck(oChangeEntity, aSupportedProperties, aSupportedOperat
|
|
|
238
226
|
throw new Error("Operation " + oChangeEntity.operation + " is not supported. The supported 'operation' is " + aSupportedOperations.join("|"));
|
|
239
227
|
}
|
|
240
228
|
}
|
|
241
|
-
function
|
|
229
|
+
function checkEntityPropertyChange(oChange, aSupportedProperties, aSupportedOperations) {
|
|
242
230
|
var id = Object.keys(oChange).filter(function (key) {
|
|
243
231
|
return key.endsWith("Id");
|
|
244
232
|
}).shift();
|
|
@@ -250,6 +238,39 @@ function checkChangesConsistency (oChange, aSupportedProperties, aSupportedOpera
|
|
|
250
238
|
}
|
|
251
239
|
checkChange(oChange.entityPropertyChange, aSupportedProperties, aSupportedOperations);
|
|
252
240
|
}
|
|
241
|
+
var layer_prefixes = {};
|
|
242
|
+
layer_prefixes[Layer.CUSTOMER] = "customer.";
|
|
243
|
+
layer_prefixes[Layer.CUSTOMER_BASE] = "customer.";
|
|
244
|
+
layer_prefixes[Layer.PARTNER] = "partner.";
|
|
245
|
+
layer_prefixes[Layer.VENDOR] = null;
|
|
246
|
+
function checkIdNamespaceCompliance(sId, oChange) {
|
|
247
|
+
var sLayer = oChange.getLayer();
|
|
248
|
+
if (!sLayer) {
|
|
249
|
+
throw new Error("Mandatory layer parameter is not provided.");
|
|
250
|
+
}
|
|
251
|
+
var sPrefix = getNamespacePrefixForLayer(sLayer);
|
|
252
|
+
if (sPrefix === null) {
|
|
253
|
+
Object.keys(layer_prefixes).forEach(function (sKey) {
|
|
254
|
+
if (layer_prefixes[sKey] && sId.startsWith(layer_prefixes[sKey])) {
|
|
255
|
+
throw new Error("Id " + sId + " must not start with reserved " + layer_prefixes[sKey]);
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
} else if (!sId.startsWith(sPrefix)) {
|
|
259
|
+
throw new Error("Id " + sId + " must start with " + sPrefix);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function getNamespacePrefixForLayer(sLayer) {
|
|
263
|
+
var sPrefix = layer_prefixes[sLayer];
|
|
264
|
+
if (sPrefix === undefined) {
|
|
265
|
+
throw new Error("Layer " + sLayer + " not supported.");
|
|
266
|
+
}
|
|
267
|
+
return sPrefix;
|
|
268
|
+
}
|
|
269
|
+
var DescriptorChangeCheck = {
|
|
270
|
+
checkEntityPropertyChange: checkEntityPropertyChange,
|
|
271
|
+
checkIdNamespaceCompliance: checkIdNamespaceCompliance,
|
|
272
|
+
getNamespacePrefixForLayer: getNamespacePrefixForLayer
|
|
273
|
+
};
|
|
253
274
|
|
|
254
275
|
var SUPPORTED_OPERATIONS$1 = ["UPDATE", "UPSERT"];
|
|
255
276
|
var SUPPORTED_PROPERTIES$1 = ["uri", "settings/maxAge"];
|
|
@@ -257,7 +278,7 @@ var ChangeDataSouce = {
|
|
|
257
278
|
applyChange: function (oManifest, oChange) {
|
|
258
279
|
var oDataSources = oManifest["sap.app"].dataSources;
|
|
259
280
|
var oChangeContent = oChange.getContent();
|
|
260
|
-
|
|
281
|
+
DescriptorChangeCheck.checkEntityPropertyChange(oChangeContent, SUPPORTED_PROPERTIES$1, SUPPORTED_OPERATIONS$1);
|
|
261
282
|
if (oDataSources) {
|
|
262
283
|
var oDataSource = oDataSources[oChangeContent.dataSourceId];
|
|
263
284
|
if (oDataSource) {
|
|
@@ -536,12 +557,13 @@ function checkingAnnotationsInsertPosition(sChangeAnnotationsInsertPosition) {
|
|
|
536
557
|
throw new Error("The defined insert position '" + sChangeAnnotationsInsertPosition + "' is not supported. The supported insert positions are: " + SUPPORTED_INSERT_POSITION.join("|"));
|
|
537
558
|
}
|
|
538
559
|
}
|
|
539
|
-
function checkingAnnotationDataSource(oChangeDataSource, aChangeAnnotations) {
|
|
560
|
+
function checkingAnnotationDataSource(oChangeDataSource, aChangeAnnotations, oChange) {
|
|
540
561
|
if (oChangeDataSource) {
|
|
541
562
|
if (Object.keys(oChangeDataSource).length === 0) {
|
|
542
563
|
throw new Error("The 'dataSource' object is empty");
|
|
543
564
|
}
|
|
544
565
|
Object.keys(oChangeDataSource).forEach(function (sAnnotation) {
|
|
566
|
+
DescriptorChangeCheck.checkIdNamespaceCompliance(sAnnotation, oChange);
|
|
545
567
|
if (!isAnnotationTypeOfOdataAnnotation(oChangeDataSource, sAnnotation)) {
|
|
546
568
|
throw new Error("The dataSource annotation '" + sAnnotation + "' is type of '" + oChangeDataSource[sAnnotation].type + "'. Only dataSource annotations of type 'ODataAnnotation' is supported");
|
|
547
569
|
}
|
|
@@ -593,7 +615,7 @@ var AddAnnotationsToOData = {
|
|
|
593
615
|
checkingDataSourceId(oManifest["sap.app"].dataSources, sChangeDataSourceId);
|
|
594
616
|
checkingAnnotationArray(aChangeAnnotations);
|
|
595
617
|
checkingAnnotationsInsertPosition(sChangeAnnotationsInsertPosition);
|
|
596
|
-
checkingAnnotationDataSource(oChangeDataSource, aChangeAnnotations);
|
|
618
|
+
checkingAnnotationDataSource(oChangeDataSource, aChangeAnnotations, oChange);
|
|
597
619
|
postChecks(oManifest["sap.app"]["dataSources"], oChangeDataSource, aChangeAnnotations);
|
|
598
620
|
merge(oManifest["sap.app"]["dataSources"], sChangeDataSourceId, aChangeAnnotations, sChangeAnnotationsInsertPosition, oChangeDataSource);
|
|
599
621
|
return oManifest;
|
|
@@ -601,12 +623,12 @@ var AddAnnotationsToOData = {
|
|
|
601
623
|
};
|
|
602
624
|
|
|
603
625
|
var SUPPORTED_OPERATIONS = ["UPDATE", "UPSERT"];
|
|
604
|
-
var SUPPORTED_PROPERTIES = ["title", "
|
|
626
|
+
var SUPPORTED_PROPERTIES = ["title", "subTitle", "icon"];
|
|
605
627
|
var ChangeInbound = {
|
|
606
628
|
applyChange: function (oManifest, oChange) {
|
|
607
629
|
var oCrossNavigation = oManifest["sap.app"].crossNavigation;
|
|
608
630
|
var oChangeContent = oChange.getContent();
|
|
609
|
-
|
|
631
|
+
DescriptorChangeCheck.checkEntityPropertyChange(oChangeContent, SUPPORTED_PROPERTIES, SUPPORTED_OPERATIONS);
|
|
610
632
|
if (oCrossNavigation && oCrossNavigation.inbounds) {
|
|
611
633
|
var oInbound = oCrossNavigation.inbounds[oChangeContent.inboundId];
|
|
612
634
|
if (oInbound) {
|
|
@@ -621,6 +643,19 @@ var ChangeInbound = {
|
|
|
621
643
|
}
|
|
622
644
|
};
|
|
623
645
|
|
|
646
|
+
var SetAbstract = {
|
|
647
|
+
applyChange: function (oManifest, oChange) {
|
|
648
|
+
if (!oChange.getContent().hasOwnProperty("abstract")) {
|
|
649
|
+
throw new Error("No abstract in change content provided");
|
|
650
|
+
}
|
|
651
|
+
if (oChange.getContent().abstract !== false) {
|
|
652
|
+
throw new Error("The current change value of property abstract is '" + oChange.getContent().abstract + "'. Only allowed value for property abstract is boolean 'false'");
|
|
653
|
+
}
|
|
654
|
+
ObjectPath.set(["sap.fiori", "abstract"], oChange.getContent().abstract, oManifest);
|
|
655
|
+
return oManifest;
|
|
656
|
+
}
|
|
657
|
+
};
|
|
658
|
+
|
|
624
659
|
function _mergeExistingLibrary(oManifestLib, oChangeLib) {
|
|
625
660
|
var oUpdatedLibrary = {};
|
|
626
661
|
if (oChangeLib.minVersion) {
|
|
@@ -704,24 +739,835 @@ var DeleteCard = {
|
|
|
704
739
|
}
|
|
705
740
|
};
|
|
706
741
|
|
|
742
|
+
var fnNow = !(typeof window != "undefined" && window.performance && performance.now && performance.timing) ? Date.now : (function () {
|
|
743
|
+
var iNavigationStart = performance.timing.navigationStart;
|
|
744
|
+
return function perfnow() {
|
|
745
|
+
return iNavigationStart + performance.now();
|
|
746
|
+
};
|
|
747
|
+
})();
|
|
748
|
+
|
|
749
|
+
var Log = {};
|
|
750
|
+
Log.Level = {
|
|
751
|
+
NONE: -1,
|
|
752
|
+
FATAL: 0,
|
|
753
|
+
ERROR: 1,
|
|
754
|
+
WARNING: 2,
|
|
755
|
+
INFO: 3,
|
|
756
|
+
DEBUG: 4,
|
|
757
|
+
TRACE: 5,
|
|
758
|
+
ALL: 5 + 1
|
|
759
|
+
};
|
|
760
|
+
var sDefaultComponent, aLog = [], mMaxLevel = {
|
|
761
|
+
"": Log.Level.ERROR
|
|
762
|
+
}, iLogEntriesLimit = 3000, oListener = null, bLogSupportInfo = false;
|
|
763
|
+
function pad0(i, w) {
|
|
764
|
+
return ("000" + String(i)).slice(-w);
|
|
765
|
+
}
|
|
766
|
+
function level(sComponent) {
|
|
767
|
+
return !sComponent || isNaN(mMaxLevel[sComponent]) ? mMaxLevel[""] : mMaxLevel[sComponent];
|
|
768
|
+
}
|
|
769
|
+
function discardLogEntries() {
|
|
770
|
+
var iLogLength = aLog.length;
|
|
771
|
+
if (iLogLength) {
|
|
772
|
+
var iEntriesToKeep = Math.min(iLogLength, Math.floor(iLogEntriesLimit * 0.7));
|
|
773
|
+
if (oListener) {
|
|
774
|
+
oListener.onDiscardLogEntries(aLog.slice(0, iLogLength - iEntriesToKeep));
|
|
775
|
+
}
|
|
776
|
+
if (iEntriesToKeep) {
|
|
777
|
+
aLog = aLog.slice(-iEntriesToKeep, iLogLength);
|
|
778
|
+
} else {
|
|
779
|
+
aLog = [];
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
function getLogEntryListenerInstance() {
|
|
784
|
+
if (!oListener) {
|
|
785
|
+
oListener = {
|
|
786
|
+
listeners: [],
|
|
787
|
+
onLogEntry: function (oLogEntry) {
|
|
788
|
+
for (var i = 0; i < oListener.listeners.length; i++) {
|
|
789
|
+
if (oListener.listeners[i].onLogEntry) {
|
|
790
|
+
oListener.listeners[i].onLogEntry(oLogEntry);
|
|
791
|
+
}
|
|
792
|
+
}
|
|
793
|
+
},
|
|
794
|
+
onDiscardLogEntries: function (aDiscardedLogEntries) {
|
|
795
|
+
for (var i = 0; i < oListener.listeners.length; i++) {
|
|
796
|
+
if (oListener.listeners[i].onDiscardLogEntries) {
|
|
797
|
+
oListener.listeners[i].onDiscardLogEntries(aDiscardedLogEntries);
|
|
798
|
+
}
|
|
799
|
+
}
|
|
800
|
+
},
|
|
801
|
+
attach: function (oLog, oLstnr) {
|
|
802
|
+
if (oLstnr) {
|
|
803
|
+
oListener.listeners.push(oLstnr);
|
|
804
|
+
if (oLstnr.onAttachToLog) {
|
|
805
|
+
oLstnr.onAttachToLog(oLog);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
},
|
|
809
|
+
detach: function (oLog, oLstnr) {
|
|
810
|
+
for (var i = 0; i < oListener.listeners.length; i++) {
|
|
811
|
+
if (oListener.listeners[i] === oLstnr) {
|
|
812
|
+
if (oLstnr.onDetachFromLog) {
|
|
813
|
+
oLstnr.onDetachFromLog(oLog);
|
|
814
|
+
}
|
|
815
|
+
oListener.listeners.splice(i, 1);
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
};
|
|
821
|
+
}
|
|
822
|
+
return oListener;
|
|
823
|
+
}
|
|
824
|
+
Log.fatal = function (sMessage, sDetails, sComponent, fnSupportInfo) {
|
|
825
|
+
log(Log.Level.FATAL, sMessage, sDetails, sComponent, fnSupportInfo);
|
|
826
|
+
};
|
|
827
|
+
Log.error = function (sMessage, sDetails, sComponent, fnSupportInfo) {
|
|
828
|
+
log(Log.Level.ERROR, sMessage, sDetails, sComponent, fnSupportInfo);
|
|
829
|
+
};
|
|
830
|
+
Log.warning = function (sMessage, sDetails, sComponent, fnSupportInfo) {
|
|
831
|
+
log(Log.Level.WARNING, sMessage, sDetails, sComponent, fnSupportInfo);
|
|
832
|
+
};
|
|
833
|
+
Log.info = function (sMessage, sDetails, sComponent, fnSupportInfo) {
|
|
834
|
+
log(Log.Level.INFO, sMessage, sDetails, sComponent, fnSupportInfo);
|
|
835
|
+
};
|
|
836
|
+
Log.debug = function (sMessage, sDetails, sComponent, fnSupportInfo) {
|
|
837
|
+
log(Log.Level.DEBUG, sMessage, sDetails, sComponent, fnSupportInfo);
|
|
838
|
+
};
|
|
839
|
+
Log.trace = function (sMessage, sDetails, sComponent, fnSupportInfo) {
|
|
840
|
+
log(Log.Level.TRACE, sMessage, sDetails, sComponent, fnSupportInfo);
|
|
841
|
+
};
|
|
842
|
+
Log.setLevel = function (iLogLevel, sComponent, _bDefault) {
|
|
843
|
+
sComponent = sComponent || sDefaultComponent || "";
|
|
844
|
+
if (!_bDefault || mMaxLevel[sComponent] == null) {
|
|
845
|
+
mMaxLevel[sComponent] = iLogLevel;
|
|
846
|
+
var sLogLevel;
|
|
847
|
+
Object.keys(Log.Level).forEach(function (sLevel) {
|
|
848
|
+
if (Log.Level[sLevel] === iLogLevel) {
|
|
849
|
+
sLogLevel = sLevel;
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
log(Log.Level.INFO, "Changing log level " + (sComponent ? "for '" + sComponent + "' " : "") + "to " + sLogLevel, "", "sap.base.log");
|
|
853
|
+
}
|
|
854
|
+
};
|
|
855
|
+
Log.getLevel = function (sComponent) {
|
|
856
|
+
return level(sComponent || sDefaultComponent);
|
|
857
|
+
};
|
|
858
|
+
Log.isLoggable = function (iLevel, sComponent) {
|
|
859
|
+
return (iLevel == null ? Log.Level.DEBUG : iLevel) <= level(sComponent || sDefaultComponent);
|
|
860
|
+
};
|
|
861
|
+
Log.logSupportInfo = function (bEnabled) {
|
|
862
|
+
bLogSupportInfo = bEnabled;
|
|
863
|
+
};
|
|
864
|
+
function log(iLevel, sMessage, sDetails, sComponent, fnSupportInfo) {
|
|
865
|
+
if (!fnSupportInfo && !sComponent && typeof sDetails === "function") {
|
|
866
|
+
fnSupportInfo = sDetails;
|
|
867
|
+
sDetails = "";
|
|
868
|
+
}
|
|
869
|
+
if (!fnSupportInfo && typeof sComponent === "function") {
|
|
870
|
+
fnSupportInfo = sComponent;
|
|
871
|
+
sComponent = "";
|
|
872
|
+
}
|
|
873
|
+
sComponent = sComponent || sDefaultComponent;
|
|
874
|
+
if (iLevel <= level(sComponent)) {
|
|
875
|
+
var fNow = fnNow(), oNow = new Date(fNow), iMicroSeconds = Math.floor((fNow - Math.floor(fNow)) * 1000), oLogEntry = {
|
|
876
|
+
time: pad0(oNow.getHours(), 2) + ":" + pad0(oNow.getMinutes(), 2) + ":" + pad0(oNow.getSeconds(), 2) + "." + pad0(oNow.getMilliseconds(), 3) + pad0(iMicroSeconds, 3),
|
|
877
|
+
date: pad0(oNow.getFullYear(), 4) + "-" + pad0(oNow.getMonth() + 1, 2) + "-" + pad0(oNow.getDate(), 2),
|
|
878
|
+
timestamp: fNow,
|
|
879
|
+
level: iLevel,
|
|
880
|
+
message: String(sMessage || ""),
|
|
881
|
+
details: String(sDetails || ""),
|
|
882
|
+
component: String(sComponent || "")
|
|
883
|
+
};
|
|
884
|
+
if (bLogSupportInfo && typeof fnSupportInfo === "function") {
|
|
885
|
+
oLogEntry.supportInfo = fnSupportInfo();
|
|
886
|
+
}
|
|
887
|
+
if (iLogEntriesLimit) {
|
|
888
|
+
if (aLog.length >= iLogEntriesLimit) {
|
|
889
|
+
discardLogEntries();
|
|
890
|
+
}
|
|
891
|
+
aLog.push(oLogEntry);
|
|
892
|
+
}
|
|
893
|
+
if (oListener) {
|
|
894
|
+
oListener.onLogEntry(oLogEntry);
|
|
895
|
+
}
|
|
896
|
+
if (console) {
|
|
897
|
+
var isDetailsError = sDetails instanceof Error, logText = oLogEntry.date + " " + oLogEntry.time + " " + oLogEntry.message + " - " + oLogEntry.details + " " + oLogEntry.component;
|
|
898
|
+
switch (iLevel) {
|
|
899
|
+
case Log.Level.FATAL:
|
|
900
|
+
case Log.Level.ERROR:
|
|
901
|
+
isDetailsError ? console.error(logText, "\n", sDetails) : console.error(logText);
|
|
902
|
+
break;
|
|
903
|
+
case Log.Level.WARNING:
|
|
904
|
+
isDetailsError ? console.warn(logText, "\n", sDetails) : console.warn(logText);
|
|
905
|
+
break;
|
|
906
|
+
case Log.Level.INFO:
|
|
907
|
+
if (console.info) {
|
|
908
|
+
isDetailsError ? console.info(logText, "\n", sDetails) : console.info(logText);
|
|
909
|
+
} else {
|
|
910
|
+
isDetailsError ? console.log(logText, "\n", sDetails) : console.log(logText);
|
|
911
|
+
}
|
|
912
|
+
break;
|
|
913
|
+
case Log.Level.DEBUG:
|
|
914
|
+
isDetailsError ? console.debug(logText, "\n", sDetails) : console.debug(logText);
|
|
915
|
+
break;
|
|
916
|
+
case Log.Level.TRACE:
|
|
917
|
+
isDetailsError ? console.trace(logText, "\n", sDetails) : console.trace(logText);
|
|
918
|
+
break;
|
|
919
|
+
}
|
|
920
|
+
if (console.info && oLogEntry.supportInfo) {
|
|
921
|
+
console.info(oLogEntry.supportInfo);
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
return oLogEntry;
|
|
925
|
+
}
|
|
926
|
+
}
|
|
927
|
+
Log.getLogEntries = function () {
|
|
928
|
+
return aLog.slice();
|
|
929
|
+
};
|
|
930
|
+
Log.getLogEntriesLimit = function () {
|
|
931
|
+
return iLogEntriesLimit;
|
|
932
|
+
};
|
|
933
|
+
Log.setLogEntriesLimit = function (iLimit) {
|
|
934
|
+
if (iLimit < 0) {
|
|
935
|
+
throw new Error("The log entries limit needs to be greater than or equal to 0!");
|
|
936
|
+
}
|
|
937
|
+
iLogEntriesLimit = iLimit;
|
|
938
|
+
if (aLog.length >= iLogEntriesLimit) {
|
|
939
|
+
discardLogEntries();
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
Log.addLogListener = function (oListener) {
|
|
943
|
+
getLogEntryListenerInstance().attach(this, oListener);
|
|
944
|
+
};
|
|
945
|
+
Log.removeLogListener = function (oListener) {
|
|
946
|
+
getLogEntryListenerInstance().detach(this, oListener);
|
|
947
|
+
};
|
|
948
|
+
function Logger(sComponent) {
|
|
949
|
+
this.fatal = function (msg, detail, comp, support) {
|
|
950
|
+
Log.fatal(msg, detail, comp || sComponent, support);
|
|
951
|
+
return this;
|
|
952
|
+
};
|
|
953
|
+
this.error = function (msg, detail, comp, support) {
|
|
954
|
+
Log.error(msg, detail, comp || sComponent, support);
|
|
955
|
+
return this;
|
|
956
|
+
};
|
|
957
|
+
this.warning = function (msg, detail, comp, support) {
|
|
958
|
+
Log.warning(msg, detail, comp || sComponent, support);
|
|
959
|
+
return this;
|
|
960
|
+
};
|
|
961
|
+
this.info = function (msg, detail, comp, support) {
|
|
962
|
+
Log.info(msg, detail, comp || sComponent, support);
|
|
963
|
+
return this;
|
|
964
|
+
};
|
|
965
|
+
this.debug = function (msg, detail, comp, support) {
|
|
966
|
+
Log.debug(msg, detail, comp || sComponent, support);
|
|
967
|
+
return this;
|
|
968
|
+
};
|
|
969
|
+
this.trace = function (msg, detail, comp, support) {
|
|
970
|
+
Log.trace(msg, detail, comp || sComponent, support);
|
|
971
|
+
return this;
|
|
972
|
+
};
|
|
973
|
+
this.setLevel = function (level, comp) {
|
|
974
|
+
Log.setLevel(level, comp || sComponent);
|
|
975
|
+
return this;
|
|
976
|
+
};
|
|
977
|
+
this.getLevel = function (comp) {
|
|
978
|
+
return Log.getLevel(comp || sComponent);
|
|
979
|
+
};
|
|
980
|
+
this.isLoggable = function (level, comp) {
|
|
981
|
+
return Log.isLoggable(level, comp || sComponent);
|
|
982
|
+
};
|
|
983
|
+
}
|
|
984
|
+
Log.getLogger = function (sComponent, iDefaultLogLevel) {
|
|
985
|
+
if (!isNaN(iDefaultLogLevel) && mMaxLevel[sComponent] == null) {
|
|
986
|
+
mMaxLevel[sComponent] = iDefaultLogLevel;
|
|
987
|
+
}
|
|
988
|
+
return new Logger(sComponent);
|
|
989
|
+
};
|
|
990
|
+
|
|
991
|
+
var fnAssert = function (bResult, vMessage) {
|
|
992
|
+
if (!bResult) {
|
|
993
|
+
var sMessage = typeof vMessage === "function" ? vMessage() : vMessage;
|
|
994
|
+
console.assert(bResult, sMessage);
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
|
|
998
|
+
var fnUniqueSort = function (aArray) {
|
|
999
|
+
fnAssert(Array.isArray(aArray), "uniqueSort: input parameter must be an Array");
|
|
1000
|
+
var iLength = aArray.length;
|
|
1001
|
+
if (iLength > 1) {
|
|
1002
|
+
aArray.sort();
|
|
1003
|
+
var j = 0;
|
|
1004
|
+
for (var i = 1; i < iLength; i++) {
|
|
1005
|
+
if (aArray.indexOf(aArray[i]) === i) {
|
|
1006
|
+
aArray[++j] = aArray[i];
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
if (++j < iLength) {
|
|
1010
|
+
aArray.splice(j, iLength - j);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
return aArray;
|
|
1014
|
+
};
|
|
1015
|
+
|
|
1016
|
+
var Metadata = function (sClassName, oClassInfo) {
|
|
1017
|
+
fnAssert(typeof sClassName === "string" && sClassName, "Metadata: sClassName must be a non-empty string");
|
|
1018
|
+
fnAssert(typeof oClassInfo === "object", "Metadata: oClassInfo must be empty or an object");
|
|
1019
|
+
if (!oClassInfo || typeof oClassInfo.metadata !== "object") {
|
|
1020
|
+
oClassInfo = {
|
|
1021
|
+
metadata: oClassInfo || ({}),
|
|
1022
|
+
constructor: ObjectPath.get(sClassName)
|
|
1023
|
+
};
|
|
1024
|
+
oClassInfo.metadata.__version = 1;
|
|
1025
|
+
}
|
|
1026
|
+
oClassInfo.metadata.__version = oClassInfo.metadata.__version || 2;
|
|
1027
|
+
if (typeof oClassInfo.constructor !== "function") {
|
|
1028
|
+
throw Error("constructor for class " + sClassName + " must have been declared before creating metadata for it");
|
|
1029
|
+
}
|
|
1030
|
+
this._sClassName = sClassName;
|
|
1031
|
+
this._oClass = oClassInfo.constructor;
|
|
1032
|
+
this.extend(oClassInfo);
|
|
1033
|
+
};
|
|
1034
|
+
Metadata.prototype.extend = function (oClassInfo) {
|
|
1035
|
+
this.applySettings(oClassInfo);
|
|
1036
|
+
this.afterApplySettings();
|
|
1037
|
+
};
|
|
1038
|
+
Metadata.prototype.applySettings = function (oClassInfo) {
|
|
1039
|
+
var that = this, oStaticInfo = oClassInfo.metadata, oPrototype;
|
|
1040
|
+
if (oStaticInfo.baseType) {
|
|
1041
|
+
var oParentClass = ObjectPath.get(oStaticInfo.baseType);
|
|
1042
|
+
if (typeof oParentClass !== "function") {
|
|
1043
|
+
Log.fatal("base class '" + oStaticInfo.baseType + "' does not exist");
|
|
1044
|
+
}
|
|
1045
|
+
if (oParentClass.getMetadata) {
|
|
1046
|
+
this._oParent = oParentClass.getMetadata();
|
|
1047
|
+
fnAssert(oParentClass === oParentClass.getMetadata().getClass(), "Metadata: oParentClass must match the class in the parent metadata");
|
|
1048
|
+
} else {
|
|
1049
|
+
this._oParent = new Metadata(oStaticInfo.baseType, {});
|
|
1050
|
+
}
|
|
1051
|
+
} else {
|
|
1052
|
+
this._oParent = undefined;
|
|
1053
|
+
}
|
|
1054
|
+
this._bAbstract = !!oStaticInfo["abstract"];
|
|
1055
|
+
this._bFinal = !!oStaticInfo["final"];
|
|
1056
|
+
this._sStereotype = oStaticInfo.stereotype || (this._oParent ? this._oParent._sStereotype : "object");
|
|
1057
|
+
this._bDeprecated = !!oStaticInfo["deprecated"];
|
|
1058
|
+
this._aInterfaces = oStaticInfo.interfaces || [];
|
|
1059
|
+
this._aPublicMethods = oStaticInfo.publicMethods || [];
|
|
1060
|
+
this._bInterfacesUnique = false;
|
|
1061
|
+
oPrototype = this._oClass.prototype;
|
|
1062
|
+
for (var n in oClassInfo) {
|
|
1063
|
+
if (n !== "metadata" && n !== "constructor") {
|
|
1064
|
+
oPrototype[n] = oClassInfo[n];
|
|
1065
|
+
if (!n.match(/^_|^on|^init$|^exit$/)) {
|
|
1066
|
+
that._aPublicMethods.push(n);
|
|
1067
|
+
}
|
|
1068
|
+
}
|
|
1069
|
+
}
|
|
1070
|
+
};
|
|
1071
|
+
Metadata.prototype.afterApplySettings = function () {
|
|
1072
|
+
if (this._oParent) {
|
|
1073
|
+
this._aAllPublicMethods = this._oParent._aAllPublicMethods.concat(this._aPublicMethods);
|
|
1074
|
+
this._bInterfacesUnique = false;
|
|
1075
|
+
} else {
|
|
1076
|
+
this._aAllPublicMethods = this._aPublicMethods;
|
|
1077
|
+
}
|
|
1078
|
+
};
|
|
1079
|
+
Metadata.prototype.getStereotype = function () {
|
|
1080
|
+
return this._sStereotype;
|
|
1081
|
+
};
|
|
1082
|
+
Metadata.prototype.getName = function () {
|
|
1083
|
+
return this._sClassName;
|
|
1084
|
+
};
|
|
1085
|
+
Metadata.prototype.getClass = function () {
|
|
1086
|
+
return this._oClass;
|
|
1087
|
+
};
|
|
1088
|
+
Metadata.prototype.getParent = function () {
|
|
1089
|
+
return this._oParent;
|
|
1090
|
+
};
|
|
1091
|
+
Metadata.prototype._dedupInterfaces = function () {
|
|
1092
|
+
if (!this._bInterfacesUnique) {
|
|
1093
|
+
fnUniqueSort(this._aInterfaces);
|
|
1094
|
+
fnUniqueSort(this._aPublicMethods);
|
|
1095
|
+
fnUniqueSort(this._aAllPublicMethods);
|
|
1096
|
+
this._bInterfacesUnique = true;
|
|
1097
|
+
}
|
|
1098
|
+
};
|
|
1099
|
+
Metadata.prototype.getPublicMethods = function () {
|
|
1100
|
+
this._dedupInterfaces();
|
|
1101
|
+
return this._aPublicMethods;
|
|
1102
|
+
};
|
|
1103
|
+
Metadata.prototype.getAllPublicMethods = function () {
|
|
1104
|
+
this._dedupInterfaces();
|
|
1105
|
+
return this._aAllPublicMethods;
|
|
1106
|
+
};
|
|
1107
|
+
Metadata.prototype.getInterfaces = function () {
|
|
1108
|
+
this._dedupInterfaces();
|
|
1109
|
+
return this._aInterfaces;
|
|
1110
|
+
};
|
|
1111
|
+
Metadata.prototype.isInstanceOf = function (sInterface) {
|
|
1112
|
+
if (this._oParent) {
|
|
1113
|
+
if (this._oParent.isInstanceOf(sInterface)) {
|
|
1114
|
+
return true;
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
var a = this._aInterfaces;
|
|
1118
|
+
for (var i = 0, l = a.length; i < l; i++) {
|
|
1119
|
+
if (a[i] === sInterface) {
|
|
1120
|
+
return true;
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
return false;
|
|
1124
|
+
};
|
|
1125
|
+
Object.defineProperty(Metadata.prototype, "_mImplementedTypes", {
|
|
1126
|
+
get: function () {
|
|
1127
|
+
if (this === Metadata.prototype) {
|
|
1128
|
+
throw new Error("sap.ui.base.Metadata: The '_mImplementedTypes' property must not be accessed on the prototype");
|
|
1129
|
+
}
|
|
1130
|
+
var result = Object.create(this._oParent ? this._oParent._mImplementedTypes : null);
|
|
1131
|
+
result[this._sClassName] = true;
|
|
1132
|
+
var aInterfaces = this._aInterfaces, i = aInterfaces.length;
|
|
1133
|
+
while (i-- > 0) {
|
|
1134
|
+
if (!result[aInterfaces[i]]) {
|
|
1135
|
+
result[aInterfaces[i]] = true;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
Object.defineProperty(this, "_mImplementedTypes", {
|
|
1139
|
+
value: Object.freeze(result),
|
|
1140
|
+
writable: false,
|
|
1141
|
+
configurable: false
|
|
1142
|
+
});
|
|
1143
|
+
return result;
|
|
1144
|
+
},
|
|
1145
|
+
configurable: true
|
|
1146
|
+
});
|
|
1147
|
+
Metadata.prototype.isA = function (vTypeName) {
|
|
1148
|
+
var mTypes = this._mImplementedTypes;
|
|
1149
|
+
if (Array.isArray(vTypeName)) {
|
|
1150
|
+
for (var i = 0; i < vTypeName.length; i++) {
|
|
1151
|
+
if ((vTypeName[i] in mTypes)) {
|
|
1152
|
+
return true;
|
|
1153
|
+
}
|
|
1154
|
+
}
|
|
1155
|
+
return false;
|
|
1156
|
+
}
|
|
1157
|
+
return (vTypeName in mTypes);
|
|
1158
|
+
};
|
|
1159
|
+
Metadata.prototype.isAbstract = function () {
|
|
1160
|
+
return this._bAbstract;
|
|
1161
|
+
};
|
|
1162
|
+
Metadata.prototype.isFinal = function () {
|
|
1163
|
+
return this._bFinal;
|
|
1164
|
+
};
|
|
1165
|
+
Metadata.prototype.isDeprecated = function () {
|
|
1166
|
+
return this._bDeprecated;
|
|
1167
|
+
};
|
|
1168
|
+
Metadata.prototype.addPublicMethods = function (sMethod) {
|
|
1169
|
+
var aNames = sMethod instanceof Array ? sMethod : arguments;
|
|
1170
|
+
Array.prototype.push.apply(this._aPublicMethods, aNames);
|
|
1171
|
+
Array.prototype.push.apply(this._aAllPublicMethods, aNames);
|
|
1172
|
+
this._bInterfacesUnique = false;
|
|
1173
|
+
};
|
|
1174
|
+
Metadata.createClass = function (fnBaseClass, sClassName, oClassInfo, FNMetaImpl) {
|
|
1175
|
+
if (typeof fnBaseClass === "string") {
|
|
1176
|
+
FNMetaImpl = oClassInfo;
|
|
1177
|
+
oClassInfo = sClassName;
|
|
1178
|
+
sClassName = fnBaseClass;
|
|
1179
|
+
fnBaseClass = null;
|
|
1180
|
+
}
|
|
1181
|
+
fnAssert(!fnBaseClass || typeof fnBaseClass === "function");
|
|
1182
|
+
fnAssert(typeof sClassName === "string" && !!sClassName);
|
|
1183
|
+
fnAssert(!oClassInfo || typeof oClassInfo === "object");
|
|
1184
|
+
fnAssert(!FNMetaImpl || typeof FNMetaImpl === "function");
|
|
1185
|
+
FNMetaImpl = FNMetaImpl || Metadata;
|
|
1186
|
+
if (typeof FNMetaImpl.preprocessClassInfo === "function") {
|
|
1187
|
+
oClassInfo = FNMetaImpl.preprocessClassInfo(oClassInfo);
|
|
1188
|
+
}
|
|
1189
|
+
oClassInfo = oClassInfo || ({});
|
|
1190
|
+
oClassInfo.metadata = oClassInfo.metadata || ({});
|
|
1191
|
+
if (!oClassInfo.hasOwnProperty("constructor")) {
|
|
1192
|
+
oClassInfo.constructor = undefined;
|
|
1193
|
+
}
|
|
1194
|
+
var fnClass = oClassInfo.constructor;
|
|
1195
|
+
fnAssert(!fnClass || typeof fnClass === "function");
|
|
1196
|
+
if (fnBaseClass) {
|
|
1197
|
+
if (!fnClass) {
|
|
1198
|
+
if (oClassInfo.metadata.deprecated) {
|
|
1199
|
+
fnClass = function () {
|
|
1200
|
+
Log.warning("Usage of deprecated class: " + sClassName);
|
|
1201
|
+
fnBaseClass.apply(this, arguments);
|
|
1202
|
+
};
|
|
1203
|
+
} else {
|
|
1204
|
+
fnClass = function () {
|
|
1205
|
+
fnBaseClass.apply(this, arguments);
|
|
1206
|
+
};
|
|
1207
|
+
}
|
|
1208
|
+
}
|
|
1209
|
+
fnClass.prototype = Object.create(fnBaseClass.prototype);
|
|
1210
|
+
fnClass.prototype.constructor = fnClass;
|
|
1211
|
+
oClassInfo.metadata.baseType = fnBaseClass.getMetadata().getName();
|
|
1212
|
+
} else {
|
|
1213
|
+
fnClass = fnClass || (function () {});
|
|
1214
|
+
delete oClassInfo.metadata.baseType;
|
|
1215
|
+
}
|
|
1216
|
+
oClassInfo.constructor = fnClass;
|
|
1217
|
+
ObjectPath.set(sClassName, fnClass);
|
|
1218
|
+
var oMetadata = new FNMetaImpl(sClassName, oClassInfo);
|
|
1219
|
+
fnClass.getMetadata = fnClass.prototype.getMetadata = function () {
|
|
1220
|
+
return oMetadata;
|
|
1221
|
+
};
|
|
1222
|
+
if (!fnClass.getMetadata().isFinal()) {
|
|
1223
|
+
fnClass.extend = function (sSCName, oSCClassInfo, fnSCMetaImpl) {
|
|
1224
|
+
return Metadata.createClass(fnClass, sSCName, oSCClassInfo, fnSCMetaImpl || FNMetaImpl);
|
|
1225
|
+
};
|
|
1226
|
+
}
|
|
1227
|
+
return fnClass;
|
|
1228
|
+
};
|
|
1229
|
+
|
|
1230
|
+
var BaseObject = Metadata.createClass("sap.ui.base.Object", {
|
|
1231
|
+
constructor: function () {
|
|
1232
|
+
if (!(this instanceof BaseObject)) {
|
|
1233
|
+
throw Error("Cannot instantiate object: \"new\" is missing!");
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
});
|
|
1237
|
+
BaseObject.prototype.destroy = function () {};
|
|
1238
|
+
BaseObject.prototype.getInterface = function () {
|
|
1239
|
+
var oInterface = new BaseObject._Interface(this, this.getMetadata().getAllPublicMethods());
|
|
1240
|
+
this.getInterface = function () {
|
|
1241
|
+
return oInterface;
|
|
1242
|
+
};
|
|
1243
|
+
return oInterface;
|
|
1244
|
+
};
|
|
1245
|
+
BaseObject.defineClass = function (sClassName, oStaticInfo, FNMetaImpl) {
|
|
1246
|
+
var oMetadata = new (FNMetaImpl || Metadata)(sClassName, oStaticInfo);
|
|
1247
|
+
var fnClass = oMetadata.getClass();
|
|
1248
|
+
fnClass.getMetadata = fnClass.prototype.getMetadata = function () {
|
|
1249
|
+
return oMetadata;
|
|
1250
|
+
};
|
|
1251
|
+
if (!oMetadata.isFinal()) {
|
|
1252
|
+
fnClass.extend = function (sSCName, oSCClassInfo, fnSCMetaImpl) {
|
|
1253
|
+
return Metadata.createClass(fnClass, sSCName, oSCClassInfo, fnSCMetaImpl || FNMetaImpl);
|
|
1254
|
+
};
|
|
1255
|
+
}
|
|
1256
|
+
Log.debug("defined class '" + sClassName + "'" + (oMetadata.getParent() ? " as subclass of " + oMetadata.getParent().getName() : ""));
|
|
1257
|
+
return oMetadata;
|
|
1258
|
+
};
|
|
1259
|
+
BaseObject.prototype.isA = function (vTypeName) {
|
|
1260
|
+
return this.getMetadata().isA(vTypeName);
|
|
1261
|
+
};
|
|
1262
|
+
BaseObject.isA = function (oObject, vTypeName) {
|
|
1263
|
+
return oObject instanceof BaseObject && oObject.isA(vTypeName);
|
|
1264
|
+
};
|
|
1265
|
+
BaseObject._Interface = function (oObject, aMethods, _bReturnFacade) {
|
|
1266
|
+
if (!oObject) {
|
|
1267
|
+
return oObject;
|
|
1268
|
+
}
|
|
1269
|
+
function fCreateDelegator(oObject, sMethodName) {
|
|
1270
|
+
return function () {
|
|
1271
|
+
var tmp = oObject[sMethodName].apply(oObject, arguments);
|
|
1272
|
+
if (_bReturnFacade) {
|
|
1273
|
+
return this;
|
|
1274
|
+
} else {
|
|
1275
|
+
return tmp instanceof BaseObject ? tmp.getInterface() : tmp;
|
|
1276
|
+
}
|
|
1277
|
+
};
|
|
1278
|
+
}
|
|
1279
|
+
if (!aMethods) {
|
|
1280
|
+
return {};
|
|
1281
|
+
}
|
|
1282
|
+
var sMethodName;
|
|
1283
|
+
for (var i = 0, ml = aMethods.length; i < ml; i++) {
|
|
1284
|
+
sMethodName = aMethods[i];
|
|
1285
|
+
if (!oObject[sMethodName] || typeof oObject[sMethodName] === "function") {
|
|
1286
|
+
this[sMethodName] = fCreateDelegator(oObject, sMethodName);
|
|
1287
|
+
}
|
|
1288
|
+
}
|
|
1289
|
+
};
|
|
1290
|
+
|
|
1291
|
+
var class2type = {};
|
|
1292
|
+
var hasOwn = class2type.hasOwnProperty;
|
|
1293
|
+
var toString = class2type.toString;
|
|
1294
|
+
var fnToString = hasOwn.toString;
|
|
1295
|
+
var ObjectFunctionString = fnToString.call(Object);
|
|
1296
|
+
var fnIsPlainObject = function (obj) {
|
|
1297
|
+
var proto, Ctor;
|
|
1298
|
+
if (!obj || toString.call(obj) !== "[object Object]") {
|
|
1299
|
+
return false;
|
|
1300
|
+
}
|
|
1301
|
+
proto = Object.getPrototypeOf(obj);
|
|
1302
|
+
if (!proto) {
|
|
1303
|
+
return true;
|
|
1304
|
+
}
|
|
1305
|
+
Ctor = hasOwn.call(proto, "constructor") && proto.constructor;
|
|
1306
|
+
return typeof Ctor === "function" && fnToString.call(Ctor) === ObjectFunctionString;
|
|
1307
|
+
};
|
|
1308
|
+
|
|
1309
|
+
var oToken = Object.create(null);
|
|
1310
|
+
var fnMerge = function () {
|
|
1311
|
+
var src, copyIsArray, copy, name, options, clone, target = arguments[2] || ({}), i = 3, length = arguments.length, deep = arguments[0] || false, skipToken = arguments[1] ? undefined : oToken;
|
|
1312
|
+
if (typeof target !== "object" && typeof target !== "function") {
|
|
1313
|
+
target = {};
|
|
1314
|
+
}
|
|
1315
|
+
for (; i < length; i++) {
|
|
1316
|
+
if ((options = arguments[i]) != null) {
|
|
1317
|
+
for (name in options) {
|
|
1318
|
+
src = target[name];
|
|
1319
|
+
copy = options[name];
|
|
1320
|
+
if (name === "__proto__" || target === copy) {
|
|
1321
|
+
continue;
|
|
1322
|
+
}
|
|
1323
|
+
if (deep && copy && (fnIsPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) {
|
|
1324
|
+
if (copyIsArray) {
|
|
1325
|
+
copyIsArray = false;
|
|
1326
|
+
clone = src && Array.isArray(src) ? src : [];
|
|
1327
|
+
} else {
|
|
1328
|
+
clone = src && fnIsPlainObject(src) ? src : {};
|
|
1329
|
+
}
|
|
1330
|
+
target[name] = fnMerge(deep, arguments[1], clone, copy);
|
|
1331
|
+
} else if (copy !== skipToken) {
|
|
1332
|
+
target[name] = copy;
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
return target;
|
|
1338
|
+
};
|
|
1339
|
+
|
|
1340
|
+
var fnExtend = function () {
|
|
1341
|
+
var args = [false, true];
|
|
1342
|
+
args.push.apply(args, arguments);
|
|
1343
|
+
return fnMerge.apply(null, args);
|
|
1344
|
+
};
|
|
1345
|
+
|
|
1346
|
+
var sFioriComponent = "FioriElements: ";
|
|
1347
|
+
function getMethods(sClassName, oLog) {
|
|
1348
|
+
var sFullClassName = sFioriComponent + sClassName;
|
|
1349
|
+
return {
|
|
1350
|
+
Level: oLog.Level,
|
|
1351
|
+
addLogListener: function (oListener) {
|
|
1352
|
+
oLog.addLogListener(oListener);
|
|
1353
|
+
},
|
|
1354
|
+
getLogger: function () {
|
|
1355
|
+
return oLog.getLogger(sFullClassName);
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
}
|
|
1359
|
+
var FeLogger = BaseObject.extend("sap.suite.ui.generic.template.genericUtilities.FeLogger", {
|
|
1360
|
+
constructor: function (sClassName) {
|
|
1361
|
+
fnExtend(this, getMethods(sClassName, Log));
|
|
1362
|
+
}
|
|
1363
|
+
});
|
|
1364
|
+
|
|
1365
|
+
var oLogger$2 = new FeLogger("manifestMerger.MergerUil").getLogger();
|
|
1366
|
+
var mergerUtil = {
|
|
1367
|
+
iterateAndFind: function iterateFind(oPages, sEntityKey, sPageComponent, sChildPageId, sParentKey) {
|
|
1368
|
+
var oPageStructure;
|
|
1369
|
+
if (Array.isArray(oPages)) {
|
|
1370
|
+
throw new Error("Manifest should have sap.ui.generic.app.pages as Object structure and not array ");
|
|
1371
|
+
}
|
|
1372
|
+
for (var sKey in oPages) {
|
|
1373
|
+
if (sKey === "entitySet" && oPages.entitySet === sEntityKey) {
|
|
1374
|
+
if (oPages.component && oPages.component.name === sPageComponent) {
|
|
1375
|
+
if (oPages.pages) {
|
|
1376
|
+
var aSiblingkeys = Object.keys(oPages.pages);
|
|
1377
|
+
findDuplicate(aSiblingkeys);
|
|
1378
|
+
}
|
|
1379
|
+
oLogger$2.info(oPages);
|
|
1380
|
+
return oPages;
|
|
1381
|
+
}
|
|
1382
|
+
} else if (typeof oPages[sKey] === "object" && !Array.isArray(oPages[sKey])) {
|
|
1383
|
+
if (oPageStructure) {
|
|
1384
|
+
break;
|
|
1385
|
+
}
|
|
1386
|
+
if (sKey === "pages" || sParentKey === "pages") {
|
|
1387
|
+
oPageStructure = iterateFind(oPages[sKey], sEntityKey, sPageComponent, sChildPageId, sKey);
|
|
1388
|
+
}
|
|
1389
|
+
} else if (sKey === "pages" && Array.isArray(oPages[sKey])) {
|
|
1390
|
+
throw new Error("Manifest should have sap.ui.generic.app.pages as Object structure and not array ");
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
function findDuplicate(aSiblingkeys) {
|
|
1394
|
+
if (aSiblingkeys.length) {
|
|
1395
|
+
aSiblingkeys.filter(function (sPageKey) {
|
|
1396
|
+
if (sPageKey === sChildPageId) {
|
|
1397
|
+
throw new Error("Adding duplicate pageKey " + sChildPageId + " is not supported.");
|
|
1398
|
+
}
|
|
1399
|
+
});
|
|
1400
|
+
}
|
|
1401
|
+
}
|
|
1402
|
+
return oPageStructure;
|
|
1403
|
+
},
|
|
1404
|
+
consistencyCheck: function (oChangeContent, sMergerType, aSupportedProperties) {
|
|
1405
|
+
if (!oChangeContent["parentPage"]) {
|
|
1406
|
+
throw new Error("Mandatory 'parentPage' parameter is not provided.");
|
|
1407
|
+
}
|
|
1408
|
+
if (!oChangeContent.parentPage.entitySet) {
|
|
1409
|
+
throw new Error("Mandatory 'parentPage.entitySet' parameter is not provided.");
|
|
1410
|
+
}
|
|
1411
|
+
if (!oChangeContent.parentPage.component) {
|
|
1412
|
+
throw new Error("Mandatory 'parentPage.component' parameter is not provided.");
|
|
1413
|
+
}
|
|
1414
|
+
if (sMergerType === "ADD") {
|
|
1415
|
+
if (!oChangeContent.childPage.id) {
|
|
1416
|
+
throw new Error(" Add mandatory parameter 'childPage.id' ");
|
|
1417
|
+
}
|
|
1418
|
+
if (!oChangeContent.childPage.definition) {
|
|
1419
|
+
throw new Error("Mandatory 'childPageDefinition' are not provided. Add 'childPage.definition' to add the new page. ");
|
|
1420
|
+
}
|
|
1421
|
+
var aChildkeys = Object.keys(oChangeContent.childPage.definition);
|
|
1422
|
+
aChildkeys.forEach(function (sKey) {
|
|
1423
|
+
if (!fnIncludes(aSupportedProperties, sKey)) {
|
|
1424
|
+
throw new Error("Changing " + sKey + " is not supported. The supported 'propertyPath' is: " + aSupportedProperties.join(","));
|
|
1425
|
+
}
|
|
1426
|
+
});
|
|
1427
|
+
var aMandatoryParams = aSupportedProperties.filter(function (sComponentKey) {
|
|
1428
|
+
return !fnIncludes(aChildkeys, sComponentKey);
|
|
1429
|
+
});
|
|
1430
|
+
if (aMandatoryParams.length) {
|
|
1431
|
+
throw new Error("Mandatory parameter " + aMandatoryParams + " is not defined.");
|
|
1432
|
+
}
|
|
1433
|
+
} else if (sMergerType === "MODIFY") {
|
|
1434
|
+
if (!oChangeContent.entityPropertyChange) {
|
|
1435
|
+
throw new Error("Changes for \"" + oChangeContent["pageId"] + "\" are not provided.");
|
|
1436
|
+
} else {
|
|
1437
|
+
var oEntityPropertyChange = oChangeContent.entityPropertyChange;
|
|
1438
|
+
if (!oEntityPropertyChange.propertyPath) {
|
|
1439
|
+
throw new Error("Invalid change format: The mandatory 'propertyPath' is not defined. Please define the mandatory property 'propertyPath'");
|
|
1440
|
+
}
|
|
1441
|
+
if (!oEntityPropertyChange.operation || oEntityPropertyChange.operation !== "UPSERT") {
|
|
1442
|
+
throw new Error("Invalid change format: The mandatory 'operation' is not defined or is not valid type. Please define the mandatory property 'operation' with type 'UPSERT");
|
|
1443
|
+
}
|
|
1444
|
+
if (!oEntityPropertyChange.propertyValue) {
|
|
1445
|
+
throw new Error("Invalid change format: The mandatory 'propertyValue' is not defined. Please define the mandatory property 'propertyValue'");
|
|
1446
|
+
}
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
};
|
|
1451
|
+
|
|
1452
|
+
var oLogger$1 = new FeLogger("manifestMerger.AddNewObjectPage").getLogger();
|
|
1453
|
+
var addNewObjectPage = {
|
|
1454
|
+
applyChange: function (oManifest, oChange) {
|
|
1455
|
+
oLogger$1.info("addNewPage use case");
|
|
1456
|
+
var aSupportedProperties = ["navigationProperty", "entitySet"];
|
|
1457
|
+
var oChangeContent = oChange.getContent();
|
|
1458
|
+
var sChildPageId = oChangeContent.childPage && oChangeContent.childPage.id;
|
|
1459
|
+
if (sChildPageId) {
|
|
1460
|
+
DescriptorChangeCheck.checkIdNamespaceCompliance(sChildPageId, oChange);
|
|
1461
|
+
}
|
|
1462
|
+
mergerUtil.consistencyCheck(oChangeContent, "ADD", aSupportedProperties);
|
|
1463
|
+
var sParentEntitySet = oChangeContent.parentPage.entitySet;
|
|
1464
|
+
var sParentComponent = oChangeContent.parentPage.component;
|
|
1465
|
+
var oPageStructure = mergerUtil.iterateAndFind(oManifest["sap.ui.generic.app"], sParentEntitySet, sParentComponent, sChildPageId);
|
|
1466
|
+
var oComponentContent = {
|
|
1467
|
+
"name": "sap.suite.ui.generic.template.ObjectPage"
|
|
1468
|
+
};
|
|
1469
|
+
if (oPageStructure) {
|
|
1470
|
+
if (oPageStructure.pages && Array.isArray(oPageStructure.pages)) {
|
|
1471
|
+
throw Error("Manifest should have sap.ui.generic.app.pages as Object structure and not array");
|
|
1472
|
+
}
|
|
1473
|
+
ObjectPath.create(["pages", sChildPageId], oPageStructure);
|
|
1474
|
+
ObjectPath.set(["pages", sChildPageId], oChangeContent.childPage.definition, oPageStructure);
|
|
1475
|
+
ObjectPath.set(["pages", sChildPageId, "component"], oComponentContent, oPageStructure);
|
|
1476
|
+
} else {
|
|
1477
|
+
throw Error("The target content definition is invalid");
|
|
1478
|
+
}
|
|
1479
|
+
return oManifest;
|
|
1480
|
+
}
|
|
1481
|
+
};
|
|
1482
|
+
|
|
1483
|
+
var oLogger = new FeLogger("manifestMerger.ChangePageConfiguration").getLogger();
|
|
1484
|
+
var changePageConfiguration = {
|
|
1485
|
+
applyChange: function (oManifest, oChange) {
|
|
1486
|
+
oLogger.info("modifyPageConfiguration use case");
|
|
1487
|
+
var oChangeContent = oChange.getContent();
|
|
1488
|
+
mergerUtil.consistencyCheck(oChangeContent, "MODIFY");
|
|
1489
|
+
var sParentEntitySet = oChangeContent.parentPage.entitySet;
|
|
1490
|
+
var sParentComponent = oChangeContent.parentPage.component;
|
|
1491
|
+
var oPageStructure = mergerUtil.iterateAndFind(oManifest["sap.ui.generic.app"], sParentEntitySet, sParentComponent);
|
|
1492
|
+
var oPropertyChange = oChangeContent.entityPropertyChange;
|
|
1493
|
+
var aPropertyKeys = Object.keys(oPropertyChange.propertyValue);
|
|
1494
|
+
aPropertyKeys.forEach(function (sCurrentKey) {
|
|
1495
|
+
var aPropertyPath = oPropertyChange.propertyPath.split("/");
|
|
1496
|
+
aPropertyPath.push(sCurrentKey);
|
|
1497
|
+
var vVal = ObjectPath.get(aPropertyPath, oPageStructure);
|
|
1498
|
+
if (vVal && typeof vVal === "object") {
|
|
1499
|
+
var oPropertyPathContent = ObjectPath.create(aPropertyPath, oPageStructure);
|
|
1500
|
+
Object.assign(oPropertyPathContent, oPropertyChange.propertyValue[sCurrentKey]);
|
|
1501
|
+
} else {
|
|
1502
|
+
ObjectPath.set(aPropertyPath, oPropertyChange.propertyValue[sCurrentKey], oPageStructure);
|
|
1503
|
+
}
|
|
1504
|
+
});
|
|
1505
|
+
return oManifest;
|
|
1506
|
+
}
|
|
1507
|
+
};
|
|
1508
|
+
|
|
1509
|
+
var _exports = {};
|
|
1510
|
+
function applyChange(manifest, change) {
|
|
1511
|
+
var _manifest$sapUi, _manifest$sapUi$routi;
|
|
1512
|
+
var changeContent = change.getContent();
|
|
1513
|
+
var pageID = changeContent === null || changeContent === void 0 ? void 0 : changeContent.page;
|
|
1514
|
+
var targets = ((_manifest$sapUi = manifest["sap.ui5"]) === null || _manifest$sapUi === void 0 ? void 0 : (_manifest$sapUi$routi = _manifest$sapUi.routing) === null || _manifest$sapUi$routi === void 0 ? void 0 : _manifest$sapUi$routi.targets) || ({});
|
|
1515
|
+
var pageSettings;
|
|
1516
|
+
var propertyChange = changeContent === null || changeContent === void 0 ? void 0 : changeContent.entityPropertyChange;
|
|
1517
|
+
if ((propertyChange === null || propertyChange === void 0 ? void 0 : propertyChange.operation) !== "UPSERT" || !(propertyChange !== null && propertyChange !== void 0 && propertyChange.propertyPath) || !(propertyChange !== null && propertyChange !== void 0 && propertyChange.propertyValue) || propertyChange !== null && propertyChange !== void 0 && propertyChange.propertyPath.startsWith("/")) {
|
|
1518
|
+
return manifest;
|
|
1519
|
+
}
|
|
1520
|
+
for (var p in targets) {
|
|
1521
|
+
if (targets[p].id === pageID) {
|
|
1522
|
+
var _targets$p$name;
|
|
1523
|
+
if ((_targets$p$name = targets[p].name) !== null && _targets$p$name !== void 0 && _targets$p$name.startsWith("sap.fe.templates.")) {
|
|
1524
|
+
var _targets$p, _targets$p$options;
|
|
1525
|
+
pageSettings = ((_targets$p = targets[p]) === null || _targets$p === void 0 ? void 0 : (_targets$p$options = _targets$p.options) === null || _targets$p$options === void 0 ? void 0 : _targets$p$options.settings) || ({});
|
|
1526
|
+
break;
|
|
1527
|
+
}
|
|
1528
|
+
}
|
|
1529
|
+
}
|
|
1530
|
+
if (!pageSettings) {
|
|
1531
|
+
return manifest;
|
|
1532
|
+
}
|
|
1533
|
+
var propertyPath = propertyChange.propertyPath.split("/");
|
|
1534
|
+
if (propertyPath[0] === "controlConfiguration") {
|
|
1535
|
+
var annotationPath = "";
|
|
1536
|
+
for (var i = 1; i < propertyPath.length; i++) {
|
|
1537
|
+
annotationPath += (i > 1 ? "/" : "") + propertyPath[i];
|
|
1538
|
+
if (annotationPath.indexOf("@") > -1) {
|
|
1539
|
+
propertyPath = ["controlConfiguration", annotationPath].concat(propertyPath.slice(i + 1));
|
|
1540
|
+
break;
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
}
|
|
1544
|
+
ObjectPath.set(propertyPath, propertyChange.propertyValue, pageSettings);
|
|
1545
|
+
return manifest;
|
|
1546
|
+
}
|
|
1547
|
+
_exports.applyChange = applyChange;
|
|
1548
|
+
|
|
707
1549
|
var Registration = {
|
|
708
|
-
appdescr_ui5_addLibraries: AddLibrary,
|
|
709
|
-
appdescr_app_setTitle: SetTitle,
|
|
710
|
-
appdescr_ovp_changeCard: ChangeCard,
|
|
711
|
-
appdescr_ovp_addNewCard: AddNewCard,
|
|
712
|
-
appdescr_ovp_removeCard: DeleteCard
|
|
1550
|
+
appdescr_ui5_addLibraries: () => Promise.resolve(AddLibrary),
|
|
1551
|
+
appdescr_app_setTitle: () => Promise.resolve(SetTitle),
|
|
1552
|
+
appdescr_ovp_changeCard: () => Promise.resolve(ChangeCard),
|
|
1553
|
+
appdescr_ovp_addNewCard: () => Promise.resolve(AddNewCard),
|
|
1554
|
+
appdescr_ovp_removeCard: () => Promise.resolve(DeleteCard),
|
|
1555
|
+
appdescr_ui_generic_app_addNewObjectPage: () => Promise.resolve(addNewObjectPage),
|
|
1556
|
+
appdescr_ui_generic_app_changePageConfiguration: () => Promise.resolve(changePageConfiguration),
|
|
1557
|
+
appdescr_fe_changePageConfiguration: () => Promise.resolve(_exports)
|
|
713
1558
|
};
|
|
714
1559
|
|
|
715
1560
|
var RegistrationBuild = {
|
|
716
|
-
appdescr_app_changeDataSource: ChangeDataSouce,
|
|
717
|
-
appdescr_ui5_addNewModelEnhanceWith: AddNewModelEnhanceWith,
|
|
718
|
-
appdescr_ui5_addComponentUsages: AddComponentUsages,
|
|
719
|
-
appdescr_ui5_setMinUI5Version: SetMinUI5Version,
|
|
720
|
-
appdescr_fiori_setRegistrationIds: SetRegistrationIds,
|
|
721
|
-
appdescr_ui5_setFlexExtensionPointEnabled: SetFlexExtensionPointEnabled,
|
|
722
|
-
appdescr_ui5_addNewModel: AddNewModel,
|
|
723
|
-
appdescr_app_addAnnotationsToOData: AddAnnotationsToOData,
|
|
724
|
-
appdescr_app_changeInbound: ChangeInbound
|
|
1561
|
+
appdescr_app_changeDataSource: () => Promise.resolve(ChangeDataSouce),
|
|
1562
|
+
appdescr_ui5_addNewModelEnhanceWith: () => Promise.resolve(AddNewModelEnhanceWith),
|
|
1563
|
+
appdescr_ui5_addComponentUsages: () => Promise.resolve(AddComponentUsages),
|
|
1564
|
+
appdescr_ui5_setMinUI5Version: () => Promise.resolve(SetMinUI5Version),
|
|
1565
|
+
appdescr_fiori_setRegistrationIds: () => Promise.resolve(SetRegistrationIds),
|
|
1566
|
+
appdescr_ui5_setFlexExtensionPointEnabled: () => Promise.resolve(SetFlexExtensionPointEnabled),
|
|
1567
|
+
appdescr_ui5_addNewModel: () => Promise.resolve(AddNewModel),
|
|
1568
|
+
appdescr_app_addAnnotationsToOData: () => Promise.resolve(AddAnnotationsToOData),
|
|
1569
|
+
appdescr_app_changeInbound: () => Promise.resolve(ChangeInbound),
|
|
1570
|
+
appdescr_fiori_setAbstract: () => Promise.resolve(SetAbstract)
|
|
725
1571
|
};
|
|
726
1572
|
var RegistrationCopy = Object.assign({}, Registration);
|
|
727
1573
|
var RegistrationBuild$1 = Object.assign(RegistrationCopy, RegistrationBuild);
|