@sap-ux/odata-service-inquirer 0.6.0 → 0.6.2
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 +0 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.js +9 -6
- package/dist/prompts/connectionValidator.d.ts +3 -2
- package/dist/prompts/connectionValidator.js +27 -26
- package/dist/prompts/datasources/cap-project/questions.js +2 -1
- package/dist/prompts/datasources/sap-system/abap-on-btp/questions.d.ts +1 -1
- package/dist/prompts/datasources/sap-system/abap-on-btp/questions.js +8 -10
- package/dist/prompts/datasources/sap-system/credentials/questions.d.ts +2 -2
- package/dist/prompts/datasources/sap-system/credentials/questions.js +2 -2
- package/dist/prompts/datasources/sap-system/service-selection/questions.js +4 -4
- package/dist/prompts/datasources/sap-system/service-selection/service-helper.d.ts +1 -1
- package/dist/prompts/datasources/sap-system/service-selection/service-helper.js +5 -4
- package/dist/prompts/datasources/sap-system/system-selection/prompt-helpers.d.ts +2 -2
- package/dist/prompts/datasources/sap-system/system-selection/prompt-helpers.js +7 -7
- package/dist/prompts/datasources/sap-system/system-selection/questions.d.ts +1 -1
- package/dist/prompts/datasources/sap-system/system-selection/questions.js +6 -5
- package/dist/prompts/datasources/service-url/questions.js +2 -1
- package/dist/prompts/datasources/service-url/validators.js +3 -3
- package/dist/prompts/prompt-helpers.d.ts +1 -1
- package/dist/prompts/prompt-helpers.js +2 -2
- package/dist/translations/odata-service-inquirer.i18n.json +4 -37
- package/dist/types.d.ts +0 -35
- package/dist/types.js +1 -41
- package/dist/utils/index.d.ts +3 -25
- package/dist/utils/index.js +5 -72
- package/package.json +7 -6
- package/dist/error-handler/error-handler.d.ts +0 -206
- package/dist/error-handler/error-handler.js +0 -567
- 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/i18n.js
CHANGED
|
@@ -14,7 +14,6 @@ exports.defaultProjectNumber = 1;
|
|
|
14
14
|
* Initialize i18next with the translations for this module.
|
|
15
15
|
*/
|
|
16
16
|
async function initI18nOdataServiceInquirer() {
|
|
17
|
-
const t0 = performance.now();
|
|
18
17
|
await i18next_1.default.init({
|
|
19
18
|
lng: 'en',
|
|
20
19
|
fallbackLng: 'en',
|
|
@@ -34,8 +33,6 @@ async function initI18nOdataServiceInquirer() {
|
|
|
34
33
|
}
|
|
35
34
|
});
|
|
36
35
|
i18next_1.default.addResourceBundle('en', odataServiceInquirerNamespace, odata_service_inquirer_i18n_json_1.default);
|
|
37
|
-
const t1 = performance.now();
|
|
38
|
-
console.log(`i18n load time: ${Math.round(t1 - t0)} milliseconds`);
|
|
39
36
|
}
|
|
40
37
|
/**
|
|
41
38
|
* Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { type InquirerAdapter } from '@sap-ux/inquirer-common';
|
|
|
2
2
|
import { type Logger } from '@sap-ux/logger';
|
|
3
3
|
import { OdataVersion } from '@sap-ux/odata-service-writer';
|
|
4
4
|
import { type ToolsSuiteTelemetryClient } from '@sap-ux/telemetry';
|
|
5
|
-
import { ERROR_TYPE, ErrorHandler } from '
|
|
5
|
+
import { ERROR_TYPE, ErrorHandler } from '@sap-ux/inquirer-common';
|
|
6
6
|
import { SystemSelectionAnswerType } from './prompts/datasources/sap-system/system-selection';
|
|
7
7
|
import { DatasourceType, promptNames, type CapRuntime, type CapService, type OdataServiceAnswers, type OdataServicePromptOptions, type OdataServiceQuestion, type SapSystemType } from './types';
|
|
8
8
|
/**
|
package/dist/index.js
CHANGED
|
@@ -9,9 +9,9 @@ exports.prompt = prompt;
|
|
|
9
9
|
const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
|
|
10
10
|
Object.defineProperty(exports, "OdataVersion", { enumerable: true, get: function () { return odata_service_writer_1.OdataVersion; } });
|
|
11
11
|
const inquirer_autocomplete_prompt_1 = __importDefault(require("inquirer-autocomplete-prompt"));
|
|
12
|
-
const
|
|
13
|
-
Object.defineProperty(exports, "ERROR_TYPE", { enumerable: true, get: function () { return
|
|
14
|
-
Object.defineProperty(exports, "ErrorHandler", { enumerable: true, get: function () { return
|
|
12
|
+
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
13
|
+
Object.defineProperty(exports, "ERROR_TYPE", { enumerable: true, get: function () { return inquirer_common_1.ERROR_TYPE; } });
|
|
14
|
+
Object.defineProperty(exports, "ErrorHandler", { enumerable: true, get: function () { return inquirer_common_1.ErrorHandler; } });
|
|
15
15
|
const i18n_1 = require("./i18n");
|
|
16
16
|
const prompts_1 = require("./prompts");
|
|
17
17
|
const logger_helper_1 = __importDefault(require("./prompts/logger-helper"));
|
|
@@ -35,10 +35,13 @@ async function getPrompts(promptOptions, logger, enableGuidedAnswers = false, te
|
|
|
35
35
|
if (logger) {
|
|
36
36
|
logger_helper_1.default.logger = logger;
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
inquirer_common_1.ErrorHandler.logger = logger_helper_1.default.logger;
|
|
39
|
+
inquirer_common_1.ErrorHandler.guidedAnswersEnabled = enableGuidedAnswers;
|
|
40
|
+
// Sets the platform for error handler telem reporting, based on the `isYUI` option
|
|
41
|
+
inquirer_common_1.ErrorHandler.platform = (0, utils_1.getPromptHostEnvironment)().technical;
|
|
42
|
+
inquirer_common_1.ErrorHandler.guidedAnswersTrigger = '@sap-ux/odata-service-inquirer';
|
|
40
43
|
utils_1.PromptState.isYUI = isYUI;
|
|
41
|
-
(0,
|
|
44
|
+
(0, inquirer_common_1.setTelemetryClient)(telemetryClient);
|
|
42
45
|
return {
|
|
43
46
|
prompts: await (0, prompts_1.getQuestions)(promptOptions),
|
|
44
47
|
// Return reference to derived answers object that will be populated with user responses (after prompting is complete)
|
|
@@ -2,7 +2,7 @@ import type { IValidationLink } from '@sap-devx/yeoman-ui-types';
|
|
|
2
2
|
import type { AxiosRequestConfig, CatalogService, ODataService, ServiceInfo, ServiceProvider } from '@sap-ux/axios-extension';
|
|
3
3
|
import { ODataVersion } from '@sap-ux/axios-extension';
|
|
4
4
|
import { type Destination } from '@sap-ux/btp-utils';
|
|
5
|
-
import { ERROR_TYPE } from '
|
|
5
|
+
import { ERROR_TYPE } from '@sap-ux/inquirer-common';
|
|
6
6
|
/**
|
|
7
7
|
* Structure to store validity information about url to be validated.
|
|
8
8
|
*/
|
|
@@ -165,8 +165,9 @@ export declare class ConnectionValidator {
|
|
|
165
165
|
*/
|
|
166
166
|
private createOdataServiceConnection;
|
|
167
167
|
/**
|
|
168
|
+
* Resets any connection state and validity information.
|
|
168
169
|
*
|
|
169
|
-
* @param resetValidity
|
|
170
|
+
* @param resetValidity if true, the validity information will be reset also
|
|
170
171
|
*/
|
|
171
172
|
resetConnectionState(resetValidity?: boolean): void;
|
|
172
173
|
/**
|
|
@@ -7,13 +7,13 @@ exports.ConnectionValidator = void 0;
|
|
|
7
7
|
const axios_extension_1 = require("@sap-ux/axios-extension");
|
|
8
8
|
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
9
9
|
const https_1 = __importDefault(require("https"));
|
|
10
|
-
const
|
|
10
|
+
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
11
11
|
const i18n_1 = require("../i18n");
|
|
12
12
|
const types_1 = require("../types");
|
|
13
13
|
const logger_helper_1 = __importDefault(require("./logger-helper"));
|
|
14
14
|
const prompt_helpers_1 = require("./prompt-helpers");
|
|
15
15
|
// Cert errors that may be ignored by prompt user
|
|
16
|
-
const ignorableCertErrors = [
|
|
16
|
+
const ignorableCertErrors = [inquirer_common_1.ERROR_TYPE.CERT_SELF_SIGNED, inquirer_common_1.ERROR_TYPE.CERT_SELF_SIGNED_CERT_IN_CHAIN];
|
|
17
17
|
/**
|
|
18
18
|
* Class that can be used to determine the connectivity using a service url, system url, or service info (UAA Key details) or reentrance ticket.
|
|
19
19
|
* This will determine if if the service/catalog is reachable, authentication is required and generates ting messages to guide the user.
|
|
@@ -273,8 +273,9 @@ class ConnectionValidator {
|
|
|
273
273
|
await this._odataService.get('');
|
|
274
274
|
}
|
|
275
275
|
/**
|
|
276
|
+
* Resets any connection state and validity information.
|
|
276
277
|
*
|
|
277
|
-
* @param resetValidity
|
|
278
|
+
* @param resetValidity if true, the validity information will be reset also
|
|
278
279
|
*/
|
|
279
280
|
resetConnectionState(resetValidity = false) {
|
|
280
281
|
this._serviceProvider = undefined;
|
|
@@ -360,8 +361,8 @@ class ConnectionValidator {
|
|
|
360
361
|
if (!statusCode) {
|
|
361
362
|
return false;
|
|
362
363
|
}
|
|
363
|
-
const errorType =
|
|
364
|
-
return errorType ===
|
|
364
|
+
const errorType = inquirer_common_1.ErrorHandler.getErrorType(statusCode);
|
|
365
|
+
return errorType === inquirer_common_1.ERROR_TYPE.NOT_FOUND || errorType === inquirer_common_1.ERROR_TYPE.AUTH;
|
|
365
366
|
}
|
|
366
367
|
/**
|
|
367
368
|
* Callback for when the Abap cloud system refresh token changes.
|
|
@@ -458,7 +459,7 @@ class ConnectionValidator {
|
|
|
458
459
|
// Return a more helpful error message
|
|
459
460
|
return {
|
|
460
461
|
valResult: prompt_helpers_1.errorHandler.getValidationErrorHelp(error, false, destination) ?? errorLog,
|
|
461
|
-
errorType: prompt_helpers_1.errorHandler.getCurrentErrorType() ??
|
|
462
|
+
errorType: prompt_helpers_1.errorHandler.getCurrentErrorType() ?? inquirer_common_1.ERROR_TYPE.DESTINATION_CONNECTION_ERROR
|
|
462
463
|
};
|
|
463
464
|
}
|
|
464
465
|
}
|
|
@@ -489,13 +490,13 @@ class ConnectionValidator {
|
|
|
489
490
|
const errorLog = prompt_helpers_1.errorHandler.logErrorMsgs(status);
|
|
490
491
|
return {
|
|
491
492
|
valResult: prompt_helpers_1.errorHandler.getValidationErrorHelp(status, false, destination) ?? errorLog,
|
|
492
|
-
errorType: prompt_helpers_1.errorHandler.getCurrentErrorType() ??
|
|
493
|
+
errorType: prompt_helpers_1.errorHandler.getCurrentErrorType() ?? inquirer_common_1.ERROR_TYPE.DESTINATION_CONNECTION_ERROR
|
|
493
494
|
};
|
|
494
495
|
}
|
|
495
496
|
if (this.validity.authRequired) {
|
|
496
497
|
return {
|
|
497
|
-
valResult:
|
|
498
|
-
errorType:
|
|
498
|
+
valResult: inquirer_common_1.ErrorHandler.getErrorMsgFromType(inquirer_common_1.ERROR_TYPE.AUTH),
|
|
499
|
+
errorType: inquirer_common_1.ERROR_TYPE.AUTH
|
|
499
500
|
};
|
|
500
501
|
}
|
|
501
502
|
return {
|
|
@@ -558,7 +559,7 @@ class ConnectionValidator {
|
|
|
558
559
|
catch (error) {
|
|
559
560
|
this.resetValidity();
|
|
560
561
|
// More helpful context specific error
|
|
561
|
-
if (
|
|
562
|
+
if (inquirer_common_1.ErrorHandler.getErrorType(error) === inquirer_common_1.ERROR_TYPE.CONNECTION) {
|
|
562
563
|
this.validity.reachable = false;
|
|
563
564
|
return prompt_helpers_1.errorHandler.logErrorMsgs((0, i18n_1.t)('errors.systemOrServiceUrlNotFound', { url: serviceUrl }));
|
|
564
565
|
}
|
|
@@ -578,40 +579,40 @@ class ConnectionValidator {
|
|
|
578
579
|
this.validity.authenticated = true;
|
|
579
580
|
return true;
|
|
580
581
|
}
|
|
581
|
-
else if (
|
|
582
|
+
else if (inquirer_common_1.ErrorHandler.getErrorType(status) === inquirer_common_1.ERROR_TYPE.NOT_FOUND) {
|
|
582
583
|
this.validity.reachable = false;
|
|
583
|
-
return
|
|
584
|
+
return inquirer_common_1.ErrorHandler.getErrorMsgFromType(inquirer_common_1.ERROR_TYPE.NOT_FOUND) ?? false;
|
|
584
585
|
}
|
|
585
|
-
else if (
|
|
586
|
+
else if (inquirer_common_1.ErrorHandler.isCertError(status)) {
|
|
586
587
|
this.validity.reachable = true;
|
|
587
|
-
this.validity.canSkipCertError = ignorableCertErrors.includes(
|
|
588
|
+
this.validity.canSkipCertError = ignorableCertErrors.includes(inquirer_common_1.ErrorHandler.getErrorType(status));
|
|
588
589
|
this.validity.authenticated = false;
|
|
589
590
|
return prompt_helpers_1.errorHandler.getValidationErrorHelp(status, false) ?? false;
|
|
590
591
|
}
|
|
591
|
-
else if (
|
|
592
|
+
else if (inquirer_common_1.ErrorHandler.getErrorType(status) === inquirer_common_1.ERROR_TYPE.AUTH) {
|
|
592
593
|
this.validity.reachable = true;
|
|
593
594
|
this.validity.authRequired = true;
|
|
594
595
|
this.validity.authenticated = false;
|
|
595
596
|
return true;
|
|
596
597
|
}
|
|
597
|
-
else if (
|
|
598
|
+
else if (inquirer_common_1.ErrorHandler.getErrorType(status) === inquirer_common_1.ERROR_TYPE.REDIRECT) {
|
|
598
599
|
this.validity.reachable = true;
|
|
599
600
|
return (0, i18n_1.t)('errors.urlRedirect');
|
|
600
601
|
}
|
|
601
|
-
else if (
|
|
602
|
+
else if (inquirer_common_1.ErrorHandler.getErrorType(status) === inquirer_common_1.ERROR_TYPE.CONNECTION) {
|
|
602
603
|
this.validity.reachable = false;
|
|
603
|
-
return (
|
|
604
|
+
return (inquirer_common_1.ErrorHandler.getErrorMsgFromType(inquirer_common_1.ERROR_TYPE.CONNECTION, (0, i18n_1.t)('texts.httpStatus', { httpStatus: status })) ?? false);
|
|
604
605
|
}
|
|
605
|
-
else if (
|
|
606
|
+
else if (inquirer_common_1.ErrorHandler.getErrorType(status) === inquirer_common_1.ERROR_TYPE.BAD_REQUEST) {
|
|
606
607
|
this.validity.reachable = true;
|
|
607
|
-
return (
|
|
608
|
+
return (inquirer_common_1.ErrorHandler.getErrorMsgFromType(inquirer_common_1.ERROR_TYPE.BAD_REQUEST, (0, i18n_1.t)('texts.httpStatus', { httpStatus: status })) ?? false);
|
|
608
609
|
}
|
|
609
|
-
else if (
|
|
610
|
+
else if (inquirer_common_1.ErrorHandler.getErrorType(status) === inquirer_common_1.ERROR_TYPE.BAD_GATEWAY) {
|
|
610
611
|
this.validity.reachable = false;
|
|
611
|
-
return (
|
|
612
|
+
return (inquirer_common_1.ErrorHandler.getErrorMsgFromType(inquirer_common_1.ERROR_TYPE.BAD_GATEWAY, (0, i18n_1.t)('texts.httpStatus', { httpStatus: status })) ?? false);
|
|
612
613
|
}
|
|
613
614
|
this.validity.reachable = true;
|
|
614
|
-
return (
|
|
615
|
+
return (inquirer_common_1.ErrorHandler.getErrorMsgFromType(inquirer_common_1.ErrorHandler.getErrorType(status), (0, i18n_1.t)('texts.httpStatus', { httpStatus: status })) ?? true);
|
|
615
616
|
}
|
|
616
617
|
/**
|
|
617
618
|
* Is a string nil or whitespace only.
|
|
@@ -663,8 +664,8 @@ class ConnectionValidator {
|
|
|
663
664
|
if (client) {
|
|
664
665
|
url.searchParams.append(types_1.SAP_CLIENT_KEY, client);
|
|
665
666
|
}
|
|
666
|
-
const authError =
|
|
667
|
-
|
|
667
|
+
const authError = inquirer_common_1.ErrorHandler.getErrorType(await this.checkUrl(url, undefined, undefined, { ignoreCertError })) ===
|
|
668
|
+
inquirer_common_1.ERROR_TYPE.AUTH;
|
|
668
669
|
// Only if we get the specific auth error so we know that auth is required, otherwise we cannot determine so leave as undefined
|
|
669
670
|
if (authError) {
|
|
670
671
|
this.validity.authRequired = true;
|
|
@@ -718,7 +719,7 @@ class ConnectionValidator {
|
|
|
718
719
|
return { valResult: true };
|
|
719
720
|
}
|
|
720
721
|
else if (this.validity.authenticated === false) {
|
|
721
|
-
return { valResult: (0, i18n_1.t)('errors.authenticationFailed'), errorType:
|
|
722
|
+
return { valResult: (0, i18n_1.t)('errors.authenticationFailed'), errorType: inquirer_common_1.ERROR_TYPE.AUTH };
|
|
722
723
|
}
|
|
723
724
|
}
|
|
724
725
|
return { valResult };
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getLocalCapProjectPrompts = getLocalCapProjectPrompts;
|
|
4
4
|
const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
|
|
5
5
|
const project_access_1 = require("@sap-ux/project-access");
|
|
6
|
+
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
6
7
|
const i18n_1 = require("../../../i18n");
|
|
7
8
|
const types_1 = require("../../../types");
|
|
8
9
|
const utils_1 = require("../../../utils");
|
|
@@ -140,7 +141,7 @@ function getLocalCapProjectPrompts(promptOptions) {
|
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
143
|
];
|
|
143
|
-
if ((0, utils_1.
|
|
144
|
+
if ((0, utils_1.getPromptHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli) {
|
|
144
145
|
prompts.push({
|
|
145
146
|
when: async (answers) => {
|
|
146
147
|
if (answers?.capService) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ServiceInstanceInfo } from '@sap/cf-tools';
|
|
2
2
|
import type { Question } from 'inquirer';
|
|
3
3
|
import { type OdataServiceAnswers, type OdataServicePromptOptions } from '../../../../types';
|
|
4
4
|
import { ConnectionValidator } from '../../../connectionValidator';
|
|
@@ -5,22 +5,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getAbapOnBTPSystemQuestions = getAbapOnBTPSystemQuestions;
|
|
7
7
|
exports.getCFDiscoverPrompts = getCFDiscoverPrompts;
|
|
8
|
+
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
8
9
|
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
9
10
|
const cf_tools_1 = require("@sap/cf-tools");
|
|
10
|
-
const error_handler_1 = require("../../../../error-handler/error-handler");
|
|
11
11
|
const i18n_1 = require("../../../../i18n");
|
|
12
|
-
const types_1 = require("../../../../types");
|
|
13
12
|
const utils_1 = require("../../../../utils");
|
|
14
13
|
const connectionValidator_1 = require("../../../connectionValidator");
|
|
15
14
|
const logger_helper_1 = __importDefault(require("../../../logger-helper"));
|
|
16
15
|
const prompt_helpers_1 = require("../../../prompt-helpers");
|
|
17
16
|
const questions_1 = require("../new-system/questions");
|
|
18
|
-
const
|
|
19
|
-
const validators_1 = require("../validators");
|
|
20
|
-
const cf_helper_1 = require("./cf-helper");
|
|
17
|
+
const types_1 = require("../new-system/types");
|
|
21
18
|
const service_selection_1 = require("../service-selection");
|
|
19
|
+
const validators_1 = require("../validators");
|
|
22
20
|
const abapOnBtpPromptNamespace = 'abapOnBtp';
|
|
23
|
-
const systemUrlPromptName = `${abapOnBtpPromptNamespace}:${
|
|
21
|
+
const systemUrlPromptName = `${abapOnBtpPromptNamespace}:${types_1.newSystemPromptNames.newSystemUrl}`;
|
|
24
22
|
const cliCfAbapServicePromptName = 'cliCfAbapService';
|
|
25
23
|
const abapOnBtpPromptNames = {
|
|
26
24
|
'abapOnBtpAuthType': 'abapOnBtpAuthType',
|
|
@@ -133,10 +131,10 @@ function getCFDiscoverPrompts(connectionValidator) {
|
|
|
133
131
|
applyDefaultWhenDirty: true
|
|
134
132
|
},
|
|
135
133
|
choices: async () => {
|
|
136
|
-
choices = await (0,
|
|
134
|
+
choices = await (0, inquirer_common_1.getCFAbapInstanceChoices)(prompt_helpers_1.errorHandler);
|
|
137
135
|
// Cannot continue if no ABAP environments are found on Yo CLI
|
|
138
136
|
if (choices.length === 0) {
|
|
139
|
-
if ((0, utils_1.
|
|
137
|
+
if ((0, utils_1.getPromptHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli) {
|
|
140
138
|
throw new Error((0, i18n_1.t)('errors.abapEnvsUnavailable'));
|
|
141
139
|
}
|
|
142
140
|
}
|
|
@@ -149,7 +147,7 @@ function getCFDiscoverPrompts(connectionValidator) {
|
|
|
149
147
|
return await validateServiceInfo(abapService, connectionValidator);
|
|
150
148
|
}
|
|
151
149
|
const errorType = prompt_helpers_1.errorHandler.getCurrentErrorType();
|
|
152
|
-
if (errorType ===
|
|
150
|
+
if (errorType === inquirer_common_1.ERROR_TYPE.NO_ABAP_ENVS) {
|
|
153
151
|
const errorMsg = prompt_helpers_1.errorHandler.getErrorMsg(true);
|
|
154
152
|
const seeLogMsg = (0, i18n_1.t)('texts.seeLogForDetails');
|
|
155
153
|
return `${errorMsg} ${seeLogMsg}`;
|
|
@@ -159,7 +157,7 @@ function getCFDiscoverPrompts(connectionValidator) {
|
|
|
159
157
|
}
|
|
160
158
|
];
|
|
161
159
|
// Only for CLI use as `list` prompt validation does not run on CLI
|
|
162
|
-
if ((0, utils_1.
|
|
160
|
+
if ((0, utils_1.getPromptHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli) {
|
|
163
161
|
questions.push({
|
|
164
162
|
when: async (answers) => {
|
|
165
163
|
const abapService = answers?.[abapOnBtpPromptNames.cloudFoundryAbapSystem];
|
|
@@ -7,8 +7,8 @@ export declare enum BasicCredentialsPromptNames {
|
|
|
7
7
|
/**
|
|
8
8
|
* Re-usable credentials prompts for connection to systems using basic auth.
|
|
9
9
|
*
|
|
10
|
-
* @param connectionValidator
|
|
11
|
-
* @param promptNamespace
|
|
10
|
+
* @param connectionValidator the connection validator to be used for the credentials validation
|
|
11
|
+
* @param promptNamespace the namespace to be used for the prompts when used multiple times in the same prompt set
|
|
12
12
|
* @param sapClient
|
|
13
13
|
* @param sapClient.sapClient the sapClient value to be used along with the credentials validation
|
|
14
14
|
* @param sapClient.isValid validation of credentials is deferred until a valid sapClient is provided or undefined
|
|
@@ -14,8 +14,8 @@ var BasicCredentialsPromptNames;
|
|
|
14
14
|
/**
|
|
15
15
|
* Re-usable credentials prompts for connection to systems using basic auth.
|
|
16
16
|
*
|
|
17
|
-
* @param connectionValidator
|
|
18
|
-
* @param promptNamespace
|
|
17
|
+
* @param connectionValidator the connection validator to be used for the credentials validation
|
|
18
|
+
* @param promptNamespace the namespace to be used for the prompts when used multiple times in the same prompt set
|
|
19
19
|
* @param sapClient
|
|
20
20
|
* @param sapClient.sapClient the sapClient value to be used along with the credentials validation
|
|
21
21
|
* @param sapClient.isValid validation of credentials is deferred until a valid sapClient is provided or undefined
|
|
@@ -4,9 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getSystemServiceQuestion = getSystemServiceQuestion;
|
|
7
|
+
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
7
8
|
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
8
9
|
const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
|
|
9
|
-
const error_handler_1 = require("../../../../error-handler/error-handler");
|
|
10
10
|
const i18n_1 = require("../../../../i18n");
|
|
11
11
|
const types_1 = require("../../../../types");
|
|
12
12
|
const utils_1 = require("../../../../utils");
|
|
@@ -92,7 +92,7 @@ function getSystemServiceQuestion(connectValidator, promptNamespace, promptOptio
|
|
|
92
92
|
}
|
|
93
93
|
// if no choices are available and an error is present, return the error message
|
|
94
94
|
if (serviceChoices.length === 0 && prompt_helpers_1.errorHandler.hasError()) {
|
|
95
|
-
return
|
|
95
|
+
return inquirer_common_1.ErrorHandler.getHelpForError(inquirer_common_1.ERROR_TYPE.SERVICES_UNAVAILABLE) ?? false;
|
|
96
96
|
}
|
|
97
97
|
// Dont re-request the same service details
|
|
98
98
|
if (serviceAnswer && previousService?.servicePath !== serviceAnswer.servicePath) {
|
|
@@ -104,7 +104,7 @@ function getSystemServiceQuestion(connectValidator, promptNamespace, promptOptio
|
|
|
104
104
|
};
|
|
105
105
|
const questions = [systemServiceQuestion];
|
|
106
106
|
// Only for CLI use as `list` prompt validation does not run on CLI unless autocomplete plugin is used
|
|
107
|
-
if ((0, utils_1.
|
|
107
|
+
if ((0, utils_1.getPromptHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli && !promptOptions?.serviceSelection?.useAutoComplete) {
|
|
108
108
|
questions.push({
|
|
109
109
|
when: async (answers) => {
|
|
110
110
|
const selectedService = answers?.[`${promptNamespace}:${types_1.promptNames.serviceSelection}`];
|
|
@@ -116,7 +116,7 @@ function getSystemServiceQuestion(connectValidator, promptNamespace, promptOptio
|
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
if (serviceChoices.length === 0 && prompt_helpers_1.errorHandler.hasError()) {
|
|
119
|
-
const noServicesError =
|
|
119
|
+
const noServicesError = inquirer_common_1.ErrorHandler.getHelpForError(inquirer_common_1.ERROR_TYPE.SERVICES_UNAVAILABLE).toString();
|
|
120
120
|
throw new Error(noServicesError);
|
|
121
121
|
}
|
|
122
122
|
return false;
|
|
@@ -46,7 +46,7 @@ export declare function getServiceType(servicePath: string, serviceType: string
|
|
|
46
46
|
*
|
|
47
47
|
* @param service the specific service to get details for
|
|
48
48
|
* @param connectionValidator a reference to the connection validator which has an active connection to the backend
|
|
49
|
-
* @param requiredOdataVersion
|
|
49
|
+
* @param requiredOdataVersion the required OData version used to validate the service
|
|
50
50
|
* @returns true if successful, setting the PromptState.odataService properties, or an error message indicating why the service details could not be retrieved.
|
|
51
51
|
*/
|
|
52
52
|
export declare function getServiceDetails(service: ServiceAnswer, connectionValidator: ConnectionValidator, requiredOdataVersion?: OdataVersion): Promise<string | boolean>;
|
|
@@ -13,6 +13,7 @@ exports.getSelectedServiceMessage = getSelectedServiceMessage;
|
|
|
13
13
|
const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
|
|
14
14
|
const axios_extension_1 = require("@sap-ux/axios-extension");
|
|
15
15
|
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
16
|
+
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
16
17
|
const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
|
|
17
18
|
const i18n_1 = require("../../../../i18n");
|
|
18
19
|
const utils_1 = require("../../../../utils");
|
|
@@ -63,7 +64,7 @@ const createServiceChoices = (serviceInfos) => {
|
|
|
63
64
|
* Logs the catalog request errors using the error handler.
|
|
64
65
|
*
|
|
65
66
|
* @param requestErrors catalog request errors, keyed by the OData version of the catalog service, with the error, status code number or error message as the value
|
|
66
|
-
* @param numOfRequests
|
|
67
|
+
* @param numOfRequests the number of catalog service requests made
|
|
67
68
|
*/
|
|
68
69
|
function logServiceCatalogErrorsForHelp(requestErrors, numOfRequests) {
|
|
69
70
|
const catalogRequesErrors = Object.values(requestErrors);
|
|
@@ -128,9 +129,9 @@ async function getServiceChoices(catalogs) {
|
|
|
128
129
|
function sendDestinationServiceSuccessTelemetryEvent(destination) {
|
|
129
130
|
// May return undefined if the same event was already sent within some time frame
|
|
130
131
|
const telemetryData = fiori_generator_shared_1.TelemetryHelper.createTelemetryData({
|
|
131
|
-
destODataType: (0,
|
|
132
|
+
destODataType: (0, inquirer_common_1.getTelemPropertyDestinationType)(destination)
|
|
132
133
|
}) ?? {};
|
|
133
|
-
(0,
|
|
134
|
+
(0, inquirer_common_1.sendTelemetryEvent)(exports.telemEventBASServiceSuccess, telemetryData);
|
|
134
135
|
}
|
|
135
136
|
/**
|
|
136
137
|
* Gets the service metadata and annotations for the specified service path.
|
|
@@ -188,7 +189,7 @@ async function getServiceType(servicePath, serviceType, catalog) {
|
|
|
188
189
|
*
|
|
189
190
|
* @param service the specific service to get details for
|
|
190
191
|
* @param connectionValidator a reference to the connection validator which has an active connection to the backend
|
|
191
|
-
* @param requiredOdataVersion
|
|
192
|
+
* @param requiredOdataVersion the required OData version used to validate the service
|
|
192
193
|
* @returns true if successful, setting the PromptState.odataService properties, or an error message indicating why the service details could not be retrieved.
|
|
193
194
|
*/
|
|
194
195
|
async function getServiceDetails(service, connectionValidator, requiredOdataVersion) {
|
|
@@ -36,8 +36,8 @@ export declare function getBackendSystemDisplayName(system: BackendSystem): stri
|
|
|
36
36
|
/**
|
|
37
37
|
* Creates a list of choices for the system selection prompt using destinations or stored backend systems, depending on the environment.
|
|
38
38
|
*
|
|
39
|
-
* @param destinationFilters
|
|
40
|
-
* @param includeCloudFoundryAbapEnvChoice
|
|
39
|
+
* @param destinationFilters the filters to apply to the destination choices
|
|
40
|
+
* @param includeCloudFoundryAbapEnvChoice whether to include the Cloud Foundry ABAP environment choice in the list
|
|
41
41
|
* @returns a list of choices for the system selection prompt
|
|
42
42
|
*/
|
|
43
43
|
export declare function createSystemChoices(destinationFilters?: Partial<DestinationFilters>, includeCloudFoundryAbapEnvChoice?: boolean): Promise<ListChoiceOptions<SystemSelectionAnswers>[]>;
|
|
@@ -9,7 +9,7 @@ exports.getBackendSystemDisplayName = getBackendSystemDisplayName;
|
|
|
9
9
|
exports.createSystemChoices = createSystemChoices;
|
|
10
10
|
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
11
11
|
const store_1 = require("@sap-ux/store");
|
|
12
|
-
const
|
|
12
|
+
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
13
13
|
const i18n_1 = require("../../../../i18n");
|
|
14
14
|
const utils_1 = require("../../../../utils");
|
|
15
15
|
const logger_helper_1 = __importDefault(require("../../../logger-helper"));
|
|
@@ -47,7 +47,7 @@ async function connectWithBackendSystem(backendSystem, connectionValidator, requ
|
|
|
47
47
|
}));
|
|
48
48
|
// If authentication failed with existing credentials the user will be prompted to enter new credentials.
|
|
49
49
|
// We log the error in case there is another issue (unresolveable) with the stored backend configuration.
|
|
50
|
-
if (errorType ===
|
|
50
|
+
if (errorType === inquirer_common_1.ERROR_TYPE.AUTH && backendSystem.username && backendSystem.password) {
|
|
51
51
|
logger_helper_1.default.logger.error((0, i18n_1.t)('errors.storedSystemConnectionError', { systemName: backendSystem.name, error: connectValResult }));
|
|
52
52
|
return true;
|
|
53
53
|
}
|
|
@@ -75,7 +75,7 @@ async function connectWithBackendSystem(backendSystem, connectionValidator, requ
|
|
|
75
75
|
async function connectWithDestination(destination, connectionValidator, requiredOdataVersion, addServicePath) {
|
|
76
76
|
const { valResult: connectValResult, errorType } = await connectionValidator.validateDestination(destination, (0, utils_1.convertODataVersionType)(requiredOdataVersion), addServicePath);
|
|
77
77
|
// If authentication failed with an auth error, and the system connection auth type is basic, we will defer validation to the credentials prompt.
|
|
78
|
-
if (errorType ===
|
|
78
|
+
if (errorType === inquirer_common_1.ERROR_TYPE.AUTH && connectionValidator.systemAuthType === 'basic') {
|
|
79
79
|
logger_helper_1.default.logger.error((0, i18n_1.t)('errors.destination.authError', { systemName: destination.Name, error: connectValResult }));
|
|
80
80
|
return true;
|
|
81
81
|
}
|
|
@@ -109,8 +109,8 @@ function getBackendSystemDisplayName(system) {
|
|
|
109
109
|
/**
|
|
110
110
|
* Matches the destination against the provided filters. Returns true if the destination matches any filters, false otherwise.
|
|
111
111
|
*
|
|
112
|
-
* @param destination
|
|
113
|
-
* @param filters
|
|
112
|
+
* @param destination the destination to match against the filters
|
|
113
|
+
* @param filters the filters to match against
|
|
114
114
|
* @returns true if the destination matches any filters, false otherwise
|
|
115
115
|
*/
|
|
116
116
|
function matchesFilters(destination, filters) {
|
|
@@ -135,8 +135,8 @@ function matchesFilters(destination, filters) {
|
|
|
135
135
|
/**
|
|
136
136
|
* Creates a list of choices for the system selection prompt using destinations or stored backend systems, depending on the environment.
|
|
137
137
|
*
|
|
138
|
-
* @param destinationFilters
|
|
139
|
-
* @param includeCloudFoundryAbapEnvChoice
|
|
138
|
+
* @param destinationFilters the filters to apply to the destination choices
|
|
139
|
+
* @param includeCloudFoundryAbapEnvChoice whether to include the Cloud Foundry ABAP environment choice in the list
|
|
140
140
|
* @returns a list of choices for the system selection prompt
|
|
141
141
|
*/
|
|
142
142
|
async function createSystemChoices(destinationFilters, includeCloudFoundryAbapEnvChoice = false) {
|
|
@@ -32,7 +32,7 @@ export declare function getSystemSelectionQuestions(promptOptions?: OdataService
|
|
|
32
32
|
* Additional destination attribute filters may be provided.
|
|
33
33
|
*
|
|
34
34
|
* @param connectionValidator A reference to the active connection validator, used to validate the service selection and retrieve service details.
|
|
35
|
-
* @param promptOptions
|
|
35
|
+
* @param promptOptions prompt options that may be used to customize the questions
|
|
36
36
|
* @returns a list of existing systems
|
|
37
37
|
*/
|
|
38
38
|
export declare function getSystemConnectionQuestions(connectionValidator: ConnectionValidator, promptOptions?: OdataServicePromptOptions): Promise<Question<SystemSelectionAnswers>[]>;
|
|
@@ -19,6 +19,7 @@ const questions_2 = require("../new-system/questions");
|
|
|
19
19
|
const questions_3 = require("../service-selection/questions");
|
|
20
20
|
const validators_1 = require("../validators");
|
|
21
21
|
const prompt_helpers_1 = require("./prompt-helpers");
|
|
22
|
+
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
22
23
|
// New system choice value is a hard to guess string to avoid conflicts with existing system names or user named systems
|
|
23
24
|
// since it will be used as a new system value in the system selection prompt.
|
|
24
25
|
exports.newSystemChoiceValue = '!@£*&937newSystem*X~qy^';
|
|
@@ -32,9 +33,9 @@ const systemSelectionPromptNames = {
|
|
|
32
33
|
/**
|
|
33
34
|
* Validates the system selection, connecting to the selected system and validating the connection.
|
|
34
35
|
*
|
|
35
|
-
* @param systemSelection
|
|
36
|
-
* @param connectionValidator
|
|
37
|
-
* @param requiredOdataVersion
|
|
36
|
+
* @param systemSelection the selected system to validate
|
|
37
|
+
* @param connectionValidator the active connection validator to use for the connection attempt
|
|
38
|
+
* @param requiredOdataVersion the required OData version for the selected system, only the specified version will be used to request a service catalog
|
|
38
39
|
* @returns the validation result of the selected system connection attempt
|
|
39
40
|
*/
|
|
40
41
|
async function validateSystemSelection(systemSelection, connectionValidator, requiredOdataVersion) {
|
|
@@ -83,7 +84,7 @@ async function getSystemSelectionQuestions(promptOptions) {
|
|
|
83
84
|
* Additional destination attribute filters may be provided.
|
|
84
85
|
*
|
|
85
86
|
* @param connectionValidator A reference to the active connection validator, used to validate the service selection and retrieve service details.
|
|
86
|
-
* @param promptOptions
|
|
87
|
+
* @param promptOptions prompt options that may be used to customize the questions
|
|
87
88
|
* @returns a list of existing systems
|
|
88
89
|
*/
|
|
89
90
|
async function getSystemConnectionQuestions(connectionValidator, promptOptions) {
|
|
@@ -156,7 +157,7 @@ async function getSystemConnectionQuestions(connectionValidator, promptOptions)
|
|
|
156
157
|
questions.push(servicePathPrompt);
|
|
157
158
|
}
|
|
158
159
|
// Only for CLI use as `list` prompt validation does not run on CLI unless autocomplete plugin is used
|
|
159
|
-
if ((0, utils_1.
|
|
160
|
+
if ((0, utils_1.getPromptHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli && !promptOptions?.systemSelection?.useAutoComplete) {
|
|
160
161
|
questions.push({
|
|
161
162
|
when: async (answers) => {
|
|
162
163
|
const selectedSystem = answers?.[types_1.promptNames.systemSelection];
|
|
@@ -12,6 +12,7 @@ const connectionValidator_1 = require("../../connectionValidator");
|
|
|
12
12
|
const logger_helper_1 = __importDefault(require("../../logger-helper"));
|
|
13
13
|
const types_2 = require("./types");
|
|
14
14
|
const validators_1 = require("./validators");
|
|
15
|
+
const fiori_generator_shared_1 = require("@sap-ux/fiori-generator-shared");
|
|
15
16
|
/**
|
|
16
17
|
* Prompt for the service URL.
|
|
17
18
|
*
|
|
@@ -207,7 +208,7 @@ function getServiceUrlQuestions({ serviceUrl: serviceUrlOpts, serviceUrlPassword
|
|
|
207
208
|
getServiceUrlPrompt(connectValidator, requiredVersion),
|
|
208
209
|
getIgnoreCertErrorsPrompt(connectValidator, requiredVersion)
|
|
209
210
|
];
|
|
210
|
-
if ((0, utils_1.
|
|
211
|
+
if ((0, utils_1.getPromptHostEnvironment)() === fiori_generator_shared_1.hostEnvironment.cli) {
|
|
211
212
|
questions.push(getCliIgnoreCertValidatePrompt(connectValidator, requiredVersion));
|
|
212
213
|
}
|
|
213
214
|
questions.push(getUsernamePrompt(connectValidator), getPasswordPrompt(connectValidator, requiredVersion));
|
|
@@ -5,7 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.validateService = validateService;
|
|
7
7
|
const axios_extension_1 = require("@sap-ux/axios-extension");
|
|
8
|
-
const
|
|
8
|
+
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
9
9
|
const i18n_1 = require("../../../i18n");
|
|
10
10
|
const types_1 = require("../../../types");
|
|
11
11
|
const utils_1 = require("../../../utils");
|
|
@@ -68,9 +68,9 @@ async function validateService(url, { odataService, axiosConfig }, requiredVersi
|
|
|
68
68
|
catch (error) {
|
|
69
69
|
delete utils_1.PromptState.odataService.metadata;
|
|
70
70
|
// Provide a more specific error message if the metadata service URL is not found
|
|
71
|
-
if (
|
|
71
|
+
if (inquirer_common_1.ErrorHandler.getErrorType(error) === inquirer_common_1.ERROR_TYPE.NOT_FOUND) {
|
|
72
72
|
// No metadata implies not a valid odata service
|
|
73
|
-
return
|
|
73
|
+
return inquirer_common_1.ErrorHandler.getErrorMsgFromType(inquirer_common_1.ERROR_TYPE.ODATA_URL_NOT_FOUND) ?? false;
|
|
74
74
|
}
|
|
75
75
|
return prompt_helpers_1.errorHandler.logErrorMsgs(error);
|
|
76
76
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ListChoiceOptions } from 'inquirer';
|
|
2
|
-
import { ErrorHandler } from '
|
|
2
|
+
import { ErrorHandler } from '@sap-ux/inquirer-common';
|
|
3
3
|
import { type DatasourceTypePromptOptions } from '../types';
|
|
4
4
|
export declare const errorHandler: ErrorHandler;
|
|
5
5
|
/**
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.errorHandler = void 0;
|
|
4
4
|
exports.getDatasourceTypeChoices = getDatasourceTypeChoices;
|
|
5
|
-
const
|
|
5
|
+
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
6
6
|
const i18n_1 = require("../i18n");
|
|
7
7
|
const types_1 = require("../types");
|
|
8
8
|
// Error handling is a cross-cutting concern, a single instance is required
|
|
9
|
-
exports.errorHandler = new
|
|
9
|
+
exports.errorHandler = new inquirer_common_1.ErrorHandler();
|
|
10
10
|
/**
|
|
11
11
|
* Get the datasource type choices.
|
|
12
12
|
*
|