@sap-ux/odata-service-inquirer 0.5.28 → 0.5.30

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.
Files changed (32) hide show
  1. package/dist/error-handler/error-handler.d.ts +2 -2
  2. package/dist/error-handler/error-handler.js +4 -4
  3. package/dist/index.d.ts +2 -12
  4. package/dist/index.js +3 -20
  5. package/dist/prompts/connectionValidator.d.ts +121 -27
  6. package/dist/prompts/connectionValidator.js +231 -36
  7. package/dist/prompts/datasources/sap-system/abap-on-btp/cf-helper.d.ts +9 -0
  8. package/dist/prompts/datasources/sap-system/abap-on-btp/cf-helper.js +55 -0
  9. package/dist/prompts/datasources/sap-system/abap-on-btp/questions.d.ts +34 -0
  10. package/dist/prompts/datasources/sap-system/abap-on-btp/questions.js +213 -0
  11. package/dist/prompts/datasources/sap-system/abap-on-prem/questions.d.ts +7 -16
  12. package/dist/prompts/datasources/sap-system/abap-on-prem/questions.js +16 -164
  13. package/dist/prompts/datasources/sap-system/new-system/questions.d.ts +36 -5
  14. package/dist/prompts/datasources/sap-system/new-system/questions.js +229 -37
  15. package/dist/prompts/datasources/sap-system/{abap-on-prem → new-system}/service-helper.d.ts +11 -1
  16. package/dist/prompts/datasources/sap-system/{abap-on-prem → new-system}/service-helper.js +30 -1
  17. package/dist/prompts/datasources/sap-system/new-system/types.d.ts +16 -0
  18. package/dist/prompts/datasources/sap-system/new-system/types.js +9 -0
  19. package/dist/prompts/datasources/sap-system/prompt-helpers.d.ts +3 -3
  20. package/dist/prompts/datasources/sap-system/prompt-helpers.js +4 -4
  21. package/dist/prompts/datasources/sap-system/validators.d.ts +10 -1
  22. package/dist/prompts/datasources/sap-system/validators.js +27 -2
  23. package/dist/prompts/datasources/service-url/questions.js +20 -8
  24. package/dist/prompts/datasources/service-url/validators.d.ts +4 -4
  25. package/dist/prompts/datasources/service-url/validators.js +4 -6
  26. package/dist/prompts/prompts.js +6 -9
  27. package/dist/translations/odata-service-inquirer.i18n.json +24 -4
  28. package/dist/types.d.ts +13 -3
  29. package/dist/types.js +5 -1
  30. package/dist/utils/index.d.ts +17 -0
  31. package/dist/utils/index.js +29 -1
  32. package/package.json +2 -1
@@ -15,10 +15,11 @@ const prompt_helpers_1 = require("./prompt-helpers");
15
15
  // Cert errors that may be ignored by prompt user
16
16
  const ignorableCertErrors = [error_handler_1.ERROR_TYPE.CERT_SELF_SIGNED, error_handler_1.ERROR_TYPE.CERT_SELF_SIGNED_CERT_IN_CHAIN];
17
17
  /**
18
- * Class that validates the connection to a service url or catalog url.
19
- * This will determine if authentication is required and if the service/catalog is reachable, generating messages to guide the user.
20
- * It is optimized for re-validation of the same url, so that the validation is not repeated if not required.
21
- *
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
+ * This will determine if if the service/catalog is reachable, authentication is required and generates ting messages to guide the user.
20
+ * Certain types of certificate errors can be ignored if required. However, the end-user should be warned about the risks using a prompt message.
21
+ * Catalog requests may be made multiple times for the same url, but the underlying connectivity module (@sap-ux/axios-extension) will cache the results to avoid repeated network requests.
22
+ * The class also stores the current connection state, including the service provider, odata service, and catalog services.
22
23
  */
23
24
  class ConnectionValidator {
24
25
  validity = {};
@@ -31,6 +32,11 @@ class ConnectionValidator {
31
32
  _axiosConfig;
32
33
  _catalogV2;
33
34
  _catalogV4;
35
+ _systemAuthType;
36
+ _serviceInfo;
37
+ _connectedUserName;
38
+ _connectedSystemName;
39
+ _refreshToken;
34
40
  /**
35
41
  * Getter for the axios configuration.
36
42
  *
@@ -65,6 +71,83 @@ class ConnectionValidator {
65
71
  get serviceProvider() {
66
72
  return this._serviceProvider;
67
73
  }
74
+ /**
75
+ * The auth type used to create an authenticated connection to the system.
76
+ *
77
+ * @returns the system auth type
78
+ */
79
+ get systemAuthType() {
80
+ return this._systemAuthType;
81
+ }
82
+ /**
83
+ * The auth type used to create an authenticated connection to the system.
84
+ *
85
+ * @param value the system auth type
86
+ */
87
+ set systemAuthType(value) {
88
+ this._systemAuthType = value;
89
+ }
90
+ /**
91
+ * Get the validated url. This is the url that has been successfully validated (not necessarily connected). Use validity to check if the url is reachable.
92
+ *
93
+ * @returns the validated url
94
+ */
95
+ get validatedUrl() {
96
+ return this._validatedUrl;
97
+ }
98
+ /**
99
+ * Get the service info used to connect to the system.
100
+ *
101
+ * @returns the service info
102
+ */
103
+ get serviceInfo() {
104
+ return this._serviceInfo;
105
+ }
106
+ /**
107
+ * Set the service info used to connect to the system.
108
+ *
109
+ * @param serviceInfo the service info
110
+ */
111
+ set serviceInfo(serviceInfo) {
112
+ this._serviceInfo = serviceInfo;
113
+ }
114
+ /**
115
+ * Get the connected user name.
116
+ *
117
+ * @returns the connected user name
118
+ */
119
+ get connectedUserName() {
120
+ return this._connectedUserName;
121
+ }
122
+ /**
123
+ * Get the refresh token.
124
+ *
125
+ * @returns the refresh token
126
+ */
127
+ get refreshToken() {
128
+ return this._refreshToken;
129
+ }
130
+ /**
131
+ * Get the connected system name. If previously set this will be used, otherwise the name is determined
132
+ * by the system auth type, or the validated url.
133
+ *
134
+ * @returns the connected system name
135
+ */
136
+ get connectedSystemName() {
137
+ if (this._connectedSystemName) {
138
+ return this._connectedSystemName;
139
+ }
140
+ if (this.systemAuthType === 'serviceKey') {
141
+ return this.serviceInfo?.systemid;
142
+ }
143
+ return this.validatedUrl;
144
+ }
145
+ /**
146
+ *
147
+ */
148
+ set connectedSystemName(value) {
149
+ this._connectedSystemName = value;
150
+ }
68
151
  /**
69
152
  * Calls a given service or system url to test its reachability and authentication requirements.
70
153
  * If the url is a system url, it will attempt to use the catalog service to get the service info.
@@ -78,7 +161,7 @@ class ConnectionValidator {
78
161
  * @param options.odataVersion if specified will restrict catalog requests to only the specified odata version
79
162
  * @returns the status code or error returned by the connection attempt
80
163
  */
81
- async checkSapService(url, username, password, { ignoreCertError = false, isSystem = false, odataVersion } = {}) {
164
+ async checkSapServiceUrl(url, username, password, { ignoreCertError = false, isSystem = false, odataVersion } = {}) {
82
165
  const isBAS = (0, btp_utils_1.isAppStudio)();
83
166
  try {
84
167
  // Auto add trailing '/' to path
@@ -92,13 +175,12 @@ class ConnectionValidator {
92
175
  url.searchParams.append('saml2', 'disabled');
93
176
  }
94
177
  const axiosConfig = this.createAxiosConfig(url, ignoreCertError, username, password);
95
- // If system, use catalog service to get the services info
96
178
  if (isSystem) {
97
- await this.createSystemConnection(axiosConfig, odataVersion);
179
+ await this.createSystemConnection({ axiosConfig, url, odataVersion });
98
180
  }
99
181
  else {
100
182
  // Full service URL
101
- await this.createServiceConnection(axiosConfig, url.pathname);
183
+ await this.createOdataServiceConnection(axiosConfig, url.pathname);
102
184
  }
103
185
  this._validatedClient = url.searchParams.get(types_1.SAP_CLIENT_KEY) ?? undefined;
104
186
  return 200;
@@ -135,7 +217,8 @@ class ConnectionValidator {
135
217
  params: Object.fromEntries(url.searchParams),
136
218
  ignoreCertErrors: ignoreCertError,
137
219
  cookies: '',
138
- baseURL: url.origin
220
+ baseURL: url.origin,
221
+ url: url.pathname
139
222
  };
140
223
  if (username && password) {
141
224
  axiosConfig = Object.assign(axiosConfig, {
@@ -153,35 +236,67 @@ class ConnectionValidator {
153
236
  * @param axiosConfig the axios request configuration
154
237
  * @param servicePath the service path without the origin
155
238
  */
156
- async createServiceConnection(axiosConfig, servicePath) {
239
+ async createOdataServiceConnection(axiosConfig, servicePath) {
157
240
  this._axiosConfig = axiosConfig;
158
241
  this._serviceProvider = (0, axios_extension_1.create)(this._axiosConfig);
159
242
  this._odataService = this._serviceProvider.service(servicePath);
160
243
  logger_helper_1.default.attachAxiosLogger(this._serviceProvider.interceptors);
161
244
  await this._odataService.get('');
162
245
  }
246
+ resetConnectionState() {
247
+ this._serviceProvider = undefined;
248
+ this._odataService = undefined;
249
+ this._catalogV2 = undefined;
250
+ this._catalogV4 = undefined;
251
+ this._serviceInfo = undefined;
252
+ this._connectedUserName = undefined;
253
+ this._refreshToken = undefined;
254
+ this._connectedSystemName = undefined;
255
+ this.resetValidity();
256
+ }
163
257
  /**
164
- * Create the connection for a system url. The system url should be provided as a base url axios config property.
258
+ * Create the connection for a system url, the specified axios config or the specified service info.
165
259
  *
166
- * @param axiosConfig the axios request configuration
167
- * @param odataVersion the odata version to restrict the catalog requests if only a specific version is required
260
+ * @param connectConfig the connection configuration
261
+ * @param connectConfig.axiosConfig the axios request configuration
262
+ * @param connectConfig.url the system url
263
+ * @param connectConfig.serviceInfo the service info
264
+ * @param connectConfig.odataVersion the odata version to restrict the catalog requests if only a specific version is required
168
265
  */
169
- async createSystemConnection(axiosConfig, odataVersion) {
170
- this._axiosConfig = axiosConfig;
171
- this._serviceProvider = (0, axios_extension_1.createForAbap)(this._axiosConfig);
172
- logger_helper_1.default.attachAxiosLogger(this._serviceProvider.interceptors);
266
+ async createSystemConnection({ axiosConfig, url, serviceInfo, odataVersion }) {
267
+ this.resetConnectionState();
268
+ if (this.systemAuthType === 'reentranceTicket' || this.systemAuthType === 'serviceKey') {
269
+ this._serviceProvider = this.getAbapOnCloudServiceProvider(url, serviceInfo);
270
+ }
271
+ else if (axiosConfig) {
272
+ this._axiosConfig = axiosConfig;
273
+ this._serviceProvider = (0, axios_extension_1.createForAbap)(axiosConfig);
274
+ }
275
+ if (this._serviceProvider) {
276
+ logger_helper_1.default.attachAxiosLogger(this._serviceProvider.interceptors);
277
+ }
173
278
  if (!odataVersion || odataVersion === axios_extension_1.ODataVersion.v2) {
174
279
  this._catalogV2 = this._serviceProvider.catalog(axios_extension_1.ODataVersion.v2);
175
280
  }
176
281
  if (!odataVersion || odataVersion === axios_extension_1.ODataVersion.v4) {
177
282
  this._catalogV4 = this._serviceProvider.catalog(axios_extension_1.ODataVersion.v4);
178
283
  }
284
+ let v4Requested = false;
179
285
  try {
180
- this._catalogV2 ? await this._catalogV2.listServices() : await this._catalogV4.listServices();
286
+ if (this._catalogV2) {
287
+ await this._catalogV2?.listServices();
288
+ }
289
+ else if (this._catalogV4) {
290
+ v4Requested = true;
291
+ await this._catalogV4?.listServices();
292
+ }
181
293
  }
182
294
  catch (error) {
183
- // We will try the v4 catalog if v2 returns a 404
184
- if (error.response?.status === 404 && this._catalogV4) {
295
+ // We will try the v4 catalog if v2 returns a 404 or an auth code. Try the v4 catalog with the credentials provided also
296
+ // as the user may not be authorized for the v2 catalog specifically.
297
+ if (this._catalogV4 &&
298
+ !v4Requested &&
299
+ this.shouldAttemptV4Catalog(error.response?.status)) {
185
300
  await this._catalogV4.listServices();
186
301
  }
187
302
  else {
@@ -190,13 +305,87 @@ class ConnectionValidator {
190
305
  }
191
306
  }
192
307
  /**
193
- * Validates the service url format as well as its reachability.
308
+ * Check if we should attempt to use the v4 catalog service as a fallback.
194
309
  *
195
- * @param serviceUrl the odata service url to validate
310
+ * @param statusCode http status code, if not provided will return false as we cannot determine the reason for v2 catalog request failure
311
+ * @returns true if we should attempt the v4 catalog service
312
+ */
313
+ shouldAttemptV4Catalog(statusCode) {
314
+ if (!statusCode) {
315
+ return false;
316
+ }
317
+ const errorType = error_handler_1.ErrorHandler.getErrorType(statusCode);
318
+ return errorType === error_handler_1.ERROR_TYPE.NOT_FOUND || errorType === error_handler_1.ERROR_TYPE.AUTH;
319
+ }
320
+ /**
321
+ * Callback for when the refresh token changes.
322
+ *
323
+ * @param refreshToken the new refresh token
324
+ */
325
+ async refreshTokenChangedCb(refreshToken) {
326
+ logger_helper_1.default.logger.debug(`ConnectionValidator.refreshTokenChangedCb()`);
327
+ this._refreshToken = refreshToken;
328
+ }
329
+ /**
330
+ * Get the service provider for the Abap on Cloud environment.
331
+ *
332
+ * @param url the system url
333
+ * @param serviceInfo the service info
334
+ * @returns the service provider
335
+ */
336
+ getAbapOnCloudServiceProvider(url, serviceInfo) {
337
+ if (this.systemAuthType === 'reentranceTicket' && url) {
338
+ return (0, axios_extension_1.createForAbapOnCloud)({
339
+ environment: axios_extension_1.AbapCloudEnvironment.EmbeddedSteampunk,
340
+ url: new URL(url.pathname, url.origin).toString()
341
+ });
342
+ }
343
+ if (this.systemAuthType === 'serviceKey' && serviceInfo) {
344
+ return (0, axios_extension_1.createForAbapOnCloud)({
345
+ environment: axios_extension_1.AbapCloudEnvironment.Standalone,
346
+ service: serviceInfo,
347
+ refreshTokenChangedCb: this.refreshTokenChangedCb.bind(this)
348
+ });
349
+ }
350
+ throw new Error('Invalid system auth type');
351
+ }
352
+ /**
353
+ * Validate the system connectivity with the specified service info (containing UAA details).
354
+ *
355
+ * @param serviceInfo the service info containing the UAA details
356
+ * @param odataVersion the odata version to restrict the catalog requests if only a specific version is required
357
+ * @returns true if the system is reachable, false if not, or an error message string
358
+ */
359
+ async validateServiceInfo(serviceInfo, odataVersion) {
360
+ if (!serviceInfo) {
361
+ return false;
362
+ }
363
+ try {
364
+ this.systemAuthType = 'serviceKey';
365
+ await this.createSystemConnection({ serviceInfo, odataVersion });
366
+ // Cache the user info
367
+ this._connectedUserName = await this.serviceProvider.user();
368
+ this._serviceInfo = serviceInfo;
369
+ this._validatedUrl = serviceInfo.url;
370
+ return this.getValidationResultFromStatusCode(200);
371
+ }
372
+ catch (error) {
373
+ logger_helper_1.default.logger.debug(`ConnectionValidator.validateServiceInfo() - error: ${error.message}`);
374
+ if (error?.isAxiosError) {
375
+ this.getValidationResultFromStatusCode(error?.response?.status || error?.code);
376
+ }
377
+ return prompt_helpers_1.errorHandler.getErrorMsg(error) ?? false;
378
+ }
379
+ }
380
+ /**
381
+ * Validates the system or service url format as well as its reachability.
382
+ *
383
+ * @param serviceUrl the url to validate, may be a system or service url.
384
+ * Note that if systemAuthType is specified, the url will be treated as a system url (only the origin will be considered)
196
385
  * @param options options for the connection validation
197
386
  * @param options.ignoreCertError ignore some certificate errors
198
- * @param options.forceReValidation force re-validation of the url even if the same url has been prevously validated
199
- * @param options.isSystem if true, the url will be treated as a system url rather than a service url
387
+ * @param options.forceReValidation force re-validation of the url
388
+ * @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
200
389
  * @param options.odataVersion if specified will restrict catalog requests to only the specified odata version
201
390
  * @returns true if the url is reachable, false if not, or an error message string
202
391
  */
@@ -214,7 +403,7 @@ class ConnectionValidator {
214
403
  return (0, i18n_1.t)('errors.invalidUrl');
215
404
  }
216
405
  // Ignore path if a system url
217
- const status = await this.checkSapService(url, undefined, undefined, {
406
+ const status = await this.checkSapServiceUrl(url, undefined, undefined, {
218
407
  ignoreCertError,
219
408
  isSystem,
220
409
  odataVersion
@@ -228,7 +417,7 @@ class ConnectionValidator {
228
417
  // More helpful context specific error
229
418
  if (error_handler_1.ErrorHandler.getErrorType(error) === error_handler_1.ERROR_TYPE.CONNECTION) {
230
419
  this.validity.reachable = false;
231
- return prompt_helpers_1.errorHandler.logErrorMsgs((0, i18n_1.t)('errors.systemOrserviceUrlNotFound', { url: serviceUrl }));
420
+ return prompt_helpers_1.errorHandler.logErrorMsgs((0, i18n_1.t)('errors.systemOrServiceUrlNotFound', { url: serviceUrl }));
232
421
  }
233
422
  this.resetValidity();
234
423
  const errorMsg = prompt_helpers_1.errorHandler.getErrorMsg(error);
@@ -236,11 +425,11 @@ class ConnectionValidator {
236
425
  }
237
426
  }
238
427
  /**
239
- * Translate the status code into a validation result.
428
+ * Converts the http status code into 'validty' and returns true if the status code indicates that the URL was reachable.
240
429
  * Sets the instance validity state based on the status code.
241
430
  *
242
431
  * @param status a http request status code used to determine the validation result
243
- * @returns true if the url is reachable, false if not, or an error message string
432
+ * @returns true, if the status code indicates the url is reachable, false if not, or an error message string
244
433
  */
245
434
  getValidationResultFromStatusCode(status) {
246
435
  if (status === 200) {
@@ -298,9 +487,9 @@ class ConnectionValidator {
298
487
  * Check whether basic auth is required for the given url, or for the previously validated url if none specified.
299
488
  * This will also set the validity state for the url. This will not validate the URL.
300
489
  *
301
- * @param urlString - the url to validate, if not provided the previously validated url will be used
302
- * @param client - optional, sap client code, if not provided the previously validated client will be used
303
- * @param ignoreCertError
490
+ * @param urlString the url to validate, if not provided the previously validated url will be used
491
+ * @param client optional, sap client code, if not provided the previously validated client will be used
492
+ * @param ignoreCertError ignore some certificate errors
304
493
  * @returns true if basic auth is required, false if not
305
494
  */
306
495
  async isAuthRequired(urlString = this._validatedUrl, client = this._validatedClient, ignoreCertError = false) {
@@ -319,8 +508,13 @@ class ConnectionValidator {
319
508
  if (client) {
320
509
  url.searchParams.append(types_1.SAP_CLIENT_KEY, client);
321
510
  }
322
- this.validity.authRequired = this.validity.reachable =
323
- error_handler_1.ErrorHandler.getErrorType(await this.checkSapService(url, undefined, undefined, { ignoreCertError })) === error_handler_1.ERROR_TYPE.AUTH;
511
+ const authError = error_handler_1.ErrorHandler.getErrorType(await this.checkSapServiceUrl(url, undefined, undefined, { ignoreCertError })) === error_handler_1.ERROR_TYPE.AUTH;
512
+ // Only if we get the specific auth error so we know that auth is required, otherwise we cannot determine so leave as undefined
513
+ if (authError) {
514
+ this.validity.authRequired = true;
515
+ this.validity.reachable = true;
516
+ }
517
+ // Returning undefined if we cannot determine if auth is required
324
518
  return this.validity.authRequired;
325
519
  }
326
520
  catch (error) {
@@ -329,7 +523,7 @@ class ConnectionValidator {
329
523
  }
330
524
  }
331
525
  /**
332
- * Test the connectivity with the specified service url using the provided credentials.
526
+ * Test the connectivity with the specified service url using the provided credentials (basic authentication).
333
527
  *
334
528
  * @param url the url to validate
335
529
  * @param username user name
@@ -341,7 +535,7 @@ class ConnectionValidator {
341
535
  * @param options.odataVersion if specified will restrict catalog requests to only the specified odata version
342
536
  * @returns true if the authentication is successful, false if not, or an error message string
343
537
  */
344
- async validateAuth(url, username, password, { ignoreCertError = false, isSystem = false, sapClient, odataVersion } = {}) {
538
+ async validateAuth(url, username, password, { ignoreCertError = false, sapClient, odataVersion, isSystem = false } = {}) {
345
539
  if (!url) {
346
540
  return false;
347
541
  }
@@ -350,7 +544,8 @@ class ConnectionValidator {
350
544
  if (sapClient) {
351
545
  urlObject.searchParams.append(types_1.SAP_CLIENT_KEY, sapClient);
352
546
  }
353
- const status = await this.checkSapService(urlObject, username, password, {
547
+ this.systemAuthType = 'basic';
548
+ const status = await this.checkSapServiceUrl(urlObject, username, password, {
354
549
  ignoreCertError,
355
550
  isSystem,
356
551
  odataVersion
@@ -0,0 +1,9 @@
1
+ import type { ServiceInstanceInfo } from '@sap/cf-tools';
2
+ import type { ListChoiceOptions } from 'inquirer';
3
+ /**
4
+ * Get the name sorted list of ABAP instance choices from an active CF login. If not logged in, an error message is logged.
5
+ *
6
+ * @returns The list of ABAP instance choices
7
+ */
8
+ export declare function getABAPInstanceChoices(): Promise<ListChoiceOptions<ServiceInstanceInfo>[]>;
9
+ //# sourceMappingURL=cf-helper.d.ts.map
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getABAPInstanceChoices = void 0;
4
+ const cf_tools_1 = require("@sap/cf-tools");
5
+ const error_handler_1 = require("../../../../error-handler/error-handler");
6
+ const i18n_1 = require("../../../../i18n");
7
+ const prompt_helpers_1 = require("../../../prompt-helpers");
8
+ const AbapEnvType = {
9
+ ABAP: 'abap',
10
+ ABAP_TRIAL: 'abap-trial',
11
+ ABAP_CANARY: 'abap-canary',
12
+ ABAP_OEM: 'abap-oem',
13
+ ABAP_OEM_CANARY: 'abap-oem-canary',
14
+ ABAP_HAAS: 'abap-haas',
15
+ ABAP_STAGING: 'abap-staging',
16
+ ABAP_INTERNAL_STAGING: 'abap-internal-staging',
17
+ DESTINATION: 'destination'
18
+ };
19
+ /**
20
+ * Get the name sorted list of ABAP instance choices from an active CF login. If not logged in, an error message is logged.
21
+ *
22
+ * @returns The list of ABAP instance choices
23
+ */
24
+ async function getABAPInstanceChoices() {
25
+ const choices = [];
26
+ try {
27
+ const filteredInstances = [
28
+ AbapEnvType.ABAP,
29
+ AbapEnvType.ABAP_TRIAL,
30
+ AbapEnvType.ABAP_CANARY,
31
+ AbapEnvType.ABAP_OEM,
32
+ AbapEnvType.ABAP_OEM_CANARY,
33
+ AbapEnvType.ABAP_HAAS,
34
+ AbapEnvType.ABAP_STAGING,
35
+ AbapEnvType.ABAP_INTERNAL_STAGING
36
+ ];
37
+ const serviceInstanceInfo = await (0, cf_tools_1.apiGetServicesInstancesFilteredByType)(filteredInstances);
38
+ if (serviceInstanceInfo.length > 0) {
39
+ serviceInstanceInfo.forEach((service) => {
40
+ choices.push({ name: service['label'], value: service });
41
+ });
42
+ }
43
+ else {
44
+ // No envs found
45
+ prompt_helpers_1.errorHandler.logErrorMsgs(error_handler_1.ERROR_TYPE.NO_ABAP_ENVS, (0, i18n_1.t)('errors.noAbapEnvsInCFSpace'));
46
+ }
47
+ }
48
+ catch (error) {
49
+ // Cannot connect to CF
50
+ prompt_helpers_1.errorHandler.logErrorMsgs(error_handler_1.ERROR_TYPE.NO_ABAP_ENVS, (0, i18n_1.t)('errors.abapEnvsCFDiscoveryFailed'));
51
+ }
52
+ return choices.sort((a, b) => (a.name ? a.name.localeCompare(b.name ?? '') : 0));
53
+ }
54
+ exports.getABAPInstanceChoices = getABAPInstanceChoices;
55
+ //# sourceMappingURL=cf-helper.js.map
@@ -0,0 +1,34 @@
1
+ import type { ServiceInstanceInfo } from '@sap/cf-tools';
2
+ import type { Question } from 'inquirer';
3
+ import { type OdataServiceAnswers, type OdataServicePromptOptions } from '../../../../types';
4
+ import { ConnectionValidator } from '../../../connectionValidator';
5
+ declare const systemUrlPromptName: "abapOnBtp:newSystemUrl";
6
+ declare const abapOnBtpPromptNames: {
7
+ readonly abapOnBtpAuthType: "abapOnBtpAuthType";
8
+ readonly serviceKey: "serviceKey";
9
+ readonly cloudFoundryAbapSystem: "cloudFoundryAbapSystem";
10
+ };
11
+ export type AbapOnBTPType = 'cloudFoundry' | 'serviceKey' | 'reentranceTicket';
12
+ interface AbapOnBtpAnswers extends Partial<OdataServiceAnswers> {
13
+ [abapOnBtpPromptNames.abapOnBtpAuthType]?: AbapOnBTPType;
14
+ [systemUrlPromptName]?: string;
15
+ [abapOnBtpPromptNames.serviceKey]?: string;
16
+ [abapOnBtpPromptNames.cloudFoundryAbapSystem]?: ServiceInstanceInfo;
17
+ }
18
+ /**
19
+ * Get the questions for the ABAP on BTP system. The questions will prompt the user for the system type (Cloud Foundry, Service Key, Re-entrance Ticket).
20
+ *
21
+ * @param promptOptions The prompt options which control the service selection and system name]
22
+ * @returns The list of questions for the ABAP on BTP system
23
+ */
24
+ export declare function getAbapOnBTPSystemQuestions(promptOptions?: OdataServicePromptOptions): Question<AbapOnBtpAnswers>[];
25
+ /**
26
+ * Get the Cloud Foundry Abap system discovery prompt. This prompt will list all available ABAP environments in the connected Cloud Foundry space.
27
+ * If the Cloud Foundry connection fails, a warning message will be displayed.
28
+ *
29
+ * @param connectionValidator The connection validator
30
+ * @returns The Cloud Foundry ABAP system discovery prompt
31
+ */
32
+ export declare function getCFDiscoverPrompts(connectionValidator: ConnectionValidator): Question[];
33
+ export {};
34
+ //# sourceMappingURL=questions.d.ts.map