@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
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import AbapRepoManager from "./repositories/abapRepoManager";
|
|
2
|
-
import { IConfiguration } from "./model/types";
|
|
3
|
-
import Language from "./model/language";
|
|
4
|
-
export interface IAnnotationFiles {
|
|
5
|
-
annotationName: string;
|
|
6
|
-
annotationFileName: string;
|
|
7
|
-
}
|
|
8
|
-
export default class AnnotationManager {
|
|
9
|
-
private abapRepoManager;
|
|
10
|
-
private configuration;
|
|
11
|
-
constructor(configuration: IConfiguration, abapRepoManager: AbapRepoManager);
|
|
12
|
-
ANNOTATIONS_FOLDER: string;
|
|
13
|
-
process(renamedBaseAppManifest: any, languages: Language[]): Promise<Map<string, string>>;
|
|
14
|
-
private normalizeAppVariantId;
|
|
15
|
-
private updateManifestModel;
|
|
16
|
-
private createManifestModel;
|
|
17
|
-
private enhanceManifestModel;
|
|
18
|
-
}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const baseAppManager_1 = require("./baseAppManager");
|
|
4
|
-
const dataSourceManager_1 = require("./annotations/dataSource/dataSourceManager");
|
|
5
|
-
const i18nManager_1 = require("./i18nManager");
|
|
6
|
-
const serviceRequestor_1 = require("./annotations/serviceRequestor");
|
|
7
|
-
const path_1 = require("path");
|
|
8
|
-
const I18N_DEFAULT_PATH = "i18n/annotations";
|
|
9
|
-
const I18N_DEFAULT_MODEL_NAME = "@i18n";
|
|
10
|
-
const SAPUI5 = "sap.ui5";
|
|
11
|
-
class AnnotationManager {
|
|
12
|
-
constructor(configuration, abapRepoManager) {
|
|
13
|
-
this.ANNOTATIONS_FOLDER = "annotations";
|
|
14
|
-
this.configuration = configuration;
|
|
15
|
-
this.abapRepoManager = abapRepoManager;
|
|
16
|
-
}
|
|
17
|
-
async process(renamedBaseAppManifest, languages) {
|
|
18
|
-
const { id } = baseAppManager_1.default.getIdVersion(renamedBaseAppManifest);
|
|
19
|
-
baseAppManager_1.default.validateProperty(id, "sap.app/id");
|
|
20
|
-
const normalisedId = this.normalizeAppVariantId(id);
|
|
21
|
-
//TODO: switch to this after resolving @i18n custom model
|
|
22
|
-
const modelName = I18N_DEFAULT_MODEL_NAME; //`i18n_a9n_${normalisedId}`;
|
|
23
|
-
const i18nPathName = path_1.posix.join(I18N_DEFAULT_PATH, normalisedId);
|
|
24
|
-
const i18nManager = new i18nManager_1.default(modelName, id, languages);
|
|
25
|
-
const serviceRequestor = new serviceRequestor_1.default(this.configuration, this.abapRepoManager);
|
|
26
|
-
const dataSourceManager = new dataSourceManager_1.default();
|
|
27
|
-
dataSourceManager.addDataSources(renamedBaseAppManifest["sap.app"]?.dataSources);
|
|
28
|
-
const annotationFiles = await dataSourceManager.createAnnotationFiles(languages, i18nManager, serviceRequestor);
|
|
29
|
-
const i18nFiles = i18nManager.createFiles(i18nPathName);
|
|
30
|
-
if (i18nManager.hasTranslations()) {
|
|
31
|
-
this.updateManifestModel(renamedBaseAppManifest, modelName, i18nPathName);
|
|
32
|
-
}
|
|
33
|
-
return new Map([...annotationFiles, ...i18nFiles]);
|
|
34
|
-
}
|
|
35
|
-
normalizeAppVariantId(id, replaceWith = "") {
|
|
36
|
-
return id.replace(/[.\W]+/gi, replaceWith);
|
|
37
|
-
}
|
|
38
|
-
updateManifestModel(renamedBaseAppManifest, modelName, i18nPathName) {
|
|
39
|
-
const uri = `${i18nPathName}/i18n.properties`;
|
|
40
|
-
this.enhanceManifestModel(renamedBaseAppManifest, modelName, uri);
|
|
41
|
-
//TODO: switch to this after resolving @i18n custom model
|
|
42
|
-
//this.createManifestModel(renamedBaseAppManifest, modelName, uri);
|
|
43
|
-
}
|
|
44
|
-
createManifestModel(manifest, modelName, uri) {
|
|
45
|
-
let sapui5 = manifest[SAPUI5] == null ? manifest[SAPUI5] = {} : manifest[SAPUI5];
|
|
46
|
-
if (sapui5.models == null) {
|
|
47
|
-
sapui5.models = {};
|
|
48
|
-
}
|
|
49
|
-
if (sapui5.models[modelName] == null) {
|
|
50
|
-
sapui5.models[modelName] = {};
|
|
51
|
-
}
|
|
52
|
-
sapui5.models[modelName].type = "sap.ui.model.resource.ResourceModel";
|
|
53
|
-
if (uri) {
|
|
54
|
-
sapui5.models[modelName].uri = uri;
|
|
55
|
-
}
|
|
56
|
-
return sapui5.models[modelName];
|
|
57
|
-
}
|
|
58
|
-
enhanceManifestModel(manifest, modelToEnhance, bundleUrl) {
|
|
59
|
-
let model = manifest[SAPUI5]?.models[modelToEnhance];
|
|
60
|
-
if (model) {
|
|
61
|
-
if (model.settings == null) {
|
|
62
|
-
model.settings = {};
|
|
63
|
-
}
|
|
64
|
-
if (model.settings.enhanceWith == null) {
|
|
65
|
-
model.settings.enhanceWith = [];
|
|
66
|
-
}
|
|
67
|
-
if (model.settings.enhanceWith.every((bundle) => bundle.bundleUrl !== bundleUrl)) {
|
|
68
|
-
model.settings.enhanceWith.push({
|
|
69
|
-
bundleUrl,
|
|
70
|
-
bundleUrlRelativeTo: "component"
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
this.createManifestModel(manifest, modelToEnhance, bundleUrl);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.default = AnnotationManager;
|
|
80
|
-
//# sourceMappingURL=annotationManager.js.map
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
export interface IDiffProperty {
|
|
2
|
-
object: any;
|
|
3
|
-
property: string | number;
|
|
4
|
-
}
|
|
5
|
-
export declare class Diff {
|
|
6
|
-
__old: string;
|
|
7
|
-
__new: string;
|
|
8
|
-
constructor(__old: string, __new: string);
|
|
9
|
-
toString(): string;
|
|
10
|
-
}
|
|
11
|
-
export interface DiffJson {
|
|
12
|
-
json: any;
|
|
13
|
-
properties: Set<IDiffProperty>;
|
|
14
|
-
}
|
|
15
|
-
export default class Comparator {
|
|
16
|
-
private diffs;
|
|
17
|
-
private xml_a;
|
|
18
|
-
private xml_b;
|
|
19
|
-
constructor(xml_a: string, xml_b: string);
|
|
20
|
-
compare(): DiffJson;
|
|
21
|
-
private traverseCompare;
|
|
22
|
-
/**
|
|
23
|
-
* If one language annotation has one property it is an object, if other
|
|
24
|
-
* language same annotation consists of multiple properties, we need to
|
|
25
|
-
* equal them, so they are both arrays (see test 01-04).
|
|
26
|
-
*/
|
|
27
|
-
private arrayIfNeeded;
|
|
28
|
-
/**
|
|
29
|
-
* If some node (Annotations, Annotation, PropertyValue, LabeledElement) has
|
|
30
|
-
* an id, we can compare by id, so the items order doesn't matter anymore.
|
|
31
|
-
* @param a array of nodes with id of one language
|
|
32
|
-
* @param b array of nodes with id of the other language
|
|
33
|
-
* @param idProperty property which value is an id (e.g. Target="<unique-id>")
|
|
34
|
-
* @param property node name (Annotations, Annotation, PropertyValue, ...)
|
|
35
|
-
*/
|
|
36
|
-
private traverseById;
|
|
37
|
-
/**
|
|
38
|
-
* Some nodes, like Annotations, Annotation, PropertyValue have unique id
|
|
39
|
-
* among other same nodes. We can use it to know what to compare with what
|
|
40
|
-
* even if the order is different. IdProperty is a property name of that id,
|
|
41
|
-
* e.g. for Annotations it will be Target (like in
|
|
42
|
-
* Target="<some-unique-id>").
|
|
43
|
-
* @param property node which might have an id: Annotations, PropertyValue
|
|
44
|
-
* @return the property name which represents id: Target, Property
|
|
45
|
-
*/
|
|
46
|
-
private getIdProperty;
|
|
47
|
-
}
|
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Diff = void 0;
|
|
4
|
-
const commonUtil_1 = require("../../util/commonUtil");
|
|
5
|
-
const annotationDiffStructureError_1 = require("../../model/annotationDiffStructureError");
|
|
6
|
-
const interchangableCase_1 = require("./interchangableCase");
|
|
7
|
-
const metadataJsonUtil_1 = require("../converter/metadataJsonUtil");
|
|
8
|
-
const xmlUtil_1 = require("../../util/xmlUtil");
|
|
9
|
-
class Diff {
|
|
10
|
-
constructor(__old, __new) {
|
|
11
|
-
this.__old = __old;
|
|
12
|
-
this.__new = __new;
|
|
13
|
-
}
|
|
14
|
-
toString() {
|
|
15
|
-
return `{ __old: ${this.__old}, __new: ${this.__new} }`;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.Diff = Diff;
|
|
19
|
-
class Comparator {
|
|
20
|
-
constructor(xml_a, xml_b) {
|
|
21
|
-
this.diffs = new Set();
|
|
22
|
-
this.xml_a = xml_a;
|
|
23
|
-
this.xml_b = xml_b;
|
|
24
|
-
}
|
|
25
|
-
compare() {
|
|
26
|
-
const json_a = typeof this.xml_a === "string" ? xmlUtil_1.default.xmlToJson(this.xml_a) : this.xml_a;
|
|
27
|
-
const json_b = typeof this.xml_b === "string" ? xmlUtil_1.default.xmlToJson(this.xml_b) : this.xml_b;
|
|
28
|
-
const scheme_a = metadataJsonUtil_1.default.getSchemaNode(json_a);
|
|
29
|
-
const scheme_b = metadataJsonUtil_1.default.getSchemaNode(json_b);
|
|
30
|
-
if (scheme_a && scheme_b) {
|
|
31
|
-
// we compare only Annotations, other types are left as it is
|
|
32
|
-
this.traverseCompare(scheme_a, scheme_b, "Annotations");
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
json: json_a,
|
|
36
|
-
properties: this.diffs
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
traverseCompare(obj_a, obj_b, property) {
|
|
40
|
-
let a = obj_a[property];
|
|
41
|
-
let b = obj_b[property];
|
|
42
|
-
if (typeof a === "object" && !(a instanceof Diff) && typeof b !== "object" ||
|
|
43
|
-
typeof b === "object" && !(b instanceof Diff) && typeof a !== "object" ||
|
|
44
|
-
a == null || b == null) {
|
|
45
|
-
// When during traversing we end up in primitives like string, we
|
|
46
|
-
// compare the values. If one of them is not primitive or oone of
|
|
47
|
-
// them is undefined, we throw exception (see test 06, 07).
|
|
48
|
-
throw new annotationDiffStructureError_1.default({ a, b });
|
|
49
|
-
}
|
|
50
|
-
else if (typeof a !== "object" && typeof b !== "object") {
|
|
51
|
-
// If primitive values are not same - we assume they are
|
|
52
|
-
// translations, so we save them.
|
|
53
|
-
if (a !== b) {
|
|
54
|
-
obj_a[property] = new Diff(a, b);
|
|
55
|
-
this.diffs.add({ object: obj_a, property });
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
a = this.arrayIfNeeded(obj_a, obj_b, property);
|
|
60
|
-
b = this.arrayIfNeeded(obj_b, obj_a, property);
|
|
61
|
-
if (Array.isArray(a)) {
|
|
62
|
-
let idProperty = this.getIdProperty(property);
|
|
63
|
-
if (idProperty) {
|
|
64
|
-
this.traverseById(a, b, idProperty, property);
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
68
|
-
if (a[i] && b[i]) {
|
|
69
|
-
this.traverseCompare(a, b, i);
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
// If the number of items of nodes without id are
|
|
73
|
-
// different, we throw error (see test 08).
|
|
74
|
-
throw new annotationDiffStructureError_1.default({ a, b });
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
for (const key of Object.keys(a)) {
|
|
81
|
-
this.traverseCompare(a, b, key);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* If one language annotation has one property it is an object, if other
|
|
88
|
-
* language same annotation consists of multiple properties, we need to
|
|
89
|
-
* equal them, so they are both arrays (see test 01-04).
|
|
90
|
-
*/
|
|
91
|
-
arrayIfNeeded(obj_a, obj_b, property) {
|
|
92
|
-
if (!Array.isArray(obj_a[property])) {
|
|
93
|
-
// If node with id - make array anyway, so it's easier to compare (see test 04).
|
|
94
|
-
if (simpleIdentifiers.has(property) || Array.isArray(obj_b[property])) {
|
|
95
|
-
obj_a[property] = [obj_a[property]];
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return obj_a[property];
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* If some node (Annotations, Annotation, PropertyValue, LabeledElement) has
|
|
102
|
-
* an id, we can compare by id, so the items order doesn't matter anymore.
|
|
103
|
-
* @param a array of nodes with id of one language
|
|
104
|
-
* @param b array of nodes with id of the other language
|
|
105
|
-
* @param idProperty property which value is an id (e.g. Target="<unique-id>")
|
|
106
|
-
* @param property node name (Annotations, Annotation, PropertyValue, ...)
|
|
107
|
-
*/
|
|
108
|
-
traverseById(a, b, idProperty, property) {
|
|
109
|
-
if (typeof property !== "string") {
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
let items_a = new Items(a, idProperty);
|
|
113
|
-
let items_b = new Items(b, idProperty);
|
|
114
|
-
const includer_a = new Includer(a, property);
|
|
115
|
-
const includer_b = new Includer(b, property);
|
|
116
|
-
for (let i = 0; i < Math.max(a.length, b.length); i++) {
|
|
117
|
-
// There might be an exceptional case, when the object doesn't
|
|
118
|
-
// contain attributes. In this case we continue traversing, like
|
|
119
|
-
// UI5 does.
|
|
120
|
-
const id_a = a[i]?._attributes?.[idProperty];
|
|
121
|
-
const id_b = b[i]?._attributes?.[idProperty];
|
|
122
|
-
if (id_a !== id_b) {
|
|
123
|
-
// We go down the array and if suddenly the ids for comparing
|
|
124
|
-
// items are not the same, we need to find the item with the
|
|
125
|
-
// same id if it exists.
|
|
126
|
-
if (items_b.has(id_a) && items_a.has(id_b)) {
|
|
127
|
-
// If we found the item with the same id, we swap places
|
|
128
|
-
// with current item (see test 05).
|
|
129
|
-
items_b.swap(id_a, i);
|
|
130
|
-
}
|
|
131
|
-
else if (!items_a.has(id_b) && id_b) {
|
|
132
|
-
// If 1st language missing the item, include it from 2nd (see test 02).
|
|
133
|
-
includer_a.include(b, i);
|
|
134
|
-
}
|
|
135
|
-
else if (!items_b.has(id_a) && id_a) {
|
|
136
|
-
// If 2nd language missing the item, include it from 1st (see test 03).
|
|
137
|
-
includer_b.include(a, i);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
this.traverseCompare(a, b, i);
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Some nodes, like Annotations, Annotation, PropertyValue have unique id
|
|
145
|
-
* among other same nodes. We can use it to know what to compare with what
|
|
146
|
-
* even if the order is different. IdProperty is a property name of that id,
|
|
147
|
-
* e.g. for Annotations it will be Target (like in
|
|
148
|
-
* Target="<some-unique-id>").
|
|
149
|
-
* @param property node which might have an id: Annotations, PropertyValue
|
|
150
|
-
* @return the property name which represents id: Target, Property
|
|
151
|
-
*/
|
|
152
|
-
getIdProperty(property) {
|
|
153
|
-
return simpleIdentifiers.get(property);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
exports.default = Comparator;
|
|
157
|
-
class Includer {
|
|
158
|
-
/**
|
|
159
|
-
* It will decide what to do with the item missing in one language.
|
|
160
|
-
* @param target an array which might miss the item
|
|
161
|
-
* @param property the node name needed to decide how to include the missing
|
|
162
|
-
* item in array
|
|
163
|
-
* @param shouldClear if the item is missing and it's not Label or QuickInfo
|
|
164
|
-
* or Heading, we clear all the properties except Ids, so in i18n.properties
|
|
165
|
-
* they will have empty values. Because we don't know what should be there.
|
|
166
|
-
*/
|
|
167
|
-
constructor(target, property, shouldClear = true) {
|
|
168
|
-
this.ALL_DIFF_CASES = [
|
|
169
|
-
new interchangableCase_1.default()
|
|
170
|
-
];
|
|
171
|
-
this.diffCases = new Array();
|
|
172
|
-
this.shouldClear = shouldClear;
|
|
173
|
-
this.target = target;
|
|
174
|
-
this.property = property;
|
|
175
|
-
for (const diffCase of this.ALL_DIFF_CASES) {
|
|
176
|
-
if (diffCase.canAccept(target, property)) {
|
|
177
|
-
this.diffCases.push(diffCase);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
/**
|
|
182
|
-
* If in some language some array missing the item, we include the missing
|
|
183
|
-
* item from other language array with the same id.
|
|
184
|
-
* @param source the item from other language array that is missed in target
|
|
185
|
-
* @param index here to put it in the array
|
|
186
|
-
*/
|
|
187
|
-
include(source, index) {
|
|
188
|
-
// Insert node with empty value (see test 02) if missing in default
|
|
189
|
-
// language or default language value if missing in other language
|
|
190
|
-
// (see test 03).
|
|
191
|
-
const clone = Includer.cloneAndClear(source[index], this.shouldClear);
|
|
192
|
-
(0, commonUtil_1.insertInArray)(this.target, index, clone);
|
|
193
|
-
// Some annotations like Label, QuickInfo or Heading are
|
|
194
|
-
// interchangable so if QuickInfo is missing we can copy the value
|
|
195
|
-
// from Label or Heading (see test 01).
|
|
196
|
-
for (const diffCase of this.diffCases) {
|
|
197
|
-
diffCase.accept(this.target, index, this.property);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
/**
|
|
201
|
-
* if the item is missing in default language, and it's not Label or
|
|
202
|
-
* QuickInfo or Heading, we clear all the properties except Ids, so in
|
|
203
|
-
* i18n.properties they will have empty values. Because we don't know what
|
|
204
|
-
* should be there. But if the item is missing in language other than
|
|
205
|
-
* default, we include the copy of item from default language and not
|
|
206
|
-
* clearing them (see test 02, 04).
|
|
207
|
-
*/
|
|
208
|
-
static cloneAndClear(obj, shouldClear = true) {
|
|
209
|
-
const clone = structuredClone(obj);
|
|
210
|
-
if (shouldClear) {
|
|
211
|
-
(0, commonUtil_1.traverse)(clone, [], (json, key) => {
|
|
212
|
-
if (typeof key !== "string" || !simpleIdentifiersReversed.has(key)) {
|
|
213
|
-
json[key] = "";
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
return clone;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
class Items {
|
|
221
|
-
/**
|
|
222
|
-
* Map of id per item which is lazy initialized if needed
|
|
223
|
-
* @param array
|
|
224
|
-
* @param idProperty
|
|
225
|
-
*/
|
|
226
|
-
constructor(array, idProperty) {
|
|
227
|
-
this.objectMap = null;
|
|
228
|
-
this.array = array;
|
|
229
|
-
this.idProperty = idProperty;
|
|
230
|
-
}
|
|
231
|
-
/**
|
|
232
|
-
* Find the item with by id and swap their places.
|
|
233
|
-
* @param id of the item which seems like not in the place it should be
|
|
234
|
-
* @param newIndex new place where the item should actually be
|
|
235
|
-
*/
|
|
236
|
-
swap(id, newIndex) {
|
|
237
|
-
const oldIndex = this.initMap().get(id);
|
|
238
|
-
const temp = this.array[newIndex];
|
|
239
|
-
this.array[newIndex] = this.array[oldIndex];
|
|
240
|
-
this.array[oldIndex] = temp;
|
|
241
|
-
this.initMap(true);
|
|
242
|
-
}
|
|
243
|
-
has(idProperty) {
|
|
244
|
-
return this.initMap().has(idProperty);
|
|
245
|
-
}
|
|
246
|
-
get(idProperty) {
|
|
247
|
-
return this.array[this.initMap().get(idProperty)];
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Lazy init the map only if the order of items are messed up, which
|
|
251
|
-
* actually an eexception, so will make it lazy way.
|
|
252
|
-
* @param force force to update.
|
|
253
|
-
* @returns the map id per item index.
|
|
254
|
-
*/
|
|
255
|
-
initMap(force = false) {
|
|
256
|
-
if (this.objectMap == null || force) {
|
|
257
|
-
this.objectMap = new Map(this.array.map((item, index) => [item._attributes[this.idProperty], index]));
|
|
258
|
-
}
|
|
259
|
-
return this.objectMap;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
class Identifiers extends Map {
|
|
263
|
-
has(property) {
|
|
264
|
-
return typeof property === "string" && super.has(property);
|
|
265
|
-
}
|
|
266
|
-
get(property) {
|
|
267
|
-
return typeof property === "string" ? super.get(property) : undefined;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
// According to OData schema some nodes MUST have the ids, by these nodes the
|
|
271
|
-
// property which contains the id is named differently as you can see.
|
|
272
|
-
const simpleIdentifiers = new Identifiers([
|
|
273
|
-
["Annotations", "Target"],
|
|
274
|
-
["Annotation", "Term"],
|
|
275
|
-
["LabeledElement", "Name"],
|
|
276
|
-
["PropertyValue", "Property"]
|
|
277
|
-
]);
|
|
278
|
-
const simpleIdentifiersReversed = new Identifiers([...simpleIdentifiers].map(([name, idProperty]) => [idProperty, name]));
|
|
279
|
-
//# sourceMappingURL=comparator.js.map
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import DiffCase from "./diffCase";
|
|
2
|
-
export default class InterchangableCase implements DiffCase {
|
|
3
|
-
accept(target: any[], i: number, name: string): void;
|
|
4
|
-
/**
|
|
5
|
-
* When default language source is already compared, it contains diff, e.g.
|
|
6
|
-
* { __old: value, __new: wert 1 }, if target annotation in other language
|
|
7
|
-
* has other value, it should also reflect the value, be { __old: value,
|
|
8
|
-
* __new: wert 2 }, not { __old: value, __new: wert 1 }. So we remove the
|
|
9
|
-
* diff completely from value and let it be compared again. Other language
|
|
10
|
-
* source will be empty anyway.
|
|
11
|
-
*/
|
|
12
|
-
private getSourceValue;
|
|
13
|
-
/**
|
|
14
|
-
* If the array doesn't have any other annotations to take the values from,
|
|
15
|
-
* we just don't do it and include the annotations from other language as it
|
|
16
|
-
* is. E.g. we include Label but there are no Heading or QuickInfo to take
|
|
17
|
-
* values from. So we just don't do it.
|
|
18
|
-
* @param target where to put the missing item
|
|
19
|
-
* @param property node name
|
|
20
|
-
* @returns true if there are some annotations to take the values from.
|
|
21
|
-
*/
|
|
22
|
-
canAccept(target: any[], property: string): boolean;
|
|
23
|
-
private interchangableTerms;
|
|
24
|
-
private findByPriority;
|
|
25
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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
|
-
}
|
|
11
|
-
accept(target, i, name) {
|
|
12
|
-
if (name === "Annotation" && this.interchangableTerms.includes(target[i]?._attributes?.Term)) {
|
|
13
|
-
const source = this.findByPriority(target, i);
|
|
14
|
-
if (source) {
|
|
15
|
-
for (const attribute of Object.keys(source._attributes)) {
|
|
16
|
-
if (attribute !== "Term") {
|
|
17
|
-
const sourceValue = this.getSourceValue(source, attribute);
|
|
18
|
-
target[i]._attributes[attribute] = sourceValue;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* When default language source is already compared, it contains diff, e.g.
|
|
26
|
-
* { __old: value, __new: wert 1 }, if target annotation in other language
|
|
27
|
-
* has other value, it should also reflect the value, be { __old: value,
|
|
28
|
-
* __new: wert 2 }, not { __old: value, __new: wert 1 }. So we remove the
|
|
29
|
-
* diff completely from value and let it be compared again. Other language
|
|
30
|
-
* source will be empty anyway.
|
|
31
|
-
*/
|
|
32
|
-
getSourceValue(source, attribute) {
|
|
33
|
-
let value = source._attributes[attribute];
|
|
34
|
-
if (value instanceof comparator_1.Diff) {
|
|
35
|
-
value = value.__old;
|
|
36
|
-
}
|
|
37
|
-
return value;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* If the array doesn't have any other annotations to take the values from,
|
|
41
|
-
* we just don't do it and include the annotations from other language as it
|
|
42
|
-
* is. E.g. we include Label but there are no Heading or QuickInfo to take
|
|
43
|
-
* values from. So we just don't do it.
|
|
44
|
-
* @param target where to put the missing item
|
|
45
|
-
* @param property node name
|
|
46
|
-
* @returns true if there are some annotations to take the values from.
|
|
47
|
-
*/
|
|
48
|
-
canAccept(target, property) {
|
|
49
|
-
return property === "Annotation" && target
|
|
50
|
-
.map(item => item._attributes?.Term)
|
|
51
|
-
.some(term => this.interchangableTerms.includes(term));
|
|
52
|
-
}
|
|
53
|
-
findByPriority(annotations, index) {
|
|
54
|
-
for (const interchangableTerm of this.interchangableTerms) {
|
|
55
|
-
for (const annotation of annotations) {
|
|
56
|
-
if (annotation._attributes?.Term === interchangableTerm &&
|
|
57
|
-
annotation !== annotations[index]) {
|
|
58
|
-
return annotation;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.default = InterchangableCase;
|
|
65
|
-
//# sourceMappingURL=interchangableCase.js.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export default class MetadataJsonReferenceUtil {
|
|
2
|
-
private json;
|
|
3
|
-
private aliases;
|
|
4
|
-
private namespaces;
|
|
5
|
-
constructor(json: any);
|
|
6
|
-
aliasToNamespace(target: string): string;
|
|
7
|
-
namespaceToAlias(target: string): string;
|
|
8
|
-
private convertReference;
|
|
9
|
-
private getAliases;
|
|
10
|
-
private getNamespaces;
|
|
11
|
-
private initReferences;
|
|
12
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const metadataJsonUtil_1 = require("./metadataJsonUtil");
|
|
4
|
-
class MetadataJsonReferenceUtil {
|
|
5
|
-
constructor(json) {
|
|
6
|
-
this.aliases = null;
|
|
7
|
-
this.namespaces = null;
|
|
8
|
-
this.json = json;
|
|
9
|
-
}
|
|
10
|
-
aliasToNamespace(target) {
|
|
11
|
-
return this.convertReference(this.getAliases(), target);
|
|
12
|
-
}
|
|
13
|
-
namespaceToAlias(target) {
|
|
14
|
-
return this.convertReference(this.getNamespaces(), target);
|
|
15
|
-
}
|
|
16
|
-
convertReference(references, target) {
|
|
17
|
-
for (const alias of references.keys()) {
|
|
18
|
-
target = target.replaceAll(alias + ".", references.get(alias) + ".");
|
|
19
|
-
}
|
|
20
|
-
return target;
|
|
21
|
-
}
|
|
22
|
-
getAliases() {
|
|
23
|
-
this.initReferences();
|
|
24
|
-
return this.aliases;
|
|
25
|
-
}
|
|
26
|
-
getNamespaces() {
|
|
27
|
-
this.initReferences();
|
|
28
|
-
return this.namespaces;
|
|
29
|
-
}
|
|
30
|
-
initReferences() {
|
|
31
|
-
if (!this.aliases || !this.namespaces) {
|
|
32
|
-
const references = new Array();
|
|
33
|
-
for (const ref of metadataJsonUtil_1.default.getReferences(this.json)) {
|
|
34
|
-
references.push(...ref.includes);
|
|
35
|
-
}
|
|
36
|
-
references.push(metadataJsonUtil_1.default.getSchemaReference(this.json));
|
|
37
|
-
this.aliases = new Map();
|
|
38
|
-
this.namespaces = new Map();
|
|
39
|
-
for (const mapping of references) {
|
|
40
|
-
if (mapping.alias && mapping.namespace) {
|
|
41
|
-
const { alias, namespace } = mapping;
|
|
42
|
-
this.aliases.set(alias, namespace);
|
|
43
|
-
this.namespaces.set(namespace, alias);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.default = MetadataJsonReferenceUtil;
|
|
50
|
-
//# sourceMappingURL=metadataJsonReferenceUtil.js.map
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export default class MetadataJsonUtil {
|
|
2
|
-
static mapAnnotationsPerTarget(json: any): Map<string, IJsonIndex>;
|
|
3
|
-
static getVersion(json: any): any;
|
|
4
|
-
static getAnnotations(json: any): any[];
|
|
5
|
-
static setAnnotations(json: any, annotations: any[]): void;
|
|
6
|
-
static getSchemaNode(json: any): any;
|
|
7
|
-
static getSchemaReference(json: any): MetadataInclude;
|
|
8
|
-
static getEdmx(json: any): any;
|
|
9
|
-
static getDataServices(json: any): any;
|
|
10
|
-
static getReferences(json: any): MetadataReference[];
|
|
11
|
-
static toArrayReadOnly(json: any): any[];
|
|
12
|
-
static toArrayTransform(json: any, property: string): void;
|
|
13
|
-
}
|
|
14
|
-
export declare class MetadataReference {
|
|
15
|
-
uri: string;
|
|
16
|
-
includes: MetadataInclude[];
|
|
17
|
-
constructor(referenceJson: any);
|
|
18
|
-
getAlias(namespace: string): string | undefined;
|
|
19
|
-
}
|
|
20
|
-
export declare class MetadataInclude {
|
|
21
|
-
namespace: string;
|
|
22
|
-
alias: string;
|
|
23
|
-
constructor(alias: string, namespace: string);
|
|
24
|
-
equals(other: MetadataInclude): boolean;
|
|
25
|
-
static fromJson(json: any): MetadataInclude;
|
|
26
|
-
}
|
|
27
|
-
export interface IJsonIndex {
|
|
28
|
-
json: any;
|
|
29
|
-
index: number;
|
|
30
|
-
}
|