@sap-ux/odata-service-inquirer 2.23.4 → 3.0.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.
Files changed (73) hide show
  1. package/dist/i18n.js +14 -24
  2. package/dist/index.d.ts +11 -6
  3. package/dist/index.js +40 -44
  4. package/dist/prompts/connectionValidator.d.ts +2 -2
  5. package/dist/prompts/connectionValidator.js +109 -116
  6. package/dist/prompts/datasources/cap-project/cap-helpers.d.ts +2 -2
  7. package/dist/prompts/datasources/cap-project/cap-helpers.js +44 -53
  8. package/dist/prompts/datasources/cap-project/questions.d.ts +2 -2
  9. package/dist/prompts/datasources/cap-project/questions.js +46 -49
  10. package/dist/prompts/datasources/cap-project/types.d.ts +1 -1
  11. package/dist/prompts/datasources/cap-project/types.js +2 -5
  12. package/dist/prompts/datasources/cap-project/validators.js +5 -8
  13. package/dist/prompts/datasources/metadata-file/index.d.ts +1 -1
  14. package/dist/prompts/datasources/metadata-file/index.js +12 -15
  15. package/dist/prompts/datasources/metadata-file/validators.js +9 -13
  16. package/dist/prompts/datasources/sap-system/abap-on-btp/questions.d.ts +3 -3
  17. package/dist/prompts/datasources/sap-system/abap-on-btp/questions.js +55 -62
  18. package/dist/prompts/datasources/sap-system/abap-on-prem/questions.d.ts +3 -3
  19. package/dist/prompts/datasources/sap-system/abap-on-prem/questions.js +26 -30
  20. package/dist/prompts/datasources/sap-system/cf-abap/questions.d.ts +2 -2
  21. package/dist/prompts/datasources/sap-system/cf-abap/questions.js +7 -10
  22. package/dist/prompts/datasources/sap-system/credentials/questions.d.ts +1 -1
  23. package/dist/prompts/datasources/sap-system/credentials/questions.js +27 -31
  24. package/dist/prompts/datasources/sap-system/external-services/value-help-download.d.ts +1 -1
  25. package/dist/prompts/datasources/sap-system/external-services/value-help-download.js +25 -31
  26. package/dist/prompts/datasources/sap-system/new-system/questions.d.ts +2 -2
  27. package/dist/prompts/datasources/sap-system/new-system/questions.js +12 -15
  28. package/dist/prompts/datasources/sap-system/new-system/types.d.ts +1 -1
  29. package/dist/prompts/datasources/sap-system/new-system/types.js +2 -5
  30. package/dist/prompts/datasources/sap-system/prompt-helpers.js +6 -9
  31. package/dist/prompts/datasources/sap-system/service-selection/index.d.ts +2 -2
  32. package/dist/prompts/datasources/sap-system/service-selection/index.js +2 -18
  33. package/dist/prompts/datasources/sap-system/service-selection/questions.d.ts +3 -3
  34. package/dist/prompts/datasources/sap-system/service-selection/questions.js +39 -45
  35. package/dist/prompts/datasources/sap-system/service-selection/service-helper.d.ts +3 -3
  36. package/dist/prompts/datasources/sap-system/service-selection/service-helper.js +78 -90
  37. package/dist/prompts/datasources/sap-system/service-selection/types.js +1 -2
  38. package/dist/prompts/datasources/sap-system/shared-prompts/shared-prompts.d.ts +5 -5
  39. package/dist/prompts/datasources/sap-system/shared-prompts/shared-prompts.js +36 -40
  40. package/dist/prompts/datasources/sap-system/system-selection/index.d.ts +1 -1
  41. package/dist/prompts/datasources/sap-system/system-selection/index.js +1 -17
  42. package/dist/prompts/datasources/sap-system/system-selection/prompt-helpers.d.ts +3 -3
  43. package/dist/prompts/datasources/sap-system/system-selection/prompt-helpers.js +48 -58
  44. package/dist/prompts/datasources/sap-system/system-selection/questions.d.ts +4 -4
  45. package/dist/prompts/datasources/sap-system/system-selection/questions.js +55 -62
  46. package/dist/prompts/datasources/sap-system/validators.js +13 -18
  47. package/dist/prompts/datasources/service-helpers/service-helpers.js +9 -15
  48. package/dist/prompts/datasources/service-url/questions.d.ts +1 -1
  49. package/dist/prompts/datasources/service-url/questions.js +43 -49
  50. package/dist/prompts/datasources/service-url/types.js +2 -5
  51. package/dist/prompts/datasources/service-url/validators.js +35 -41
  52. package/dist/prompts/edmx/alp-questions.d.ts +1 -1
  53. package/dist/prompts/edmx/alp-questions.js +28 -31
  54. package/dist/prompts/edmx/entity-helper.js +26 -35
  55. package/dist/prompts/edmx/questions.d.ts +1 -1
  56. package/dist/prompts/edmx/questions.js +78 -84
  57. package/dist/prompts/index.d.ts +1 -1
  58. package/dist/prompts/index.js +1 -17
  59. package/dist/prompts/logger-helper.js +4 -40
  60. package/dist/prompts/prompt-helpers.d.ts +1 -1
  61. package/dist/prompts/prompt-helpers.js +12 -16
  62. package/dist/prompts/prompts.d.ts +1 -1
  63. package/dist/prompts/prompts.js +16 -19
  64. package/dist/prompts/types.js +1 -2
  65. package/dist/prompts/validators.js +7 -13
  66. package/dist/types.d.ts +2 -2
  67. package/dist/types.js +8 -11
  68. package/dist/utils/index.d.ts +1 -1
  69. package/dist/utils/index.js +38 -53
  70. package/dist/utils/prompt-state.d.ts +1 -1
  71. package/dist/utils/prompt-state.js +1 -5
  72. package/dist/utils/store.js +7 -14
  73. package/package.json +22 -20
package/dist/i18n.js CHANGED
@@ -1,23 +1,15 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.i18n = exports.defaultProjectNumber = void 0;
7
- exports.initI18nOdataServiceInquirer = initI18nOdataServiceInquirer;
8
- exports.t = t;
9
- const inquirer_common_1 = require("@sap-ux/inquirer-common");
10
- const project_input_validator_1 = require("@sap-ux/project-input-validator");
11
- const i18next_1 = __importDefault(require("i18next"));
12
- const odata_service_inquirer_i18n_json_1 = __importDefault(require("./translations/odata-service-inquirer.i18n.json"));
1
+ import { addi18nResourceBundle as addInquirerCommonTexts } from '@sap-ux/inquirer-common';
2
+ import { addi18nResourceBundle as addProjectInputValidatorTexts } from '@sap-ux/project-input-validator';
3
+ import i18next from 'i18next';
4
+ import translations from './translations/odata-service-inquirer.i18n.json' with { type: 'json' };
13
5
  const odataServiceInquirerNamespace = 'odata-service-inquirer';
14
- exports.defaultProjectNumber = 1;
15
- exports.i18n = i18next_1.default.createInstance();
6
+ export const defaultProjectNumber = 1;
7
+ export const i18n = i18next.createInstance();
16
8
  /**
17
9
  * Initialize i18next with the translations for this module.
18
10
  */
19
- async function initI18nOdataServiceInquirer() {
20
- await exports.i18n.init({
11
+ export async function initI18nOdataServiceInquirer() {
12
+ await i18n.init({
21
13
  lng: 'en',
22
14
  fallbackLng: 'en',
23
15
  missingInterpolationHandler: () => '',
@@ -36,10 +28,10 @@ async function initI18nOdataServiceInquirer() {
36
28
  },
37
29
  showSupportNotice: false
38
30
  });
39
- exports.i18n.addResourceBundle('en', odataServiceInquirerNamespace, odata_service_inquirer_i18n_json_1.default);
31
+ i18n.addResourceBundle('en', odataServiceInquirerNamespace, translations);
40
32
  // add other bundles that are used in consumed modules
41
- (0, inquirer_common_1.addi18nResourceBundle)();
42
- (0, project_input_validator_1.addi18nResourceBundle)();
33
+ addInquirerCommonTexts();
34
+ addProjectInputValidatorTexts();
43
35
  }
44
36
  /**
45
37
  * Helper function facading the call to i18next. Unless a namespace option is provided the local namespace will be used.
@@ -48,13 +40,11 @@ async function initI18nOdataServiceInquirer() {
48
40
  * @param options additional options
49
41
  * @returns {string} localized string stored for the given key
50
42
  */
51
- function t(key, options) {
43
+ export function t(key, options) {
52
44
  if (!options?.ns) {
53
45
  options = Object.assign(options ?? {}, { ns: odataServiceInquirerNamespace });
54
46
  }
55
- return exports.i18n.t(key, options);
47
+ return i18n.t(key, options);
56
48
  }
57
- initI18nOdataServiceInquirer().catch(() => {
58
- // Needed for lint
59
- });
49
+ void initI18nOdataServiceInquirer().catch(() => undefined);
60
50
  //# sourceMappingURL=i18n.js.map
package/dist/index.d.ts CHANGED
@@ -3,13 +3,13 @@ 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
5
  import type { Question } from 'inquirer';
6
- import type { ServiceAnswer } from './prompts/datasources/sap-system/service-selection';
7
- import { type SystemSelectionAnswers } from './prompts/datasources/sap-system/system-selection';
8
- import type { CfAbapEnvServiceChoice, NewSystemChoice, SystemSelectionAnswerType } from './prompts/datasources/sap-system/system-selection/prompt-helpers';
6
+ import type { ServiceAnswer } from './prompts/datasources/sap-system/service-selection/index.js';
7
+ import { type SystemSelectionAnswers } from './prompts/datasources/sap-system/system-selection/index.js';
8
+ import { CfAbapEnvServiceChoice, NewSystemChoice } from './prompts/datasources/sap-system/system-selection/prompt-helpers.js';
9
9
  import type { Annotations } from '@sap-ux/axios-extension';
10
- import type { CapRuntime, CapService } from '@sap-ux/cap-config-writer';
11
10
  import type { TemplateType } from '@sap-ux/fiori-elements-writer';
12
- import { type EntityPromptOptions, type OdataServiceAnswers, type OdataServicePromptOptions, type OdataServiceQuestion, type SapSystemType, type ConnectedSystem, DatasourceType, EntityRelatedAnswers, promptNames } from './types';
11
+ import type { EntityRelatedAnswers, EntityPromptOptions, OdataServiceAnswers, OdataServicePromptOptions, OdataServiceQuestion, ConnectedSystem } from './types.js';
12
+ import { DatasourceType } from './types.js';
13
13
  /**
14
14
  * Get the inquirer prompts for odata service.
15
15
  *
@@ -64,5 +64,10 @@ declare function getEntityRelatedPrompts(metadata: string, templateType: Templat
64
64
  * @returns the prompt answers
65
65
  */
66
66
  declare function prompt(adapter: InquirerAdapter, promptOptions?: OdataServicePromptOptions, logger?: Logger, enableGuidedAnswers?: boolean, telemetryClient?: ToolsSuiteTelemetryClient, isYUI?: boolean, connectedSystem?: ConnectedSystem): Promise<OdataServiceAnswers>;
67
- export { CfAbapEnvServiceChoice, DatasourceType, EntityRelatedAnswers, ERROR_TYPE, ErrorHandler, getEntityRelatedPrompts, getPrompts, getSystemSelectionQuestions, NewSystemChoice, OdataVersion, prompt, promptNames, SystemSelectionAnswerType, type CapRuntime, type CapService, type InquirerAdapter, type OdataServiceAnswers, type OdataServicePromptOptions, type SapSystemType, type ConnectedSystem };
67
+ export { CfAbapEnvServiceChoice, DatasourceType, ERROR_TYPE, ErrorHandler, getEntityRelatedPrompts, getPrompts, getSystemSelectionQuestions, NewSystemChoice, OdataVersion, prompt };
68
+ export { promptNames } from './types.js';
69
+ export type { SystemSelectionAnswerType } from './prompts/datasources/sap-system/system-selection/prompt-helpers.js';
70
+ export type { CapRuntime, CapService } from '@sap-ux/cap-config-writer';
71
+ export type { InquirerAdapter } from '@sap-ux/inquirer-common';
72
+ export type { EntityRelatedAnswers, OdataServiceAnswers, OdataServicePromptOptions, SapSystemType, ConnectedSystem } from './types.js';
68
73
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -1,28 +1,14 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.promptNames = exports.OdataVersion = exports.ErrorHandler = exports.ERROR_TYPE = exports.DatasourceType = void 0;
7
- exports.getEntityRelatedPrompts = getEntityRelatedPrompts;
8
- exports.getPrompts = getPrompts;
9
- exports.getSystemSelectionQuestions = getSystemSelectionQuestions;
10
- exports.prompt = prompt;
11
- const inquirer_common_1 = require("@sap-ux/inquirer-common");
12
- Object.defineProperty(exports, "ERROR_TYPE", { enumerable: true, get: function () { return inquirer_common_1.ERROR_TYPE; } });
13
- Object.defineProperty(exports, "ErrorHandler", { enumerable: true, get: function () { return inquirer_common_1.ErrorHandler; } });
14
- const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
15
- Object.defineProperty(exports, "OdataVersion", { enumerable: true, get: function () { return odata_service_writer_1.OdataVersion; } });
16
- const inquirer_autocomplete_prompt_1 = __importDefault(require("inquirer-autocomplete-prompt"));
17
- const i18n_1 = require("./i18n");
18
- const prompts_1 = require("./prompts");
19
- const system_selection_1 = require("./prompts/datasources/sap-system/system-selection");
20
- const questions_1 = require("./prompts/edmx/questions");
21
- const logger_helper_1 = __importDefault(require("./prompts/logger-helper"));
22
- const types_1 = require("./types");
23
- Object.defineProperty(exports, "DatasourceType", { enumerable: true, get: function () { return types_1.DatasourceType; } });
24
- Object.defineProperty(exports, "promptNames", { enumerable: true, get: function () { return types_1.promptNames; } });
25
- const utils_1 = require("./utils");
1
+ import { ERROR_TYPE, ErrorHandler, setTelemetryClient } from '@sap-ux/inquirer-common';
2
+ import { OdataVersion } from '@sap-ux/odata-service-writer';
3
+ import autocomplete from 'inquirer-autocomplete-prompt';
4
+ import { initI18nOdataServiceInquirer } from './i18n.js';
5
+ import { getQuestions } from './prompts/index.js';
6
+ import { getSystemSelectionQuestions as getSystemSelectionQuestionsBase } from './prompts/datasources/sap-system/system-selection/index.js';
7
+ import { CfAbapEnvServiceChoice, NewSystemChoice } from './prompts/datasources/sap-system/system-selection/prompt-helpers.js';
8
+ import { getEntitySelectionQuestions } from './prompts/edmx/questions.js';
9
+ import LoggerHelper from './prompts/logger-helper.js';
10
+ import { DatasourceType } from './types.js';
11
+ import { getPromptHostEnvironment, PromptState } from './utils/index.js';
26
12
  /**
27
13
  * Get the inquirer prompts for odata service.
28
14
  *
@@ -36,21 +22,21 @@ const utils_1 = require("./utils");
36
22
  */
37
23
  async function getPrompts(promptOptions, logger, enableGuidedAnswers = false, telemetryClient, isYUI = false, connectedSystem) {
38
24
  // prompt texts must be loaded before the prompts are created, wait for the i18n bundle to be initialized
39
- await (0, i18n_1.initI18nOdataServiceInquirer)();
25
+ await initI18nOdataServiceInquirer();
40
26
  if (logger) {
41
- logger_helper_1.default.logger = logger;
27
+ LoggerHelper.logger = logger;
42
28
  }
43
- inquirer_common_1.ErrorHandler.logger = logger_helper_1.default.logger;
44
- inquirer_common_1.ErrorHandler.guidedAnswersEnabled = enableGuidedAnswers;
29
+ ErrorHandler.logger = LoggerHelper.logger;
30
+ ErrorHandler.guidedAnswersEnabled = enableGuidedAnswers;
45
31
  // Sets the platform for error handler telem reporting, based on the `isYUI` option
46
- inquirer_common_1.ErrorHandler.platform = (0, utils_1.getPromptHostEnvironment)().technical;
47
- inquirer_common_1.ErrorHandler.guidedAnswersTrigger = '@sap-ux/odata-service-inquirer';
48
- utils_1.PromptState.isYUI = isYUI;
49
- (0, inquirer_common_1.setTelemetryClient)(telemetryClient);
32
+ ErrorHandler.platform = getPromptHostEnvironment().technical;
33
+ ErrorHandler.guidedAnswersTrigger = '@sap-ux/odata-service-inquirer';
34
+ PromptState.isYUI = isYUI;
35
+ setTelemetryClient(telemetryClient);
50
36
  return {
51
- prompts: await (0, prompts_1.getQuestions)(promptOptions, connectedSystem),
37
+ prompts: await getQuestions(promptOptions, connectedSystem),
52
38
  // Return reference to derived answers object that will be populated with user responses (after prompting is complete)
53
- answers: utils_1.PromptState.odataService
39
+ answers: PromptState.odataService
54
40
  };
55
41
  }
56
42
  /**
@@ -63,14 +49,14 @@ async function getPrompts(promptOptions, logger, enableGuidedAnswers = false, te
63
49
  */
64
50
  async function getSystemSelectionQuestions(promptOptions, isYUI, logger) {
65
51
  if (isYUI !== undefined) {
66
- utils_1.PromptState.isYUI = isYUI;
52
+ PromptState.isYUI = isYUI;
67
53
  }
68
54
  if (logger) {
69
- logger_helper_1.default.logger = logger;
55
+ LoggerHelper.logger = logger;
70
56
  }
71
57
  return {
72
- prompts: await (0, system_selection_1.getSystemSelectionQuestions)(promptOptions),
73
- answers: utils_1.PromptState.odataService
58
+ prompts: await getSystemSelectionQuestionsBase(promptOptions),
59
+ answers: PromptState.odataService
74
60
  };
75
61
  }
76
62
  /**
@@ -88,10 +74,10 @@ async function getSystemSelectionQuestions(promptOptions, isYUI, logger) {
88
74
  */
89
75
  function getEntityRelatedPrompts(metadata, templateType, isCapService = false, promptOptions, annotations, logger, isYUI = false) {
90
76
  if (logger) {
91
- logger_helper_1.default.logger = logger;
77
+ LoggerHelper.logger = logger;
92
78
  }
93
- utils_1.PromptState.isYUI = isYUI;
94
- return (0, questions_1.getEntitySelectionQuestions)(metadata, templateType, isCapService, promptOptions, annotations);
79
+ PromptState.isYUI = isYUI;
80
+ return getEntitySelectionQuestions(metadata, templateType, isCapService, promptOptions, annotations);
95
81
  }
96
82
  /**
97
83
  * Prompt for odata service writer inputs.
@@ -109,12 +95,22 @@ async function prompt(adapter, promptOptions, logger, enableGuidedAnswers, telem
109
95
  if (adapter?.promptModule &&
110
96
  (promptOptions?.serviceSelection?.useAutoComplete ?? promptOptions?.capProject?.useAutoComplete)) {
111
97
  const pm = adapter.promptModule;
112
- pm.registerPrompt('autocomplete', inquirer_autocomplete_prompt_1.default);
98
+ pm.registerPrompt('autocomplete', autocomplete);
113
99
  }
114
100
  const odataServicePrompts = (await getPrompts(promptOptions, logger, enableGuidedAnswers, telemetryClient, isYUI, connectedSystem)).prompts;
115
101
  const answers = await adapter.prompt(odataServicePrompts);
116
102
  // Add dervied service answers to the answers object
117
- Object.assign(answers, utils_1.PromptState.odataService);
103
+ Object.assign(answers, PromptState.odataService);
118
104
  return answers;
119
105
  }
106
+ export { CfAbapEnvServiceChoice,
107
+ // @deprecated - temp export to support to support open source migration
108
+ DatasourceType,
109
+ // @deprecated - temp export to support to support open source migration
110
+ ERROR_TYPE,
111
+ // @deprecated - temp export to support to support open source migration
112
+ ErrorHandler, getEntityRelatedPrompts, getPrompts, getSystemSelectionQuestions, NewSystemChoice,
113
+ // @deprecated - temp export to support to support open source migration
114
+ OdataVersion, prompt };
115
+ export { promptNames } from './types.js';
120
116
  //# sourceMappingURL=index.js.map
@@ -2,8 +2,8 @@ import type { AxiosRequestConfig, CatalogService, ODataService, ProviderConfigur
2
2
  import { ODataVersion } from '@sap-ux/axios-extension';
3
3
  import { type Destination } from '@sap-ux/btp-utils';
4
4
  import { ERROR_TYPE } from '@sap-ux/inquirer-common';
5
- import type { ConnectedSystem } from '../types';
6
- import type { ValidationResult } from './types';
5
+ import type { ConnectedSystem } from '../types.js';
6
+ import type { ValidationResult } from './types.js';
7
7
  /**
8
8
  * Structure to store validity information about url to be validated.
9
9
  */