@sap-ux/adp-tooling 0.19.10 → 1.0.0
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/dist/abap/client.d.ts +1 -1
- package/dist/abap/client.js +8 -13
- package/dist/abap/config.js +5 -8
- package/dist/abap/index.d.ts +3 -3
- package/dist/abap/index.js +3 -19
- package/dist/abap/provider.js +5 -8
- package/dist/base/abap/manifest-service.d.ts +1 -1
- package/dist/base/abap/manifest-service.js +9 -18
- package/dist/base/cf.js +8 -11
- package/dist/base/change-utils.d.ts +1 -1
- package/dist/base/change-utils.js +49 -62
- package/dist/base/constants/index.js +12 -15
- package/dist/base/credentials.d.ts +2 -2
- package/dist/base/credentials.js +6 -9
- package/dist/base/helper.d.ts +1 -1
- package/dist/base/helper.js +40 -57
- package/dist/base/project-builder.js +3 -6
- package/dist/base/prompt.d.ts +1 -1
- package/dist/base/prompt.js +19 -25
- package/dist/btp/api.d.ts +1 -1
- package/dist/btp/api.js +10 -18
- package/dist/btp/index.d.ts +1 -1
- package/dist/btp/index.js +1 -17
- package/dist/cf/app/discovery.d.ts +1 -1
- package/dist/cf/app/discovery.js +11 -18
- package/dist/cf/app/html5-repo.d.ts +1 -1
- package/dist/cf/app/html5-repo.js +24 -32
- package/dist/cf/app/index.d.ts +2 -2
- package/dist/cf/app/index.js +2 -18
- package/dist/cf/core/auth.d.ts +1 -1
- package/dist/cf/core/auth.js +4 -8
- package/dist/cf/core/config.d.ts +1 -1
- package/dist/cf/core/config.js +9 -15
- package/dist/cf/core/index.d.ts +2 -2
- package/dist/cf/core/index.js +2 -18
- package/dist/cf/deploy.d.ts +1 -1
- package/dist/cf/deploy.js +33 -44
- package/dist/cf/index.d.ts +6 -6
- package/dist/cf/index.js +6 -22
- package/dist/cf/project/index.d.ts +3 -3
- package/dist/cf/project/index.js +3 -19
- package/dist/cf/project/mta.d.ts +1 -1
- package/dist/cf/project/mta.js +23 -66
- package/dist/cf/project/yaml-loader.d.ts +1 -1
- package/dist/cf/project/yaml-loader.js +8 -16
- package/dist/cf/project/yaml.d.ts +2 -2
- package/dist/cf/project/yaml.js +28 -72
- package/dist/cf/services/api.d.ts +1 -1
- package/dist/cf/services/api.js +46 -93
- package/dist/cf/services/cli.d.ts +1 -1
- package/dist/cf/services/cli.js +31 -42
- package/dist/cf/services/destinations.js +12 -48
- package/dist/cf/services/index.d.ts +5 -5
- package/dist/cf/services/index.js +5 -21
- package/dist/cf/services/manifest.d.ts +1 -1
- package/dist/cf/services/manifest.js +9 -13
- package/dist/cf/services/ssh.js +14 -22
- package/dist/cf/utils/index.d.ts +1 -1
- package/dist/cf/utils/index.js +1 -17
- package/dist/cf/utils/validation.d.ts +1 -1
- package/dist/cf/utils/validation.js +12 -18
- package/dist/common/flp-parameters.d.ts +1 -1
- package/dist/common/flp-parameters.js +1 -4
- package/dist/common/index.d.ts +1 -1
- package/dist/common/index.js +1 -17
- package/dist/i18n.js +8 -16
- package/dist/index.d.ts +23 -23
- package/dist/index.js +23 -46
- package/dist/preview/adp-preview.d.ts +1 -1
- package/dist/preview/adp-preview.js +41 -39
- package/dist/preview/change-handler.d.ts +1 -1
- package/dist/preview/change-handler.js +51 -59
- package/dist/preview/descriptor-change-handler.d.ts +1 -1
- package/dist/preview/descriptor-change-handler.js +18 -21
- package/dist/preview/ovp-routes-handler.js +11 -13
- package/dist/preview/routes-handler.js +36 -71
- package/dist/preview/utils.d.ts +1 -1
- package/dist/preview/utils.js +5 -8
- package/dist/prompts/add-annotations-to-odata/index.d.ts +1 -1
- package/dist/prompts/add-annotations-to-odata/index.js +24 -26
- package/dist/prompts/add-component-usages/index.d.ts +1 -1
- package/dist/prompts/add-component-usages/index.js +41 -43
- package/dist/prompts/add-new-model/index.d.ts +1 -1
- package/dist/prompts/add-new-model/index.js +75 -80
- package/dist/prompts/change-data-source/index.d.ts +1 -1
- package/dist/prompts/change-data-source/index.js +19 -22
- package/dist/prompts/change-inbound/index.d.ts +1 -1
- package/dist/prompts/change-inbound/index.js +11 -14
- package/dist/prompts/index.d.ts +5 -5
- package/dist/prompts/index.js +5 -15
- package/dist/source/applications.d.ts +2 -2
- package/dist/source/applications.js +7 -11
- package/dist/source/index.d.ts +3 -3
- package/dist/source/index.js +3 -19
- package/dist/source/manifest.d.ts +1 -1
- package/dist/source/manifest.js +15 -25
- package/dist/source/systems.d.ts +1 -1
- package/dist/source/systems.js +20 -27
- package/dist/types.d.ts +1 -1
- package/dist/types.js +64 -17
- package/dist/ui5/fetch.d.ts +1 -1
- package/dist/ui5/fetch.js +8 -12
- package/dist/ui5/format.d.ts +1 -1
- package/dist/ui5/format.js +17 -29
- package/dist/ui5/index.d.ts +4 -4
- package/dist/ui5/index.js +4 -20
- package/dist/ui5/network.d.ts +1 -1
- package/dist/ui5/network.js +1 -4
- package/dist/ui5/validator.js +14 -20
- package/dist/ui5/version-info.d.ts +1 -1
- package/dist/ui5/version-info.js +25 -36
- package/dist/writer/cf.d.ts +1 -1
- package/dist/writer/cf.js +35 -43
- package/dist/writer/changes/writer-factory.d.ts +2 -2
- package/dist/writer/changes/writer-factory.js +10 -13
- package/dist/writer/changes/writers/annotations-writer.d.ts +1 -1
- package/dist/writer/changes/writers/annotations-writer.js +11 -46
- package/dist/writer/changes/writers/component-usages-writer.d.ts +1 -1
- package/dist/writer/changes/writers/component-usages-writer.js +9 -12
- package/dist/writer/changes/writers/data-source-writer.d.ts +1 -1
- package/dist/writer/changes/writers/data-source-writer.js +7 -10
- package/dist/writer/changes/writers/inbound-writer.d.ts +1 -1
- package/dist/writer/changes/writers/inbound-writer.js +10 -13
- package/dist/writer/changes/writers/index.d.ts +5 -5
- package/dist/writer/changes/writers/index.js +5 -21
- package/dist/writer/changes/writers/new-model-writer.d.ts +1 -1
- package/dist/writer/changes/writers/new-model-writer.js +16 -20
- package/dist/writer/editors.d.ts +1 -1
- package/dist/writer/editors.js +6 -9
- package/dist/writer/i18n/index.d.ts +1 -1
- package/dist/writer/i18n/index.js +13 -17
- package/dist/writer/i18n/key-user-translations.js +9 -14
- package/dist/writer/inbound-navigation.d.ts +1 -1
- package/dist/writer/inbound-navigation.js +18 -27
- package/dist/writer/index.d.ts +1 -1
- package/dist/writer/index.js +36 -37
- package/dist/writer/manifest/descriptor-content.d.ts +2 -2
- package/dist/writer/manifest/descriptor-content.js +9 -15
- package/dist/writer/manifest/index.d.ts +1 -1
- package/dist/writer/manifest/index.js +1 -17
- package/dist/writer/options.d.ts +1 -1
- package/dist/writer/options.js +16 -27
- package/dist/writer/project-utils.d.ts +1 -1
- package/dist/writer/project-utils.js +49 -57
- package/dist/writer/writer-config.d.ts +2 -2
- package/dist/writer/writer-config.js +25 -30
- package/package.json +19 -17
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const destinations_1 = require("../../cf/services/destinations");
|
|
13
|
-
const types_1 = require("../../types");
|
|
14
|
-
const cf_1 = require("../../base/cf");
|
|
15
|
-
const helper_1 = require("../../base/helper");
|
|
16
|
-
const project_input_validator_1 = require("@sap-ux/project-input-validator");
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { listDestinations, isOnPremiseDestination, isAppStudio } from '@sap-ux/btp-utils';
|
|
4
|
+
import { Severity, MessageType } from '@sap-devx/yeoman-ui-types';
|
|
5
|
+
import { t } from '../../i18n.js';
|
|
6
|
+
import { getChangesByType } from '../../base/change-utils.js';
|
|
7
|
+
import { getBtpDestinations } from '../../cf/services/destinations.js';
|
|
8
|
+
import { ChangeType, NamespacePrefix, ServiceType, FlexLayer } from '../../types.js';
|
|
9
|
+
import { isCFEnvironment } from '../../base/cf.js';
|
|
10
|
+
import { getAdpConfig } from '../../base/helper.js';
|
|
11
|
+
import { validateEmptyString, validateEmptySpaces, validateSpecialChars, hasContentDuplication, hasCustomerPrefix, isDataSourceURI, validateJSON } from '@sap-ux/project-input-validator';
|
|
17
12
|
/**
|
|
18
13
|
* Reads the routes array from the xs-app.json file in the project's webapp folder.
|
|
19
14
|
* Returns an empty array if the file does not exist or cannot be parsed.
|
|
@@ -23,8 +18,8 @@ const project_input_validator_1 = require("@sap-ux/project-input-validator");
|
|
|
23
18
|
*/
|
|
24
19
|
function readXsAppRoutes(projectPath) {
|
|
25
20
|
try {
|
|
26
|
-
const xsAppPath =
|
|
27
|
-
const content = JSON.parse(
|
|
21
|
+
const xsAppPath = join(projectPath, 'webapp', 'xs-app.json');
|
|
22
|
+
const content = JSON.parse(readFileSync(xsAppPath, 'utf-8'));
|
|
28
23
|
return Array.isArray(content?.routes) ? content.routes : [];
|
|
29
24
|
}
|
|
30
25
|
catch {
|
|
@@ -32,9 +27,9 @@ function readXsAppRoutes(projectPath) {
|
|
|
32
27
|
}
|
|
33
28
|
}
|
|
34
29
|
const serviceTypeChoices = [
|
|
35
|
-
{ name:
|
|
36
|
-
{ name:
|
|
37
|
-
{ name:
|
|
30
|
+
{ name: ServiceType.ODATA_V2, value: ServiceType.ODATA_V2 },
|
|
31
|
+
{ name: ServiceType.ODATA_V4, value: ServiceType.ODATA_V4 },
|
|
32
|
+
{ name: ServiceType.HTTP, value: ServiceType.HTTP }
|
|
38
33
|
];
|
|
39
34
|
/**
|
|
40
35
|
* Exucute generic validation for input.
|
|
@@ -43,7 +38,7 @@ const serviceTypeChoices = [
|
|
|
43
38
|
* @returns {string | boolean} An error message if the value is an empty string, or true if it is not.
|
|
44
39
|
*/
|
|
45
40
|
function validatePromptInput(value) {
|
|
46
|
-
const validators = [
|
|
41
|
+
const validators = [validateEmptyString, validateEmptySpaces, validateSpecialChars];
|
|
47
42
|
for (const validator of validators) {
|
|
48
43
|
const validationResult = validator(value);
|
|
49
44
|
if (typeof validationResult === 'string') {
|
|
@@ -51,7 +46,7 @@ function validatePromptInput(value) {
|
|
|
51
46
|
}
|
|
52
47
|
}
|
|
53
48
|
if (!/[a-zA-Z0-9]$/.test(value)) {
|
|
54
|
-
return
|
|
49
|
+
return t('validators.errorInputMustEndWithAlphanumeric');
|
|
55
50
|
}
|
|
56
51
|
return true;
|
|
57
52
|
}
|
|
@@ -63,16 +58,16 @@ function validatePromptInput(value) {
|
|
|
63
58
|
* @returns {boolean | string} True if the value is valid, or an error message if validation fails.
|
|
64
59
|
*/
|
|
65
60
|
function validateCustomerValue(value, label) {
|
|
66
|
-
if (!
|
|
67
|
-
return
|
|
68
|
-
value:
|
|
69
|
-
prefix:
|
|
61
|
+
if (!hasCustomerPrefix(value)) {
|
|
62
|
+
return t('validators.errorInputInvalidValuePrefix', {
|
|
63
|
+
value: t(label),
|
|
64
|
+
prefix: NamespacePrefix.CUSTOMER
|
|
70
65
|
});
|
|
71
66
|
}
|
|
72
67
|
if (!value.replace('customer.', '').length) {
|
|
73
|
-
return
|
|
74
|
-
value:
|
|
75
|
-
prefix:
|
|
68
|
+
return t('validators.errorCustomerEmptyValue', {
|
|
69
|
+
value: t(label),
|
|
70
|
+
prefix: NamespacePrefix.CUSTOMER
|
|
76
71
|
});
|
|
77
72
|
}
|
|
78
73
|
return true;
|
|
@@ -84,11 +79,11 @@ function validateCustomerValue(value, label) {
|
|
|
84
79
|
* @returns {boolean | string} True if the JSON is valid, or an error message if validation fails.
|
|
85
80
|
*/
|
|
86
81
|
function validatePromptJSON(value) {
|
|
87
|
-
const validationResult =
|
|
82
|
+
const validationResult = validateEmptyString(value);
|
|
88
83
|
if (typeof validationResult === 'string') {
|
|
89
84
|
return true;
|
|
90
85
|
}
|
|
91
|
-
return
|
|
86
|
+
return validateJSON(value);
|
|
92
87
|
}
|
|
93
88
|
/**
|
|
94
89
|
* Validates the OData Service name prompt.
|
|
@@ -109,8 +104,8 @@ function validatePromptODataName(value, isCustomerBase, changeFiles) {
|
|
|
109
104
|
return validationResult;
|
|
110
105
|
}
|
|
111
106
|
}
|
|
112
|
-
if (
|
|
113
|
-
return
|
|
107
|
+
if (hasContentDuplication(value, 'dataSource', changeFiles)) {
|
|
108
|
+
return t('validators.errorDuplicatedValueOData');
|
|
114
109
|
}
|
|
115
110
|
return true;
|
|
116
111
|
}
|
|
@@ -121,12 +116,12 @@ function validatePromptODataName(value, isCustomerBase, changeFiles) {
|
|
|
121
116
|
* @returns {boolean | string} True if the URI is valid, or an error message if validation fails.
|
|
122
117
|
*/
|
|
123
118
|
function validatePromptURI(value) {
|
|
124
|
-
const validationResult =
|
|
119
|
+
const validationResult = validateEmptyString(value);
|
|
125
120
|
if (typeof validationResult === 'string') {
|
|
126
121
|
return validationResult;
|
|
127
122
|
}
|
|
128
|
-
if (!
|
|
129
|
-
return
|
|
123
|
+
if (!isDataSourceURI(value)) {
|
|
124
|
+
return t('validators.errorInvalidDataSourceURI');
|
|
130
125
|
}
|
|
131
126
|
return true;
|
|
132
127
|
}
|
|
@@ -151,11 +146,11 @@ function buildResultingServiceUrl(destinationUrl, serviceUri) {
|
|
|
151
146
|
* @param {ServiceType} serviceType - The selected service type.
|
|
152
147
|
* @returns {string | undefined} The OData version string ('2.0' or '4.0'), or undefined for HTTP.
|
|
153
148
|
*/
|
|
154
|
-
function getODataVersionFromServiceType(serviceType) {
|
|
155
|
-
if (serviceType ===
|
|
149
|
+
export function getODataVersionFromServiceType(serviceType) {
|
|
150
|
+
if (serviceType === ServiceType.ODATA_V2) {
|
|
156
151
|
return '2.0';
|
|
157
152
|
}
|
|
158
|
-
if (serviceType ===
|
|
153
|
+
if (serviceType === ServiceType.ODATA_V4) {
|
|
159
154
|
return '4.0';
|
|
160
155
|
}
|
|
161
156
|
return undefined;
|
|
@@ -171,15 +166,15 @@ function getODataVersionFromServiceType(serviceType) {
|
|
|
171
166
|
*/
|
|
172
167
|
async function getAbapServiceUrl(projectPath) {
|
|
173
168
|
try {
|
|
174
|
-
const { target } = (await
|
|
169
|
+
const { target } = (await getAdpConfig(projectPath, 'ui5.yaml'));
|
|
175
170
|
if (!target) {
|
|
176
171
|
return undefined;
|
|
177
172
|
}
|
|
178
|
-
if (!
|
|
173
|
+
if (!isAppStudio()) {
|
|
179
174
|
return target.url;
|
|
180
175
|
}
|
|
181
176
|
if (target.destination) {
|
|
182
|
-
const destinations = await
|
|
177
|
+
const destinations = await listDestinations();
|
|
183
178
|
return destinations[target.destination]?.Host;
|
|
184
179
|
}
|
|
185
180
|
}
|
|
@@ -198,7 +193,7 @@ async function getAbapServiceUrl(projectPath) {
|
|
|
198
193
|
*/
|
|
199
194
|
async function getDestinationChoices(projectPath, logger) {
|
|
200
195
|
try {
|
|
201
|
-
const destinations = await
|
|
196
|
+
const destinations = await getBtpDestinations(projectPath);
|
|
202
197
|
const choices = Object.entries(destinations).map(([name, dest]) => ({
|
|
203
198
|
name,
|
|
204
199
|
value: dest
|
|
@@ -207,7 +202,7 @@ async function getDestinationChoices(projectPath, logger) {
|
|
|
207
202
|
}
|
|
208
203
|
catch (e) {
|
|
209
204
|
logger?.error(e.message);
|
|
210
|
-
return { choices: [], error:
|
|
205
|
+
return { choices: [], error: t('error.errorFetchingDestinations') };
|
|
211
206
|
}
|
|
212
207
|
}
|
|
213
208
|
/**
|
|
@@ -219,21 +214,21 @@ async function getDestinationChoices(projectPath, logger) {
|
|
|
219
214
|
* @param {AppWizard} [appWizard] - Optional AppWizard instance for showing notifications.
|
|
220
215
|
* @returns {YUIQuestion<NewModelAnswers>[]} The questions/prompts.
|
|
221
216
|
*/
|
|
222
|
-
async function getPrompts(projectPath, layer, logger, appWizard) {
|
|
223
|
-
const isCustomerBase =
|
|
224
|
-
const defaultSeviceName = isCustomerBase ?
|
|
225
|
-
const isCFEnv = await
|
|
217
|
+
export async function getPrompts(projectPath, layer, logger, appWizard) {
|
|
218
|
+
const isCustomerBase = FlexLayer.CUSTOMER_BASE === layer;
|
|
219
|
+
const defaultSeviceName = isCustomerBase ? NamespacePrefix.CUSTOMER : NamespacePrefix.EMPTY;
|
|
220
|
+
const isCFEnv = await isCFEnvironment(projectPath);
|
|
226
221
|
const abapServiceUrl = isCFEnv ? undefined : await getAbapServiceUrl(projectPath);
|
|
227
222
|
const changeFiles = [
|
|
228
|
-
...
|
|
229
|
-
...
|
|
223
|
+
...getChangesByType(projectPath, ChangeType.ADD_NEW_MODEL),
|
|
224
|
+
...getChangesByType(projectPath, ChangeType.ADD_NEW_DATA_SOURCE)
|
|
230
225
|
];
|
|
231
226
|
let destinationError;
|
|
232
227
|
let destinationChoices;
|
|
233
228
|
if (isCFEnv) {
|
|
234
229
|
({ choices: destinationChoices, error: destinationError } = await getDestinationChoices(projectPath, logger));
|
|
235
230
|
if (destinationError) {
|
|
236
|
-
appWizard?.showError(destinationError,
|
|
231
|
+
appWizard?.showError(destinationError, MessageType.notification);
|
|
237
232
|
}
|
|
238
233
|
}
|
|
239
234
|
const buildResultingUrlMessage = (i18nKey, uri, previousAnswers) => {
|
|
@@ -243,42 +238,42 @@ async function getPrompts(projectPath, layer, logger, appWizard) {
|
|
|
243
238
|
return undefined;
|
|
244
239
|
}
|
|
245
240
|
return {
|
|
246
|
-
message:
|
|
247
|
-
severity:
|
|
241
|
+
message: t(i18nKey, { url: resultingUrl, interpolation: { escapeValue: false } }),
|
|
242
|
+
severity: Severity.information
|
|
248
243
|
};
|
|
249
244
|
};
|
|
250
245
|
return [
|
|
251
246
|
{
|
|
252
247
|
type: 'list',
|
|
253
248
|
name: 'serviceType',
|
|
254
|
-
message:
|
|
255
|
-
choices: isCFEnv ? serviceTypeChoices : serviceTypeChoices.filter((c) => c.value !==
|
|
249
|
+
message: t('prompts.serviceTypeLabel'),
|
|
250
|
+
choices: isCFEnv ? serviceTypeChoices : serviceTypeChoices.filter((c) => c.value !== ServiceType.HTTP),
|
|
256
251
|
store: false,
|
|
257
|
-
validate:
|
|
252
|
+
validate: validateEmptyString,
|
|
258
253
|
guiOptions: {
|
|
259
254
|
mandatory: true,
|
|
260
|
-
hint:
|
|
255
|
+
hint: t('prompts.serviceTypeTooltip')
|
|
261
256
|
}
|
|
262
257
|
},
|
|
263
258
|
{
|
|
264
259
|
type: 'list',
|
|
265
260
|
name: 'destination',
|
|
266
|
-
message:
|
|
261
|
+
message: t('prompts.destinationLabel'),
|
|
267
262
|
choices: () => destinationChoices ?? [],
|
|
268
263
|
when: () => isCFEnv,
|
|
269
264
|
guiOptions: {
|
|
270
265
|
mandatory: true,
|
|
271
|
-
hint:
|
|
266
|
+
hint: t('prompts.destinationTooltip')
|
|
272
267
|
},
|
|
273
|
-
validate: (value) =>
|
|
268
|
+
validate: (value) => validateEmptyString(value?.Name)
|
|
274
269
|
},
|
|
275
270
|
{
|
|
276
271
|
type: 'input',
|
|
277
272
|
name: 'uri',
|
|
278
|
-
message:
|
|
273
|
+
message: t('prompts.serviceUriLabel'),
|
|
279
274
|
guiOptions: {
|
|
280
275
|
mandatory: true,
|
|
281
|
-
hint:
|
|
276
|
+
hint: t('prompts.oDataServiceUriTooltip')
|
|
282
277
|
},
|
|
283
278
|
validate: (value) => {
|
|
284
279
|
const uriResult = validatePromptURI(value);
|
|
@@ -286,7 +281,7 @@ async function getPrompts(projectPath, layer, logger, appWizard) {
|
|
|
286
281
|
return uriResult;
|
|
287
282
|
}
|
|
288
283
|
if (isCFEnv && readXsAppRoutes(projectPath).some((r) => r.target === `${value}$1`)) {
|
|
289
|
-
return
|
|
284
|
+
return t('validators.errorRouteAlreadyExists');
|
|
290
285
|
}
|
|
291
286
|
return true;
|
|
292
287
|
},
|
|
@@ -296,9 +291,9 @@ async function getPrompts(projectPath, layer, logger, appWizard) {
|
|
|
296
291
|
{
|
|
297
292
|
type: 'input',
|
|
298
293
|
name: 'modelAndDatasourceName',
|
|
299
|
-
message: (answers) => answers.serviceType ===
|
|
300
|
-
?
|
|
301
|
-
:
|
|
294
|
+
message: (answers) => answers.serviceType === ServiceType.HTTP
|
|
295
|
+
? t('prompts.datasourceNameLabel')
|
|
296
|
+
: t('prompts.modelAndDatasourceNameLabel'),
|
|
302
297
|
default: defaultSeviceName,
|
|
303
298
|
store: false,
|
|
304
299
|
validate: (value) => {
|
|
@@ -306,18 +301,18 @@ async function getPrompts(projectPath, layer, logger, appWizard) {
|
|
|
306
301
|
},
|
|
307
302
|
guiOptions: {
|
|
308
303
|
mandatory: true,
|
|
309
|
-
hint:
|
|
304
|
+
hint: t('prompts.modelAndDatasourceNameTooltip')
|
|
310
305
|
}
|
|
311
306
|
},
|
|
312
307
|
{
|
|
313
308
|
type: 'editor',
|
|
314
309
|
name: 'modelSettings',
|
|
315
|
-
message:
|
|
310
|
+
message: t('prompts.oDataServiceModelSettingsLabel'),
|
|
316
311
|
store: false,
|
|
317
312
|
validate: validatePromptJSON,
|
|
318
|
-
when: (answers) => answers.serviceType !==
|
|
313
|
+
when: (answers) => answers.serviceType !== ServiceType.HTTP,
|
|
319
314
|
guiOptions: {
|
|
320
|
-
hint:
|
|
315
|
+
hint: t('prompts.oDataServiceModelSettingsTooltip')
|
|
321
316
|
}
|
|
322
317
|
},
|
|
323
318
|
{
|
|
@@ -325,17 +320,17 @@ async function getPrompts(projectPath, layer, logger, appWizard) {
|
|
|
325
320
|
name: 'addAnnotationMode',
|
|
326
321
|
message: 'Do you want to add annotation?',
|
|
327
322
|
default: false,
|
|
328
|
-
when: (answers) => answers.serviceType !==
|
|
323
|
+
when: (answers) => answers.serviceType !== ServiceType.HTTP
|
|
329
324
|
},
|
|
330
325
|
{
|
|
331
326
|
type: 'input',
|
|
332
327
|
name: 'dataSourceURI',
|
|
333
|
-
message:
|
|
328
|
+
message: t('prompts.oDataAnnotationDataSourceUriLabel'),
|
|
334
329
|
validate: validatePromptURI,
|
|
335
330
|
store: false,
|
|
336
331
|
guiOptions: {
|
|
337
332
|
mandatory: true,
|
|
338
|
-
hint:
|
|
333
|
+
hint: t('prompts.oDataAnnotationDataSourceUriTooltip')
|
|
339
334
|
},
|
|
340
335
|
when: (answers) => answers.addAnnotationMode,
|
|
341
336
|
additionalMessages: (uri, previousAnswers) => buildResultingUrlMessage('prompts.resultingAnnotationUrl', uri, previousAnswers)
|
|
@@ -343,11 +338,11 @@ async function getPrompts(projectPath, layer, logger, appWizard) {
|
|
|
343
338
|
{
|
|
344
339
|
type: 'editor',
|
|
345
340
|
name: 'annotationSettings',
|
|
346
|
-
message:
|
|
341
|
+
message: t('prompts.oDataAnnotationSettingsLabel'),
|
|
347
342
|
validate: validatePromptJSON,
|
|
348
343
|
store: false,
|
|
349
344
|
guiOptions: {
|
|
350
|
-
hint:
|
|
345
|
+
hint: t('prompts.oDataAnnotationSettingsTooltip')
|
|
351
346
|
},
|
|
352
347
|
when: (answers) => answers.addAnnotationMode
|
|
353
348
|
}
|
|
@@ -362,9 +357,9 @@ async function getPrompts(projectPath, layer, logger, appWizard) {
|
|
|
362
357
|
* @param {ToolsLogger} [logger] - Optional logger instance.
|
|
363
358
|
* @returns {Promise<NewModelData>} The data required by NewModelWriter.
|
|
364
359
|
*/
|
|
365
|
-
async function createNewModelData(projectPath, variant, answers, logger) {
|
|
360
|
+
export async function createNewModelData(projectPath, variant, answers, logger) {
|
|
366
361
|
const { modelAndDatasourceName, uri, serviceType, modelSettings, addAnnotationMode } = answers;
|
|
367
|
-
const isCloudFoundry = await
|
|
362
|
+
const isCloudFoundry = await isCFEnvironment(projectPath);
|
|
368
363
|
return {
|
|
369
364
|
variant,
|
|
370
365
|
serviceType,
|
|
@@ -372,13 +367,13 @@ async function createNewModelData(projectPath, variant, answers, logger) {
|
|
|
372
367
|
destinationName: isCloudFoundry ? answers.destination?.Name : undefined,
|
|
373
368
|
...(isCloudFoundry &&
|
|
374
369
|
answers.destination && {
|
|
375
|
-
isOnPremiseDestination:
|
|
370
|
+
isOnPremiseDestination: isOnPremiseDestination(answers.destination)
|
|
376
371
|
}),
|
|
377
372
|
logger,
|
|
378
373
|
service: {
|
|
379
374
|
name: modelAndDatasourceName,
|
|
380
375
|
uri,
|
|
381
|
-
modelName: serviceType ===
|
|
376
|
+
modelName: serviceType === ServiceType.HTTP ? undefined : modelAndDatasourceName,
|
|
382
377
|
version: getODataVersionFromServiceType(serviceType),
|
|
383
378
|
modelSettings
|
|
384
379
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { YUIQuestion } from '@sap-ux/inquirer-common';
|
|
2
2
|
import type { ManifestNamespace } from '@sap-ux/project-access';
|
|
3
|
-
import type { ChangeDataSourceAnswers } from '../../types';
|
|
3
|
+
import type { ChangeDataSourceAnswers } from '../../types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Gets the prompts for changing the data source.
|
|
6
6
|
*
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const i18n_1 = require("../../i18n");
|
|
5
|
-
const project_access_1 = require("@sap-ux/project-access");
|
|
6
|
-
const project_input_validator_1 = require("@sap-ux/project-input-validator");
|
|
1
|
+
import { t } from '../../i18n.js';
|
|
2
|
+
import { filterDataSourcesByType } from '@sap-ux/project-access';
|
|
3
|
+
import { validateEmptyString, isDataSourceURI } from '@sap-ux/project-input-validator';
|
|
7
4
|
/**
|
|
8
5
|
* Checks if the selected service has server-side annotations.
|
|
9
6
|
* A server-side annotation is detected when:
|
|
@@ -28,12 +25,12 @@ function hasServerSideAnnotations(dataSources, serviceId) {
|
|
|
28
25
|
* @returns {boolean | string} True if the value is a valid URI, or an error message if not a valid URI or empty.
|
|
29
26
|
*/
|
|
30
27
|
function validatePromptOdataURI(value) {
|
|
31
|
-
const validationResult =
|
|
28
|
+
const validationResult = validateEmptyString(value);
|
|
32
29
|
if (typeof validationResult === 'string') {
|
|
33
30
|
return validationResult;
|
|
34
31
|
}
|
|
35
|
-
if (!
|
|
36
|
-
return
|
|
32
|
+
if (!isDataSourceURI(value)) {
|
|
33
|
+
return t('validators.errorInvalidDataSourceURI');
|
|
37
34
|
}
|
|
38
35
|
return true;
|
|
39
36
|
}
|
|
@@ -44,12 +41,12 @@ function validatePromptOdataURI(value) {
|
|
|
44
41
|
* @returns {boolean | string} True if the value is a valid URI or empty, or an error message if not a valid URI.
|
|
45
42
|
*/
|
|
46
43
|
function validatePromptAnnotationURI(value) {
|
|
47
|
-
const validationResult =
|
|
44
|
+
const validationResult = validateEmptyString(value);
|
|
48
45
|
if (typeof validationResult === 'string') {
|
|
49
46
|
return true;
|
|
50
47
|
}
|
|
51
|
-
if (!
|
|
52
|
-
return
|
|
48
|
+
if (!isDataSourceURI(value)) {
|
|
49
|
+
return t('validators.errorInvalidDataSourceURI');
|
|
53
50
|
}
|
|
54
51
|
return true;
|
|
55
52
|
}
|
|
@@ -59,28 +56,28 @@ function validatePromptAnnotationURI(value) {
|
|
|
59
56
|
* @param {Record<string, ManifestNamespace.DataSource>} dataSources - Data sources from the manifest.
|
|
60
57
|
* @returns {YUIQuestion<ChangeDataSourceAnswers>[]} The questions/prompts.
|
|
61
58
|
*/
|
|
62
|
-
function getPrompts(dataSources) {
|
|
63
|
-
const dataSourceIds = Object.keys(
|
|
59
|
+
export function getPrompts(dataSources) {
|
|
60
|
+
const dataSourceIds = Object.keys(filterDataSourcesByType(dataSources, 'OData'));
|
|
64
61
|
return [
|
|
65
62
|
{
|
|
66
63
|
type: 'list',
|
|
67
64
|
name: 'id',
|
|
68
|
-
message:
|
|
65
|
+
message: t('prompts.oDataSourceLabel'),
|
|
69
66
|
choices: dataSourceIds,
|
|
70
67
|
default: dataSourceIds[0],
|
|
71
68
|
store: false,
|
|
72
69
|
guiOptions: {
|
|
73
70
|
mandatory: true,
|
|
74
|
-
hint:
|
|
71
|
+
hint: t('prompts.oDataSourceTooltip')
|
|
75
72
|
}
|
|
76
73
|
},
|
|
77
74
|
{
|
|
78
75
|
type: 'input',
|
|
79
76
|
name: 'uri',
|
|
80
|
-
message:
|
|
77
|
+
message: t('prompts.oDataSourceURILabel'),
|
|
81
78
|
guiOptions: {
|
|
82
79
|
mandatory: true,
|
|
83
|
-
hint:
|
|
80
|
+
hint: t('prompts.oDataSourceURITooltip')
|
|
84
81
|
},
|
|
85
82
|
validate: validatePromptOdataURI,
|
|
86
83
|
when: !!dataSourceIds.length,
|
|
@@ -89,18 +86,18 @@ function getPrompts(dataSources) {
|
|
|
89
86
|
{
|
|
90
87
|
type: 'number',
|
|
91
88
|
name: 'maxAge',
|
|
92
|
-
message:
|
|
89
|
+
message: t('prompts.maxAgeLabel'),
|
|
93
90
|
guiOptions: {
|
|
94
|
-
hint:
|
|
91
|
+
hint: t('prompts.maxAgeTooltip')
|
|
95
92
|
},
|
|
96
93
|
when: (answers) => answers.uri !== ''
|
|
97
94
|
},
|
|
98
95
|
{
|
|
99
96
|
type: 'input',
|
|
100
97
|
name: 'annotationUri',
|
|
101
|
-
message:
|
|
98
|
+
message: t('prompts.oDataAnnotationSourceURILabel'),
|
|
102
99
|
guiOptions: {
|
|
103
|
-
hint:
|
|
100
|
+
hint: t('prompts.oDataAnnotationSourceURITooltip')
|
|
104
101
|
},
|
|
105
102
|
validate: validatePromptAnnotationURI,
|
|
106
103
|
when: (answers) => hasServerSideAnnotations(dataSources, answers.id)
|
|
@@ -1,49 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPrompts = getPrompts;
|
|
4
|
-
const i18n_1 = require("../../i18n");
|
|
1
|
+
import { t } from '../../i18n.js';
|
|
5
2
|
/**
|
|
6
3
|
* Gets the prompts for Inbound Change.
|
|
7
4
|
*
|
|
8
5
|
* @returns {YUIQuestion<InboundChangeAnswers>[]} The questions/prompts.
|
|
9
6
|
*/
|
|
10
|
-
function getPrompts() {
|
|
7
|
+
export function getPrompts() {
|
|
11
8
|
return [
|
|
12
9
|
{
|
|
13
10
|
type: 'input',
|
|
14
11
|
name: 'title',
|
|
15
|
-
message:
|
|
12
|
+
message: t('prompts.title'),
|
|
16
13
|
guiOptions: {
|
|
17
|
-
hint:
|
|
14
|
+
hint: t('tooltips.title')
|
|
18
15
|
},
|
|
19
16
|
store: false,
|
|
20
17
|
validate: (value, answers) => answers.subtitle !== '' || answers.icon !== '' || value !== ''
|
|
21
18
|
? true
|
|
22
|
-
:
|
|
19
|
+
: t('validators.missingIconOrTitleOrSubtitle')
|
|
23
20
|
},
|
|
24
21
|
{
|
|
25
22
|
type: 'input',
|
|
26
23
|
name: 'subtitle',
|
|
27
|
-
message:
|
|
24
|
+
message: t('prompts.subtitle'),
|
|
28
25
|
guiOptions: {
|
|
29
|
-
hint:
|
|
26
|
+
hint: t('tooltips.subtitle')
|
|
30
27
|
},
|
|
31
28
|
store: false,
|
|
32
29
|
validate: (value, answers) => value !== '' || answers.icon !== '' || answers.title !== ''
|
|
33
30
|
? true
|
|
34
|
-
:
|
|
31
|
+
: t('validators.missingIconOrTitleOrSubtitle')
|
|
35
32
|
},
|
|
36
33
|
{
|
|
37
34
|
type: 'input',
|
|
38
35
|
name: 'icon',
|
|
39
|
-
message:
|
|
36
|
+
message: t('prompts.icon'),
|
|
40
37
|
guiOptions: {
|
|
41
|
-
hint:
|
|
38
|
+
hint: t('tooltips.icon')
|
|
42
39
|
},
|
|
43
40
|
store: false,
|
|
44
41
|
validate: (value, answers) => answers.subtitle !== '' || value !== '' || answers.title !== ''
|
|
45
42
|
? true
|
|
46
|
-
:
|
|
43
|
+
: t('validators.missingIconOrTitleOrSubtitle')
|
|
47
44
|
}
|
|
48
45
|
];
|
|
49
46
|
}
|
package/dist/prompts/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { getPrompts as getPromptsForChangeDataSource } from './change-data-source';
|
|
2
|
-
export { getPrompts as getPromptsForAddComponentUsages } from './add-component-usages';
|
|
3
|
-
export { getPrompts as getPromptsForNewModel, getODataVersionFromServiceType, createNewModelData } from './add-new-model';
|
|
4
|
-
export { getPrompts as getPromptsForChangeInbound } from './change-inbound';
|
|
5
|
-
export { getPrompts as getPromptsForAddAnnotationsToOData } from './add-annotations-to-odata';
|
|
1
|
+
export { getPrompts as getPromptsForChangeDataSource } from './change-data-source/index.js';
|
|
2
|
+
export { getPrompts as getPromptsForAddComponentUsages } from './add-component-usages/index.js';
|
|
3
|
+
export { getPrompts as getPromptsForNewModel, getODataVersionFromServiceType, createNewModelData } from './add-new-model/index.js';
|
|
4
|
+
export { getPrompts as getPromptsForChangeInbound } from './change-inbound/index.js';
|
|
5
|
+
export { getPrompts as getPromptsForAddAnnotationsToOData } from './add-annotations-to-odata/index.js';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/prompts/index.js
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var add_component_usages_1 = require("./add-component-usages");
|
|
7
|
-
Object.defineProperty(exports, "getPromptsForAddComponentUsages", { enumerable: true, get: function () { return add_component_usages_1.getPrompts; } });
|
|
8
|
-
var add_new_model_1 = require("./add-new-model");
|
|
9
|
-
Object.defineProperty(exports, "getPromptsForNewModel", { enumerable: true, get: function () { return add_new_model_1.getPrompts; } });
|
|
10
|
-
Object.defineProperty(exports, "getODataVersionFromServiceType", { enumerable: true, get: function () { return add_new_model_1.getODataVersionFromServiceType; } });
|
|
11
|
-
Object.defineProperty(exports, "createNewModelData", { enumerable: true, get: function () { return add_new_model_1.createNewModelData; } });
|
|
12
|
-
var change_inbound_1 = require("./change-inbound");
|
|
13
|
-
Object.defineProperty(exports, "getPromptsForChangeInbound", { enumerable: true, get: function () { return change_inbound_1.getPrompts; } });
|
|
14
|
-
var add_annotations_to_odata_1 = require("./add-annotations-to-odata");
|
|
15
|
-
Object.defineProperty(exports, "getPromptsForAddAnnotationsToOData", { enumerable: true, get: function () { return add_annotations_to_odata_1.getPrompts; } });
|
|
1
|
+
export { getPrompts as getPromptsForChangeDataSource } from './change-data-source/index.js';
|
|
2
|
+
export { getPrompts as getPromptsForAddComponentUsages } from './add-component-usages/index.js';
|
|
3
|
+
export { getPrompts as getPromptsForNewModel, getODataVersionFromServiceType, createNewModelData } from './add-new-model/index.js';
|
|
4
|
+
export { getPrompts as getPromptsForChangeInbound } from './change-inbound/index.js';
|
|
5
|
+
export { getPrompts as getPromptsForAddAnnotationsToOData } from './add-annotations-to-odata/index.js';
|
|
16
6
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AbapServiceProvider } from '@sap-ux/axios-extension';
|
|
2
2
|
import type { ToolsLogger } from '@sap-ux/logger';
|
|
3
|
-
import type { SourceApplication } from '../types';
|
|
4
|
-
import { SupportedProject } from './systems';
|
|
3
|
+
import type { SourceApplication } from '../types.js';
|
|
4
|
+
import { SupportedProject } from './systems.js';
|
|
5
5
|
/**
|
|
6
6
|
* Checks whether the application supports manifest-first approach.
|
|
7
7
|
*
|