@ui5/task-adaptation 1.1.3 → 1.3.0
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/dist/annotationManager.d.ts +3 -3
- package/dist/annotationManager.js +16 -17
- package/dist/annotations/comparator/comparator.js +30 -26
- package/dist/annotations/comparator/diffCase.js +1 -2
- package/dist/annotations/comparator/interchangableCase.d.ts +1 -1
- package/dist/annotations/comparator/interchangableCase.js +7 -12
- package/dist/annotations/converter/metadataJsonReferenceUtil.js +7 -9
- package/dist/annotations/converter/metadataJsonUtil.js +7 -10
- package/dist/annotations/converter/ui5JsonConverter.js +5 -6
- package/dist/annotations/converter/ui5MetadataJsonUtil.js +1 -4
- package/dist/annotations/converter/ui5XmlConverter.js +4 -7
- package/dist/annotations/dataSource/dataSource.d.ts +5 -5
- package/dist/annotations/dataSource/dataSource.js +8 -8
- package/dist/annotations/dataSource/dataSourceManager.d.ts +4 -5
- package/dist/annotations/dataSource/dataSourceManager.js +14 -27
- package/dist/annotations/dataSource/dataSourceOData.d.ts +3 -3
- package/dist/annotations/dataSource/dataSourceOData.js +13 -15
- package/dist/annotations/dataSource/dataSourceODataAnnotation.d.ts +2 -2
- package/dist/annotations/dataSource/dataSourceODataAnnotation.js +8 -6
- package/dist/annotations/serviceRequestor.d.ts +3 -3
- package/dist/annotations/serviceRequestor.js +15 -13
- package/dist/annotations/transformers/convertV2ToV4.d.ts +1 -1
- package/dist/annotations/transformers/convertV2ToV4.js +7 -10
- package/dist/annotations/transformers/makeAnnotationNamespaceUnique.d.ts +1 -1
- package/dist/annotations/transformers/makeAnnotationNamespaceUnique.js +8 -11
- package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.d.ts +1 -1
- package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.js +3 -6
- package/dist/annotations/transformers/transformer.d.ts +2 -2
- package/dist/annotations/transformers/transformer.js +1 -2
- package/dist/annotations/transformers/traverseReferences.d.ts +1 -1
- package/dist/annotations/transformers/traverseReferences.js +16 -17
- package/dist/appVariantManager.d.ts +1 -1
- package/dist/appVariantManager.js +17 -20
- package/dist/baseAppManager.d.ts +2 -2
- package/dist/baseAppManager.js +18 -20
- package/dist/buildStrategy.js +2 -4
- package/dist/bundle.d.ts +25 -0
- package/dist/bundle.js +3696 -219
- package/dist/cache/annotationsCacheManager.d.ts +2 -2
- package/dist/cache/annotationsCacheManager.js +3 -5
- package/dist/cache/baseAppFilesCacheManager.d.ts +1 -1
- package/dist/cache/baseAppFilesCacheManager.js +3 -6
- package/dist/cache/cacheManager.d.ts +1 -1
- package/dist/cache/cacheManager.js +9 -12
- package/dist/i18nManager.d.ts +3 -3
- package/dist/i18nManager.js +23 -23
- package/dist/index.d.ts +6 -1
- package/dist/index.js +14 -16
- package/dist/model/annotationDiffStructureError.js +1 -4
- package/dist/model/language.js +4 -4
- package/dist/model/noAuthorizationProvidedError.js +1 -4
- package/dist/model/serverError.js +1 -4
- package/dist/model/types.d.ts +1 -1
- package/dist/model/types.js +1 -2
- package/dist/processors/abapProcessor.d.ts +5 -5
- package/dist/processors/abapProcessor.js +9 -8
- package/dist/processors/cfProcessor.d.ts +3 -3
- package/dist/processors/cfProcessor.js +7 -8
- package/dist/processors/processor.d.ts +1 -1
- package/dist/processors/processor.js +11 -15
- package/dist/repositories/abapRepoManager.d.ts +1 -1
- package/dist/repositories/abapRepoManager.js +14 -14
- package/dist/repositories/html5RepoManager.d.ts +1 -1
- package/dist/repositories/html5RepoManager.js +12 -14
- package/dist/util/cfUtil.d.ts +1 -1
- package/dist/util/cfUtil.js +12 -14
- package/dist/util/commonUtil.d.ts +2 -2
- package/dist/util/commonUtil.js +19 -32
- package/dist/util/i18nMerger.d.ts +6 -2
- package/dist/util/i18nMerger.js +10 -14
- package/dist/util/requestUtil.d.ts +1 -1
- package/dist/util/requestUtil.js +9 -12
- package/dist/util/resourceUtil.js +8 -11
- package/dist/util/urlUtil.d.ts +2 -2
- package/dist/util/urlUtil.js +3 -6
- package/dist/util/xmlUtil.js +2 -5
- package/dist/util/zipUtil.js +2 -6
- package/eslint.config.js +52 -0
- package/package.json +44 -51
- 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/annotations/dataSource/dataSourceODataAnnotationBeta.d.ts +0 -6
- package/dist/annotations/dataSource/dataSourceODataAnnotationBeta.js +0 -18
- package/dist/bundle-odata.js +0 -5498
- package/scripts/rollup/bundleDefinition-odata.js +0 -9
package/CHANGELOG.md
CHANGED
|
@@ -2,7 +2,13 @@
|
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
|
4
4
|
|
|
5
|
-
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task-adaptation/compare/v1.
|
|
5
|
+
A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task-adaptation/compare/v1.3.0...HEAD).
|
|
6
|
+
|
|
7
|
+
<a name="v1.3.0"></a>
|
|
8
|
+
## [v1.3.0] - 2024-03-22
|
|
9
|
+
|
|
10
|
+
<a name="v1.2.0"></a>
|
|
11
|
+
## [v1.2.0] - 2024-03-05
|
|
6
12
|
|
|
7
13
|
<a name="v1.1.3"></a>
|
|
8
14
|
## [v1.1.3] - 2024-02-26
|
|
@@ -82,6 +88,8 @@ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-task
|
|
|
82
88
|
<a name="v1.0.0"></a>
|
|
83
89
|
## v1.0.0 - 2020-12-09
|
|
84
90
|
|
|
91
|
+
[v1.3.0]: https://github.com/SAP/ui5-task-adaptation/compare/v1.2.0...v1.3.0
|
|
92
|
+
[v1.2.0]: https://github.com/SAP/ui5-task-adaptation/compare/v1.1.3...v1.2.0
|
|
85
93
|
[v1.1.3]: https://github.com/SAP/ui5-task-adaptation/compare/v1.1.2...v1.1.3
|
|
86
94
|
[v1.1.2]: https://github.com/SAP/ui5-task-adaptation/compare/v1.1.1...v1.1.2
|
|
87
95
|
[v1.1.1]: https://github.com/SAP/ui5-task-adaptation/compare/v1.1.0...v1.1.1
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import AbapRepoManager from "./repositories/abapRepoManager";
|
|
2
|
-
import { IConfiguration } from "./model/types";
|
|
3
|
-
import Language from "./model/language";
|
|
1
|
+
import AbapRepoManager from "./repositories/abapRepoManager.js";
|
|
2
|
+
import { IConfiguration } from "./model/types.js";
|
|
3
|
+
import Language from "./model/language.js";
|
|
4
4
|
export interface IAnnotationFiles {
|
|
5
5
|
annotationName: string;
|
|
6
6
|
annotationFileName: string;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const serviceRequestor_1 = require("./annotations/serviceRequestor");
|
|
7
|
-
const path_1 = require("path");
|
|
1
|
+
import BaseAppManager from "./baseAppManager.js";
|
|
2
|
+
import DataSourceManager from "./annotations/dataSource/dataSourceManager.js";
|
|
3
|
+
import I18nManager from "./i18nManager.js";
|
|
4
|
+
import ServiceRequestor from "./annotations/serviceRequestor.js";
|
|
5
|
+
import { posix as path } from "path";
|
|
8
6
|
const I18N_DEFAULT_PATH = "i18n/annotations";
|
|
9
7
|
const I18N_DEFAULT_MODEL_NAME = "@i18n";
|
|
10
8
|
const SAPUI5 = "sap.ui5";
|
|
11
|
-
class AnnotationManager {
|
|
9
|
+
export default class AnnotationManager {
|
|
10
|
+
abapRepoManager;
|
|
11
|
+
configuration;
|
|
12
12
|
constructor(configuration, abapRepoManager) {
|
|
13
|
-
this.ANNOTATIONS_FOLDER = "annotations";
|
|
14
13
|
this.configuration = configuration;
|
|
15
14
|
this.abapRepoManager = abapRepoManager;
|
|
16
15
|
}
|
|
16
|
+
ANNOTATIONS_FOLDER = "annotations";
|
|
17
17
|
async process(renamedBaseAppManifest, languages) {
|
|
18
|
-
const { id } =
|
|
19
|
-
|
|
18
|
+
const { id } = BaseAppManager.getIdVersion(renamedBaseAppManifest);
|
|
19
|
+
BaseAppManager.validateProperty(id, "sap.app/id");
|
|
20
20
|
const normalisedId = this.normalizeAppVariantId(id);
|
|
21
21
|
//TODO: switch to this after resolving @i18n custom model
|
|
22
22
|
const modelName = I18N_DEFAULT_MODEL_NAME; //`i18n_a9n_${normalisedId}`;
|
|
23
|
-
const i18nPathName =
|
|
24
|
-
const i18nManager = new
|
|
25
|
-
const serviceRequestor = new
|
|
26
|
-
const dataSourceManager = new
|
|
27
|
-
dataSourceManager.addDataSources(renamedBaseAppManifest["sap.app"]?.dataSources
|
|
23
|
+
const i18nPathName = path.join(I18N_DEFAULT_PATH, normalisedId);
|
|
24
|
+
const i18nManager = new I18nManager(modelName, id, languages);
|
|
25
|
+
const serviceRequestor = new ServiceRequestor(this.configuration, this.abapRepoManager);
|
|
26
|
+
const dataSourceManager = new DataSourceManager();
|
|
27
|
+
dataSourceManager.addDataSources(renamedBaseAppManifest["sap.app"]?.dataSources);
|
|
28
28
|
const annotationFiles = await dataSourceManager.createAnnotationFiles(languages, i18nManager, serviceRequestor);
|
|
29
29
|
const i18nFiles = i18nManager.createFiles(i18nPathName);
|
|
30
30
|
if (i18nManager.hasTranslations()) {
|
|
@@ -76,5 +76,4 @@ class AnnotationManager {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
exports.default = AnnotationManager;
|
|
80
79
|
//# sourceMappingURL=annotationManager.js.map
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class Diff {
|
|
1
|
+
import { insertInArray, traverse } from "../../util/commonUtil.js";
|
|
2
|
+
import AnnotationDiffStructureError from "../../model/annotationDiffStructureError.js";
|
|
3
|
+
import InterchangableCase from "./interchangableCase.js";
|
|
4
|
+
import MetadataJsonUtil from "../converter/metadataJsonUtil.js";
|
|
5
|
+
import XmlUtil from "../../util/xmlUtil.js";
|
|
6
|
+
export class Diff {
|
|
7
|
+
__old;
|
|
8
|
+
__new;
|
|
10
9
|
constructor(__old, __new) {
|
|
11
10
|
this.__old = __old;
|
|
12
11
|
this.__new = __new;
|
|
@@ -15,18 +14,19 @@ class Diff {
|
|
|
15
14
|
return `{ __old: ${this.__old}, __new: ${this.__new} }`;
|
|
16
15
|
}
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
export default class Comparator {
|
|
18
|
+
diffs = new Set();
|
|
19
|
+
xml_a;
|
|
20
|
+
xml_b;
|
|
20
21
|
constructor(xml_a, xml_b) {
|
|
21
|
-
this.diffs = new Set();
|
|
22
22
|
this.xml_a = xml_a;
|
|
23
23
|
this.xml_b = xml_b;
|
|
24
24
|
}
|
|
25
25
|
compare() {
|
|
26
|
-
const json_a = typeof this.xml_a === "string" ?
|
|
27
|
-
const json_b = typeof this.xml_b === "string" ?
|
|
28
|
-
const scheme_a =
|
|
29
|
-
const scheme_b =
|
|
26
|
+
const json_a = typeof this.xml_a === "string" ? XmlUtil.xmlToJson(this.xml_a) : this.xml_a;
|
|
27
|
+
const json_b = typeof this.xml_b === "string" ? XmlUtil.xmlToJson(this.xml_b) : this.xml_b;
|
|
28
|
+
const scheme_a = MetadataJsonUtil.getSchemaNode(json_a);
|
|
29
|
+
const scheme_b = MetadataJsonUtil.getSchemaNode(json_b);
|
|
30
30
|
if (scheme_a && scheme_b) {
|
|
31
31
|
// we compare only Annotations, other types are left as it is
|
|
32
32
|
this.traverseCompare(scheme_a, scheme_b, "Annotations");
|
|
@@ -45,7 +45,7 @@ class Comparator {
|
|
|
45
45
|
// When during traversing we end up in primitives like string, we
|
|
46
46
|
// compare the values. If one of them is not primitive or oone of
|
|
47
47
|
// them is undefined, we throw exception (see test 06, 07).
|
|
48
|
-
throw new
|
|
48
|
+
throw new AnnotationDiffStructureError({ a, b });
|
|
49
49
|
}
|
|
50
50
|
else if (typeof a !== "object" && typeof b !== "object") {
|
|
51
51
|
// If primitive values are not same - we assume they are
|
|
@@ -71,7 +71,7 @@ class Comparator {
|
|
|
71
71
|
else {
|
|
72
72
|
// If the number of items of nodes without id are
|
|
73
73
|
// different, we throw error (see test 08).
|
|
74
|
-
throw new
|
|
74
|
+
throw new AnnotationDiffStructureError({ a, b });
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
}
|
|
@@ -153,8 +153,14 @@ class Comparator {
|
|
|
153
153
|
return simpleIdentifiers.get(property);
|
|
154
154
|
}
|
|
155
155
|
}
|
|
156
|
-
exports.default = Comparator;
|
|
157
156
|
class Includer {
|
|
157
|
+
ALL_DIFF_CASES = [
|
|
158
|
+
new InterchangableCase()
|
|
159
|
+
];
|
|
160
|
+
diffCases = new Array();
|
|
161
|
+
shouldClear;
|
|
162
|
+
target;
|
|
163
|
+
property;
|
|
158
164
|
/**
|
|
159
165
|
* It will decide what to do with the item missing in one language.
|
|
160
166
|
* @param target an array which might miss the item
|
|
@@ -165,10 +171,6 @@ class Includer {
|
|
|
165
171
|
* they will have empty values. Because we don't know what should be there.
|
|
166
172
|
*/
|
|
167
173
|
constructor(target, property, shouldClear = true) {
|
|
168
|
-
this.ALL_DIFF_CASES = [
|
|
169
|
-
new interchangableCase_1.default()
|
|
170
|
-
];
|
|
171
|
-
this.diffCases = new Array();
|
|
172
174
|
this.shouldClear = shouldClear;
|
|
173
175
|
this.target = target;
|
|
174
176
|
this.property = property;
|
|
@@ -189,7 +191,7 @@ class Includer {
|
|
|
189
191
|
// language or default language value if missing in other language
|
|
190
192
|
// (see test 03).
|
|
191
193
|
const clone = Includer.cloneAndClear(source[index], this.shouldClear);
|
|
192
|
-
|
|
194
|
+
insertInArray(this.target, index, clone);
|
|
193
195
|
// Some annotations like Label, QuickInfo or Heading are
|
|
194
196
|
// interchangable so if QuickInfo is missing we can copy the value
|
|
195
197
|
// from Label or Heading (see test 01).
|
|
@@ -208,7 +210,7 @@ class Includer {
|
|
|
208
210
|
static cloneAndClear(obj, shouldClear = true) {
|
|
209
211
|
const clone = structuredClone(obj);
|
|
210
212
|
if (shouldClear) {
|
|
211
|
-
|
|
213
|
+
traverse(clone, [], (json, key) => {
|
|
212
214
|
if (typeof key !== "string" || !simpleIdentifiersReversed.has(key)) {
|
|
213
215
|
json[key] = "";
|
|
214
216
|
}
|
|
@@ -218,13 +220,15 @@ class Includer {
|
|
|
218
220
|
}
|
|
219
221
|
}
|
|
220
222
|
class Items {
|
|
223
|
+
idProperty;
|
|
224
|
+
array;
|
|
225
|
+
objectMap = null;
|
|
221
226
|
/**
|
|
222
227
|
* Map of id per item which is lazy initialized if needed
|
|
223
228
|
* @param array
|
|
224
229
|
* @param idProperty
|
|
225
230
|
*/
|
|
226
231
|
constructor(array, idProperty) {
|
|
227
|
-
this.objectMap = null;
|
|
228
232
|
this.array = array;
|
|
229
233
|
this.idProperty = idProperty;
|
|
230
234
|
}
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const comparator_1 = require("./comparator");
|
|
4
|
-
class InterchangableCase {
|
|
5
|
-
constructor() {
|
|
6
|
-
// If one of the terms is missing, its values can be filled by others.
|
|
7
|
-
// Usually Heading or QuickInfo is missing. So we order terms by source
|
|
8
|
-
// priority (take from label first).
|
|
9
|
-
this.interchangableTerms = ["SAP__common.Label", "SAP__common.Heading", "SAP__common.QuickInfo"];
|
|
10
|
-
}
|
|
1
|
+
import { Diff } from "./comparator.js";
|
|
2
|
+
export default class InterchangableCase {
|
|
11
3
|
accept(target, i, name) {
|
|
12
4
|
if (name === "Annotation" && this.interchangableTerms.includes(target[i]?._attributes?.Term)) {
|
|
13
5
|
const source = this.findByPriority(target, i);
|
|
@@ -31,7 +23,7 @@ class InterchangableCase {
|
|
|
31
23
|
*/
|
|
32
24
|
getSourceValue(source, attribute) {
|
|
33
25
|
let value = source._attributes[attribute];
|
|
34
|
-
if (value instanceof
|
|
26
|
+
if (value instanceof Diff) {
|
|
35
27
|
value = value.__old;
|
|
36
28
|
}
|
|
37
29
|
return value;
|
|
@@ -50,6 +42,10 @@ class InterchangableCase {
|
|
|
50
42
|
.map(item => item._attributes?.Term)
|
|
51
43
|
.some(term => this.interchangableTerms.includes(term));
|
|
52
44
|
}
|
|
45
|
+
// If one of the terms is missing, its values can be filled by others.
|
|
46
|
+
// Usually Heading or QuickInfo is missing. So we order terms by source
|
|
47
|
+
// priority (take from label first).
|
|
48
|
+
interchangableTerms = ["SAP__common.Label", "SAP__common.Heading", "SAP__common.QuickInfo"];
|
|
53
49
|
findByPriority(annotations, index) {
|
|
54
50
|
for (const interchangableTerm of this.interchangableTerms) {
|
|
55
51
|
for (const annotation of annotations) {
|
|
@@ -61,5 +57,4 @@ class InterchangableCase {
|
|
|
61
57
|
}
|
|
62
58
|
}
|
|
63
59
|
}
|
|
64
|
-
exports.default = InterchangableCase;
|
|
65
60
|
//# sourceMappingURL=interchangableCase.js.map
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import MetadataJsonUtil from "./metadataJsonUtil.js";
|
|
2
|
+
export default class MetadataJsonReferenceUtil {
|
|
3
|
+
json;
|
|
4
|
+
aliases = null;
|
|
5
|
+
namespaces = null;
|
|
5
6
|
constructor(json) {
|
|
6
|
-
this.aliases = null;
|
|
7
|
-
this.namespaces = null;
|
|
8
7
|
this.json = json;
|
|
9
8
|
}
|
|
10
9
|
aliasToNamespace(target) {
|
|
@@ -30,10 +29,10 @@ class MetadataJsonReferenceUtil {
|
|
|
30
29
|
initReferences() {
|
|
31
30
|
if (!this.aliases || !this.namespaces) {
|
|
32
31
|
const references = new Array();
|
|
33
|
-
for (const ref of
|
|
32
|
+
for (const ref of MetadataJsonUtil.getReferences(this.json)) {
|
|
34
33
|
references.push(...ref.includes);
|
|
35
34
|
}
|
|
36
|
-
references.push(
|
|
35
|
+
references.push(MetadataJsonUtil.getSchemaReference(this.json));
|
|
37
36
|
this.aliases = new Map();
|
|
38
37
|
this.namespaces = new Map();
|
|
39
38
|
for (const mapping of references) {
|
|
@@ -46,5 +45,4 @@ class MetadataJsonReferenceUtil {
|
|
|
46
45
|
}
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
|
-
exports.default = MetadataJsonReferenceUtil;
|
|
50
48
|
//# sourceMappingURL=metadataJsonReferenceUtil.js.map
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MetadataInclude = exports.MetadataReference = void 0;
|
|
4
|
-
class MetadataJsonUtil {
|
|
1
|
+
export default class MetadataJsonUtil {
|
|
5
2
|
static mapAnnotationsPerTarget(json) {
|
|
6
3
|
const annotations = Array.isArray(json) ? json : this.getAnnotations(json);
|
|
7
4
|
return new Map(annotations.map((json, index) => [json?._attributes?.Target, { json, index }]));
|
|
@@ -42,10 +39,10 @@ class MetadataJsonUtil {
|
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
41
|
}
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
export class MetadataReference {
|
|
43
|
+
uri;
|
|
44
|
+
includes = new Array();
|
|
47
45
|
constructor(referenceJson) {
|
|
48
|
-
this.includes = new Array();
|
|
49
46
|
this.uri = referenceJson._attributes.Uri;
|
|
50
47
|
for (const include of MetadataJsonUtil.toArrayReadOnly(referenceJson["edmx:Include"])) {
|
|
51
48
|
this.includes.push(MetadataInclude.fromJson(include));
|
|
@@ -56,8 +53,9 @@ class MetadataReference {
|
|
|
56
53
|
return include?.alias;
|
|
57
54
|
}
|
|
58
55
|
}
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
export class MetadataInclude {
|
|
57
|
+
namespace;
|
|
58
|
+
alias;
|
|
61
59
|
constructor(alias, namespace) {
|
|
62
60
|
this.alias = alias;
|
|
63
61
|
this.namespace = namespace;
|
|
@@ -69,5 +67,4 @@ class MetadataInclude {
|
|
|
69
67
|
return new MetadataInclude(json?._attributes?.Alias, json?._attributes?.Namespace);
|
|
70
68
|
}
|
|
71
69
|
}
|
|
72
|
-
exports.MetadataInclude = MetadataInclude;
|
|
73
70
|
//# sourceMappingURL=metadataJsonUtil.js.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import UI5JsonParser from "./ui5MetadataJsonUtil.js";
|
|
2
|
+
export default class UI5JsonConverter {
|
|
3
|
+
config;
|
|
4
|
+
oAnnotationConfig;
|
|
5
5
|
static convertAnnotations(json) {
|
|
6
|
-
const annotationsNode =
|
|
6
|
+
const annotationsNode = UI5JsonParser.getAnnotationsNode(json);
|
|
7
7
|
if (annotationsNode) {
|
|
8
8
|
return Object.entries(annotationsNode).map(([target, annotations]) => this.processAnnotations(annotations, target));
|
|
9
9
|
}
|
|
@@ -249,5 +249,4 @@ class UI5JsonConverter {
|
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
}
|
|
252
|
-
exports.default = UI5JsonConverter;
|
|
253
252
|
//# sourceMappingURL=ui5JsonConverter.js.map
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
class UI5MetadataJsonUtil {
|
|
1
|
+
export default class UI5MetadataJsonUtil {
|
|
4
2
|
static getAnnotationsNode(json) {
|
|
5
3
|
for (const key of Object.keys(json)) {
|
|
6
4
|
if (json[key].$kind === "Schema") {
|
|
@@ -9,5 +7,4 @@ class UI5MetadataJsonUtil {
|
|
|
9
7
|
}
|
|
10
8
|
}
|
|
11
9
|
}
|
|
12
|
-
exports.default = UI5MetadataJsonUtil;
|
|
13
10
|
//# sourceMappingURL=ui5MetadataJsonUtil.js.map
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const jsdom_1 = require("jsdom");
|
|
5
|
-
class UI5XmlConverter {
|
|
1
|
+
import { V2MetadataConverter, V4MetadataConverter } from "../../../dist/bundle.js";
|
|
2
|
+
import { JSDOM } from "jsdom";
|
|
3
|
+
export default class UI5XmlConverter {
|
|
6
4
|
static convertV2(xml) {
|
|
7
5
|
return new V2MetadataConverter().convertXMLMetadata(this.getDocument(xml));
|
|
8
6
|
}
|
|
@@ -10,8 +8,7 @@ class UI5XmlConverter {
|
|
|
10
8
|
return new V4MetadataConverter().convertXMLMetadata(this.getDocument(xml));
|
|
11
9
|
}
|
|
12
10
|
static getDocument(xml) {
|
|
13
|
-
return (new
|
|
11
|
+
return (new JSDOM(xml, { contentType: "application/xml" })).window._document;
|
|
14
12
|
}
|
|
15
13
|
}
|
|
16
|
-
exports.default = UI5XmlConverter;
|
|
17
14
|
//# sourceMappingURL=ui5XmlConverter.js.map
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import I18nManager from "../../i18nManager";
|
|
2
|
-
import { IAnnotationDownloadParams } from "./dataSourceOData";
|
|
3
|
-
import Language from "../../model/language";
|
|
4
|
-
import ServiceRequestor from "../serviceRequestor";
|
|
5
|
-
import Transformer from "../transformers/transformer";
|
|
1
|
+
import I18nManager from "../../i18nManager.js";
|
|
2
|
+
import { IAnnotationDownloadParams } from "./dataSourceOData.js";
|
|
3
|
+
import Language from "../../model/language.js";
|
|
4
|
+
import ServiceRequestor from "../serviceRequestor.js";
|
|
5
|
+
import Transformer from "../transformers/transformer.js";
|
|
6
6
|
export default class DataSource {
|
|
7
7
|
protected name: string;
|
|
8
8
|
private uri;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import XmlUtil from "../../util/xmlUtil.js";
|
|
2
|
+
export default class DataSource {
|
|
3
|
+
name;
|
|
4
|
+
uri;
|
|
5
|
+
jsonTransformers = new Array();
|
|
5
6
|
constructor(name, uri) {
|
|
6
|
-
this.jsonTransformers = new Array();
|
|
7
7
|
this.name = name;
|
|
8
8
|
this.uri = uri;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Update the json of the dataSources in manifest.json
|
|
12
12
|
*/
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
13
14
|
updateManifest(_) {
|
|
14
15
|
// to be overriden in children
|
|
15
16
|
}
|
|
@@ -22,7 +23,7 @@ class DataSource {
|
|
|
22
23
|
async createAnnotationFile(languages, i18nManager, serviceRequestor) {
|
|
23
24
|
const annotationJsons = this.getPromisesPerLanguage(languages, serviceRequestor);
|
|
24
25
|
const annotationJson = await i18nManager.populateTranslations(annotationJsons);
|
|
25
|
-
const xml =
|
|
26
|
+
const xml = XmlUtil.jsonToXml(await annotationJson.json);
|
|
26
27
|
return {
|
|
27
28
|
filename: this.getFilename(),
|
|
28
29
|
xml
|
|
@@ -51,12 +52,11 @@ class DataSource {
|
|
|
51
52
|
return this.afterXmlDownload({ xml: languageXmlContent, language, serviceRequestor, uri: this.uri });
|
|
52
53
|
}
|
|
53
54
|
async afterXmlDownload({ xml, language, serviceRequestor, uri }) {
|
|
54
|
-
let json =
|
|
55
|
+
let json = XmlUtil.xmlToJson(xml);
|
|
55
56
|
for (const transformer of this.jsonTransformers) {
|
|
56
57
|
json = await transformer.transform({ xml, json, language, serviceRequestor, uri });
|
|
57
58
|
}
|
|
58
59
|
return json;
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
|
-
exports.default = DataSource;
|
|
62
62
|
//# sourceMappingURL=dataSource.js.map
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import I18nManager from "../../i18nManager";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import ServiceRequestor from "../serviceRequestor";
|
|
1
|
+
import I18nManager from "../../i18nManager.js";
|
|
2
|
+
import Language from "../../model/language.js";
|
|
3
|
+
import ServiceRequestor from "../serviceRequestor.js";
|
|
5
4
|
export default class DataSourceManager {
|
|
6
5
|
private dataSources;
|
|
7
6
|
/**
|
|
8
7
|
* Parses dataSources from manifest.json.
|
|
9
8
|
* @param dataSourcesJson manifest.json/sap.app/dataSources node
|
|
10
9
|
*/
|
|
11
|
-
addDataSources(dataSourcesJson: any
|
|
10
|
+
addDataSources(dataSourcesJson: any): void;
|
|
12
11
|
createAnnotationFiles(languages: Language[], i18nManager: I18nManager, serviceRequestor: ServiceRequestor): Promise<Map<string, string>>;
|
|
13
12
|
}
|
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const path_1 = require("path");
|
|
7
|
-
class DataSourceManager {
|
|
8
|
-
constructor() {
|
|
9
|
-
this.dataSources = new Array();
|
|
10
|
-
}
|
|
1
|
+
import DataSourceOData from "./dataSourceOData.js";
|
|
2
|
+
import DataSourceODataAnnotation from "./dataSourceODataAnnotation.js";
|
|
3
|
+
import path from "path/posix";
|
|
4
|
+
export default class DataSourceManager {
|
|
5
|
+
dataSources = new Array();
|
|
11
6
|
/**
|
|
12
7
|
* Parses dataSources from manifest.json.
|
|
13
8
|
* @param dataSourcesJson manifest.json/sap.app/dataSources node
|
|
14
9
|
*/
|
|
15
|
-
addDataSources(dataSourcesJson
|
|
10
|
+
addDataSources(dataSourcesJson) {
|
|
16
11
|
if (!dataSourcesJson) {
|
|
17
12
|
return;
|
|
18
13
|
}
|
|
19
14
|
const odataAnnotationMap = new Map();
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
this.dataSources.push(odata);
|
|
28
|
-
}
|
|
15
|
+
// Loop over OData first to collect linked annotation names
|
|
16
|
+
for (const [name, dataSource] of Object.entries(dataSourcesJson)) {
|
|
17
|
+
if (dataSource.uri?.startsWith("/") && dataSource.type === "OData") {
|
|
18
|
+
const uri = path.normalize(dataSource.uri + "/$metadata");
|
|
19
|
+
const odata = new DataSourceOData(name, uri, dataSource);
|
|
20
|
+
odata.getAnnotations().forEach(annotation => odataAnnotationMap.set(annotation, uri));
|
|
21
|
+
this.dataSources.push(odata);
|
|
29
22
|
}
|
|
30
23
|
}
|
|
31
24
|
// If ODataAnnotation is in OData annotations, pass metadata url to it
|
|
@@ -33,12 +26,7 @@ class DataSourceManager {
|
|
|
33
26
|
const uri = dataSource.uri;
|
|
34
27
|
const metadataUrl = odataAnnotationMap.get(name);
|
|
35
28
|
if (uri?.startsWith("/") && dataSource.type === "ODataAnnotation") {
|
|
36
|
-
|
|
37
|
-
this.dataSources.push(new dataSourceODataAnnotationBeta_1.default(name, uri, dataSource, metadataUrl));
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
this.dataSources.push(new dataSourceODataAnnotation_1.default(name, uri, dataSource));
|
|
41
|
-
}
|
|
29
|
+
this.dataSources.push(new DataSourceODataAnnotation(name, uri, dataSource, metadataUrl));
|
|
42
30
|
}
|
|
43
31
|
}
|
|
44
32
|
for (const dataSource of this.dataSources) {
|
|
@@ -54,5 +42,4 @@ class DataSourceManager {
|
|
|
54
42
|
return annotationFiles;
|
|
55
43
|
}
|
|
56
44
|
}
|
|
57
|
-
exports.default = DataSourceManager;
|
|
58
45
|
//# sourceMappingURL=dataSourceManager.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import DataSource from "./dataSource";
|
|
2
|
-
import Language from "../../model/language";
|
|
3
|
-
import ServiceRequestor from "../serviceRequestor";
|
|
1
|
+
import DataSource from "./dataSource.js";
|
|
2
|
+
import Language from "../../model/language.js";
|
|
3
|
+
import ServiceRequestor from "../serviceRequestor.js";
|
|
4
4
|
export interface IAnnotationDownloadParams {
|
|
5
5
|
uri: string;
|
|
6
6
|
xml: string;
|
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class DataSourceOData extends dataSource_1.default {
|
|
1
|
+
import ConvertV2ToV4 from "../transformers/convertV2ToV4.js";
|
|
2
|
+
import DataSource from "./dataSource.js";
|
|
3
|
+
import MakeAnnotationNamespaceUnique from "../transformers/makeAnnotationNamespaceUnique.js";
|
|
4
|
+
import RemoveAllSchemaNodesExceptAnnotations from "../transformers/removeAllSchemaNodesExceptAnnotations.js";
|
|
5
|
+
import TraverseReferences from "../transformers/traverseReferences.js";
|
|
6
|
+
import { getUniqueName } from "../../util/commonUtil.js";
|
|
7
|
+
export default class DataSourceOData extends DataSource {
|
|
8
|
+
dataSourceJson;
|
|
10
9
|
constructor(name, uri, dataSourceJson) {
|
|
11
10
|
super(name, uri);
|
|
12
11
|
this.dataSourceJson = dataSourceJson;
|
|
13
12
|
this.jsonTransformers = [
|
|
14
|
-
new
|
|
15
|
-
new
|
|
16
|
-
new
|
|
17
|
-
new
|
|
13
|
+
new TraverseReferences(),
|
|
14
|
+
new ConvertV2ToV4(),
|
|
15
|
+
new RemoveAllSchemaNodesExceptAnnotations(),
|
|
16
|
+
new MakeAnnotationNamespaceUnique()
|
|
18
17
|
];
|
|
19
18
|
}
|
|
20
19
|
updateManifest(manifestDataSources) {
|
|
@@ -23,7 +22,7 @@ class DataSourceOData extends dataSource_1.default {
|
|
|
23
22
|
}
|
|
24
23
|
addNewODataAnnotation(manifestDataSources) {
|
|
25
24
|
const newAnnotationNameTemplate = `annotation_${this.name}`;
|
|
26
|
-
let newAnnotationName =
|
|
25
|
+
let newAnnotationName = getUniqueName(Object.keys(manifestDataSources), newAnnotationNameTemplate);
|
|
27
26
|
this.getAnnotations().unshift(newAnnotationName);
|
|
28
27
|
manifestDataSources[newAnnotationName] = {
|
|
29
28
|
type: "ODataAnnotation",
|
|
@@ -43,5 +42,4 @@ class DataSourceOData extends dataSource_1.default {
|
|
|
43
42
|
return this.getSettings().annotations;
|
|
44
43
|
}
|
|
45
44
|
}
|
|
46
|
-
exports.default = DataSourceOData;
|
|
47
45
|
//# sourceMappingURL=dataSourceOData.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import DataSource from "./dataSource";
|
|
1
|
+
import DataSource from "./dataSource.js";
|
|
2
2
|
export default class DataSourceODataAnnotation extends DataSource {
|
|
3
3
|
private dataSourceJson;
|
|
4
|
-
constructor(name: string, uri: string, dataSourceJson: any);
|
|
4
|
+
constructor(name: string, uri: string, dataSourceJson: any, metadataUrl: string | undefined);
|
|
5
5
|
updateManifest(): void;
|
|
6
6
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
constructor(name, uri, dataSourceJson) {
|
|
1
|
+
import DataSource from "./dataSource.js";
|
|
2
|
+
import TraverseReferences from "../transformers/traverseReferences.js";
|
|
3
|
+
export default class DataSourceODataAnnotation extends DataSource {
|
|
4
|
+
dataSourceJson;
|
|
5
|
+
constructor(name, uri, dataSourceJson, metadataUrl) {
|
|
6
6
|
super(name, uri);
|
|
7
7
|
this.dataSourceJson = dataSourceJson;
|
|
8
|
+
this.jsonTransformers = [
|
|
9
|
+
new TraverseReferences(metadataUrl)
|
|
10
|
+
];
|
|
8
11
|
}
|
|
9
12
|
updateManifest() {
|
|
10
13
|
this.dataSourceJson.uri = this.getFilename();
|
|
11
14
|
}
|
|
12
15
|
}
|
|
13
|
-
exports.default = DataSourceODataAnnotation;
|
|
14
16
|
//# sourceMappingURL=dataSourceODataAnnotation.js.map
|