@sap-ux/adp-tooling 0.12.27 → 0.12.28

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.
@@ -33,13 +33,21 @@ function validatePromptId(value, changeFiles, isCustomerBase) {
33
33
  if (typeof validationResult === 'string') {
34
34
  return validationResult;
35
35
  }
36
- if (isCustomerBase && !(0, project_input_validator_1.hasCustomerPrefix)(value)) {
37
- return (0, i18n_1.t)('validators.errorInputInvalidValuePrefix', {
38
- value: (0, i18n_1.t)('prompts.component.usageIdLabel'),
39
- prefix: "customer." /* NamespacePrefix.CUSTOMER */
40
- });
36
+ if (isCustomerBase) {
37
+ if (!(0, project_input_validator_1.hasCustomerPrefix)(value)) {
38
+ return (0, i18n_1.t)('validators.errorInputInvalidValuePrefix', {
39
+ value: (0, i18n_1.t)('prompts.component.usageIdLabel'),
40
+ prefix: "customer." /* NamespacePrefix.CUSTOMER */
41
+ });
42
+ }
43
+ if (!value.replace('customer.', '').length) {
44
+ return (0, i18n_1.t)('validators.errorCustomerEmptyValue', {
45
+ value: (0, i18n_1.t)('prompts.component.usageIdLabel'),
46
+ prefix: "customer." /* NamespacePrefix.CUSTOMER */
47
+ });
48
+ }
41
49
  }
42
- if ((0, project_input_validator_1.hasContentDuplication)(value, 'dataSource', changeFiles)) {
50
+ if ((0, project_input_validator_1.hasContentDuplication)(value, 'componentUsages', changeFiles)) {
43
51
  return (0, i18n_1.t)('validators.errorDuplicateValueComponentId');
44
52
  }
45
53
  return true;
@@ -49,21 +57,14 @@ function validatePromptId(value, changeFiles, isCustomerBase) {
49
57
  *
50
58
  * @param value The value to validate.
51
59
  * @param changeFiles The change files to check for duplication.
52
- * @param isCustomerBase Flag to check if the project is customer scenario.
53
60
  * @returns {string | boolean} An error message if the value is invalid, or true if it is not.
54
61
  */
55
- function validatePromptLibrary(value, changeFiles, isCustomerBase) {
62
+ function validatePromptLibrary(value, changeFiles) {
56
63
  const validationResult = validatePromptInput(value);
57
64
  if (typeof validationResult === 'string') {
58
65
  return validationResult;
59
66
  }
60
- if (isCustomerBase && !(0, project_input_validator_1.hasCustomerPrefix)(value)) {
61
- return (0, i18n_1.t)('validators.errorInputInvalidValuePrefix', {
62
- value: (0, i18n_1.t)('prompts.component.libraryLabel'),
63
- prefix: "customer." /* NamespacePrefix.CUSTOMER */
64
- });
65
- }
66
- if ((0, project_input_validator_1.hasContentDuplication)(value, 'dataSource', changeFiles)) {
67
+ if ((0, project_input_validator_1.hasContentDuplication)(value, 'libraries', changeFiles)) {
67
68
  return (0, i18n_1.t)('validators.errorDuplicateValueLibrary');
68
69
  }
69
70
  return true;
@@ -169,7 +170,7 @@ function getPrompts(basePath, layer) {
169
170
  mandatory: true,
170
171
  hint: (0, i18n_1.t)('prompts.component.libraryTooltip')
171
172
  },
172
- validate: (value) => validatePromptLibrary(value, libraryChangeFiles, isCustomerBase),
173
+ validate: (value) => validatePromptLibrary(value, libraryChangeFiles),
173
174
  store: false,
174
175
  when: (answers) => answers.shouldAddLibrary
175
176
  },
@@ -25,6 +25,28 @@ function validatePromptInput(value) {
25
25
  }
26
26
  return true;
27
27
  }
28
+ /**
29
+ * Validates if a value has a customer prefix and is empty except for customer prefix.
30
+ *
31
+ * @param value The value to validate.
32
+ * @param label The label of the prompt.
33
+ * @returns {boolean | string} True if the value is valid, or an error message if validation fails.
34
+ */
35
+ function validateCustomerValue(value, label) {
36
+ if (!(0, project_input_validator_1.hasCustomerPrefix)(value)) {
37
+ return (0, i18n_1.t)('validators.errorInputInvalidValuePrefix', {
38
+ value: (0, i18n_1.t)(label),
39
+ prefix: "customer." /* NamespacePrefix.CUSTOMER */
40
+ });
41
+ }
42
+ if (!value.replace('customer.', '').length) {
43
+ return (0, i18n_1.t)('validators.errorCustomerEmptyValue', {
44
+ value: (0, i18n_1.t)(label),
45
+ prefix: "customer." /* NamespacePrefix.CUSTOMER */
46
+ });
47
+ }
48
+ return true;
49
+ }
28
50
  /**
29
51
  * Validates a JSON string.
30
52
  *
@@ -48,15 +70,15 @@ function validatePromptJSON(value) {
48
70
  * @returns {boolean | string} True if no duplication is found, or an error message if validation fails.
49
71
  */
50
72
  function validatePromptODataName(value, answers, isCustomerBase, changeFiles) {
51
- const validationResult = validatePromptInput(value);
73
+ let validationResult = validatePromptInput(value);
52
74
  if (typeof validationResult === 'string') {
53
75
  return validationResult;
54
76
  }
55
- if (isCustomerBase && !(0, project_input_validator_1.hasCustomerPrefix)(value)) {
56
- return (0, i18n_1.t)('validators.errorInputInvalidValuePrefix', {
57
- value: (0, i18n_1.t)('prompts.oDataServiceNameLabel'),
58
- prefix: "customer." /* NamespacePrefix.CUSTOMER */
59
- });
77
+ if (isCustomerBase) {
78
+ validationResult = validateCustomerValue(value, 'prompts.oDataServiceNameLabel');
79
+ if (typeof validationResult === 'string') {
80
+ return validationResult;
81
+ }
60
82
  }
61
83
  if ((0, project_input_validator_1.hasContentDuplication)(value, 'dataSource', changeFiles)) {
62
84
  return (0, i18n_1.t)('validators.errorDuplicatedValueOData');
@@ -76,15 +98,15 @@ function validatePromptODataName(value, answers, isCustomerBase, changeFiles) {
76
98
  * @returns {boolean | string} True if no duplication is found, or an error message if validation fails.
77
99
  */
78
100
  function validatePromptODataAnnotationsName(value, answers, isCustomerBase, changeFiles) {
79
- const validationResult = validatePromptInput(value);
101
+ let validationResult = validatePromptInput(value);
80
102
  if (typeof validationResult === 'string') {
81
103
  return validationResult;
82
104
  }
83
- if (isCustomerBase && !(0, project_input_validator_1.hasCustomerPrefix)(value)) {
84
- return (0, i18n_1.t)('validators.errorInputInvalidValuePrefix', {
85
- value: (0, i18n_1.t)('prompts.oDataAnnotationDataSourceNameLabel'),
86
- prefix: "customer." /* NamespacePrefix.CUSTOMER */
87
- });
105
+ if (isCustomerBase) {
106
+ validationResult = validateCustomerValue(value, 'prompts.oDataAnnotationDataSourceNameLabel');
107
+ if (typeof validationResult === 'string') {
108
+ return validationResult;
109
+ }
88
110
  }
89
111
  if ((0, project_input_validator_1.hasContentDuplication)(value, 'dataSource', changeFiles)) {
90
112
  return (0, i18n_1.t)('validators.errorDuplicatedValueOData');
@@ -103,15 +125,15 @@ function validatePromptODataAnnotationsName(value, answers, isCustomerBase, chan
103
125
  * @returns {boolean | string} True if no duplication is found, or an error message if validation fails.
104
126
  */
105
127
  function validatePromptModelName(value, isCustomerBase, changeFiles) {
106
- const validationResult = validatePromptInput(value);
128
+ let validationResult = validatePromptInput(value);
107
129
  if (typeof validationResult === 'string') {
108
130
  return validationResult;
109
131
  }
110
- if (isCustomerBase && !(0, project_input_validator_1.hasCustomerPrefix)(value)) {
111
- return (0, i18n_1.t)('validators.errorInputInvalidValuePrefix', {
112
- value: (0, i18n_1.t)('prompts.oDataServiceModelNameLabel'),
113
- prefix: "customer." /* NamespacePrefix.CUSTOMER */
114
- });
132
+ if (isCustomerBase) {
133
+ validationResult = validateCustomerValue(value, 'prompts.oDataServiceModelNameLabel');
134
+ if (typeof validationResult === 'string') {
135
+ return validationResult;
136
+ }
115
137
  }
116
138
  if ((0, project_input_validator_1.hasContentDuplication)(value, 'model', changeFiles)) {
117
139
  return (0, i18n_1.t)('validators.errorDuplicatedValueSapui5Model');
@@ -240,7 +262,7 @@ function getPrompts(projectPath, layer) {
240
262
  type: 'input',
241
263
  name: 'dataSourceURI',
242
264
  message: (0, i18n_1.t)('prompts.oDataAnnotationDataSourceUriLabel'),
243
- validate: project_input_validator_1.validateEmptyString,
265
+ validate: validatePromptURI,
244
266
  store: false,
245
267
  guiOptions: {
246
268
  mandatory: true,
@@ -66,6 +66,7 @@
66
66
  "errorDuplicateValueLibrary": "Library with the same name was already added to the project",
67
67
  "errorDuplicateNamesOData": "OData Service Name must be different from OData Annotation Data Source Name",
68
68
  "errorInputInvalidValuePrefix": "{{value}} should start with '{{prefix}}'",
69
+ "errorCustomerEmptyValue": "{{value}} should contain at least one character in addition to '{{prefix}}'",
69
70
  "errorInvalidDataSourceURI": "Invalid URI. Should start and end with '/' and contain no spaces"
70
71
  },
71
72
  "choices": {
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  "bugs": {
10
10
  "url": "https://github.com/SAP/open-ux-tools/issues?q=is%3Aopen+is%3Aissue+label%3Abug+label%3Aadp-tooling"
11
11
  },
12
- "version": "0.12.27",
12
+ "version": "0.12.28",
13
13
  "license": "Apache-2.0",
14
14
  "author": "@SAP/ux-tools-team",
15
15
  "main": "dist/index.js",
@@ -37,7 +37,7 @@
37
37
  "@sap-ux/inquirer-common": "0.4.3",
38
38
  "@sap-ux/logger": "0.6.0",
39
39
  "@sap-ux/project-access": "1.26.4",
40
- "@sap-ux/project-input-validator": "0.3.2",
40
+ "@sap-ux/project-input-validator": "0.3.3",
41
41
  "@sap-ux/system-access": "0.5.5",
42
42
  "@sap-ux/ui5-config": "0.23.1"
43
43
  },