@ui5/task-adaptation 1.2.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -1
- package/eslint.config.js +52 -0
- package/package.json +42 -52
- package/scripts/metadataDownloadHelper.ts +8 -7
- package/scripts/rollup/bundle.d.ts +25 -0
- package/scripts/rollup/bundleDefinition.js +11 -1
- package/scripts/{bundler.ts → rollup/bundler.ts} +6 -17
- package/scripts/rollup/overrides/sap/base/config.js +10 -0
- package/scripts/rollup/project/package.json +2 -1
- package/scripts/rollup/project/ui5.yaml +1 -1
- package/scripts/rollup/ui5Resolve.ts +14 -38
- package/scripts/rollup.ts +67 -23
- package/types/ui5.d.ts +44 -0
- package/dist/annotationManager.d.ts +0 -18
- package/dist/annotationManager.js +0 -80
- package/dist/annotations/comparator/comparator.d.ts +0 -47
- package/dist/annotations/comparator/comparator.js +0 -279
- package/dist/annotations/comparator/diffCase.d.ts +0 -4
- package/dist/annotations/comparator/diffCase.js +0 -3
- package/dist/annotations/comparator/interchangableCase.d.ts +0 -25
- package/dist/annotations/comparator/interchangableCase.js +0 -65
- package/dist/annotations/converter/metadataJsonReferenceUtil.d.ts +0 -12
- package/dist/annotations/converter/metadataJsonReferenceUtil.js +0 -50
- package/dist/annotations/converter/metadataJsonUtil.d.ts +0 -30
- package/dist/annotations/converter/metadataJsonUtil.js +0 -73
- package/dist/annotations/converter/ui5JsonConverter.d.ts +0 -21
- package/dist/annotations/converter/ui5JsonConverter.js +0 -253
- package/dist/annotations/converter/ui5MetadataJsonUtil.d.ts +0 -3
- package/dist/annotations/converter/ui5MetadataJsonUtil.js +0 -13
- package/dist/annotations/converter/ui5XmlConverter.d.ts +0 -5
- package/dist/annotations/converter/ui5XmlConverter.js +0 -17
- package/dist/annotations/dataSource/dataSource.d.ts +0 -34
- package/dist/annotations/dataSource/dataSource.js +0 -62
- package/dist/annotations/dataSource/dataSourceManager.d.ts +0 -12
- package/dist/annotations/dataSource/dataSourceManager.js +0 -50
- package/dist/annotations/dataSource/dataSourceOData.d.ts +0 -17
- package/dist/annotations/dataSource/dataSourceOData.js +0 -47
- package/dist/annotations/dataSource/dataSourceODataAnnotation.d.ts +0 -6
- package/dist/annotations/dataSource/dataSourceODataAnnotation.js +0 -18
- package/dist/annotations/serviceRequestor.d.ts +0 -9
- package/dist/annotations/serviceRequestor.js +0 -71
- package/dist/annotations/transformers/convertV2ToV4.d.ts +0 -4
- package/dist/annotations/transformers/convertV2ToV4.js +0 -16
- package/dist/annotations/transformers/makeAnnotationNamespaceUnique.d.ts +0 -6
- package/dist/annotations/transformers/makeAnnotationNamespaceUnique.js +0 -44
- package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.d.ts +0 -4
- package/dist/annotations/transformers/removeAllSchemaNodesExceptAnnotations.js +0 -17
- package/dist/annotations/transformers/transformer.d.ts +0 -12
- package/dist/annotations/transformers/transformer.js +0 -3
- package/dist/annotations/transformers/traverseReferences.d.ts +0 -9
- package/dist/annotations/transformers/traverseReferences.js +0 -67
- package/dist/appVariantManager.d.ts +0 -12
- package/dist/appVariantManager.js +0 -105
- package/dist/baseAppManager.d.ts +0 -29
- package/dist/baseAppManager.js +0 -141
- package/dist/buildStrategy.d.ts +0 -7
- package/dist/buildStrategy.js +0 -21
- package/dist/bundle-odata.js +0 -5498
- package/dist/bundle.js +0 -3475
- package/dist/cache/annotationsCacheManager.d.ts +0 -8
- package/dist/cache/annotationsCacheManager.js +0 -18
- package/dist/cache/baseAppFilesCacheManager.d.ts +0 -6
- package/dist/cache/baseAppFilesCacheManager.js +0 -15
- package/dist/cache/cacheManager.d.ts +0 -16
- package/dist/cache/cacheManager.js +0 -68
- package/dist/i18nManager.d.ts +0 -43
- package/dist/i18nManager.js +0 -203
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -27
- package/dist/model/annotationDiffStructureError.d.ts +0 -3
- package/dist/model/annotationDiffStructureError.js +0 -11
- package/dist/model/language.d.ts +0 -13
- package/dist/model/language.js +0 -37
- package/dist/model/noAuthorizationProvidedError.d.ts +0 -3
- package/dist/model/noAuthorizationProvidedError.js +0 -9
- package/dist/model/serverError.d.ts +0 -3
- package/dist/model/serverError.js +0 -9
- package/dist/model/types.d.ts +0 -119
- package/dist/model/types.js +0 -3
- package/dist/processors/abapProcessor.d.ts +0 -21
- package/dist/processors/abapProcessor.js +0 -36
- package/dist/processors/cfProcessor.d.ts +0 -17
- package/dist/processors/cfProcessor.js +0 -46
- package/dist/processors/processor.d.ts +0 -7
- package/dist/processors/processor.js +0 -36
- package/dist/repositories/abapRepoManager.d.ts +0 -13
- package/dist/repositories/abapRepoManager.js +0 -82
- package/dist/repositories/html5RepoManager.d.ts +0 -11
- package/dist/repositories/html5RepoManager.js +0 -89
- package/dist/util/cfUtil.d.ts +0 -30
- package/dist/util/cfUtil.js +0 -173
- package/dist/util/commonUtil.d.ts +0 -13
- package/dist/util/commonUtil.js +0 -129
- package/dist/util/i18nMerger.d.ts +0 -28
- package/dist/util/i18nMerger.js +0 -103
- package/dist/util/requestUtil.d.ts +0 -8
- package/dist/util/requestUtil.js +0 -57
- package/dist/util/resourceUtil.d.ts +0 -11
- package/dist/util/resourceUtil.js +0 -65
- package/dist/util/urlUtil.d.ts +0 -4
- package/dist/util/urlUtil.js +0 -21
- package/dist/util/xmlUtil.d.ts +0 -4
- package/dist/util/xmlUtil.js +0 -24
- package/dist/util/zipUtil.d.ts +0 -2
- package/dist/util/zipUtil.js +0 -20
- package/scripts/rollup/bundleDefinition-odata.js +0 -9
package/dist/util/commonUtil.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getUniqueName = exports.logBetaUsage = exports.logBuilderVersion = exports.traverse = exports.removePropertiesExtension = exports.writeTempAnnotations = exports.insertInArray = exports.renameResources = exports.escapeRegex = exports.validateObject = exports.dotToUnderscore = void 0;
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const log = require("@ui5/logger").getLogger("rollup-plugin-ui5-resolve-task-adaptation");
|
|
7
|
-
function dotToUnderscore(value) {
|
|
8
|
-
return value.replace(/\./g, "_");
|
|
9
|
-
}
|
|
10
|
-
exports.dotToUnderscore = dotToUnderscore;
|
|
11
|
-
function validateObject(options, properties, message) {
|
|
12
|
-
for (const property of properties) {
|
|
13
|
-
if (!options[property]) {
|
|
14
|
-
throw new Error(`'${String(property)}' ${message}`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.validateObject = validateObject;
|
|
19
|
-
function escapeRegex(update) {
|
|
20
|
-
return update.replaceAll(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
|
21
|
-
}
|
|
22
|
-
exports.escapeRegex = escapeRegex;
|
|
23
|
-
function renameResources(files, search, replacement) {
|
|
24
|
-
// The current regex works if the old Id is contained in the new Id, given
|
|
25
|
-
// that they do not have the same beginning.
|
|
26
|
-
// more complete alternative: /((?<!newIdStart)|(?!newIdEnd))oldId/g
|
|
27
|
-
let escapedSearch;
|
|
28
|
-
if (replacement.includes(search)) {
|
|
29
|
-
const [before, _] = replacement.split(search);
|
|
30
|
-
// Matches a position in the string that is not immediately preceded by
|
|
31
|
-
// the string "before". Since we won't replace anyway, we should also
|
|
32
|
-
// ignore one with the slashes.
|
|
33
|
-
const escapedBefore = escapeRegex(before).replaceAll("\\.", "[\\./]");
|
|
34
|
-
escapedSearch = `(?<!${escapedBefore})${escapeRegex(search)}`;
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
escapedSearch = escapeRegex(search);
|
|
38
|
-
}
|
|
39
|
-
const dotToSlash = (update) => update.replaceAll(".", "\/");
|
|
40
|
-
const replaces = [
|
|
41
|
-
{
|
|
42
|
-
regexp: new RegExp(escapedSearch, "g"),
|
|
43
|
-
replacement
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
regexp: new RegExp(dotToSlash(escapedSearch), "g"),
|
|
47
|
-
replacement: dotToSlash(replacement)
|
|
48
|
-
}
|
|
49
|
-
];
|
|
50
|
-
files.forEach((content, filepath, map) => {
|
|
51
|
-
map.set(filepath, replaces.reduce((p, c) => p.replace(c.regexp, c.replacement), content));
|
|
52
|
-
});
|
|
53
|
-
return files;
|
|
54
|
-
}
|
|
55
|
-
exports.renameResources = renameResources;
|
|
56
|
-
function insertInArray(array, index, insert) {
|
|
57
|
-
array.splice(index, 0, insert);
|
|
58
|
-
}
|
|
59
|
-
exports.insertInArray = insertInArray;
|
|
60
|
-
function writeTempAnnotations({ writeTempFiles }, name, language, content) {
|
|
61
|
-
const TEMP_DIST_FOLDER = path_1.posix.join(process.cwd(), "dist-debug", name);
|
|
62
|
-
if (writeTempFiles) {
|
|
63
|
-
if (!fs.existsSync(TEMP_DIST_FOLDER)) {
|
|
64
|
-
fs.mkdirSync(TEMP_DIST_FOLDER, { recursive: true });
|
|
65
|
-
}
|
|
66
|
-
if (language) {
|
|
67
|
-
name += "-" + language.i18n;
|
|
68
|
-
}
|
|
69
|
-
fs.writeFileSync(path_1.posix.join(TEMP_DIST_FOLDER, name + ".xml"), content);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
exports.writeTempAnnotations = writeTempAnnotations;
|
|
73
|
-
function removePropertiesExtension(filePath) {
|
|
74
|
-
const lastIndexOf = filePath.lastIndexOf(".properties");
|
|
75
|
-
return filePath.substring(0, lastIndexOf);
|
|
76
|
-
}
|
|
77
|
-
exports.removePropertiesExtension = removePropertiesExtension;
|
|
78
|
-
function traverse(json, paths, callback) {
|
|
79
|
-
for (const key of Object.keys(json)) {
|
|
80
|
-
const internPaths = [...paths];
|
|
81
|
-
internPaths.push(key);
|
|
82
|
-
if (typeof json[key] === "object") {
|
|
83
|
-
if (Array.isArray(json[key])) {
|
|
84
|
-
const array = json[key];
|
|
85
|
-
for (let i = 0; i < array.length; i++) {
|
|
86
|
-
if (typeof array[i] === "object") {
|
|
87
|
-
traverse(array[i], internPaths, callback);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
callback(array, i, internPaths);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
traverse(json[key], internPaths, callback);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
else {
|
|
99
|
-
callback(json, key, internPaths);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
exports.traverse = traverse;
|
|
104
|
-
async function logBuilderVersion() {
|
|
105
|
-
try {
|
|
106
|
-
// @ts-ignore
|
|
107
|
-
const packageJSON = await Promise.resolve().then(() => require("../../package.json"));
|
|
108
|
-
log.info(`Running app-variant-bundler-build with version ${packageJSON.version}`);
|
|
109
|
-
}
|
|
110
|
-
catch (e) {
|
|
111
|
-
// do nothing
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
exports.logBuilderVersion = logBuilderVersion;
|
|
115
|
-
async function logBetaUsage() {
|
|
116
|
-
log.info("Beta features enabled");
|
|
117
|
-
}
|
|
118
|
-
exports.logBetaUsage = logBetaUsage;
|
|
119
|
-
function getUniqueName(existingNames, template) {
|
|
120
|
-
let suffix = -1;
|
|
121
|
-
let suffixString;
|
|
122
|
-
do {
|
|
123
|
-
suffixString = suffix === -1 ? "" : suffix;
|
|
124
|
-
suffix++;
|
|
125
|
-
} while (existingNames.includes(template + suffixString));
|
|
126
|
-
return template + suffixString;
|
|
127
|
-
}
|
|
128
|
-
exports.getUniqueName = getUniqueName;
|
|
129
|
-
//# sourceMappingURL=commonUtil.js.map
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { IAppVariantInfo } from "../model/types";
|
|
2
|
-
export default class I18NMerger {
|
|
3
|
-
static analyzeAppVariantManifestChanges(rootFolder: string, tranlsationRegexPattern: string, { changes }: IAppVariantInfo): {
|
|
4
|
-
mergePathsRegex: RegExp[];
|
|
5
|
-
copyPathsRegex: RegExp[];
|
|
6
|
-
};
|
|
7
|
-
static mergeI18NFiles(baseAppResources: any[], appVariantResources: any[], projectNamespace: string, baseAppManifestI18NPath: string, appVariantInfo: IAppVariantInfo, taskUtil: any): Promise<any[]>;
|
|
8
|
-
/**
|
|
9
|
-
* Merge/Append base property file with property file from app variant
|
|
10
|
-
* FIXME Currently merge could duplicate keys which causes undefined
|
|
11
|
-
* behavior => Existing keys which are in merge content must be removed =>
|
|
12
|
-
* Actually only descriptor texts are relevant for merge which always have
|
|
13
|
-
* app variant Id as prefix => If we filter on them we do not need to remove
|
|
14
|
-
* existing overwritten keys (as there should be none)
|
|
15
|
-
*/
|
|
16
|
-
private static mergePropertiesFiles;
|
|
17
|
-
/**
|
|
18
|
-
* update the path of app variant property file so it will be copied into
|
|
19
|
-
<app_variant_id> folder
|
|
20
|
-
*/
|
|
21
|
-
private static moveToAppVarSubfolder;
|
|
22
|
-
/**
|
|
23
|
-
* create new i18n file in case e.g. translation file does not exist in base
|
|
24
|
-
* app but in variant and copy of translation file is needed
|
|
25
|
-
*/
|
|
26
|
-
private static createFile;
|
|
27
|
-
private static mergeFiles;
|
|
28
|
-
}
|
package/dist/util/i18nMerger.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const commonUtil_1 = require("./commonUtil");
|
|
4
|
-
const resourceUtil_1 = require("./resourceUtil");
|
|
5
|
-
const path_1 = require("path");
|
|
6
|
-
const Resource = require("@ui5/fs/lib/Resource");
|
|
7
|
-
class I18NMerger {
|
|
8
|
-
static analyzeAppVariantManifestChanges(rootFolder, tranlsationRegexPattern, { changes }) {
|
|
9
|
-
// check which files need to be copied and which files need to be merged and copied
|
|
10
|
-
// this is necessary because lrep does not support multiple enhanceWith with multiple locations
|
|
11
|
-
const mergePaths = new Set();
|
|
12
|
-
const copyPaths = new Set();
|
|
13
|
-
changes.forEach((change) => {
|
|
14
|
-
const i18nPathWithExtension = change.content?.bundleUrl || change.texts?.i18n;
|
|
15
|
-
if (i18nPathWithExtension) {
|
|
16
|
-
// build regex to match specific + language related files
|
|
17
|
-
const i18nPath = (0, commonUtil_1.removePropertiesExtension)(i18nPathWithExtension);
|
|
18
|
-
const resourcePath = path_1.posix.join(rootFolder, i18nPath);
|
|
19
|
-
const regex = new RegExp((0, commonUtil_1.escapeRegex)(resourcePath) + tranlsationRegexPattern);
|
|
20
|
-
if (change.changeType.includes("addNewModelEnhanceWith")) {
|
|
21
|
-
copyPaths.add(regex);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
mergePaths.add(regex);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
return { mergePathsRegex: [...mergePaths.values()], copyPathsRegex: [...copyPaths.values()] };
|
|
29
|
-
}
|
|
30
|
-
static async mergeI18NFiles(baseAppResources, appVariantResources, projectNamespace, baseAppManifestI18NPath, appVariantInfo, taskUtil) {
|
|
31
|
-
const aggregatedResourceFilesMap = new Map(baseAppResources.map(baseAppResource => [baseAppResource.getPath(), baseAppResource]));
|
|
32
|
-
const i18nTargetFolder = (0, commonUtil_1.dotToUnderscore)(appVariantInfo.id);
|
|
33
|
-
const rootFolder = resourceUtil_1.default.getRootFolder(projectNamespace);
|
|
34
|
-
const tranlsationRegexPattern = "((_[a-z]{2,3})?(_[a-zA-Z]{2,3}(_[a-zA-Z]{2,20})?)?)\.properties$";
|
|
35
|
-
const { copyPathsRegex: copyPathsValues, mergePathsRegex: mergePathsValues } = this.analyzeAppVariantManifestChanges(rootFolder, tranlsationRegexPattern, appVariantInfo);
|
|
36
|
-
for (const appVariantResource of appVariantResources) {
|
|
37
|
-
const appVariantResourcePath = appVariantResource.getPath();
|
|
38
|
-
if (appVariantResourcePath.endsWith(".properties")) {
|
|
39
|
-
// merge/copy logic
|
|
40
|
-
// check if file matches with regex in merge/copy
|
|
41
|
-
const mergePathMatch = mergePathsValues.map(path => appVariantResourcePath.match(path)).find(match => match);
|
|
42
|
-
const shouldMergeFile = !!mergePathMatch;
|
|
43
|
-
const shouldCopyFile = copyPathsValues.map(path => appVariantResourcePath.match(path)).find(match => match);
|
|
44
|
-
if (shouldMergeFile) {
|
|
45
|
-
let baseAppI18NPath = `${rootFolder}/${baseAppManifestI18NPath}${mergePathMatch[1] || ""}.properties`;
|
|
46
|
-
await this.mergePropertiesFiles(aggregatedResourceFilesMap, appVariantResource, baseAppI18NPath);
|
|
47
|
-
}
|
|
48
|
-
// Resource for to be copied file already exists so we only have to adjust path
|
|
49
|
-
// Otherwise we have to omit it. We always change the path to avoid omitting a base app file
|
|
50
|
-
this.moveToAppVarSubfolder(appVariantResource, rootFolder, i18nTargetFolder);
|
|
51
|
-
if (!shouldCopyFile) {
|
|
52
|
-
taskUtil.setTag(appVariantResource, taskUtil.STANDARD_TAGS.OmitFromBuildResult, true);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
aggregatedResourceFilesMap.set(appVariantResource.getPath(), appVariantResource);
|
|
56
|
-
}
|
|
57
|
-
return Array.from(aggregatedResourceFilesMap.values());
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Merge/Append base property file with property file from app variant
|
|
61
|
-
* FIXME Currently merge could duplicate keys which causes undefined
|
|
62
|
-
* behavior => Existing keys which are in merge content must be removed =>
|
|
63
|
-
* Actually only descriptor texts are relevant for merge which always have
|
|
64
|
-
* app variant Id as prefix => If we filter on them we do not need to remove
|
|
65
|
-
* existing overwritten keys (as there should be none)
|
|
66
|
-
*/
|
|
67
|
-
static async mergePropertiesFiles(aggregatedResourceFilesMap, variantResource, baseAppI18NPath) {
|
|
68
|
-
const baseAppI18NFile = aggregatedResourceFilesMap.get(baseAppI18NPath);
|
|
69
|
-
if (baseAppI18NFile) {
|
|
70
|
-
await this.mergeFiles(baseAppI18NFile, variantResource);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
// create the merge target file if it missing in base app. Maybe the language does not exist in the base app.
|
|
74
|
-
// Since the file might also be copied we do not just change the path of it but create another resource
|
|
75
|
-
await this.createFile(aggregatedResourceFilesMap, baseAppI18NPath, variantResource);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* update the path of app variant property file so it will be copied into
|
|
80
|
-
<app_variant_id> folder
|
|
81
|
-
*/
|
|
82
|
-
static moveToAppVarSubfolder(variantResource, rootFolder, i18nBundleName) {
|
|
83
|
-
const relativeFilePath = variantResource.getPath().substring(rootFolder.length);
|
|
84
|
-
const newResourcePath = path_1.posix.join(rootFolder, i18nBundleName, relativeFilePath);
|
|
85
|
-
variantResource.setPath(newResourcePath);
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* create new i18n file in case e.g. translation file does not exist in base
|
|
89
|
-
* app but in variant and copy of translation file is needed
|
|
90
|
-
*/
|
|
91
|
-
static async createFile(aggregatedResourceFilesMap, path, resource) {
|
|
92
|
-
const createdFile = await resource.clone();
|
|
93
|
-
createdFile.setPath(path);
|
|
94
|
-
aggregatedResourceFilesMap.set(path, createdFile);
|
|
95
|
-
}
|
|
96
|
-
static async mergeFiles(baseFile, variantFile) {
|
|
97
|
-
const variantFileContent = await variantFile.getString();
|
|
98
|
-
const mergedFileContent = await baseFile.getString();
|
|
99
|
-
baseFile.setString(`${mergedFileContent}\n\n#App variant specific text file\n\n${variantFileContent}`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
exports.default = I18NMerger;
|
|
103
|
-
//# sourceMappingURL=i18nMerger.js.map
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { IAuth } from "../model/types";
|
|
2
|
-
export default class RequestUtil {
|
|
3
|
-
static head(url: string, auth?: IAuth): Promise<any>;
|
|
4
|
-
static get(url: string, options?: any, auth?: IAuth): Promise<any>;
|
|
5
|
-
static request(url: string, method: Function, auth?: IAuth, options?: any): Promise<any>;
|
|
6
|
-
private static handleError;
|
|
7
|
-
static retryWithAuth<T>(requestWithoutAuth: Function, requestWithAuth: Function): Promise<T>;
|
|
8
|
-
}
|
package/dist/util/requestUtil.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const axios_1 = require("axios");
|
|
4
|
-
const noAuthorizationProvidedError_1 = require("../model/noAuthorizationProvidedError");
|
|
5
|
-
const serverError_1 = require("../model/serverError");
|
|
6
|
-
class RequestUtil {
|
|
7
|
-
static async head(url, auth) {
|
|
8
|
-
return this.request(url, axios_1.default.head, auth);
|
|
9
|
-
}
|
|
10
|
-
static async get(url, options, auth) {
|
|
11
|
-
return this.request(url, axios_1.default.get, auth, options);
|
|
12
|
-
}
|
|
13
|
-
static async request(url, method, auth, options) {
|
|
14
|
-
try {
|
|
15
|
-
return await method(url, { auth, ...options })
|
|
16
|
-
.then((response) => response.data);
|
|
17
|
-
}
|
|
18
|
-
catch (error) {
|
|
19
|
-
this.handleError(error, url);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
static handleError(error, uri) {
|
|
23
|
-
if (error.response) {
|
|
24
|
-
// HTTP Status Code > 2xx
|
|
25
|
-
if (error.response.status === 401) {
|
|
26
|
-
throw new noAuthorizationProvidedError_1.default(uri);
|
|
27
|
-
}
|
|
28
|
-
else if (error.response.status >= 500) {
|
|
29
|
-
throw new serverError_1.default(uri, error);
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
throw new Error(`Unexpected response received from '${uri}': ${error.response.status} ${error.response.data ?? ""}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
else if (error.request) {
|
|
36
|
-
throw new Error(`No response was received from '${uri}': ${error.code}`);
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
throw new Error(`Error sending request to '${uri}': ${error.code}`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
static async retryWithAuth(requestWithoutAuth, requestWithAuth) {
|
|
43
|
-
try {
|
|
44
|
-
return await requestWithoutAuth();
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
if (error instanceof noAuthorizationProvidedError_1.default) {
|
|
48
|
-
return await requestWithAuth();
|
|
49
|
-
}
|
|
50
|
-
else {
|
|
51
|
-
throw error;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
exports.default = RequestUtil;
|
|
57
|
-
//# sourceMappingURL=requestUtil.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export default class ResourceUtil {
|
|
2
|
-
static getRootFolder(projectNamespace?: string): string;
|
|
3
|
-
static relativeToRoot(resourcePath: string, projectNamespace?: string): string;
|
|
4
|
-
static getResourcePath(projectNamespace?: string, ...paths: string[]): string;
|
|
5
|
-
static write(dir: string, files: Map<string, string>): Promise<void[]>;
|
|
6
|
-
static read(rootFolder: string, folder: string, files: Map<string, string>, exclude?: string[]): void;
|
|
7
|
-
static getString(resource: any): Promise<string>;
|
|
8
|
-
static getJson(resource: any): Promise<any>;
|
|
9
|
-
static setString(resource: any, str: string): void;
|
|
10
|
-
static createResource(filename: string, projectNamespace: string, content: string): any;
|
|
11
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const fs = require("fs");
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const resourceFactory = require("@ui5/fs/lib/resourceFactory");
|
|
6
|
-
const UTF8 = "utf8";
|
|
7
|
-
class ResourceUtil {
|
|
8
|
-
static getRootFolder(projectNamespace) {
|
|
9
|
-
const newPath = ["/resources"];
|
|
10
|
-
if (projectNamespace) {
|
|
11
|
-
newPath.push(projectNamespace);
|
|
12
|
-
}
|
|
13
|
-
return path_1.posix.join(...newPath);
|
|
14
|
-
}
|
|
15
|
-
static relativeToRoot(resourcePath, projectNamespace) {
|
|
16
|
-
const rootFolder = ResourceUtil.getRootFolder(projectNamespace);
|
|
17
|
-
return path_1.posix.relative(rootFolder, resourcePath);
|
|
18
|
-
}
|
|
19
|
-
static getResourcePath(projectNamespace, ...paths) {
|
|
20
|
-
return path_1.posix.join(this.getRootFolder(projectNamespace), ...paths);
|
|
21
|
-
}
|
|
22
|
-
static write(dir, files) {
|
|
23
|
-
const fsTarget = resourceFactory.createAdapter({
|
|
24
|
-
fsBasePath: dir,
|
|
25
|
-
virBasePath: "/"
|
|
26
|
-
});
|
|
27
|
-
const promises = [];
|
|
28
|
-
files.forEach((string, filename) => {
|
|
29
|
-
const resource = resourceFactory.createResource({ path: "/" + filename, string });
|
|
30
|
-
promises.push(fsTarget.write(resource));
|
|
31
|
-
});
|
|
32
|
-
return Promise.all(promises);
|
|
33
|
-
}
|
|
34
|
-
static read(rootFolder, folder, files, exclude = []) {
|
|
35
|
-
const entries = fs.readdirSync(folder);
|
|
36
|
-
for (let entry of entries) {
|
|
37
|
-
const entryPath = path_1.posix.join(folder, entry);
|
|
38
|
-
const stats = fs.lstatSync(entryPath);
|
|
39
|
-
if (stats.isFile() && !exclude.some(filepath => entryPath.endsWith(filepath))) {
|
|
40
|
-
const normalized = entryPath.substring(rootFolder.length + 1);
|
|
41
|
-
files.set(normalized, fs.readFileSync(entryPath, { encoding: "utf-8" }));
|
|
42
|
-
}
|
|
43
|
-
else if (stats.isDirectory()) {
|
|
44
|
-
this.read(rootFolder, entryPath, files, exclude);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
static getString(resource) {
|
|
49
|
-
return resource.getBuffer().then((buffer) => buffer.toString(UTF8));
|
|
50
|
-
}
|
|
51
|
-
static getJson(resource) {
|
|
52
|
-
return resource.getBuffer().then((buffer) => JSON.parse(buffer.toString(UTF8)));
|
|
53
|
-
}
|
|
54
|
-
static setString(resource, str) {
|
|
55
|
-
resource.setBuffer(Buffer.from(str, UTF8));
|
|
56
|
-
}
|
|
57
|
-
static createResource(filename, projectNamespace, content) {
|
|
58
|
-
return resourceFactory.createResource({
|
|
59
|
-
path: this.getResourcePath(projectNamespace, filename),
|
|
60
|
-
string: content
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
exports.default = ResourceUtil;
|
|
65
|
-
//# sourceMappingURL=resourceUtil.js.map
|
package/dist/util/urlUtil.d.ts
DELETED
package/dist/util/urlUtil.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const { URI } = require("../../dist/bundle-odata");
|
|
4
|
-
class UrlUtil {
|
|
5
|
-
static join(relativeUrl, parentUrl) {
|
|
6
|
-
// Remove trailing slash, otherwise url join can be incorrect Remove
|
|
7
|
-
// trailing slash, otherwise url join can be incorrect Annotation URLs
|
|
8
|
-
// defined in manifest might end with .../$value/ or .../$value and both
|
|
9
|
-
// are accepted by Gateway and produce the same content with same
|
|
10
|
-
// relative URLs. The first case is actually incorrect and we have to
|
|
11
|
-
// sanitize the same way as UI5. We also trim urls domain/host, because
|
|
12
|
-
// we need to substitute it with destination to download later.
|
|
13
|
-
return new URI(relativeUrl).absoluteTo(parentUrl.replace(/\/$/, "")).toString();
|
|
14
|
-
}
|
|
15
|
-
static getResourcePath(url) {
|
|
16
|
-
// Trim urls domain/host.
|
|
17
|
-
return url && URI.parse(url).path;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
exports.default = UrlUtil;
|
|
21
|
-
//# sourceMappingURL=urlUtil.js.map
|
package/dist/util/xmlUtil.d.ts
DELETED
package/dist/util/xmlUtil.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const convert = require("xml-js");
|
|
4
|
-
const XML_OPTIONS = { compact: true, spaces: 4 };
|
|
5
|
-
class XmlUtil {
|
|
6
|
-
static jsonToXml(json) {
|
|
7
|
-
return convert.json2xml(json, {
|
|
8
|
-
...XML_OPTIONS, attributeValueFn: (val) => val
|
|
9
|
-
.replaceAll(""", "\"")
|
|
10
|
-
.replaceAll("&", "&")
|
|
11
|
-
.replaceAll("<", "<")
|
|
12
|
-
.replaceAll("\"", """)
|
|
13
|
-
.replaceAll("'", "'")
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
static xmlToJson(xml) {
|
|
17
|
-
return JSON.parse(convert.xml2json(xml, {
|
|
18
|
-
...XML_OPTIONS, attributeValueFn: (val) => val
|
|
19
|
-
.replaceAll(""", "\"")
|
|
20
|
-
}));
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.default = XmlUtil;
|
|
24
|
-
//# sourceMappingURL=xmlUtil.js.map
|
package/dist/util/zipUtil.d.ts
DELETED
package/dist/util/zipUtil.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.unzipZipEntries = void 0;
|
|
4
|
-
const AdmZip = require("adm-zip");
|
|
5
|
-
async function unzipZipEntries(zip) {
|
|
6
|
-
let admZip;
|
|
7
|
-
try {
|
|
8
|
-
admZip = new AdmZip(zip);
|
|
9
|
-
const entries = admZip.getEntries();
|
|
10
|
-
return mapEntries(entries);
|
|
11
|
-
}
|
|
12
|
-
catch (error) {
|
|
13
|
-
throw new Error("Failed to parse zip content from HTML5 Repository: " + error.message);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
exports.unzipZipEntries = unzipZipEntries;
|
|
17
|
-
function mapEntries(entries) {
|
|
18
|
-
return new Map(entries.filter(entry => !entry.isDirectory).map(entry => [entry.entryName, entry.getData().toString("utf8")]));
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=zipUtil.js.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import URI from "sap/ui/thirdparty/URI";
|
|
2
|
-
import V2MetadataConverter from "sap/ui/model/odata/v4/lib/_V2MetadataConverter";
|
|
3
|
-
import V4MetadataConverter from "sap/ui/model/odata/v4/lib/_V4MetadataConverter";
|
|
4
|
-
|
|
5
|
-
export {
|
|
6
|
-
URI,
|
|
7
|
-
V4MetadataConverter,
|
|
8
|
-
V2MetadataConverter
|
|
9
|
-
};
|