@sap-ux/odata-service-inquirer 0.2.3 → 0.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/dist/error-handler/error-handler.d.ts +7 -0
- package/dist/error-handler/error-handler.js +24 -11
- package/dist/i18n.js +6 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +1 -1
- package/dist/prompts/datasources/cap-project/questions.js +1 -1
- package/dist/prompts/datasources/service-url/connectionValidator.d.ts +99 -0
- package/dist/prompts/datasources/service-url/connectionValidator.js +271 -0
- package/dist/prompts/datasources/service-url/questions.d.ts +12 -0
- package/dist/prompts/datasources/service-url/questions.js +216 -0
- package/dist/prompts/datasources/service-url/types.d.ts +9 -0
- package/dist/prompts/datasources/service-url/types.js +13 -0
- package/dist/prompts/datasources/service-url/validators.d.ts +19 -0
- package/dist/prompts/datasources/service-url/validators.js +95 -0
- package/dist/prompts/logger-helper.d.ts +12 -0
- package/dist/prompts/logger-helper.js +59 -0
- package/dist/prompts/prompts.js +2 -0
- package/dist/prompts/validators.d.ts +1 -1
- package/dist/prompts/validators.js +6 -10
- package/dist/translations/odata-service-inquirer.i18n.json +23 -2
- package/dist/types.d.ts +42 -5
- package/dist/types.js +10 -1
- package/dist/utils/index.d.ts +18 -1
- package/dist/utils/index.js +54 -4
- package/dist/utils/prompt-state.js +4 -1
- package/package.json +9 -6
package/dist/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hostEnvironment = exports.ValidationLink = exports.promptNames = exports.DatasourceType = void 0;
|
|
3
|
+
exports.SAP_CLIENT_KEY = exports.hostEnvironment = exports.ValidationLink = exports.promptNames = exports.DatasourceType = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* This file contains types that are exported by the module and are needed for consumers using the APIs `prompt` and `getPrompts`.
|
|
6
6
|
*/
|
|
@@ -35,6 +35,14 @@ var promptNames;
|
|
|
35
35
|
* Cap service
|
|
36
36
|
*/
|
|
37
37
|
promptNames["capService"] = "capService";
|
|
38
|
+
/**
|
|
39
|
+
* Odata service URL
|
|
40
|
+
*/
|
|
41
|
+
promptNames["serviceUrl"] = "serviceUrl";
|
|
42
|
+
/**
|
|
43
|
+
* password
|
|
44
|
+
*/
|
|
45
|
+
promptNames["serviceUrlPassword"] = "serviceUrlPassword";
|
|
38
46
|
})(promptNames || (exports.promptNames = promptNames = {}));
|
|
39
47
|
/**
|
|
40
48
|
* Implementation of IValidationLink interface.
|
|
@@ -73,4 +81,5 @@ exports.hostEnvironment = {
|
|
|
73
81
|
technical: 'CLI'
|
|
74
82
|
}
|
|
75
83
|
};
|
|
84
|
+
exports.SAP_CLIENT_KEY = 'sap-client';
|
|
76
85
|
//# sourceMappingURL=types.js.map
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { TelemetryProperties, ToolsSuiteTelemetryClient } from '@sap-ux/telemetry';
|
|
2
2
|
import { PromptState } from './prompt-state';
|
|
3
|
+
import { OdataVersion } from '@sap-ux/odata-service-writer';
|
|
3
4
|
/**
|
|
4
5
|
* Determine if the current prompting environment is cli or a hosted extension (app studio or vscode).
|
|
5
6
|
*
|
|
6
7
|
* @returns the platform name and technical name
|
|
7
8
|
*/
|
|
8
|
-
export declare function
|
|
9
|
+
export declare function getHostEnvironment(): {
|
|
9
10
|
name: string;
|
|
10
11
|
technical: string;
|
|
11
12
|
};
|
|
@@ -22,5 +23,21 @@ export declare function setTelemetryClient(toolsSuiteTelemetryClient: ToolsSuite
|
|
|
22
23
|
* @param telemetryData the telemetry values to report
|
|
23
24
|
*/
|
|
24
25
|
export declare function sendTelemetryEvent(eventName: string, telemetryData: TelemetryProperties): void;
|
|
26
|
+
/**
|
|
27
|
+
* Validate xml and parse the odata version from the metadata xml.
|
|
28
|
+
*
|
|
29
|
+
* @param metadata a metadata string
|
|
30
|
+
* @returns the odata version of the specified metadata, throws an error if the metadata is invalid
|
|
31
|
+
*/
|
|
32
|
+
export declare function parseOdataVersion(metadata: string): OdataVersion;
|
|
33
|
+
/**
|
|
34
|
+
* Replaces the origin in the metadata URIs with a relative path.
|
|
35
|
+
* The path will be tested for '/sap/opu/odata/' and if found, the origin will be replaced with './'.
|
|
36
|
+
* This is to ensure that the SAP internal backend URIs are relative and that other non-SAP URIs are not affected.
|
|
37
|
+
*
|
|
38
|
+
* @param metadata a metadata string containing URIs which include origin (protocol, host, port)
|
|
39
|
+
* @returns the metadata string with URIs replaced with relative paths
|
|
40
|
+
*/
|
|
41
|
+
export declare function originToRelative(metadata: string): string;
|
|
25
42
|
export { PromptState };
|
|
26
43
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/utils/index.js
CHANGED
|
@@ -3,20 +3,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PromptState = exports.sendTelemetryEvent = exports.setTelemetryClient = exports.
|
|
6
|
+
exports.PromptState = exports.originToRelative = exports.parseOdataVersion = exports.sendTelemetryEvent = exports.setTelemetryClient = exports.getHostEnvironment = void 0;
|
|
7
7
|
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
8
8
|
const telemetry_1 = require("@sap-ux/telemetry");
|
|
9
9
|
const os_name_1 = __importDefault(require("os-name"));
|
|
10
10
|
const types_1 = require("../types");
|
|
11
11
|
const prompt_state_1 = require("./prompt-state");
|
|
12
12
|
Object.defineProperty(exports, "PromptState", { enumerable: true, get: function () { return prompt_state_1.PromptState; } });
|
|
13
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
14
|
+
const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
|
|
15
|
+
const logger_helper_1 = __importDefault(require("../prompts/logger-helper"));
|
|
16
|
+
const i18n_1 = require("../i18n");
|
|
13
17
|
const osVersionName = (0, os_name_1.default)();
|
|
14
18
|
/**
|
|
15
19
|
* Determine if the current prompting environment is cli or a hosted extension (app studio or vscode).
|
|
16
20
|
*
|
|
17
21
|
* @returns the platform name and technical name
|
|
18
22
|
*/
|
|
19
|
-
function
|
|
23
|
+
function getHostEnvironment() {
|
|
20
24
|
if (!prompt_state_1.PromptState.isYUI) {
|
|
21
25
|
return types_1.hostEnvironment.cli;
|
|
22
26
|
}
|
|
@@ -24,7 +28,7 @@ function getPlatform() {
|
|
|
24
28
|
return (0, btp_utils_1.isAppStudio)() ? types_1.hostEnvironment.bas : types_1.hostEnvironment.vscode;
|
|
25
29
|
}
|
|
26
30
|
}
|
|
27
|
-
exports.
|
|
31
|
+
exports.getHostEnvironment = getHostEnvironment;
|
|
28
32
|
let telemetryClient;
|
|
29
33
|
/**
|
|
30
34
|
* Set the telemetry client.
|
|
@@ -58,7 +62,7 @@ exports.sendTelemetryEvent = sendTelemetryEvent;
|
|
|
58
62
|
*/
|
|
59
63
|
function createTelemetryEvent(eventName, telemetryData) {
|
|
60
64
|
const telemProps = Object.assign(telemetryData, {
|
|
61
|
-
Platform:
|
|
65
|
+
Platform: getHostEnvironment().technical,
|
|
62
66
|
OperatingSystem: osVersionName
|
|
63
67
|
});
|
|
64
68
|
return {
|
|
@@ -67,4 +71,50 @@ function createTelemetryEvent(eventName, telemetryData) {
|
|
|
67
71
|
measurements: {}
|
|
68
72
|
};
|
|
69
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Validate xml and parse the odata version from the metadata xml.
|
|
76
|
+
*
|
|
77
|
+
* @param metadata a metadata string
|
|
78
|
+
* @returns the odata version of the specified metadata, throws an error if the metadata is invalid
|
|
79
|
+
*/
|
|
80
|
+
function parseOdataVersion(metadata) {
|
|
81
|
+
const options = {
|
|
82
|
+
attributeNamePrefix: '',
|
|
83
|
+
ignoreAttributes: false,
|
|
84
|
+
ignoreNameSpace: true,
|
|
85
|
+
parseAttributeValue: true,
|
|
86
|
+
removeNSPrefix: true
|
|
87
|
+
};
|
|
88
|
+
const parser = new fast_xml_parser_1.XMLParser(options);
|
|
89
|
+
try {
|
|
90
|
+
const parsed = parser.parse(metadata, true);
|
|
91
|
+
const odataVersion = parsed['Edmx']['Version'] === 1 ? odata_service_writer_1.OdataVersion.v2 : odata_service_writer_1.OdataVersion.v4;
|
|
92
|
+
return odataVersion;
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
logger_helper_1.default.logger.error(error);
|
|
96
|
+
throw new Error((0, i18n_1.t)('prompts.validationMessages.metadataInvalid'));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
exports.parseOdataVersion = parseOdataVersion;
|
|
100
|
+
/**
|
|
101
|
+
* Replaces the origin in the metadata URIs with a relative path.
|
|
102
|
+
* The path will be tested for '/sap/opu/odata/' and if found, the origin will be replaced with './'.
|
|
103
|
+
* This is to ensure that the SAP internal backend URIs are relative and that other non-SAP URIs are not affected.
|
|
104
|
+
*
|
|
105
|
+
* @param metadata a metadata string containing URIs which include origin (protocol, host, port)
|
|
106
|
+
* @returns the metadata string with URIs replaced with relative paths
|
|
107
|
+
*/
|
|
108
|
+
function originToRelative(metadata) {
|
|
109
|
+
// Regex explanation:
|
|
110
|
+
// 1. Match the string "Uri=" literally
|
|
111
|
+
// 2. Match either "http" or "https"
|
|
112
|
+
// 3. Match the origin (protocol, host, port) as few times as possible
|
|
113
|
+
// 4. Match a single forward slash, indicating the first path segment of the URL (after the origin)
|
|
114
|
+
// 5. Match "sap/opu/odata" or "sap/opu/odata4" literally
|
|
115
|
+
return metadata.replace(new RegExp(/(Uri=")(http|https):\/{2}(.*?)(\/)(sap\/opu\/(odata\/|odata4\/))/, 'g'),
|
|
116
|
+
// Retain the original path segment after the origin, matched with capture group 5 (index 4)
|
|
117
|
+
(match, ...patterns) => `${patterns[0]}./${patterns[4]}`);
|
|
118
|
+
}
|
|
119
|
+
exports.originToRelative = originToRelative;
|
|
70
120
|
//# sourceMappingURL=index.js.map
|
|
@@ -9,7 +9,10 @@ exports.PromptState = void 0;
|
|
|
9
9
|
*/
|
|
10
10
|
class PromptState {
|
|
11
11
|
static reset() {
|
|
12
|
-
|
|
12
|
+
// Reset all values in the odataService object, do not reset the object reference itself as it may be used by external consumers
|
|
13
|
+
Object.keys(PromptState.odataService).forEach((key) => {
|
|
14
|
+
PromptState.odataService[key] = undefined;
|
|
15
|
+
});
|
|
13
16
|
}
|
|
14
17
|
}
|
|
15
18
|
exports.PromptState = PromptState;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sap-ux/odata-service-inquirer",
|
|
3
3
|
"description": "Prompts module that can prompt users for inputs required for odata service writing",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -19,14 +19,17 @@
|
|
|
19
19
|
"!dist/**/*.map"
|
|
20
20
|
],
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"
|
|
22
|
+
"axios": "1.6.8",
|
|
23
|
+
"axios-logger": "2.8.0",
|
|
24
|
+
"fast-xml-parser": "4.2.7",
|
|
23
25
|
"i18next": "23.5.1",
|
|
24
26
|
"os-name": "4.0.1",
|
|
27
|
+
"@sap-ux/axios-extension": "1.13.1",
|
|
25
28
|
"@sap-ux/btp-utils": "0.14.4",
|
|
26
|
-
"@sap-ux/telemetry": "0.4.
|
|
27
|
-
"@sap-ux/inquirer-common": "0.
|
|
29
|
+
"@sap-ux/telemetry": "0.4.33",
|
|
30
|
+
"@sap-ux/inquirer-common": "0.3.0",
|
|
28
31
|
"@sap-ux/logger": "0.5.1",
|
|
29
|
-
"@sap-ux/project-access": "1.22.
|
|
32
|
+
"@sap-ux/project-access": "1.22.1"
|
|
30
33
|
},
|
|
31
34
|
"devDependencies": {
|
|
32
35
|
"@sap-devx/yeoman-ui-types": "1.14.4",
|
|
@@ -35,7 +38,7 @@
|
|
|
35
38
|
"@types/lodash": "4.14.202",
|
|
36
39
|
"jest-extended": "3.2.4",
|
|
37
40
|
"lodash": "4.17.21",
|
|
38
|
-
"@sap-ux/odata-service-writer": "0.20.
|
|
41
|
+
"@sap-ux/odata-service-writer": "0.20.3",
|
|
39
42
|
"@sap-ux/feature-toggle": "0.1.1"
|
|
40
43
|
},
|
|
41
44
|
"engines": {
|