From fd8d1491ca4b5607fea632f86ffa21ae4e67b73f Mon Sep 17 00:00:00 2001 From: John Long Date: Thu, 12 Dec 2024 16:20:59 +0000 Subject: [PATCH] fix(btp-utils): refactor code to reuse abapenvtype --- packages/btp-utils/src/destination.ts | 24 ++++++++++--------- .../inquirer-common/src/prompts/cf-helper.ts | 13 +--------- 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/packages/btp-utils/src/destination.ts b/packages/btp-utils/src/destination.ts index e1dabd5dcc..c3d9ff0591 100644 --- a/packages/btp-utils/src/destination.ts +++ b/packages/btp-utils/src/destination.ts @@ -246,41 +246,43 @@ export function isAbapODataDestination(destination: Destination): boolean { /** * Cloud Foundry instance types */ -export enum ServiceType { +export const AbapEnvType = { /** * ABAP instance type */ - ABAP = 'abap', + ABAP: 'abap', /** * ABAP trial instance type */ - ABAP_TRIAL = 'abap-trial', + ABAP_TRIAL: 'abap-trial', /** * ABAP CANARY trial instance type */ - ABAP_CANARY = 'abap-canary', + ABAP_CANARY: 'abap-canary', /** * ABAP OEM instance type */ - ABAP_OEM = 'abap-oem', + ABAP_OEM: 'abap-oem', /** * ABAP OEM CANARY instance type */ - ABAP_OEM_CANARY = 'abap-oem-canary', + ABAP_OEM_CANARY: 'abap-oem-canary', /** * ABAP HAAS instance type */ - ABAP_HAAS = 'abap-haas', + ABAP_HAAS: 'abap-haas', /** * Destination service instance type */ - DESTINATION = 'destination', + DESTINATION: 'destination', /** * ABAP Staging service instance type */ - ABAP_STAGING = 'abap-staging', + ABAP_STAGING: 'abap-staging', /** * ABAP Internal Staging service instance type */ - ABAP_INTERNAL_STAGING = 'abap-internal-staging' -} + ABAP_INTERNAL_STAGING: 'abap-internal-staging' +} as const; + +export type AbapEnvType = (typeof AbapEnvType)[keyof typeof AbapEnvType]; diff --git a/packages/inquirer-common/src/prompts/cf-helper.ts b/packages/inquirer-common/src/prompts/cf-helper.ts index 4af0d2e622..3fe2bbe839 100644 --- a/packages/inquirer-common/src/prompts/cf-helper.ts +++ b/packages/inquirer-common/src/prompts/cf-helper.ts @@ -3,18 +3,7 @@ import { apiGetServicesInstancesFilteredByType as getServicesInstances } from '@ import type { ListChoiceOptions } from 'inquirer'; import { ERROR_TYPE, type ErrorHandler } from '../error-handler/error-handler'; import { t } from '../i18n'; - -const AbapEnvType = { - ABAP: 'abap', - ABAP_TRIAL: 'abap-trial', - ABAP_CANARY: 'abap-canary', - ABAP_OEM: 'abap-oem', - ABAP_OEM_CANARY: 'abap-oem-canary', - ABAP_HAAS: 'abap-haas', - ABAP_STAGING: 'abap-staging', - ABAP_INTERNAL_STAGING: 'abap-internal-staging', - DESTINATION: 'destination' -} as const; +import { AbapEnvType } from '@sap-ux/btp-utils'; /** * Get the name sorted list of ABAP instance choices from an active CF login. If not logged in, an error message is logged.