@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.
Files changed (106) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/eslint.config.js +52 -0
  3. package/package.json +42 -52
  4. package/scripts/metadataDownloadHelper.ts +8 -7
  5. package/scripts/rollup/bundle.d.ts +25 -0
  6. package/scripts/rollup/bundleDefinition.js +11 -1
  7. package/scripts/{bundler.ts → rollup/bundler.ts} +6 -17
  8. package/scripts/rollup/overrides/sap/base/config.js +10 -0
  9. package/scripts/rollup/project/package.json +2 -1
  10. package/scripts/rollup/project/ui5.yaml +1 -1
  11. package/scripts/rollup/ui5Resolve.ts +14 -38
  12. package/scripts/rollup.ts +67 -23
  13. package/types/ui5.d.ts +44 -0
  14. package/dist/annotationManager.d.ts +0 -18
  15. package/dist/annotationManager.js +0 -80
  16. package/dist/annotations/comparator/comparator.d.ts +0 -47
  17. package/dist/annotations/comparator/comparator.js +0 -279
  18. package/dist/annotations/comparator/diffCase.d.ts +0 -4
  19. package/dist/annotations/comparator/diffCase.js +0 -3
  20. package/dist/annotations/comparator/interchangableCase.d.ts +0 -25
  21. package/dist/annotations/comparator/interchangableCase.js +0 -65
  22. package/dist/annotations/converter/metadataJsonReferenceUtil.d.ts +0 -12
  23. package/dist/annotations/converter/metadataJsonReferenceUtil.js +0 -50
  24. package/dist/annotations/converter/metadataJsonUtil.d.ts +0 -30
  25. package/dist/annotations/converter/metadataJsonUtil.js +0 -73
  26. package/dist/annotations/converter/ui5JsonConverter.d.ts +0 -21
  27. package/dist/annotations/converter/ui5JsonConverter.js +0 -253
  28. package/dist/annotations/converter/ui5MetadataJsonUtil.d.ts +0 -3
  29. package/dist/annotations/converter/ui5MetadataJsonUtil.js +0 -13
  30. package/dist/annotations/converter/ui5XmlConverter.d.ts +0 -5
  31. package/dist/annotations/converter/ui5XmlConverter.js +0 -17
  32. package/dist/annotations/dataSource/dataSource.d.ts +0 -34
  33. package/dist/annotations/dataSource/dataSource.js +0 -62
  34. package/dist/annotations/dataSource/dataSourceManager.d.ts +0 -12
  35. package/dist/annotations/dataSource/dataSourceManager.js +0 -50
  36. package/dist/annotations/dataSource/dataSourceOData.d.ts +0 -17
  37. package/dist/annotations/dataSource/dataSourceOData.js +0 -47
  38. package/dist/annotations/dataSource/dataSourceODataAnnotation.d.ts +0 -6
  39. package/dist/annotations/dataSource/dataSourceODataAnnotation.js +0 -18
  40. package/dist/annotations/serviceRequestor.d.ts +0 -9
  41. package/dist/annotations/serviceRequestor.js +0 -71
  42. package/dist/annotations/transformers/convertV2ToV4.d.ts +0 -4
  43. package/dist/annotations/transformers/convertV2ToV4.js +0 -16
  44. package/dist/annotations/transformers/makeAnnotationNamespaceUnique.d.ts +0 -6
  45. package/dist/annotations/transformers/makeAnnotationNamespaceUnique.js +0 -44
  46. package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.d.ts +0 -4
  47. package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.js +0 -17
  48. package/dist/annotations/transformers/transformer.d.ts +0 -12
  49. package/dist/annotations/transformers/transformer.js +0 -3
  50. package/dist/annotations/transformers/traverseReferences.d.ts +0 -9
  51. package/dist/annotations/transformers/traverseReferences.js +0 -67
  52. package/dist/appVariantManager.d.ts +0 -12
  53. package/dist/appVariantManager.js +0 -105
  54. package/dist/baseAppManager.d.ts +0 -29
  55. package/dist/baseAppManager.js +0 -141
  56. package/dist/buildStrategy.d.ts +0 -7
  57. package/dist/buildStrategy.js +0 -21
  58. package/dist/bundle-odata.js +0 -5498
  59. package/dist/bundle.js +0 -3475
  60. package/dist/cache/annotationsCacheManager.d.ts +0 -8
  61. package/dist/cache/annotationsCacheManager.js +0 -18
  62. package/dist/cache/baseAppFilesCacheManager.d.ts +0 -6
  63. package/dist/cache/baseAppFilesCacheManager.js +0 -15
  64. package/dist/cache/cacheManager.d.ts +0 -16
  65. package/dist/cache/cacheManager.js +0 -68
  66. package/dist/i18nManager.d.ts +0 -43
  67. package/dist/i18nManager.js +0 -203
  68. package/dist/index.d.ts +0 -1
  69. package/dist/index.js +0 -27
  70. package/dist/model/annotationDiffStructureError.d.ts +0 -3
  71. package/dist/model/annotationDiffStructureError.js +0 -11
  72. package/dist/model/language.d.ts +0 -13
  73. package/dist/model/language.js +0 -37
  74. package/dist/model/noAuthorizationProvidedError.d.ts +0 -3
  75. package/dist/model/noAuthorizationProvidedError.js +0 -9
  76. package/dist/model/serverError.d.ts +0 -3
  77. package/dist/model/serverError.js +0 -9
  78. package/dist/model/types.d.ts +0 -119
  79. package/dist/model/types.js +0 -3
  80. package/dist/processors/abapProcessor.d.ts +0 -21
  81. package/dist/processors/abapProcessor.js +0 -36
  82. package/dist/processors/cfProcessor.d.ts +0 -17
  83. package/dist/processors/cfProcessor.js +0 -46
  84. package/dist/processors/processor.d.ts +0 -7
  85. package/dist/processors/processor.js +0 -36
  86. package/dist/repositories/abapRepoManager.d.ts +0 -13
  87. package/dist/repositories/abapRepoManager.js +0 -82
  88. package/dist/repositories/html5RepoManager.d.ts +0 -11
  89. package/dist/repositories/html5RepoManager.js +0 -89
  90. package/dist/util/cfUtil.d.ts +0 -30
  91. package/dist/util/cfUtil.js +0 -173
  92. package/dist/util/commonUtil.d.ts +0 -13
  93. package/dist/util/commonUtil.js +0 -129
  94. package/dist/util/i18nMerger.d.ts +0 -28
  95. package/dist/util/i18nMerger.js +0 -103
  96. package/dist/util/requestUtil.d.ts +0 -8
  97. package/dist/util/requestUtil.js +0 -57
  98. package/dist/util/resourceUtil.d.ts +0 -11
  99. package/dist/util/resourceUtil.js +0 -65
  100. package/dist/util/urlUtil.d.ts +0 -4
  101. package/dist/util/urlUtil.js +0 -21
  102. package/dist/util/xmlUtil.d.ts +0 -4
  103. package/dist/util/xmlUtil.js +0 -24
  104. package/dist/util/zipUtil.d.ts +0 -2
  105. package/dist/util/zipUtil.js +0 -20
  106. package/scripts/rollup/bundleDefinition-odata.js +0 -9
@@ -1,73 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MetadataInclude = exports.MetadataReference = void 0;
4
- class MetadataJsonUtil {
5
- static mapAnnotationsPerTarget(json) {
6
- const annotations = Array.isArray(json) ? json : this.getAnnotations(json);
7
- return new Map(annotations.map((json, index) => [json?._attributes?.Target, { json, index }]));
8
- }
9
- static getVersion(json) {
10
- return this.getEdmx(json)?._attributes?.Version;
11
- }
12
- static getAnnotations(json) {
13
- return this.toArrayReadOnly(this.getSchemaNode(json)?.Annotations);
14
- }
15
- static setAnnotations(json, annotations) {
16
- const schema = this.getSchemaNode(json);
17
- annotations.forEach(annotation => annotation._attributes.xmlns = "http://docs.oasis-open.org/odata/ns/edm");
18
- schema.Annotations = annotations;
19
- }
20
- static getSchemaNode(json) {
21
- return this.getDataServices(json)?.Schema;
22
- }
23
- static getSchemaReference(json) {
24
- return MetadataInclude.fromJson(this.getDataServices(json)?.Schema?._attributes);
25
- }
26
- static getEdmx(json) {
27
- return json["edmx:Edmx"];
28
- }
29
- static getDataServices(json) {
30
- return this.getEdmx(json)["edmx:DataServices"];
31
- }
32
- static getReferences(json) {
33
- const referenceNode = this.toArrayReadOnly(this.getEdmx(json)["edmx:Reference"]);
34
- return referenceNode.map(ref => new MetadataReference(ref));
35
- }
36
- static toArrayReadOnly(json) {
37
- return Array.isArray(json) ? json : [json];
38
- }
39
- static toArrayTransform(json, property) {
40
- if (!Array.isArray(json[property])) {
41
- json[property] = [json[property]];
42
- }
43
- }
44
- }
45
- exports.default = MetadataJsonUtil;
46
- class MetadataReference {
47
- constructor(referenceJson) {
48
- this.includes = new Array();
49
- this.uri = referenceJson._attributes.Uri;
50
- for (const include of MetadataJsonUtil.toArrayReadOnly(referenceJson["edmx:Include"])) {
51
- this.includes.push(MetadataInclude.fromJson(include));
52
- }
53
- }
54
- getAlias(namespace) {
55
- const include = this.includes.find(include => include.namespace === namespace);
56
- return include?.alias;
57
- }
58
- }
59
- exports.MetadataReference = MetadataReference;
60
- class MetadataInclude {
61
- constructor(alias, namespace) {
62
- this.alias = alias;
63
- this.namespace = namespace;
64
- }
65
- equals(other) {
66
- return this.alias === other.alias && this.namespace === other.namespace;
67
- }
68
- static fromJson(json) {
69
- return new MetadataInclude(json?._attributes?.Alias, json?._attributes?.Namespace);
70
- }
71
- }
72
- exports.MetadataInclude = MetadataInclude;
73
- //# sourceMappingURL=metadataJsonUtil.js.map
@@ -1,21 +0,0 @@
1
- export default class UI5JsonConverter {
2
- config: any;
3
- oAnnotationConfig: any;
4
- static convertAnnotations(json: any): any[];
5
- static processAnnotations(json: any, target: string): any;
6
- private static processObject;
7
- static processTerms(json: any): any;
8
- private static processInlineAnnotationWithCollections;
9
- private static isReferenced;
10
- private static processAnnotation;
11
- private static getInlineAnnotation;
12
- private static createTerm;
13
- private static processCollection;
14
- private static processCollectionItem;
15
- private static updateToArray;
16
- private static getAttributes;
17
- private static trimLeft;
18
- private static trimByAt;
19
- private static isWrapped;
20
- private static getWrappedProperty;
21
- }
@@ -1,253 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const ui5MetadataJsonUtil_1 = require("./ui5MetadataJsonUtil");
4
- class UI5JsonConverter {
5
- static convertAnnotations(json) {
6
- const annotationsNode = ui5MetadataJsonUtil_1.default.getAnnotationsNode(json);
7
- if (annotationsNode) {
8
- return Object.entries(annotationsNode).map(([target, annotations]) => this.processAnnotations(annotations, target));
9
- }
10
- return [];
11
- }
12
- static processAnnotations(json, target) {
13
- const attributes = {
14
- "_attributes": {
15
- "Target": this.trimLeft(target, "@")
16
- }
17
- };
18
- const annotation = this.processTerms(json);
19
- return Object.assign(attributes, annotation);
20
- }
21
- static processObject(term, value) {
22
- let wrapped = this.getWrappedProperty(value);
23
- if (wrapped) {
24
- this.getAttributes(term)[wrapped.property] = wrapped.value;
25
- }
26
- else {
27
- const record = this.processTerms(value);
28
- this.updateToArray(term, "Record", record);
29
- }
30
- }
31
- static processTerms(json) {
32
- let result = {};
33
- const pendingInlineAnnotationKeys = new Array();
34
- for (const key of Object.keys(json)) {
35
- let wrapped = this.getWrappedProperty(json);
36
- const inlineAnnotation = this.getInlineAnnotation(key);
37
- if (inlineAnnotation) {
38
- pendingInlineAnnotationKeys.push(inlineAnnotation);
39
- continue;
40
- }
41
- if (wrapped) {
42
- this.getAttributes(result)[wrapped.property] = wrapped.value;
43
- }
44
- else if (key.startsWith("$")) {
45
- this.getAttributes(result)[this.trimLeft(key, "$")] = json[key];
46
- }
47
- else {
48
- // Split Annotation from PropertyValue
49
- const options = (key[0] === "@") ? {
50
- attributesProperty: "Term",
51
- entity: "Annotation"
52
- } : {
53
- attributesProperty: "Property",
54
- entity: "PropertyValue",
55
- explicitBoolean: true
56
- };
57
- const term = this.createTerm(key, options.attributesProperty);
58
- const value = json[key];
59
- if (typeof value === "string") {
60
- term._attributes.String = value;
61
- }
62
- else if (typeof value === "boolean" && (!value || options.explicitBoolean)) {
63
- term._attributes.Bool = value.toString();
64
- }
65
- else if (typeof value === "number") {
66
- term._attributes.Int = value.toString();
67
- }
68
- else if (Array.isArray(value)) {
69
- this.processCollection(term, value);
70
- }
71
- else if (typeof value === "object") {
72
- this.processObject(term, value);
73
- }
74
- this.updateToArray(result, options.entity, term);
75
- }
76
- }
77
- for (const inlineAnnotation of pendingInlineAnnotationKeys) {
78
- const { term, reference } = inlineAnnotation;
79
- if (inlineAnnotation.isInlineAnnotationWithCollections) {
80
- // TODO can possibly be merged with below
81
- this.processInlineAnnotationWithCollections(inlineAnnotation, json, result);
82
- }
83
- else if (Array.isArray(json[inlineAnnotation.key])) {
84
- const annotationTerm = { Annotation: this.createTerm(term, "Term") };
85
- this.processCollection(annotationTerm.Annotation, json[inlineAnnotation.key]);
86
- if (Array.isArray(result[inlineAnnotation.entity])) {
87
- let referenced = result[inlineAnnotation.entity].find((item) => this.isReferenced(item, inlineAnnotation.attributesProperty, reference));
88
- if (referenced) {
89
- referenced = Object.assign(referenced, annotationTerm);
90
- }
91
- }
92
- else if (result[inlineAnnotation.entity]) {
93
- result[inlineAnnotation.entity] = Object.assign(result[inlineAnnotation.entity], annotationTerm);
94
- }
95
- }
96
- else {
97
- const annotation = this.processAnnotation(json, inlineAnnotation.key, term);
98
- if (Array.isArray(result[inlineAnnotation.entity])) {
99
- const referenced = result[inlineAnnotation.entity].find((item) => this.isReferenced(item, inlineAnnotation.attributesProperty, reference));
100
- if (referenced) {
101
- referenced.Annotation = annotation;
102
- }
103
- }
104
- else if (result[inlineAnnotation.entity]) {
105
- result[inlineAnnotation.entity].Annotation = annotation;
106
- }
107
- }
108
- }
109
- return result;
110
- }
111
- static processInlineAnnotationWithCollections(inlineAnnotation, json, result) {
112
- delete Object.assign(json, { [`@${inlineAnnotation.term}`]: json[inlineAnnotation.key] })[inlineAnnotation.key];
113
- const term = this.createTerm(inlineAnnotation.term, "Term");
114
- this.processCollection(term, json[`@${inlineAnnotation.term}`]);
115
- const PropertyValue = (Array.isArray(result.PropertyValue)) ? result.PropertyValue : [result.PropertyValue];
116
- const targetProperty = PropertyValue.find((propertyValueObject) => {
117
- return this.isReferenced(propertyValueObject, "Property", inlineAnnotation.reference);
118
- });
119
- if (targetProperty) {
120
- this.updateToArray(targetProperty, "Annotation", term);
121
- }
122
- }
123
- static isReferenced(item, attributesProperty, reference) {
124
- return this.getAttributes(item) && this.getAttributes(item)[attributesProperty] === reference;
125
- }
126
- static processAnnotation(json, key, term = key) {
127
- const annotation = this.processTerms(json[key]);
128
- const annotationTerm = this.trimByAt(term);
129
- const attributes = this.getAttributes(annotation);
130
- if (Object.keys(attributes).length > 0 && annotationTerm) {
131
- annotation._attributes = Object.assign({ "Term": annotationTerm }, attributes);
132
- }
133
- else {
134
- this.getAttributes(annotation).Term = annotationTerm;
135
- }
136
- return annotation;
137
- }
138
- static getInlineAnnotation(key) {
139
- const parts = key.split("@"); // @<ref>@<term>
140
- if (parts.length === 3) {
141
- return {
142
- reference: parts[1],
143
- term: parts[2],
144
- key,
145
- attributesProperty: "Term",
146
- entity: "Annotation"
147
- };
148
- }
149
- else if (parts.length === 2 && parts[0]) { // <ref>@<term>
150
- return {
151
- reference: parts[0],
152
- term: parts[1],
153
- key,
154
- isInlineAnnotationWithCollections: true,
155
- attributesProperty: "Property",
156
- entity: "PropertyValue",
157
- };
158
- }
159
- }
160
- static createTerm(key, attributesProperty) {
161
- const parts = key.split("#");
162
- const qualifier = parts.length > 1 && parts.pop();
163
- const term = {
164
- "_attributes": {
165
- [attributesProperty]: this.trimByAt(parts[0])
166
- }
167
- };
168
- if (qualifier) {
169
- term._attributes.Qualifier = qualifier;
170
- }
171
- return term;
172
- }
173
- static processCollection(term, value) {
174
- const collection = term.Collection = {};
175
- for (const item of value) {
176
- this.processCollectionItem(collection, item);
177
- }
178
- }
179
- static processCollectionItem(collection, item) {
180
- let wrapped = this.getWrappedProperty(item);
181
- if (wrapped) {
182
- this.updateToArray(collection, wrapped.property, wrapped.value.length > 0 ? { _text: wrapped.value } : {});
183
- }
184
- else if (typeof item === "string") {
185
- this.updateToArray(collection, "String", { _text: item });
186
- }
187
- else if (typeof item === "object") {
188
- this.processObject(collection, item);
189
- }
190
- }
191
- static updateToArray(object, key, value) {
192
- if (object[key]) {
193
- if (!Array.isArray(object[key])) {
194
- object[key] = [object[key]];
195
- }
196
- object[key].push(value);
197
- }
198
- else {
199
- object[key] = value;
200
- }
201
- }
202
- static getAttributes(parent) {
203
- if (parent._attributes == null) {
204
- parent._attributes = {};
205
- }
206
- return parent._attributes;
207
- }
208
- static trimLeft(str, char) {
209
- while (str.startsWith(char)) {
210
- str = str.substring(1);
211
- }
212
- return str;
213
- }
214
- static trimByAt(term) {
215
- const indexOfAt = term.indexOf("@");
216
- if (indexOfAt > -1) {
217
- return term.substring(indexOfAt + 1);
218
- }
219
- return term;
220
- }
221
- static isWrapped(type) {
222
- // copied from openUI5 _MetadataConverter.js
223
- switch (type) {
224
- case "$AnnotationPath":
225
- case "$NavigationPropertyPath":
226
- case "$Path":
227
- case "$PropertyPath":
228
- case "$Binary":
229
- case "$Date":
230
- case "$DateTimeOffset":
231
- case "$Decimal":
232
- case "$Duration":
233
- case "$Guid":
234
- case "$TimeOfDay":
235
- case "$UrlRef":
236
- case "$EnumMember":
237
- return true;
238
- }
239
- }
240
- static getWrappedProperty(item) {
241
- if (typeof item === "object") {
242
- const keys = Object.keys(item);
243
- if (keys.length === 1 && this.isWrapped(keys[0])) {
244
- return {
245
- property: keys[0].substring(1),
246
- value: item[keys[0]]
247
- };
248
- }
249
- }
250
- }
251
- }
252
- exports.default = UI5JsonConverter;
253
- //# sourceMappingURL=ui5JsonConverter.js.map
@@ -1,3 +0,0 @@
1
- export default class UI5MetadataJsonUtil {
2
- static getAnnotationsNode(json: any): any;
3
- }
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- class UI5MetadataJsonUtil {
4
- static getAnnotationsNode(json) {
5
- for (const key of Object.keys(json)) {
6
- if (json[key].$kind === "Schema") {
7
- return json[key].$Annotations;
8
- }
9
- }
10
- }
11
- }
12
- exports.default = UI5MetadataJsonUtil;
13
- //# sourceMappingURL=ui5MetadataJsonUtil.js.map
@@ -1,5 +0,0 @@
1
- export default class UI5XmlConverter {
2
- static convertV2(xml: string): any;
3
- static convertV4(xml: string): any;
4
- private static getDocument;
5
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const { V2MetadataConverter, V4MetadataConverter } = require("../../../dist/bundle-odata");
4
- const jsdom_1 = require("jsdom");
5
- class UI5XmlConverter {
6
- static convertV2(xml) {
7
- return new V2MetadataConverter().convertXMLMetadata(this.getDocument(xml));
8
- }
9
- static convertV4(xml) {
10
- return new V4MetadataConverter().convertXMLMetadata(this.getDocument(xml));
11
- }
12
- static getDocument(xml) {
13
- return (new jsdom_1.JSDOM(xml, { contentType: "application/xml" })).window._document;
14
- }
15
- }
16
- exports.default = UI5XmlConverter;
17
- //# sourceMappingURL=ui5XmlConverter.js.map
@@ -1,34 +0,0 @@
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";
6
- export default class DataSource {
7
- protected name: string;
8
- private uri;
9
- protected jsonTransformers: Transformer[];
10
- constructor(name: string, uri: string);
11
- /**
12
- * Update the json of the dataSources in manifest.json
13
- */
14
- updateManifest(_: any): void;
15
- /**
16
- * Get the filename under which it should be stored in dist folder
17
- */
18
- getFilename(): string;
19
- createAnnotationFile(languages: Language[], i18nManager: I18nManager, serviceRequestor: ServiceRequestor): Promise<{
20
- filename: string;
21
- xml: string;
22
- }>;
23
- /**
24
- * Download the annotation for all configured languages
25
- * @param languages from configuration
26
- * @param serviceRequestor will download the annotation for all languages
27
- */
28
- private getPromisesPerLanguage;
29
- /**
30
- * Download annotations and process xml string after it
31
- */
32
- downloadAnnotation(language: Language, serviceRequestor: ServiceRequestor): Promise<any>;
33
- afterXmlDownload({ xml, language, serviceRequestor, uri }: IAnnotationDownloadParams): Promise<any>;
34
- }
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const xmlUtil_1 = require("../../util/xmlUtil");
4
- class DataSource {
5
- constructor(name, uri) {
6
- this.jsonTransformers = new Array();
7
- this.name = name;
8
- this.uri = uri;
9
- }
10
- /**
11
- * Update the json of the dataSources in manifest.json
12
- */
13
- updateManifest(_) {
14
- // to be overriden in children
15
- }
16
- /**
17
- * Get the filename under which it should be stored in dist folder
18
- */
19
- getFilename() {
20
- return `annotations/annotation_${this.name}.xml`;
21
- }
22
- async createAnnotationFile(languages, i18nManager, serviceRequestor) {
23
- const annotationJsons = this.getPromisesPerLanguage(languages, serviceRequestor);
24
- const annotationJson = await i18nManager.populateTranslations(annotationJsons);
25
- const xml = xmlUtil_1.default.jsonToXml(await annotationJson.json);
26
- return {
27
- filename: this.getFilename(),
28
- xml
29
- };
30
- }
31
- /**
32
- * Download the annotation for all configured languages
33
- * @param languages from configuration
34
- * @param serviceRequestor will download the annotation for all languages
35
- */
36
- getPromisesPerLanguage(languages, serviceRequestor) {
37
- const promises = new Map();
38
- for (const language of languages) {
39
- promises.set(language, this.downloadAnnotation(language, serviceRequestor));
40
- }
41
- return promises;
42
- }
43
- /**
44
- * Download annotations and process xml string after it
45
- */
46
- async downloadAnnotation(language, serviceRequestor) {
47
- const languageXmlContent = await serviceRequestor.downloadAnnotation(this.uri, this.name, language);
48
- if (!languageXmlContent) {
49
- throw new Error(`Xml is undefined for '${this.uri}', name '${this.name}' and language '${language.sap}'`);
50
- }
51
- return this.afterXmlDownload({ xml: languageXmlContent, language, serviceRequestor, uri: this.uri });
52
- }
53
- async afterXmlDownload({ xml, language, serviceRequestor, uri }) {
54
- let json = xmlUtil_1.default.xmlToJson(xml);
55
- for (const transformer of this.jsonTransformers) {
56
- json = await transformer.transform({ xml, json, language, serviceRequestor, uri });
57
- }
58
- return json;
59
- }
60
- }
61
- exports.default = DataSource;
62
- //# sourceMappingURL=dataSource.js.map
@@ -1,12 +0,0 @@
1
- import I18nManager from "../../i18nManager";
2
- import Language from "../../model/language";
3
- import ServiceRequestor from "../serviceRequestor";
4
- export default class DataSourceManager {
5
- private dataSources;
6
- /**
7
- * Parses dataSources from manifest.json.
8
- * @param dataSourcesJson manifest.json/sap.app/dataSources node
9
- */
10
- addDataSources(dataSourcesJson: any): void;
11
- createAnnotationFiles(languages: Language[], i18nManager: I18nManager, serviceRequestor: ServiceRequestor): Promise<Map<string, string>>;
12
- }
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const dataSourceOData_1 = require("./dataSourceOData");
4
- const dataSourceODataAnnotation_1 = require("./dataSourceODataAnnotation");
5
- const path_1 = require("path");
6
- class DataSourceManager {
7
- constructor() {
8
- this.dataSources = new Array();
9
- }
10
- /**
11
- * Parses dataSources from manifest.json.
12
- * @param dataSourcesJson manifest.json/sap.app/dataSources node
13
- */
14
- addDataSources(dataSourcesJson) {
15
- if (!dataSourcesJson) {
16
- return;
17
- }
18
- const odataAnnotationMap = new Map();
19
- // Loop over OData first to collect linked annotation names
20
- for (const [name, dataSource] of Object.entries(dataSourcesJson)) {
21
- if (dataSource.uri?.startsWith("/") && dataSource.type === "OData") {
22
- const uri = path_1.posix.normalize(dataSource.uri + "/$metadata");
23
- const odata = new dataSourceOData_1.default(name, uri, dataSource);
24
- odata.getAnnotations().forEach(annotation => odataAnnotationMap.set(annotation, uri));
25
- this.dataSources.push(odata);
26
- }
27
- }
28
- // If ODataAnnotation is in OData annotations, pass metadata url to it
29
- for (const [name, dataSource] of Object.entries(dataSourcesJson)) {
30
- const uri = dataSource.uri;
31
- const metadataUrl = odataAnnotationMap.get(name);
32
- if (uri?.startsWith("/") && dataSource.type === "ODataAnnotation") {
33
- this.dataSources.push(new dataSourceODataAnnotation_1.default(name, uri, dataSource, metadataUrl));
34
- }
35
- }
36
- for (const dataSource of this.dataSources) {
37
- dataSource.updateManifest(dataSourcesJson);
38
- }
39
- }
40
- async createAnnotationFiles(languages, i18nManager, serviceRequestor) {
41
- const annotationFiles = new Map();
42
- for (const dataSource of this.dataSources) {
43
- const { filename, xml } = await dataSource.createAnnotationFile(languages, i18nManager, serviceRequestor);
44
- annotationFiles.set(filename, xml);
45
- }
46
- return annotationFiles;
47
- }
48
- }
49
- exports.default = DataSourceManager;
50
- //# sourceMappingURL=dataSourceManager.js.map
@@ -1,17 +0,0 @@
1
- import DataSource from "./dataSource";
2
- import Language from "../../model/language";
3
- import ServiceRequestor from "../serviceRequestor";
4
- export interface IAnnotationDownloadParams {
5
- uri: string;
6
- xml: string;
7
- language: Language;
8
- serviceRequestor: ServiceRequestor;
9
- }
10
- export default class DataSourceOData extends DataSource {
11
- private dataSourceJson;
12
- constructor(name: string, uri: string, dataSourceJson: any);
13
- updateManifest(manifestDataSources: any): void;
14
- addNewODataAnnotation(manifestDataSources: any): void;
15
- private getSettings;
16
- getAnnotations(): string[];
17
- }
@@ -1,47 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const convertV2ToV4_1 = require("../transformers/convertV2ToV4");
4
- const dataSource_1 = require("./dataSource");
5
- const makeAnnotationNamespaceUnique_1 = require("../transformers/makeAnnotationNamespaceUnique");
6
- const removeAllSchemaNodesExceptAnnotations_1 = require("../transformers/removeAllSchemaNodesExceptAnnotations");
7
- const traverseReferences_1 = require("../transformers/traverseReferences");
8
- const commonUtil_1 = require("../../util/commonUtil");
9
- class DataSourceOData extends dataSource_1.default {
10
- constructor(name, uri, dataSourceJson) {
11
- super(name, uri);
12
- this.dataSourceJson = dataSourceJson;
13
- this.jsonTransformers = [
14
- new traverseReferences_1.default(),
15
- new convertV2ToV4_1.default(),
16
- new removeAllSchemaNodesExceptAnnotations_1.default(),
17
- new makeAnnotationNamespaceUnique_1.default()
18
- ];
19
- }
20
- updateManifest(manifestDataSources) {
21
- this.getSettings().ignoreAnnotationsFromMetadata = true;
22
- this.addNewODataAnnotation(manifestDataSources);
23
- }
24
- addNewODataAnnotation(manifestDataSources) {
25
- const newAnnotationNameTemplate = `annotation_${this.name}`;
26
- let newAnnotationName = (0, commonUtil_1.getUniqueName)(Object.keys(manifestDataSources), newAnnotationNameTemplate);
27
- this.getAnnotations().unshift(newAnnotationName);
28
- manifestDataSources[newAnnotationName] = {
29
- type: "ODataAnnotation",
30
- uri: this.getFilename()
31
- };
32
- }
33
- getSettings() {
34
- if (this.dataSourceJson.settings == null) {
35
- this.dataSourceJson.settings = {};
36
- }
37
- return this.dataSourceJson.settings;
38
- }
39
- getAnnotations() {
40
- if (this.getSettings().annotations == null) {
41
- this.getSettings().annotations = [];
42
- }
43
- return this.getSettings().annotations;
44
- }
45
- }
46
- exports.default = DataSourceOData;
47
- //# sourceMappingURL=dataSourceOData.js.map
@@ -1,6 +0,0 @@
1
- import DataSource from "./dataSource";
2
- export default class DataSourceODataAnnotation extends DataSource {
3
- private dataSourceJson;
4
- constructor(name: string, uri: string, dataSourceJson: any, metadataUrl: string | undefined);
5
- updateManifest(): void;
6
- }
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const dataSource_1 = require("./dataSource");
4
- const traverseReferences_1 = require("../transformers/traverseReferences");
5
- class DataSourceODataAnnotation extends dataSource_1.default {
6
- constructor(name, uri, dataSourceJson, metadataUrl) {
7
- super(name, uri);
8
- this.dataSourceJson = dataSourceJson;
9
- this.jsonTransformers = [
10
- new traverseReferences_1.default(metadataUrl)
11
- ];
12
- }
13
- updateManifest() {
14
- this.dataSourceJson.uri = this.getFilename();
15
- }
16
- }
17
- exports.default = DataSourceODataAnnotation;
18
- //# sourceMappingURL=dataSourceODataAnnotation.js.map
@@ -1,9 +0,0 @@
1
- import AbapRepoManager from "../repositories/abapRepoManager";
2
- import { IConfiguration } from "../model/types";
3
- import Language from "../model/language";
4
- export default class ServiceRequestor {
5
- private abapRepoManager;
6
- private configuration;
7
- constructor(configuration: IConfiguration, abapRepoManager: AbapRepoManager);
8
- downloadAnnotation(uri: string, name: string, language: Language): Promise<string>;
9
- }