@ui5/task-adaptation 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/eslint.config.js +52 -0
- package/package.json +42 -52
- package/scripts/metadataDownloadHelper.ts +8 -7
- package/scripts/rollup/bundle.d.ts +25 -0
- package/scripts/rollup/bundleDefinition.js +11 -1
- package/scripts/{bundler.ts → rollup/bundler.ts} +6 -17
- package/scripts/rollup/overrides/sap/base/config.js +10 -0
- package/scripts/rollup/project/package.json +2 -1
- package/scripts/rollup/project/ui5.yaml +1 -1
- package/scripts/rollup/ui5Resolve.ts +14 -38
- package/scripts/rollup.ts +67 -23
- package/types/ui5.d.ts +44 -0
- package/dist/annotationManager.d.ts +0 -18
- package/dist/annotationManager.js +0 -80
- package/dist/annotations/comparator/comparator.d.ts +0 -47
- package/dist/annotations/comparator/comparator.js +0 -279
- package/dist/annotations/comparator/diffCase.d.ts +0 -4
- package/dist/annotations/comparator/diffCase.js +0 -3
- package/dist/annotations/comparator/interchangableCase.d.ts +0 -25
- package/dist/annotations/comparator/interchangableCase.js +0 -65
- package/dist/annotations/converter/metadataJsonReferenceUtil.d.ts +0 -12
- package/dist/annotations/converter/metadataJsonReferenceUtil.js +0 -50
- package/dist/annotations/converter/metadataJsonUtil.d.ts +0 -30
- package/dist/annotations/converter/metadataJsonUtil.js +0 -73
- package/dist/annotations/converter/ui5JsonConverter.d.ts +0 -21
- package/dist/annotations/converter/ui5JsonConverter.js +0 -253
- package/dist/annotations/converter/ui5MetadataJsonUtil.d.ts +0 -3
- package/dist/annotations/converter/ui5MetadataJsonUtil.js +0 -13
- package/dist/annotations/converter/ui5XmlConverter.d.ts +0 -5
- package/dist/annotations/converter/ui5XmlConverter.js +0 -17
- package/dist/annotations/dataSource/dataSource.d.ts +0 -34
- package/dist/annotations/dataSource/dataSource.js +0 -62
- package/dist/annotations/dataSource/dataSourceManager.d.ts +0 -12
- package/dist/annotations/dataSource/dataSourceManager.js +0 -50
- package/dist/annotations/dataSource/dataSourceOData.d.ts +0 -17
- package/dist/annotations/dataSource/dataSourceOData.js +0 -47
- package/dist/annotations/dataSource/dataSourceODataAnnotation.d.ts +0 -6
- package/dist/annotations/dataSource/dataSourceODataAnnotation.js +0 -18
- package/dist/annotations/serviceRequestor.d.ts +0 -9
- package/dist/annotations/serviceRequestor.js +0 -71
- package/dist/annotations/transformers/convertV2ToV4.d.ts +0 -4
- package/dist/annotations/transformers/convertV2ToV4.js +0 -16
- package/dist/annotations/transformers/makeAnnotationNamespaceUnique.d.ts +0 -6
- package/dist/annotations/transformers/makeAnnotationNamespaceUnique.js +0 -44
- package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.d.ts +0 -4
- package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.js +0 -17
- package/dist/annotations/transformers/transformer.d.ts +0 -12
- package/dist/annotations/transformers/transformer.js +0 -3
- package/dist/annotations/transformers/traverseReferences.d.ts +0 -9
- package/dist/annotations/transformers/traverseReferences.js +0 -67
- package/dist/appVariantManager.d.ts +0 -12
- package/dist/appVariantManager.js +0 -105
- package/dist/baseAppManager.d.ts +0 -29
- package/dist/baseAppManager.js +0 -141
- package/dist/buildStrategy.d.ts +0 -7
- package/dist/buildStrategy.js +0 -21
- package/dist/bundle-odata.js +0 -5498
- package/dist/bundle.js +0 -3475
- package/dist/cache/annotationsCacheManager.d.ts +0 -8
- package/dist/cache/annotationsCacheManager.js +0 -18
- package/dist/cache/baseAppFilesCacheManager.d.ts +0 -6
- package/dist/cache/baseAppFilesCacheManager.js +0 -15
- package/dist/cache/cacheManager.d.ts +0 -16
- package/dist/cache/cacheManager.js +0 -68
- package/dist/i18nManager.d.ts +0 -43
- package/dist/i18nManager.js +0 -203
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -27
- package/dist/model/annotationDiffStructureError.d.ts +0 -3
- package/dist/model/annotationDiffStructureError.js +0 -11
- package/dist/model/language.d.ts +0 -13
- package/dist/model/language.js +0 -37
- package/dist/model/noAuthorizationProvidedError.d.ts +0 -3
- package/dist/model/noAuthorizationProvidedError.js +0 -9
- package/dist/model/serverError.d.ts +0 -3
- package/dist/model/serverError.js +0 -9
- package/dist/model/types.d.ts +0 -119
- package/dist/model/types.js +0 -3
- package/dist/processors/abapProcessor.d.ts +0 -21
- package/dist/processors/abapProcessor.js +0 -36
- package/dist/processors/cfProcessor.d.ts +0 -17
- package/dist/processors/cfProcessor.js +0 -46
- package/dist/processors/processor.d.ts +0 -7
- package/dist/processors/processor.js +0 -36
- package/dist/repositories/abapRepoManager.d.ts +0 -13
- package/dist/repositories/abapRepoManager.js +0 -82
- package/dist/repositories/html5RepoManager.d.ts +0 -11
- package/dist/repositories/html5RepoManager.js +0 -89
- package/dist/util/cfUtil.d.ts +0 -30
- package/dist/util/cfUtil.js +0 -173
- package/dist/util/commonUtil.d.ts +0 -13
- package/dist/util/commonUtil.js +0 -129
- package/dist/util/i18nMerger.d.ts +0 -28
- package/dist/util/i18nMerger.js +0 -103
- package/dist/util/requestUtil.d.ts +0 -8
- package/dist/util/requestUtil.js +0 -57
- package/dist/util/resourceUtil.d.ts +0 -11
- package/dist/util/resourceUtil.js +0 -65
- package/dist/util/urlUtil.d.ts +0 -4
- package/dist/util/urlUtil.js +0 -21
- package/dist/util/xmlUtil.d.ts +0 -4
- package/dist/util/xmlUtil.js +0 -24
- package/dist/util/zipUtil.d.ts +0 -2
- package/dist/util/zipUtil.js +0 -20
- package/scripts/rollup/bundleDefinition-odata.js +0 -9
package/dist/bundle.js
DELETED
|
@@ -1,3475 +0,0 @@
|
|
|
1
|
-
var window = {};
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var fnIsEmptyObject = function isEmptyObject(obj) {
|
|
7
|
-
for (var sName in obj) {
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
return true;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
var FlexObjectFactory = function () {};
|
|
14
|
-
|
|
15
|
-
var CHANGES_NAMESPACE = "$sap.ui.fl.changes";
|
|
16
|
-
function getDescriptorChanges(oManifest) {
|
|
17
|
-
var aAppDescriptorChangesRaw = oManifest && oManifest.getEntry && oManifest.getEntry(CHANGES_NAMESPACE) && oManifest.getEntry(CHANGES_NAMESPACE).descriptor || [];
|
|
18
|
-
return aAppDescriptorChangesRaw.map(function (oChange) {
|
|
19
|
-
return FlexObjectFactory.createAppDescriptorChange(oChange);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
var Applier = {
|
|
23
|
-
applyChanges: function (oUpdatedManifest, aAppDescriptorChanges, mStrategy) {
|
|
24
|
-
return mStrategy.registry().then(function (Registry) {
|
|
25
|
-
var aChangeHandlerPromises = aAppDescriptorChanges.map(function (oChange) {
|
|
26
|
-
return Registry[oChange.getChangeType()] && Registry[oChange.getChangeType()]();
|
|
27
|
-
});
|
|
28
|
-
return Promise.all(aChangeHandlerPromises);
|
|
29
|
-
}).then(function (aChangeHandlers) {
|
|
30
|
-
aChangeHandlers.forEach(function (oChangeHandler, iIndex) {
|
|
31
|
-
try {
|
|
32
|
-
var oChange = aAppDescriptorChanges[iIndex];
|
|
33
|
-
oUpdatedManifest = oChangeHandler.applyChange(oUpdatedManifest, oChange);
|
|
34
|
-
if (!oChangeHandler.skipPostprocessing && !fnIsEmptyObject(oChange.getTexts())) {
|
|
35
|
-
oUpdatedManifest = mStrategy.processTexts(oUpdatedManifest, oChange.getTexts());
|
|
36
|
-
}
|
|
37
|
-
} catch (oError) {
|
|
38
|
-
mStrategy.handleError(oError);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
return oUpdatedManifest;
|
|
42
|
-
});
|
|
43
|
-
},
|
|
44
|
-
applyChangesIncludedInManifest: function (oManifest, mStrategy) {
|
|
45
|
-
var aDescriptorChanges = getDescriptorChanges(oManifest);
|
|
46
|
-
var oManifestJSON = oManifest.getJson();
|
|
47
|
-
delete oManifestJSON[CHANGES_NAMESPACE];
|
|
48
|
-
if (aDescriptorChanges.length > 0) {
|
|
49
|
-
return this.applyChanges(oManifestJSON, aDescriptorChanges, mStrategy).then(function () {
|
|
50
|
-
return;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return Promise.resolve();
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
var _URI = window && window.URI;
|
|
58
|
-
function URI(url, base) {
|
|
59
|
-
var _urlSupplied = arguments.length >= 1;
|
|
60
|
-
var _baseSupplied = arguments.length >= 2;
|
|
61
|
-
if (!(this instanceof URI)) {
|
|
62
|
-
if (_urlSupplied) {
|
|
63
|
-
if (_baseSupplied) {
|
|
64
|
-
return new URI(url, base);
|
|
65
|
-
}
|
|
66
|
-
return new URI(url);
|
|
67
|
-
}
|
|
68
|
-
return new URI();
|
|
69
|
-
}
|
|
70
|
-
if (url === undefined) {
|
|
71
|
-
if (_urlSupplied) {
|
|
72
|
-
throw new TypeError("undefined is not a valid argument for URI");
|
|
73
|
-
}
|
|
74
|
-
if (typeof location !== "undefined") {
|
|
75
|
-
url = location.href + "";
|
|
76
|
-
} else {
|
|
77
|
-
url = "";
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
if (url === null) {
|
|
81
|
-
if (_urlSupplied) {
|
|
82
|
-
throw new TypeError("null is not a valid argument for URI");
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
this.href(url);
|
|
86
|
-
if (base !== undefined) {
|
|
87
|
-
return this.absoluteTo(base);
|
|
88
|
-
}
|
|
89
|
-
return this;
|
|
90
|
-
}
|
|
91
|
-
function isInteger(value) {
|
|
92
|
-
return (/^[0-9]+$/).test(value);
|
|
93
|
-
}
|
|
94
|
-
URI.version = "1.19.11";
|
|
95
|
-
var p = URI.prototype;
|
|
96
|
-
var hasOwn$1 = Object.prototype.hasOwnProperty;
|
|
97
|
-
function escapeRegEx(string) {
|
|
98
|
-
return string.replace(/([.*+?^=!:${}()|[\]\/\\])/g, "\\$1");
|
|
99
|
-
}
|
|
100
|
-
function getType(value) {
|
|
101
|
-
if (value === undefined) {
|
|
102
|
-
return "Undefined";
|
|
103
|
-
}
|
|
104
|
-
return String(Object.prototype.toString.call(value)).slice(8, -1);
|
|
105
|
-
}
|
|
106
|
-
function isArray(obj) {
|
|
107
|
-
return getType(obj) === "Array";
|
|
108
|
-
}
|
|
109
|
-
function filterArrayValues(data, value) {
|
|
110
|
-
var lookup = {};
|
|
111
|
-
var i, length;
|
|
112
|
-
if (getType(value) === "RegExp") {
|
|
113
|
-
lookup = null;
|
|
114
|
-
} else if (isArray(value)) {
|
|
115
|
-
for ((i = 0, length = value.length); i < length; i++) {
|
|
116
|
-
lookup[value[i]] = true;
|
|
117
|
-
}
|
|
118
|
-
} else {
|
|
119
|
-
lookup[value] = true;
|
|
120
|
-
}
|
|
121
|
-
for ((i = 0, length = data.length); i < length; i++) {
|
|
122
|
-
var _match = lookup && lookup[data[i]] !== undefined || !lookup && value.test(data[i]);
|
|
123
|
-
if (_match) {
|
|
124
|
-
data.splice(i, 1);
|
|
125
|
-
length--;
|
|
126
|
-
i--;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return data;
|
|
130
|
-
}
|
|
131
|
-
function arrayContains(list, value) {
|
|
132
|
-
var i, length;
|
|
133
|
-
if (isArray(value)) {
|
|
134
|
-
for ((i = 0, length = value.length); i < length; i++) {
|
|
135
|
-
if (!arrayContains(list, value[i])) {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
var _type = getType(value);
|
|
142
|
-
for ((i = 0, length = list.length); i < length; i++) {
|
|
143
|
-
if (_type === "RegExp") {
|
|
144
|
-
if (typeof list[i] === "string" && list[i].match(value)) {
|
|
145
|
-
return true;
|
|
146
|
-
}
|
|
147
|
-
} else if (list[i] === value) {
|
|
148
|
-
return true;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
function arraysEqual(one, two) {
|
|
154
|
-
if (!isArray(one) || !isArray(two)) {
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
if (one.length !== two.length) {
|
|
158
|
-
return false;
|
|
159
|
-
}
|
|
160
|
-
one.sort();
|
|
161
|
-
two.sort();
|
|
162
|
-
for (var i = 0, l = one.length; i < l; i++) {
|
|
163
|
-
if (one[i] !== two[i]) {
|
|
164
|
-
return false;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
return true;
|
|
168
|
-
}
|
|
169
|
-
function trimSlashes(text) {
|
|
170
|
-
var trim_expression = /^\/+|\/+$/g;
|
|
171
|
-
return text.replace(trim_expression, "");
|
|
172
|
-
}
|
|
173
|
-
URI._parts = function () {
|
|
174
|
-
return {
|
|
175
|
-
protocol: null,
|
|
176
|
-
username: null,
|
|
177
|
-
password: null,
|
|
178
|
-
hostname: null,
|
|
179
|
-
urn: null,
|
|
180
|
-
port: null,
|
|
181
|
-
path: null,
|
|
182
|
-
query: null,
|
|
183
|
-
fragment: null,
|
|
184
|
-
preventInvalidHostname: URI.preventInvalidHostname,
|
|
185
|
-
duplicateQueryParameters: URI.duplicateQueryParameters,
|
|
186
|
-
escapeQuerySpace: URI.escapeQuerySpace
|
|
187
|
-
};
|
|
188
|
-
};
|
|
189
|
-
URI.preventInvalidHostname = false;
|
|
190
|
-
URI.duplicateQueryParameters = false;
|
|
191
|
-
URI.escapeQuerySpace = true;
|
|
192
|
-
URI.protocol_expression = /^[a-z][a-z0-9.+-]*$/i;
|
|
193
|
-
URI.idn_expression = /[^a-z0-9\._-]/i;
|
|
194
|
-
URI.punycode_expression = /(xn--)/i;
|
|
195
|
-
URI.ip4_expression = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
|
196
|
-
URI.ip6_expression = /^\s*((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?\s*$/;
|
|
197
|
-
URI.find_uri_expression = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/ig;
|
|
198
|
-
URI.findUri = {
|
|
199
|
-
start: /\b(?:([a-z][a-z0-9.+-]*:\/\/)|www\.)/gi,
|
|
200
|
-
end: /[\s\r\n]|$/,
|
|
201
|
-
trim: /[`!()\[\]{};:'".,<>?«»“”„‘’]+$/,
|
|
202
|
-
parens: /(\([^\)]*\)|\[[^\]]*\]|\{[^}]*\}|<[^>]*>)/g
|
|
203
|
-
};
|
|
204
|
-
URI.leading_whitespace_expression = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/;
|
|
205
|
-
URI.ascii_tab_whitespace = /[\u0009\u000A\u000D]+/g;
|
|
206
|
-
URI.defaultPorts = {
|
|
207
|
-
http: "80",
|
|
208
|
-
https: "443",
|
|
209
|
-
ftp: "21",
|
|
210
|
-
gopher: "70",
|
|
211
|
-
ws: "80",
|
|
212
|
-
wss: "443"
|
|
213
|
-
};
|
|
214
|
-
URI.hostProtocols = ["http", "https"];
|
|
215
|
-
URI.invalid_hostname_characters = /[^a-zA-Z0-9\.\-:_]/;
|
|
216
|
-
URI.domAttributes = {
|
|
217
|
-
"a": "href",
|
|
218
|
-
"blockquote": "cite",
|
|
219
|
-
"link": "href",
|
|
220
|
-
"base": "href",
|
|
221
|
-
"script": "src",
|
|
222
|
-
"form": "action",
|
|
223
|
-
"img": "src",
|
|
224
|
-
"area": "href",
|
|
225
|
-
"iframe": "src",
|
|
226
|
-
"embed": "src",
|
|
227
|
-
"source": "src",
|
|
228
|
-
"track": "src",
|
|
229
|
-
"input": "src",
|
|
230
|
-
"audio": "src",
|
|
231
|
-
"video": "src"
|
|
232
|
-
};
|
|
233
|
-
URI.getDomAttribute = function (node) {
|
|
234
|
-
if (!node || !node.nodeName) {
|
|
235
|
-
return undefined;
|
|
236
|
-
}
|
|
237
|
-
var nodeName = node.nodeName.toLowerCase();
|
|
238
|
-
if (nodeName === "input" && node.type !== "image") {
|
|
239
|
-
return undefined;
|
|
240
|
-
}
|
|
241
|
-
return URI.domAttributes[nodeName];
|
|
242
|
-
};
|
|
243
|
-
function escapeForDumbFirefox36(value) {
|
|
244
|
-
return escape(value);
|
|
245
|
-
}
|
|
246
|
-
function strictEncodeURIComponent(string) {
|
|
247
|
-
return encodeURIComponent(string).replace(/[!'()*]/g, escapeForDumbFirefox36).replace(/\*/g, "%2A");
|
|
248
|
-
}
|
|
249
|
-
URI.encode = strictEncodeURIComponent;
|
|
250
|
-
URI.decode = decodeURIComponent;
|
|
251
|
-
URI.iso8859 = function () {
|
|
252
|
-
URI.encode = escape;
|
|
253
|
-
URI.decode = unescape;
|
|
254
|
-
};
|
|
255
|
-
URI.unicode = function () {
|
|
256
|
-
URI.encode = strictEncodeURIComponent;
|
|
257
|
-
URI.decode = decodeURIComponent;
|
|
258
|
-
};
|
|
259
|
-
URI.characters = {
|
|
260
|
-
pathname: {
|
|
261
|
-
encode: {
|
|
262
|
-
expression: /%(24|26|2B|2C|3B|3D|3A|40)/ig,
|
|
263
|
-
map: {
|
|
264
|
-
"%24": "$",
|
|
265
|
-
"%26": "&",
|
|
266
|
-
"%2B": "+",
|
|
267
|
-
"%2C": ",",
|
|
268
|
-
"%3B": ";",
|
|
269
|
-
"%3D": "=",
|
|
270
|
-
"%3A": ":",
|
|
271
|
-
"%40": "@"
|
|
272
|
-
}
|
|
273
|
-
},
|
|
274
|
-
decode: {
|
|
275
|
-
expression: /[\/\?#]/g,
|
|
276
|
-
map: {
|
|
277
|
-
"/": "%2F",
|
|
278
|
-
"?": "%3F",
|
|
279
|
-
"#": "%23"
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
reserved: {
|
|
284
|
-
encode: {
|
|
285
|
-
expression: /%(21|23|24|26|27|28|29|2A|2B|2C|2F|3A|3B|3D|3F|40|5B|5D)/ig,
|
|
286
|
-
map: {
|
|
287
|
-
"%3A": ":",
|
|
288
|
-
"%2F": "/",
|
|
289
|
-
"%3F": "?",
|
|
290
|
-
"%23": "#",
|
|
291
|
-
"%5B": "[",
|
|
292
|
-
"%5D": "]",
|
|
293
|
-
"%40": "@",
|
|
294
|
-
"%21": "!",
|
|
295
|
-
"%24": "$",
|
|
296
|
-
"%26": "&",
|
|
297
|
-
"%27": "'",
|
|
298
|
-
"%28": "(",
|
|
299
|
-
"%29": ")",
|
|
300
|
-
"%2A": "*",
|
|
301
|
-
"%2B": "+",
|
|
302
|
-
"%2C": ",",
|
|
303
|
-
"%3B": ";",
|
|
304
|
-
"%3D": "="
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
},
|
|
308
|
-
urnpath: {
|
|
309
|
-
encode: {
|
|
310
|
-
expression: /%(21|24|27|28|29|2A|2B|2C|3B|3D|40)/ig,
|
|
311
|
-
map: {
|
|
312
|
-
"%21": "!",
|
|
313
|
-
"%24": "$",
|
|
314
|
-
"%27": "'",
|
|
315
|
-
"%28": "(",
|
|
316
|
-
"%29": ")",
|
|
317
|
-
"%2A": "*",
|
|
318
|
-
"%2B": "+",
|
|
319
|
-
"%2C": ",",
|
|
320
|
-
"%3B": ";",
|
|
321
|
-
"%3D": "=",
|
|
322
|
-
"%40": "@"
|
|
323
|
-
}
|
|
324
|
-
},
|
|
325
|
-
decode: {
|
|
326
|
-
expression: /[\/\?#:]/g,
|
|
327
|
-
map: {
|
|
328
|
-
"/": "%2F",
|
|
329
|
-
"?": "%3F",
|
|
330
|
-
"#": "%23",
|
|
331
|
-
":": "%3A"
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
URI.encodeQuery = function (string, escapeQuerySpace) {
|
|
337
|
-
var escaped = URI.encode(string + "");
|
|
338
|
-
if (escapeQuerySpace === undefined) {
|
|
339
|
-
escapeQuerySpace = URI.escapeQuerySpace;
|
|
340
|
-
}
|
|
341
|
-
return escapeQuerySpace ? escaped.replace(/%20/g, "+") : escaped;
|
|
342
|
-
};
|
|
343
|
-
URI.decodeQuery = function (string, escapeQuerySpace) {
|
|
344
|
-
string += "";
|
|
345
|
-
if (escapeQuerySpace === undefined) {
|
|
346
|
-
escapeQuerySpace = URI.escapeQuerySpace;
|
|
347
|
-
}
|
|
348
|
-
try {
|
|
349
|
-
return URI.decode(escapeQuerySpace ? string.replace(/\+/g, "%20") : string);
|
|
350
|
-
} catch (e) {
|
|
351
|
-
return string;
|
|
352
|
-
}
|
|
353
|
-
};
|
|
354
|
-
var _parts = {
|
|
355
|
-
"encode": "encode",
|
|
356
|
-
"decode": "decode"
|
|
357
|
-
};
|
|
358
|
-
var _part;
|
|
359
|
-
var generateAccessor = function (_group, _part) {
|
|
360
|
-
return function (string) {
|
|
361
|
-
try {
|
|
362
|
-
return URI[_part](string + "").replace(URI.characters[_group][_part].expression, function (c) {
|
|
363
|
-
return URI.characters[_group][_part].map[c];
|
|
364
|
-
});
|
|
365
|
-
} catch (e) {
|
|
366
|
-
return string;
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
|
-
};
|
|
370
|
-
for (_part in _parts) {
|
|
371
|
-
URI[_part + "PathSegment"] = generateAccessor("pathname", _parts[_part]);
|
|
372
|
-
URI[_part + "UrnPathSegment"] = generateAccessor("urnpath", _parts[_part]);
|
|
373
|
-
}
|
|
374
|
-
var generateSegmentedPathFunction = function (_sep, _codingFuncName, _innerCodingFuncName) {
|
|
375
|
-
return function (string) {
|
|
376
|
-
var actualCodingFunc;
|
|
377
|
-
if (!_innerCodingFuncName) {
|
|
378
|
-
actualCodingFunc = URI[_codingFuncName];
|
|
379
|
-
} else {
|
|
380
|
-
actualCodingFunc = function (string) {
|
|
381
|
-
return URI[_codingFuncName](URI[_innerCodingFuncName](string));
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
var segments = (string + "").split(_sep);
|
|
385
|
-
for (var i = 0, length = segments.length; i < length; i++) {
|
|
386
|
-
segments[i] = actualCodingFunc(segments[i]);
|
|
387
|
-
}
|
|
388
|
-
return segments.join(_sep);
|
|
389
|
-
};
|
|
390
|
-
};
|
|
391
|
-
URI.decodePath = generateSegmentedPathFunction("/", "decodePathSegment");
|
|
392
|
-
URI.decodeUrnPath = generateSegmentedPathFunction(":", "decodeUrnPathSegment");
|
|
393
|
-
URI.recodePath = generateSegmentedPathFunction("/", "encodePathSegment", "decode");
|
|
394
|
-
URI.recodeUrnPath = generateSegmentedPathFunction(":", "encodeUrnPathSegment", "decode");
|
|
395
|
-
URI.encodeReserved = generateAccessor("reserved", "encode");
|
|
396
|
-
URI.parse = function (string, parts) {
|
|
397
|
-
var pos;
|
|
398
|
-
if (!parts) {
|
|
399
|
-
parts = {
|
|
400
|
-
preventInvalidHostname: URI.preventInvalidHostname
|
|
401
|
-
};
|
|
402
|
-
}
|
|
403
|
-
string = string.replace(URI.leading_whitespace_expression, "");
|
|
404
|
-
string = string.replace(URI.ascii_tab_whitespace, "");
|
|
405
|
-
pos = string.indexOf("#");
|
|
406
|
-
if (pos > -1) {
|
|
407
|
-
parts.fragment = string.substring(pos + 1) || null;
|
|
408
|
-
string = string.substring(0, pos);
|
|
409
|
-
}
|
|
410
|
-
pos = string.indexOf("?");
|
|
411
|
-
if (pos > -1) {
|
|
412
|
-
parts.query = string.substring(pos + 1) || null;
|
|
413
|
-
string = string.substring(0, pos);
|
|
414
|
-
}
|
|
415
|
-
string = string.replace(/^(https?|ftp|wss?)?:+[/\\]*/i, "$1://");
|
|
416
|
-
string = string.replace(/^[/\\]{2,}/i, "//");
|
|
417
|
-
if (string.substring(0, 2) === "//") {
|
|
418
|
-
parts.protocol = null;
|
|
419
|
-
string = string.substring(2);
|
|
420
|
-
string = URI.parseAuthority(string, parts);
|
|
421
|
-
} else {
|
|
422
|
-
pos = string.indexOf(":");
|
|
423
|
-
if (pos > -1) {
|
|
424
|
-
parts.protocol = string.substring(0, pos) || null;
|
|
425
|
-
if (parts.protocol && !parts.protocol.match(URI.protocol_expression)) {
|
|
426
|
-
parts.protocol = undefined;
|
|
427
|
-
} else if (string.substring(pos + 1, pos + 3).replace(/\\/g, "/") === "//") {
|
|
428
|
-
string = string.substring(pos + 3);
|
|
429
|
-
string = URI.parseAuthority(string, parts);
|
|
430
|
-
} else {
|
|
431
|
-
string = string.substring(pos + 1);
|
|
432
|
-
parts.urn = true;
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
parts.path = string;
|
|
437
|
-
return parts;
|
|
438
|
-
};
|
|
439
|
-
URI.parseHost = function (string, parts) {
|
|
440
|
-
if (!string) {
|
|
441
|
-
string = "";
|
|
442
|
-
}
|
|
443
|
-
string = string.replace(/\\/g, "/");
|
|
444
|
-
var pos = string.indexOf("/");
|
|
445
|
-
var bracketPos;
|
|
446
|
-
var t;
|
|
447
|
-
if (pos === -1) {
|
|
448
|
-
pos = string.length;
|
|
449
|
-
}
|
|
450
|
-
if (string.charAt(0) === "[") {
|
|
451
|
-
bracketPos = string.indexOf("]");
|
|
452
|
-
parts.hostname = string.substring(1, bracketPos) || null;
|
|
453
|
-
parts.port = string.substring(bracketPos + 2, pos) || null;
|
|
454
|
-
if (parts.port === "/") {
|
|
455
|
-
parts.port = null;
|
|
456
|
-
}
|
|
457
|
-
} else {
|
|
458
|
-
var firstColon = string.indexOf(":");
|
|
459
|
-
var firstSlash = string.indexOf("/");
|
|
460
|
-
var nextColon = string.indexOf(":", firstColon + 1);
|
|
461
|
-
if (nextColon !== -1 && (firstSlash === -1 || nextColon < firstSlash)) {
|
|
462
|
-
parts.hostname = string.substring(0, pos) || null;
|
|
463
|
-
parts.port = null;
|
|
464
|
-
} else {
|
|
465
|
-
t = string.substring(0, pos).split(":");
|
|
466
|
-
parts.hostname = t[0] || null;
|
|
467
|
-
parts.port = t[1] || null;
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
if (parts.hostname && string.substring(pos).charAt(0) !== "/") {
|
|
471
|
-
pos++;
|
|
472
|
-
string = "/" + string;
|
|
473
|
-
}
|
|
474
|
-
if (parts.preventInvalidHostname) {
|
|
475
|
-
URI.ensureValidHostname(parts.hostname, parts.protocol);
|
|
476
|
-
}
|
|
477
|
-
if (parts.port) {
|
|
478
|
-
URI.ensureValidPort(parts.port);
|
|
479
|
-
}
|
|
480
|
-
return string.substring(pos) || "/";
|
|
481
|
-
};
|
|
482
|
-
URI.parseAuthority = function (string, parts) {
|
|
483
|
-
string = URI.parseUserinfo(string, parts);
|
|
484
|
-
return URI.parseHost(string, parts);
|
|
485
|
-
};
|
|
486
|
-
URI.parseUserinfo = function (string, parts) {
|
|
487
|
-
var _string = string;
|
|
488
|
-
var firstBackSlash = string.indexOf("\\");
|
|
489
|
-
if (firstBackSlash !== -1) {
|
|
490
|
-
string = string.replace(/\\/g, "/");
|
|
491
|
-
}
|
|
492
|
-
var firstSlash = string.indexOf("/");
|
|
493
|
-
var pos = string.lastIndexOf("@", firstSlash > -1 ? firstSlash : string.length - 1);
|
|
494
|
-
var t;
|
|
495
|
-
if (pos > -1 && (firstSlash === -1 || pos < firstSlash)) {
|
|
496
|
-
t = string.substring(0, pos).split(":");
|
|
497
|
-
parts.username = t[0] ? URI.decode(t[0]) : null;
|
|
498
|
-
t.shift();
|
|
499
|
-
parts.password = t[0] ? URI.decode(t.join(":")) : null;
|
|
500
|
-
string = _string.substring(pos + 1);
|
|
501
|
-
} else {
|
|
502
|
-
parts.username = null;
|
|
503
|
-
parts.password = null;
|
|
504
|
-
}
|
|
505
|
-
return string;
|
|
506
|
-
};
|
|
507
|
-
URI.parseQuery = function (string, escapeQuerySpace) {
|
|
508
|
-
if (!string) {
|
|
509
|
-
return {};
|
|
510
|
-
}
|
|
511
|
-
string = string.replace(/&+/g, "&").replace(/^\?*&*|&+$/g, "");
|
|
512
|
-
if (!string) {
|
|
513
|
-
return {};
|
|
514
|
-
}
|
|
515
|
-
var items = {};
|
|
516
|
-
var splits = string.split("&");
|
|
517
|
-
var length = splits.length;
|
|
518
|
-
var v, name, value;
|
|
519
|
-
for (var i = 0; i < length; i++) {
|
|
520
|
-
v = splits[i].split("=");
|
|
521
|
-
name = URI.decodeQuery(v.shift(), escapeQuerySpace);
|
|
522
|
-
value = v.length ? URI.decodeQuery(v.join("="), escapeQuerySpace) : null;
|
|
523
|
-
if (name === "__proto__") {
|
|
524
|
-
continue;
|
|
525
|
-
} else if (hasOwn$1.call(items, name)) {
|
|
526
|
-
if (typeof items[name] === "string" || items[name] === null) {
|
|
527
|
-
items[name] = [items[name]];
|
|
528
|
-
}
|
|
529
|
-
items[name].push(value);
|
|
530
|
-
} else {
|
|
531
|
-
items[name] = value;
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
return items;
|
|
535
|
-
};
|
|
536
|
-
URI.build = function (parts) {
|
|
537
|
-
var t = "";
|
|
538
|
-
var requireAbsolutePath = false;
|
|
539
|
-
if (parts.protocol) {
|
|
540
|
-
t += parts.protocol + ":";
|
|
541
|
-
}
|
|
542
|
-
if (!parts.urn && (t || parts.hostname)) {
|
|
543
|
-
t += "//";
|
|
544
|
-
requireAbsolutePath = true;
|
|
545
|
-
}
|
|
546
|
-
t += URI.buildAuthority(parts) || "";
|
|
547
|
-
if (typeof parts.path === "string") {
|
|
548
|
-
if (parts.path.charAt(0) !== "/" && requireAbsolutePath) {
|
|
549
|
-
t += "/";
|
|
550
|
-
}
|
|
551
|
-
t += parts.path;
|
|
552
|
-
}
|
|
553
|
-
if (typeof parts.query === "string" && parts.query) {
|
|
554
|
-
t += "?" + parts.query;
|
|
555
|
-
}
|
|
556
|
-
if (typeof parts.fragment === "string" && parts.fragment) {
|
|
557
|
-
t += "#" + parts.fragment;
|
|
558
|
-
}
|
|
559
|
-
return t;
|
|
560
|
-
};
|
|
561
|
-
URI.buildHost = function (parts) {
|
|
562
|
-
var t = "";
|
|
563
|
-
if (!parts.hostname) {
|
|
564
|
-
return "";
|
|
565
|
-
} else if (URI.ip6_expression.test(parts.hostname)) {
|
|
566
|
-
t += "[" + parts.hostname + "]";
|
|
567
|
-
} else {
|
|
568
|
-
t += parts.hostname;
|
|
569
|
-
}
|
|
570
|
-
if (parts.port) {
|
|
571
|
-
t += ":" + parts.port;
|
|
572
|
-
}
|
|
573
|
-
return t;
|
|
574
|
-
};
|
|
575
|
-
URI.buildAuthority = function (parts) {
|
|
576
|
-
return URI.buildUserinfo(parts) + URI.buildHost(parts);
|
|
577
|
-
};
|
|
578
|
-
URI.buildUserinfo = function (parts) {
|
|
579
|
-
var t = "";
|
|
580
|
-
if (parts.username) {
|
|
581
|
-
t += URI.encode(parts.username);
|
|
582
|
-
}
|
|
583
|
-
if (parts.password) {
|
|
584
|
-
t += ":" + URI.encode(parts.password);
|
|
585
|
-
}
|
|
586
|
-
if (t) {
|
|
587
|
-
t += "@";
|
|
588
|
-
}
|
|
589
|
-
return t;
|
|
590
|
-
};
|
|
591
|
-
URI.buildQuery = function (data, duplicateQueryParameters, escapeQuerySpace) {
|
|
592
|
-
var t = "";
|
|
593
|
-
var unique, key, i, length;
|
|
594
|
-
for (key in data) {
|
|
595
|
-
if (key === "__proto__") {
|
|
596
|
-
continue;
|
|
597
|
-
} else if (hasOwn$1.call(data, key)) {
|
|
598
|
-
if (isArray(data[key])) {
|
|
599
|
-
unique = {};
|
|
600
|
-
for ((i = 0, length = data[key].length); i < length; i++) {
|
|
601
|
-
if (data[key][i] !== undefined && unique[data[key][i] + ""] === undefined) {
|
|
602
|
-
t += "&" + URI.buildQueryParameter(key, data[key][i], escapeQuerySpace);
|
|
603
|
-
if (duplicateQueryParameters !== true) {
|
|
604
|
-
unique[data[key][i] + ""] = true;
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
} else if (data[key] !== undefined) {
|
|
609
|
-
t += "&" + URI.buildQueryParameter(key, data[key], escapeQuerySpace);
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
return t.substring(1);
|
|
614
|
-
};
|
|
615
|
-
URI.buildQueryParameter = function (name, value, escapeQuerySpace) {
|
|
616
|
-
return URI.encodeQuery(name, escapeQuerySpace) + (value !== null ? "=" + URI.encodeQuery(value, escapeQuerySpace) : "");
|
|
617
|
-
};
|
|
618
|
-
URI.addQuery = function (data, name, value) {
|
|
619
|
-
if (typeof name === "object") {
|
|
620
|
-
for (var key in name) {
|
|
621
|
-
if (hasOwn$1.call(name, key)) {
|
|
622
|
-
URI.addQuery(data, key, name[key]);
|
|
623
|
-
}
|
|
624
|
-
}
|
|
625
|
-
} else if (typeof name === "string") {
|
|
626
|
-
if (data[name] === undefined) {
|
|
627
|
-
data[name] = value;
|
|
628
|
-
return;
|
|
629
|
-
} else if (typeof data[name] === "string") {
|
|
630
|
-
data[name] = [data[name]];
|
|
631
|
-
}
|
|
632
|
-
if (!isArray(value)) {
|
|
633
|
-
value = [value];
|
|
634
|
-
}
|
|
635
|
-
data[name] = (data[name] || []).concat(value);
|
|
636
|
-
} else {
|
|
637
|
-
throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");
|
|
638
|
-
}
|
|
639
|
-
};
|
|
640
|
-
URI.setQuery = function (data, name, value) {
|
|
641
|
-
if (typeof name === "object") {
|
|
642
|
-
for (var key in name) {
|
|
643
|
-
if (hasOwn$1.call(name, key)) {
|
|
644
|
-
URI.setQuery(data, key, name[key]);
|
|
645
|
-
}
|
|
646
|
-
}
|
|
647
|
-
} else if (typeof name === "string") {
|
|
648
|
-
data[name] = value === undefined ? null : value;
|
|
649
|
-
} else {
|
|
650
|
-
throw new TypeError("URI.setQuery() accepts an object, string as the name parameter");
|
|
651
|
-
}
|
|
652
|
-
};
|
|
653
|
-
URI.removeQuery = function (data, name, value) {
|
|
654
|
-
var i, length, key;
|
|
655
|
-
if (isArray(name)) {
|
|
656
|
-
for ((i = 0, length = name.length); i < length; i++) {
|
|
657
|
-
data[name[i]] = undefined;
|
|
658
|
-
}
|
|
659
|
-
} else if (getType(name) === "RegExp") {
|
|
660
|
-
for (key in data) {
|
|
661
|
-
if (name.test(key)) {
|
|
662
|
-
data[key] = undefined;
|
|
663
|
-
}
|
|
664
|
-
}
|
|
665
|
-
} else if (typeof name === "object") {
|
|
666
|
-
for (key in name) {
|
|
667
|
-
if (hasOwn$1.call(name, key)) {
|
|
668
|
-
URI.removeQuery(data, key, name[key]);
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
} else if (typeof name === "string") {
|
|
672
|
-
if (value !== undefined) {
|
|
673
|
-
if (getType(value) === "RegExp") {
|
|
674
|
-
if (!isArray(data[name]) && value.test(data[name])) {
|
|
675
|
-
data[name] = undefined;
|
|
676
|
-
} else {
|
|
677
|
-
data[name] = filterArrayValues(data[name], value);
|
|
678
|
-
}
|
|
679
|
-
} else if (data[name] === String(value) && (!isArray(value) || value.length === 1)) {
|
|
680
|
-
data[name] = undefined;
|
|
681
|
-
} else if (isArray(data[name])) {
|
|
682
|
-
data[name] = filterArrayValues(data[name], value);
|
|
683
|
-
}
|
|
684
|
-
} else {
|
|
685
|
-
data[name] = undefined;
|
|
686
|
-
}
|
|
687
|
-
} else {
|
|
688
|
-
throw new TypeError("URI.removeQuery() accepts an object, string, RegExp as the first parameter");
|
|
689
|
-
}
|
|
690
|
-
};
|
|
691
|
-
URI.hasQuery = function (data, name, value, withinArray) {
|
|
692
|
-
switch (getType(name)) {
|
|
693
|
-
case "String":
|
|
694
|
-
break;
|
|
695
|
-
case "RegExp":
|
|
696
|
-
for (var key in data) {
|
|
697
|
-
if (hasOwn$1.call(data, key)) {
|
|
698
|
-
if (name.test(key) && (value === undefined || URI.hasQuery(data, key, value))) {
|
|
699
|
-
return true;
|
|
700
|
-
}
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
return false;
|
|
704
|
-
case "Object":
|
|
705
|
-
for (var _key in name) {
|
|
706
|
-
if (hasOwn$1.call(name, _key)) {
|
|
707
|
-
if (!URI.hasQuery(data, _key, name[_key])) {
|
|
708
|
-
return false;
|
|
709
|
-
}
|
|
710
|
-
}
|
|
711
|
-
}
|
|
712
|
-
return true;
|
|
713
|
-
default:
|
|
714
|
-
throw new TypeError("URI.hasQuery() accepts a string, regular expression or object as the name parameter");
|
|
715
|
-
}
|
|
716
|
-
switch (getType(value)) {
|
|
717
|
-
case "Undefined":
|
|
718
|
-
return (name in data);
|
|
719
|
-
case "Boolean":
|
|
720
|
-
var _booly = Boolean(isArray(data[name]) ? data[name].length : data[name]);
|
|
721
|
-
return value === _booly;
|
|
722
|
-
case "Function":
|
|
723
|
-
return !!value(data[name], name, data);
|
|
724
|
-
case "Array":
|
|
725
|
-
if (!isArray(data[name])) {
|
|
726
|
-
return false;
|
|
727
|
-
}
|
|
728
|
-
var op = withinArray ? arrayContains : arraysEqual;
|
|
729
|
-
return op(data[name], value);
|
|
730
|
-
case "RegExp":
|
|
731
|
-
if (!isArray(data[name])) {
|
|
732
|
-
return Boolean(data[name] && data[name].match(value));
|
|
733
|
-
}
|
|
734
|
-
if (!withinArray) {
|
|
735
|
-
return false;
|
|
736
|
-
}
|
|
737
|
-
return arrayContains(data[name], value);
|
|
738
|
-
case "Number":
|
|
739
|
-
value = String(value);
|
|
740
|
-
case "String":
|
|
741
|
-
if (!isArray(data[name])) {
|
|
742
|
-
return data[name] === value;
|
|
743
|
-
}
|
|
744
|
-
if (!withinArray) {
|
|
745
|
-
return false;
|
|
746
|
-
}
|
|
747
|
-
return arrayContains(data[name], value);
|
|
748
|
-
default:
|
|
749
|
-
throw new TypeError("URI.hasQuery() accepts undefined, boolean, string, number, RegExp, Function as the value parameter");
|
|
750
|
-
}
|
|
751
|
-
};
|
|
752
|
-
URI.joinPaths = function () {
|
|
753
|
-
var input = [];
|
|
754
|
-
var segments = [];
|
|
755
|
-
var nonEmptySegments = 0;
|
|
756
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
757
|
-
var url = new URI(arguments[i]);
|
|
758
|
-
input.push(url);
|
|
759
|
-
var _segments = url.segment();
|
|
760
|
-
for (var s = 0; s < _segments.length; s++) {
|
|
761
|
-
if (typeof _segments[s] === "string") {
|
|
762
|
-
segments.push(_segments[s]);
|
|
763
|
-
}
|
|
764
|
-
if (_segments[s]) {
|
|
765
|
-
nonEmptySegments++;
|
|
766
|
-
}
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
if (!segments.length || !nonEmptySegments) {
|
|
770
|
-
return new URI("");
|
|
771
|
-
}
|
|
772
|
-
var uri = new URI("").segment(segments);
|
|
773
|
-
if (input[0].path() === "" || input[0].path().slice(0, 1) === "/") {
|
|
774
|
-
uri.path("/" + uri.path());
|
|
775
|
-
}
|
|
776
|
-
return uri.normalize();
|
|
777
|
-
};
|
|
778
|
-
URI.commonPath = function (one, two) {
|
|
779
|
-
var length = Math.min(one.length, two.length);
|
|
780
|
-
var pos;
|
|
781
|
-
for (pos = 0; pos < length; pos++) {
|
|
782
|
-
if (one.charAt(pos) !== two.charAt(pos)) {
|
|
783
|
-
pos--;
|
|
784
|
-
break;
|
|
785
|
-
}
|
|
786
|
-
}
|
|
787
|
-
if (pos < 1) {
|
|
788
|
-
return one.charAt(0) === two.charAt(0) && one.charAt(0) === "/" ? "/" : "";
|
|
789
|
-
}
|
|
790
|
-
if (one.charAt(pos) !== "/" || two.charAt(pos) !== "/") {
|
|
791
|
-
pos = one.substring(0, pos).lastIndexOf("/");
|
|
792
|
-
}
|
|
793
|
-
return one.substring(0, pos + 1);
|
|
794
|
-
};
|
|
795
|
-
URI.withinString = function (string, callback, options) {
|
|
796
|
-
options || (options = {});
|
|
797
|
-
var _start = options.start || URI.findUri.start;
|
|
798
|
-
var _end = options.end || URI.findUri.end;
|
|
799
|
-
var _trim = options.trim || URI.findUri.trim;
|
|
800
|
-
var _parens = options.parens || URI.findUri.parens;
|
|
801
|
-
var _attributeOpen = /[a-z0-9-]=["']?$/i;
|
|
802
|
-
_start.lastIndex = 0;
|
|
803
|
-
while (true) {
|
|
804
|
-
var match = _start.exec(string);
|
|
805
|
-
if (!match) {
|
|
806
|
-
break;
|
|
807
|
-
}
|
|
808
|
-
var start = match.index;
|
|
809
|
-
if (options.ignoreHtml) {
|
|
810
|
-
var attributeOpen = string.slice(Math.max(start - 3, 0), start);
|
|
811
|
-
if (attributeOpen && _attributeOpen.test(attributeOpen)) {
|
|
812
|
-
continue;
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
var end = start + string.slice(start).search(_end);
|
|
816
|
-
var slice = string.slice(start, end);
|
|
817
|
-
var parensEnd = -1;
|
|
818
|
-
while (true) {
|
|
819
|
-
var parensMatch = _parens.exec(slice);
|
|
820
|
-
if (!parensMatch) {
|
|
821
|
-
break;
|
|
822
|
-
}
|
|
823
|
-
var parensMatchEnd = parensMatch.index + parensMatch[0].length;
|
|
824
|
-
parensEnd = Math.max(parensEnd, parensMatchEnd);
|
|
825
|
-
}
|
|
826
|
-
if (parensEnd > -1) {
|
|
827
|
-
slice = slice.slice(0, parensEnd) + slice.slice(parensEnd).replace(_trim, "");
|
|
828
|
-
} else {
|
|
829
|
-
slice = slice.replace(_trim, "");
|
|
830
|
-
}
|
|
831
|
-
if (slice.length <= match[0].length) {
|
|
832
|
-
continue;
|
|
833
|
-
}
|
|
834
|
-
if (options.ignore && options.ignore.test(slice)) {
|
|
835
|
-
continue;
|
|
836
|
-
}
|
|
837
|
-
end = start + slice.length;
|
|
838
|
-
var result = callback(slice, start, end, string);
|
|
839
|
-
if (result === undefined) {
|
|
840
|
-
_start.lastIndex = end;
|
|
841
|
-
continue;
|
|
842
|
-
}
|
|
843
|
-
result = String(result);
|
|
844
|
-
string = string.slice(0, start) + result + string.slice(end);
|
|
845
|
-
_start.lastIndex = start + result.length;
|
|
846
|
-
}
|
|
847
|
-
_start.lastIndex = 0;
|
|
848
|
-
return string;
|
|
849
|
-
};
|
|
850
|
-
URI.ensureValidHostname = function (v, protocol) {
|
|
851
|
-
var hasHostname = !!v;
|
|
852
|
-
var hasProtocol = !!protocol;
|
|
853
|
-
var rejectEmptyHostname = false;
|
|
854
|
-
if (hasProtocol) {
|
|
855
|
-
rejectEmptyHostname = arrayContains(URI.hostProtocols, protocol);
|
|
856
|
-
}
|
|
857
|
-
if (rejectEmptyHostname && !hasHostname) {
|
|
858
|
-
throw new TypeError("Hostname cannot be empty, if protocol is " + protocol);
|
|
859
|
-
} else if (v && v.match(URI.invalid_hostname_characters)) {
|
|
860
|
-
if (!punycode) {
|
|
861
|
-
throw new TypeError("Hostname \"" + v + "\" contains characters other than [A-Z0-9.-:_] and Punycode.js is not available");
|
|
862
|
-
}
|
|
863
|
-
if (punycode.toASCII(v).match(URI.invalid_hostname_characters)) {
|
|
864
|
-
throw new TypeError("Hostname \"" + v + "\" contains characters other than [A-Z0-9.-:_]");
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
};
|
|
868
|
-
URI.ensureValidPort = function (v) {
|
|
869
|
-
if (!v) {
|
|
870
|
-
return;
|
|
871
|
-
}
|
|
872
|
-
var port = Number(v);
|
|
873
|
-
if (isInteger(port) && port > 0 && port < 65536) {
|
|
874
|
-
return;
|
|
875
|
-
}
|
|
876
|
-
throw new TypeError("Port \"" + v + "\" is not a valid port");
|
|
877
|
-
};
|
|
878
|
-
URI.noConflict = function (removeAll) {
|
|
879
|
-
if (removeAll) {
|
|
880
|
-
var unconflicted = {
|
|
881
|
-
URI: this.noConflict()
|
|
882
|
-
};
|
|
883
|
-
if (window.URITemplate && typeof window.URITemplate.noConflict === "function") {
|
|
884
|
-
unconflicted.URITemplate = window.URITemplate.noConflict();
|
|
885
|
-
}
|
|
886
|
-
if (window.IPv6 && typeof window.IPv6.noConflict === "function") {
|
|
887
|
-
unconflicted.IPv6 = window.IPv6.noConflict();
|
|
888
|
-
}
|
|
889
|
-
if (window.SecondLevelDomains && typeof window.SecondLevelDomains.noConflict === "function") {
|
|
890
|
-
unconflicted.SecondLevelDomains = window.SecondLevelDomains.noConflict();
|
|
891
|
-
}
|
|
892
|
-
return unconflicted;
|
|
893
|
-
} else if (window.URI === this) {
|
|
894
|
-
window.URI = _URI;
|
|
895
|
-
}
|
|
896
|
-
return this;
|
|
897
|
-
};
|
|
898
|
-
p.build = function (deferBuild) {
|
|
899
|
-
if (deferBuild === true) {
|
|
900
|
-
this._deferred_build = true;
|
|
901
|
-
} else if (deferBuild === undefined || this._deferred_build) {
|
|
902
|
-
this._string = URI.build(this._parts);
|
|
903
|
-
this._deferred_build = false;
|
|
904
|
-
}
|
|
905
|
-
return this;
|
|
906
|
-
};
|
|
907
|
-
p.clone = function () {
|
|
908
|
-
return new URI(this);
|
|
909
|
-
};
|
|
910
|
-
p.valueOf = p.toString = function () {
|
|
911
|
-
return this.build(false)._string;
|
|
912
|
-
};
|
|
913
|
-
function generateSimpleAccessor(_part) {
|
|
914
|
-
return function (v, build) {
|
|
915
|
-
if (v === undefined) {
|
|
916
|
-
return this._parts[_part] || "";
|
|
917
|
-
} else {
|
|
918
|
-
this._parts[_part] = v || null;
|
|
919
|
-
this.build(!build);
|
|
920
|
-
return this;
|
|
921
|
-
}
|
|
922
|
-
};
|
|
923
|
-
}
|
|
924
|
-
function generatePrefixAccessor(_part, _key) {
|
|
925
|
-
return function (v, build) {
|
|
926
|
-
if (v === undefined) {
|
|
927
|
-
return this._parts[_part] || "";
|
|
928
|
-
} else {
|
|
929
|
-
if (v !== null) {
|
|
930
|
-
v = v + "";
|
|
931
|
-
if (v.charAt(0) === _key) {
|
|
932
|
-
v = v.substring(1);
|
|
933
|
-
}
|
|
934
|
-
}
|
|
935
|
-
this._parts[_part] = v;
|
|
936
|
-
this.build(!build);
|
|
937
|
-
return this;
|
|
938
|
-
}
|
|
939
|
-
};
|
|
940
|
-
}
|
|
941
|
-
p.protocol = generateSimpleAccessor("protocol");
|
|
942
|
-
p.username = generateSimpleAccessor("username");
|
|
943
|
-
p.password = generateSimpleAccessor("password");
|
|
944
|
-
p.hostname = generateSimpleAccessor("hostname");
|
|
945
|
-
p.port = generateSimpleAccessor("port");
|
|
946
|
-
p.query = generatePrefixAccessor("query", "?");
|
|
947
|
-
p.fragment = generatePrefixAccessor("fragment", "#");
|
|
948
|
-
p.search = function (v, build) {
|
|
949
|
-
var t = this.query(v, build);
|
|
950
|
-
return typeof t === "string" && t.length ? "?" + t : t;
|
|
951
|
-
};
|
|
952
|
-
p.hash = function (v, build) {
|
|
953
|
-
var t = this.fragment(v, build);
|
|
954
|
-
return typeof t === "string" && t.length ? "#" + t : t;
|
|
955
|
-
};
|
|
956
|
-
p.pathname = function (v, build) {
|
|
957
|
-
if (v === undefined || v === true) {
|
|
958
|
-
var res = this._parts.path || (this._parts.hostname ? "/" : "");
|
|
959
|
-
return v ? (this._parts.urn ? URI.decodeUrnPath : URI.decodePath)(res) : res;
|
|
960
|
-
} else {
|
|
961
|
-
if (this._parts.urn) {
|
|
962
|
-
this._parts.path = v ? URI.recodeUrnPath(v) : "";
|
|
963
|
-
} else {
|
|
964
|
-
this._parts.path = v ? URI.recodePath(v) : "/";
|
|
965
|
-
}
|
|
966
|
-
this.build(!build);
|
|
967
|
-
return this;
|
|
968
|
-
}
|
|
969
|
-
};
|
|
970
|
-
p.path = p.pathname;
|
|
971
|
-
p.href = function (href, build) {
|
|
972
|
-
var key;
|
|
973
|
-
if (href === undefined) {
|
|
974
|
-
return this.toString();
|
|
975
|
-
}
|
|
976
|
-
this._string = "";
|
|
977
|
-
this._parts = URI._parts();
|
|
978
|
-
var _URI = href instanceof URI;
|
|
979
|
-
var _object = typeof href === "object" && (href.hostname || href.path || href.pathname);
|
|
980
|
-
if (href.nodeName) {
|
|
981
|
-
var attribute = URI.getDomAttribute(href);
|
|
982
|
-
href = href[attribute] || "";
|
|
983
|
-
_object = false;
|
|
984
|
-
}
|
|
985
|
-
if (!_URI && _object && href.pathname !== undefined) {
|
|
986
|
-
href = href.toString();
|
|
987
|
-
}
|
|
988
|
-
if (typeof href === "string" || href instanceof String) {
|
|
989
|
-
this._parts = URI.parse(String(href), this._parts);
|
|
990
|
-
} else if (_URI || _object) {
|
|
991
|
-
var src = _URI ? href._parts : href;
|
|
992
|
-
for (key in src) {
|
|
993
|
-
if (key === "query") {
|
|
994
|
-
continue;
|
|
995
|
-
}
|
|
996
|
-
if (hasOwn$1.call(this._parts, key)) {
|
|
997
|
-
this._parts[key] = src[key];
|
|
998
|
-
}
|
|
999
|
-
}
|
|
1000
|
-
if (src.query) {
|
|
1001
|
-
this.query(src.query, false);
|
|
1002
|
-
}
|
|
1003
|
-
} else {
|
|
1004
|
-
throw new TypeError("invalid input");
|
|
1005
|
-
}
|
|
1006
|
-
this.build(!build);
|
|
1007
|
-
return this;
|
|
1008
|
-
};
|
|
1009
|
-
p.is = function (what) {
|
|
1010
|
-
var ip = false;
|
|
1011
|
-
var ip4 = false;
|
|
1012
|
-
var ip6 = false;
|
|
1013
|
-
var name = false;
|
|
1014
|
-
var sld = false;
|
|
1015
|
-
var idn = false;
|
|
1016
|
-
var punycode = false;
|
|
1017
|
-
var relative = !this._parts.urn;
|
|
1018
|
-
if (this._parts.hostname) {
|
|
1019
|
-
relative = false;
|
|
1020
|
-
ip4 = URI.ip4_expression.test(this._parts.hostname);
|
|
1021
|
-
ip6 = URI.ip6_expression.test(this._parts.hostname);
|
|
1022
|
-
ip = ip4 || ip6;
|
|
1023
|
-
name = !ip;
|
|
1024
|
-
sld = name && SLD && SLD.has(this._parts.hostname);
|
|
1025
|
-
idn = name && URI.idn_expression.test(this._parts.hostname);
|
|
1026
|
-
punycode = name && URI.punycode_expression.test(this._parts.hostname);
|
|
1027
|
-
}
|
|
1028
|
-
switch (what.toLowerCase()) {
|
|
1029
|
-
case "relative":
|
|
1030
|
-
return relative;
|
|
1031
|
-
case "absolute":
|
|
1032
|
-
return !relative;
|
|
1033
|
-
case "domain":
|
|
1034
|
-
case "name":
|
|
1035
|
-
return name;
|
|
1036
|
-
case "sld":
|
|
1037
|
-
return sld;
|
|
1038
|
-
case "ip":
|
|
1039
|
-
return ip;
|
|
1040
|
-
case "ip4":
|
|
1041
|
-
case "ipv4":
|
|
1042
|
-
case "inet4":
|
|
1043
|
-
return ip4;
|
|
1044
|
-
case "ip6":
|
|
1045
|
-
case "ipv6":
|
|
1046
|
-
case "inet6":
|
|
1047
|
-
return ip6;
|
|
1048
|
-
case "idn":
|
|
1049
|
-
return idn;
|
|
1050
|
-
case "url":
|
|
1051
|
-
return !this._parts.urn;
|
|
1052
|
-
case "urn":
|
|
1053
|
-
return !!this._parts.urn;
|
|
1054
|
-
case "punycode":
|
|
1055
|
-
return punycode;
|
|
1056
|
-
}
|
|
1057
|
-
return null;
|
|
1058
|
-
};
|
|
1059
|
-
var _protocol = p.protocol;
|
|
1060
|
-
var _port = p.port;
|
|
1061
|
-
var _hostname = p.hostname;
|
|
1062
|
-
p.protocol = function (v, build) {
|
|
1063
|
-
if (v) {
|
|
1064
|
-
v = v.replace(/:(\/\/)?$/, "");
|
|
1065
|
-
if (!v.match(URI.protocol_expression)) {
|
|
1066
|
-
throw new TypeError("Protocol \"" + v + "\" contains characters other than [A-Z0-9.+-] or doesn't start with [A-Z]");
|
|
1067
|
-
}
|
|
1068
|
-
}
|
|
1069
|
-
return _protocol.call(this, v, build);
|
|
1070
|
-
};
|
|
1071
|
-
p.scheme = p.protocol;
|
|
1072
|
-
p.port = function (v, build) {
|
|
1073
|
-
if (this._parts.urn) {
|
|
1074
|
-
return v === undefined ? "" : this;
|
|
1075
|
-
}
|
|
1076
|
-
if (v !== undefined) {
|
|
1077
|
-
if (v === 0) {
|
|
1078
|
-
v = null;
|
|
1079
|
-
}
|
|
1080
|
-
if (v) {
|
|
1081
|
-
v += "";
|
|
1082
|
-
if (v.charAt(0) === ":") {
|
|
1083
|
-
v = v.substring(1);
|
|
1084
|
-
}
|
|
1085
|
-
URI.ensureValidPort(v);
|
|
1086
|
-
}
|
|
1087
|
-
}
|
|
1088
|
-
return _port.call(this, v, build);
|
|
1089
|
-
};
|
|
1090
|
-
p.hostname = function (v, build) {
|
|
1091
|
-
if (this._parts.urn) {
|
|
1092
|
-
return v === undefined ? "" : this;
|
|
1093
|
-
}
|
|
1094
|
-
if (v !== undefined) {
|
|
1095
|
-
var x = {
|
|
1096
|
-
preventInvalidHostname: this._parts.preventInvalidHostname
|
|
1097
|
-
};
|
|
1098
|
-
var res = URI.parseHost(v, x);
|
|
1099
|
-
if (res !== "/") {
|
|
1100
|
-
throw new TypeError("Hostname \"" + v + "\" contains characters other than [A-Z0-9.-]");
|
|
1101
|
-
}
|
|
1102
|
-
v = x.hostname;
|
|
1103
|
-
if (this._parts.preventInvalidHostname) {
|
|
1104
|
-
URI.ensureValidHostname(v, this._parts.protocol);
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
return _hostname.call(this, v, build);
|
|
1108
|
-
};
|
|
1109
|
-
p.origin = function (v, build) {
|
|
1110
|
-
if (this._parts.urn) {
|
|
1111
|
-
return v === undefined ? "" : this;
|
|
1112
|
-
}
|
|
1113
|
-
if (v === undefined) {
|
|
1114
|
-
var protocol = this.protocol();
|
|
1115
|
-
var authority = this.authority();
|
|
1116
|
-
if (!authority) {
|
|
1117
|
-
return "";
|
|
1118
|
-
}
|
|
1119
|
-
return (protocol ? protocol + "://" : "") + this.authority();
|
|
1120
|
-
} else {
|
|
1121
|
-
var origin = URI(v);
|
|
1122
|
-
this.protocol(origin.protocol()).authority(origin.authority()).build(!build);
|
|
1123
|
-
return this;
|
|
1124
|
-
}
|
|
1125
|
-
};
|
|
1126
|
-
p.host = function (v, build) {
|
|
1127
|
-
if (this._parts.urn) {
|
|
1128
|
-
return v === undefined ? "" : this;
|
|
1129
|
-
}
|
|
1130
|
-
if (v === undefined) {
|
|
1131
|
-
return this._parts.hostname ? URI.buildHost(this._parts) : "";
|
|
1132
|
-
} else {
|
|
1133
|
-
var res = URI.parseHost(v, this._parts);
|
|
1134
|
-
if (res !== "/") {
|
|
1135
|
-
throw new TypeError("Hostname \"" + v + "\" contains characters other than [A-Z0-9.-]");
|
|
1136
|
-
}
|
|
1137
|
-
this.build(!build);
|
|
1138
|
-
return this;
|
|
1139
|
-
}
|
|
1140
|
-
};
|
|
1141
|
-
p.authority = function (v, build) {
|
|
1142
|
-
if (this._parts.urn) {
|
|
1143
|
-
return v === undefined ? "" : this;
|
|
1144
|
-
}
|
|
1145
|
-
if (v === undefined) {
|
|
1146
|
-
return this._parts.hostname ? URI.buildAuthority(this._parts) : "";
|
|
1147
|
-
} else {
|
|
1148
|
-
var res = URI.parseAuthority(v, this._parts);
|
|
1149
|
-
if (res !== "/") {
|
|
1150
|
-
throw new TypeError("Hostname \"" + v + "\" contains characters other than [A-Z0-9.-]");
|
|
1151
|
-
}
|
|
1152
|
-
this.build(!build);
|
|
1153
|
-
return this;
|
|
1154
|
-
}
|
|
1155
|
-
};
|
|
1156
|
-
p.userinfo = function (v, build) {
|
|
1157
|
-
if (this._parts.urn) {
|
|
1158
|
-
return v === undefined ? "" : this;
|
|
1159
|
-
}
|
|
1160
|
-
if (v === undefined) {
|
|
1161
|
-
var t = URI.buildUserinfo(this._parts);
|
|
1162
|
-
return t ? t.substring(0, t.length - 1) : t;
|
|
1163
|
-
} else {
|
|
1164
|
-
if (v[v.length - 1] !== "@") {
|
|
1165
|
-
v += "@";
|
|
1166
|
-
}
|
|
1167
|
-
URI.parseUserinfo(v, this._parts);
|
|
1168
|
-
this.build(!build);
|
|
1169
|
-
return this;
|
|
1170
|
-
}
|
|
1171
|
-
};
|
|
1172
|
-
p.resource = function (v, build) {
|
|
1173
|
-
var parts;
|
|
1174
|
-
if (v === undefined) {
|
|
1175
|
-
return this.path() + this.search() + this.hash();
|
|
1176
|
-
}
|
|
1177
|
-
parts = URI.parse(v);
|
|
1178
|
-
this._parts.path = parts.path;
|
|
1179
|
-
this._parts.query = parts.query;
|
|
1180
|
-
this._parts.fragment = parts.fragment;
|
|
1181
|
-
this.build(!build);
|
|
1182
|
-
return this;
|
|
1183
|
-
};
|
|
1184
|
-
p.subdomain = function (v, build) {
|
|
1185
|
-
if (this._parts.urn) {
|
|
1186
|
-
return v === undefined ? "" : this;
|
|
1187
|
-
}
|
|
1188
|
-
if (v === undefined) {
|
|
1189
|
-
if (!this._parts.hostname || this.is("IP")) {
|
|
1190
|
-
return "";
|
|
1191
|
-
}
|
|
1192
|
-
var end = this._parts.hostname.length - this.domain().length - 1;
|
|
1193
|
-
return this._parts.hostname.substring(0, end) || "";
|
|
1194
|
-
} else {
|
|
1195
|
-
var e = this._parts.hostname.length - this.domain().length;
|
|
1196
|
-
var sub = this._parts.hostname.substring(0, e);
|
|
1197
|
-
var replace = new RegExp("^" + escapeRegEx(sub));
|
|
1198
|
-
if (v && v.charAt(v.length - 1) !== ".") {
|
|
1199
|
-
v += ".";
|
|
1200
|
-
}
|
|
1201
|
-
if (v.indexOf(":") !== -1) {
|
|
1202
|
-
throw new TypeError("Domains cannot contain colons");
|
|
1203
|
-
}
|
|
1204
|
-
if (v) {
|
|
1205
|
-
URI.ensureValidHostname(v, this._parts.protocol);
|
|
1206
|
-
}
|
|
1207
|
-
this._parts.hostname = this._parts.hostname.replace(replace, v);
|
|
1208
|
-
this.build(!build);
|
|
1209
|
-
return this;
|
|
1210
|
-
}
|
|
1211
|
-
};
|
|
1212
|
-
p.domain = function (v, build) {
|
|
1213
|
-
if (this._parts.urn) {
|
|
1214
|
-
return v === undefined ? "" : this;
|
|
1215
|
-
}
|
|
1216
|
-
if (typeof v === "boolean") {
|
|
1217
|
-
build = v;
|
|
1218
|
-
v = undefined;
|
|
1219
|
-
}
|
|
1220
|
-
if (v === undefined) {
|
|
1221
|
-
if (!this._parts.hostname || this.is("IP")) {
|
|
1222
|
-
return "";
|
|
1223
|
-
}
|
|
1224
|
-
var t = this._parts.hostname.match(/\./g);
|
|
1225
|
-
if (t && t.length < 2) {
|
|
1226
|
-
return this._parts.hostname;
|
|
1227
|
-
}
|
|
1228
|
-
var end = this._parts.hostname.length - this.tld(build).length - 1;
|
|
1229
|
-
end = this._parts.hostname.lastIndexOf(".", end - 1) + 1;
|
|
1230
|
-
return this._parts.hostname.substring(end) || "";
|
|
1231
|
-
} else {
|
|
1232
|
-
if (!v) {
|
|
1233
|
-
throw new TypeError("cannot set domain empty");
|
|
1234
|
-
}
|
|
1235
|
-
if (v.indexOf(":") !== -1) {
|
|
1236
|
-
throw new TypeError("Domains cannot contain colons");
|
|
1237
|
-
}
|
|
1238
|
-
URI.ensureValidHostname(v, this._parts.protocol);
|
|
1239
|
-
if (!this._parts.hostname || this.is("IP")) {
|
|
1240
|
-
this._parts.hostname = v;
|
|
1241
|
-
} else {
|
|
1242
|
-
var replace = new RegExp(escapeRegEx(this.domain()) + "$");
|
|
1243
|
-
this._parts.hostname = this._parts.hostname.replace(replace, v);
|
|
1244
|
-
}
|
|
1245
|
-
this.build(!build);
|
|
1246
|
-
return this;
|
|
1247
|
-
}
|
|
1248
|
-
};
|
|
1249
|
-
p.tld = function (v, build) {
|
|
1250
|
-
if (this._parts.urn) {
|
|
1251
|
-
return v === undefined ? "" : this;
|
|
1252
|
-
}
|
|
1253
|
-
if (typeof v === "boolean") {
|
|
1254
|
-
build = v;
|
|
1255
|
-
v = undefined;
|
|
1256
|
-
}
|
|
1257
|
-
if (v === undefined) {
|
|
1258
|
-
if (!this._parts.hostname || this.is("IP")) {
|
|
1259
|
-
return "";
|
|
1260
|
-
}
|
|
1261
|
-
var pos = this._parts.hostname.lastIndexOf(".");
|
|
1262
|
-
var tld = this._parts.hostname.substring(pos + 1);
|
|
1263
|
-
if (build !== true && SLD && SLD.list[tld.toLowerCase()]) {
|
|
1264
|
-
return SLD.get(this._parts.hostname) || tld;
|
|
1265
|
-
}
|
|
1266
|
-
return tld;
|
|
1267
|
-
} else {
|
|
1268
|
-
var replace;
|
|
1269
|
-
if (!v) {
|
|
1270
|
-
throw new TypeError("cannot set TLD empty");
|
|
1271
|
-
} else if (v.match(/[^a-zA-Z0-9-]/)) {
|
|
1272
|
-
if (SLD && SLD.is(v)) {
|
|
1273
|
-
replace = new RegExp(escapeRegEx(this.tld()) + "$");
|
|
1274
|
-
this._parts.hostname = this._parts.hostname.replace(replace, v);
|
|
1275
|
-
} else {
|
|
1276
|
-
throw new TypeError("TLD \"" + v + "\" contains characters other than [A-Z0-9]");
|
|
1277
|
-
}
|
|
1278
|
-
} else if (!this._parts.hostname || this.is("IP")) {
|
|
1279
|
-
throw new ReferenceError("cannot set TLD on non-domain host");
|
|
1280
|
-
} else {
|
|
1281
|
-
replace = new RegExp(escapeRegEx(this.tld()) + "$");
|
|
1282
|
-
this._parts.hostname = this._parts.hostname.replace(replace, v);
|
|
1283
|
-
}
|
|
1284
|
-
this.build(!build);
|
|
1285
|
-
return this;
|
|
1286
|
-
}
|
|
1287
|
-
};
|
|
1288
|
-
p.directory = function (v, build) {
|
|
1289
|
-
if (this._parts.urn) {
|
|
1290
|
-
return v === undefined ? "" : this;
|
|
1291
|
-
}
|
|
1292
|
-
if (v === undefined || v === true) {
|
|
1293
|
-
if (!this._parts.path && !this._parts.hostname) {
|
|
1294
|
-
return "";
|
|
1295
|
-
}
|
|
1296
|
-
if (this._parts.path === "/") {
|
|
1297
|
-
return "/";
|
|
1298
|
-
}
|
|
1299
|
-
var end = this._parts.path.length - this.filename().length - 1;
|
|
1300
|
-
var res = this._parts.path.substring(0, end) || (this._parts.hostname ? "/" : "");
|
|
1301
|
-
return v ? URI.decodePath(res) : res;
|
|
1302
|
-
} else {
|
|
1303
|
-
var e = this._parts.path.length - this.filename().length;
|
|
1304
|
-
var directory = this._parts.path.substring(0, e);
|
|
1305
|
-
var replace = new RegExp("^" + escapeRegEx(directory));
|
|
1306
|
-
if (!this.is("relative")) {
|
|
1307
|
-
if (!v) {
|
|
1308
|
-
v = "/";
|
|
1309
|
-
}
|
|
1310
|
-
if (v.charAt(0) !== "/") {
|
|
1311
|
-
v = "/" + v;
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
if (v && v.charAt(v.length - 1) !== "/") {
|
|
1315
|
-
v += "/";
|
|
1316
|
-
}
|
|
1317
|
-
v = URI.recodePath(v);
|
|
1318
|
-
this._parts.path = this._parts.path.replace(replace, v);
|
|
1319
|
-
this.build(!build);
|
|
1320
|
-
return this;
|
|
1321
|
-
}
|
|
1322
|
-
};
|
|
1323
|
-
p.filename = function (v, build) {
|
|
1324
|
-
if (this._parts.urn) {
|
|
1325
|
-
return v === undefined ? "" : this;
|
|
1326
|
-
}
|
|
1327
|
-
if (typeof v !== "string") {
|
|
1328
|
-
if (!this._parts.path || this._parts.path === "/") {
|
|
1329
|
-
return "";
|
|
1330
|
-
}
|
|
1331
|
-
var pos = this._parts.path.lastIndexOf("/");
|
|
1332
|
-
var res = this._parts.path.substring(pos + 1);
|
|
1333
|
-
return v ? URI.decodePathSegment(res) : res;
|
|
1334
|
-
} else {
|
|
1335
|
-
var mutatedDirectory = false;
|
|
1336
|
-
if (v.charAt(0) === "/") {
|
|
1337
|
-
v = v.substring(1);
|
|
1338
|
-
}
|
|
1339
|
-
if (v.match(/\.?\//)) {
|
|
1340
|
-
mutatedDirectory = true;
|
|
1341
|
-
}
|
|
1342
|
-
var replace = new RegExp(escapeRegEx(this.filename()) + "$");
|
|
1343
|
-
v = URI.recodePath(v);
|
|
1344
|
-
this._parts.path = this._parts.path.replace(replace, v);
|
|
1345
|
-
if (mutatedDirectory) {
|
|
1346
|
-
this.normalizePath(build);
|
|
1347
|
-
} else {
|
|
1348
|
-
this.build(!build);
|
|
1349
|
-
}
|
|
1350
|
-
return this;
|
|
1351
|
-
}
|
|
1352
|
-
};
|
|
1353
|
-
p.suffix = function (v, build) {
|
|
1354
|
-
if (this._parts.urn) {
|
|
1355
|
-
return v === undefined ? "" : this;
|
|
1356
|
-
}
|
|
1357
|
-
if (v === undefined || v === true) {
|
|
1358
|
-
if (!this._parts.path || this._parts.path === "/") {
|
|
1359
|
-
return "";
|
|
1360
|
-
}
|
|
1361
|
-
var filename = this.filename();
|
|
1362
|
-
var pos = filename.lastIndexOf(".");
|
|
1363
|
-
var s, res;
|
|
1364
|
-
if (pos === -1) {
|
|
1365
|
-
return "";
|
|
1366
|
-
}
|
|
1367
|
-
s = filename.substring(pos + 1);
|
|
1368
|
-
res = (/^[a-z0-9%]+$/i).test(s) ? s : "";
|
|
1369
|
-
return v ? URI.decodePathSegment(res) : res;
|
|
1370
|
-
} else {
|
|
1371
|
-
if (v.charAt(0) === ".") {
|
|
1372
|
-
v = v.substring(1);
|
|
1373
|
-
}
|
|
1374
|
-
var suffix = this.suffix();
|
|
1375
|
-
var replace;
|
|
1376
|
-
if (!suffix) {
|
|
1377
|
-
if (!v) {
|
|
1378
|
-
return this;
|
|
1379
|
-
}
|
|
1380
|
-
this._parts.path += "." + URI.recodePath(v);
|
|
1381
|
-
} else if (!v) {
|
|
1382
|
-
replace = new RegExp(escapeRegEx("." + suffix) + "$");
|
|
1383
|
-
} else {
|
|
1384
|
-
replace = new RegExp(escapeRegEx(suffix) + "$");
|
|
1385
|
-
}
|
|
1386
|
-
if (replace) {
|
|
1387
|
-
v = URI.recodePath(v);
|
|
1388
|
-
this._parts.path = this._parts.path.replace(replace, v);
|
|
1389
|
-
}
|
|
1390
|
-
this.build(!build);
|
|
1391
|
-
return this;
|
|
1392
|
-
}
|
|
1393
|
-
};
|
|
1394
|
-
p.segment = function (segment, v, build) {
|
|
1395
|
-
var separator = this._parts.urn ? ":" : "/";
|
|
1396
|
-
var path = this.path();
|
|
1397
|
-
var absolute = path.substring(0, 1) === "/";
|
|
1398
|
-
var segments = path.split(separator);
|
|
1399
|
-
if (segment !== undefined && typeof segment !== "number") {
|
|
1400
|
-
build = v;
|
|
1401
|
-
v = segment;
|
|
1402
|
-
segment = undefined;
|
|
1403
|
-
}
|
|
1404
|
-
if (segment !== undefined && typeof segment !== "number") {
|
|
1405
|
-
throw new Error("Bad segment \"" + segment + "\", must be 0-based integer");
|
|
1406
|
-
}
|
|
1407
|
-
if (absolute) {
|
|
1408
|
-
segments.shift();
|
|
1409
|
-
}
|
|
1410
|
-
if (segment < 0) {
|
|
1411
|
-
segment = Math.max(segments.length + segment, 0);
|
|
1412
|
-
}
|
|
1413
|
-
if (v === undefined) {
|
|
1414
|
-
return segment === undefined ? segments : segments[segment];
|
|
1415
|
-
} else if (segment === null || segments[segment] === undefined) {
|
|
1416
|
-
if (isArray(v)) {
|
|
1417
|
-
segments = [];
|
|
1418
|
-
for (var i = 0, l = v.length; i < l; i++) {
|
|
1419
|
-
if (!v[i].length && (!segments.length || !segments[segments.length - 1].length)) {
|
|
1420
|
-
continue;
|
|
1421
|
-
}
|
|
1422
|
-
if (segments.length && !segments[segments.length - 1].length) {
|
|
1423
|
-
segments.pop();
|
|
1424
|
-
}
|
|
1425
|
-
segments.push(trimSlashes(v[i]));
|
|
1426
|
-
}
|
|
1427
|
-
} else if (v || typeof v === "string") {
|
|
1428
|
-
v = trimSlashes(v);
|
|
1429
|
-
if (segments[segments.length - 1] === "") {
|
|
1430
|
-
segments[segments.length - 1] = v;
|
|
1431
|
-
} else {
|
|
1432
|
-
segments.push(v);
|
|
1433
|
-
}
|
|
1434
|
-
}
|
|
1435
|
-
} else {
|
|
1436
|
-
if (v) {
|
|
1437
|
-
segments[segment] = trimSlashes(v);
|
|
1438
|
-
} else {
|
|
1439
|
-
segments.splice(segment, 1);
|
|
1440
|
-
}
|
|
1441
|
-
}
|
|
1442
|
-
if (absolute) {
|
|
1443
|
-
segments.unshift("");
|
|
1444
|
-
}
|
|
1445
|
-
return this.path(segments.join(separator), build);
|
|
1446
|
-
};
|
|
1447
|
-
p.segmentCoded = function (segment, v, build) {
|
|
1448
|
-
var segments, i, l;
|
|
1449
|
-
if (typeof segment !== "number") {
|
|
1450
|
-
build = v;
|
|
1451
|
-
v = segment;
|
|
1452
|
-
segment = undefined;
|
|
1453
|
-
}
|
|
1454
|
-
if (v === undefined) {
|
|
1455
|
-
segments = this.segment(segment, v, build);
|
|
1456
|
-
if (!isArray(segments)) {
|
|
1457
|
-
segments = segments !== undefined ? URI.decode(segments) : undefined;
|
|
1458
|
-
} else {
|
|
1459
|
-
for ((i = 0, l = segments.length); i < l; i++) {
|
|
1460
|
-
segments[i] = URI.decode(segments[i]);
|
|
1461
|
-
}
|
|
1462
|
-
}
|
|
1463
|
-
return segments;
|
|
1464
|
-
}
|
|
1465
|
-
if (!isArray(v)) {
|
|
1466
|
-
v = typeof v === "string" || v instanceof String ? URI.encode(v) : v;
|
|
1467
|
-
} else {
|
|
1468
|
-
for ((i = 0, l = v.length); i < l; i++) {
|
|
1469
|
-
v[i] = URI.encode(v[i]);
|
|
1470
|
-
}
|
|
1471
|
-
}
|
|
1472
|
-
return this.segment(segment, v, build);
|
|
1473
|
-
};
|
|
1474
|
-
var q = p.query;
|
|
1475
|
-
p.query = function (v, build) {
|
|
1476
|
-
if (v === true) {
|
|
1477
|
-
return URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
|
1478
|
-
} else if (typeof v === "function") {
|
|
1479
|
-
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
|
1480
|
-
var result = v.call(this, data);
|
|
1481
|
-
this._parts.query = URI.buildQuery(result || data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
|
|
1482
|
-
this.build(!build);
|
|
1483
|
-
return this;
|
|
1484
|
-
} else if (v !== undefined && typeof v !== "string") {
|
|
1485
|
-
this._parts.query = URI.buildQuery(v, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
|
|
1486
|
-
this.build(!build);
|
|
1487
|
-
return this;
|
|
1488
|
-
} else {
|
|
1489
|
-
return q.call(this, v, build);
|
|
1490
|
-
}
|
|
1491
|
-
};
|
|
1492
|
-
p.setQuery = function (name, value, build) {
|
|
1493
|
-
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
|
1494
|
-
if (typeof name === "string" || name instanceof String) {
|
|
1495
|
-
data[name] = value !== undefined ? value : null;
|
|
1496
|
-
} else if (typeof name === "object") {
|
|
1497
|
-
for (var key in name) {
|
|
1498
|
-
if (hasOwn$1.call(name, key)) {
|
|
1499
|
-
data[key] = name[key];
|
|
1500
|
-
}
|
|
1501
|
-
}
|
|
1502
|
-
} else {
|
|
1503
|
-
throw new TypeError("URI.addQuery() accepts an object, string as the name parameter");
|
|
1504
|
-
}
|
|
1505
|
-
this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
|
|
1506
|
-
if (typeof name !== "string") {
|
|
1507
|
-
build = value;
|
|
1508
|
-
}
|
|
1509
|
-
this.build(!build);
|
|
1510
|
-
return this;
|
|
1511
|
-
};
|
|
1512
|
-
p.addQuery = function (name, value, build) {
|
|
1513
|
-
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
|
1514
|
-
URI.addQuery(data, name, value === undefined ? null : value);
|
|
1515
|
-
this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
|
|
1516
|
-
if (typeof name !== "string") {
|
|
1517
|
-
build = value;
|
|
1518
|
-
}
|
|
1519
|
-
this.build(!build);
|
|
1520
|
-
return this;
|
|
1521
|
-
};
|
|
1522
|
-
p.removeQuery = function (name, value, build) {
|
|
1523
|
-
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
|
1524
|
-
URI.removeQuery(data, name, value);
|
|
1525
|
-
this._parts.query = URI.buildQuery(data, this._parts.duplicateQueryParameters, this._parts.escapeQuerySpace);
|
|
1526
|
-
if (typeof name !== "string") {
|
|
1527
|
-
build = value;
|
|
1528
|
-
}
|
|
1529
|
-
this.build(!build);
|
|
1530
|
-
return this;
|
|
1531
|
-
};
|
|
1532
|
-
p.hasQuery = function (name, value, withinArray) {
|
|
1533
|
-
var data = URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace);
|
|
1534
|
-
return URI.hasQuery(data, name, value, withinArray);
|
|
1535
|
-
};
|
|
1536
|
-
p.setSearch = p.setQuery;
|
|
1537
|
-
p.addSearch = p.addQuery;
|
|
1538
|
-
p.removeSearch = p.removeQuery;
|
|
1539
|
-
p.hasSearch = p.hasQuery;
|
|
1540
|
-
p.normalize = function () {
|
|
1541
|
-
if (this._parts.urn) {
|
|
1542
|
-
return this.normalizeProtocol(false).normalizePath(false).normalizeQuery(false).normalizeFragment(false).build();
|
|
1543
|
-
}
|
|
1544
|
-
return this.normalizeProtocol(false).normalizeHostname(false).normalizePort(false).normalizePath(false).normalizeQuery(false).normalizeFragment(false).build();
|
|
1545
|
-
};
|
|
1546
|
-
p.normalizeProtocol = function (build) {
|
|
1547
|
-
if (typeof this._parts.protocol === "string") {
|
|
1548
|
-
this._parts.protocol = this._parts.protocol.toLowerCase();
|
|
1549
|
-
this.build(!build);
|
|
1550
|
-
}
|
|
1551
|
-
return this;
|
|
1552
|
-
};
|
|
1553
|
-
p.normalizeHostname = function (build) {
|
|
1554
|
-
if (this._parts.hostname) {
|
|
1555
|
-
if (this.is("IDN") && punycode) {
|
|
1556
|
-
this._parts.hostname = punycode.toASCII(this._parts.hostname);
|
|
1557
|
-
} else if (this.is("IPv6") && IPv6) {
|
|
1558
|
-
this._parts.hostname = IPv6.best(this._parts.hostname);
|
|
1559
|
-
}
|
|
1560
|
-
this._parts.hostname = this._parts.hostname.toLowerCase();
|
|
1561
|
-
this.build(!build);
|
|
1562
|
-
}
|
|
1563
|
-
return this;
|
|
1564
|
-
};
|
|
1565
|
-
p.normalizePort = function (build) {
|
|
1566
|
-
if (typeof this._parts.protocol === "string" && this._parts.port === URI.defaultPorts[this._parts.protocol]) {
|
|
1567
|
-
this._parts.port = null;
|
|
1568
|
-
this.build(!build);
|
|
1569
|
-
}
|
|
1570
|
-
return this;
|
|
1571
|
-
};
|
|
1572
|
-
p.normalizePath = function (build) {
|
|
1573
|
-
var _path = this._parts.path;
|
|
1574
|
-
if (!_path) {
|
|
1575
|
-
return this;
|
|
1576
|
-
}
|
|
1577
|
-
if (this._parts.urn) {
|
|
1578
|
-
this._parts.path = URI.recodeUrnPath(this._parts.path);
|
|
1579
|
-
this.build(!build);
|
|
1580
|
-
return this;
|
|
1581
|
-
}
|
|
1582
|
-
if (this._parts.path === "/") {
|
|
1583
|
-
return this;
|
|
1584
|
-
}
|
|
1585
|
-
_path = URI.recodePath(_path);
|
|
1586
|
-
var _was_relative;
|
|
1587
|
-
var _leadingParents = "";
|
|
1588
|
-
var _parent, _pos;
|
|
1589
|
-
if (_path.charAt(0) !== "/") {
|
|
1590
|
-
_was_relative = true;
|
|
1591
|
-
_path = "/" + _path;
|
|
1592
|
-
}
|
|
1593
|
-
if (_path.slice(-3) === "/.." || _path.slice(-2) === "/.") {
|
|
1594
|
-
_path += "/";
|
|
1595
|
-
}
|
|
1596
|
-
_path = _path.replace(/(\/(\.\/)+)|(\/\.$)/g, "/").replace(/\/{2,}/g, "/");
|
|
1597
|
-
if (_was_relative) {
|
|
1598
|
-
_leadingParents = _path.substring(1).match(/^(\.\.\/)+/) || "";
|
|
1599
|
-
if (_leadingParents) {
|
|
1600
|
-
_leadingParents = _leadingParents[0];
|
|
1601
|
-
}
|
|
1602
|
-
}
|
|
1603
|
-
while (true) {
|
|
1604
|
-
_parent = _path.search(/\/\.\.(\/|$)/);
|
|
1605
|
-
if (_parent === -1) {
|
|
1606
|
-
break;
|
|
1607
|
-
} else if (_parent === 0) {
|
|
1608
|
-
_path = _path.substring(3);
|
|
1609
|
-
continue;
|
|
1610
|
-
}
|
|
1611
|
-
_pos = _path.substring(0, _parent).lastIndexOf("/");
|
|
1612
|
-
if (_pos === -1) {
|
|
1613
|
-
_pos = _parent;
|
|
1614
|
-
}
|
|
1615
|
-
_path = _path.substring(0, _pos) + _path.substring(_parent + 3);
|
|
1616
|
-
}
|
|
1617
|
-
if (_was_relative && this.is("relative")) {
|
|
1618
|
-
_path = _leadingParents + _path.substring(1);
|
|
1619
|
-
}
|
|
1620
|
-
this._parts.path = _path;
|
|
1621
|
-
this.build(!build);
|
|
1622
|
-
return this;
|
|
1623
|
-
};
|
|
1624
|
-
p.normalizePathname = p.normalizePath;
|
|
1625
|
-
p.normalizeQuery = function (build) {
|
|
1626
|
-
if (typeof this._parts.query === "string") {
|
|
1627
|
-
if (!this._parts.query.length) {
|
|
1628
|
-
this._parts.query = null;
|
|
1629
|
-
} else {
|
|
1630
|
-
this.query(URI.parseQuery(this._parts.query, this._parts.escapeQuerySpace));
|
|
1631
|
-
}
|
|
1632
|
-
this.build(!build);
|
|
1633
|
-
}
|
|
1634
|
-
return this;
|
|
1635
|
-
};
|
|
1636
|
-
p.normalizeFragment = function (build) {
|
|
1637
|
-
if (!this._parts.fragment) {
|
|
1638
|
-
this._parts.fragment = null;
|
|
1639
|
-
this.build(!build);
|
|
1640
|
-
}
|
|
1641
|
-
return this;
|
|
1642
|
-
};
|
|
1643
|
-
p.normalizeSearch = p.normalizeQuery;
|
|
1644
|
-
p.normalizeHash = p.normalizeFragment;
|
|
1645
|
-
p.iso8859 = function () {
|
|
1646
|
-
var e = URI.encode;
|
|
1647
|
-
var d = URI.decode;
|
|
1648
|
-
URI.encode = escape;
|
|
1649
|
-
URI.decode = decodeURIComponent;
|
|
1650
|
-
try {
|
|
1651
|
-
this.normalize();
|
|
1652
|
-
} finally {
|
|
1653
|
-
URI.encode = e;
|
|
1654
|
-
URI.decode = d;
|
|
1655
|
-
}
|
|
1656
|
-
return this;
|
|
1657
|
-
};
|
|
1658
|
-
p.unicode = function () {
|
|
1659
|
-
var e = URI.encode;
|
|
1660
|
-
var d = URI.decode;
|
|
1661
|
-
URI.encode = strictEncodeURIComponent;
|
|
1662
|
-
URI.decode = unescape;
|
|
1663
|
-
try {
|
|
1664
|
-
this.normalize();
|
|
1665
|
-
} finally {
|
|
1666
|
-
URI.encode = e;
|
|
1667
|
-
URI.decode = d;
|
|
1668
|
-
}
|
|
1669
|
-
return this;
|
|
1670
|
-
};
|
|
1671
|
-
p.readable = function () {
|
|
1672
|
-
var uri = this.clone();
|
|
1673
|
-
uri.username("").password("").normalize();
|
|
1674
|
-
var t = "";
|
|
1675
|
-
if (uri._parts.protocol) {
|
|
1676
|
-
t += uri._parts.protocol + "://";
|
|
1677
|
-
}
|
|
1678
|
-
if (uri._parts.hostname) {
|
|
1679
|
-
if (uri.is("punycode") && punycode) {
|
|
1680
|
-
t += punycode.toUnicode(uri._parts.hostname);
|
|
1681
|
-
if (uri._parts.port) {
|
|
1682
|
-
t += ":" + uri._parts.port;
|
|
1683
|
-
}
|
|
1684
|
-
} else {
|
|
1685
|
-
t += uri.host();
|
|
1686
|
-
}
|
|
1687
|
-
}
|
|
1688
|
-
if (uri._parts.hostname && uri._parts.path && uri._parts.path.charAt(0) !== "/") {
|
|
1689
|
-
t += "/";
|
|
1690
|
-
}
|
|
1691
|
-
t += uri.path(true);
|
|
1692
|
-
if (uri._parts.query) {
|
|
1693
|
-
var q = "";
|
|
1694
|
-
for (var i = 0, qp = uri._parts.query.split("&"), l = qp.length; i < l; i++) {
|
|
1695
|
-
var kv = (qp[i] || "").split("=");
|
|
1696
|
-
q += "&" + URI.decodeQuery(kv[0], this._parts.escapeQuerySpace).replace(/&/g, "%26");
|
|
1697
|
-
if (kv[1] !== undefined) {
|
|
1698
|
-
q += "=" + URI.decodeQuery(kv[1], this._parts.escapeQuerySpace).replace(/&/g, "%26");
|
|
1699
|
-
}
|
|
1700
|
-
}
|
|
1701
|
-
t += "?" + q.substring(1);
|
|
1702
|
-
}
|
|
1703
|
-
t += URI.decodeQuery(uri.hash(), true);
|
|
1704
|
-
return t;
|
|
1705
|
-
};
|
|
1706
|
-
p.absoluteTo = function (base) {
|
|
1707
|
-
var resolved = this.clone();
|
|
1708
|
-
var properties = ["protocol", "username", "password", "hostname", "port"];
|
|
1709
|
-
var basedir, i, p;
|
|
1710
|
-
if (this._parts.urn) {
|
|
1711
|
-
throw new Error("URNs do not have any generally defined hierarchical components");
|
|
1712
|
-
}
|
|
1713
|
-
if (!(base instanceof URI)) {
|
|
1714
|
-
base = new URI(base);
|
|
1715
|
-
}
|
|
1716
|
-
if (resolved._parts.protocol) {
|
|
1717
|
-
return resolved;
|
|
1718
|
-
} else {
|
|
1719
|
-
resolved._parts.protocol = base._parts.protocol;
|
|
1720
|
-
}
|
|
1721
|
-
if (this._parts.hostname) {
|
|
1722
|
-
return resolved;
|
|
1723
|
-
}
|
|
1724
|
-
for (i = 0; p = properties[i]; i++) {
|
|
1725
|
-
resolved._parts[p] = base._parts[p];
|
|
1726
|
-
}
|
|
1727
|
-
if (!resolved._parts.path) {
|
|
1728
|
-
resolved._parts.path = base._parts.path;
|
|
1729
|
-
if (!resolved._parts.query) {
|
|
1730
|
-
resolved._parts.query = base._parts.query;
|
|
1731
|
-
}
|
|
1732
|
-
} else {
|
|
1733
|
-
if (resolved._parts.path.substring(-2) === "..") {
|
|
1734
|
-
resolved._parts.path += "/";
|
|
1735
|
-
}
|
|
1736
|
-
if (resolved.path().charAt(0) !== "/") {
|
|
1737
|
-
basedir = base.directory();
|
|
1738
|
-
basedir = basedir ? basedir : base.path().indexOf("/") === 0 ? "/" : "";
|
|
1739
|
-
resolved._parts.path = (basedir ? basedir + "/" : "") + resolved._parts.path;
|
|
1740
|
-
resolved.normalizePath();
|
|
1741
|
-
}
|
|
1742
|
-
}
|
|
1743
|
-
resolved.build();
|
|
1744
|
-
return resolved;
|
|
1745
|
-
};
|
|
1746
|
-
p.relativeTo = function (base) {
|
|
1747
|
-
var relative = this.clone().normalize();
|
|
1748
|
-
var relativeParts, baseParts, common, relativePath, basePath;
|
|
1749
|
-
if (relative._parts.urn) {
|
|
1750
|
-
throw new Error("URNs do not have any generally defined hierarchical components");
|
|
1751
|
-
}
|
|
1752
|
-
base = new URI(base).normalize();
|
|
1753
|
-
relativeParts = relative._parts;
|
|
1754
|
-
baseParts = base._parts;
|
|
1755
|
-
relativePath = relative.path();
|
|
1756
|
-
basePath = base.path();
|
|
1757
|
-
if (relativePath.charAt(0) !== "/") {
|
|
1758
|
-
throw new Error("URI is already relative");
|
|
1759
|
-
}
|
|
1760
|
-
if (basePath.charAt(0) !== "/") {
|
|
1761
|
-
throw new Error("Cannot calculate a URI relative to another relative URI");
|
|
1762
|
-
}
|
|
1763
|
-
if (relativeParts.protocol === baseParts.protocol) {
|
|
1764
|
-
relativeParts.protocol = null;
|
|
1765
|
-
}
|
|
1766
|
-
if (relativeParts.username !== baseParts.username || relativeParts.password !== baseParts.password) {
|
|
1767
|
-
return relative.build();
|
|
1768
|
-
}
|
|
1769
|
-
if (relativeParts.protocol !== null || relativeParts.username !== null || relativeParts.password !== null) {
|
|
1770
|
-
return relative.build();
|
|
1771
|
-
}
|
|
1772
|
-
if (relativeParts.hostname === baseParts.hostname && relativeParts.port === baseParts.port) {
|
|
1773
|
-
relativeParts.hostname = null;
|
|
1774
|
-
relativeParts.port = null;
|
|
1775
|
-
} else {
|
|
1776
|
-
return relative.build();
|
|
1777
|
-
}
|
|
1778
|
-
if (relativePath === basePath) {
|
|
1779
|
-
relativeParts.path = "";
|
|
1780
|
-
return relative.build();
|
|
1781
|
-
}
|
|
1782
|
-
common = URI.commonPath(relativePath, basePath);
|
|
1783
|
-
if (!common) {
|
|
1784
|
-
return relative.build();
|
|
1785
|
-
}
|
|
1786
|
-
var parents = baseParts.path.substring(common.length).replace(/[^\/]*$/, "").replace(/.*?\//g, "../");
|
|
1787
|
-
relativeParts.path = parents + relativeParts.path.substring(common.length) || "./";
|
|
1788
|
-
return relative.build();
|
|
1789
|
-
};
|
|
1790
|
-
p.equals = function (uri) {
|
|
1791
|
-
var one = this.clone();
|
|
1792
|
-
var two = new URI(uri);
|
|
1793
|
-
var one_map = {};
|
|
1794
|
-
var two_map = {};
|
|
1795
|
-
var checked = {};
|
|
1796
|
-
var one_query, two_query, key;
|
|
1797
|
-
one.normalize();
|
|
1798
|
-
two.normalize();
|
|
1799
|
-
if (one.toString() === two.toString()) {
|
|
1800
|
-
return true;
|
|
1801
|
-
}
|
|
1802
|
-
one_query = one.query();
|
|
1803
|
-
two_query = two.query();
|
|
1804
|
-
one.query("");
|
|
1805
|
-
two.query("");
|
|
1806
|
-
if (one.toString() !== two.toString()) {
|
|
1807
|
-
return false;
|
|
1808
|
-
}
|
|
1809
|
-
if (one_query.length !== two_query.length) {
|
|
1810
|
-
return false;
|
|
1811
|
-
}
|
|
1812
|
-
one_map = URI.parseQuery(one_query, this._parts.escapeQuerySpace);
|
|
1813
|
-
two_map = URI.parseQuery(two_query, this._parts.escapeQuerySpace);
|
|
1814
|
-
for (key in one_map) {
|
|
1815
|
-
if (hasOwn$1.call(one_map, key)) {
|
|
1816
|
-
if (!isArray(one_map[key])) {
|
|
1817
|
-
if (one_map[key] !== two_map[key]) {
|
|
1818
|
-
return false;
|
|
1819
|
-
}
|
|
1820
|
-
} else if (!arraysEqual(one_map[key], two_map[key])) {
|
|
1821
|
-
return false;
|
|
1822
|
-
}
|
|
1823
|
-
checked[key] = true;
|
|
1824
|
-
}
|
|
1825
|
-
}
|
|
1826
|
-
for (key in two_map) {
|
|
1827
|
-
if (hasOwn$1.call(two_map, key)) {
|
|
1828
|
-
if (!checked[key]) {
|
|
1829
|
-
return false;
|
|
1830
|
-
}
|
|
1831
|
-
}
|
|
1832
|
-
}
|
|
1833
|
-
return true;
|
|
1834
|
-
};
|
|
1835
|
-
p.preventInvalidHostname = function (v) {
|
|
1836
|
-
this._parts.preventInvalidHostname = !!v;
|
|
1837
|
-
return this;
|
|
1838
|
-
};
|
|
1839
|
-
p.duplicateQueryParameters = function (v) {
|
|
1840
|
-
this._parts.duplicateQueryParameters = !!v;
|
|
1841
|
-
return this;
|
|
1842
|
-
};
|
|
1843
|
-
p.escapeQuerySpace = function (v) {
|
|
1844
|
-
this._parts.escapeQuerySpace = !!v;
|
|
1845
|
-
return this;
|
|
1846
|
-
};
|
|
1847
|
-
|
|
1848
|
-
var ApplyUtil = {
|
|
1849
|
-
formatBundleName: function (sId, sBundleUrl) {
|
|
1850
|
-
if (sBundleUrl.startsWith("/")) {
|
|
1851
|
-
throw Error("Absolute paths are not supported");
|
|
1852
|
-
}
|
|
1853
|
-
var sNormalizedUrl = new URI(sId + "/" + sBundleUrl).normalize().path();
|
|
1854
|
-
return sNormalizedUrl.replace(/\//g, ".").replace("..", ".").replace(/.properties$/g, "");
|
|
1855
|
-
}
|
|
1856
|
-
};
|
|
1857
|
-
|
|
1858
|
-
var Change = function (oFile) {
|
|
1859
|
-
this._oDefinition = oFile;
|
|
1860
|
-
};
|
|
1861
|
-
Change.prototype.getChangeType = function () {
|
|
1862
|
-
if (this._oDefinition) {
|
|
1863
|
-
return this._oDefinition.flexObjectMetadata ? this._oDefinition.flexObjectMetadata.changeType : this._oDefinition.changeType;
|
|
1864
|
-
}
|
|
1865
|
-
};
|
|
1866
|
-
Change.prototype.getLayer = function () {
|
|
1867
|
-
return this._oDefinition.layer;
|
|
1868
|
-
};
|
|
1869
|
-
Change.prototype.getContent = function () {
|
|
1870
|
-
return this._oDefinition.content;
|
|
1871
|
-
};
|
|
1872
|
-
Change.prototype.getTexts = function () {
|
|
1873
|
-
return this._oDefinition.texts;
|
|
1874
|
-
};
|
|
1875
|
-
|
|
1876
|
-
var ObjectPath = {};
|
|
1877
|
-
var defaultRootContext = window;
|
|
1878
|
-
function getObjectPathArray(vObjectPath) {
|
|
1879
|
-
return Array.isArray(vObjectPath) ? vObjectPath.slice() : vObjectPath.split(".");
|
|
1880
|
-
}
|
|
1881
|
-
ObjectPath.create = function (vObjectPath, oRootContext) {
|
|
1882
|
-
var oObject = oRootContext || defaultRootContext;
|
|
1883
|
-
var aNames = getObjectPathArray(vObjectPath);
|
|
1884
|
-
for (var i = 0; i < aNames.length; i++) {
|
|
1885
|
-
var sName = aNames[i];
|
|
1886
|
-
if (oObject[sName] === null || oObject[sName] !== undefined && (typeof oObject[sName] !== "object" && typeof oObject[sName] !== "function")) {
|
|
1887
|
-
throw new Error("Could not set object-path for '" + aNames.join(".") + "', path segment '" + sName + "' already exists.");
|
|
1888
|
-
}
|
|
1889
|
-
oObject[sName] = oObject[sName] || ({});
|
|
1890
|
-
oObject = oObject[sName];
|
|
1891
|
-
}
|
|
1892
|
-
return oObject;
|
|
1893
|
-
};
|
|
1894
|
-
ObjectPath.get = function (vObjectPath, oRootContext) {
|
|
1895
|
-
var oObject = oRootContext || defaultRootContext;
|
|
1896
|
-
var aNames = getObjectPathArray(vObjectPath);
|
|
1897
|
-
var sPropertyName = aNames.pop();
|
|
1898
|
-
for (var i = 0; i < aNames.length && oObject; i++) {
|
|
1899
|
-
oObject = oObject[aNames[i]];
|
|
1900
|
-
}
|
|
1901
|
-
return oObject ? oObject[sPropertyName] : undefined;
|
|
1902
|
-
};
|
|
1903
|
-
ObjectPath.set = function (vObjectPath, vValue, oRootContext) {
|
|
1904
|
-
oRootContext = oRootContext || defaultRootContext;
|
|
1905
|
-
var aNames = getObjectPathArray(vObjectPath);
|
|
1906
|
-
var sPropertyName = aNames.pop();
|
|
1907
|
-
var oObject = ObjectPath.create(aNames, oRootContext);
|
|
1908
|
-
oObject[sPropertyName] = vValue;
|
|
1909
|
-
};
|
|
1910
|
-
|
|
1911
|
-
function setPropValueByPath(oEntityProp, oRoot) {
|
|
1912
|
-
var aPath = oEntityProp.propertyPath.split("/");
|
|
1913
|
-
var valueByPath = ObjectPath.get(aPath, oRoot);
|
|
1914
|
-
if (valueByPath && oEntityProp.operation === "INSERT") {
|
|
1915
|
-
throw new Error("Path has already a value. 'INSERT' operation is not appropriate.");
|
|
1916
|
-
}
|
|
1917
|
-
if (!valueByPath && oEntityProp.operation === "UPDATE") {
|
|
1918
|
-
throw new Error("Path does not contain a value. 'UPDATE' operation is not appropriate.");
|
|
1919
|
-
}
|
|
1920
|
-
ObjectPath.set(aPath, oEntityProp.propertyValue, oRoot);
|
|
1921
|
-
}
|
|
1922
|
-
function changePropertyValueByPath (vChanges, oRootPath) {
|
|
1923
|
-
if (Array.isArray(vChanges)) {
|
|
1924
|
-
vChanges.forEach(function (oEntityProp) {
|
|
1925
|
-
setPropValueByPath(oEntityProp, oRootPath);
|
|
1926
|
-
});
|
|
1927
|
-
} else {
|
|
1928
|
-
setPropValueByPath(vChanges, oRootPath);
|
|
1929
|
-
}
|
|
1930
|
-
}
|
|
1931
|
-
|
|
1932
|
-
var fnValues = function values(mObject) {
|
|
1933
|
-
if (typeof mObject === "undefined" || mObject === null || mObject !== mObject) {
|
|
1934
|
-
return [];
|
|
1935
|
-
}
|
|
1936
|
-
return Object.values(mObject);
|
|
1937
|
-
};
|
|
1938
|
-
|
|
1939
|
-
var fnIncludes = function (vCollection, vValue, iFromIndex) {
|
|
1940
|
-
if (typeof iFromIndex !== "number") {
|
|
1941
|
-
iFromIndex = 0;
|
|
1942
|
-
}
|
|
1943
|
-
if (Array.isArray(vCollection) || typeof vCollection === "string") {
|
|
1944
|
-
if (iFromIndex < 0) {
|
|
1945
|
-
iFromIndex = vCollection.length + iFromIndex < 0 ? 0 : vCollection.length + iFromIndex;
|
|
1946
|
-
}
|
|
1947
|
-
return vCollection.includes(vValue, iFromIndex);
|
|
1948
|
-
} else {
|
|
1949
|
-
return fnIncludes(fnValues(vCollection), vValue, iFromIndex);
|
|
1950
|
-
}
|
|
1951
|
-
};
|
|
1952
|
-
|
|
1953
|
-
var Layer = {
|
|
1954
|
-
USER: "USER",
|
|
1955
|
-
PUBLIC: "PUBLIC",
|
|
1956
|
-
CUSTOMER: "CUSTOMER",
|
|
1957
|
-
CUSTOMER_BASE: "CUSTOMER_BASE",
|
|
1958
|
-
PARTNER: "PARTNER",
|
|
1959
|
-
VENDOR: "VENDOR",
|
|
1960
|
-
BASE: "BASE"
|
|
1961
|
-
};
|
|
1962
|
-
|
|
1963
|
-
function checkChange(oEntityPropertyChange, aSupportedProperties, aSupportedOperations) {
|
|
1964
|
-
if (Array.isArray(oEntityPropertyChange)) {
|
|
1965
|
-
oEntityPropertyChange.forEach(function (change) {
|
|
1966
|
-
formatEntityCheck(change, aSupportedProperties, aSupportedOperations);
|
|
1967
|
-
});
|
|
1968
|
-
} else {
|
|
1969
|
-
formatEntityCheck(oEntityPropertyChange, aSupportedProperties, aSupportedOperations);
|
|
1970
|
-
}
|
|
1971
|
-
}
|
|
1972
|
-
function getClearedGenericPath(aSupportedProperties) {
|
|
1973
|
-
var aPropertiesClearedGenericPath = [];
|
|
1974
|
-
var aPropertiesWithGenericPath = aSupportedProperties.filter(function (sProperty) {
|
|
1975
|
-
return sProperty.endsWith("/*");
|
|
1976
|
-
});
|
|
1977
|
-
aPropertiesWithGenericPath.forEach(function (sProperty) {
|
|
1978
|
-
var sClearedProperty = sProperty.replaceAll("/*", "");
|
|
1979
|
-
if (sClearedProperty) {
|
|
1980
|
-
aPropertiesClearedGenericPath.push(sClearedProperty);
|
|
1981
|
-
}
|
|
1982
|
-
});
|
|
1983
|
-
return aPropertiesClearedGenericPath;
|
|
1984
|
-
}
|
|
1985
|
-
function isGenericPropertyPathSupported(aSupportedProperties, sPropertyPath) {
|
|
1986
|
-
var aClearedGenericPath = getClearedGenericPath(aSupportedProperties);
|
|
1987
|
-
return aClearedGenericPath.some(function (path) {
|
|
1988
|
-
return sPropertyPath.startsWith(path);
|
|
1989
|
-
});
|
|
1990
|
-
}
|
|
1991
|
-
function formatEntityCheck(oChangeEntity, aSupportedProperties, aSupportedOperations) {
|
|
1992
|
-
if (!oChangeEntity.propertyPath) {
|
|
1993
|
-
throw new Error("Invalid change format: The mandatory 'propertyPath' is not defined. Please define the mandatory property 'propertyPath'");
|
|
1994
|
-
}
|
|
1995
|
-
if (!oChangeEntity.operation) {
|
|
1996
|
-
throw new Error("Invalid change format: The mandatory 'operation' is not defined. Please define the mandatory property 'operation'");
|
|
1997
|
-
}
|
|
1998
|
-
if (oChangeEntity.operation.toUpperCase() !== "DELETE") {
|
|
1999
|
-
if (!oChangeEntity.hasOwnProperty("propertyValue")) {
|
|
2000
|
-
throw new Error("Invalid change format: The mandatory 'propertyValue' is not defined. Please define the mandatory property 'propertyValue'");
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
if (!fnIncludes(aSupportedProperties, oChangeEntity.propertyPath) && !isGenericPropertyPathSupported(aSupportedProperties, oChangeEntity.propertyPath)) {
|
|
2004
|
-
throw new Error("Changing " + oChangeEntity.propertyPath + " is not supported. The supported 'propertyPath' is: " + aSupportedProperties.join("|"));
|
|
2005
|
-
}
|
|
2006
|
-
if (!fnIncludes(aSupportedOperations, oChangeEntity.operation)) {
|
|
2007
|
-
throw new Error("Operation " + oChangeEntity.operation + " is not supported. The supported 'operation' is " + aSupportedOperations.join("|"));
|
|
2008
|
-
}
|
|
2009
|
-
}
|
|
2010
|
-
function checkEntityPropertyChange(oChange, aSupportedProperties, aSupportedOperations) {
|
|
2011
|
-
var id = Object.keys(oChange).filter(function (key) {
|
|
2012
|
-
return key.endsWith("Id");
|
|
2013
|
-
}).shift();
|
|
2014
|
-
if (!oChange[id]) {
|
|
2015
|
-
throw new Error("Mandatory \"" + id + "\" parameter is not provided.");
|
|
2016
|
-
}
|
|
2017
|
-
if (!oChange.entityPropertyChange) {
|
|
2018
|
-
throw new Error("Changes for \"" + oChange[id] + "\" are not provided.");
|
|
2019
|
-
}
|
|
2020
|
-
checkChange(oChange.entityPropertyChange, aSupportedProperties, aSupportedOperations);
|
|
2021
|
-
}
|
|
2022
|
-
var layer_prefixes = {};
|
|
2023
|
-
layer_prefixes[Layer.CUSTOMER] = "customer.";
|
|
2024
|
-
layer_prefixes[Layer.CUSTOMER_BASE] = "customer.";
|
|
2025
|
-
layer_prefixes[Layer.PARTNER] = "partner.";
|
|
2026
|
-
layer_prefixes[Layer.VENDOR] = null;
|
|
2027
|
-
function checkIdNamespaceCompliance(sId, oChange) {
|
|
2028
|
-
var sLayer = oChange.getLayer();
|
|
2029
|
-
if (!sLayer) {
|
|
2030
|
-
throw new Error("Mandatory layer parameter is not provided.");
|
|
2031
|
-
}
|
|
2032
|
-
var sPrefix = getNamespacePrefixForLayer(sLayer);
|
|
2033
|
-
if (sPrefix === null) {
|
|
2034
|
-
Object.keys(layer_prefixes).forEach(function (sKey) {
|
|
2035
|
-
if (layer_prefixes[sKey] && sId.startsWith(layer_prefixes[sKey])) {
|
|
2036
|
-
throw new Error("Id " + sId + " must not start with reserved " + layer_prefixes[sKey]);
|
|
2037
|
-
}
|
|
2038
|
-
});
|
|
2039
|
-
} else if (!sId.startsWith(sPrefix)) {
|
|
2040
|
-
throw new Error("Id " + sId + " must start with " + sPrefix);
|
|
2041
|
-
}
|
|
2042
|
-
}
|
|
2043
|
-
function getNamespacePrefixForLayer(sLayer) {
|
|
2044
|
-
var sPrefix = layer_prefixes[sLayer];
|
|
2045
|
-
if (sPrefix === undefined) {
|
|
2046
|
-
throw new Error("Layer " + sLayer + " not supported.");
|
|
2047
|
-
}
|
|
2048
|
-
return sPrefix;
|
|
2049
|
-
}
|
|
2050
|
-
var DescriptorChangeCheck = {
|
|
2051
|
-
checkEntityPropertyChange: checkEntityPropertyChange,
|
|
2052
|
-
checkIdNamespaceCompliance: checkIdNamespaceCompliance,
|
|
2053
|
-
getNamespacePrefixForLayer: getNamespacePrefixForLayer,
|
|
2054
|
-
getClearedGenericPath: getClearedGenericPath,
|
|
2055
|
-
isGenericPropertyPathSupported: isGenericPropertyPathSupported
|
|
2056
|
-
};
|
|
2057
|
-
|
|
2058
|
-
var SUPPORTED_OPERATIONS$1 = ["UPDATE", "UPSERT"];
|
|
2059
|
-
var SUPPORTED_PROPERTIES$1 = ["uri", "settings/maxAge"];
|
|
2060
|
-
var ChangeDataSource = {
|
|
2061
|
-
applyChange: function (oManifest, oChange) {
|
|
2062
|
-
var oDataSources = oManifest["sap.app"].dataSources;
|
|
2063
|
-
var oChangeContent = oChange.getContent();
|
|
2064
|
-
DescriptorChangeCheck.checkEntityPropertyChange(oChangeContent, SUPPORTED_PROPERTIES$1, SUPPORTED_OPERATIONS$1);
|
|
2065
|
-
if (oDataSources) {
|
|
2066
|
-
var oDataSource = oDataSources[oChangeContent.dataSourceId];
|
|
2067
|
-
if (oDataSource) {
|
|
2068
|
-
changePropertyValueByPath(oChangeContent.entityPropertyChange, oDataSource);
|
|
2069
|
-
} else {
|
|
2070
|
-
throw new Error("Nothing to update. DataSource with ID \"" + oChangeContent.dataSourceId + "\" does not exist.");
|
|
2071
|
-
}
|
|
2072
|
-
} else {
|
|
2073
|
-
throw Error("No sap.app/dataSource found in manifest.json");
|
|
2074
|
-
}
|
|
2075
|
-
return oManifest;
|
|
2076
|
-
}
|
|
2077
|
-
};
|
|
2078
|
-
|
|
2079
|
-
var AddNewModelEnhanceWith = {
|
|
2080
|
-
applyChange: function (oManifest, oChange) {
|
|
2081
|
-
var sModelId = oChange.getContent().modelId;
|
|
2082
|
-
var sI18N = ApplyUtil.formatBundleName(oManifest["sap.app"].id, oChange.getTexts().i18n);
|
|
2083
|
-
var oModel = oManifest["sap.ui5"].models[sModelId];
|
|
2084
|
-
if (oModel) {
|
|
2085
|
-
if (oModel.type && oModel.type === "sap.ui.model.resource.ResourceModel") {
|
|
2086
|
-
if (!(oModel.settings && oModel.settings.enhanceWith)) {
|
|
2087
|
-
ObjectPath.set("settings.enhanceWith", [], oModel);
|
|
2088
|
-
}
|
|
2089
|
-
var oEnhanceWith = oModel.settings.enhanceWith;
|
|
2090
|
-
oEnhanceWith.push({
|
|
2091
|
-
bundleName: sI18N
|
|
2092
|
-
});
|
|
2093
|
-
}
|
|
2094
|
-
}
|
|
2095
|
-
return oManifest;
|
|
2096
|
-
},
|
|
2097
|
-
skipPostprocessing: true
|
|
2098
|
-
};
|
|
2099
|
-
|
|
2100
|
-
var AddComponentUsages = {
|
|
2101
|
-
applyChange: function (oManifest, oChange) {
|
|
2102
|
-
var oChangeComponentUsages = oChange.getContent().componentUsages;
|
|
2103
|
-
if (!oManifest["sap.ui5"]["componentUsages"]) {
|
|
2104
|
-
oManifest["sap.ui5"]["componentUsages"] = {};
|
|
2105
|
-
}
|
|
2106
|
-
var oManifestComponentUsages = oManifest["sap.ui5"].componentUsages;
|
|
2107
|
-
Object.keys(oChangeComponentUsages).forEach(function (sComponentUsageName) {
|
|
2108
|
-
if (oManifestComponentUsages[sComponentUsageName]) {
|
|
2109
|
-
throw new Error("Component usage '" + sComponentUsageName + "' already exists");
|
|
2110
|
-
} else {
|
|
2111
|
-
oManifestComponentUsages[sComponentUsageName] = oChangeComponentUsages[sComponentUsageName];
|
|
2112
|
-
}
|
|
2113
|
-
});
|
|
2114
|
-
return oManifest;
|
|
2115
|
-
}
|
|
2116
|
-
};
|
|
2117
|
-
|
|
2118
|
-
var rVersion = /^[0-9]+(?:\.([0-9]+)(?:\.([0-9]+))?)?(.*)$/;
|
|
2119
|
-
function Version(vMajor, iMinor, iPatch, sSuffix) {
|
|
2120
|
-
if (vMajor instanceof Version) {
|
|
2121
|
-
return vMajor;
|
|
2122
|
-
}
|
|
2123
|
-
if (!(this instanceof Version)) {
|
|
2124
|
-
return new Version(vMajor, iMinor, iPatch, sSuffix);
|
|
2125
|
-
}
|
|
2126
|
-
var m;
|
|
2127
|
-
if (typeof vMajor === "string") {
|
|
2128
|
-
m = rVersion.exec(vMajor);
|
|
2129
|
-
} else if (Array.isArray(vMajor)) {
|
|
2130
|
-
m = vMajor;
|
|
2131
|
-
} else {
|
|
2132
|
-
m = arguments;
|
|
2133
|
-
}
|
|
2134
|
-
m = m || [];
|
|
2135
|
-
function norm(v) {
|
|
2136
|
-
v = parseInt(v);
|
|
2137
|
-
return isNaN(v) ? 0 : v;
|
|
2138
|
-
}
|
|
2139
|
-
vMajor = norm(m[0]);
|
|
2140
|
-
iMinor = norm(m[1]);
|
|
2141
|
-
iPatch = norm(m[2]);
|
|
2142
|
-
sSuffix = String(m[3] || "");
|
|
2143
|
-
this.toString = function () {
|
|
2144
|
-
return vMajor + "." + iMinor + "." + iPatch + sSuffix;
|
|
2145
|
-
};
|
|
2146
|
-
this.getMajor = function () {
|
|
2147
|
-
return vMajor;
|
|
2148
|
-
};
|
|
2149
|
-
this.getMinor = function () {
|
|
2150
|
-
return iMinor;
|
|
2151
|
-
};
|
|
2152
|
-
this.getPatch = function () {
|
|
2153
|
-
return iPatch;
|
|
2154
|
-
};
|
|
2155
|
-
this.getSuffix = function () {
|
|
2156
|
-
return sSuffix;
|
|
2157
|
-
};
|
|
2158
|
-
this.compareTo = function () {
|
|
2159
|
-
var vOther = Version.apply(window, arguments);
|
|
2160
|
-
return vMajor - vOther.getMajor() || iMinor - vOther.getMinor() || iPatch - vOther.getPatch() || (sSuffix < vOther.getSuffix() ? -1 : sSuffix === vOther.getSuffix() ? 0 : 1);
|
|
2161
|
-
};
|
|
2162
|
-
}
|
|
2163
|
-
Version.prototype.inRange = function (vMin, vMax) {
|
|
2164
|
-
return this.compareTo(vMin) >= 0 && this.compareTo(vMax) < 0;
|
|
2165
|
-
};
|
|
2166
|
-
|
|
2167
|
-
var SetMinUI5Version = {
|
|
2168
|
-
applyChange: function (oManifest, oChange) {
|
|
2169
|
-
var vCurrentVersion = new Version(oManifest["sap.ui5"].dependencies.minUI5Version);
|
|
2170
|
-
if (vCurrentVersion.compareTo(oChange.getContent().minUI5Version) <= 0) {
|
|
2171
|
-
oManifest["sap.ui5"].dependencies.minUI5Version = oChange.getContent().minUI5Version;
|
|
2172
|
-
}
|
|
2173
|
-
return oManifest;
|
|
2174
|
-
}
|
|
2175
|
-
};
|
|
2176
|
-
|
|
2177
|
-
var SetRegistrationIds = {
|
|
2178
|
-
applyChange: function (oManifest, oChange) {
|
|
2179
|
-
ObjectPath.set(["sap.fiori", "registrationIds"], oChange.getContent().registrationIds, oManifest);
|
|
2180
|
-
return oManifest;
|
|
2181
|
-
}
|
|
2182
|
-
};
|
|
2183
|
-
|
|
2184
|
-
var SetFlexExtensionPointEnabled = {
|
|
2185
|
-
applyChange: function (oManifest, oChange) {
|
|
2186
|
-
if (!oChange.getContent().flexExtensionPointEnabled) {
|
|
2187
|
-
throw new Error("No flexExtensionPointEnabled in change content provided");
|
|
2188
|
-
}
|
|
2189
|
-
ObjectPath.set(["sap.ui5", "flexExtensionPointEnabled"], oChange.getContent().flexExtensionPointEnabled, oManifest);
|
|
2190
|
-
return oManifest;
|
|
2191
|
-
}
|
|
2192
|
-
};
|
|
2193
|
-
|
|
2194
|
-
var SUPPORTED_MODEL_DATASOURCE_TYPES = ["OData", "INA", "XML", "JSON", "FHIR", "http", "WebSocket"];
|
|
2195
|
-
var SUPPORTED_DATASOURCE_TYPES = SUPPORTED_MODEL_DATASOURCE_TYPES.concat(["ODataAnnotation"]);
|
|
2196
|
-
function isDataSourceTypeSupported(oChangeDataSource, sDataSource, aSupportedTypes) {
|
|
2197
|
-
return !oChangeDataSource[sDataSource].type || aSupportedTypes.indexOf(oChangeDataSource[sDataSource]["type"]) >= 0;
|
|
2198
|
-
}
|
|
2199
|
-
function isODataDefinedForODataAnnotation(oChangeDataSources, sODataAnnotationName) {
|
|
2200
|
-
return getObjectAsArray(oChangeDataSources).some(function (oDataSource) {
|
|
2201
|
-
return (!oDataSource.type || oDataSource["type"] === "OData") && oDataSource["settings"]["annotations"].indexOf(sODataAnnotationName) >= 0;
|
|
2202
|
-
});
|
|
2203
|
-
}
|
|
2204
|
-
function isReferencedModelDataSourceExisting(oManifestDataSource, oChangeDataSource, sDataSource) {
|
|
2205
|
-
return isExistingAndSupported(oChangeDataSource, sDataSource, SUPPORTED_MODEL_DATASOURCE_TYPES) || isDataSourceExistingInManifest(oManifestDataSource, sDataSource);
|
|
2206
|
-
}
|
|
2207
|
-
function isExistingAndSupported(oDataSources, sDataSource, aSupportedTypes) {
|
|
2208
|
-
return hasSearchType(oDataSources, sDataSource) && isDataSourceTypeSupported(oDataSources, sDataSource, aSupportedTypes);
|
|
2209
|
-
}
|
|
2210
|
-
function isDataSourceExistingInManifest(oDataSources, sDataSource) {
|
|
2211
|
-
if (hasSearchType(oDataSources, sDataSource)) {
|
|
2212
|
-
if (oDataSources[sDataSource].type && oDataSources[sDataSource]["type"] === "ODataAnnotation") {
|
|
2213
|
-
throw new Error("The already existing dataSource '" + sDataSource + "' in the manifest is type of 'ODataAnnotation'. A model must not reference to a dataSource which is of type 'ODataAnnotation'");
|
|
2214
|
-
}
|
|
2215
|
-
return true;
|
|
2216
|
-
}
|
|
2217
|
-
return false;
|
|
2218
|
-
}
|
|
2219
|
-
function hasSearchType(oToBeSearched, sSearchType) {
|
|
2220
|
-
return oToBeSearched && Object.keys(oToBeSearched).indexOf(sSearchType) >= 0;
|
|
2221
|
-
}
|
|
2222
|
-
function mergeChange(oManifestContent, oChangeContent, sErrorMessage) {
|
|
2223
|
-
if (oChangeContent) {
|
|
2224
|
-
Object.keys(oChangeContent).forEach(function (sNewModelName) {
|
|
2225
|
-
if (oManifestContent[sNewModelName]) {
|
|
2226
|
-
throw new Error("The " + sErrorMessage + " '" + sNewModelName + "' already exists");
|
|
2227
|
-
}
|
|
2228
|
-
oManifestContent[sNewModelName] = oChangeContent[sNewModelName];
|
|
2229
|
-
});
|
|
2230
|
-
}
|
|
2231
|
-
}
|
|
2232
|
-
function merge$2(oManifest, oChange, sRootPath, sChildPath, sModelPath) {
|
|
2233
|
-
if (!oManifest[sRootPath][sChildPath]) {
|
|
2234
|
-
oManifest[sRootPath][sChildPath] = {};
|
|
2235
|
-
}
|
|
2236
|
-
mergeChange(oManifest[sRootPath][sChildPath], oChange.getContent()[sModelPath], sModelPath);
|
|
2237
|
-
return oManifest[sRootPath][sChildPath];
|
|
2238
|
-
}
|
|
2239
|
-
function isChangeDataSourceUsedByChangeModel(oChangeDataSource, oChangeModel, sDataSource) {
|
|
2240
|
-
if (oChangeDataSource[sDataSource].type === "ODataAnnotation") {
|
|
2241
|
-
return true;
|
|
2242
|
-
}
|
|
2243
|
-
return getObjectAsArray(oChangeModel).some(function (oModel) {
|
|
2244
|
-
return oModel.dataSource && oModel["dataSource"] === sDataSource;
|
|
2245
|
-
});
|
|
2246
|
-
}
|
|
2247
|
-
function hasModelPropertyTypOrDataSource(oChangeModel, sModel) {
|
|
2248
|
-
return oChangeModel[sModel].type || oChangeModel[sModel].dataSource;
|
|
2249
|
-
}
|
|
2250
|
-
function getObjectAsArray(oObject) {
|
|
2251
|
-
return Object.keys(oObject).map(function (sObject) {
|
|
2252
|
-
return oObject[sObject];
|
|
2253
|
-
});
|
|
2254
|
-
}
|
|
2255
|
-
var AddNewModel = {
|
|
2256
|
-
applyChange: function (oManifest, oChange) {
|
|
2257
|
-
var oChangeModel = oChange.getContent().model;
|
|
2258
|
-
var oChangeDataSource = oChange.getContent().dataSource;
|
|
2259
|
-
if (oChangeModel) {
|
|
2260
|
-
if (Object.keys(oChangeModel).length !== 1) {
|
|
2261
|
-
throw new Error("There are currently '" + Object.keys(oChangeModel).length + "' models in the change. Currently it is only allowed to add '1' model");
|
|
2262
|
-
}
|
|
2263
|
-
Object.keys(oChangeModel).forEach(function (sModel) {
|
|
2264
|
-
if (!hasModelPropertyTypOrDataSource(oChangeModel, sModel)) {
|
|
2265
|
-
throw new Error("There is no 'dataSource' or 'type' in the change model defined. Please define either 'type' or 'dataSource' in property '" + sModel + "'");
|
|
2266
|
-
}
|
|
2267
|
-
if (oChangeModel[sModel].dataSource) {
|
|
2268
|
-
if (!isReferencedModelDataSourceExisting(oManifest["sap.app"]["dataSources"], oChangeDataSource, oChangeModel[sModel]["dataSource"])) {
|
|
2269
|
-
throw new Error("The defined dataSource '" + oChangeModel[sModel]["dataSource"] + "' in the model does not exists as dataSource or must be allowed type of " + SUPPORTED_MODEL_DATASOURCE_TYPES.join("|"));
|
|
2270
|
-
}
|
|
2271
|
-
}
|
|
2272
|
-
});
|
|
2273
|
-
} else {
|
|
2274
|
-
throw new Error("No model defined");
|
|
2275
|
-
}
|
|
2276
|
-
if (oChangeDataSource) {
|
|
2277
|
-
Object.keys(oChangeDataSource).forEach(function (sDataSource) {
|
|
2278
|
-
if (!isDataSourceTypeSupported(oChangeDataSource, sDataSource, SUPPORTED_DATASOURCE_TYPES)) {
|
|
2279
|
-
throw new Error("The dataSource '" + sDataSource + "' has the type '" + oChangeDataSource[sDataSource]["type"] + "', but only dataSources with the follwing types are supported: " + SUPPORTED_DATASOURCE_TYPES.join("|"));
|
|
2280
|
-
}
|
|
2281
|
-
if (!isChangeDataSourceUsedByChangeModel(oChangeDataSource, oChangeModel, sDataSource)) {
|
|
2282
|
-
throw new Error("The dataSource in the change '" + sDataSource + "' is not used by any model in the change. A dataSource in the change must be used by model in the change");
|
|
2283
|
-
}
|
|
2284
|
-
if (oChangeDataSource[sDataSource]["type"] === "ODataAnnotation") {
|
|
2285
|
-
if (!isODataDefinedForODataAnnotation(oChangeDataSource, sDataSource)) {
|
|
2286
|
-
throw new Error("There is no dataSource with type 'OData' defined which includes the annotation '" + sDataSource + "'");
|
|
2287
|
-
}
|
|
2288
|
-
}
|
|
2289
|
-
});
|
|
2290
|
-
}
|
|
2291
|
-
merge$2(oManifest, oChange, "sap.ui5", "models", "model");
|
|
2292
|
-
merge$2(oManifest, oChange, "sap.app", "dataSources", "dataSource");
|
|
2293
|
-
return oManifest;
|
|
2294
|
-
}
|
|
2295
|
-
};
|
|
2296
|
-
|
|
2297
|
-
var SUPPORTED_INSERT_POSITION = ["BEGINNING", "END"];
|
|
2298
|
-
function isDataSourceIdExistingInManifest(oManifestDataSources, sDataSourceId) {
|
|
2299
|
-
return Object.keys(oManifestDataSources).indexOf(sDataSourceId) >= 0;
|
|
2300
|
-
}
|
|
2301
|
-
function isDataSourceTypeOData(oManifestDataSources, sDataSource) {
|
|
2302
|
-
return !oManifestDataSources[sDataSource].type || oManifestDataSources[sDataSource].type === "OData";
|
|
2303
|
-
}
|
|
2304
|
-
function isAnnotationExisting(oManifestDataSources, oChangeDataSource, sAnnotation) {
|
|
2305
|
-
return oManifestDataSources[sAnnotation] && oManifestDataSources[sAnnotation].type === "ODataAnnotation" || oChangeDataSource[sAnnotation];
|
|
2306
|
-
}
|
|
2307
|
-
function isAnnotationTypeOfOdataAnnotation(oChangeDataSource, sAnnotation) {
|
|
2308
|
-
return oChangeDataSource[sAnnotation].type && oChangeDataSource[sAnnotation].type === "ODataAnnotation";
|
|
2309
|
-
}
|
|
2310
|
-
function isAnnotationPartOfAnnotationsArray(aChangeAnnotations, sAnnotation) {
|
|
2311
|
-
return aChangeAnnotations.indexOf(sAnnotation) >= 0;
|
|
2312
|
-
}
|
|
2313
|
-
function checkingDataSourceId(oManifestDataSources, sChangeDataSourceId) {
|
|
2314
|
-
if (sChangeDataSourceId) {
|
|
2315
|
-
if (Object.keys(oManifestDataSources).length > 0) {
|
|
2316
|
-
if (!isDataSourceIdExistingInManifest(oManifestDataSources, sChangeDataSourceId)) {
|
|
2317
|
-
throw new Error("There is no dataSource '" + sChangeDataSourceId + "' existing in the manifest. You can only add annotations to already existing dataSources in the manifest");
|
|
2318
|
-
}
|
|
2319
|
-
if (!isDataSourceTypeOData(oManifestDataSources, sChangeDataSourceId)) {
|
|
2320
|
-
throw new Error("The dataSource '" + sChangeDataSourceId + "' is existing in the manifest but is not type of 'OData'. The type of the dataSource in the manifest is '" + oManifestDataSources[sChangeDataSourceId].type + "'");
|
|
2321
|
-
}
|
|
2322
|
-
} else {
|
|
2323
|
-
throw new Error("There are no dataSources in the manifest at all");
|
|
2324
|
-
}
|
|
2325
|
-
} else {
|
|
2326
|
-
throw new Error("Invalid change format: The mandatory 'dataSourceId' is not defined. Please define the mandatory property 'dataSourceId' and refer it to an existing OData");
|
|
2327
|
-
}
|
|
2328
|
-
}
|
|
2329
|
-
function checkingAnnotationArray(aChangeAnnotations) {
|
|
2330
|
-
if (aChangeAnnotations) {
|
|
2331
|
-
if (aChangeAnnotations.length === 0) {
|
|
2332
|
-
throw new Error("Invalid change format: The 'annotations' array property is empty");
|
|
2333
|
-
}
|
|
2334
|
-
} else {
|
|
2335
|
-
throw new Error("Invalid change format: The mandatory 'annotations' array property is not defined. Please define the 'annotations' array property");
|
|
2336
|
-
}
|
|
2337
|
-
}
|
|
2338
|
-
function checkingAnnotationsInsertPosition(sChangeAnnotationsInsertPosition) {
|
|
2339
|
-
if (!(SUPPORTED_INSERT_POSITION.indexOf(sChangeAnnotationsInsertPosition) >= 0) && !(sChangeAnnotationsInsertPosition === undefined)) {
|
|
2340
|
-
throw new Error("The defined insert position '" + sChangeAnnotationsInsertPosition + "' is not supported. The supported insert positions are: " + SUPPORTED_INSERT_POSITION.join("|"));
|
|
2341
|
-
}
|
|
2342
|
-
}
|
|
2343
|
-
function checkingAnnotationDataSource(oChangeDataSource, aChangeAnnotations, oChange) {
|
|
2344
|
-
if (oChangeDataSource) {
|
|
2345
|
-
if (Object.keys(oChangeDataSource).length === 0) {
|
|
2346
|
-
throw new Error("The 'dataSource' object is empty");
|
|
2347
|
-
}
|
|
2348
|
-
Object.keys(oChangeDataSource).forEach(function (sAnnotation) {
|
|
2349
|
-
DescriptorChangeCheck.checkIdNamespaceCompliance(sAnnotation, oChange);
|
|
2350
|
-
if (!isAnnotationTypeOfOdataAnnotation(oChangeDataSource, sAnnotation)) {
|
|
2351
|
-
throw new Error("The dataSource annotation '" + sAnnotation + "' is type of '" + oChangeDataSource[sAnnotation].type + "'. Only dataSource annotations of type 'ODataAnnotation' is supported");
|
|
2352
|
-
}
|
|
2353
|
-
if (!isAnnotationPartOfAnnotationsArray(aChangeAnnotations, sAnnotation)) {
|
|
2354
|
-
throw new Error("The annotation '" + sAnnotation + "' is not part of 'annotations' array property. Please add the annotation '" + sAnnotation + "' in the 'annotations' array property");
|
|
2355
|
-
}
|
|
2356
|
-
});
|
|
2357
|
-
} else {
|
|
2358
|
-
throw new Error("Invalid change format: The mandatory 'dataSource' object is not defined. Please define the mandatory 'dataSource' object");
|
|
2359
|
-
}
|
|
2360
|
-
}
|
|
2361
|
-
function merge$1(oManifestDataSources, sChangeDataSourceId, aChangeAnnotations, sChangeAnnotationsInsertPosition, oChangeDataSource) {
|
|
2362
|
-
mergeAnnotationArray(oManifestDataSources[sChangeDataSourceId], aChangeAnnotations, sChangeAnnotationsInsertPosition);
|
|
2363
|
-
mergeAnnotationDataSources(oManifestDataSources, oChangeDataSource);
|
|
2364
|
-
}
|
|
2365
|
-
function mergeAnnotationArray(oManifestDataSourceId, aChangeAnnotations, sChangeAnnotationsInsertPosition) {
|
|
2366
|
-
if (!oManifestDataSourceId["settings"]) {
|
|
2367
|
-
oManifestDataSourceId["settings"] = {};
|
|
2368
|
-
}
|
|
2369
|
-
if (!oManifestDataSourceId["settings"].annotations) {
|
|
2370
|
-
oManifestDataSourceId["settings"].annotations = [];
|
|
2371
|
-
}
|
|
2372
|
-
var aNotExistingAnnotationsInChange = oManifestDataSourceId["settings"].annotations.filter(function (annotation) {
|
|
2373
|
-
return aChangeAnnotations.indexOf(annotation) < 0;
|
|
2374
|
-
});
|
|
2375
|
-
oManifestDataSourceId["settings"].annotations = aNotExistingAnnotationsInChange;
|
|
2376
|
-
if (sChangeAnnotationsInsertPosition === "END") {
|
|
2377
|
-
oManifestDataSourceId["settings"].annotations = oManifestDataSourceId["settings"].annotations.concat(aChangeAnnotations);
|
|
2378
|
-
} else {
|
|
2379
|
-
oManifestDataSourceId["settings"].annotations = aChangeAnnotations.concat(oManifestDataSourceId["settings"].annotations);
|
|
2380
|
-
}
|
|
2381
|
-
}
|
|
2382
|
-
function mergeAnnotationDataSources(oManifestDataSources, oChangeDataSource) {
|
|
2383
|
-
Object.assign(oManifestDataSources, oChangeDataSource);
|
|
2384
|
-
}
|
|
2385
|
-
function postChecks(oManifestDataSources, oChangeDataSource, aChangeAnnotations) {
|
|
2386
|
-
aChangeAnnotations.forEach(function (sAnnotation) {
|
|
2387
|
-
if (!isAnnotationExisting(oManifestDataSources, oChangeDataSource, sAnnotation)) {
|
|
2388
|
-
throw new Error("The annotation '" + sAnnotation + "' is part of 'annotations' array property but does not exists in the change property 'dataSource' and in the manifest (or it is not type of 'ODataAnnotation' in the manifest)");
|
|
2389
|
-
}
|
|
2390
|
-
});
|
|
2391
|
-
}
|
|
2392
|
-
var AddAnnotationsToOData = {
|
|
2393
|
-
applyChange: function (oManifest, oChange) {
|
|
2394
|
-
var sChangeDataSourceId = oChange.getContent().dataSourceId;
|
|
2395
|
-
var aChangeAnnotations = oChange.getContent().annotations;
|
|
2396
|
-
var sChangeAnnotationsInsertPosition = oChange.getContent().annotationsInsertPosition;
|
|
2397
|
-
var oChangeDataSource = oChange.getContent().dataSource;
|
|
2398
|
-
checkingDataSourceId(oManifest["sap.app"].dataSources, sChangeDataSourceId);
|
|
2399
|
-
checkingAnnotationArray(aChangeAnnotations);
|
|
2400
|
-
checkingAnnotationsInsertPosition(sChangeAnnotationsInsertPosition);
|
|
2401
|
-
checkingAnnotationDataSource(oChangeDataSource, aChangeAnnotations, oChange);
|
|
2402
|
-
postChecks(oManifest["sap.app"]["dataSources"], oChangeDataSource, aChangeAnnotations);
|
|
2403
|
-
merge$1(oManifest["sap.app"]["dataSources"], sChangeDataSourceId, aChangeAnnotations, sChangeAnnotationsInsertPosition, oChangeDataSource);
|
|
2404
|
-
return oManifest;
|
|
2405
|
-
}
|
|
2406
|
-
};
|
|
2407
|
-
|
|
2408
|
-
function checkManifestPath(oManifest) {
|
|
2409
|
-
if (!oManifest["sap.app"].hasOwnProperty("crossNavigation")) {
|
|
2410
|
-
throw new Error("No sap.app/crossNavigation path exists in the manifest");
|
|
2411
|
-
}
|
|
2412
|
-
if (!oManifest["sap.app"]["crossNavigation"].hasOwnProperty("inbounds")) {
|
|
2413
|
-
throw new Error("No sap.app/crossNavigation/inbounds path exists in the manifest");
|
|
2414
|
-
}
|
|
2415
|
-
}
|
|
2416
|
-
function getAndCheckInboundId$1(oChangeContent) {
|
|
2417
|
-
var sInbounds = oChangeContent["inboundId"];
|
|
2418
|
-
if (sInbounds === "") {
|
|
2419
|
-
throw new Error("The ID of your inbound is empty");
|
|
2420
|
-
}
|
|
2421
|
-
if (typeof sInbounds !== "string") {
|
|
2422
|
-
throw new Error("The type of your inbound ID must be string");
|
|
2423
|
-
}
|
|
2424
|
-
return sInbounds;
|
|
2425
|
-
}
|
|
2426
|
-
function merge(oManifest, sInboundId) {
|
|
2427
|
-
var oInbound = {};
|
|
2428
|
-
oInbound[sInboundId] = oManifest["sap.app"]["crossNavigation"]["inbounds"][sInboundId];
|
|
2429
|
-
oManifest["sap.app"]["crossNavigation"]["inbounds"] = oInbound;
|
|
2430
|
-
}
|
|
2431
|
-
var RemoveAllInboundsExceptOne = {
|
|
2432
|
-
applyChange: function (oManifest, oChange) {
|
|
2433
|
-
checkManifestPath(oManifest);
|
|
2434
|
-
var sInboundId = getAndCheckInboundId$1(oChange.getContent());
|
|
2435
|
-
if (oManifest["sap.app"]["crossNavigation"]["inbounds"][sInboundId]) {
|
|
2436
|
-
merge(oManifest, sInboundId);
|
|
2437
|
-
} else {
|
|
2438
|
-
throw new Error("No inbound exists with the ID \"" + sInboundId + "\" in sap.app/crossNavigation/inbounds");
|
|
2439
|
-
}
|
|
2440
|
-
return oManifest;
|
|
2441
|
-
}
|
|
2442
|
-
};
|
|
2443
|
-
|
|
2444
|
-
var SUPPORTED_OPERATIONS = ["UPDATE", "UPSERT"];
|
|
2445
|
-
var SUPPORTED_PROPERTIES = ["title", "subTitle", "icon", "signature/parameters/*"];
|
|
2446
|
-
var ChangeInbound = {
|
|
2447
|
-
applyChange: function (oManifest, oChange) {
|
|
2448
|
-
var oCrossNavigation = oManifest["sap.app"].crossNavigation;
|
|
2449
|
-
var oChangeContent = oChange.getContent();
|
|
2450
|
-
DescriptorChangeCheck.checkEntityPropertyChange(oChangeContent, SUPPORTED_PROPERTIES, SUPPORTED_OPERATIONS);
|
|
2451
|
-
if (oCrossNavigation && oCrossNavigation.inbounds) {
|
|
2452
|
-
var oInbound = oCrossNavigation.inbounds[oChangeContent.inboundId];
|
|
2453
|
-
if (oInbound) {
|
|
2454
|
-
changePropertyValueByPath(oChangeContent.entityPropertyChange, oInbound);
|
|
2455
|
-
} else {
|
|
2456
|
-
throw new Error("Nothing to update. Inbound with ID \"" + oChangeContent.inboundId + "\" does not exist.");
|
|
2457
|
-
}
|
|
2458
|
-
} else {
|
|
2459
|
-
throw new Error("sap.app/crossNavigation or sap.app/crossNavigation/inbounds sections have not been found in manifest.json");
|
|
2460
|
-
}
|
|
2461
|
-
return oManifest;
|
|
2462
|
-
}
|
|
2463
|
-
};
|
|
2464
|
-
|
|
2465
|
-
function getAndCheckInboundId(oChangeContent) {
|
|
2466
|
-
var aInbounds = Object.keys(oChangeContent["inbound"]);
|
|
2467
|
-
if (aInbounds.length > 1) {
|
|
2468
|
-
throw new Error("It is not allowed to add more than one inbound");
|
|
2469
|
-
}
|
|
2470
|
-
if (aInbounds.length < 1) {
|
|
2471
|
-
throw new Error("Inbound does not exist");
|
|
2472
|
-
}
|
|
2473
|
-
if (aInbounds[0] === "") {
|
|
2474
|
-
throw new Error("The ID of your inbound is empty");
|
|
2475
|
-
}
|
|
2476
|
-
return aInbounds[aInbounds.length - 1];
|
|
2477
|
-
}
|
|
2478
|
-
var AddNewInbound = {
|
|
2479
|
-
applyChange: function (oManifest, oChange) {
|
|
2480
|
-
if (!oManifest["sap.app"]["crossNavigation"]) {
|
|
2481
|
-
oManifest["sap.app"]["crossNavigation"] = {};
|
|
2482
|
-
}
|
|
2483
|
-
if (!oManifest["sap.app"]["crossNavigation"]["inbounds"]) {
|
|
2484
|
-
oManifest["sap.app"]["crossNavigation"]["inbounds"] = {};
|
|
2485
|
-
}
|
|
2486
|
-
var oChangeContent = oChange.getContent();
|
|
2487
|
-
var sInboundId = getAndCheckInboundId(oChangeContent);
|
|
2488
|
-
var oInboundInManifest = oManifest["sap.app"]["crossNavigation"]["inbounds"][sInboundId];
|
|
2489
|
-
if (!oInboundInManifest) {
|
|
2490
|
-
DescriptorChangeCheck.checkIdNamespaceCompliance(sInboundId, oChange);
|
|
2491
|
-
oManifest["sap.app"]["crossNavigation"]["inbounds"][sInboundId] = oChangeContent["inbound"][sInboundId];
|
|
2492
|
-
} else {
|
|
2493
|
-
throw new Error("Inbound with ID \"" + sInboundId + "\" already exist.");
|
|
2494
|
-
}
|
|
2495
|
-
return oManifest;
|
|
2496
|
-
}
|
|
2497
|
-
};
|
|
2498
|
-
|
|
2499
|
-
var SetAbstract = {
|
|
2500
|
-
applyChange: function (oManifest, oChange) {
|
|
2501
|
-
if (!oChange.getContent().hasOwnProperty("abstract")) {
|
|
2502
|
-
throw new Error("No abstract in change content provided");
|
|
2503
|
-
}
|
|
2504
|
-
if (oChange.getContent().abstract !== false) {
|
|
2505
|
-
throw new Error("The current change value of property abstract is '" + oChange.getContent().abstract + "'. Only allowed value for property abstract is boolean 'false'");
|
|
2506
|
-
}
|
|
2507
|
-
ObjectPath.set(["sap.fiori", "abstract"], oChange.getContent().abstract, oManifest);
|
|
2508
|
-
return oManifest;
|
|
2509
|
-
}
|
|
2510
|
-
};
|
|
2511
|
-
|
|
2512
|
-
function _mergeExistingLibrary(oManifestLib, oChangeLib) {
|
|
2513
|
-
var oUpdatedLibrary = {};
|
|
2514
|
-
if (oChangeLib.minVersion) {
|
|
2515
|
-
var vManifest = new Version(oManifestLib.minVersion);
|
|
2516
|
-
oUpdatedLibrary.minVersion = vManifest.compareTo(oChangeLib.minVersion) >= 0 ? oManifestLib.minVersion : oChangeLib.minVersion;
|
|
2517
|
-
}
|
|
2518
|
-
if (oChangeLib.lazy) {
|
|
2519
|
-
oUpdatedLibrary.lazy = oManifestLib.lazy === oChangeLib.lazy === true;
|
|
2520
|
-
}
|
|
2521
|
-
return oUpdatedLibrary;
|
|
2522
|
-
}
|
|
2523
|
-
var AddLibrary = {
|
|
2524
|
-
applyChange: function (oManifest, oChange) {
|
|
2525
|
-
if (!oManifest["sap.ui5"]["dependencies"]["libs"]) {
|
|
2526
|
-
oManifest["sap.ui5"]["dependencies"]["libs"] = {};
|
|
2527
|
-
}
|
|
2528
|
-
var oManifestLibs = oManifest["sap.ui5"]["dependencies"]["libs"];
|
|
2529
|
-
var oChangeLibs = oChange.getContent().libraries;
|
|
2530
|
-
Object.keys(oChangeLibs).forEach(function (sLibName) {
|
|
2531
|
-
if (oManifestLibs[sLibName]) {
|
|
2532
|
-
oManifestLibs[sLibName] = _mergeExistingLibrary(oManifestLibs[sLibName], oChangeLibs[sLibName]);
|
|
2533
|
-
} else {
|
|
2534
|
-
oManifestLibs[sLibName] = oChangeLibs[sLibName];
|
|
2535
|
-
}
|
|
2536
|
-
});
|
|
2537
|
-
return oManifest;
|
|
2538
|
-
}
|
|
2539
|
-
};
|
|
2540
|
-
|
|
2541
|
-
var SetTitle = {
|
|
2542
|
-
applyChange: function (oManifest) {
|
|
2543
|
-
oManifest["sap.app"].title = "{{" + oManifest["sap.app"].id + "_sap.app.title}}";
|
|
2544
|
-
return oManifest;
|
|
2545
|
-
}
|
|
2546
|
-
};
|
|
2547
|
-
|
|
2548
|
-
var ChangeCard = {
|
|
2549
|
-
applyChange: function (oManifest, oChange) {
|
|
2550
|
-
var oChangedCard = oChange.getContent();
|
|
2551
|
-
var bIsOperationValid = oChangedCard.entityPropertyChange.operation === "UPSERT";
|
|
2552
|
-
var oOldCards = oManifest["sap.ovp"].cards;
|
|
2553
|
-
var oPropertyChange = oChangedCard.entityPropertyChange;
|
|
2554
|
-
if (Array.isArray(oPropertyChange)) {
|
|
2555
|
-
throw Error("Expected value for oPropertyChange was an object");
|
|
2556
|
-
}
|
|
2557
|
-
if (!bIsOperationValid) {
|
|
2558
|
-
throw Error("This Operation is not supported");
|
|
2559
|
-
}
|
|
2560
|
-
if ((oChangedCard.cardId in oOldCards) && ("propertyPath" in oPropertyChange)) {
|
|
2561
|
-
ObjectPath.set([oChangedCard.cardId, oPropertyChange.propertyPath], oPropertyChange.propertyValue, oOldCards);
|
|
2562
|
-
} else {
|
|
2563
|
-
throw Error("Change card settings was not found");
|
|
2564
|
-
}
|
|
2565
|
-
return oManifest;
|
|
2566
|
-
}
|
|
2567
|
-
};
|
|
2568
|
-
|
|
2569
|
-
var AddNewCard = {
|
|
2570
|
-
applyChange: function (oManifest, oChange) {
|
|
2571
|
-
var oNewCard = oChange.getContent();
|
|
2572
|
-
var oOldCards = oManifest["sap.ovp"].cards;
|
|
2573
|
-
if (("card" in oNewCard) && Object.keys(oNewCard.card).length > 0 && !((Object.keys(oNewCard.card) in oOldCards))) {
|
|
2574
|
-
Object.assign(oOldCards, oNewCard.card);
|
|
2575
|
-
} else {
|
|
2576
|
-
throw Error("No new card found");
|
|
2577
|
-
}
|
|
2578
|
-
return oManifest;
|
|
2579
|
-
}
|
|
2580
|
-
};
|
|
2581
|
-
|
|
2582
|
-
var DeleteCard = {
|
|
2583
|
-
applyChange: function (oManifest, oChange) {
|
|
2584
|
-
var oDeleteCard = oChange.getContent();
|
|
2585
|
-
var oOldCards = oManifest["sap.ovp"].cards;
|
|
2586
|
-
if ((oDeleteCard.cardId in oOldCards)) {
|
|
2587
|
-
delete oOldCards[oDeleteCard.cardId];
|
|
2588
|
-
} else {
|
|
2589
|
-
throw Error("The card to be deleted was not found");
|
|
2590
|
-
}
|
|
2591
|
-
return oManifest;
|
|
2592
|
-
}
|
|
2593
|
-
};
|
|
2594
|
-
|
|
2595
|
-
var fnAssert = function (bResult, vMessage) {
|
|
2596
|
-
if (!bResult) {
|
|
2597
|
-
var sMessage = typeof vMessage === "function" ? vMessage() : vMessage;
|
|
2598
|
-
console.assert(bResult, sMessage);
|
|
2599
|
-
}
|
|
2600
|
-
};
|
|
2601
|
-
|
|
2602
|
-
var fnNow = !(typeof window != "undefined" && window.performance && performance.now && performance.timing) ? Date.now : (function () {
|
|
2603
|
-
var iNavigationStart = performance.timing.navigationStart;
|
|
2604
|
-
return function perfnow() {
|
|
2605
|
-
return iNavigationStart + performance.now();
|
|
2606
|
-
};
|
|
2607
|
-
})();
|
|
2608
|
-
|
|
2609
|
-
var Log = {};
|
|
2610
|
-
Log.Level = {
|
|
2611
|
-
NONE: -1,
|
|
2612
|
-
FATAL: 0,
|
|
2613
|
-
ERROR: 1,
|
|
2614
|
-
WARNING: 2,
|
|
2615
|
-
INFO: 3,
|
|
2616
|
-
DEBUG: 4,
|
|
2617
|
-
TRACE: 5,
|
|
2618
|
-
ALL: 5 + 1
|
|
2619
|
-
};
|
|
2620
|
-
var aLog = [], mMaxLevel = {
|
|
2621
|
-
"": Log.Level.ERROR
|
|
2622
|
-
}, iLogEntriesLimit = 3000, oListener = null, bLogSupportInfo = false;
|
|
2623
|
-
function pad0(i, w) {
|
|
2624
|
-
return ("000" + String(i)).slice(-w);
|
|
2625
|
-
}
|
|
2626
|
-
function level(sComponent) {
|
|
2627
|
-
return !sComponent || isNaN(mMaxLevel[sComponent]) ? mMaxLevel[""] : mMaxLevel[sComponent];
|
|
2628
|
-
}
|
|
2629
|
-
function discardLogEntries() {
|
|
2630
|
-
var iLogLength = aLog.length;
|
|
2631
|
-
if (iLogLength) {
|
|
2632
|
-
var iEntriesToKeep = Math.min(iLogLength, Math.floor(iLogEntriesLimit * 0.7));
|
|
2633
|
-
if (oListener) {
|
|
2634
|
-
oListener.onDiscardLogEntries(aLog.slice(0, iLogLength - iEntriesToKeep));
|
|
2635
|
-
}
|
|
2636
|
-
if (iEntriesToKeep) {
|
|
2637
|
-
aLog = aLog.slice(-iEntriesToKeep, iLogLength);
|
|
2638
|
-
} else {
|
|
2639
|
-
aLog = [];
|
|
2640
|
-
}
|
|
2641
|
-
}
|
|
2642
|
-
}
|
|
2643
|
-
function getLogEntryListenerInstance() {
|
|
2644
|
-
if (!oListener) {
|
|
2645
|
-
oListener = {
|
|
2646
|
-
listeners: [],
|
|
2647
|
-
onLogEntry: function (oLogEntry) {
|
|
2648
|
-
for (var i = 0; i < oListener.listeners.length; i++) {
|
|
2649
|
-
if (oListener.listeners[i].onLogEntry) {
|
|
2650
|
-
oListener.listeners[i].onLogEntry(oLogEntry);
|
|
2651
|
-
}
|
|
2652
|
-
}
|
|
2653
|
-
},
|
|
2654
|
-
onDiscardLogEntries: function (aDiscardedLogEntries) {
|
|
2655
|
-
for (var i = 0; i < oListener.listeners.length; i++) {
|
|
2656
|
-
if (oListener.listeners[i].onDiscardLogEntries) {
|
|
2657
|
-
oListener.listeners[i].onDiscardLogEntries(aDiscardedLogEntries);
|
|
2658
|
-
}
|
|
2659
|
-
}
|
|
2660
|
-
},
|
|
2661
|
-
attach: function (oLog, oLstnr) {
|
|
2662
|
-
if (oLstnr) {
|
|
2663
|
-
oListener.listeners.push(oLstnr);
|
|
2664
|
-
if (oLstnr.onAttachToLog) {
|
|
2665
|
-
oLstnr.onAttachToLog(oLog);
|
|
2666
|
-
}
|
|
2667
|
-
}
|
|
2668
|
-
},
|
|
2669
|
-
detach: function (oLog, oLstnr) {
|
|
2670
|
-
for (var i = 0; i < oListener.listeners.length; i++) {
|
|
2671
|
-
if (oListener.listeners[i] === oLstnr) {
|
|
2672
|
-
if (oLstnr.onDetachFromLog) {
|
|
2673
|
-
oLstnr.onDetachFromLog(oLog);
|
|
2674
|
-
}
|
|
2675
|
-
oListener.listeners.splice(i, 1);
|
|
2676
|
-
return;
|
|
2677
|
-
}
|
|
2678
|
-
}
|
|
2679
|
-
}
|
|
2680
|
-
};
|
|
2681
|
-
}
|
|
2682
|
-
return oListener;
|
|
2683
|
-
}
|
|
2684
|
-
Log.fatal = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
|
2685
|
-
log(Log.Level.FATAL, sMessage, vDetails, sComponent, fnSupportInfo);
|
|
2686
|
-
};
|
|
2687
|
-
Log.error = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
|
2688
|
-
log(Log.Level.ERROR, sMessage, vDetails, sComponent, fnSupportInfo);
|
|
2689
|
-
};
|
|
2690
|
-
Log.warning = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
|
2691
|
-
log(Log.Level.WARNING, sMessage, vDetails, sComponent, fnSupportInfo);
|
|
2692
|
-
};
|
|
2693
|
-
Log.info = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
|
2694
|
-
log(Log.Level.INFO, sMessage, vDetails, sComponent, fnSupportInfo);
|
|
2695
|
-
};
|
|
2696
|
-
Log.debug = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
|
2697
|
-
log(Log.Level.DEBUG, sMessage, vDetails, sComponent, fnSupportInfo);
|
|
2698
|
-
};
|
|
2699
|
-
Log.trace = function (sMessage, vDetails, sComponent, fnSupportInfo) {
|
|
2700
|
-
log(Log.Level.TRACE, sMessage, vDetails, sComponent, fnSupportInfo);
|
|
2701
|
-
};
|
|
2702
|
-
Log.setLevel = function (iLogLevel, sComponent, _bDefault) {
|
|
2703
|
-
sComponent = sComponent || "";
|
|
2704
|
-
if (!_bDefault || mMaxLevel[sComponent] == null) {
|
|
2705
|
-
mMaxLevel[sComponent] = iLogLevel;
|
|
2706
|
-
var sLogLevel;
|
|
2707
|
-
Object.keys(Log.Level).forEach(function (sLevel) {
|
|
2708
|
-
if (Log.Level[sLevel] === iLogLevel) {
|
|
2709
|
-
sLogLevel = sLevel;
|
|
2710
|
-
}
|
|
2711
|
-
});
|
|
2712
|
-
log(Log.Level.INFO, "Changing log level " + (sComponent ? "for '" + sComponent + "' " : "") + "to " + sLogLevel, "", "sap.base.log");
|
|
2713
|
-
}
|
|
2714
|
-
};
|
|
2715
|
-
Log.getLevel = function (sComponent) {
|
|
2716
|
-
return level(sComponent);
|
|
2717
|
-
};
|
|
2718
|
-
Log.isLoggable = function (iLevel, sComponent) {
|
|
2719
|
-
return (iLevel == null ? Log.Level.DEBUG : iLevel) <= level(sComponent);
|
|
2720
|
-
};
|
|
2721
|
-
Log.logSupportInfo = function (bEnabled) {
|
|
2722
|
-
bLogSupportInfo = bEnabled;
|
|
2723
|
-
};
|
|
2724
|
-
function log(iLevel, sMessage, vDetails, sComponent, fnSupportInfo) {
|
|
2725
|
-
if (!fnSupportInfo && !sComponent && typeof vDetails === "function") {
|
|
2726
|
-
fnSupportInfo = vDetails;
|
|
2727
|
-
vDetails = "";
|
|
2728
|
-
}
|
|
2729
|
-
if (!fnSupportInfo && typeof sComponent === "function") {
|
|
2730
|
-
fnSupportInfo = sComponent;
|
|
2731
|
-
sComponent = "";
|
|
2732
|
-
}
|
|
2733
|
-
if (iLevel <= level(sComponent)) {
|
|
2734
|
-
var fNow = fnNow(), oNow = new Date(fNow), iMicroSeconds = Math.floor((fNow - Math.floor(fNow)) * 1000), oLogEntry = {
|
|
2735
|
-
time: pad0(oNow.getHours(), 2) + ":" + pad0(oNow.getMinutes(), 2) + ":" + pad0(oNow.getSeconds(), 2) + "." + pad0(oNow.getMilliseconds(), 3) + pad0(iMicroSeconds, 3),
|
|
2736
|
-
date: pad0(oNow.getFullYear(), 4) + "-" + pad0(oNow.getMonth() + 1, 2) + "-" + pad0(oNow.getDate(), 2),
|
|
2737
|
-
timestamp: fNow,
|
|
2738
|
-
level: iLevel,
|
|
2739
|
-
message: String(sMessage || ""),
|
|
2740
|
-
details: String(vDetails || ""),
|
|
2741
|
-
component: String(sComponent || "")
|
|
2742
|
-
};
|
|
2743
|
-
if (bLogSupportInfo && typeof fnSupportInfo === "function") {
|
|
2744
|
-
oLogEntry.supportInfo = fnSupportInfo();
|
|
2745
|
-
}
|
|
2746
|
-
if (iLogEntriesLimit) {
|
|
2747
|
-
if (aLog.length >= iLogEntriesLimit) {
|
|
2748
|
-
discardLogEntries();
|
|
2749
|
-
}
|
|
2750
|
-
aLog.push(oLogEntry);
|
|
2751
|
-
}
|
|
2752
|
-
if (oListener) {
|
|
2753
|
-
oListener.onLogEntry(oLogEntry);
|
|
2754
|
-
}
|
|
2755
|
-
if (console) {
|
|
2756
|
-
var isDetailsError = vDetails instanceof Error, logText = oLogEntry.date + " " + oLogEntry.time + " " + oLogEntry.message + " - " + oLogEntry.details + " " + oLogEntry.component;
|
|
2757
|
-
switch (iLevel) {
|
|
2758
|
-
case Log.Level.FATAL:
|
|
2759
|
-
case Log.Level.ERROR:
|
|
2760
|
-
isDetailsError ? console.error(logText, "\n", vDetails) : console.error(logText);
|
|
2761
|
-
break;
|
|
2762
|
-
case Log.Level.WARNING:
|
|
2763
|
-
isDetailsError ? console.warn(logText, "\n", vDetails) : console.warn(logText);
|
|
2764
|
-
break;
|
|
2765
|
-
case Log.Level.INFO:
|
|
2766
|
-
if (console.info) {
|
|
2767
|
-
isDetailsError ? console.info(logText, "\n", vDetails) : console.info(logText);
|
|
2768
|
-
} else {
|
|
2769
|
-
isDetailsError ? console.log(logText, "\n", vDetails) : console.log(logText);
|
|
2770
|
-
}
|
|
2771
|
-
break;
|
|
2772
|
-
case Log.Level.DEBUG:
|
|
2773
|
-
isDetailsError ? console.debug(logText, "\n", vDetails) : console.debug(logText);
|
|
2774
|
-
break;
|
|
2775
|
-
case Log.Level.TRACE:
|
|
2776
|
-
isDetailsError ? console.trace(logText, "\n", vDetails) : console.trace(logText);
|
|
2777
|
-
break;
|
|
2778
|
-
}
|
|
2779
|
-
if (console.info && oLogEntry.supportInfo) {
|
|
2780
|
-
console.info(oLogEntry.supportInfo);
|
|
2781
|
-
}
|
|
2782
|
-
}
|
|
2783
|
-
return oLogEntry;
|
|
2784
|
-
}
|
|
2785
|
-
}
|
|
2786
|
-
Log.getLogEntries = function () {
|
|
2787
|
-
return aLog.slice();
|
|
2788
|
-
};
|
|
2789
|
-
Log.getLogEntriesLimit = function () {
|
|
2790
|
-
return iLogEntriesLimit;
|
|
2791
|
-
};
|
|
2792
|
-
Log.setLogEntriesLimit = function (iLimit) {
|
|
2793
|
-
if (iLimit < 0) {
|
|
2794
|
-
throw new Error("The log entries limit needs to be greater than or equal to 0!");
|
|
2795
|
-
}
|
|
2796
|
-
iLogEntriesLimit = iLimit;
|
|
2797
|
-
if (aLog.length >= iLogEntriesLimit) {
|
|
2798
|
-
discardLogEntries();
|
|
2799
|
-
}
|
|
2800
|
-
};
|
|
2801
|
-
Log.addLogListener = function (oListener) {
|
|
2802
|
-
getLogEntryListenerInstance().attach(this, oListener);
|
|
2803
|
-
};
|
|
2804
|
-
Log.removeLogListener = function (oListener) {
|
|
2805
|
-
getLogEntryListenerInstance().detach(this, oListener);
|
|
2806
|
-
};
|
|
2807
|
-
function Logger(sComponent) {
|
|
2808
|
-
this.fatal = function (msg, detail, comp, support) {
|
|
2809
|
-
Log.fatal(msg, detail, comp || sComponent, support);
|
|
2810
|
-
return this;
|
|
2811
|
-
};
|
|
2812
|
-
this.error = function (msg, detail, comp, support) {
|
|
2813
|
-
Log.error(msg, detail, comp || sComponent, support);
|
|
2814
|
-
return this;
|
|
2815
|
-
};
|
|
2816
|
-
this.warning = function (msg, detail, comp, support) {
|
|
2817
|
-
Log.warning(msg, detail, comp || sComponent, support);
|
|
2818
|
-
return this;
|
|
2819
|
-
};
|
|
2820
|
-
this.info = function (msg, detail, comp, support) {
|
|
2821
|
-
Log.info(msg, detail, comp || sComponent, support);
|
|
2822
|
-
return this;
|
|
2823
|
-
};
|
|
2824
|
-
this.debug = function (msg, detail, comp, support) {
|
|
2825
|
-
Log.debug(msg, detail, comp || sComponent, support);
|
|
2826
|
-
return this;
|
|
2827
|
-
};
|
|
2828
|
-
this.trace = function (msg, detail, comp, support) {
|
|
2829
|
-
Log.trace(msg, detail, comp || sComponent, support);
|
|
2830
|
-
return this;
|
|
2831
|
-
};
|
|
2832
|
-
this.setLevel = function (level, comp) {
|
|
2833
|
-
Log.setLevel(level, comp || sComponent);
|
|
2834
|
-
return this;
|
|
2835
|
-
};
|
|
2836
|
-
this.getLevel = function (comp) {
|
|
2837
|
-
return Log.getLevel(comp || sComponent);
|
|
2838
|
-
};
|
|
2839
|
-
this.isLoggable = function (level, comp) {
|
|
2840
|
-
return Log.isLoggable(level, comp || sComponent);
|
|
2841
|
-
};
|
|
2842
|
-
}
|
|
2843
|
-
Log.getLogger = function (sComponent, iDefaultLogLevel) {
|
|
2844
|
-
if (!isNaN(iDefaultLogLevel) && mMaxLevel[sComponent] == null) {
|
|
2845
|
-
mMaxLevel[sComponent] = iDefaultLogLevel;
|
|
2846
|
-
}
|
|
2847
|
-
return new Logger(sComponent);
|
|
2848
|
-
};
|
|
2849
|
-
|
|
2850
|
-
var fnUniqueSort = function (aArray) {
|
|
2851
|
-
fnAssert(Array.isArray(aArray), "uniqueSort: input parameter must be an Array");
|
|
2852
|
-
var iLength = aArray.length;
|
|
2853
|
-
if (iLength > 1) {
|
|
2854
|
-
aArray.sort();
|
|
2855
|
-
var j = 0;
|
|
2856
|
-
for (var i = 1; i < iLength; i++) {
|
|
2857
|
-
if (aArray.indexOf(aArray[i]) === i) {
|
|
2858
|
-
aArray[++j] = aArray[i];
|
|
2859
|
-
}
|
|
2860
|
-
}
|
|
2861
|
-
if (++j < iLength) {
|
|
2862
|
-
aArray.splice(j, iLength - j);
|
|
2863
|
-
}
|
|
2864
|
-
}
|
|
2865
|
-
return aArray;
|
|
2866
|
-
};
|
|
2867
|
-
|
|
2868
|
-
function isFunction(obj) {
|
|
2869
|
-
return typeof obj === "function";
|
|
2870
|
-
}
|
|
2871
|
-
var Metadata = function (sClassName, oClassInfo) {
|
|
2872
|
-
fnAssert(typeof sClassName === "string" && sClassName, "Metadata: sClassName must be a non-empty string");
|
|
2873
|
-
fnAssert(typeof oClassInfo === "object", "Metadata: oClassInfo must be empty or an object");
|
|
2874
|
-
if (!oClassInfo || typeof oClassInfo.metadata !== "object") {
|
|
2875
|
-
oClassInfo = {
|
|
2876
|
-
metadata: oClassInfo || ({}),
|
|
2877
|
-
constructor: ObjectPath.get(sClassName)
|
|
2878
|
-
};
|
|
2879
|
-
oClassInfo.metadata.__version = 1;
|
|
2880
|
-
}
|
|
2881
|
-
oClassInfo.metadata.__version = oClassInfo.metadata.__version || 2;
|
|
2882
|
-
if (!isFunction(oClassInfo.constructor)) {
|
|
2883
|
-
throw Error("constructor for class " + sClassName + " must have been declared before creating metadata for it");
|
|
2884
|
-
}
|
|
2885
|
-
this._sClassName = sClassName;
|
|
2886
|
-
this._oClass = oClassInfo.constructor;
|
|
2887
|
-
this.extend(oClassInfo);
|
|
2888
|
-
};
|
|
2889
|
-
Metadata.prototype.extend = function (oClassInfo) {
|
|
2890
|
-
this.applySettings(oClassInfo);
|
|
2891
|
-
this.afterApplySettings();
|
|
2892
|
-
};
|
|
2893
|
-
Metadata.prototype.applySettings = function (oClassInfo) {
|
|
2894
|
-
var that = this, oStaticInfo = oClassInfo.metadata, oPrototype;
|
|
2895
|
-
if (oStaticInfo.baseType) {
|
|
2896
|
-
var oParentClass;
|
|
2897
|
-
if (isFunction(oStaticInfo.baseType)) {
|
|
2898
|
-
oParentClass = oStaticInfo.baseType;
|
|
2899
|
-
if (!isFunction(oParentClass.getMetadata)) {
|
|
2900
|
-
throw new TypeError("baseType must be a UI5 class with a static getMetadata function");
|
|
2901
|
-
}
|
|
2902
|
-
} else {
|
|
2903
|
-
oParentClass = ObjectPath.get(oStaticInfo.baseType);
|
|
2904
|
-
if (!isFunction(oParentClass)) {
|
|
2905
|
-
Log.fatal("base class '" + oStaticInfo.baseType + "' does not exist");
|
|
2906
|
-
}
|
|
2907
|
-
}
|
|
2908
|
-
if (oParentClass.getMetadata) {
|
|
2909
|
-
this._oParent = oParentClass.getMetadata();
|
|
2910
|
-
fnAssert(oParentClass === oParentClass.getMetadata().getClass(), "Metadata: oParentClass must match the class in the parent metadata");
|
|
2911
|
-
} else {
|
|
2912
|
-
this._oParent = new Metadata(oStaticInfo.baseType, {});
|
|
2913
|
-
}
|
|
2914
|
-
} else {
|
|
2915
|
-
this._oParent = undefined;
|
|
2916
|
-
}
|
|
2917
|
-
this._bAbstract = !!oStaticInfo["abstract"];
|
|
2918
|
-
this._bFinal = !!oStaticInfo["final"];
|
|
2919
|
-
this._sStereotype = oStaticInfo.stereotype || (this._oParent ? this._oParent._sStereotype : "object");
|
|
2920
|
-
this._bDeprecated = !!oStaticInfo["deprecated"];
|
|
2921
|
-
this._aInterfaces = oStaticInfo.interfaces || [];
|
|
2922
|
-
this._aPublicMethods = oStaticInfo.publicMethods || [];
|
|
2923
|
-
this._bInterfacesUnique = false;
|
|
2924
|
-
oPrototype = this._oClass.prototype;
|
|
2925
|
-
for (var n in oClassInfo) {
|
|
2926
|
-
if (n !== "metadata" && n !== "constructor") {
|
|
2927
|
-
oPrototype[n] = oClassInfo[n];
|
|
2928
|
-
if (!n.match(/^_|^on|^init$|^exit$/)) {
|
|
2929
|
-
that._aPublicMethods.push(n);
|
|
2930
|
-
}
|
|
2931
|
-
}
|
|
2932
|
-
}
|
|
2933
|
-
};
|
|
2934
|
-
Metadata.prototype.afterApplySettings = function () {
|
|
2935
|
-
if (this._oParent) {
|
|
2936
|
-
this._aAllPublicMethods = this._oParent._aAllPublicMethods.concat(this._aPublicMethods);
|
|
2937
|
-
this._bInterfacesUnique = false;
|
|
2938
|
-
} else {
|
|
2939
|
-
this._aAllPublicMethods = this._aPublicMethods;
|
|
2940
|
-
}
|
|
2941
|
-
};
|
|
2942
|
-
Metadata.prototype.getStereotype = function () {
|
|
2943
|
-
return this._sStereotype;
|
|
2944
|
-
};
|
|
2945
|
-
Metadata.prototype.getName = function () {
|
|
2946
|
-
return this._sClassName;
|
|
2947
|
-
};
|
|
2948
|
-
Metadata.prototype.getClass = function () {
|
|
2949
|
-
return this._oClass;
|
|
2950
|
-
};
|
|
2951
|
-
Metadata.prototype.getParent = function () {
|
|
2952
|
-
return this._oParent;
|
|
2953
|
-
};
|
|
2954
|
-
Metadata.prototype._dedupInterfaces = function () {
|
|
2955
|
-
if (!this._bInterfacesUnique) {
|
|
2956
|
-
fnUniqueSort(this._aInterfaces);
|
|
2957
|
-
fnUniqueSort(this._aPublicMethods);
|
|
2958
|
-
fnUniqueSort(this._aAllPublicMethods);
|
|
2959
|
-
this._bInterfacesUnique = true;
|
|
2960
|
-
}
|
|
2961
|
-
};
|
|
2962
|
-
Metadata.prototype.getPublicMethods = function () {
|
|
2963
|
-
this._dedupInterfaces();
|
|
2964
|
-
return this._aPublicMethods;
|
|
2965
|
-
};
|
|
2966
|
-
Metadata.prototype.getAllPublicMethods = function () {
|
|
2967
|
-
this._dedupInterfaces();
|
|
2968
|
-
return this._aAllPublicMethods;
|
|
2969
|
-
};
|
|
2970
|
-
Metadata.prototype.getInterfaces = function () {
|
|
2971
|
-
this._dedupInterfaces();
|
|
2972
|
-
return this._aInterfaces;
|
|
2973
|
-
};
|
|
2974
|
-
Metadata.prototype.isInstanceOf = function (sInterface) {
|
|
2975
|
-
if (this._oParent) {
|
|
2976
|
-
if (this._oParent.isInstanceOf(sInterface)) {
|
|
2977
|
-
return true;
|
|
2978
|
-
}
|
|
2979
|
-
}
|
|
2980
|
-
var a = this._aInterfaces;
|
|
2981
|
-
for (var i = 0, l = a.length; i < l; i++) {
|
|
2982
|
-
if (a[i] === sInterface) {
|
|
2983
|
-
return true;
|
|
2984
|
-
}
|
|
2985
|
-
}
|
|
2986
|
-
return false;
|
|
2987
|
-
};
|
|
2988
|
-
Object.defineProperty(Metadata.prototype, "_mImplementedTypes", {
|
|
2989
|
-
get: function () {
|
|
2990
|
-
if (this === Metadata.prototype) {
|
|
2991
|
-
throw new Error("sap.ui.base.Metadata: The '_mImplementedTypes' property must not be accessed on the prototype");
|
|
2992
|
-
}
|
|
2993
|
-
var result = Object.create(this._oParent ? this._oParent._mImplementedTypes : null);
|
|
2994
|
-
result[this._sClassName] = true;
|
|
2995
|
-
var aInterfaces = this._aInterfaces, i = aInterfaces.length;
|
|
2996
|
-
while (i-- > 0) {
|
|
2997
|
-
if (!result[aInterfaces[i]]) {
|
|
2998
|
-
result[aInterfaces[i]] = true;
|
|
2999
|
-
}
|
|
3000
|
-
}
|
|
3001
|
-
Object.defineProperty(this, "_mImplementedTypes", {
|
|
3002
|
-
value: Object.freeze(result),
|
|
3003
|
-
writable: false,
|
|
3004
|
-
configurable: false
|
|
3005
|
-
});
|
|
3006
|
-
return result;
|
|
3007
|
-
},
|
|
3008
|
-
configurable: true
|
|
3009
|
-
});
|
|
3010
|
-
Metadata.prototype.isA = function (vTypeName) {
|
|
3011
|
-
var mTypes = this._mImplementedTypes;
|
|
3012
|
-
if (Array.isArray(vTypeName)) {
|
|
3013
|
-
for (var i = 0; i < vTypeName.length; i++) {
|
|
3014
|
-
if ((vTypeName[i] in mTypes)) {
|
|
3015
|
-
return true;
|
|
3016
|
-
}
|
|
3017
|
-
}
|
|
3018
|
-
return false;
|
|
3019
|
-
}
|
|
3020
|
-
return (vTypeName in mTypes);
|
|
3021
|
-
};
|
|
3022
|
-
Metadata.prototype.isAbstract = function () {
|
|
3023
|
-
return this._bAbstract;
|
|
3024
|
-
};
|
|
3025
|
-
Metadata.prototype.isFinal = function () {
|
|
3026
|
-
return this._bFinal;
|
|
3027
|
-
};
|
|
3028
|
-
Metadata.prototype.isDeprecated = function () {
|
|
3029
|
-
return this._bDeprecated;
|
|
3030
|
-
};
|
|
3031
|
-
Metadata.prototype.addPublicMethods = function (sMethod) {
|
|
3032
|
-
var aNames = sMethod instanceof Array ? sMethod : arguments;
|
|
3033
|
-
Array.prototype.push.apply(this._aPublicMethods, aNames);
|
|
3034
|
-
Array.prototype.push.apply(this._aAllPublicMethods, aNames);
|
|
3035
|
-
this._bInterfacesUnique = false;
|
|
3036
|
-
};
|
|
3037
|
-
Metadata.createClass = function (fnBaseClass, sClassName, oClassInfo, FNMetaImpl) {
|
|
3038
|
-
if (typeof fnBaseClass === "string") {
|
|
3039
|
-
FNMetaImpl = oClassInfo;
|
|
3040
|
-
oClassInfo = sClassName;
|
|
3041
|
-
sClassName = fnBaseClass;
|
|
3042
|
-
fnBaseClass = null;
|
|
3043
|
-
}
|
|
3044
|
-
fnAssert(!fnBaseClass || isFunction(fnBaseClass));
|
|
3045
|
-
fnAssert(typeof sClassName === "string" && !!sClassName);
|
|
3046
|
-
fnAssert(!oClassInfo || typeof oClassInfo === "object");
|
|
3047
|
-
fnAssert(!FNMetaImpl || isFunction(FNMetaImpl));
|
|
3048
|
-
FNMetaImpl = FNMetaImpl || Metadata;
|
|
3049
|
-
if (isFunction(FNMetaImpl.preprocessClassInfo)) {
|
|
3050
|
-
oClassInfo = FNMetaImpl.preprocessClassInfo(oClassInfo);
|
|
3051
|
-
}
|
|
3052
|
-
oClassInfo = oClassInfo || ({});
|
|
3053
|
-
oClassInfo.metadata = oClassInfo.metadata || ({});
|
|
3054
|
-
if (!oClassInfo.hasOwnProperty("constructor")) {
|
|
3055
|
-
oClassInfo.constructor = undefined;
|
|
3056
|
-
}
|
|
3057
|
-
var fnClass = oClassInfo.constructor;
|
|
3058
|
-
fnAssert(!fnClass || isFunction(fnClass));
|
|
3059
|
-
if (fnBaseClass) {
|
|
3060
|
-
if (!fnClass) {
|
|
3061
|
-
if (oClassInfo.metadata.deprecated) {
|
|
3062
|
-
fnClass = function () {
|
|
3063
|
-
Log.warning("Usage of deprecated class: " + sClassName);
|
|
3064
|
-
fnBaseClass.apply(this, arguments);
|
|
3065
|
-
};
|
|
3066
|
-
} else {
|
|
3067
|
-
fnClass = function () {
|
|
3068
|
-
fnBaseClass.apply(this, arguments);
|
|
3069
|
-
};
|
|
3070
|
-
}
|
|
3071
|
-
}
|
|
3072
|
-
fnClass.prototype = Object.create(fnBaseClass.prototype);
|
|
3073
|
-
fnClass.prototype.constructor = fnClass;
|
|
3074
|
-
oClassInfo.metadata.baseType = fnBaseClass;
|
|
3075
|
-
} else {
|
|
3076
|
-
fnClass = fnClass || (function () {});
|
|
3077
|
-
delete oClassInfo.metadata.baseType;
|
|
3078
|
-
}
|
|
3079
|
-
oClassInfo.constructor = fnClass;
|
|
3080
|
-
ObjectPath.set(sClassName, fnClass);
|
|
3081
|
-
var oMetadata = new FNMetaImpl(sClassName, oClassInfo);
|
|
3082
|
-
fnClass.getMetadata = fnClass.prototype.getMetadata = function () {
|
|
3083
|
-
return oMetadata;
|
|
3084
|
-
};
|
|
3085
|
-
if (!fnClass.getMetadata().isFinal()) {
|
|
3086
|
-
fnClass.extend = function (sSCName, oSCClassInfo, fnSCMetaImpl) {
|
|
3087
|
-
return Metadata.createClass(fnClass, sSCName, oSCClassInfo, fnSCMetaImpl || FNMetaImpl);
|
|
3088
|
-
};
|
|
3089
|
-
}
|
|
3090
|
-
return fnClass;
|
|
3091
|
-
};
|
|
3092
|
-
|
|
3093
|
-
var BaseObject = Metadata.createClass("sap.ui.base.Object", {
|
|
3094
|
-
constructor: function () {
|
|
3095
|
-
if (!(this instanceof BaseObject)) {
|
|
3096
|
-
throw Error("Cannot instantiate object: \"new\" is missing!");
|
|
3097
|
-
}
|
|
3098
|
-
}
|
|
3099
|
-
});
|
|
3100
|
-
BaseObject.prototype.destroy = function () {};
|
|
3101
|
-
BaseObject.prototype.getInterface = function () {
|
|
3102
|
-
var oInterface = new BaseObject._Interface(this, this.getMetadata().getAllPublicMethods());
|
|
3103
|
-
this.getInterface = function () {
|
|
3104
|
-
return oInterface;
|
|
3105
|
-
};
|
|
3106
|
-
return oInterface;
|
|
3107
|
-
};
|
|
3108
|
-
BaseObject.defineClass = function (sClassName, oStaticInfo, FNMetaImpl) {
|
|
3109
|
-
var oMetadata = new (FNMetaImpl || Metadata)(sClassName, oStaticInfo);
|
|
3110
|
-
var fnClass = oMetadata.getClass();
|
|
3111
|
-
fnClass.getMetadata = fnClass.prototype.getMetadata = function () {
|
|
3112
|
-
return oMetadata;
|
|
3113
|
-
};
|
|
3114
|
-
if (!oMetadata.isFinal()) {
|
|
3115
|
-
fnClass.extend = function (sSCName, oSCClassInfo, fnSCMetaImpl) {
|
|
3116
|
-
return Metadata.createClass(fnClass, sSCName, oSCClassInfo, fnSCMetaImpl || FNMetaImpl);
|
|
3117
|
-
};
|
|
3118
|
-
}
|
|
3119
|
-
Log.debug("defined class '" + sClassName + "'" + (oMetadata.getParent() ? " as subclass of " + oMetadata.getParent().getName() : ""));
|
|
3120
|
-
return oMetadata;
|
|
3121
|
-
};
|
|
3122
|
-
BaseObject.prototype.isA = function (vTypeName) {
|
|
3123
|
-
return this.getMetadata().isA(vTypeName);
|
|
3124
|
-
};
|
|
3125
|
-
BaseObject.isA = function (oObject, vTypeName) {
|
|
3126
|
-
return oObject instanceof BaseObject && oObject.isA(vTypeName);
|
|
3127
|
-
};
|
|
3128
|
-
BaseObject._Interface = function (oObject, aMethods, _bReturnFacade) {
|
|
3129
|
-
if (!oObject) {
|
|
3130
|
-
return oObject;
|
|
3131
|
-
}
|
|
3132
|
-
function fCreateDelegator(oObject, sMethodName) {
|
|
3133
|
-
return function () {
|
|
3134
|
-
var tmp = oObject[sMethodName].apply(oObject, arguments);
|
|
3135
|
-
if (_bReturnFacade) {
|
|
3136
|
-
return this;
|
|
3137
|
-
} else {
|
|
3138
|
-
return tmp instanceof BaseObject ? tmp.getInterface() : tmp;
|
|
3139
|
-
}
|
|
3140
|
-
};
|
|
3141
|
-
}
|
|
3142
|
-
if (!aMethods) {
|
|
3143
|
-
return {};
|
|
3144
|
-
}
|
|
3145
|
-
var sMethodName;
|
|
3146
|
-
for (var i = 0, ml = aMethods.length; i < ml; i++) {
|
|
3147
|
-
sMethodName = aMethods[i];
|
|
3148
|
-
if (!oObject[sMethodName] || typeof oObject[sMethodName] === "function") {
|
|
3149
|
-
this[sMethodName] = fCreateDelegator(oObject, sMethodName);
|
|
3150
|
-
}
|
|
3151
|
-
}
|
|
3152
|
-
};
|
|
3153
|
-
|
|
3154
|
-
var class2type = {};
|
|
3155
|
-
var hasOwn = class2type.hasOwnProperty;
|
|
3156
|
-
var toString = class2type.toString;
|
|
3157
|
-
var fnToString = hasOwn.toString;
|
|
3158
|
-
var ObjectFunctionString = fnToString.call(Object);
|
|
3159
|
-
var fnIsPlainObject = function (obj) {
|
|
3160
|
-
var proto, Ctor;
|
|
3161
|
-
if (!obj || toString.call(obj) !== "[object Object]") {
|
|
3162
|
-
return false;
|
|
3163
|
-
}
|
|
3164
|
-
proto = Object.getPrototypeOf(obj);
|
|
3165
|
-
if (!proto) {
|
|
3166
|
-
return true;
|
|
3167
|
-
}
|
|
3168
|
-
Ctor = hasOwn.call(proto, "constructor") && proto.constructor;
|
|
3169
|
-
return typeof Ctor === "function" && fnToString.call(Ctor) === ObjectFunctionString;
|
|
3170
|
-
};
|
|
3171
|
-
|
|
3172
|
-
var oToken = Object.create(null);
|
|
3173
|
-
var fnMerge = function () {
|
|
3174
|
-
var src, copyIsArray, copy, name, options, clone, target = arguments[2] || ({}), i = 3, length = arguments.length, deep = arguments[0] || false, skipToken = arguments[1] ? undefined : oToken;
|
|
3175
|
-
if (typeof target !== "object" && typeof target !== "function") {
|
|
3176
|
-
target = {};
|
|
3177
|
-
}
|
|
3178
|
-
for (; i < length; i++) {
|
|
3179
|
-
if ((options = arguments[i]) != null) {
|
|
3180
|
-
for (name in options) {
|
|
3181
|
-
src = target[name];
|
|
3182
|
-
copy = options[name];
|
|
3183
|
-
if (name === "__proto__" || target === copy) {
|
|
3184
|
-
continue;
|
|
3185
|
-
}
|
|
3186
|
-
if (deep && copy && (fnIsPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) {
|
|
3187
|
-
if (copyIsArray) {
|
|
3188
|
-
copyIsArray = false;
|
|
3189
|
-
clone = src && Array.isArray(src) ? src : [];
|
|
3190
|
-
} else {
|
|
3191
|
-
clone = src && fnIsPlainObject(src) ? src : {};
|
|
3192
|
-
}
|
|
3193
|
-
target[name] = fnMerge(deep, arguments[1], clone, copy);
|
|
3194
|
-
} else if (copy !== skipToken) {
|
|
3195
|
-
target[name] = copy;
|
|
3196
|
-
}
|
|
3197
|
-
}
|
|
3198
|
-
}
|
|
3199
|
-
}
|
|
3200
|
-
return target;
|
|
3201
|
-
};
|
|
3202
|
-
|
|
3203
|
-
var fnExtend = function () {
|
|
3204
|
-
var args = [false, true];
|
|
3205
|
-
args.push.apply(args, arguments);
|
|
3206
|
-
return fnMerge.apply(null, args);
|
|
3207
|
-
};
|
|
3208
|
-
|
|
3209
|
-
var sFioriComponent = "FioriElements: ";
|
|
3210
|
-
function getMethods(sClassName, oLog) {
|
|
3211
|
-
var sFullClassName = sFioriComponent + sClassName;
|
|
3212
|
-
return {
|
|
3213
|
-
Level: oLog.Level,
|
|
3214
|
-
addLogListener: function (oListener) {
|
|
3215
|
-
oLog.addLogListener(oListener);
|
|
3216
|
-
},
|
|
3217
|
-
getLogger: function () {
|
|
3218
|
-
var oRet = oLog.getLogger(sFullClassName);
|
|
3219
|
-
return oRet;
|
|
3220
|
-
}
|
|
3221
|
-
};
|
|
3222
|
-
}
|
|
3223
|
-
var FeLogger = BaseObject.extend("sap.suite.ui.generic.template.genericUtilities.FeLogger", {
|
|
3224
|
-
constructor: function (sClassName) {
|
|
3225
|
-
fnExtend(this, getMethods(sClassName, Log));
|
|
3226
|
-
}
|
|
3227
|
-
});
|
|
3228
|
-
|
|
3229
|
-
var oLogger$2 = new FeLogger("manifestMerger.MergerUil").getLogger();
|
|
3230
|
-
var mergerUtil = {
|
|
3231
|
-
iterateAndFind: function iterateFind(oPages, sEntityKey, sPageComponent, sChildPageId, sParentKey) {
|
|
3232
|
-
var oPageStructure;
|
|
3233
|
-
if (Array.isArray(oPages)) {
|
|
3234
|
-
throw new Error("Manifest should have sap.ui.generic.app.pages as Object structure and not array ");
|
|
3235
|
-
}
|
|
3236
|
-
for (var sKey in oPages) {
|
|
3237
|
-
if (sKey === "entitySet" && oPages.entitySet === sEntityKey) {
|
|
3238
|
-
if (oPages.component && oPages.component.name === sPageComponent) {
|
|
3239
|
-
if (oPages.pages) {
|
|
3240
|
-
var aSiblingkeys = Object.keys(oPages.pages);
|
|
3241
|
-
findDuplicate(aSiblingkeys);
|
|
3242
|
-
}
|
|
3243
|
-
oLogger$2.info(oPages);
|
|
3244
|
-
return oPages;
|
|
3245
|
-
}
|
|
3246
|
-
} else if (typeof oPages[sKey] === "object" && !Array.isArray(oPages[sKey])) {
|
|
3247
|
-
if (oPageStructure) {
|
|
3248
|
-
break;
|
|
3249
|
-
}
|
|
3250
|
-
if (sKey === "pages" || sParentKey === "pages") {
|
|
3251
|
-
oPageStructure = iterateFind(oPages[sKey], sEntityKey, sPageComponent, sChildPageId, sKey);
|
|
3252
|
-
}
|
|
3253
|
-
} else if (sKey === "pages" && Array.isArray(oPages[sKey])) {
|
|
3254
|
-
throw new Error("Manifest should have sap.ui.generic.app.pages as Object structure and not array ");
|
|
3255
|
-
}
|
|
3256
|
-
}
|
|
3257
|
-
function findDuplicate(aSiblingkeys) {
|
|
3258
|
-
if (aSiblingkeys.length) {
|
|
3259
|
-
aSiblingkeys.filter(function (sPageKey) {
|
|
3260
|
-
if (sPageKey === sChildPageId) {
|
|
3261
|
-
throw new Error("Adding duplicate pageKey " + sChildPageId + " is not supported.");
|
|
3262
|
-
}
|
|
3263
|
-
});
|
|
3264
|
-
}
|
|
3265
|
-
}
|
|
3266
|
-
return oPageStructure;
|
|
3267
|
-
},
|
|
3268
|
-
consistencyCheck: function (oChangeContent, sMergerType, aSupportedProperties) {
|
|
3269
|
-
if (!oChangeContent["parentPage"]) {
|
|
3270
|
-
throw new Error("Mandatory 'parentPage' parameter is not provided.");
|
|
3271
|
-
}
|
|
3272
|
-
if (!oChangeContent.parentPage.entitySet) {
|
|
3273
|
-
throw new Error("Mandatory 'parentPage.entitySet' parameter is not provided.");
|
|
3274
|
-
}
|
|
3275
|
-
if (!oChangeContent.parentPage.component) {
|
|
3276
|
-
throw new Error("Mandatory 'parentPage.component' parameter is not provided.");
|
|
3277
|
-
}
|
|
3278
|
-
if (sMergerType === "ADD") {
|
|
3279
|
-
if (!oChangeContent.childPage.id) {
|
|
3280
|
-
throw new Error(" Add mandatory parameter 'childPage.id' ");
|
|
3281
|
-
}
|
|
3282
|
-
if (!oChangeContent.childPage.definition) {
|
|
3283
|
-
throw new Error("Mandatory 'childPageDefinition' are not provided. Add 'childPage.definition' to add the new page. ");
|
|
3284
|
-
}
|
|
3285
|
-
var aChildkeys = Object.keys(oChangeContent.childPage.definition);
|
|
3286
|
-
aChildkeys.forEach(function (sKey) {
|
|
3287
|
-
if (!fnIncludes(aSupportedProperties, sKey)) {
|
|
3288
|
-
throw new Error("Changing " + sKey + " is not supported. The supported 'propertyPath' is: " + aSupportedProperties.join(","));
|
|
3289
|
-
}
|
|
3290
|
-
});
|
|
3291
|
-
var aMandatoryParams = aSupportedProperties.filter(function (sComponentKey) {
|
|
3292
|
-
return !fnIncludes(aChildkeys, sComponentKey);
|
|
3293
|
-
});
|
|
3294
|
-
if (aMandatoryParams.length) {
|
|
3295
|
-
throw new Error("Mandatory parameter " + aMandatoryParams + " is not defined.");
|
|
3296
|
-
}
|
|
3297
|
-
} else if (sMergerType === "MODIFY") {
|
|
3298
|
-
if (!oChangeContent.entityPropertyChange) {
|
|
3299
|
-
throw new Error("Changes for \"" + oChangeContent["pageId"] + "\" are not provided.");
|
|
3300
|
-
} else {
|
|
3301
|
-
var oEntityPropertyChange = oChangeContent.entityPropertyChange;
|
|
3302
|
-
if (!oEntityPropertyChange.propertyPath) {
|
|
3303
|
-
throw new Error("Invalid change format: The mandatory 'propertyPath' is not defined. Please define the mandatory property 'propertyPath'");
|
|
3304
|
-
}
|
|
3305
|
-
if (!oEntityPropertyChange.operation || oEntityPropertyChange.operation !== "UPSERT") {
|
|
3306
|
-
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");
|
|
3307
|
-
}
|
|
3308
|
-
if (!oEntityPropertyChange.propertyValue) {
|
|
3309
|
-
throw new Error("Invalid change format: The mandatory 'propertyValue' is not defined. Please define the mandatory property 'propertyValue'");
|
|
3310
|
-
}
|
|
3311
|
-
}
|
|
3312
|
-
}
|
|
3313
|
-
}
|
|
3314
|
-
};
|
|
3315
|
-
|
|
3316
|
-
var oLogger$1 = new FeLogger("manifestMerger.AddNewObjectPage").getLogger();
|
|
3317
|
-
var addNewObjectPage = {
|
|
3318
|
-
applyChange: function (oManifest, oChange) {
|
|
3319
|
-
oLogger$1.info("addNewPage use case");
|
|
3320
|
-
var aSupportedProperties = ["navigationProperty", "entitySet"];
|
|
3321
|
-
var oChangeContent = oChange.getContent();
|
|
3322
|
-
var sChildPageId = oChangeContent.childPage && oChangeContent.childPage.id;
|
|
3323
|
-
if (sChildPageId) {
|
|
3324
|
-
DescriptorChangeCheck.checkIdNamespaceCompliance(sChildPageId, oChange);
|
|
3325
|
-
}
|
|
3326
|
-
mergerUtil.consistencyCheck(oChangeContent, "ADD", aSupportedProperties);
|
|
3327
|
-
var sParentEntitySet = oChangeContent.parentPage.entitySet;
|
|
3328
|
-
var sParentComponent = oChangeContent.parentPage.component;
|
|
3329
|
-
var oPageStructure = mergerUtil.iterateAndFind(oManifest["sap.ui.generic.app"], sParentEntitySet, sParentComponent, sChildPageId);
|
|
3330
|
-
var oComponentContent = {
|
|
3331
|
-
"name": "sap.suite.ui.generic.template.ObjectPage"
|
|
3332
|
-
};
|
|
3333
|
-
if (oPageStructure) {
|
|
3334
|
-
if (oPageStructure.pages && Array.isArray(oPageStructure.pages)) {
|
|
3335
|
-
throw Error("Manifest should have sap.ui.generic.app.pages as Object structure and not array");
|
|
3336
|
-
}
|
|
3337
|
-
ObjectPath.create(["pages", sChildPageId], oPageStructure);
|
|
3338
|
-
ObjectPath.set(["pages", sChildPageId], oChangeContent.childPage.definition, oPageStructure);
|
|
3339
|
-
ObjectPath.set(["pages", sChildPageId, "component"], oComponentContent, oPageStructure);
|
|
3340
|
-
} else {
|
|
3341
|
-
throw Error("The target content definition is invalid");
|
|
3342
|
-
}
|
|
3343
|
-
return oManifest;
|
|
3344
|
-
}
|
|
3345
|
-
};
|
|
3346
|
-
|
|
3347
|
-
var oLogger = new FeLogger("manifestMerger.ChangePageConfiguration").getLogger();
|
|
3348
|
-
var changePageConfiguration = {
|
|
3349
|
-
applyChange: function (oManifest, oChange) {
|
|
3350
|
-
oLogger.info("modifyPageConfiguration use case");
|
|
3351
|
-
var oChangeContent = oChange.getContent();
|
|
3352
|
-
mergerUtil.consistencyCheck(oChangeContent, "MODIFY");
|
|
3353
|
-
var sParentEntitySet = oChangeContent.parentPage.entitySet;
|
|
3354
|
-
var sParentComponent = oChangeContent.parentPage.component;
|
|
3355
|
-
var oPageStructure = mergerUtil.iterateAndFind(oManifest["sap.ui.generic.app"], sParentEntitySet, sParentComponent);
|
|
3356
|
-
var oPropertyChange = oChangeContent.entityPropertyChange;
|
|
3357
|
-
var aPropertyKeys = Object.keys(oPropertyChange.propertyValue);
|
|
3358
|
-
aPropertyKeys.forEach(function (sCurrentKey) {
|
|
3359
|
-
var aPropertyPath = oPropertyChange.propertyPath.split("/");
|
|
3360
|
-
aPropertyPath.push(sCurrentKey);
|
|
3361
|
-
var vVal = ObjectPath.get(aPropertyPath, oPageStructure);
|
|
3362
|
-
if (vVal && typeof vVal === "object") {
|
|
3363
|
-
var oPropertyPathContent = ObjectPath.create(aPropertyPath, oPageStructure);
|
|
3364
|
-
Object.assign(oPropertyPathContent, oPropertyChange.propertyValue[sCurrentKey]);
|
|
3365
|
-
} else {
|
|
3366
|
-
ObjectPath.set(aPropertyPath, oPropertyChange.propertyValue[sCurrentKey], oPageStructure);
|
|
3367
|
-
}
|
|
3368
|
-
});
|
|
3369
|
-
return oManifest;
|
|
3370
|
-
}
|
|
3371
|
-
};
|
|
3372
|
-
|
|
3373
|
-
var o = {};
|
|
3374
|
-
let e = {};
|
|
3375
|
-
function i(n, o) {
|
|
3376
|
-
const e = o.getContent();
|
|
3377
|
-
const i = e === null || e === void 0 ? void 0 : e.page;
|
|
3378
|
-
const a = e === null || e === void 0 ? void 0 : e.entityPropertyChange;
|
|
3379
|
-
if ((a === null || a === void 0 ? void 0 : a.operation) !== "UPSERT" || !(a !== null && a !== void 0 && a.propertyPath) || (a === null || a === void 0 ? void 0 : a.propertyValue) === undefined || a !== null && a !== void 0 && a.propertyPath.startsWith("/")) {
|
|
3380
|
-
Log.error("Change content is not a valid");
|
|
3381
|
-
return n;
|
|
3382
|
-
}
|
|
3383
|
-
return r(n, i, a.propertyPath, a.propertyValue);
|
|
3384
|
-
}
|
|
3385
|
-
o.applyChange = i;
|
|
3386
|
-
function r(o, i, r, l, u) {
|
|
3387
|
-
const c = s(o, i);
|
|
3388
|
-
if (c) {
|
|
3389
|
-
const t = a(r);
|
|
3390
|
-
ObjectPath.set(t, l, c);
|
|
3391
|
-
if (u) {
|
|
3392
|
-
e[i] = e[i] || [];
|
|
3393
|
-
e[i].push(r);
|
|
3394
|
-
}
|
|
3395
|
-
} else {
|
|
3396
|
-
Log.error(`No Fiori elements page with ID ${i} found in routing targets.`);
|
|
3397
|
-
}
|
|
3398
|
-
return o;
|
|
3399
|
-
}
|
|
3400
|
-
o.changeConfiguration = r;
|
|
3401
|
-
function a(t) {
|
|
3402
|
-
let n = t.split("/");
|
|
3403
|
-
if (n[0] === "controlConfiguration") {
|
|
3404
|
-
let t = "";
|
|
3405
|
-
for (let o = 1; o < n.length; o++) {
|
|
3406
|
-
t += (o > 1 ? "/" : "") + n[o];
|
|
3407
|
-
if (t.indexOf("@") > -1) {
|
|
3408
|
-
n = ["controlConfiguration", t].concat(n.slice(o + 1));
|
|
3409
|
-
break;
|
|
3410
|
-
}
|
|
3411
|
-
}
|
|
3412
|
-
}
|
|
3413
|
-
return n;
|
|
3414
|
-
}
|
|
3415
|
-
function s(t, n) {
|
|
3416
|
-
var o, e;
|
|
3417
|
-
let i;
|
|
3418
|
-
const r = ((o = t["sap.ui5"]) === null || o === void 0 ? void 0 : (e = o.routing) === null || e === void 0 ? void 0 : e.targets) ?? ({});
|
|
3419
|
-
for (const t in r) {
|
|
3420
|
-
if (r[t].id === n && r[t].name.startsWith("sap.fe.templates.")) {
|
|
3421
|
-
var a;
|
|
3422
|
-
i = ((a = r[t].options) === null || a === void 0 ? void 0 : a.settings) ?? ({});
|
|
3423
|
-
break;
|
|
3424
|
-
}
|
|
3425
|
-
}
|
|
3426
|
-
return i;
|
|
3427
|
-
}
|
|
3428
|
-
function l(t, o, i, r) {
|
|
3429
|
-
o = o ?? ({});
|
|
3430
|
-
const s = e[r] || [];
|
|
3431
|
-
for (const e of s) {
|
|
3432
|
-
const i = a(e);
|
|
3433
|
-
const r = ObjectPath.get(i, t);
|
|
3434
|
-
ObjectPath.set(i, r, o);
|
|
3435
|
-
}
|
|
3436
|
-
return o;
|
|
3437
|
-
}
|
|
3438
|
-
o.applyPageConfigurationChanges = l;
|
|
3439
|
-
function u() {
|
|
3440
|
-
e = {};
|
|
3441
|
-
}
|
|
3442
|
-
o.cleanPageConfigurationChanges = u;
|
|
3443
|
-
|
|
3444
|
-
var Registration = {
|
|
3445
|
-
appdescr_ui5_addLibraries: () => Promise.resolve(AddLibrary),
|
|
3446
|
-
appdescr_app_setTitle: () => Promise.resolve(SetTitle),
|
|
3447
|
-
appdescr_ovp_changeCard: () => Promise.resolve(ChangeCard),
|
|
3448
|
-
appdescr_ovp_addNewCard: () => Promise.resolve(AddNewCard),
|
|
3449
|
-
appdescr_ovp_removeCard: () => Promise.resolve(DeleteCard),
|
|
3450
|
-
appdescr_ui_generic_app_addNewObjectPage: () => Promise.resolve(addNewObjectPage),
|
|
3451
|
-
appdescr_ui_generic_app_changePageConfiguration: () => Promise.resolve(changePageConfiguration),
|
|
3452
|
-
appdescr_fe_changePageConfiguration: () => Promise.resolve(o)
|
|
3453
|
-
};
|
|
3454
|
-
|
|
3455
|
-
var RegistrationBuild = {
|
|
3456
|
-
appdescr_app_changeDataSource: () => Promise.resolve(ChangeDataSource),
|
|
3457
|
-
appdescr_ui5_addNewModelEnhanceWith: () => Promise.resolve(AddNewModelEnhanceWith),
|
|
3458
|
-
appdescr_ui5_addComponentUsages: () => Promise.resolve(AddComponentUsages),
|
|
3459
|
-
appdescr_ui5_setMinUI5Version: () => Promise.resolve(SetMinUI5Version),
|
|
3460
|
-
appdescr_fiori_setRegistrationIds: () => Promise.resolve(SetRegistrationIds),
|
|
3461
|
-
appdescr_ui5_setFlexExtensionPointEnabled: () => Promise.resolve(SetFlexExtensionPointEnabled),
|
|
3462
|
-
appdescr_ui5_addNewModel: () => Promise.resolve(AddNewModel),
|
|
3463
|
-
appdescr_app_addAnnotationsToOData: () => Promise.resolve(AddAnnotationsToOData),
|
|
3464
|
-
appdescr_app_removeAllInboundsExceptOne: () => Promise.resolve(RemoveAllInboundsExceptOne),
|
|
3465
|
-
appdescr_app_changeInbound: () => Promise.resolve(ChangeInbound),
|
|
3466
|
-
appdescr_app_addNewInbound: () => Promise.resolve(AddNewInbound),
|
|
3467
|
-
appdescr_fiori_setAbstract: () => Promise.resolve(SetAbstract)
|
|
3468
|
-
};
|
|
3469
|
-
var RegistrationCopy = Object.assign({}, Registration);
|
|
3470
|
-
var RegistrationBuild$1 = Object.assign(RegistrationCopy, RegistrationBuild);
|
|
3471
|
-
|
|
3472
|
-
exports.Applier = Applier;
|
|
3473
|
-
exports.ApplyUtil = ApplyUtil;
|
|
3474
|
-
exports.Change = Change;
|
|
3475
|
-
exports.RegistrationBuild = RegistrationBuild$1;
|