Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(@sap-ux/odata service inquirer): Adds system selection prompting #2374

Draft
wants to merge 16 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions packages/btp-utils/src/destination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export interface Destination extends Partial<AdditionalDestinationProperties> {
Authentication: string;
ProxyType: string;
Description: string;
/**
* N.B. Not the host but the full destination URL property!
*/
Host: string;
}

Expand Down Expand Up @@ -224,3 +227,16 @@ export function isS4HC(destination: Destination): boolean {
destination.ProxyType === ProxyType.INTERNET
);
}

/**
* Checks if the destination attributes WebIDEUsage is configured with odata_abap.
*
* @param destination destination configuration properties
* @returns true, if this destination has the the 'odata_abap' attribute set
*/
export function isAbapODataDestination(destination: Destination): boolean {
return (
!!destination.WebIDEUsage?.includes(WebIDEUsage.ODATA_ABAP) &&
!destination.WebIDEUsage?.includes(WebIDEUsage.ODATA_GENERIC)
);
}
1 change: 1 addition & 0 deletions packages/odata-service-inquirer/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ config.snapshotFormat = {
escapeString: false,
printBasicPrototype: false
};
config.collectCoverage = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert

module.exports = config;
4 changes: 1 addition & 3 deletions packages/odata-service-inquirer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@
"@types/inquirer-autocomplete-prompt": "2.0.1",
"@types/inquirer": "8.2.6",
"@types/lodash": "4.14.202",
"jest-extended": "3.2.4",
"lodash": "4.17.21"
},
"jest-extended": "3.2.4" },
"engines": {
"node": ">=18.x"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export enum ERROR_TYPE {
DESTINATION_NOT_FOUND = 'DESTINATION_NOT_FOUND',
DESTINATION_MISCONFIGURED = 'DESTINATION_MISCONFIGURED',
NO_V2_SERVICES = 'NO_V2_SERVICES',
NO_V4_SERVICES = 'NO_V4_SERVICES'
NO_V4_SERVICES = 'NO_V4_SERVICES',
BAD_REQUEST = 'BAD_REQUEST'
}

// Used to match regex expressions to error messages, etc. providing a way to return a consistent
Expand Down Expand Up @@ -90,7 +91,8 @@ export const ERROR_MAP: Record<ERROR_TYPE, RegExp[]> = {
[ERROR_TYPE.DESTINATION_NOT_FOUND]: [],
[ERROR_TYPE.DESTINATION_MISCONFIGURED]: [],
[ERROR_TYPE.NO_V2_SERVICES]: [],
[ERROR_TYPE.NO_V4_SERVICES]: []
[ERROR_TYPE.NO_V4_SERVICES]: [],
[ERROR_TYPE.BAD_REQUEST]: [/400/]
};

type ValidationLinkOrString = string | ValidationLink;
Expand Down Expand Up @@ -124,7 +126,7 @@ export class ErrorHandler {
[ERROR_TYPE.CERT_SELF_SIGNED_CERT_IN_CHAIN]: t('errors.urlCertValidationError', {
certErrorReason: t('texts.anUntrustedRootCert')
}),
[ERROR_TYPE.AUTH]: t('errors.authenticationFailed', { error }),
[ERROR_TYPE.AUTH]: t('errors.authenticationFailed', { error: (error as Error)?.message || error }),
[ERROR_TYPE.AUTH_TIMEOUT]: t('errors.authenticationTimeout'),
[ERROR_TYPE.TIMEOUT]: t('errors.timeout, { error }'),
[ERROR_TYPE.INVALID_URL]: t('errors.invalidUrl'),
Expand All @@ -149,7 +151,8 @@ export class ErrorHandler {
[ERROR_TYPE.DESTINATION_BAD_GATEWAY_503]: t('errors.destinationUnavailable'),
[ERROR_TYPE.REDIRECT]: t('errors.redirectError'),
[ERROR_TYPE.NO_SUCH_HOST]: t('errors.noSuchHostError'),
[ERROR_TYPE.NO_ABAP_ENVS]: t('errors.abapEnvsUnavailable')
[ERROR_TYPE.NO_ABAP_ENVS]: t('errors.abapEnvsUnavailable'),
[ERROR_TYPE.BAD_REQUEST]: t('errors.badRequest')
});

/**
Expand Down Expand Up @@ -188,7 +191,8 @@ export class ErrorHandler {
[ERROR_TYPE.ODATA_URL_NOT_FOUND]: undefined,
[ERROR_TYPE.INTERNAL_SERVER_ERROR]: undefined,
[ERROR_TYPE.NO_V2_SERVICES]: undefined,
[ERROR_TYPE.TIMEOUT]: undefined
[ERROR_TYPE.TIMEOUT]: undefined,
[ERROR_TYPE.BAD_REQUEST]: undefined
};
return errorToHelp[errorType];
};
Expand Down
14 changes: 10 additions & 4 deletions packages/odata-service-inquirer/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import autocomplete from 'inquirer-autocomplete-prompt';
import { ERROR_TYPE, ErrorHandler } from './error-handler/error-handler';
import { initI18nOdataServiceInquirer } from './i18n';
import { getQuestions } from './prompts';
import { newSystemChoiceValue } from './prompts/datasources/sap-system/new-system/questions';
import { newSystemChoiceValue } from './prompts/datasources/sap-system/system-selection';
import LoggerHelper from './prompts/logger-helper';
import {
DatasourceType,
Expand Down Expand Up @@ -86,18 +86,24 @@ async function prompt(
}

export {
// @derecated - temp export to support to support open source migration
DatasourceType,
// @deprecated - temp export to support to support open source migration
ERROR_TYPE,
// @deprecated - temp export to support to support open source migration
ErrorHandler,
// @deprecated - temp export to support to support open source migration
OdataVersion,
getPrompts,
// @deprecated - temp export to support to support open source migration
newSystemChoiceValue,
// @deprecated - temp export to support to support open source migration
type SapSystemType,
getPrompts,
prompt,
promptNames,
type CapRuntime,
type CapService,
type InquirerAdapter,
type OdataServiceAnswers,
type OdataServicePromptOptions,
type SapSystemType
type OdataServicePromptOptions
};
Loading
Loading