@ui5/task-adaptation 1.3.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 (94) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/package.json +5 -8
  3. package/dist/annotationManager.d.ts +0 -18
  4. package/dist/annotationManager.js +0 -79
  5. package/dist/annotations/comparator/comparator.d.ts +0 -47
  6. package/dist/annotations/comparator/comparator.js +0 -283
  7. package/dist/annotations/comparator/diffCase.d.ts +0 -4
  8. package/dist/annotations/comparator/diffCase.js +0 -2
  9. package/dist/annotations/comparator/interchangableCase.d.ts +0 -25
  10. package/dist/annotations/comparator/interchangableCase.js +0 -60
  11. package/dist/annotations/converter/metadataJsonReferenceUtil.d.ts +0 -12
  12. package/dist/annotations/converter/metadataJsonReferenceUtil.js +0 -48
  13. package/dist/annotations/converter/metadataJsonUtil.d.ts +0 -30
  14. package/dist/annotations/converter/metadataJsonUtil.js +0 -70
  15. package/dist/annotations/converter/ui5JsonConverter.d.ts +0 -21
  16. package/dist/annotations/converter/ui5JsonConverter.js +0 -252
  17. package/dist/annotations/converter/ui5MetadataJsonUtil.d.ts +0 -3
  18. package/dist/annotations/converter/ui5MetadataJsonUtil.js +0 -10
  19. package/dist/annotations/converter/ui5XmlConverter.d.ts +0 -5
  20. package/dist/annotations/converter/ui5XmlConverter.js +0 -14
  21. package/dist/annotations/dataSource/dataSource.d.ts +0 -34
  22. package/dist/annotations/dataSource/dataSource.js +0 -62
  23. package/dist/annotations/dataSource/dataSourceManager.d.ts +0 -12
  24. package/dist/annotations/dataSource/dataSourceManager.js +0 -45
  25. package/dist/annotations/dataSource/dataSourceOData.d.ts +0 -17
  26. package/dist/annotations/dataSource/dataSourceOData.js +0 -45
  27. package/dist/annotations/dataSource/dataSourceODataAnnotation.d.ts +0 -6
  28. package/dist/annotations/dataSource/dataSourceODataAnnotation.js +0 -16
  29. package/dist/annotations/serviceRequestor.d.ts +0 -9
  30. package/dist/annotations/serviceRequestor.js +0 -73
  31. package/dist/annotations/transformers/convertV2ToV4.d.ts +0 -4
  32. package/dist/annotations/transformers/convertV2ToV4.js +0 -13
  33. package/dist/annotations/transformers/makeAnnotationNamespaceUnique.d.ts +0 -6
  34. package/dist/annotations/transformers/makeAnnotationNamespaceUnique.js +0 -41
  35. package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.d.ts +0 -4
  36. package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.js +0 -14
  37. package/dist/annotations/transformers/transformer.d.ts +0 -12
  38. package/dist/annotations/transformers/transformer.js +0 -2
  39. package/dist/annotations/transformers/traverseReferences.d.ts +0 -9
  40. package/dist/annotations/transformers/traverseReferences.js +0 -66
  41. package/dist/appVariantManager.d.ts +0 -12
  42. package/dist/appVariantManager.js +0 -102
  43. package/dist/baseAppManager.d.ts +0 -29
  44. package/dist/baseAppManager.js +0 -139
  45. package/dist/buildStrategy.d.ts +0 -7
  46. package/dist/buildStrategy.js +0 -19
  47. package/dist/bundle.d.ts +0 -25
  48. package/dist/bundle.js +0 -6952
  49. package/dist/cache/annotationsCacheManager.d.ts +0 -8
  50. package/dist/cache/annotationsCacheManager.js +0 -16
  51. package/dist/cache/baseAppFilesCacheManager.d.ts +0 -6
  52. package/dist/cache/baseAppFilesCacheManager.js +0 -12
  53. package/dist/cache/cacheManager.d.ts +0 -16
  54. package/dist/cache/cacheManager.js +0 -65
  55. package/dist/i18nManager.d.ts +0 -43
  56. package/dist/i18nManager.js +0 -203
  57. package/dist/index.d.ts +0 -6
  58. package/dist/index.js +0 -25
  59. package/dist/model/annotationDiffStructureError.d.ts +0 -3
  60. package/dist/model/annotationDiffStructureError.js +0 -8
  61. package/dist/model/language.d.ts +0 -13
  62. package/dist/model/language.js +0 -37
  63. package/dist/model/noAuthorizationProvidedError.d.ts +0 -3
  64. package/dist/model/noAuthorizationProvidedError.js +0 -6
  65. package/dist/model/serverError.d.ts +0 -3
  66. package/dist/model/serverError.js +0 -6
  67. package/dist/model/types.d.ts +0 -119
  68. package/dist/model/types.js +0 -2
  69. package/dist/processors/abapProcessor.d.ts +0 -21
  70. package/dist/processors/abapProcessor.js +0 -37
  71. package/dist/processors/cfProcessor.d.ts +0 -17
  72. package/dist/processors/cfProcessor.js +0 -45
  73. package/dist/processors/processor.d.ts +0 -7
  74. package/dist/processors/processor.js +0 -32
  75. package/dist/repositories/abapRepoManager.d.ts +0 -13
  76. package/dist/repositories/abapRepoManager.js +0 -82
  77. package/dist/repositories/html5RepoManager.d.ts +0 -11
  78. package/dist/repositories/html5RepoManager.js +0 -87
  79. package/dist/util/cfUtil.d.ts +0 -30
  80. package/dist/util/cfUtil.js +0 -171
  81. package/dist/util/commonUtil.d.ts +0 -13
  82. package/dist/util/commonUtil.js +0 -116
  83. package/dist/util/i18nMerger.d.ts +0 -32
  84. package/dist/util/i18nMerger.js +0 -99
  85. package/dist/util/requestUtil.d.ts +0 -8
  86. package/dist/util/requestUtil.js +0 -54
  87. package/dist/util/resourceUtil.d.ts +0 -11
  88. package/dist/util/resourceUtil.js +0 -62
  89. package/dist/util/urlUtil.d.ts +0 -4
  90. package/dist/util/urlUtil.js +0 -18
  91. package/dist/util/xmlUtil.d.ts +0 -4
  92. package/dist/util/xmlUtil.js +0 -21
  93. package/dist/util/zipUtil.d.ts +0 -2
  94. package/dist/util/zipUtil.js +0 -16
@@ -1,70 +0,0 @@
1
- export default class MetadataJsonUtil {
2
- static mapAnnotationsPerTarget(json) {
3
- const annotations = Array.isArray(json) ? json : this.getAnnotations(json);
4
- return new Map(annotations.map((json, index) => [json?._attributes?.Target, { json, index }]));
5
- }
6
- static getVersion(json) {
7
- return this.getEdmx(json)?._attributes?.Version;
8
- }
9
- static getAnnotations(json) {
10
- return this.toArrayReadOnly(this.getSchemaNode(json)?.Annotations);
11
- }
12
- static setAnnotations(json, annotations) {
13
- const schema = this.getSchemaNode(json);
14
- annotations.forEach(annotation => annotation._attributes.xmlns = "http://docs.oasis-open.org/odata/ns/edm");
15
- schema.Annotations = annotations;
16
- }
17
- static getSchemaNode(json) {
18
- return this.getDataServices(json)?.Schema;
19
- }
20
- static getSchemaReference(json) {
21
- return MetadataInclude.fromJson(this.getDataServices(json)?.Schema?._attributes);
22
- }
23
- static getEdmx(json) {
24
- return json["edmx:Edmx"];
25
- }
26
- static getDataServices(json) {
27
- return this.getEdmx(json)["edmx:DataServices"];
28
- }
29
- static getReferences(json) {
30
- const referenceNode = this.toArrayReadOnly(this.getEdmx(json)["edmx:Reference"]);
31
- return referenceNode.map(ref => new MetadataReference(ref));
32
- }
33
- static toArrayReadOnly(json) {
34
- return Array.isArray(json) ? json : [json];
35
- }
36
- static toArrayTransform(json, property) {
37
- if (!Array.isArray(json[property])) {
38
- json[property] = [json[property]];
39
- }
40
- }
41
- }
42
- export class MetadataReference {
43
- uri;
44
- includes = new Array();
45
- constructor(referenceJson) {
46
- this.uri = referenceJson._attributes.Uri;
47
- for (const include of MetadataJsonUtil.toArrayReadOnly(referenceJson["edmx:Include"])) {
48
- this.includes.push(MetadataInclude.fromJson(include));
49
- }
50
- }
51
- getAlias(namespace) {
52
- const include = this.includes.find(include => include.namespace === namespace);
53
- return include?.alias;
54
- }
55
- }
56
- export class MetadataInclude {
57
- namespace;
58
- alias;
59
- constructor(alias, namespace) {
60
- this.alias = alias;
61
- this.namespace = namespace;
62
- }
63
- equals(other) {
64
- return this.alias === other.alias && this.namespace === other.namespace;
65
- }
66
- static fromJson(json) {
67
- return new MetadataInclude(json?._attributes?.Alias, json?._attributes?.Namespace);
68
- }
69
- }
70
- //# 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,252 +0,0 @@
1
- import UI5JsonParser from "./ui5MetadataJsonUtil.js";
2
- export default class UI5JsonConverter {
3
- config;
4
- oAnnotationConfig;
5
- static convertAnnotations(json) {
6
- const annotationsNode = UI5JsonParser.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
- //# sourceMappingURL=ui5JsonConverter.js.map
@@ -1,3 +0,0 @@
1
- export default class UI5MetadataJsonUtil {
2
- static getAnnotationsNode(json: any): any;
3
- }
@@ -1,10 +0,0 @@
1
- export default class UI5MetadataJsonUtil {
2
- static getAnnotationsNode(json) {
3
- for (const key of Object.keys(json)) {
4
- if (json[key].$kind === "Schema") {
5
- return json[key].$Annotations;
6
- }
7
- }
8
- }
9
- }
10
- //# 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,14 +0,0 @@
1
- import { V2MetadataConverter, V4MetadataConverter } from "../../../dist/bundle.js";
2
- import { JSDOM } from "jsdom";
3
- export default class UI5XmlConverter {
4
- static convertV2(xml) {
5
- return new V2MetadataConverter().convertXMLMetadata(this.getDocument(xml));
6
- }
7
- static convertV4(xml) {
8
- return new V4MetadataConverter().convertXMLMetadata(this.getDocument(xml));
9
- }
10
- static getDocument(xml) {
11
- return (new JSDOM(xml, { contentType: "application/xml" })).window._document;
12
- }
13
- }
14
- //# sourceMappingURL=ui5XmlConverter.js.map
@@ -1,34 +0,0 @@
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
- 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
- import XmlUtil from "../../util/xmlUtil.js";
2
- export default class DataSource {
3
- name;
4
- uri;
5
- jsonTransformers = new Array();
6
- constructor(name, uri) {
7
- this.name = name;
8
- this.uri = uri;
9
- }
10
- /**
11
- * Update the json of the dataSources in manifest.json
12
- */
13
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
14
- updateManifest(_) {
15
- // to be overriden in children
16
- }
17
- /**
18
- * Get the filename under which it should be stored in dist folder
19
- */
20
- getFilename() {
21
- return `annotations/annotation_${this.name}.xml`;
22
- }
23
- async createAnnotationFile(languages, i18nManager, serviceRequestor) {
24
- const annotationJsons = this.getPromisesPerLanguage(languages, serviceRequestor);
25
- const annotationJson = await i18nManager.populateTranslations(annotationJsons);
26
- const xml = XmlUtil.jsonToXml(await annotationJson.json);
27
- return {
28
- filename: this.getFilename(),
29
- xml
30
- };
31
- }
32
- /**
33
- * Download the annotation for all configured languages
34
- * @param languages from configuration
35
- * @param serviceRequestor will download the annotation for all languages
36
- */
37
- getPromisesPerLanguage(languages, serviceRequestor) {
38
- const promises = new Map();
39
- for (const language of languages) {
40
- promises.set(language, this.downloadAnnotation(language, serviceRequestor));
41
- }
42
- return promises;
43
- }
44
- /**
45
- * Download annotations and process xml string after it
46
- */
47
- async downloadAnnotation(language, serviceRequestor) {
48
- const languageXmlContent = await serviceRequestor.downloadAnnotation(this.uri, this.name, language);
49
- if (!languageXmlContent) {
50
- throw new Error(`Xml is undefined for '${this.uri}', name '${this.name}' and language '${language.sap}'`);
51
- }
52
- return this.afterXmlDownload({ xml: languageXmlContent, language, serviceRequestor, uri: this.uri });
53
- }
54
- async afterXmlDownload({ xml, language, serviceRequestor, uri }) {
55
- let json = XmlUtil.xmlToJson(xml);
56
- for (const transformer of this.jsonTransformers) {
57
- json = await transformer.transform({ xml, json, language, serviceRequestor, uri });
58
- }
59
- return json;
60
- }
61
- }
62
- //# sourceMappingURL=dataSource.js.map
@@ -1,12 +0,0 @@
1
- import I18nManager from "../../i18nManager.js";
2
- import Language from "../../model/language.js";
3
- import ServiceRequestor from "../serviceRequestor.js";
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,45 +0,0 @@
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();
6
- /**
7
- * Parses dataSources from manifest.json.
8
- * @param dataSourcesJson manifest.json/sap.app/dataSources node
9
- */
10
- addDataSources(dataSourcesJson) {
11
- if (!dataSourcesJson) {
12
- return;
13
- }
14
- const odataAnnotationMap = new Map();
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);
22
- }
23
- }
24
- // If ODataAnnotation is in OData annotations, pass metadata url to it
25
- for (const [name, dataSource] of Object.entries(dataSourcesJson)) {
26
- const uri = dataSource.uri;
27
- const metadataUrl = odataAnnotationMap.get(name);
28
- if (uri?.startsWith("/") && dataSource.type === "ODataAnnotation") {
29
- this.dataSources.push(new DataSourceODataAnnotation(name, uri, dataSource, metadataUrl));
30
- }
31
- }
32
- for (const dataSource of this.dataSources) {
33
- dataSource.updateManifest(dataSourcesJson);
34
- }
35
- }
36
- async createAnnotationFiles(languages, i18nManager, serviceRequestor) {
37
- const annotationFiles = new Map();
38
- for (const dataSource of this.dataSources) {
39
- const { filename, xml } = await dataSource.createAnnotationFile(languages, i18nManager, serviceRequestor);
40
- annotationFiles.set(filename, xml);
41
- }
42
- return annotationFiles;
43
- }
44
- }
45
- //# sourceMappingURL=dataSourceManager.js.map
@@ -1,17 +0,0 @@
1
- import DataSource from "./dataSource.js";
2
- import Language from "../../model/language.js";
3
- import ServiceRequestor from "../serviceRequestor.js";
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,45 +0,0 @@
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;
9
- constructor(name, uri, dataSourceJson) {
10
- super(name, uri);
11
- this.dataSourceJson = dataSourceJson;
12
- this.jsonTransformers = [
13
- new TraverseReferences(),
14
- new ConvertV2ToV4(),
15
- new RemoveAllSchemaNodesExceptAnnotations(),
16
- new MakeAnnotationNamespaceUnique()
17
- ];
18
- }
19
- updateManifest(manifestDataSources) {
20
- this.getSettings().ignoreAnnotationsFromMetadata = true;
21
- this.addNewODataAnnotation(manifestDataSources);
22
- }
23
- addNewODataAnnotation(manifestDataSources) {
24
- const newAnnotationNameTemplate = `annotation_${this.name}`;
25
- let newAnnotationName = getUniqueName(Object.keys(manifestDataSources), newAnnotationNameTemplate);
26
- this.getAnnotations().unshift(newAnnotationName);
27
- manifestDataSources[newAnnotationName] = {
28
- type: "ODataAnnotation",
29
- uri: this.getFilename()
30
- };
31
- }
32
- getSettings() {
33
- if (this.dataSourceJson.settings == null) {
34
- this.dataSourceJson.settings = {};
35
- }
36
- return this.dataSourceJson.settings;
37
- }
38
- getAnnotations() {
39
- if (this.getSettings().annotations == null) {
40
- this.getSettings().annotations = [];
41
- }
42
- return this.getSettings().annotations;
43
- }
44
- }
45
- //# sourceMappingURL=dataSourceOData.js.map
@@ -1,6 +0,0 @@
1
- import DataSource from "./dataSource.js";
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,16 +0,0 @@
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
- super(name, uri);
7
- this.dataSourceJson = dataSourceJson;
8
- this.jsonTransformers = [
9
- new TraverseReferences(metadataUrl)
10
- ];
11
- }
12
- updateManifest() {
13
- this.dataSourceJson.uri = this.getFilename();
14
- }
15
- }
16
- //# sourceMappingURL=dataSourceODataAnnotation.js.map
@@ -1,9 +0,0 @@
1
- import AbapRepoManager from "../repositories/abapRepoManager.js";
2
- import { IConfiguration } from "../model/types.js";
3
- import Language from "../model/language.js";
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
- }