@sap/ux-specification 1.71.72 → 1.71.74

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.
@@ -5,12 +5,14 @@ import type { Definition } from 'typescript-json-schema';
5
5
  /**
6
6
  * Adds definitions for forms in object page sections to the app schema
7
7
  * @param {SectionType} sectionType - prefix to distinguish Section and HeaderSection
8
- * @param {FacetConfig} section - facet or section in the FE core model
8
+ * @param {FacetConfig} section - section definition, as prepared from the annotations
9
9
  * @param {object} appSchemaSection - current definition of facet or section in the JSON schema
10
10
  * @param {object} appSchema - app specific schema that gets enhanced
11
11
  * @param {FioriElementsVersion} version - Fiori Elements version
12
+ * @param {string} facetKey - facet key
13
+ * @returns {string | undefined} target id of form
12
14
  */
13
- export declare function handleForm(sectionType: SectionType, section: FacetConfig, appSchemaSection: Definition, appSchema: Definition, version: FioriElementsVersion, withActions?: boolean): void;
15
+ export declare function handleForm(sectionType: SectionType, section: FacetConfig, appSchemaSection: Definition, appSchema: Definition, version: FioriElementsVersion, facetKey: string): string | undefined;
14
16
  /**
15
17
  * Replaces an alias in an annotation ID or reference, based on the AVT references' list
16
18
  * @param annotationIdentifier - annotation ID or reference
@@ -21,12 +23,12 @@ export declare function replaceAlias(annotationIdentifier: string, oDataServiceA
21
23
  /**
22
24
  * Common routine to determine the name and the ID of a header action
23
25
  * @param action - action as given by AVT
24
- * @param entityType - entity type by AVT
25
26
  * @returns an object comprising action name and action id
26
27
  */
27
- export declare function getActionNameAndId(action: string, entityType: EntityType): {
28
+ export declare function getActionNameAndId(item: any, oDataServiceAVT: ConvertedMetadata): {
28
29
  actionName: string;
29
30
  actionId: string;
31
+ namespace: string;
30
32
  };
31
33
  /**
32
34
  * Add Object Page Footer Action Buttons to app-specific schema
@@ -1 +1 @@
1
- {"version":3,"file":"objectPage.d.ts","sourceRoot":"","sources":["../../../../../src/sync/common/generate/objectPage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB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AG,IAAI,CAUzF;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,GAAG,SAAS,GAAG,SAAS,CAMlH"}
@@ -3,7 +3,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.determineEntitySetOfFacet = exports.addCommonHeaderSchema = exports.addHeaderActions = exports.addFooterActions = exports.getActionNameAndId = exports.replaceAlias = exports.handleForm = void 0;
4
4
  const StableIdHelper_1 = require("../../v4/utils/StableIdHelper");
5
5
  const ux_specification_types_1 = require("@sap/ux-specification-types");
6
+ const ux_specification_types_2 = require("@sap/ux-specification-types");
6
7
  const __1 = require("..");
8
+ /**
9
+ * Copies the field properties from the generic definition to the specific field definition
10
+ * @param {FioriElementsVersion} version - Fiori Elements version
11
+ * @param {object} appSchema - App schema in general
12
+ * @param {DataFieldAbstractTypes} field - field definition in parser output (AVT)
13
+ * @param {string} fieldDefinition - the unique ID for the given field definition
14
+ */
15
+ function copyFieldProperties(version, appSchema, field, fieldDefinition) {
16
+ if (version === ux_specification_types_2.FioriElementsVersion.v4 && appSchema['definitions']['Field']) {
17
+ switch (field.$Type) {
18
+ case "com.sap.vocabularies.UI.v1.DataField" /* DataField */:
19
+ case "com.sap.vocabularies.UI.v1.DataFieldForAnnotation" /* DataFieldForAnnotation */:
20
+ case "com.sap.vocabularies.UI.v1.DataFieldWithNavigationPath" /* DataFieldWithNavigationPath */:
21
+ case "com.sap.vocabularies.UI.v1.DataFieldWithUrl" /* DataFieldWithUrl */: {
22
+ appSchema.definitions[fieldDefinition].properties =
23
+ appSchema.definitions.Field['properties'];
24
+ break;
25
+ }
26
+ }
27
+ }
28
+ else if (version === ux_specification_types_2.FioriElementsVersion.v2 && appSchema['definitions']['Field']) {
29
+ switch (field.$Type) {
30
+ case "com.sap.vocabularies.UI.v1.DataField" /* DataField */:
31
+ case "com.sap.vocabularies.UI.v1.DataFieldForAnnotation" /* DataFieldForAnnotation */:
32
+ case "com.sap.vocabularies.UI.v1.DataFieldWithUrl" /* DataFieldWithUrl */: {
33
+ appSchema.definitions[fieldDefinition].properties =
34
+ appSchema.definitions.Field['properties'];
35
+ break;
36
+ }
37
+ }
38
+ }
39
+ }
7
40
  /**
8
41
  * Determines the name for a field definition in app schema
9
42
  * @param {FioriElementsVersion} version - Fiori Elements version
@@ -13,16 +46,102 @@ const __1 = require("..");
13
46
  * @returns the field definition name in schema
14
47
  */
15
48
  function determineFieldDefinitionName(version, fieldReferenceId, targetID, fieldReference) {
16
- const fieldReferenceType = version === ux_specification_types_1.FioriElementsVersion.v2 && fieldReferenceId && fieldReferenceId.includes('::')
49
+ const fieldReferenceType = version === ux_specification_types_2.FioriElementsVersion.v2 && fieldReferenceId && fieldReferenceId.includes('::')
17
50
  ? fieldReferenceId.split('::')[0].replace('DataField', 'Field')
18
51
  : undefined;
19
- if (version === ux_specification_types_1.FioriElementsVersion.v2) {
52
+ if (version === ux_specification_types_2.FioriElementsVersion.v2) {
20
53
  return `${fieldReferenceType}<${targetID}::${fieldReference}>`;
21
54
  }
22
55
  else {
23
56
  return `${targetID}::${fieldReference}`;
24
57
  }
25
58
  }
59
+ /**
60
+ * Add th keys and targt tag for Datafield*
61
+ * @param field - the given field definition
62
+ * @param appSchema - the app schema to be updated
63
+ * @param schemaKeyOfField - key for the given field in the app schema
64
+ */
65
+ function addKeysTagForDataField(field, appSchema, schemaKeyOfField) {
66
+ if (typeof field.Value !== 'string' && field.Value.type === 'Path') {
67
+ appSchema.definitions[schemaKeyOfField][ux_specification_types_2.SchemaTag.keys] = [
68
+ {
69
+ name: 'Value',
70
+ value: field.Value.path
71
+ }
72
+ ];
73
+ appSchema.definitions[schemaKeyOfField][ux_specification_types_2.SchemaTag.target] = field.Value.$target
74
+ ? field.Value.$target.fullyQualifiedName.split('/')[0]
75
+ : field.Value.targetString.split('/')[0];
76
+ }
77
+ else if (typeof field.Value === 'string' && field.Value) {
78
+ appSchema.definitions[schemaKeyOfField][ux_specification_types_2.SchemaTag.keys] = [
79
+ {
80
+ name: 'Value',
81
+ value: field.Value
82
+ }
83
+ ];
84
+ appSchema.definitions[schemaKeyOfField][ux_specification_types_2.SchemaTag.target] = field.fullyQualifiedName.split('@')[0];
85
+ }
86
+ }
87
+ /**
88
+ * Adds the "keys" tag to a field definition in schema
89
+ * @param field - the given field definition
90
+ * @param appSchema - the app schema to be updated
91
+ * @param schemaKeyOfField - key for the given field in the app schema
92
+ */
93
+ function addKeysTagToField(field, appSchema, schemaKeyOfField) {
94
+ if (field.$Type === "com.sap.vocabularies.UI.v1.DataField" /* DataField */ ||
95
+ field.$Type === "com.sap.vocabularies.UI.v1.DataFieldWithUrl" /* DataFieldWithUrl */ ||
96
+ field.$Type === "com.sap.vocabularies.UI.v1.DataFieldWithNavigationPath" /* DataFieldWithNavigationPath */) {
97
+ addKeysTagForDataField(field, appSchema, schemaKeyOfField);
98
+ }
99
+ else if (field.$Type === "com.sap.vocabularies.UI.v1.DataFieldForAnnotation" /* DataFieldForAnnotation */) {
100
+ appSchema.definitions[schemaKeyOfField][ux_specification_types_2.SchemaTag.keys] = [
101
+ {
102
+ name: 'Target',
103
+ value: field.Target.value
104
+ }
105
+ ];
106
+ appSchema.definitions[schemaKeyOfField][ux_specification_types_2.SchemaTag.target] =
107
+ field.Target.$target.fullyQualifiedName.split('@')[0];
108
+ }
109
+ else if (field.$Type === "com.sap.vocabularies.UI.v1.DataFieldForAction" /* DataFieldForAction */) {
110
+ const separator = field.Action.lastIndexOf('.');
111
+ if (separator === -1) {
112
+ appSchema.definitions[schemaKeyOfField][ux_specification_types_2.SchemaTag.keys] = [
113
+ {
114
+ name: 'Action',
115
+ value: field.Action
116
+ }
117
+ ];
118
+ }
119
+ else {
120
+ appSchema.definitions[schemaKeyOfField][ux_specification_types_2.SchemaTag.keys] = [
121
+ {
122
+ name: 'Action',
123
+ value: field.Action.substring(separator + 1, field.Action.length)
124
+ }
125
+ ];
126
+ appSchema.definitions[schemaKeyOfField][ux_specification_types_2.SchemaTag.target] = field.Action.substring(0, separator);
127
+ }
128
+ }
129
+ else if (field.$Type === "com.sap.vocabularies.UI.v1.DataFieldForIntentBasedNavigation" /* DataFieldForIntentBasedNavigation */) {
130
+ appSchema.definitions[schemaKeyOfField][ux_specification_types_2.SchemaTag.keys] = [
131
+ {
132
+ name: 'SemanticObject',
133
+ value: field.SemanticObject
134
+ }
135
+ ];
136
+ if (field.Action) {
137
+ appSchema.definitions[schemaKeyOfField][ux_specification_types_2.SchemaTag.keys].push({
138
+ name: 'Action',
139
+ value: field.Action
140
+ });
141
+ }
142
+ appSchema.definitions[schemaKeyOfField][ux_specification_types_2.SchemaTag.target] = field.fullyQualifiedName.split('@')[0];
143
+ }
144
+ }
26
145
  /**
27
146
  * Adds a field definition to the app specific schema
28
147
  * @param {string} sectionType - prefix to distinguish Section and HeaderSection
@@ -36,58 +155,50 @@ function determineFieldDefinitionName(version, fieldReferenceId, targetID, field
36
155
  function addField(sectionType, appSchema, field, targetID, key, section, version, withActions = true) {
37
156
  // Calculate field reference
38
157
  const fieldReferenceId = StableIdHelper_1.getStableIdPartFromDataField(field);
39
- const fieldReference = version === ux_specification_types_1.FioriElementsVersion.v2 && fieldReferenceId && fieldReferenceId.includes('::')
158
+ const fieldReference = version === ux_specification_types_2.FioriElementsVersion.v2 && fieldReferenceId && fieldReferenceId.includes('::')
40
159
  ? fieldReferenceId.split('::').splice(1).join('::')
41
160
  : fieldReferenceId;
42
161
  // Determine field definition name
43
- const fieldDefinition = determineFieldDefinitionName(version, fieldReferenceId, targetID, fieldReference);
162
+ const schemaKeyOfField = determineFieldDefinitionName(version, fieldReferenceId, targetID, fieldReference);
44
163
  // Evaluate field type, set field reference of properties of fields' or actions' definition
45
164
  if (!field || !field.$Type) {
46
165
  return;
47
166
  }
48
167
  else if (field.$Type === "com.sap.vocabularies.UI.v1.DataFieldForAction" /* DataFieldForAction */ ||
49
168
  field.$Type === "com.sap.vocabularies.UI.v1.DataFieldForIntentBasedNavigation" /* DataFieldForIntentBasedNavigation */) {
50
- if (withActions && sectionType === ux_specification_types_1.SectionType.Section) {
51
- const actionsDefinition = __1.prepareRef(`${sectionType}${ux_specification_types_1.DefinitionName.Actions}<${targetID}>`);
169
+ if (withActions && sectionType === ux_specification_types_2.SectionType.Section) {
170
+ const actionsDefinition = __1.prepareRef(`${sectionType}${ux_specification_types_2.DefinitionName.Actions}<${targetID}>`);
52
171
  const fieldInSchema = (appSchema.definitions[actionsDefinition].properties[fieldReference] =
53
172
  {
54
- $ref: `${__1.DEFINITION_LINK_PREFIX}${fieldDefinition}`
173
+ $ref: `${__1.DEFINITION_LINK_PREFIX}${schemaKeyOfField}`
55
174
  });
56
- fieldInSchema[ux_specification_types_1.SchemaTag.propertyIndex] = parseInt(key);
175
+ fieldInSchema[ux_specification_types_2.SchemaTag.propertyIndex] = parseInt(key);
57
176
  }
58
177
  }
59
178
  else {
60
- const fieldsDefinition = __1.prepareRef(`${sectionType}${ux_specification_types_1.DefinitionName.Fields}<${targetID}>`);
179
+ const fieldsDefinition = __1.prepareRef(`${sectionType}${ux_specification_types_2.DefinitionName.Fields}<${targetID}>`);
61
180
  appSchema.definitions[fieldsDefinition]['properties'][fieldReference] = {
62
- $ref: `${__1.DEFINITION_LINK_PREFIX}${fieldDefinition}`,
181
+ $ref: `${__1.DEFINITION_LINK_PREFIX}${schemaKeyOfField}`,
63
182
  propertyIndex: parseInt(key)
64
183
  };
65
184
  }
66
185
  // Now set up the field definition
67
- appSchema.definitions[fieldDefinition] = {
186
+ appSchema.definitions[schemaKeyOfField] = {
68
187
  type: 'object',
69
188
  properties: {},
70
189
  description: __1.getDatafieldDescription(field, section.entityType),
71
190
  additionalProperties: false
72
191
  };
73
192
  //Add tags
74
- appSchema.definitions[fieldDefinition][ux_specification_types_1.SchemaTag.annotationPath] = `/${section.entityType.fullyQualifiedName}/${field.fullyQualifiedName.split(section.entityType.fullyQualifiedName)[1]}`;
75
- appSchema.definitions[fieldDefinition][ux_specification_types_1.SchemaTag.annotationType] = field.$Type;
76
- appSchema.definitions[fieldDefinition][ux_specification_types_1.SchemaTag.isViewNode] = true;
77
- __1.addDataTypeToDefinition(appSchema.definitions[fieldDefinition], field);
78
- if (version === ux_specification_types_1.FioriElementsVersion.v2 && appSchema['definitions']['Field']) {
79
- switch (field.$Type) {
80
- case "com.sap.vocabularies.UI.v1.DataField" /* DataField */:
81
- case "com.sap.vocabularies.UI.v1.DataFieldForAnnotation" /* DataFieldForAnnotation */:
82
- case "com.sap.vocabularies.UI.v1.DataFieldWithUrl" /* DataFieldWithUrl */: {
83
- appSchema['definitions'][fieldDefinition]['properties'] =
84
- appSchema['definitions']['Field']['properties'];
85
- break;
86
- }
87
- }
88
- }
89
- if (field.$Type === "com.sap.vocabularies.UI.v1.DataFieldForAction" /* DataFieldForAction */ && appSchema['definitions']?.['FormAction']) {
90
- appSchema['definitions'][fieldDefinition]['properties'] = appSchema['definitions']['FormAction']['properties'];
193
+ addKeysTagToField(field, appSchema, schemaKeyOfField);
194
+ appSchema.definitions[schemaKeyOfField][ux_specification_types_2.SchemaTag.annotationPath] = `/${section.entityType.fullyQualifiedName}/${field.fullyQualifiedName.split(section.entityType.fullyQualifiedName)[1]}`;
195
+ appSchema.definitions[schemaKeyOfField][ux_specification_types_2.SchemaTag.annotationType] = field.$Type;
196
+ appSchema.definitions[schemaKeyOfField][ux_specification_types_2.SchemaTag.isViewNode] = true;
197
+ __1.addDataTypeToDefinition(appSchema.definitions[schemaKeyOfField], field);
198
+ // Copy the generic definition of field properties to the specific one
199
+ copyFieldProperties(version, appSchema, field, schemaKeyOfField);
200
+ if (field.$Type === "com.sap.vocabularies.UI.v1.DataFieldForAction" /* DataFieldForAction */ && appSchema.definitions?.['FormAction']) {
201
+ appSchema.definitions[schemaKeyOfField].properties = appSchema.definitions[ux_specification_types_2.DefinitionName.FormAction].properties;
91
202
  }
92
203
  }
93
204
  /**
@@ -109,24 +220,23 @@ function determineTargetIdOfForm(section) {
109
220
  return targetID;
110
221
  }
111
222
  /**
112
- * Adds definitions for forms in object page sections to the app schema
223
+ * Adds the specific definitions of the form fields to a schema
224
+ * @param {FacetConfig} section - section definition, as prepared from the annotations
113
225
  * @param {SectionType} sectionType - prefix to distinguish Section and HeaderSection
114
- * @param {FacetConfig} section - facet or section in the FE core model
115
- * @param {object} appSchemaSection - current definition of facet or section in the JSON schema
116
226
  * @param {object} appSchema - app specific schema that gets enhanced
227
+ * @param {string } targetID - target id of form
117
228
  * @param {FioriElementsVersion} version - Fiori Elements version
118
229
  */
119
- function handleForm(sectionType, section, appSchemaSection, appSchema, version, withActions = true) {
230
+ function addFieldsToFormDefinition(section, sectionType, appSchema, targetID, version, withActions = true) {
120
231
  if (!section.target) {
121
232
  return;
122
233
  }
123
- const targetID = determineTargetIdOfForm(section);
124
- const formDefinition = __1.prepareRef(`${sectionType}${ux_specification_types_1.DefinitionName.Form}<${targetID}>`);
125
- const fieldsDefinition = __1.prepareRef(`${sectionType}${ux_specification_types_1.DefinitionName.Fields}<${targetID}>`);
126
- const actionsDefinition = __1.prepareRef(`${sectionType}${ux_specification_types_1.DefinitionName.Actions}<${targetID}>`);
234
+ const formDefinition = __1.prepareRef(`${sectionType}${ux_specification_types_2.DefinitionName.Form}<${targetID}>`);
235
+ const fieldsDefinition = __1.prepareRef(`${sectionType}${ux_specification_types_2.DefinitionName.Fields}<${targetID}>`);
236
+ const actionsDefinition = __1.prepareRef(`${sectionType}${ux_specification_types_2.DefinitionName.Actions}<${targetID}>`);
127
237
  // Form definition
128
- appSchemaSection.properties['form'] = { $ref: `${__1.DEFINITION_LINK_PREFIX}${formDefinition}` };
129
- if (sectionType === ux_specification_types_1.SectionType.Section && withActions) {
238
+ appSchema.properties['form'] = { $ref: `${__1.DEFINITION_LINK_PREFIX}${formDefinition}` };
239
+ if (sectionType === ux_specification_types_2.SectionType.Section && withActions) {
130
240
  appSchema['definitions'][formDefinition] = {
131
241
  type: 'object',
132
242
  properties: {
@@ -144,7 +254,7 @@ function handleForm(sectionType, section, appSchemaSection, appSchema, version,
144
254
  description: 'Actions',
145
255
  additionalProperties: false
146
256
  };
147
- appSchema['definitions'][actionsDefinition][ux_specification_types_1.SchemaTag.isViewNode] = true;
257
+ appSchema['definitions'][actionsDefinition][ux_specification_types_2.SchemaTag.isViewNode] = true;
148
258
  }
149
259
  else {
150
260
  appSchema['definitions'][formDefinition] = {
@@ -156,9 +266,9 @@ function handleForm(sectionType, section, appSchemaSection, appSchema, version,
156
266
  additionalProperties: false
157
267
  };
158
268
  }
159
- appSchema.definitions[formDefinition][ux_specification_types_1.SchemaTag.isViewNode] = true;
269
+ appSchema.definitions[formDefinition][ux_specification_types_2.SchemaTag.isViewNode] = true;
160
270
  if (section.entityType?.name) {
161
- appSchema.definitions[formDefinition][ux_specification_types_1.SchemaTag.annotationPath] = __1.createAnnotationPath(section.entityType.fullyQualifiedName, section.target['term'], section.target['qualifier']);
271
+ appSchema.definitions[formDefinition][ux_specification_types_2.SchemaTag.annotationPath] = __1.createAnnotationPath(section.entityType.fullyQualifiedName, section.target['term'], section.target['qualifier']);
162
272
  }
163
273
  // Fields definition
164
274
  appSchema.definitions[fieldsDefinition] = {
@@ -167,9 +277,9 @@ function handleForm(sectionType, section, appSchemaSection, appSchema, version,
167
277
  description: 'Fields',
168
278
  additionalProperties: false
169
279
  };
170
- appSchema.definitions[fieldsDefinition][ux_specification_types_1.SchemaTag.isViewNode] = true;
280
+ appSchema.definitions[fieldsDefinition][ux_specification_types_2.SchemaTag.isViewNode] = true;
171
281
  // Add fields
172
- if (section.base === ux_specification_types_1.FacetBase.Identification) {
282
+ if (section.base === ux_specification_types_2.FacetBase.Identification) {
173
283
  for (const key in section.target) {
174
284
  const field = section.target[key];
175
285
  if (field) {
@@ -184,6 +294,95 @@ function handleForm(sectionType, section, appSchemaSection, appSchema, version,
184
294
  }
185
295
  }
186
296
  }
297
+ /**
298
+ * Adds the schema tags for a form definition
299
+ * @param {FacetConfig} section - section definition, as prepared from the annotations
300
+ * @param {object} appSchema - app specific schema that gets enhanced
301
+ * @param {string} formDefinitionKey - key of the form definition in schema
302
+ */
303
+ function addTagsToFormDefinition(section, appSchema, formDefinitionKey) {
304
+ if (section.target) {
305
+ const targetValue = section.target['qualifier']
306
+ ? `${section.target['term']}#${section.target['qualifier']}`
307
+ : `${section.target['term']}`;
308
+ appSchema.definitions[formDefinitionKey][ux_specification_types_2.SchemaTag.keys] = [
309
+ {
310
+ name: ux_specification_types_1.SchemaKeyName.target,
311
+ value: targetValue.replace(/com.sap.vocabularies.UI.v1./g, '')
312
+ }
313
+ ];
314
+ appSchema.definitions[formDefinitionKey][ux_specification_types_2.SchemaTag.target] = section.target['fullyQualifiedName'].split('@')[0];
315
+ }
316
+ appSchema.definitions[formDefinitionKey][ux_specification_types_2.SchemaTag.isViewNode] = true;
317
+ if (section.entityType?.name) {
318
+ appSchema.definitions[formDefinitionKey][ux_specification_types_2.SchemaTag.annotationPath] = __1.createAnnotationPath(section.entityType.fullyQualifiedName, section.target['term'], section.target['qualifier']);
319
+ }
320
+ }
321
+ /**
322
+ * Adds definitions for forms in object page sections to the app schema
323
+ * @param {SectionType} sectionType - prefix to distinguish Section and HeaderSection
324
+ * @param {FacetConfig} section - section definition, as prepared from the annotations
325
+ * @param {object} appSchemaSection - current definition of facet or section in the JSON schema
326
+ * @param {object} appSchema - app specific schema that gets enhanced
327
+ * @param {FioriElementsVersion} version - Fiori Elements version
328
+ * @param {string} facetKey - facet key
329
+ * @returns {string | undefined} target id of form
330
+ */
331
+ function handleForm(sectionType, section, appSchemaSection, appSchema, version, facetKey) {
332
+ if (!section.target) {
333
+ return;
334
+ }
335
+ const targetID = determineTargetIdOfForm(section);
336
+ const formDefinitionKey = __1.prepareRef(`${sectionType}${ux_specification_types_2.DefinitionName.Form}<${targetID}>`);
337
+ const fieldsDefinitionKey = __1.prepareRef(`${sectionType}${ux_specification_types_2.DefinitionName.Fields}<${targetID}>`);
338
+ const actionsDefinitionKey = __1.prepareRef(`${sectionType}${ux_specification_types_2.DefinitionName.Actions}<${targetID}>`);
339
+ const withActions = section.base === ux_specification_types_2.FacetBase.Identification && facetKey.indexOf('#') < 0 ? false : true;
340
+ // Form definition
341
+ appSchemaSection.properties.form = { $ref: `${__1.DEFINITION_LINK_PREFIX}${formDefinitionKey}` };
342
+ if (sectionType === ux_specification_types_2.SectionType.Section && withActions) {
343
+ appSchema.definitions[formDefinitionKey] = {
344
+ type: 'object',
345
+ properties: {
346
+ actions: {
347
+ $ref: `${__1.DEFINITION_LINK_PREFIX}${actionsDefinitionKey}`
348
+ },
349
+ fields: { $ref: `${__1.DEFINITION_LINK_PREFIX}${fieldsDefinitionKey}` }
350
+ },
351
+ description: 'Form',
352
+ additionalProperties: false
353
+ };
354
+ appSchema.definitions[actionsDefinitionKey] = {
355
+ type: 'object',
356
+ properties: {},
357
+ description: 'Actions',
358
+ additionalProperties: false
359
+ };
360
+ appSchema.definitions[actionsDefinitionKey][ux_specification_types_2.SchemaTag.isViewNode] = true;
361
+ }
362
+ else {
363
+ appSchema.definitions[formDefinitionKey] = {
364
+ type: 'object',
365
+ properties: {
366
+ fields: { $ref: `${__1.DEFINITION_LINK_PREFIX}${fieldsDefinitionKey}` }
367
+ },
368
+ description: 'Form',
369
+ additionalProperties: false
370
+ };
371
+ }
372
+ //Add schema tags
373
+ addTagsToFormDefinition(section, appSchema, formDefinitionKey);
374
+ // Fields definition
375
+ appSchema.definitions[fieldsDefinitionKey] = {
376
+ type: 'object',
377
+ properties: {},
378
+ description: 'Fields',
379
+ additionalProperties: false
380
+ };
381
+ appSchema.definitions[fieldsDefinitionKey][ux_specification_types_2.SchemaTag.isViewNode] = true;
382
+ // Add fields
383
+ addFieldsToFormDefinition(section, sectionType, appSchema, targetID, version, withActions);
384
+ return targetID;
385
+ }
187
386
  exports.handleForm = handleForm;
188
387
  /**
189
388
  * Replaces an alias in an annotation ID or reference, based on the AVT references' list
@@ -209,25 +408,33 @@ exports.replaceAlias = replaceAlias;
209
408
  /**
210
409
  * Common routine to determine the name and the ID of a header action
211
410
  * @param action - action as given by AVT
212
- * @param entityType - entity type by AVT
213
411
  * @returns an object comprising action name and action id
214
412
  */
215
- function getActionNameAndId(action, entityType) {
216
- let separatorIndex = action.lastIndexOf('/');
413
+ function getActionNameAndId(item, oDataServiceAVT) {
414
+ const action = replaceAlias(item.Action, oDataServiceAVT);
415
+ let relevantAction = action;
416
+ let separatorIndex = action.indexOf('(');
417
+ if (separatorIndex > 0) {
418
+ relevantAction = action.substring(0, separatorIndex);
419
+ }
420
+ separatorIndex = relevantAction.lastIndexOf('/');
217
421
  if (separatorIndex === -1) {
218
- separatorIndex = action.lastIndexOf('.');
422
+ separatorIndex = relevantAction.lastIndexOf('.');
219
423
  }
220
- let actionName, actionId;
424
+ let actionName, actionId, namespace;
221
425
  if (separatorIndex > -1) {
222
- actionName = action.substring(separatorIndex + 1);
223
- actionId = `${action.substring(0, separatorIndex)}::${actionName}`;
426
+ actionName = relevantAction.substring(separatorIndex + 1);
427
+ namespace = relevantAction.substring(0, separatorIndex);
428
+ actionId = `${relevantAction.substring(0, separatorIndex)}::${actionName}`;
224
429
  }
225
430
  else {
226
- actionName = action;
227
- const namespace = entityType.fullyQualifiedName.split(entityType.name)[0];
228
- actionId = `${namespace.substring(0, namespace.length - 1)}::${actionName}`;
431
+ actionName = relevantAction;
432
+ namespace = item.fullyQualifiedName.split('@')[0];
433
+ if (actionName && actionName !== '') {
434
+ actionId = `${namespace.substring(0, namespace.length - 1)}::${actionName}`;
435
+ }
229
436
  }
230
- return { actionName, actionId };
437
+ return { actionName, actionId, namespace };
231
438
  }
232
439
  exports.getActionNameAndId = getActionNameAndId;
233
440
  /**
@@ -238,36 +445,36 @@ exports.getActionNameAndId = getActionNameAndId;
238
445
  * @param {ConvertedMetadata} oDataServiceAVT - complete service information, as returned by annotation vocabularies tool
239
446
  */
240
447
  function addFooterActions(appSchema, generateParameters) {
241
- appSchema.definitions[ux_specification_types_1.DefinitionName.ObjectPageFooter] = JSON.parse(JSON.stringify(appSchema.definitions[`${ux_specification_types_1.DefinitionName.ObjectPageFooter}<ObjectPageFooterActions>`]));
448
+ appSchema.definitions[ux_specification_types_2.DefinitionName.ObjectPageFooter] = JSON.parse(JSON.stringify(appSchema.definitions[`${ux_specification_types_2.DefinitionName.ObjectPageFooter}<ObjectPageFooterActions>`]));
242
449
  // Change reference of footer
243
450
  appSchema.properties['footer'] = {
244
- $ref: `${__1.DEFINITION_LINK_PREFIX}${ux_specification_types_1.DefinitionName.ObjectPageFooter}`
451
+ $ref: `${__1.DEFINITION_LINK_PREFIX}${ux_specification_types_2.DefinitionName.ObjectPageFooter}`
245
452
  };
246
453
  // Add action to configuration
247
- appSchema.definitions[ux_specification_types_1.DefinitionName.ObjectPageFooter].properties[ux_specification_types_1.PropertyName.actions] = {
248
- $ref: `${__1.DEFINITION_LINK_PREFIX}${ux_specification_types_1.DefinitionName.FooterActions}`
454
+ appSchema.definitions[ux_specification_types_2.DefinitionName.ObjectPageFooter].properties[ux_specification_types_2.PropertyName.actions] = {
455
+ $ref: `${__1.DEFINITION_LINK_PREFIX}${ux_specification_types_2.DefinitionName.FooterActions}`
249
456
  };
250
- const footerActions = (appSchema.definitions[ux_specification_types_1.DefinitionName.FooterActions] = {
457
+ const footerActions = (appSchema.definitions[ux_specification_types_2.DefinitionName.FooterActions] = {
251
458
  type: 'object',
252
459
  properties: {},
253
460
  description: 'Actions',
254
461
  additionalProperties: false
255
462
  });
256
- footerActions[ux_specification_types_1.SchemaTag.isViewNode] = true;
257
- const alias = __1.findAlias(ux_specification_types_1.UIVOCABULARY, generateParameters.serviceAVT);
463
+ footerActions[ux_specification_types_2.SchemaTag.isViewNode] = true;
464
+ const alias = __1.findAlias(ux_specification_types_2.UIVOCABULARY, generateParameters.serviceAVT);
258
465
  const entityType = generateParameters.entitySet.entityType;
259
466
  const actionAnnotation = alias && entityType.annotations?.[alias]?.Identification;
260
467
  if (actionAnnotation) {
261
468
  const convertedIdentification = actionAnnotation.fullyQualifiedName.replace(`@${"com.sap.vocabularies.UI.v1.Identification" /* Identification */}`, `/@${"com.sap.vocabularies.UI.v1.Identification" /* Identification */}`);
262
- footerActions[ux_specification_types_1.SchemaTag.annotationPath] = `/${convertedIdentification}`;
469
+ footerActions[ux_specification_types_2.SchemaTag.annotationPath] = `/${convertedIdentification}`;
263
470
  actionAnnotation.forEach((item, index) => {
264
471
  if (item['Determining'] && item.$Type === "com.sap.vocabularies.UI.v1.DataFieldForAction" /* DataFieldForAction */) {
265
- const { actionName, actionId } = getActionNameAndId(item.Action, entityType);
472
+ const { actionName, actionId } = getActionNameAndId(item, generateParameters.serviceAVT);
266
473
  const description = item.Label || actionName;
267
- const actionDefinitionKey = __1.prepareRef(`${ux_specification_types_1.DefinitionName.ObjectPageFooterAction}<${actionId}>`);
268
- if (appSchema.definitions[ux_specification_types_1.DefinitionName.ObjectPageFooterAction]) {
474
+ const actionDefinitionKey = __1.prepareRef(`${ux_specification_types_2.DefinitionName.ObjectPageFooterAction}<${actionId}>`);
475
+ if (appSchema.definitions[ux_specification_types_2.DefinitionName.ObjectPageFooterAction]) {
269
476
  appSchema.definitions[actionDefinitionKey] = {
270
- ...JSON.parse(JSON.stringify(appSchema.definitions[ux_specification_types_1.DefinitionName.ObjectPageFooterAction])),
477
+ ...JSON.parse(JSON.stringify(appSchema.definitions[ux_specification_types_2.DefinitionName.ObjectPageFooterAction])),
271
478
  description,
272
479
  annotationPath: `/${convertedIdentification}/${index}`
273
480
  };
@@ -278,8 +485,8 @@ function addFooterActions(appSchema, generateParameters) {
278
485
  properties: {},
279
486
  description: description
280
487
  };
281
- appSchema.definitions[actionDefinitionKey][ux_specification_types_1.SchemaTag.isViewNode] = true;
282
- appSchema.definitions[actionDefinitionKey][ux_specification_types_1.SchemaTag.annotationPath] = `/${convertedIdentification}/${index}`;
488
+ appSchema.definitions[actionDefinitionKey][ux_specification_types_2.SchemaTag.isViewNode] = true;
489
+ appSchema.definitions[actionDefinitionKey][ux_specification_types_2.SchemaTag.annotationPath] = `/${convertedIdentification}/${index}`;
283
490
  }
284
491
  footerActions.properties[actionId] = {
285
492
  $ref: `${__1.DEFINITION_LINK_PREFIX}${actionDefinitionKey}`
@@ -288,10 +495,10 @@ function addFooterActions(appSchema, generateParameters) {
288
495
  });
289
496
  }
290
497
  else {
291
- footerActions[ux_specification_types_1.SchemaTag.annotationPath] = `/${entityType.fullyQualifiedName}/@${"com.sap.vocabularies.UI.v1.Identification" /* Identification */}`;
498
+ footerActions[ux_specification_types_2.SchemaTag.annotationPath] = `/${entityType.fullyQualifiedName}/@${"com.sap.vocabularies.UI.v1.Identification" /* Identification */}`;
292
499
  }
293
- delete appSchema.definitions[ux_specification_types_1.DefinitionName.ObjectPageFooterActions];
294
- delete appSchema.definitions[`${ux_specification_types_1.DefinitionName.ObjectPageFooter}<${ux_specification_types_1.DefinitionName.ObjectPageFooterActions}>`];
500
+ delete appSchema.definitions[ux_specification_types_2.DefinitionName.ObjectPageFooterActions];
501
+ delete appSchema.definitions[`${ux_specification_types_2.DefinitionName.ObjectPageFooter}<${ux_specification_types_2.DefinitionName.ObjectPageFooterActions}>`];
295
502
  }
296
503
  exports.addFooterActions = addFooterActions;
297
504
  /**
@@ -301,32 +508,32 @@ exports.addFooterActions = addFooterActions;
301
508
  * @param {ConvertedMetadata} oDataServiceAVT - complete service information, as returned by annotation vocabularies tool
302
509
  */
303
510
  function addHeaderActions(appSchema, entityType, oDataServiceAVT, addHeaderActionCallBack) {
304
- appSchema.definitions[ux_specification_types_1.DefinitionName.ObjectPageHeader].properties[ux_specification_types_1.PropertyName.actions] = {
305
- $ref: `${__1.DEFINITION_LINK_PREFIX}${ux_specification_types_1.DefinitionName.HeaderActions}`
511
+ appSchema.definitions[ux_specification_types_2.DefinitionName.ObjectPageHeader].properties[ux_specification_types_2.PropertyName.actions] = {
512
+ $ref: `${__1.DEFINITION_LINK_PREFIX}${ux_specification_types_2.DefinitionName.HeaderActions}`
306
513
  };
307
- const headerActions = (appSchema.definitions[ux_specification_types_1.DefinitionName.HeaderActions] = {
514
+ const headerActions = (appSchema.definitions[ux_specification_types_2.DefinitionName.HeaderActions] = {
308
515
  type: 'object',
309
516
  properties: {},
310
517
  description: 'Actions',
311
518
  additionalProperties: false
312
519
  });
313
- headerActions[ux_specification_types_1.SchemaTag.isViewNode] = true;
314
- const alias = __1.findAlias(ux_specification_types_1.UIVOCABULARY, oDataServiceAVT);
520
+ headerActions[ux_specification_types_2.SchemaTag.isViewNode] = true;
521
+ const alias = __1.findAlias(ux_specification_types_2.UIVOCABULARY, oDataServiceAVT);
315
522
  const identification = alias &&
316
523
  entityType.annotations &&
317
524
  entityType.annotations[alias] &&
318
525
  entityType.annotations[alias].Identification;
319
526
  if (identification) {
320
- headerActions[ux_specification_types_1.SchemaTag.annotationPath] =
527
+ headerActions[ux_specification_types_2.SchemaTag.annotationPath] =
321
528
  '/' +
322
529
  identification.fullyQualifiedName.replace(`@${"com.sap.vocabularies.UI.v1.Identification" /* Identification */}`, `/@${"com.sap.vocabularies.UI.v1.Identification" /* Identification */}`);
323
530
  identification.forEach(addHeaderActionCallBack(entityType, appSchema, identification, headerActions, oDataServiceAVT));
324
531
  }
325
532
  else {
326
- headerActions[ux_specification_types_1.SchemaTag.annotationPath] = `/${entityType.fullyQualifiedName}/@${"com.sap.vocabularies.UI.v1.Identification" /* Identification */}`;
533
+ headerActions[ux_specification_types_2.SchemaTag.annotationPath] = `/${entityType.fullyQualifiedName}/@${"com.sap.vocabularies.UI.v1.Identification" /* Identification */}`;
327
534
  }
328
- delete appSchema.definitions[ux_specification_types_1.DefinitionName.GenericActions];
329
- delete appSchema.definitions[`${ux_specification_types_1.DefinitionName.ObjectPageHeader}<${ux_specification_types_1.DefinitionName.GenericActions}>`];
535
+ delete appSchema.definitions[ux_specification_types_2.DefinitionName.GenericActions];
536
+ delete appSchema.definitions[`${ux_specification_types_2.DefinitionName.ObjectPageHeader}<${ux_specification_types_2.DefinitionName.GenericActions}>`];
330
537
  }
331
538
  exports.addHeaderActions = addHeaderActions;
332
539
  /**
@@ -336,10 +543,10 @@ exports.addHeaderActions = addHeaderActions;
336
543
  */
337
544
  function addCommonHeaderSchema(appSchema, entityType) {
338
545
  appSchema.properties['header'] = {
339
- $ref: `${__1.DEFINITION_LINK_PREFIX}${ux_specification_types_1.DefinitionName.ObjectPageHeader}`
546
+ $ref: `${__1.DEFINITION_LINK_PREFIX}${ux_specification_types_2.DefinitionName.ObjectPageHeader}`
340
547
  };
341
- appSchema.definitions[ux_specification_types_1.DefinitionName.ObjectPageHeader] = JSON.parse(JSON.stringify(appSchema.definitions[`${ux_specification_types_1.DefinitionName.ObjectPageHeader}<${ux_specification_types_1.DefinitionName.GenericActions}>`]));
342
- appSchema.definitions[ux_specification_types_1.DefinitionName.ObjectPageHeader][ux_specification_types_1.SchemaTag.annotationPath] = `/${entityType.fullyQualifiedName}/@${"com.sap.vocabularies.UI.v1.HeaderInfo" /* HeaderInfo */}`;
548
+ appSchema.definitions[ux_specification_types_2.DefinitionName.ObjectPageHeader] = JSON.parse(JSON.stringify(appSchema.definitions[`${ux_specification_types_2.DefinitionName.ObjectPageHeader}<${ux_specification_types_2.DefinitionName.GenericActions}>`]));
549
+ appSchema.definitions[ux_specification_types_2.DefinitionName.ObjectPageHeader][ux_specification_types_2.SchemaTag.annotationPath] = `/${entityType.fullyQualifiedName}/@${"com.sap.vocabularies.UI.v1.HeaderInfo" /* HeaderInfo */}`;
343
550
  }
344
551
  exports.addCommonHeaderSchema = addCommonHeaderSchema;
345
552
  /**