@sap-ux/odata-service-inquirer 0.5.60 → 0.6.0
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 +25 -3
- package/dist/error-handler/error-handler.js +154 -52
- package/dist/i18n.js +15 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -3
- package/dist/prompts/connectionValidator.d.ts +63 -12
- package/dist/prompts/connectionValidator.js +196 -38
- package/dist/prompts/datasources/sap-system/abap-on-btp/questions.d.ts +2 -1
- package/dist/prompts/datasources/sap-system/abap-on-btp/questions.js +3 -1
- package/dist/prompts/datasources/sap-system/abap-on-prem/questions.d.ts +9 -11
- package/dist/prompts/datasources/sap-system/abap-on-prem/questions.js +21 -55
- package/dist/prompts/datasources/sap-system/credentials/questions.d.ts +21 -0
- package/dist/prompts/datasources/sap-system/credentials/questions.js +123 -0
- package/dist/prompts/datasources/sap-system/new-system/questions.d.ts +4 -26
- package/dist/prompts/datasources/sap-system/new-system/questions.js +18 -168
- package/dist/prompts/datasources/sap-system/new-system/types.d.ts +0 -10
- package/dist/prompts/datasources/sap-system/service-selection/index.d.ts +3 -0
- package/dist/prompts/datasources/sap-system/service-selection/index.js +19 -0
- package/dist/prompts/datasources/sap-system/service-selection/questions.d.ts +15 -0
- package/dist/prompts/datasources/sap-system/service-selection/questions.js +146 -0
- package/dist/prompts/datasources/sap-system/service-selection/service-helper.d.ts +71 -0
- package/dist/prompts/datasources/sap-system/service-selection/service-helper.js +281 -0
- package/dist/prompts/datasources/sap-system/service-selection/types.d.ts +11 -0
- package/dist/prompts/datasources/sap-system/service-selection/types.js +3 -0
- package/dist/prompts/datasources/sap-system/system-selection/index.d.ts +2 -0
- package/dist/prompts/datasources/sap-system/system-selection/index.js +18 -0
- package/dist/prompts/datasources/sap-system/system-selection/prompt-helpers.d.ts +44 -0
- package/dist/prompts/datasources/sap-system/system-selection/prompt-helpers.js +190 -0
- package/dist/prompts/datasources/sap-system/system-selection/questions.d.ts +40 -0
- package/dist/prompts/datasources/sap-system/system-selection/questions.js +181 -0
- package/dist/prompts/datasources/sap-system/validators.d.ts +8 -0
- package/dist/prompts/datasources/sap-system/validators.js +17 -0
- package/dist/prompts/datasources/service-url/questions.js +2 -2
- package/dist/prompts/datasources/service-url/validators.js +5 -6
- package/dist/prompts/prompt-helpers.d.ts +1 -2
- package/dist/prompts/prompt-helpers.js +2 -11
- package/dist/prompts/prompts.js +5 -34
- package/dist/prompts/validators.d.ts +1 -1
- package/dist/prompts/validators.js +1 -1
- package/dist/translations/odata-service-inquirer.i18n.json +36 -15
- package/dist/types.d.ts +57 -10
- package/dist/types.js +7 -1
- package/dist/utils/index.d.ts +12 -3
- package/dist/utils/index.js +27 -5
- package/package.json +6 -6
- package/dist/prompts/datasources/sap-system/new-system/service-helper.d.ts +0 -43
- package/dist/prompts/datasources/sap-system/new-system/service-helper.js +0 -175
package/dist/types.js
CHANGED
|
@@ -7,12 +7,14 @@ exports.SAP_CLIENT_KEY = exports.hostEnvironment = exports.ValidationLink = expo
|
|
|
7
7
|
var DatasourceType;
|
|
8
8
|
(function (DatasourceType) {
|
|
9
9
|
DatasourceType["sapSystem"] = "sapSystem";
|
|
10
|
-
DatasourceType["businessHub"] = "businessHub";
|
|
11
10
|
DatasourceType["capProject"] = "capProject";
|
|
12
11
|
DatasourceType["odataServiceUrl"] = "odataServiceUrl";
|
|
13
12
|
DatasourceType["none"] = "none";
|
|
14
13
|
DatasourceType["metadataFile"] = "metadataFile";
|
|
14
|
+
// @deprecated
|
|
15
15
|
DatasourceType["projectSpecificDestination"] = "projectSpecificDestination";
|
|
16
|
+
// @deprecated
|
|
17
|
+
DatasourceType["businessHub"] = "businessHub";
|
|
16
18
|
})(DatasourceType || (exports.DatasourceType = DatasourceType = {}));
|
|
17
19
|
exports.SapSystemTypes = {
|
|
18
20
|
abapOnPrem: 'abapOnPrem',
|
|
@@ -55,6 +57,10 @@ var promptNames;
|
|
|
55
57
|
* Newly created systems can be named for storage
|
|
56
58
|
*/
|
|
57
59
|
promptNames["userSystemName"] = "userSystemName";
|
|
60
|
+
/**
|
|
61
|
+
* System selection
|
|
62
|
+
*/
|
|
63
|
+
promptNames["systemSelection"] = "systemSelection";
|
|
58
64
|
})(promptNames || (exports.promptNames = promptNames = {}));
|
|
59
65
|
/**
|
|
60
66
|
* Implementation of IValidationLink interface.
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import type { TelemetryProperties, ToolsSuiteTelemetryClient } from '@sap-ux/telemetry';
|
|
2
|
-
import { PromptState } from './prompt-state';
|
|
3
|
-
import { OdataVersion } from '@sap-ux/odata-service-writer';
|
|
4
1
|
import { ODataVersion } from '@sap-ux/axios-extension';
|
|
2
|
+
import { type Destination } from '@sap-ux/btp-utils';
|
|
3
|
+
import { OdataVersion } from '@sap-ux/odata-service-writer';
|
|
4
|
+
import type { TelemetryProperties, ToolsSuiteTelemetryClient } from '@sap-ux/telemetry';
|
|
5
5
|
import type { ListChoiceOptions } from 'inquirer';
|
|
6
|
+
import { PromptState } from './prompt-state';
|
|
7
|
+
export type TelemPropertyDestinationType = 'AbapODataCatalogDest' | 'GenericODataFullUrlDest' | 'GenericODataPartialUrlDest' | 'Unknown';
|
|
6
8
|
/**
|
|
7
9
|
* Determine if the current prompting environment is cli or a hosted extension (app studio or vscode).
|
|
8
10
|
*
|
|
@@ -25,6 +27,13 @@ export declare function setTelemetryClient(toolsSuiteTelemetryClient: ToolsSuite
|
|
|
25
27
|
* @param telemetryData the telemetry values to report
|
|
26
28
|
*/
|
|
27
29
|
export declare function sendTelemetryEvent(eventName: string, telemetryData: TelemetryProperties): void;
|
|
30
|
+
/**
|
|
31
|
+
* Used only to generate telemetry events in the case of destination errors.
|
|
32
|
+
*
|
|
33
|
+
* @param destination
|
|
34
|
+
* @returns the telemetry property destination type
|
|
35
|
+
*/
|
|
36
|
+
export declare function getTelemPropertyDestinationType(destination: Destination): TelemPropertyDestinationType;
|
|
28
37
|
/**
|
|
29
38
|
* Validate xml and parse the odata version from the metadata xml.
|
|
30
39
|
*
|
package/dist/utils/index.js
CHANGED
|
@@ -7,21 +7,22 @@ exports.PromptState = void 0;
|
|
|
7
7
|
exports.getHostEnvironment = getHostEnvironment;
|
|
8
8
|
exports.setTelemetryClient = setTelemetryClient;
|
|
9
9
|
exports.sendTelemetryEvent = sendTelemetryEvent;
|
|
10
|
+
exports.getTelemPropertyDestinationType = getTelemPropertyDestinationType;
|
|
10
11
|
exports.parseOdataVersion = parseOdataVersion;
|
|
11
12
|
exports.originToRelative = originToRelative;
|
|
12
13
|
exports.convertODataVersionType = convertODataVersionType;
|
|
13
14
|
exports.getDefaultChoiceIndex = getDefaultChoiceIndex;
|
|
15
|
+
const axios_extension_1 = require("@sap-ux/axios-extension");
|
|
14
16
|
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
17
|
+
const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
|
|
15
18
|
const telemetry_1 = require("@sap-ux/telemetry");
|
|
19
|
+
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
16
20
|
const os_name_1 = __importDefault(require("os-name"));
|
|
21
|
+
const i18n_1 = require("../i18n");
|
|
22
|
+
const logger_helper_1 = __importDefault(require("../prompts/logger-helper"));
|
|
17
23
|
const types_1 = require("../types");
|
|
18
24
|
const prompt_state_1 = require("./prompt-state");
|
|
19
25
|
Object.defineProperty(exports, "PromptState", { enumerable: true, get: function () { return prompt_state_1.PromptState; } });
|
|
20
|
-
const fast_xml_parser_1 = require("fast-xml-parser");
|
|
21
|
-
const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
|
|
22
|
-
const logger_helper_1 = __importDefault(require("../prompts/logger-helper"));
|
|
23
|
-
const i18n_1 = require("../i18n");
|
|
24
|
-
const axios_extension_1 = require("@sap-ux/axios-extension");
|
|
25
26
|
const osVersionName = (0, os_name_1.default)();
|
|
26
27
|
/**
|
|
27
28
|
* Determine if the current prompting environment is cli or a hosted extension (app studio or vscode).
|
|
@@ -54,6 +55,7 @@ function setTelemetryClient(toolsSuiteTelemetryClient) {
|
|
|
54
55
|
function sendTelemetryEvent(eventName, telemetryData) {
|
|
55
56
|
const telemetryEvent = createTelemetryEvent(eventName, telemetryData);
|
|
56
57
|
if (telemetryClient) {
|
|
58
|
+
// Do not wait for the telemetry event to be sent, it cannot be recovered if it fails, do not block the process
|
|
57
59
|
/* eslint-disable @typescript-eslint/no-floating-promises */
|
|
58
60
|
telemetryClient.reportEvent(telemetryEvent, telemetry_1.SampleRate.NoSampling);
|
|
59
61
|
}
|
|
@@ -76,6 +78,26 @@ function createTelemetryEvent(eventName, telemetryData) {
|
|
|
76
78
|
measurements: {}
|
|
77
79
|
};
|
|
78
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Used only to generate telemetry events in the case of destination errors.
|
|
83
|
+
*
|
|
84
|
+
* @param destination
|
|
85
|
+
* @returns the telemetry property destination type
|
|
86
|
+
*/
|
|
87
|
+
function getTelemPropertyDestinationType(destination) {
|
|
88
|
+
if ((0, btp_utils_1.isAbapODataDestination)(destination)) {
|
|
89
|
+
return 'AbapODataCatalogDest';
|
|
90
|
+
}
|
|
91
|
+
else if ((0, btp_utils_1.isFullUrlDestination)(destination)) {
|
|
92
|
+
return 'GenericODataFullUrlDest';
|
|
93
|
+
}
|
|
94
|
+
else if ((0, btp_utils_1.isPartialUrlDestination)(destination)) {
|
|
95
|
+
return 'GenericODataPartialUrlDest';
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
return 'Unknown';
|
|
99
|
+
}
|
|
100
|
+
}
|
|
79
101
|
/**
|
|
80
102
|
* Validate xml and parse the odata version from the metadata xml.
|
|
81
103
|
*
|
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.6.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/SAP/open-ux-tools.git",
|
|
@@ -26,10 +26,11 @@
|
|
|
26
26
|
"i18next": "23.5.1",
|
|
27
27
|
"inquirer-autocomplete-prompt": "2.0.1",
|
|
28
28
|
"os-name": "4.0.1",
|
|
29
|
-
"@sap-ux/axios-extension": "1.17.
|
|
30
|
-
"@sap-ux/btp-utils": "0.
|
|
31
|
-
"@sap-ux/
|
|
32
|
-
"@sap-ux/
|
|
29
|
+
"@sap-ux/axios-extension": "1.17.2",
|
|
30
|
+
"@sap-ux/btp-utils": "0.16.0",
|
|
31
|
+
"@sap-ux/fiori-generator-shared": "0.7.6",
|
|
32
|
+
"@sap-ux/guided-answers-helper": "0.1.0",
|
|
33
|
+
"@sap-ux/telemetry": "0.5.42",
|
|
33
34
|
"@sap-ux/inquirer-common": "0.4.10",
|
|
34
35
|
"@sap-ux/logger": "0.6.0",
|
|
35
36
|
"@sap-ux/project-access": "1.28.6",
|
|
@@ -42,7 +43,6 @@
|
|
|
42
43
|
"@types/inquirer": "8.2.6",
|
|
43
44
|
"@types/lodash": "4.14.202",
|
|
44
45
|
"jest-extended": "3.2.4",
|
|
45
|
-
"lodash": "4.17.21",
|
|
46
46
|
"@sap-ux/odata-service-writer": "0.23.1",
|
|
47
47
|
"@sap-ux/feature-toggle": "0.2.2"
|
|
48
48
|
},
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { type CatalogService, ServiceType, V2CatalogService, type Annotations, type ServiceProvider } from '@sap-ux/axios-extension';
|
|
2
|
-
import type { ListChoiceOptions } from 'inquirer';
|
|
3
|
-
import type { ServiceAnswer } from './types';
|
|
4
|
-
import type { ConnectionValidator } from '../../../connectionValidator';
|
|
5
|
-
/**
|
|
6
|
-
* Get the service choices from the specified catalogs.
|
|
7
|
-
*
|
|
8
|
-
* @param catalogs catalogs to get the services from. There should be one per odata version required.
|
|
9
|
-
* @returns service choices based on the provided catalogs
|
|
10
|
-
*/
|
|
11
|
-
export declare function getServiceChoices(catalogs: CatalogService[]): Promise<ListChoiceOptions<ServiceAnswer>[]>;
|
|
12
|
-
/**
|
|
13
|
-
* Gets the service metadata and annotations for the specified service path.
|
|
14
|
-
*
|
|
15
|
-
* @param servicePath service path
|
|
16
|
-
* @param catalog the catalog service used to get the annotations for the specified service path
|
|
17
|
-
* @param serviceProvider the service provider for the connected system
|
|
18
|
-
* @returns Promise<string | boolean>, string error message or true if successful
|
|
19
|
-
*/
|
|
20
|
-
export declare function getServiceMetadata(servicePath: string, catalog: CatalogService, serviceProvider: ServiceProvider): Promise<{
|
|
21
|
-
annotations: Annotations[];
|
|
22
|
-
metadata: string;
|
|
23
|
-
serviceProvider: ServiceProvider;
|
|
24
|
-
} | string>;
|
|
25
|
-
/**
|
|
26
|
-
* Get service type for 'Not Determined' services from `ServiceTypeForHUBServices()`
|
|
27
|
-
*
|
|
28
|
-
* @param servicePath service path
|
|
29
|
-
* @param serviceType service type
|
|
30
|
-
* @param catalog the catalog service used to get the service type for the specified service path
|
|
31
|
-
* @returns service type
|
|
32
|
-
*/
|
|
33
|
-
export declare function getServiceType(servicePath: string, serviceType: string | undefined, catalog: V2CatalogService): Promise<ServiceType | undefined>;
|
|
34
|
-
/**
|
|
35
|
-
* Requests and sets the service details to the PromptState.odataService properties.
|
|
36
|
-
* If an error occurs, the error message is returned for use in validators.
|
|
37
|
-
*
|
|
38
|
-
* @param service the specific service to get details for
|
|
39
|
-
* @param connectionValidator a reference to the connection validator which has an active connection to the backend
|
|
40
|
-
* @returns true if successful, setting the PromptState.odataService properties, or an error message indicating why the service details could not be retrieved.
|
|
41
|
-
*/
|
|
42
|
-
export declare function getServiceDetails(service: ServiceAnswer, connectionValidator: ConnectionValidator): Promise<string | boolean>;
|
|
43
|
-
//# sourceMappingURL=service-helper.d.ts.map
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getServiceChoices = getServiceChoices;
|
|
7
|
-
exports.getServiceMetadata = getServiceMetadata;
|
|
8
|
-
exports.getServiceType = getServiceType;
|
|
9
|
-
exports.getServiceDetails = getServiceDetails;
|
|
10
|
-
const axios_extension_1 = require("@sap-ux/axios-extension");
|
|
11
|
-
const i18n_1 = require("../../../../i18n");
|
|
12
|
-
const logger_helper_1 = __importDefault(require("../../../logger-helper"));
|
|
13
|
-
const utils_1 = require("../../../../utils");
|
|
14
|
-
const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
|
|
15
|
-
const prompt_helpers_1 = require("../../../prompt-helpers");
|
|
16
|
-
// Service ids continaining these paths should not be offered as UI compatible services
|
|
17
|
-
const nonUIServicePaths = ['/IWBEP/COMMON/'];
|
|
18
|
-
/**
|
|
19
|
-
* Builds and formats the service choices list.
|
|
20
|
-
*
|
|
21
|
-
* @param serviceInfos service information to build the choices from. Services with a service id containing '/IWBEP/COMMON' are ignored.
|
|
22
|
-
* @returns service choices list
|
|
23
|
-
*/
|
|
24
|
-
const createServiceChoices = (serviceInfos) => {
|
|
25
|
-
const choices = [];
|
|
26
|
-
// Provide additional service information in trace mode (YUI only)
|
|
27
|
-
let isLogTrace = false;
|
|
28
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Only specific loggers have this method
|
|
29
|
-
if (typeof logger_helper_1.default.logger.getLogLevel === 'function') {
|
|
30
|
-
isLogTrace = logger_helper_1.default.logger.getLogLevel() === 'trace';
|
|
31
|
-
}
|
|
32
|
-
serviceInfos
|
|
33
|
-
// Exclude non-UI compatible services
|
|
34
|
-
?.filter((service) => !nonUIServicePaths.some((path) => service.path.includes(path)))
|
|
35
|
-
.forEach((service) => {
|
|
36
|
-
let serviceName = service.name;
|
|
37
|
-
const servicePath = service.path;
|
|
38
|
-
serviceName = `${serviceName} (${service.serviceVersion}) - OData V${service.odataVersion}`;
|
|
39
|
-
if (isLogTrace) {
|
|
40
|
-
serviceName = `${serviceName} Service Type: ${service.serviceType}`;
|
|
41
|
-
}
|
|
42
|
-
choices.push({
|
|
43
|
-
name: serviceName,
|
|
44
|
-
value: {
|
|
45
|
-
servicePath,
|
|
46
|
-
serviceODataVersion: service.odataVersion,
|
|
47
|
-
toString: () => serviceName,
|
|
48
|
-
serviceType: service.serviceType
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
|
-
return choices.sort((a, b) => (a.name ? a.name.localeCompare(b.name ?? '') : 0));
|
|
53
|
-
};
|
|
54
|
-
/**
|
|
55
|
-
* Logs the catalog reuest errors.
|
|
56
|
-
*
|
|
57
|
-
* @param requestErrors catalog request errors
|
|
58
|
-
*/
|
|
59
|
-
function logErrorsForHelp(requestErrors) {
|
|
60
|
-
// Log the first error only
|
|
61
|
-
const catalogErrors = Object.values(requestErrors);
|
|
62
|
-
if (catalogErrors.length > 0) {
|
|
63
|
-
catalogErrors.forEach((error) => prompt_helpers_1.errorHandler.logErrorMsgs(error));
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Get the service choices from the specified catalogs.
|
|
68
|
-
*
|
|
69
|
-
* @param catalogs catalogs to get the services from. There should be one per odata version required.
|
|
70
|
-
* @returns service choices based on the provided catalogs
|
|
71
|
-
*/
|
|
72
|
-
async function getServiceChoices(catalogs) {
|
|
73
|
-
const requestErrors = {};
|
|
74
|
-
const listServicesRequests = catalogs.map(async (catalog) => {
|
|
75
|
-
try {
|
|
76
|
-
return await catalog.listServices();
|
|
77
|
-
}
|
|
78
|
-
catch (error) {
|
|
79
|
-
logger_helper_1.default.logger.error((0, i18n_1.t)('errors.serviceCatalogRequest', {
|
|
80
|
-
catalogRequestUri: catalog.getUri(),
|
|
81
|
-
entitySet: catalog.entitySet,
|
|
82
|
-
error
|
|
83
|
-
}));
|
|
84
|
-
// Save any errors for processing later as we may show more useful message to the user
|
|
85
|
-
Object.assign(requestErrors, {
|
|
86
|
-
[catalog instanceof axios_extension_1.V2CatalogService ? axios_extension_1.ODataVersion.v2 : axios_extension_1.ODataVersion.v4]: error
|
|
87
|
-
});
|
|
88
|
-
return [];
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
const serviceInfos = await Promise.all(listServicesRequests);
|
|
92
|
-
const flatServices = serviceInfos?.flat() ?? [];
|
|
93
|
-
logger_helper_1.default.logger.debug(`Number of services available: ${flatServices.length}`);
|
|
94
|
-
if (flatServices.length === 0) {
|
|
95
|
-
logErrorsForHelp(requestErrors);
|
|
96
|
-
}
|
|
97
|
-
return createServiceChoices(flatServices);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Gets the service metadata and annotations for the specified service path.
|
|
101
|
-
*
|
|
102
|
-
* @param servicePath service path
|
|
103
|
-
* @param catalog the catalog service used to get the annotations for the specified service path
|
|
104
|
-
* @param serviceProvider the service provider for the connected system
|
|
105
|
-
* @returns Promise<string | boolean>, string error message or true if successful
|
|
106
|
-
*/
|
|
107
|
-
async function getServiceMetadata(servicePath, catalog, serviceProvider) {
|
|
108
|
-
let annotations = [];
|
|
109
|
-
try {
|
|
110
|
-
try {
|
|
111
|
-
annotations = await catalog.getAnnotations({ path: servicePath });
|
|
112
|
-
}
|
|
113
|
-
catch {
|
|
114
|
-
logger_helper_1.default.logger.info((0, i18n_1.t)('prompts.validationMessages.noAnnotations'));
|
|
115
|
-
}
|
|
116
|
-
const odataService = serviceProvider.service(servicePath);
|
|
117
|
-
const metadata = await odataService.metadata();
|
|
118
|
-
return {
|
|
119
|
-
annotations,
|
|
120
|
-
metadata,
|
|
121
|
-
serviceProvider
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
catch (error) {
|
|
125
|
-
logger_helper_1.default.logger.error((0, i18n_1.t)('errors.serviceMetadataErrorLog', { servicePath, error }));
|
|
126
|
-
return (0, i18n_1.t)('errors.serviceMetadataErrorUI', { servicePath });
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Get service type for 'Not Determined' services from `ServiceTypeForHUBServices()`
|
|
131
|
-
*
|
|
132
|
-
* @param servicePath service path
|
|
133
|
-
* @param serviceType service type
|
|
134
|
-
* @param catalog the catalog service used to get the service type for the specified service path
|
|
135
|
-
* @returns service type
|
|
136
|
-
*/
|
|
137
|
-
async function getServiceType(servicePath, serviceType, catalog) {
|
|
138
|
-
let resolvedServiceType;
|
|
139
|
-
if (serviceType === axios_extension_1.ServiceType.NotDetermined) {
|
|
140
|
-
try {
|
|
141
|
-
resolvedServiceType = (await catalog.getServiceType(servicePath)) ?? axios_extension_1.ServiceType.NotDetermined;
|
|
142
|
-
}
|
|
143
|
-
catch (e) {
|
|
144
|
-
logger_helper_1.default.logger.error((0, i18n_1.t)('errors.serviceTypeRequestError', { error: e.message }));
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
return resolvedServiceType ?? serviceType;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Requests and sets the service details to the PromptState.odataService properties.
|
|
151
|
-
* If an error occurs, the error message is returned for use in validators.
|
|
152
|
-
*
|
|
153
|
-
* @param service the specific service to get details for
|
|
154
|
-
* @param connectionValidator a reference to the connection validator which has an active connection to the backend
|
|
155
|
-
* @returns true if successful, setting the PromptState.odataService properties, or an error message indicating why the service details could not be retrieved.
|
|
156
|
-
*/
|
|
157
|
-
async function getServiceDetails(service, connectionValidator) {
|
|
158
|
-
const serviceCatalog = connectionValidator.catalogs[service.serviceODataVersion];
|
|
159
|
-
if (!serviceCatalog || !connectionValidator.serviceProvider) {
|
|
160
|
-
logger_helper_1.default.logger.error('ConenctionValidator is not initialized');
|
|
161
|
-
return false;
|
|
162
|
-
}
|
|
163
|
-
const serviceResult = await getServiceMetadata(service.servicePath, serviceCatalog, connectionValidator.serviceProvider);
|
|
164
|
-
if (typeof serviceResult === 'string') {
|
|
165
|
-
return serviceResult;
|
|
166
|
-
}
|
|
167
|
-
utils_1.PromptState.odataService.annotations = serviceResult?.annotations;
|
|
168
|
-
utils_1.PromptState.odataService.metadata = serviceResult?.metadata;
|
|
169
|
-
utils_1.PromptState.odataService.odataVersion =
|
|
170
|
-
service.serviceODataVersion === axios_extension_1.ODataVersion.v2 ? odata_service_writer_1.OdataVersion.v2 : odata_service_writer_1.OdataVersion.v4;
|
|
171
|
-
utils_1.PromptState.odataService.servicePath = service.servicePath;
|
|
172
|
-
utils_1.PromptState.odataService.origin = connectionValidator.validatedUrl;
|
|
173
|
-
return true;
|
|
174
|
-
}
|
|
175
|
-
//# sourceMappingURL=service-helper.js.map
|