@sap-ux/odata-service-inquirer 0.6.0 → 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/index.d.ts +1 -1
- package/dist/index.js +9 -6
- package/dist/prompts/connectionValidator.d.ts +1 -1
- package/dist/prompts/connectionValidator.js +25 -25
- 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.js +3 -2
- package/dist/prompts/datasources/sap-system/system-selection/prompt-helpers.js +3 -3
- package/dist/prompts/datasources/sap-system/system-selection/questions.js +2 -1
- 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 +6 -5
- 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/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
|
*/
|
|
@@ -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.
|
|
@@ -360,8 +360,8 @@ class ConnectionValidator {
|
|
|
360
360
|
if (!statusCode) {
|
|
361
361
|
return false;
|
|
362
362
|
}
|
|
363
|
-
const errorType =
|
|
364
|
-
return errorType ===
|
|
363
|
+
const errorType = inquirer_common_1.ErrorHandler.getErrorType(statusCode);
|
|
364
|
+
return errorType === inquirer_common_1.ERROR_TYPE.NOT_FOUND || errorType === inquirer_common_1.ERROR_TYPE.AUTH;
|
|
365
365
|
}
|
|
366
366
|
/**
|
|
367
367
|
* Callback for when the Abap cloud system refresh token changes.
|
|
@@ -458,7 +458,7 @@ class ConnectionValidator {
|
|
|
458
458
|
// Return a more helpful error message
|
|
459
459
|
return {
|
|
460
460
|
valResult: prompt_helpers_1.errorHandler.getValidationErrorHelp(error, false, destination) ?? errorLog,
|
|
461
|
-
errorType: prompt_helpers_1.errorHandler.getCurrentErrorType() ??
|
|
461
|
+
errorType: prompt_helpers_1.errorHandler.getCurrentErrorType() ?? inquirer_common_1.ERROR_TYPE.DESTINATION_CONNECTION_ERROR
|
|
462
462
|
};
|
|
463
463
|
}
|
|
464
464
|
}
|
|
@@ -489,13 +489,13 @@ class ConnectionValidator {
|
|
|
489
489
|
const errorLog = prompt_helpers_1.errorHandler.logErrorMsgs(status);
|
|
490
490
|
return {
|
|
491
491
|
valResult: prompt_helpers_1.errorHandler.getValidationErrorHelp(status, false, destination) ?? errorLog,
|
|
492
|
-
errorType: prompt_helpers_1.errorHandler.getCurrentErrorType() ??
|
|
492
|
+
errorType: prompt_helpers_1.errorHandler.getCurrentErrorType() ?? inquirer_common_1.ERROR_TYPE.DESTINATION_CONNECTION_ERROR
|
|
493
493
|
};
|
|
494
494
|
}
|
|
495
495
|
if (this.validity.authRequired) {
|
|
496
496
|
return {
|
|
497
|
-
valResult:
|
|
498
|
-
errorType:
|
|
497
|
+
valResult: inquirer_common_1.ErrorHandler.getErrorMsgFromType(inquirer_common_1.ERROR_TYPE.AUTH),
|
|
498
|
+
errorType: inquirer_common_1.ERROR_TYPE.AUTH
|
|
499
499
|
};
|
|
500
500
|
}
|
|
501
501
|
return {
|
|
@@ -558,7 +558,7 @@ class ConnectionValidator {
|
|
|
558
558
|
catch (error) {
|
|
559
559
|
this.resetValidity();
|
|
560
560
|
// More helpful context specific error
|
|
561
|
-
if (
|
|
561
|
+
if (inquirer_common_1.ErrorHandler.getErrorType(error) === inquirer_common_1.ERROR_TYPE.CONNECTION) {
|
|
562
562
|
this.validity.reachable = false;
|
|
563
563
|
return prompt_helpers_1.errorHandler.logErrorMsgs((0, i18n_1.t)('errors.systemOrServiceUrlNotFound', { url: serviceUrl }));
|
|
564
564
|
}
|
|
@@ -578,40 +578,40 @@ class ConnectionValidator {
|
|
|
578
578
|
this.validity.authenticated = true;
|
|
579
579
|
return true;
|
|
580
580
|
}
|
|
581
|
-
else if (
|
|
581
|
+
else if (inquirer_common_1.ErrorHandler.getErrorType(status) === inquirer_common_1.ERROR_TYPE.NOT_FOUND) {
|
|
582
582
|
this.validity.reachable = false;
|
|
583
|
-
return
|
|
583
|
+
return inquirer_common_1.ErrorHandler.getErrorMsgFromType(inquirer_common_1.ERROR_TYPE.NOT_FOUND) ?? false;
|
|
584
584
|
}
|
|
585
|
-
else if (
|
|
585
|
+
else if (inquirer_common_1.ErrorHandler.isCertError(status)) {
|
|
586
586
|
this.validity.reachable = true;
|
|
587
|
-
this.validity.canSkipCertError = ignorableCertErrors.includes(
|
|
587
|
+
this.validity.canSkipCertError = ignorableCertErrors.includes(inquirer_common_1.ErrorHandler.getErrorType(status));
|
|
588
588
|
this.validity.authenticated = false;
|
|
589
589
|
return prompt_helpers_1.errorHandler.getValidationErrorHelp(status, false) ?? false;
|
|
590
590
|
}
|
|
591
|
-
else if (
|
|
591
|
+
else if (inquirer_common_1.ErrorHandler.getErrorType(status) === inquirer_common_1.ERROR_TYPE.AUTH) {
|
|
592
592
|
this.validity.reachable = true;
|
|
593
593
|
this.validity.authRequired = true;
|
|
594
594
|
this.validity.authenticated = false;
|
|
595
595
|
return true;
|
|
596
596
|
}
|
|
597
|
-
else if (
|
|
597
|
+
else if (inquirer_common_1.ErrorHandler.getErrorType(status) === inquirer_common_1.ERROR_TYPE.REDIRECT) {
|
|
598
598
|
this.validity.reachable = true;
|
|
599
599
|
return (0, i18n_1.t)('errors.urlRedirect');
|
|
600
600
|
}
|
|
601
|
-
else if (
|
|
601
|
+
else if (inquirer_common_1.ErrorHandler.getErrorType(status) === inquirer_common_1.ERROR_TYPE.CONNECTION) {
|
|
602
602
|
this.validity.reachable = false;
|
|
603
|
-
return (
|
|
603
|
+
return (inquirer_common_1.ErrorHandler.getErrorMsgFromType(inquirer_common_1.ERROR_TYPE.CONNECTION, (0, i18n_1.t)('texts.httpStatus', { httpStatus: status })) ?? false);
|
|
604
604
|
}
|
|
605
|
-
else if (
|
|
605
|
+
else if (inquirer_common_1.ErrorHandler.getErrorType(status) === inquirer_common_1.ERROR_TYPE.BAD_REQUEST) {
|
|
606
606
|
this.validity.reachable = true;
|
|
607
|
-
return (
|
|
607
|
+
return (inquirer_common_1.ErrorHandler.getErrorMsgFromType(inquirer_common_1.ERROR_TYPE.BAD_REQUEST, (0, i18n_1.t)('texts.httpStatus', { httpStatus: status })) ?? false);
|
|
608
608
|
}
|
|
609
|
-
else if (
|
|
609
|
+
else if (inquirer_common_1.ErrorHandler.getErrorType(status) === inquirer_common_1.ERROR_TYPE.BAD_GATEWAY) {
|
|
610
610
|
this.validity.reachable = false;
|
|
611
|
-
return (
|
|
611
|
+
return (inquirer_common_1.ErrorHandler.getErrorMsgFromType(inquirer_common_1.ERROR_TYPE.BAD_GATEWAY, (0, i18n_1.t)('texts.httpStatus', { httpStatus: status })) ?? false);
|
|
612
612
|
}
|
|
613
613
|
this.validity.reachable = true;
|
|
614
|
-
return (
|
|
614
|
+
return (inquirer_common_1.ErrorHandler.getErrorMsgFromType(inquirer_common_1.ErrorHandler.getErrorType(status), (0, i18n_1.t)('texts.httpStatus', { httpStatus: status })) ?? true);
|
|
615
615
|
}
|
|
616
616
|
/**
|
|
617
617
|
* Is a string nil or whitespace only.
|
|
@@ -663,8 +663,8 @@ class ConnectionValidator {
|
|
|
663
663
|
if (client) {
|
|
664
664
|
url.searchParams.append(types_1.SAP_CLIENT_KEY, client);
|
|
665
665
|
}
|
|
666
|
-
const authError =
|
|
667
|
-
|
|
666
|
+
const authError = inquirer_common_1.ErrorHandler.getErrorType(await this.checkUrl(url, undefined, undefined, { ignoreCertError })) ===
|
|
667
|
+
inquirer_common_1.ERROR_TYPE.AUTH;
|
|
668
668
|
// Only if we get the specific auth error so we know that auth is required, otherwise we cannot determine so leave as undefined
|
|
669
669
|
if (authError) {
|
|
670
670
|
this.validity.authRequired = true;
|
|
@@ -718,7 +718,7 @@ class ConnectionValidator {
|
|
|
718
718
|
return { valResult: true };
|
|
719
719
|
}
|
|
720
720
|
else if (this.validity.authenticated === false) {
|
|
721
|
-
return { valResult: (0, i18n_1.t)('errors.authenticationFailed'), errorType:
|
|
721
|
+
return { valResult: (0, i18n_1.t)('errors.authenticationFailed'), errorType: inquirer_common_1.ERROR_TYPE.AUTH };
|
|
722
722
|
}
|
|
723
723
|
}
|
|
724
724
|
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;
|
|
@@ -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");
|
|
@@ -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.
|
|
@@ -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
|
}
|
|
@@ -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^';
|
|
@@ -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
|
*
|
|
@@ -128,35 +128,18 @@
|
|
|
128
128
|
},
|
|
129
129
|
"errors": {
|
|
130
130
|
"destination": {
|
|
131
|
-
"
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
"notReachable": "The selected system is not reachable. System name: {{systemName}}, error: {{- error}}",
|
|
135
|
-
"misconfigured": "The destination is misconfigured. $t(errors.destination.missingPropMsg, {\"destinationProperty\": \"{{destinationProperty}}\" })",
|
|
136
|
-
"missingPropMsg": "The property: `{{destinationProperty}}` is missing.",
|
|
137
|
-
"httpConnectionError": "A connection error occurred with the selected destination. Http code: {{- code}}. See log for more details."
|
|
138
|
-
},
|
|
139
|
-
"cannotReadCapServiceMetadata": "An error occurred reading CAP service metadata: {{serviceName}}. See log for more details.",
|
|
131
|
+
"authError": "The selected system is returning an authentication error. System name: {{systemName}}, error: {{- error}}"
|
|
132
|
+
},
|
|
133
|
+
"cannotReadCapServiceMetadata": "An error occurred reading CAP service metadata: {{serviceName}}. $t(texts.seeLogForDetails)",
|
|
140
134
|
"capModelAndServicesLoadError": "An error occurred loading the CAP model and services. {{- error}}",
|
|
141
135
|
"capServiceUrlPathNotDefined": "An error occurred reading CAP service metadata: {{serviceName}}. CAP service property `urlPath` is not defined but is required.",
|
|
142
136
|
"unknownError": "An error occurred{{- error, addMsgWithColonFormatter}}",
|
|
143
|
-
"servicesUnavailable": "An error occurred retrieving service(s) for SAP System.",
|
|
144
|
-
"certificateError": "A certificate error has occurred: {{- error}}",
|
|
145
|
-
"urlCertValidationError": "The system URL is using {{certErrorReason}} security certificate.",
|
|
146
137
|
"authenticationFailed": "Authentication incorrect. {{error}}",
|
|
147
|
-
"authenticationTimeout": "Authorization was not verified within the allowed time. Please ensure you have authenticated using the associated browser window.",
|
|
148
138
|
"invalidUrl": "Invalid URL{{-input, addMsgWithColonFormatter}}",
|
|
149
139
|
"connectionError": "A connection error occurred, please ensure the target host is available on the network: {{- error}}",
|
|
150
|
-
"timeout": "A connection timeout error occurred: {{- error}}",
|
|
151
|
-
"serverReturnedAnError": "The server returned an error. {{errorDesc}}",
|
|
152
|
-
"serverUnableToCompleteRequest": "The server was unable to complete the request",
|
|
153
|
-
"catalogServiceNotActive": "Catalog service is not active",
|
|
154
140
|
"urlNotFound": "URL not found",
|
|
155
|
-
"odataServiceUrlNotFound": "The service URL you have provided is not a valid OData Service. Fiori applications require an OData service as the data source.",
|
|
156
141
|
"noServicesAvailable": "There are no V{{version}} OData services available from the selected system and the template you have chosen supports V{{version}} OData services only",
|
|
157
|
-
"redirectError": "A redirect response was received from the server",
|
|
158
142
|
"abapEnvsUnavailable": "ABAP environments unavailable",
|
|
159
|
-
"noSuchHostError": "No such host is known",
|
|
160
143
|
"systemOrServiceUrlNotFound": "Please verify the url: {{- url}}, target system configuration and network connectivity",
|
|
161
144
|
"urlRedirect": "The service URL is redirecting",
|
|
162
145
|
"certValidationRequired": "Certificate validation is required to continue.",
|
|
@@ -165,34 +148,18 @@
|
|
|
165
148
|
"serviceMetadataErrorUI": "$t(errors.serviceMetadataError, {\"servicePath\": \"{{- servicePath}}\" }). $t(texts.seeLogForDetails)",
|
|
166
149
|
"serviceMetadataErrorLog": "$t(errors.serviceMetadataError, {\"servicePath\": \"{{- servicePath}}\" }). {{error}}",
|
|
167
150
|
"serviceTypeRequestError": "Error retrieving service type: {{- error}}",
|
|
168
|
-
"noAbapEnvsInCFSpace": "No ABAP environments in CF space found.",
|
|
169
|
-
"abapEnvsCFDiscoveryFailed": "Discovering ABAP Environments failed. Please ensure you are logged into Cloud Foundry (see https://docs.cloudfoundry.org/cf-cli/getting-started.html#login).",
|
|
170
151
|
"abapServiceAuthenticationFailed": "ABAP environment authentication using UAA failed.",
|
|
171
152
|
"serviceCatalogRequest": "An error occurred requesting services from: {{- catalogRequestUri }} and entity set: {{entitySet}}. {{error}}",
|
|
172
153
|
"storedSystemConnectionError": "An error occurred while validating the stored system connection info. System name: {{-systemName}}, error: {{- error}}",
|
|
173
154
|
"noCatalogOrServiceAvailable": "No active system or OData service endpoint connection available to retrieve service(s).",
|
|
174
|
-
"
|
|
175
|
-
"allCatalogServiceRequestsFailed": "All catalog service requests failed for the selected system. OData version(s): V{{version}}.",
|
|
176
|
-
"internalServerError": "Internal server error{{-errorMsg, addMsgWithColonFormatter}}",
|
|
177
|
-
"badGateway": "Bad gateway{{- errorMsg, addMsgWithColonFormatter}}",
|
|
178
|
-
"badRequest": "Bad request{{- errorMsg, addMsgWithColonFormatter}}"
|
|
155
|
+
"allCatalogServiceRequestsFailed": "All catalog service requests failed for the selected system. OData version(s): V{{version}}."
|
|
179
156
|
},
|
|
180
157
|
"texts": {
|
|
181
|
-
"anExpiredCert": "an expired",
|
|
182
|
-
"aSelfSignedCert": "a self-signed",
|
|
183
|
-
"anUnknownOrInvalidCert": "an unknown or invalid",
|
|
184
|
-
"anUntrustedRootCert": "an untrusted root",
|
|
185
158
|
"suggestedSystemNameClient": ", client {{client}}",
|
|
186
159
|
"seeLogForDetails": "See log for more details.",
|
|
187
160
|
"forUserName": "(for user [{{username}}])",
|
|
188
161
|
"systemTypeBTP": "BTP",
|
|
189
162
|
"systemTypeS4HC": "S4HC",
|
|
190
163
|
"httpStatus": "http status {{httpStatus}}"
|
|
191
|
-
},
|
|
192
|
-
"guidedAnswers": {
|
|
193
|
-
"validationErrorHelpText": "Need help with this error?"
|
|
194
|
-
},
|
|
195
|
-
"telemetry": {
|
|
196
|
-
"unknownOsText": "Unknown"
|
|
197
164
|
}
|
|
198
165
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { IValidationLink } from '@sap-devx/yeoman-ui-types';
|
|
2
1
|
import type { Annotations, ServiceProvider } from '@sap-ux/axios-extension';
|
|
3
2
|
import type { Destination } from '@sap-ux/btp-utils';
|
|
4
3
|
import type { CommonPromptOptions, YUIQuestion } from '@sap-ux/inquirer-common';
|
|
@@ -270,40 +269,6 @@ export type OdataServiceUrlPasswordOptions = Pick<CommonPromptOptions, 'addition
|
|
|
270
269
|
type odataServiceInquirerPromptOptions = Record<promptNames.datasourceType, DatasourceTypePromptOptions> & Record<promptNames.metadataFilePath, MetadataPromptOptions> & Record<promptNames.capProject, CapProjectPromptOptions> & Record<promptNames.capService, CapServicePromptOptions> & Record<promptNames.serviceUrl, OdataServiceUrlPromptOptions> & Record<promptNames.serviceUrlPassword, OdataServiceUrlPasswordOptions> & Record<promptNames.serviceSelection, ServiceSelectionPromptOptions> & Record<promptNames.userSystemName, SystemNamePromptOptions> & Record<promptNames.systemSelection, SystemSelectionPromptOptions>;
|
|
271
270
|
export type OdataServiceQuestion = YUIQuestion<OdataServiceAnswers>;
|
|
272
271
|
export type OdataServicePromptOptions = Partial<odataServiceInquirerPromptOptions>;
|
|
273
|
-
/**
|
|
274
|
-
* Implementation of IValidationLink interface.
|
|
275
|
-
* Provides a toString() for serialization on CLI since IValidationLink rendering is only supported by YeomanUI.
|
|
276
|
-
*/
|
|
277
|
-
export declare class ValidationLink implements IValidationLink {
|
|
278
|
-
message: IValidationLink['message'];
|
|
279
|
-
link: IValidationLink['link'];
|
|
280
|
-
/**
|
|
281
|
-
* Constructor for ValidationLink.
|
|
282
|
-
*
|
|
283
|
-
* @param validationLink The validation link object to be used for serialization
|
|
284
|
-
*/
|
|
285
|
-
constructor(validationLink: IValidationLink);
|
|
286
|
-
/**
|
|
287
|
-
* Serialize the validation link object to a string.
|
|
288
|
-
*
|
|
289
|
-
* @returns The validation link object as a string
|
|
290
|
-
*/
|
|
291
|
-
toString(): string;
|
|
292
|
-
}
|
|
293
|
-
export declare const hostEnvironment: {
|
|
294
|
-
vscode: {
|
|
295
|
-
name: string;
|
|
296
|
-
technical: string;
|
|
297
|
-
};
|
|
298
|
-
bas: {
|
|
299
|
-
name: string;
|
|
300
|
-
technical: string;
|
|
301
|
-
};
|
|
302
|
-
cli: {
|
|
303
|
-
name: string;
|
|
304
|
-
technical: string;
|
|
305
|
-
};
|
|
306
|
-
};
|
|
307
272
|
export declare const SAP_CLIENT_KEY = "sap-client";
|
|
308
273
|
export {};
|
|
309
274
|
//# sourceMappingURL=types.d.ts.map
|