@sap-ux/odata-service-inquirer 0.5.60 → 0.6.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/i18n.js +15 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +10 -9
- package/dist/prompts/connectionValidator.d.ts +63 -12
- package/dist/prompts/connectionValidator.js +208 -50
- package/dist/prompts/datasources/cap-project/questions.js +2 -1
- package/dist/prompts/datasources/sap-system/abap-on-btp/questions.d.ts +3 -2
- package/dist/prompts/datasources/sap-system/abap-on-btp/questions.js +10 -10
- 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 +282 -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 +182 -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 +4 -3
- package/dist/prompts/datasources/service-url/validators.js +8 -9
- package/dist/prompts/prompt-helpers.d.ts +2 -3
- package/dist/prompts/prompt-helpers.js +4 -13
- 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 +25 -37
- package/dist/types.d.ts +57 -45
- package/dist/types.js +7 -41
- package/dist/utils/index.d.ts +5 -18
- package/dist/utils/index.js +10 -55
- package/package.json +10 -9
- package/dist/error-handler/error-handler.d.ts +0 -184
- package/dist/error-handler/error-handler.js +0 -465
- package/dist/prompts/datasources/sap-system/abap-on-btp/cf-helper.d.ts +0 -9
- package/dist/prompts/datasources/sap-system/abap-on-btp/cf-helper.js +0 -54
- 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
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getABAPInstanceChoices = getABAPInstanceChoices;
|
|
4
|
-
const cf_tools_1 = require("@sap/cf-tools");
|
|
5
|
-
const error_handler_1 = require("../../../../error-handler/error-handler");
|
|
6
|
-
const i18n_1 = require("../../../../i18n");
|
|
7
|
-
const prompt_helpers_1 = require("../../../prompt-helpers");
|
|
8
|
-
const AbapEnvType = {
|
|
9
|
-
ABAP: 'abap',
|
|
10
|
-
ABAP_TRIAL: 'abap-trial',
|
|
11
|
-
ABAP_CANARY: 'abap-canary',
|
|
12
|
-
ABAP_OEM: 'abap-oem',
|
|
13
|
-
ABAP_OEM_CANARY: 'abap-oem-canary',
|
|
14
|
-
ABAP_HAAS: 'abap-haas',
|
|
15
|
-
ABAP_STAGING: 'abap-staging',
|
|
16
|
-
ABAP_INTERNAL_STAGING: 'abap-internal-staging',
|
|
17
|
-
DESTINATION: 'destination'
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Get the name sorted list of ABAP instance choices from an active CF login. If not logged in, an error message is logged.
|
|
21
|
-
*
|
|
22
|
-
* @returns The list of ABAP instance choices
|
|
23
|
-
*/
|
|
24
|
-
async function getABAPInstanceChoices() {
|
|
25
|
-
const choices = [];
|
|
26
|
-
try {
|
|
27
|
-
const filteredInstances = [
|
|
28
|
-
AbapEnvType.ABAP,
|
|
29
|
-
AbapEnvType.ABAP_TRIAL,
|
|
30
|
-
AbapEnvType.ABAP_CANARY,
|
|
31
|
-
AbapEnvType.ABAP_OEM,
|
|
32
|
-
AbapEnvType.ABAP_OEM_CANARY,
|
|
33
|
-
AbapEnvType.ABAP_HAAS,
|
|
34
|
-
AbapEnvType.ABAP_STAGING,
|
|
35
|
-
AbapEnvType.ABAP_INTERNAL_STAGING
|
|
36
|
-
];
|
|
37
|
-
const serviceInstanceInfo = await (0, cf_tools_1.apiGetServicesInstancesFilteredByType)(filteredInstances);
|
|
38
|
-
if (serviceInstanceInfo.length > 0) {
|
|
39
|
-
serviceInstanceInfo.forEach((service) => {
|
|
40
|
-
choices.push({ name: service['label'], value: service });
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
// No envs found
|
|
45
|
-
prompt_helpers_1.errorHandler.logErrorMsgs(error_handler_1.ERROR_TYPE.NO_ABAP_ENVS, (0, i18n_1.t)('errors.noAbapEnvsInCFSpace'));
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
// Cannot connect to CF
|
|
50
|
-
prompt_helpers_1.errorHandler.logErrorMsgs(error_handler_1.ERROR_TYPE.NO_ABAP_ENVS, (0, i18n_1.t)('errors.abapEnvsCFDiscoveryFailed'));
|
|
51
|
-
}
|
|
52
|
-
return choices.sort((a, b) => (a.name ? a.name.localeCompare(b.name ?? '') : 0));
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=cf-helper.js.map
|
|
@@ -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
|