@sap-ux/odata-service-inquirer 0.1.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/LICENSE +201 -0
- package/README.md +87 -0
- package/dist/error-handler/error-handler.d.ts +176 -0
- package/dist/error-handler/error-handler.js +450 -0
- package/dist/error-handler/help/help-topics.d.ts +37 -0
- package/dist/error-handler/help/help-topics.js +40 -0
- package/dist/error-handler/help/images/guidedAnswersIcon_svg_base64.d.ts +2 -0
- package/dist/error-handler/help/images/guidedAnswersIcon_svg_base64.js +5 -0
- package/dist/error-handler/help/images/index.d.ts +2 -0
- package/dist/error-handler/help/images/index.js +18 -0
- package/dist/i18n.d.ts +15 -0
- package/dist/i18n.js +50 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +73 -0
- package/dist/prompts/datasources/cap-project/cap-helpers.d.ts +26 -0
- package/dist/prompts/datasources/cap-project/cap-helpers.js +215 -0
- package/dist/prompts/datasources/cap-project/questions.d.ts +14 -0
- package/dist/prompts/datasources/cap-project/questions.js +172 -0
- package/dist/prompts/datasources/cap-project/types.d.ts +27 -0
- package/dist/prompts/datasources/cap-project/types.js +12 -0
- package/dist/prompts/datasources/cap-project/validators.d.ts +8 -0
- package/dist/prompts/datasources/cap-project/validators.js +35 -0
- package/dist/prompts/datasources/metadata-file/index.d.ts +10 -0
- package/dist/prompts/datasources/metadata-file/index.js +47 -0
- package/dist/prompts/datasources/metadata-file/validators.d.ts +13 -0
- package/dist/prompts/datasources/metadata-file/validators.js +45 -0
- package/dist/prompts/index.d.ts +2 -0
- package/dist/prompts/index.js +18 -0
- package/dist/prompts/logger-helper.d.ts +20 -0
- package/dist/prompts/logger-helper.js +27 -0
- package/dist/prompts/prompt-helpers.d.ts +14 -0
- package/dist/prompts/prompt-helpers.js +44 -0
- package/dist/prompts/prompts.d.ts +9 -0
- package/dist/prompts/prompts.js +98 -0
- package/dist/prompts/validators.d.ts +13 -0
- package/dist/prompts/validators.js +45 -0
- package/dist/translations/odata-service-inquirer.i18n.json +88 -0
- package/dist/types.d.ts +176 -0
- package/dist/types.js +76 -0
- package/dist/utils/index.d.ts +26 -0
- package/dist/utils/index.js +70 -0
- package/dist/utils/prompt-state.d.ts +13 -0
- package/dist/utils/prompt-state.js +18 -0
- package/package.json +55 -0
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.getMetadataFileQuestion = void 0;
|
|
13
|
+
const i18n_1 = require("../../../i18n");
|
|
14
|
+
const types_1 = require("../../../types");
|
|
15
|
+
const validators_1 = require("./validators");
|
|
16
|
+
const utils_1 = require("../../../utils");
|
|
17
|
+
/**
|
|
18
|
+
* Returns the metadata file question based on the provided @type{MetadataPromptOptions}.
|
|
19
|
+
*
|
|
20
|
+
* @param promptOptions - The metadata prompt options
|
|
21
|
+
* @returns the metadata file question
|
|
22
|
+
*/
|
|
23
|
+
function getMetadataFileQuestion(promptOptions) {
|
|
24
|
+
const metadataFileQuestion = {
|
|
25
|
+
type: 'input',
|
|
26
|
+
guiType: 'file-browser',
|
|
27
|
+
name: types_1.promptNames.metadataFilePath,
|
|
28
|
+
guiOptions: { mandatory: true, breadcrumb: true },
|
|
29
|
+
message: (0, i18n_1.t)('prompts.metadataFile.message'),
|
|
30
|
+
validate: (path) => __awaiter(this, void 0, void 0, function* () {
|
|
31
|
+
utils_1.PromptState.reset();
|
|
32
|
+
const validateResult = yield (0, validators_1.validateMetadataFile)(path, promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions.requiredOdataVersion);
|
|
33
|
+
if (typeof validateResult === 'string' || typeof validateResult === 'boolean') {
|
|
34
|
+
return validateResult;
|
|
35
|
+
}
|
|
36
|
+
if (validateResult.metadata) {
|
|
37
|
+
utils_1.PromptState.odataService.odataVersion = validateResult.version;
|
|
38
|
+
utils_1.PromptState.odataService.metadata = validateResult.metadata;
|
|
39
|
+
utils_1.PromptState.odataService.servicePath = (0, i18n_1.t)('prompts.metadataFile.placeholder_odata_service_url'); // Dummy path used by v4 preview server middleware
|
|
40
|
+
}
|
|
41
|
+
return true;
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
return metadataFileQuestion;
|
|
45
|
+
}
|
|
46
|
+
exports.getMetadataFileQuestion = getMetadataFileQuestion;
|
|
47
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validates the metadata file, returning an error string, if not valid, or an object with the valid metadata and version.
|
|
3
|
+
*
|
|
4
|
+
* @param path
|
|
5
|
+
* @param odataVersion
|
|
6
|
+
* @returns
|
|
7
|
+
*/
|
|
8
|
+
import { OdataVersion } from '@sap-ux/odata-service-writer';
|
|
9
|
+
export declare const validateMetadataFile: (path: string, odataVersion?: OdataVersion) => Promise<{
|
|
10
|
+
version: OdataVersion;
|
|
11
|
+
metadata: string;
|
|
12
|
+
} | string | boolean>;
|
|
13
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Validates the metadata file, returning an error string, if not valid, or an object with the valid metadata and version.
|
|
4
|
+
*
|
|
5
|
+
* @param path
|
|
6
|
+
* @param odataVersion
|
|
7
|
+
* @returns
|
|
8
|
+
*/
|
|
9
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
10
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
11
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
12
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
13
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
14
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
15
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.validateMetadataFile = void 0;
|
|
20
|
+
const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
|
|
21
|
+
const promises_1 = require("fs/promises");
|
|
22
|
+
const validators_1 = require("../../validators");
|
|
23
|
+
const i18n_1 = require("../../../i18n");
|
|
24
|
+
const validateMetadataFile = (path, odataVersion) => __awaiter(void 0, void 0, void 0, function* () {
|
|
25
|
+
if (!path) {
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
const metadata = yield (0, promises_1.readFile)(path, 'utf-8');
|
|
30
|
+
metadata.replace(/ & /g, ' & ');
|
|
31
|
+
const { validationMsg, version } = (0, validators_1.validateODataVersion)(metadata, odataVersion);
|
|
32
|
+
if (validationMsg) {
|
|
33
|
+
return validationMsg;
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
version: version !== null && version !== void 0 ? version : odata_service_writer_1.OdataVersion.v4,
|
|
37
|
+
metadata
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
return (0, i18n_1.t)('prompts.validationMessages.metadataFilePathNotValid');
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
exports.validateMetadataFile = validateMetadataFile;
|
|
45
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./prompts"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type Logger } from '@sap-ux/logger';
|
|
2
|
+
/**
|
|
3
|
+
* Static logger prevents passing of logger references through all functions, as this is a cross-cutting concern.
|
|
4
|
+
*/
|
|
5
|
+
export default class LoggerHelper {
|
|
6
|
+
private static _logger;
|
|
7
|
+
/**
|
|
8
|
+
* Get the logger.
|
|
9
|
+
*
|
|
10
|
+
* @returns the logger
|
|
11
|
+
*/
|
|
12
|
+
static get logger(): Logger;
|
|
13
|
+
/**
|
|
14
|
+
* Set the logger.
|
|
15
|
+
*
|
|
16
|
+
* @param value the logger to set
|
|
17
|
+
*/
|
|
18
|
+
static set logger(value: Logger);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=logger-helper.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const logger_1 = require("@sap-ux/logger");
|
|
4
|
+
/**
|
|
5
|
+
* Static logger prevents passing of logger references through all functions, as this is a cross-cutting concern.
|
|
6
|
+
*/
|
|
7
|
+
class LoggerHelper {
|
|
8
|
+
/**
|
|
9
|
+
* Get the logger.
|
|
10
|
+
*
|
|
11
|
+
* @returns the logger
|
|
12
|
+
*/
|
|
13
|
+
static get logger() {
|
|
14
|
+
return LoggerHelper._logger;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Set the logger.
|
|
18
|
+
*
|
|
19
|
+
* @param value the logger to set
|
|
20
|
+
*/
|
|
21
|
+
static set logger(value) {
|
|
22
|
+
LoggerHelper._logger = value;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
LoggerHelper._logger = new logger_1.ToolsLogger({ logPrefix: '@sap-ux/odata-service-inquirer' });
|
|
26
|
+
exports.default = LoggerHelper;
|
|
27
|
+
//# sourceMappingURL=logger-helper.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ListChoiceOptions } from 'inquirer';
|
|
2
|
+
import { ErrorHandler } from '../error-handler/error-handler';
|
|
3
|
+
import { type DatasourceTypePromptOptions } from '../types';
|
|
4
|
+
export declare const errorHandler: ErrorHandler;
|
|
5
|
+
/**
|
|
6
|
+
* Get the datasource type choices.
|
|
7
|
+
*
|
|
8
|
+
* @param options - optionally include some of the supported datasource type choices
|
|
9
|
+
* @param options.includeNone - Include the `NONE` option in the datasource type prompt
|
|
10
|
+
* @param options.includeProjectSpecificDest - Include the `projectSpecificDestination` option in the datasource type prompt
|
|
11
|
+
* @returns The datasource type choices
|
|
12
|
+
*/
|
|
13
|
+
export declare function getDatasourceTypeChoices({ includeNone, includeProjectSpecificDest }?: DatasourceTypePromptOptions): ListChoiceOptions[];
|
|
14
|
+
//# sourceMappingURL=prompt-helpers.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getDatasourceTypeChoices = exports.errorHandler = void 0;
|
|
4
|
+
const btp_utils_1 = require("@sap-ux/btp-utils");
|
|
5
|
+
const error_handler_1 = require("../error-handler/error-handler");
|
|
6
|
+
const i18n_1 = require("../i18n");
|
|
7
|
+
const types_1 = require("../types");
|
|
8
|
+
// Error handling is a cross-cutting concern, a single instance is required
|
|
9
|
+
exports.errorHandler = new error_handler_1.ErrorHandler();
|
|
10
|
+
/**
|
|
11
|
+
* Get the datasource type choices.
|
|
12
|
+
*
|
|
13
|
+
* @param options - optionally include some of the supported datasource type choices
|
|
14
|
+
* @param options.includeNone - Include the `NONE` option in the datasource type prompt
|
|
15
|
+
* @param options.includeProjectSpecificDest - Include the `projectSpecificDestination` option in the datasource type prompt
|
|
16
|
+
* @returns The datasource type choices
|
|
17
|
+
*/
|
|
18
|
+
function getDatasourceTypeChoices({ includeNone = false, includeProjectSpecificDest = false } = {}) {
|
|
19
|
+
const choices = [
|
|
20
|
+
{
|
|
21
|
+
name: (0, i18n_1.t)('prompts.datasourceType.sapSystemChoiceText'),
|
|
22
|
+
value: types_1.DatasourceType.sapSystem
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
name: (0, i18n_1.t)('prompts.datasourceType.odataServiceUrlChoiceText'),
|
|
26
|
+
value: types_1.DatasourceType.odataServiceUrl
|
|
27
|
+
},
|
|
28
|
+
{ name: (0, i18n_1.t)('prompts.datasourceType.businessHubChoiceText'), value: types_1.DatasourceType.businessHub }
|
|
29
|
+
];
|
|
30
|
+
if ((0, btp_utils_1.isAppStudio)() && includeProjectSpecificDest) {
|
|
31
|
+
choices.push({
|
|
32
|
+
name: (0, i18n_1.t)('prompts.datasourceType.projectSpecificDestChoiceText'),
|
|
33
|
+
value: types_1.DatasourceType.projectSpecificDestination
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
choices.push({ name: (0, i18n_1.t)('prompts.datasourceType.capProjectChoiceText'), value: types_1.DatasourceType.capProject });
|
|
37
|
+
choices.push({ name: (0, i18n_1.t)('prompts.datasourceType.metadataFileChoiceText'), value: types_1.DatasourceType.metadataFile });
|
|
38
|
+
if (includeNone) {
|
|
39
|
+
choices.unshift({ name: (0, i18n_1.t)('prompts.datasourceType.noneName'), value: types_1.DatasourceType.none });
|
|
40
|
+
}
|
|
41
|
+
return choices;
|
|
42
|
+
}
|
|
43
|
+
exports.getDatasourceTypeChoices = getDatasourceTypeChoices;
|
|
44
|
+
//# sourceMappingURL=prompt-helpers.js.map
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type OdataServicePromptOptions, type OdataServiceQuestion } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Get the prompts for the OData service inquirer.
|
|
4
|
+
*
|
|
5
|
+
* @param promptOptions - options that can control some of the prompt behavior. See {@link OdataServicePromptOptions} for details
|
|
6
|
+
* @returns the prompts used to provide input for OData service generation
|
|
7
|
+
*/
|
|
8
|
+
export declare function getQuestions(promptOptions?: OdataServicePromptOptions): Promise<OdataServiceQuestion[]>;
|
|
9
|
+
//# sourceMappingURL=prompts.d.ts.map
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.getQuestions = void 0;
|
|
16
|
+
const yeoman_ui_types_1 = require("@sap-devx/yeoman-ui-types");
|
|
17
|
+
const inquirer_common_1 = require("@sap-ux/inquirer-common");
|
|
18
|
+
const i18n_1 = require("../i18n");
|
|
19
|
+
const types_1 = require("../types");
|
|
20
|
+
const metadata_file_1 = require("./datasources/metadata-file");
|
|
21
|
+
const prompt_helpers_1 = require("./prompt-helpers");
|
|
22
|
+
const questions_1 = require("./datasources/cap-project/questions");
|
|
23
|
+
const logger_helper_1 = __importDefault(require("./logger-helper"));
|
|
24
|
+
/**
|
|
25
|
+
* Get the prompts for the OData service inquirer.
|
|
26
|
+
*
|
|
27
|
+
* @param promptOptions - options that can control some of the prompt behavior. See {@link OdataServicePromptOptions} for details
|
|
28
|
+
* @returns the prompts used to provide input for OData service generation
|
|
29
|
+
*/
|
|
30
|
+
function getQuestions(promptOptions) {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
const questions = [getDatasourceTypeQuestion(promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions.datasourceType)];
|
|
33
|
+
// Add conditional questions depending on the selected source
|
|
34
|
+
questions.push(...(yield getDatasourceTypeConditionalQuestions(promptOptions)));
|
|
35
|
+
return questions;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.getQuestions = getQuestions;
|
|
39
|
+
/**
|
|
40
|
+
* Get the datasource type question.
|
|
41
|
+
*
|
|
42
|
+
* @param options - options that can control some of the prompt behavior. See {@link DatasourceTypePromptOptions} for details
|
|
43
|
+
* @returns the datasource type question
|
|
44
|
+
*/
|
|
45
|
+
function getDatasourceTypeQuestion(options) {
|
|
46
|
+
var _a;
|
|
47
|
+
const choices = (0, prompt_helpers_1.getDatasourceTypeChoices)(options);
|
|
48
|
+
return {
|
|
49
|
+
type: 'list',
|
|
50
|
+
name: types_1.promptNames.datasourceType,
|
|
51
|
+
guiOptions: {
|
|
52
|
+
breadcrumb: true
|
|
53
|
+
},
|
|
54
|
+
default: (_a = options === null || options === void 0 ? void 0 : options.default) !== null && _a !== void 0 ? _a : -1,
|
|
55
|
+
message: (0, i18n_1.t)('prompts.datasourceType.message'),
|
|
56
|
+
choices,
|
|
57
|
+
additionalMessages: (source) => {
|
|
58
|
+
var _a;
|
|
59
|
+
if ([
|
|
60
|
+
types_1.DatasourceType.businessHub,
|
|
61
|
+
types_1.DatasourceType.none,
|
|
62
|
+
types_1.DatasourceType.odataServiceUrl,
|
|
63
|
+
types_1.DatasourceType.projectSpecificDestination,
|
|
64
|
+
types_1.DatasourceType.sapSystem
|
|
65
|
+
].includes(source)) {
|
|
66
|
+
(_a = logger_helper_1.default.logger) === null || _a === void 0 ? void 0 : _a.warn((0, i18n_1.t)('prompts.datasourceType.notYetImplementedWarningMessage', { datasourceType: source }));
|
|
67
|
+
return {
|
|
68
|
+
message: (0, i18n_1.t)('prompts.datasourceType.notYetImplementedWarningMessage', { datasourceType: source }),
|
|
69
|
+
severity: yeoman_ui_types_1.Severity.warning
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
if (source === types_1.DatasourceType.businessHub) {
|
|
73
|
+
return {
|
|
74
|
+
message: (0, i18n_1.t)('prompts.nonUIServiceTypeWarningMessage', {
|
|
75
|
+
serviceTypeDesc: (0, i18n_1.t)('prompts.datasourceType.businessHubName')
|
|
76
|
+
}),
|
|
77
|
+
severity: yeoman_ui_types_1.Severity.warning
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Apply addiitonal when conditions based on the datasource type answer.
|
|
85
|
+
*
|
|
86
|
+
* @param promptOptions - options that can control some of the prompt behavior. See {@link OdataServicePromptOptions} for details
|
|
87
|
+
* @returns the conditional questions based on the datasource type answer
|
|
88
|
+
*/
|
|
89
|
+
function getDatasourceTypeConditionalQuestions(promptOptions) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const conditionalQuestions = [];
|
|
92
|
+
conditionalQuestions.push(...(0, inquirer_common_1.withCondition)([(0, metadata_file_1.getMetadataFileQuestion)(promptOptions === null || promptOptions === void 0 ? void 0 : promptOptions.metadataFilePath)], (answers) => answers.datasourceType === types_1.DatasourceType.metadataFile));
|
|
93
|
+
conditionalQuestions.push(...(0, inquirer_common_1.withCondition)((0, questions_1.getLocalCapProjectPrompts)(promptOptions), (answers) => answers.datasourceType === types_1.DatasourceType.capProject));
|
|
94
|
+
//...further data sources to be added here
|
|
95
|
+
return conditionalQuestions;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=prompts.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OdataVersion } from '@sap-ux/odata-service-writer';
|
|
2
|
+
/**
|
|
3
|
+
* Validator function to verify if the specified metadata edmx version matches the specified required odata version.
|
|
4
|
+
*
|
|
5
|
+
* @param edmx the edmx to validate
|
|
6
|
+
* @param requiredVersion the required odata version to validate against
|
|
7
|
+
* @returns version and/or validation error message
|
|
8
|
+
*/
|
|
9
|
+
export declare function validateODataVersion(edmx: string, requiredVersion?: OdataVersion): {
|
|
10
|
+
validationMsg?: string;
|
|
11
|
+
version?: OdataVersion;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=validators.d.ts.map
|
|
@@ -0,0 +1,45 @@
|
|
|
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.validateODataVersion = void 0;
|
|
7
|
+
const i18n_1 = require("../i18n");
|
|
8
|
+
const odata_service_writer_1 = require("@sap-ux/odata-service-writer");
|
|
9
|
+
const wing_service_explorer_1 = require("@sap/wing-service-explorer");
|
|
10
|
+
const logger_helper_1 = __importDefault(require("./logger-helper"));
|
|
11
|
+
/**
|
|
12
|
+
* Validator function to verify if the specified metadata edmx version matches the specified required odata version.
|
|
13
|
+
*
|
|
14
|
+
* @param edmx the edmx to validate
|
|
15
|
+
* @param requiredVersion the required odata version to validate against
|
|
16
|
+
* @returns version and/or validation error message
|
|
17
|
+
*/
|
|
18
|
+
function validateODataVersion(edmx, requiredVersion) {
|
|
19
|
+
const metadataFactory = wing_service_explorer_1.MetadataFactory.getMetadataFactory();
|
|
20
|
+
try {
|
|
21
|
+
const explorer = metadataFactory.getMetadataExplorer(edmx);
|
|
22
|
+
// Wing service explorer does not export the type of the protocol, so we need to check the string
|
|
23
|
+
const version = explorer.getProtocolType().indexOf('v4') > 0 ? odata_service_writer_1.OdataVersion.v4 : odata_service_writer_1.OdataVersion.v2;
|
|
24
|
+
if (requiredVersion && requiredVersion !== version) {
|
|
25
|
+
const odataErrorMsg = (0, i18n_1.t)('prompts.validationMessages.odataVersionMismatch', {
|
|
26
|
+
providedOdataVersion: version,
|
|
27
|
+
requiredOdataVersion: requiredVersion
|
|
28
|
+
});
|
|
29
|
+
logger_helper_1.default.logger.error(odataErrorMsg);
|
|
30
|
+
return {
|
|
31
|
+
validationMsg: odataErrorMsg
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
version
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
return {
|
|
40
|
+
validationMsg: (0, i18n_1.t)('prompts.validationMessages.metadataInvalid')
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.validateODataVersion = validateODataVersion;
|
|
45
|
+
//# sourceMappingURL=validators.js.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{
|
|
2
|
+
"prompts": {
|
|
3
|
+
"datasourceType": {
|
|
4
|
+
"message": "Data source",
|
|
5
|
+
"projectSpecificDestName": "Project Specific Destination",
|
|
6
|
+
"businessHubName": "SAP Business Accelerator Hub",
|
|
7
|
+
"sapSystemName": "SAP System",
|
|
8
|
+
"odataServiceUrlName": "OData Service Url",
|
|
9
|
+
"capProjectName": "Local CAP Project",
|
|
10
|
+
"metadataFileName": "Metadata File",
|
|
11
|
+
"noneName": "None",
|
|
12
|
+
"projectSpecificDestChoiceText": "Connect to a $t(prompts.datasourceType.projectSpecificDestName)",
|
|
13
|
+
"businessHubChoiceText": "Connect to $t(prompts.datasourceType.businessHubName)",
|
|
14
|
+
"sapSystemChoiceText": "Connect to a $t(prompts.datasourceType.sapSystemName)",
|
|
15
|
+
"odataServiceUrlChoiceText": "Connect to an $t(prompts.datasourceType.odataServiceUrlName)",
|
|
16
|
+
"capProjectChoiceText": "Use a $t(prompts.datasourceType.capProjectName)",
|
|
17
|
+
"metadataFileChoiceText": "Upload a $t(prompts.datasourceType.metadataFileName)",
|
|
18
|
+
"notYetImplementedWarningMessage": "The selected data source type: {{ datasourceType }} is not yet implemented."
|
|
19
|
+
},
|
|
20
|
+
"metadataFile": {
|
|
21
|
+
"message": "Metadata file path",
|
|
22
|
+
"description": "Upload a metadata file",
|
|
23
|
+
"placeholder_odata_service_url": "/here/goes/your/serviceurl/"
|
|
24
|
+
},
|
|
25
|
+
"capProject": {
|
|
26
|
+
"message": "Choose your CAP project",
|
|
27
|
+
"description": "Select a local CAP project",
|
|
28
|
+
"breadcrumb": "CAP Project",
|
|
29
|
+
"enterCapPathChoiceName": "Manually select CAP project folder path"
|
|
30
|
+
},
|
|
31
|
+
"capProjectPath": {
|
|
32
|
+
"message": "CAP project folder path",
|
|
33
|
+
"description": "Select a local CAP project",
|
|
34
|
+
"breadcrumb": "CAP Project",
|
|
35
|
+
"enterCapPathChoiceName": "Manually select CAP project folder path"
|
|
36
|
+
},
|
|
37
|
+
"capService": {
|
|
38
|
+
"message": "OData service",
|
|
39
|
+
"description": "Select a local CAP service",
|
|
40
|
+
"breadcrumb": "CAP Service",
|
|
41
|
+
"enterCapPathChoiceName": "Manually select CAP service folder path"
|
|
42
|
+
},
|
|
43
|
+
"validationMessages": {
|
|
44
|
+
"odataVersionMismatch": "The template you have chosen supports V{{requiredOdataVersion}} OData services only. The provided version is V{{providedOdataVersion}}.",
|
|
45
|
+
"metadataInvalid": "The service metadata is invalid.",
|
|
46
|
+
"metadataFilePathNotValid": "Metadata file does not exist or is not accessible. Please specify a valid file path.",
|
|
47
|
+
"capProjectNotFound": "The folder you have selected does not seem to contain a valid CAP project. Please check and try again."
|
|
48
|
+
},
|
|
49
|
+
"nonUIServiceTypeWarningMessage": "Please note that {{serviceTypeDesc}} services are not intended to be used for the generation of SAP Fiori UI applications"
|
|
50
|
+
},
|
|
51
|
+
"errors": {
|
|
52
|
+
"cannotReadCapServiceMetadata": "An error occurred reading CAP service metadata: {{serviceName}}. See log for more details.",
|
|
53
|
+
"capModelAndServicesLoadError": "An error occurred loading the CAP model and services. {{- error}}",
|
|
54
|
+
"capServiceUrlPathNotDefined": "An error occurred reading CAP service metadata: {{serviceName}}. CAP service property `urlPath` is not defined but is required.",
|
|
55
|
+
"unknownError": "An error occurred: {{- error}}",
|
|
56
|
+
"servicesUnavailable": "An error occurred retrieving service(s) for SAP System.",
|
|
57
|
+
"certificateError": "A certificate error has occurred: {{- error}}",
|
|
58
|
+
"urlCertValidationError": "The system URL is using {{certErrorReason}} security certificate.",
|
|
59
|
+
"authenticationFailed": "Authentication incorrect {{error}}",
|
|
60
|
+
"authenticationTimeout": "Authorization was not verified within the allowed time. Please ensure you have authenticated using the associated browser window.",
|
|
61
|
+
"invalidUrl": "Not a valid URL",
|
|
62
|
+
"connectionError": "A connection error occurred, please ensure the target host is available on the network: {{- error}}",
|
|
63
|
+
"serviceUnavailable": "Selected service is returning an error.",
|
|
64
|
+
"catalogServiceNotActive": "Catalog service is not active",
|
|
65
|
+
"internalServerError": "The URL you have provided cannot be accessed and is returning: '{{- error}}'. Please ensure that the URL is accessible externally.",
|
|
66
|
+
"urlNotFound": "URL not found",
|
|
67
|
+
"odataServiceUrlNotFound": "The service URL you have provided is not a valid OData Service. Fiori applications require an OData service as the data source.",
|
|
68
|
+
"destinationUnavailable": "The selected destination references an instance that is not available. Please check your destination configuration and try again.",
|
|
69
|
+
"destinationNotFound": "The destination is mis-configured, HTTP Error 404 returned, the requested resource could not be found.",
|
|
70
|
+
"destinationMisconfigured": "The destination is mis-configured, HTML5.DynamicDestination property is missing.",
|
|
71
|
+
"noServicesAvailable": "There are no V{{version}} OData services available from the selected system and the template you have chosen supports V{{version}} OData services only",
|
|
72
|
+
"redirectError": "A redirect response was received from the server",
|
|
73
|
+
"abapEnvsUnavailable": "ABAP environments unavailable",
|
|
74
|
+
"noSuchHostError": "No such host is known"
|
|
75
|
+
},
|
|
76
|
+
"texts": {
|
|
77
|
+
"anExpiredCert": "an expired",
|
|
78
|
+
"aSelfSignedCert": "a self-signed",
|
|
79
|
+
"anUnknownOrInvalidCert": "an unknown or invalid",
|
|
80
|
+
"anUntrustedRootCert": "an untrusted root"
|
|
81
|
+
},
|
|
82
|
+
"guidedAnswers": {
|
|
83
|
+
"validationErrorHelpText": "Need help with this error?"
|
|
84
|
+
},
|
|
85
|
+
"telemetry": {
|
|
86
|
+
"unknownOsText": "Unknown"
|
|
87
|
+
}
|
|
88
|
+
}
|