@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
package/dist/i18n.js
CHANGED
|
@@ -14,16 +14,28 @@ 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();
|
|
17
18
|
await i18next_1.default.init({
|
|
18
19
|
lng: 'en',
|
|
19
20
|
fallbackLng: 'en',
|
|
20
21
|
missingInterpolationHandler: () => '',
|
|
21
22
|
interpolation: {
|
|
22
|
-
format: function
|
|
23
|
-
|
|
23
|
+
format: function (value, format) {
|
|
24
|
+
// OData version formatter
|
|
25
|
+
if (format === 'odataVersionFormatter') {
|
|
26
|
+
return value ? ` V${value}` : '';
|
|
27
|
+
}
|
|
28
|
+
// If we have a value add a colon before outputting
|
|
29
|
+
if (format === 'addMsgWithColonFormatter') {
|
|
30
|
+
return value ? `: ${value}` : '';
|
|
31
|
+
}
|
|
32
|
+
return value;
|
|
24
33
|
}
|
|
25
34
|
}
|
|
26
|
-
}
|
|
35
|
+
});
|
|
36
|
+
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`);
|
|
27
39
|
}
|
|
28
40
|
/**
|
|
29
41
|
* 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,8 +2,8 @@ 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 '
|
|
6
|
-
import {
|
|
5
|
+
import { ERROR_TYPE, ErrorHandler } from '@sap-ux/inquirer-common';
|
|
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
|
/**
|
|
9
9
|
* Get the inquirer prompts for odata service.
|
|
@@ -31,5 +31,5 @@ declare function getPrompts(promptOptions?: OdataServicePromptOptions, logger?:
|
|
|
31
31
|
* @returns the prompt answers
|
|
32
32
|
*/
|
|
33
33
|
declare function prompt(adapter: InquirerAdapter, promptOptions?: OdataServicePromptOptions, logger?: Logger, enableGuidedAnswers?: boolean, telemetryClient?: ToolsSuiteTelemetryClient, isYUI?: boolean): Promise<OdataServiceAnswers>;
|
|
34
|
-
export { DatasourceType, ERROR_TYPE, ErrorHandler,
|
|
34
|
+
export { DatasourceType, ERROR_TYPE, ErrorHandler, getPrompts, OdataVersion, prompt, promptNames, SystemSelectionAnswerType, type CapRuntime, type CapService, type InquirerAdapter, type OdataServiceAnswers, type OdataServicePromptOptions, type SapSystemType };
|
|
35
35
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -3,19 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.promptNames = exports.
|
|
6
|
+
exports.promptNames = exports.OdataVersion = exports.ErrorHandler = exports.ERROR_TYPE = exports.DatasourceType = void 0;
|
|
7
7
|
exports.getPrompts = getPrompts;
|
|
8
8
|
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
|
-
const questions_1 = require("./prompts/datasources/sap-system/new-system/questions");
|
|
18
|
-
Object.defineProperty(exports, "newSystemChoiceValue", { enumerable: true, get: function () { return questions_1.newSystemChoiceValue; } });
|
|
19
17
|
const logger_helper_1 = __importDefault(require("./prompts/logger-helper"));
|
|
20
18
|
const types_1 = require("./types");
|
|
21
19
|
Object.defineProperty(exports, "DatasourceType", { enumerable: true, get: function () { return types_1.DatasourceType; } });
|
|
@@ -37,10 +35,13 @@ async function getPrompts(promptOptions, logger, enableGuidedAnswers = false, te
|
|
|
37
35
|
if (logger) {
|
|
38
36
|
logger_helper_1.default.logger = logger;
|
|
39
37
|
}
|
|
40
|
-
|
|
41
|
-
|
|
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';
|
|
42
43
|
utils_1.PromptState.isYUI = isYUI;
|
|
43
|
-
(0,
|
|
44
|
+
(0, inquirer_common_1.setTelemetryClient)(telemetryClient);
|
|
44
45
|
return {
|
|
45
46
|
prompts: await (0, prompts_1.getQuestions)(promptOptions),
|
|
46
47
|
// Return reference to derived answers object that will be populated with user responses (after prompting is complete)
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
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
|
+
import { type Destination } from '@sap-ux/btp-utils';
|
|
5
|
+
import { ERROR_TYPE } from '@sap-ux/inquirer-common';
|
|
4
6
|
/**
|
|
5
7
|
* Structure to store validity information about url to be validated.
|
|
6
8
|
*/
|
|
@@ -11,7 +13,7 @@ interface Validity {
|
|
|
11
13
|
authenticated?: boolean;
|
|
12
14
|
canSkipCertError?: boolean;
|
|
13
15
|
}
|
|
14
|
-
type ValidationResult = string | boolean | IValidationLink;
|
|
16
|
+
export type ValidationResult = string | boolean | IValidationLink;
|
|
15
17
|
export type SystemAuthType = 'serviceKey' | 'reentranceTicket' | 'basic' | 'unknown';
|
|
16
18
|
/**
|
|
17
19
|
* Class that can be used to determine the connectivity using a service url, system url, or service info (UAA Key details) or reentrance ticket.
|
|
@@ -23,6 +25,8 @@ export type SystemAuthType = 'serviceKey' | 'reentranceTicket' | 'basic' | 'unkn
|
|
|
23
25
|
export declare class ConnectionValidator {
|
|
24
26
|
readonly validity: Validity;
|
|
25
27
|
private _validatedUrl;
|
|
28
|
+
private _destinationUrl;
|
|
29
|
+
private _destination;
|
|
26
30
|
private _validatedClient;
|
|
27
31
|
private _odataService;
|
|
28
32
|
private _serviceProvider;
|
|
@@ -105,6 +109,18 @@ export declare class ConnectionValidator {
|
|
|
105
109
|
* @returns the refresh token
|
|
106
110
|
*/
|
|
107
111
|
get refreshToken(): string | undefined;
|
|
112
|
+
/**
|
|
113
|
+
* Get the full expanded destination url as defined in the destination configuration. This should not be used to connect from App Studio (use the .dest form).
|
|
114
|
+
*
|
|
115
|
+
* @returns the connected destination 'URL' attribute value
|
|
116
|
+
*/
|
|
117
|
+
get destinationUrl(): string | undefined;
|
|
118
|
+
/**
|
|
119
|
+
* Get the destination.
|
|
120
|
+
*
|
|
121
|
+
* @returns the connected destination 'URL' attribute value
|
|
122
|
+
*/
|
|
123
|
+
get destination(): Destination | undefined;
|
|
108
124
|
/**
|
|
109
125
|
* Get the connected system name. If previously set this will be used, otherwise the name is determined
|
|
110
126
|
* by the system auth type, or the validated url.
|
|
@@ -128,8 +144,9 @@ export declare class ConnectionValidator {
|
|
|
128
144
|
* @param options.isSystem if true, the url will be treated as a system url rather than a service url
|
|
129
145
|
* @param options.odataVersion if specified will restrict catalog requests to only the specified odata version
|
|
130
146
|
* @returns the status code or error returned by the connection attempt
|
|
147
|
+
* @throws an error if the connection attempt fails and the error is a 500 on App Studio or a non-axios error is caught
|
|
131
148
|
*/
|
|
132
|
-
private
|
|
149
|
+
private checkUrl;
|
|
133
150
|
/**
|
|
134
151
|
* Create the axios configuration object for the service or system connection.
|
|
135
152
|
*
|
|
@@ -147,7 +164,11 @@ export declare class ConnectionValidator {
|
|
|
147
164
|
* @param servicePath the service path without the origin
|
|
148
165
|
*/
|
|
149
166
|
private createOdataServiceConnection;
|
|
150
|
-
|
|
167
|
+
/**
|
|
168
|
+
*
|
|
169
|
+
* @param resetValidity
|
|
170
|
+
*/
|
|
171
|
+
resetConnectionState(resetValidity?: boolean): void;
|
|
151
172
|
/**
|
|
152
173
|
* Create the connection for a system url, the specified axios config or the specified service info.
|
|
153
174
|
*
|
|
@@ -156,6 +177,8 @@ export declare class ConnectionValidator {
|
|
|
156
177
|
* @param connectConfig.url the system url
|
|
157
178
|
* @param connectConfig.serviceInfo the service info
|
|
158
179
|
* @param connectConfig.odataVersion the odata version to restrict the catalog requests if only a specific version is required
|
|
180
|
+
* @param connectConfig.destination the destination to connect with
|
|
181
|
+
* @throws an error if the connection attempt fails, callers should handle the error
|
|
159
182
|
*/
|
|
160
183
|
private createSystemConnection;
|
|
161
184
|
/**
|
|
@@ -166,7 +189,7 @@ export declare class ConnectionValidator {
|
|
|
166
189
|
*/
|
|
167
190
|
private shouldAttemptV4Catalog;
|
|
168
191
|
/**
|
|
169
|
-
* Callback for when the refresh token changes.
|
|
192
|
+
* Callback for when the Abap cloud system refresh token changes.
|
|
170
193
|
*
|
|
171
194
|
* @param refreshToken the new refresh token
|
|
172
195
|
*/
|
|
@@ -181,14 +204,38 @@ export declare class ConnectionValidator {
|
|
|
181
204
|
private getAbapOnCloudServiceProvider;
|
|
182
205
|
/**
|
|
183
206
|
* Validate the system connectivity with the specified service info (containing UAA details).
|
|
207
|
+
* This will create a connection to the system, updating the service provider reference.
|
|
208
|
+
* The connected user name will be cached for later use.
|
|
184
209
|
*
|
|
185
210
|
* @param serviceInfo the service info containing the UAA details
|
|
186
211
|
* @param odataVersion the odata version to restrict the catalog requests if only a specific version is required
|
|
187
|
-
* @returns true if the system is reachable, false if not, or an error message string
|
|
212
|
+
* @returns true if the system is reachable and authenticated, if required, false if not, or an error message string
|
|
188
213
|
*/
|
|
189
214
|
validateServiceInfo(serviceInfo: ServiceInfo, odataVersion?: ODataVersion): Promise<ValidationResult>;
|
|
190
215
|
/**
|
|
191
|
-
*
|
|
216
|
+
* Validate the specified destination connectivity, determining if authentication is required or if the destination is misconfigured.
|
|
217
|
+
*
|
|
218
|
+
* @param destination the destination to validate
|
|
219
|
+
* @param odataVersion the odata version to restrict the catalog requests if only a specific version is required
|
|
220
|
+
* @param servicePath the service path to validate, if specified will be appended to the destination URL for validation, if not specified the destination url will be used
|
|
221
|
+
* @returns true if the system is reachable and authenticated, if required, false if not, or an error message string
|
|
222
|
+
*/
|
|
223
|
+
validateDestination(destination: Destination, odataVersion?: ODataVersion, servicePath?: string): Promise<{
|
|
224
|
+
valResult: ValidationResult;
|
|
225
|
+
errorType?: ERROR_TYPE;
|
|
226
|
+
}>;
|
|
227
|
+
/**
|
|
228
|
+
* Validate the connectivity to a destination odata service (for generic odata service destinations), determining, for example, if authentication is required.
|
|
229
|
+
*
|
|
230
|
+
* @param destination a destination that is a generic odata service destination
|
|
231
|
+
* @param servicePath additional service path to append to the destination URL
|
|
232
|
+
* @param requiredOdataVersion the required odata version, if specified will validate the odata service version satisfies the specified version
|
|
233
|
+
* @returns validation result and error type if validation fails
|
|
234
|
+
*/
|
|
235
|
+
private validateOdataServiceDestination;
|
|
236
|
+
/**
|
|
237
|
+
* Validates an odata service url format as well as its reachability. Note if this function returns true, this is only an indication that the system is reachable
|
|
238
|
+
* not that a connection has been established. The connection may require separate authentication or other steps (it may be reachable but a cert error was returned).
|
|
192
239
|
*
|
|
193
240
|
* @param serviceUrl the url to validate, may be a system or service url.
|
|
194
241
|
* Note that if systemAuthType is specified, the url will be treated as a system url (only the origin will be considered)
|
|
@@ -197,17 +244,18 @@ export declare class ConnectionValidator {
|
|
|
197
244
|
* @param options.forceReValidation force re-validation of the url
|
|
198
245
|
* @param options.isSystem if true, the url will be treated as a system url rather than a service url, this value is retained for subsequent calls
|
|
199
246
|
* @param options.odataVersion if specified will restrict catalog requests to only the specified odata version
|
|
247
|
+
* @param options.systemAuthType the system auth type used to create system connections, if not specified or `isSystem` is false or undefined, `basic` is assumed
|
|
200
248
|
* @returns true if the url is reachable, false if not, or an error message string
|
|
201
249
|
*/
|
|
202
|
-
validateUrl(serviceUrl: string, { ignoreCertError, forceReValidation, isSystem, odataVersion }?: {
|
|
250
|
+
validateUrl(serviceUrl: string, { ignoreCertError, forceReValidation, isSystem, odataVersion, systemAuthType }?: {
|
|
203
251
|
ignoreCertError?: boolean;
|
|
204
252
|
forceReValidation?: boolean;
|
|
205
253
|
isSystem?: boolean;
|
|
206
254
|
odataVersion?: ODataVersion;
|
|
255
|
+
systemAuthType?: SystemAuthType;
|
|
207
256
|
}): Promise<ValidationResult>;
|
|
208
257
|
/**
|
|
209
|
-
*
|
|
210
|
-
* Sets the instance validity state based on the status code.
|
|
258
|
+
* Sets the instance validity state based on the status code and returns true if the status code indicates that the URL was reachable.
|
|
211
259
|
*
|
|
212
260
|
* @param status a http request status code used to determine the validation result
|
|
213
261
|
* @returns true, if the status code indicates the url is reachable, false if not, or an error message string
|
|
@@ -229,7 +277,7 @@ export declare class ConnectionValidator {
|
|
|
229
277
|
private isUrlValidated;
|
|
230
278
|
/**
|
|
231
279
|
* Check whether basic auth is required for the given url, or for the previously validated url if none specified.
|
|
232
|
-
* This will also set the validity state for the url.
|
|
280
|
+
* This will also set the validity state for the url.
|
|
233
281
|
*
|
|
234
282
|
* @param urlString the url to validate, if not provided the previously validated url will be used
|
|
235
283
|
* @param client optional, sap client code, if not provided the previously validated client will be used
|
|
@@ -250,12 +298,15 @@ export declare class ConnectionValidator {
|
|
|
250
298
|
* @param options.odataVersion if specified will restrict catalog requests to only the specified odata version
|
|
251
299
|
* @returns true if the authentication is successful, false if not, or an error message string
|
|
252
300
|
*/
|
|
253
|
-
validateAuth(url: string, username
|
|
301
|
+
validateAuth(url: string, username?: string, password?: string, { ignoreCertError, sapClient, odataVersion, isSystem }?: {
|
|
254
302
|
ignoreCertError?: boolean;
|
|
255
303
|
odataVersion?: ODataVersion;
|
|
256
304
|
sapClient?: string;
|
|
257
305
|
isSystem?: boolean;
|
|
258
|
-
}): Promise<
|
|
306
|
+
}): Promise<{
|
|
307
|
+
valResult: ValidationResult;
|
|
308
|
+
errorType?: ERROR_TYPE;
|
|
309
|
+
}>;
|
|
259
310
|
/**
|
|
260
311
|
* Reset the validity state.
|
|
261
312
|
*/
|