@sap-ux/preview-middleware 0.21.7 → 0.22.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.
|
@@ -10,10 +10,15 @@ sap.ui.define([
|
|
|
10
10
|
const getLibrary = ___utils['getLibrary'];
|
|
11
11
|
const MessageBarType = ___sap_ux_private_control_property_editor_common['MessageBarType'];
|
|
12
12
|
const sendInfoCenterMessage = ___utils_info_center_message['sendInfoCenterMessage'];
|
|
13
|
+
const FetchError = ___utils_error['FetchError'];
|
|
13
14
|
const getError = ___utils_error['getError'];
|
|
14
15
|
async function getUi5ApiDtMetadata(libName) {
|
|
15
16
|
const libUrl = '/test-resources/' + libName.split('.').join('/') + '/designtime/api.json';
|
|
16
|
-
|
|
17
|
+
const response = await fetch(libUrl);
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
throw new FetchError(response);
|
|
20
|
+
}
|
|
21
|
+
return response.json();
|
|
17
22
|
}
|
|
18
23
|
const ui5ApiDtMetadata = new Map();
|
|
19
24
|
function loadDefaultLibraries() {
|
|
@@ -111,8 +116,11 @@ sap.ui.define([
|
|
|
111
116
|
let doc;
|
|
112
117
|
try {
|
|
113
118
|
doc = await getControlPropertyDocumentation(controlName, contLibName);
|
|
114
|
-
} catch (
|
|
119
|
+
} catch (error) {
|
|
115
120
|
Log.error(`Error in getting documentation for ${ contLibName }`);
|
|
121
|
+
if (error instanceof FetchError && error.status === 404) {
|
|
122
|
+
return undefined;
|
|
123
|
+
}
|
|
116
124
|
await sendInfoCenterMessage({
|
|
117
125
|
title: { key: 'DOCUMENTATION_ERROR_TITLE' },
|
|
118
126
|
description: {
|
|
@@ -4,7 +4,7 @@ import type { Properties } from './utils';
|
|
|
4
4
|
import Log from 'sap/base/Log';
|
|
5
5
|
import { MessageBarType, PropertiesInfo } from '@sap-ux-private/control-property-editor-common';
|
|
6
6
|
import { sendInfoCenterMessage } from '../utils/info-center-message';
|
|
7
|
-
import { getError } from '../utils/error';
|
|
7
|
+
import { FetchError, getError } from '../utils/error';
|
|
8
8
|
|
|
9
9
|
export interface ControlMetadata {
|
|
10
10
|
baseType: string | undefined;
|
|
@@ -20,7 +20,11 @@ export interface ControlMetadata {
|
|
|
20
20
|
*/
|
|
21
21
|
export async function getUi5ApiDtMetadata(libName: string): Promise<SchemaForApiJsonFiles> {
|
|
22
22
|
const libUrl = '/test-resources/' + libName.split('.').join('/') + '/designtime/api.json';
|
|
23
|
-
|
|
23
|
+
const response = await fetch(libUrl);
|
|
24
|
+
if (!response.ok) {
|
|
25
|
+
throw new FetchError(response);
|
|
26
|
+
}
|
|
27
|
+
return response.json();
|
|
24
28
|
}
|
|
25
29
|
|
|
26
30
|
/**
|
|
@@ -170,8 +174,14 @@ export async function getDocumentation(controlName: string, contLibName: string)
|
|
|
170
174
|
let doc: Properties | undefined;
|
|
171
175
|
try {
|
|
172
176
|
doc = await getControlPropertyDocumentation(controlName, contLibName);
|
|
173
|
-
} catch (
|
|
177
|
+
} catch (error) {
|
|
174
178
|
Log.error(`Error in getting documentation for ${contLibName}`);
|
|
179
|
+
// For some UI5 components we do not have an api.json provided instead 404, not found,
|
|
180
|
+
// response is retuned from the server. For such components we do not want to
|
|
181
|
+
// flood the info center with errors.
|
|
182
|
+
if (error instanceof FetchError && error.status === 404) {
|
|
183
|
+
return undefined;
|
|
184
|
+
}
|
|
175
185
|
await sendInfoCenterMessage({
|
|
176
186
|
title: { key: 'DOCUMENTATION_ERROR_TITLE' },
|
|
177
187
|
description: { key: 'DOCUMENTATION_ERROR_DESCRIPTION', params: [contLibName] },
|
|
@@ -12,10 +12,17 @@ sap.ui.define([], function () {
|
|
|
12
12
|
function getError(error) {
|
|
13
13
|
return error instanceof Error ? error : new Error(JSON.stringify(error));
|
|
14
14
|
}
|
|
15
|
+
class FetchError extends Error {
|
|
16
|
+
constructor(response) {
|
|
17
|
+
super(`Fetch error: ${response.url}, ${response.status} - ${response.statusText}`);
|
|
18
|
+
this.status = response.status;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
15
21
|
var __exports = {
|
|
16
22
|
__esModule: true
|
|
17
23
|
};
|
|
18
24
|
__exports.getError = getError;
|
|
25
|
+
__exports.FetchError = FetchError;
|
|
19
26
|
return __exports;
|
|
20
27
|
});
|
|
21
28
|
//# sourceMappingURL=error.js.map
|
|
@@ -7,3 +7,12 @@
|
|
|
7
7
|
export function getError(error: unknown): Error {
|
|
8
8
|
return error instanceof Error ? error : new Error(JSON.stringify(error));
|
|
9
9
|
}
|
|
10
|
+
|
|
11
|
+
export class FetchError extends Error {
|
|
12
|
+
readonly status: number;
|
|
13
|
+
|
|
14
|
+
constructor(response: Response) {
|
|
15
|
+
super(`Fetch error: ${response.url}, ${response.status} - ${response.statusText}`);
|
|
16
|
+
this.status = response.status;
|
|
17
|
+
}
|
|
18
|
+
}
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Apreview-middleware"
|
|
11
11
|
},
|
|
12
|
-
"version": "0.
|
|
12
|
+
"version": "0.22.1",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"author": "@SAP/ux-tools-team",
|
|
15
15
|
"main": "dist/index.js",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"ejs": "3.1.10",
|
|
26
26
|
"mem-fs": "2.1.0",
|
|
27
27
|
"mem-fs-editor": "9.4.0",
|
|
28
|
-
"@sap-ux/adp-tooling": "0.15.
|
|
28
|
+
"@sap-ux/adp-tooling": "0.15.19",
|
|
29
29
|
"@sap-ux/btp-utils": "1.1.0",
|
|
30
30
|
"@sap-ux/control-property-editor-sources": "npm:@sap-ux/control-property-editor@0.7.0",
|
|
31
|
-
"@sap-ux/feature-toggle": "0.3.0",
|
|
32
31
|
"@sap-ux/logger": "0.7.0",
|
|
32
|
+
"@sap-ux/feature-toggle": "0.3.0",
|
|
33
33
|
"@sap-ux/project-access": "1.30.12",
|
|
34
34
|
"@sap-ux/system-access": "0.6.12",
|
|
35
35
|
"@sap-ux/i18n": "0.3.3"
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"nock": "13.4.0",
|
|
51
51
|
"npm-run-all2": "6.2.0",
|
|
52
52
|
"supertest": "7.1.4",
|
|
53
|
-
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.
|
|
53
|
+
"@private/preview-middleware-client": "npm:@sap-ux-private/preview-middleware-client@0.16.0",
|
|
54
54
|
"@sap-ux/axios-extension": "1.22.5",
|
|
55
55
|
"@sap-ux/store": "1.1.2",
|
|
56
56
|
"@sap-ux/ui5-info": "0.12.1"
|