@sap/ux-specification 1.84.112 → 1.84.114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/dist/documentation/v2/v2-AnalyticalListPage.html +2 -2
  3. package/dist/documentation/v2/v2-ApplicationV2.html +2 -2
  4. package/dist/documentation/v2/v2-ListReport.html +2 -2
  5. package/dist/documentation/v2/v2-ObjectPage.html +2 -2
  6. package/dist/documentation/v2/v2-OverviewPage.html +2 -2
  7. package/dist/documentation/v4/v4-ApplicationV4.html +2 -2
  8. package/dist/documentation/v4/v4-ListReport.html +2 -2
  9. package/dist/documentation/v4/v4-ObjectPage.html +2 -2
  10. package/dist/index-min.js +21 -21
  11. package/dist/index-min.js.map +3 -3
  12. package/dist/specification/package.json +2 -2
  13. package/dist/specification/scripts/extractDocu.js +2 -2
  14. package/dist/specification/scripts/extractDocu.js.map +1 -1
  15. package/dist/specification/src/sync/common/dist_tag.json +17 -2
  16. package/dist/specification/src/sync/common/generate/utils.d.ts +7 -0
  17. package/dist/specification/src/sync/common/generate/utils.d.ts.map +1 -1
  18. package/dist/specification/src/sync/common/generate/utils.js +17 -0
  19. package/dist/specification/src/sync/common/generate/utils.js.map +1 -1
  20. package/dist/specification/src/sync/common/i18n.json +2 -1
  21. package/dist/specification/src/sync/v2/export/exportPageGeneric.d.ts +72 -0
  22. package/dist/specification/src/sync/v2/export/exportPageGeneric.d.ts.map +1 -0
  23. package/dist/specification/src/sync/v2/export/exportPageGeneric.js +307 -0
  24. package/dist/specification/src/sync/v2/export/exportPageGeneric.js.map +1 -0
  25. package/dist/specification/src/sync/v2/generate/manifestPropertyUtils.d.ts +118 -0
  26. package/dist/specification/src/sync/v2/generate/manifestPropertyUtils.d.ts.map +1 -0
  27. package/dist/specification/src/sync/v2/generate/manifestPropertyUtils.js +151 -0
  28. package/dist/specification/src/sync/v2/generate/manifestPropertyUtils.js.map +1 -0
  29. package/dist/specification/src/sync/v2/generate/schemaAdaptation.d.ts +2 -2
  30. package/dist/specification/src/sync/v2/generate/schemaAdaptation.js +6 -6
  31. package/dist/specification/src/sync/v2/generate/schemaAdaptation.js.map +1 -1
  32. package/dist/specification/src/sync/v2/generate/utils.d.ts +0 -14
  33. package/dist/specification/src/sync/v2/generate/utils.d.ts.map +1 -1
  34. package/dist/specification/src/sync/v2/generate/utils.js +0 -38
  35. package/dist/specification/src/sync/v2/generate/utils.js.map +1 -1
  36. package/dist/specification/src/sync/v2/import/importPage.d.ts +3 -3
  37. package/dist/specification/src/sync/v2/import/importPage.d.ts.map +1 -1
  38. package/dist/specification/src/sync/v2/import/importPage.js +4 -13
  39. package/dist/specification/src/sync/v2/import/importPage.js.map +1 -1
  40. package/dist/specification/src/sync/v2/utils.d.ts +8 -0
  41. package/dist/specification/src/sync/v2/utils.d.ts.map +1 -1
  42. package/dist/specification/src/sync/v2/utils.js +11 -1
  43. package/dist/specification/src/sync/v2/utils.js.map +1 -1
  44. package/dist/specification/src/sync/v4/generate/listReport.d.ts.map +1 -1
  45. package/dist/specification/src/sync/v4/generate/listReport.js +8 -2
  46. package/dist/specification/src/sync/v4/generate/listReport.js.map +1 -1
  47. package/dist/types/src/apiTypes.d.ts +13 -0
  48. package/dist/types/src/apiTypes.d.ts.map +1 -1
  49. package/dist/types/src/apiTypes.js +18 -1
  50. package/dist/types/src/apiTypes.js.map +1 -1
  51. package/dist/types/src/common/types.d.ts +4 -0
  52. package/dist/types/src/common/types.d.ts.map +1 -1
  53. package/package.json +2 -2
@@ -0,0 +1,307 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.exportPage = exportPage;
4
+ const ux_specification_types_1 = require("@sap/ux-specification-types");
5
+ const utils_1 = require("../utils");
6
+ const common_1 = require("../../common");
7
+ /**
8
+ * This function is called for every property in the page specific schema with artifactType FlexChange.
9
+ * Thereby, we assume that such a property always corresponds to a control property (with same name) that can be changed via a flex change
10
+ * The function will derive the information about the flex change that should be created (or the information that no flex change is needed)
11
+ * for this property and add it to the list.
12
+ *
13
+ * @param propertyDefinition - definition of the property in the page specific schema
14
+ * @param value - the value for the property according to the config object that is currently exported
15
+ * @param propertyName - name of the property
16
+ * @param flexList - the list to be enhanced
17
+ */
18
+ function addFlexChangeInfoToList(propertyDefinition, value, propertyName, flexList) {
19
+ const newValue = value === undefined ? null : value; // special logic for control properties which are not changed by flex
20
+ // TODO: Add conversion exit logic
21
+ const isBinding = typeof newValue === 'string' && newValue.startsWith('{');
22
+ flexList.push({
23
+ controlId: propertyDefinition[ux_specification_types_1.SchemaTag.controlId],
24
+ controlType: propertyDefinition[ux_specification_types_1.SchemaTag.controlType],
25
+ propertyName,
26
+ newValue,
27
+ isBinding
28
+ });
29
+ }
30
+ /**
31
+ * Returns how a value from the config should be passed to the manifest.
32
+ * This function will be called for all properties with artifactType 'Manifest'.
33
+ * In case the property has type 'object' it will also be recursively be called for all children of the object.
34
+ *
35
+ * @param value - the value for the property in the config currently processed (undefined if the property is not present in the config)
36
+ * @param oldValue - current value for the property in the manifest (resp. undefined if the property is not in the current manifest)
37
+ * @param propertyDefinition - definition of the property in the current schema
38
+ * @param globalTypeDefinitions - global type definitions that may be referred from within propertyDefinition
39
+ * @returns the value for the property in the modified manifest, resp. undefined when the property should be removed from the manifest.
40
+ */
41
+ function getValueForManifest(value, oldValue, propertyDefinition, globalTypeDefinitions) {
42
+ // Special logic for string arrays. Note that the opposite logic is implemented in function getConfigRep in import.importPage.ts
43
+ if (propertyDefinition.type === 'array' && propertyDefinition.items?.['type'] === 'string') {
44
+ if (!Array.isArray(value) || value.length === 0) {
45
+ return oldValue === '' || typeof oldValue !== 'string' ? oldValue : undefined;
46
+ }
47
+ return value.join(',');
48
+ }
49
+ if (value === oldValue || propertyDefinition.type !== 'object' || !propertyDefinition.properties) {
50
+ return value; // unchanged entries will not be modified. Moreover, only objects with properties need special care
51
+ }
52
+ // In case an object is to be returned this return object is built as follows:
53
+ // Take (a shallow copy of) oldValue as a starting point (resp. an empty object if oldValue was not a valid object) and
54
+ // replace its values for 'known' properties (i.e. the properties defined in the schema) by the corresponding property value from newValue.
55
+ // If this would set the property value to undefined remove the property instead.
56
+ // Note that this procedure guarantees that the values for unknown properties stay as they are in oldValue.
57
+ const returnObject = typeof oldValue === 'object' && oldValue !== null ? { ...oldValue } : {};
58
+ let hasNewValueDefinedChildProperty = false;
59
+ let hasOldValueDefinedChildProperty = false;
60
+ for (const childProperty in propertyDefinition.properties) {
61
+ let childPropertyDefinition = propertyDefinition.properties[childProperty];
62
+ if (!(0, utils_1.isDefinition)(childPropertyDefinition)) {
63
+ continue; // ignore properties defined as boolean (should not appear in our schemas anyway)
64
+ }
65
+ const refType = (0, common_1.getRefType)(childPropertyDefinition);
66
+ childPropertyDefinition = (refType && globalTypeDefinitions[refType]) || childPropertyDefinition;
67
+ const oldChildValue = returnObject[childProperty];
68
+ hasOldValueDefinedChildProperty = hasOldValueDefinedChildProperty || oldChildValue !== undefined;
69
+ const newChildValue = getValueForManifest(value ? value[childProperty] : undefined, oldChildValue, childPropertyDefinition, globalTypeDefinitions);
70
+ if (newChildValue === undefined) {
71
+ delete returnObject[childProperty];
72
+ }
73
+ else {
74
+ returnObject[childProperty] = newChildValue;
75
+ hasNewValueDefinedChildProperty = true;
76
+ }
77
+ }
78
+ // If the object which was built in the way described above has at least one known property value we can safely return it as the new value
79
+ if (hasNewValueDefinedChildProperty) {
80
+ return returnObject;
81
+ }
82
+ // When we reach this point newValue does not contain a value for any known property. If the same was true for oldValue we can safely return the oldValue as
83
+ // no changes have been applied to this object.
84
+ if (!hasOldValueDefinedChildProperty) {
85
+ return oldValue;
86
+ }
87
+ // When we reach this point then newValue contains the information that all known properties should be removed from the oldValue
88
+ // and that this has happened for at least one property. We still distinguish two cases:
89
+ // - oldValues contains no unknown properties. As all known properties have been removed, returnObject has been stripped to be an empty object.
90
+ // In this case we return undefined to indicate that the object should be removed from the manifest as well.
91
+ // - oldValue contains at least one unknown property. In this case we want to keep the object alive, now containing only the unknown properties.
92
+ // This is, what we get from returnObject.
93
+ return Object.keys(oldValue).every((oldValueKey) => (0, utils_1.isDefinition)(propertyDefinition.properties[oldValueKey]))
94
+ ? undefined
95
+ : returnObject;
96
+ }
97
+ /**
98
+ * Returns whether two java script instances should be considered as different manifest entries.
99
+ *
100
+ * @param obj1 the first instance
101
+ * @param obj2 the second instance
102
+ * @returns whether obj1 and obj2 should be considered different.
103
+ */
104
+ function isDifferent(obj1, obj2) {
105
+ if (typeof obj1 !== 'object' || typeof obj2 !== 'object' || obj1 === null || obj2 === null) {
106
+ return obj1 !== obj2;
107
+ }
108
+ // This if-block is probably superfluous, since manifests of v2 apps should not contain any
109
+ // arrays. We leave it in for completeness.
110
+ if (Array.isArray(obj1) || Array.isArray(obj2)) {
111
+ if (Array.isArray(obj1) && Array.isArray(obj2)) {
112
+ return (obj1.length !== obj2.length ||
113
+ obj1.some(function (entry1, i) {
114
+ return isDifferent(entry1, obj2[i]);
115
+ }));
116
+ }
117
+ return true;
118
+ }
119
+ const keys1 = Object.keys(obj1).filter((key) => obj1[key] !== undefined);
120
+ const keys2 = Object.keys(obj2).filter((key) => obj2[key] !== undefined);
121
+ return (keys1.length !== keys2.length ||
122
+ keys1.some(function (key) {
123
+ return isDifferent(obj1[key], obj2[key]);
124
+ }));
125
+ }
126
+ /**
127
+ * Returns whether an object should be considered as an empty object (and thus normally should be removed from the manifest).
128
+ *
129
+ * @param obj - the object to be checked
130
+ * @returns whether the object should be considered empty
131
+ */
132
+ function isEmpty(obj) {
133
+ return !obj || !Object.keys(obj).some((key) => obj[key] !== undefined);
134
+ }
135
+ /**
136
+ * This function is called by transferConfigPropertyToExportResults (see below) for schema properties that have artifactType 'Manifest'.
137
+ * It is responsible for transferring the config value of this property to the manifest and the fragments (not implemented yet).
138
+ *
139
+ * @param fullManifestPath - the path in the manifest (ending with the name of the property itself) the value should be passed to
140
+ * @param value - content of the property according to the config, resp. undefined if the property is not present in the config.
141
+ * In the later case the property should (normally) be removed from the manifest.
142
+ * @param target - the results of the export to be updated
143
+ * @param propertyDefinition - definition of the property in the page specific schema
144
+ * @param globalTypeDefinitions - global type definitions that may be referred from within propertyDefinition
145
+ */
146
+ function applyManifestChange(fullManifestPath, value, target, propertyDefinition, globalTypeDefinitions) {
147
+ let manifestSection = target.manifest; // will be used to step down in the hierarchy of the manifest to the parent of the target property
148
+ const lengthToParent = fullManifestPath.length - 1;
149
+ const finalProperty = fullManifestPath[lengthToParent]; // name of the property which should be updated
150
+ const backPath = []; // Will be set to contain the (not null) objects in the current manifest which lie on the path to the parent of the target property
151
+ // Step down in the manifest to the parent of the target property. Stop if an entry on that path is missing (or not an object).
152
+ fullManifestPath.some(function (property, i) {
153
+ if (i === lengthToParent) {
154
+ // as we only want to navigate to the parent, stop now
155
+ return true;
156
+ }
157
+ const nextSection = manifestSection[property];
158
+ if (typeof nextSection !== 'object' || nextSection === null) {
159
+ return true; // do not step down to something which is not an object (normally that means that we reached undefined, but incorrect manifests may also contain other values where an object is expected)
160
+ }
161
+ // Safely step down to the object on the next level
162
+ manifestSection = nextSection;
163
+ backPath.push(manifestSection);
164
+ });
165
+ // If the length of backPath is lengthToParent the parent object already exists in the manifest (and is an object). So we (potentially) have an old value for the target property
166
+ const oldValue = backPath.length === lengthToParent ? manifestSection[finalProperty] : undefined;
167
+ const newValue = getValueForManifest(value, oldValue, propertyDefinition, globalTypeDefinitions);
168
+ if (!isDifferent(newValue, oldValue)) {
169
+ return; // nothing to do
170
+ }
171
+ // newValue and oldValue are different
172
+ if (newValue === undefined) {
173
+ // Note: As newValue and oldValue are different, oldValue cannot be undefined as well. Hence, backPath.length === lengthToParent according to the definition of oldValue
174
+ target.manifestChangeIndicator = ux_specification_types_1.ChangeIndicator.Deleted;
175
+ // Remove the specified property from its parent. Then loop the object hierarchy upwards and delete all objects which have been made empty by this process.
176
+ for (let i = lengthToParent; i > 0; i--) {
177
+ const candidateForRemove = backPath[i]; // will be undefined in the first run
178
+ if (!isEmpty(candidateForRemove)) {
179
+ break; // stop the process when finding an object that is not empty after deleting the specified entry. Will not happen in the first run.
180
+ }
181
+ // As the object is empty: Remove it from its parent. Will be executed at least once, thereby removing the specified property from its parent.
182
+ const parent = backPath[i - 1];
183
+ const prop = fullManifestPath[i];
184
+ delete parent[prop];
185
+ }
186
+ }
187
+ else {
188
+ // Create a path of empty objects to the parent of target, if the manifest is not structured deep enough yet
189
+ for (let i = backPath.length; i < lengthToParent; i++) {
190
+ const newEmptyObject = {};
191
+ manifestSection[fullManifestPath[i]] = newEmptyObject;
192
+ manifestSection = newEmptyObject;
193
+ }
194
+ // Now manifestSection is the parent object of the property to be set -> update it with the new value
195
+ manifestSection[finalProperty] = newValue;
196
+ target.manifestChangeIndicator = oldValue === undefined ? ux_specification_types_1.ChangeIndicator.Created : ux_specification_types_1.ChangeIndicator.Updated;
197
+ }
198
+ }
199
+ /**
200
+ * This function is called by function transferConfigToExportResults (see below) for all properties contained in the
201
+ * schema element processed by this function.
202
+ * It is responsible for transferring the content of the config for this property to the export results.
203
+ *
204
+ * @param source - the section of the config that potentially contains the property
205
+ * @param target - the results of the export to be updated
206
+ * @param property - name of the property to be handled
207
+ * @param propertyDefinition - definition of the property in the page specific schema
208
+ * @param globalTypeDefinitions - global type definitions that may be referred from within propertyDefinition
209
+ */
210
+ function transferConfigPropertyToExportResults(source, target, property, propertyDefinition, globalTypeDefinitions) {
211
+ const sourcePart = source?.[property];
212
+ const artifactType = propertyDefinition[ux_specification_types_1.SchemaTag.artifactType];
213
+ // We distinguish three cases:
214
+ // - current property is handled by flex
215
+ // - current property can be mapped onto a manifest property (or a section within the manifest)
216
+ // - property is still complex and points to a global type which describes how the content should be processed
217
+ // Note that the inline definition of a complex type is not yet supported.
218
+ if (artifactType === ux_specification_types_1.ArtifactType.FlexChange) {
219
+ // Case 1
220
+ addFlexChangeInfoToList(propertyDefinition, sourcePart, property, target.flexList);
221
+ }
222
+ else if (artifactType === ux_specification_types_1.ArtifactType.Manifest && propertyDefinition[ux_specification_types_1.SchemaTag.manifestPath]) {
223
+ // Case 2
224
+ let manifestPath;
225
+ // propertyDefinition.manifestPath is an instance of AccessorSpec that describes how to find
226
+ // the place in the manifest representing the property.
227
+ // We will use this definition to build the full path (including the property name itself) -> this is manifestPath
228
+ const accessorSpec = propertyDefinition[ux_specification_types_1.SchemaTag.manifestPath];
229
+ if (Array.isArray(accessorSpec)) {
230
+ manifestPath = accessorSpec.concat([property]);
231
+ }
232
+ else {
233
+ manifestPath = accessorSpec.path;
234
+ if (accessorSpec.addTargetPropertyToPath) {
235
+ manifestPath = manifestPath.concat([property]);
236
+ }
237
+ }
238
+ applyManifestChange(manifestPath, sourcePart, target, propertyDefinition, globalTypeDefinitions);
239
+ }
240
+ else {
241
+ // Note: inline type definitions currently not supported
242
+ const refType = (0, common_1.getRefType)(propertyDefinition);
243
+ const refTypeDefinition = refType ? globalTypeDefinitions[refType] : undefined;
244
+ if ((0, utils_1.isDefinition)(refTypeDefinition)) {
245
+ transferConfigToExportResults(sourcePart, target, refTypeDefinition, globalTypeDefinitions);
246
+ }
247
+ }
248
+ }
249
+ /**
250
+ * This function is used by function exportPage (see below).
251
+ * It (recursively) transfers the content of the config or one of its sub-objects to the export results.
252
+ * Note that the process is driven by the structure of the schema and not by the structure of the current config.
253
+ * This means that we will finally process all properties defined directly or indirectly within the given schema element, even if they are not contained in the config
254
+ * (which means that no change for the corresponding property should be there).
255
+ * This ensures that properties which have been removed from the config are handled correctly as well (for manifest based properties this means that they are removed from the manifest,
256
+ * for flex changes this means that a flex change with value null is created).
257
+ *
258
+ * @param source - the section of the config to be transferred
259
+ * @param target - the results of the export to be updated
260
+ * @param definition - schema element describing the section of the config currently processed
261
+ * @param globalTypeDefinitions - global type definitions that may be referred from within definition
262
+ */
263
+ function transferConfigToExportResults(source, target, definition, globalTypeDefinitions) {
264
+ const properties = definition.properties || {};
265
+ // Perform the update for all available properties
266
+ for (const property in properties) {
267
+ // propertyDefinition tells us how to handle the property
268
+ const propertyDefinition = definition.properties[property];
269
+ if ((0, utils_1.isDefinition)(propertyDefinition)) {
270
+ // ignore properties that are null or boolean (should not occur in our schemas anyway)
271
+ transferConfigPropertyToExportResults(source, target, property, propertyDefinition, globalTypeDefinitions);
272
+ }
273
+ }
274
+ }
275
+ /**
276
+ * This function implements the generic export for a page.
277
+ * More precisely it takes the current state of the app (manifest, flex changes, fragments), the page specific schema for a page within the app, and the
278
+ * config for this page. It returns the information how the app should be adapted.
279
+ * Thereby, we assume that the config was created by function getConfigForPage (in importPage.ts) from the current state of the page
280
+ * and then potentially modified (e.g. by user interaction).
281
+ *
282
+ * @param inParameters - an object containing all information relevant for the export process
283
+ * @returns the information about the updated state of the app
284
+ */
285
+ function exportPage(inParameters) {
286
+ const config = inParameters.config;
287
+ const globalTypeDefinitions = inParameters.jsonSchema.definitions;
288
+ // As a starting point create a return object representing the current state of the app
289
+ const fragmentResults = (inParameters.fragments || []).map(function (fragment) {
290
+ const result = {
291
+ ...fragment,
292
+ changeIndicator: ux_specification_types_1.ChangeIndicator.NoChange
293
+ };
294
+ return result;
295
+ });
296
+ // TODO: Check whether property 'views' needs to be initialized as well
297
+ const returnObject = {
298
+ manifest: structuredClone(inParameters.manifest),
299
+ manifestChangeIndicator: ux_specification_types_1.ChangeIndicator.NoChange,
300
+ flexList: [],
301
+ fragments: fragmentResults
302
+ };
303
+ // Adapt returnObject according to the state of the config. This is driven by the page specific schema.
304
+ transferConfigToExportResults(config, returnObject, inParameters.jsonSchema, globalTypeDefinitions);
305
+ return returnObject;
306
+ }
307
+ //# sourceMappingURL=exportPageGeneric.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exportPageGeneric.js","sourceRoot":"","sources":["../../../../../../src/sync/v2/export/exportPageGeneric.ts"],"names":[],"mappings":";;AAuYA,gCAuBC;AA9YD,wEAAuF;AAEvF,oCAAwC;AACxC,yCAA0C;AAwD1C;;;;;;;;;;GAUG;AACH,SAAS,uBAAuB,CAC5B,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ACtF,qCAAqC,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,kBAAkB,EAAE,qBAAqB,CAAC,CAAC;QAC/G,CAAC;IACL,CAAC;AACL,CAAC;AAED;;;;;;;;;GASG;AACH,SAAgB,UAAU,CAAC,YAAoC;IAC3D,MAAM,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC;IACnC,MAAM,qBAAqB,GAAG,YAAY,CAAC,UAAU,CAAC,WAA4C,CAAC;IAEnG,uFAAuF;IACvF,MAAM,eAAe,GAAG,CAAC,YAAY,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,UAAU,QAAQ;QACzE,MAAM,MAAM,GAAmB;YAC3B,GAAG,QAAQ;YACX,eAAe,EAAE,wCAAe,CAAC,QAAQ;SAC5C,CAAC;QACF,OAAO,MAAM,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,uEAAuE;IACvE,MAAM,YAAY,GAAG;QACjB,QAAQ,EAAE,eAAe,CAAC,YAAY,CAAC,QAAQ,CAAC;QAChD,uBAAuB,EAAE,wCAAe,CAAC,QAAQ;QACjD,QAAQ,EAAE,EAAgB;QAC1B,SAAS,EAAE,eAAe;KAC7B,CAAC;IACF,uGAAuG;IACvG,6BAA6B,CAAC,MAAM,EAAE,YAAY,EAAE,YAAY,CAAC,UAAU,EAAE,qBAAqB,CAAC,CAAC;IACpG,OAAO,YAAY,CAAC;AACxB,CAAC"}
@@ -0,0 +1,118 @@
1
+ /**
2
+ * @file This file contains helper functions for generating page specific schemas that are used in the context of manifest properties.
3
+ * The functionality is implicitly tested by the more complex unit-tests for generic schema generation and generic import in test-folder unit/genericSchemaHandling.
4
+ */
5
+ import type { Definition } from 'typescript-json-schema';
6
+ import type { SyncRule, GenerateAppSchemaParameters, ProcessingRule, AccessorPath, SchemaHandlingParams, ReferenceAdaptationInfo } from '@sap/ux-specification-types';
7
+ import type { ExtensionLogger } from '../../..';
8
+ /**
9
+ * Type check for properties coming from the manifest.
10
+ *
11
+ * @param parent - the parent object in manifest which may contain the property.
12
+ * @param propertyName - name of the property name to be checked
13
+ * @param logger - a logger which may receive the error message in case a type error is detected
14
+ * @param expectedType - the expected type of the value of the property (if it is not undefined)
15
+ * @param mandatory - specifies handling of null and undefined: If parent is null this is always considered an error.
16
+ * undefined value for parent or its specified property is considered an error when parameter mandatory is true.
17
+ * null value for the specified property is considered an error when mandatory is true or the expected type is not 'object'.
18
+ * @returns the information whether a type error was detected.
19
+ */
20
+ export declare function hasPropertyTypeError(parent: unknown, propertyName: string, logger?: ExtensionLogger, expectedType?: string, mandatory?: boolean): boolean;
21
+ /**
22
+ * This symbol is used to indicate that a property is not allowed in the current context and that it should be hidden without any explanation.
23
+ */
24
+ export declare const DISALLOWED_WITHOUT_EXPLANATION: unique symbol;
25
+ /**
26
+ * An instance of this type describes whether a property is allowed in the current context or not.
27
+ * A faulty instance of this type expresses that the property is allowed in the current context.
28
+ * A non-faulty string instance expresses that the property is not allowed in the current context.
29
+ * Moreover, it contains the human readable reason why the property is not allowed.
30
+ * The special value DISALLOWED_WITHOUT_EXPLANATION indicates that the property is not allowed in the current context
31
+ * and that it should be hidden without any explanation.
32
+ */
33
+ export type DisallowedSpecification = string | typeof DISALLOWED_WITHOUT_EXPLANATION;
34
+ /**
35
+ * Helper function to be called within elementAdapters of syncRules.
36
+ * The function should be called when a property defined in the generic schema is not valid
37
+ * for the page the specific schema is currently generated for.
38
+ * We distinguish two cases:
39
+ * - The property is present in the manifest (although it should not)
40
+ * - The property is not present in the manifest (as expected)
41
+ * In the first case the corresponding property should still be present in the schema.
42
+ * However, a warning message is added to the schema in order to make the user aware of this inconsistency.
43
+ * In the second case the property should not be shown to the user. So, preferably we would
44
+ * remove the property from the schema.
45
+ * However, this is currently not possible due to a flaw in the undo/redo logic which results in schemas
46
+ * being used to process the export that do not exactly fit to the current state of the config.
47
+ * For these cases we need the manifest path which is stored with the definition of the property in the schema.
48
+ * Therefore, we set the hidden flag of the property to true. This will be changed as soon as the undo/redo logic has been refactored.
49
+ *
50
+ * @param disallowedReason - The truthy description how the disallowed property should be handled
51
+ * @param element - the element in the schema representing the property
52
+ * @param value - the value of the property in the manifest
53
+ * @param manifestPath - the path to the property in the manifest
54
+ * @returns the ProcessingRule for element, resp. undefined if the element should not be removed from the page specific schema.
55
+ * Note that the second case will only occur after the refactoring of the undo/redo logic.
56
+ */
57
+ export declare function handleDisallowedProperty(disallowedReason: DisallowedSpecification, element: Definition, value: unknown, manifestPath: AccessorPath): ProcessingRule | undefined;
58
+ /**
59
+ * Instances of this type are used during page specific schema generation. They specify how to deal with a specific manifest property.
60
+ * Instances of this type should be provided by instances of type ManifestAnalyzer (passed to function getSyncRuleForManifestProperty).
61
+ *
62
+ * @property manifestPath - specifies where the content for this property should be located within the manifest
63
+ * @property disallowedReason - faulty when the property is valid for the page. Otherwise describes how to deal with the disallowed property if it is present in the manifest.
64
+ */
65
+ export type ManifestRule = {
66
+ manifestPath: AccessorPath;
67
+ disallowedReason?: DisallowedSpecification;
68
+ };
69
+ /**
70
+ * An instance of this type provides a possibility to obtain a ManifestRule. ManifestAnalyzers should be provided by users of function getSyncRuleForManifestProperty.
71
+ *
72
+ * @param element - the element in the schema representing the property to be analyzed
73
+ * @param schemaHandlingParams - information provided by the hierarchy level above of the schema generation process
74
+ * @param generateParameters - input parameters for the schema generation process
75
+ * @returns a ManifestRule which specifies how to deal with the manifest property
76
+ */
77
+ export type ManifestAnalyzer = (element: Definition, schemaHandlingParams: SchemaHandlingParams, generateParameters: GenerateAppSchemaParameters) => ManifestRule;
78
+ /**
79
+ * An instance of this type is called within an instance of type ElementAdapter.
80
+ * Thereby, the schema element it is working on represents a manifest property.
81
+ * The function is called with the same parameters as an instance of type ElementAdapter.
82
+ * The only difference is that the function is called with an additional parameter 'value' which contains the value of the property in the manifest.
83
+ * The task of this function is to adapt the schema element for the page specific schema (if such an adaptation is necessary).
84
+ *
85
+ * @param element - same as in type ElementAdapter. It represents a manifest property.
86
+ * @param schemaHandlingParams - same as in type ElementAdapter
87
+ * @param generateParameters - same as in type ElementAdapter
88
+ * @param value - the value of the property in the manifest
89
+ * @returns a ProcessingRule which specifies how to deal with the manifest property
90
+ */
91
+ type ElementAdapterExtended = (element: Definition, schemaHandlingParams: SchemaHandlingParams, generateParameters: GenerateAppSchemaParameters, value: unknown) => void;
92
+ /**
93
+ * An instance of this type is called within an instance of type ElementAdapter.
94
+ * Thereby, the schema element it is working on represents a manifest property.
95
+ * The function is called with the same parameters as an instance of type ElementAdapter.
96
+ * The only difference is that the parameter 'element' is not passed to the function.
97
+ * The task of this function is to provide the ReferenceAdaptationInfo which should be included
98
+ * in the ProcessingRule provided by the ElementAdapter (if an adaptation of the reference is necessary).
99
+ *
100
+ * @param schemaHandlingParams - same as in type ElementAdapter
101
+ * @param generateParameters - same as in type ElementAdapter
102
+ * @returns the ReferenceAdaptationInfo to be included in the ProcessingRule if necessary
103
+ */
104
+ export type ReferenceAdaptationProvider = (schemaHandlingParams: SchemaHandlingParams, generateParameters: GenerateAppSchemaParameters) => ReferenceAdaptationInfo | undefined;
105
+ /**
106
+ * This function can be used to generate a SyncRule for a manifest property that may be omitted in the page specific schema
107
+ * depending on the context of the page.
108
+ *
109
+ * @param property - the name of the property in the manifest the SyncRule should be generated for
110
+ * @param analyze - provides the ManifestRule for the property
111
+ * @param adapt - an optional function that can be used to adapt the schema element representing the manifest property
112
+ * @param provideReferenceAdaptation - an optional function that can be used to provide the ReferenceAdaptationInfo for the manifest property
113
+ * @param expectedType - the expected type of the value of the property (if it is not undefined)
114
+ * @returns the SyncRule for the manifest property
115
+ */
116
+ export declare function getSyncRuleForManifestProperty(property: string, analyze: ManifestAnalyzer, adapt?: ElementAdapterExtended, provideReferenceAdaptation?: ReferenceAdaptationProvider, expectedType?: string): SyncRule;
117
+ export {};
118
+ //# sourceMappingURL=manifestPropertyUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifestPropertyUtils.d.ts","sourceRoot":"","sources":["../../../../../../src/s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AAE,2BAA2B,EAC/C,KAAK,EAAE,OAAO,KACb,IAAI,CAAC;AAEV;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,2BAA2B,GAAG,CACtC,oBAAoB,EAAE,oBAAoB,EAC1C,kBAAkB,EAAE,2BAA2B,KAC9C,uBAAuB,GAAG,SAAS,CAAC;AAEzC;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAC1C,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,gBAAgB,EACzB,KAAK,CAAC,EAAE,sBAAsB,EAC9B,0BAA0B,CAAC,EAAE,2BAA2B,EACxD,YAAY,CAAC,EAAE,MAAM,GACtB,QAAQ,CAwCV"}
@@ -0,0 +1,151 @@
1
+ "use strict";
2
+ /**
3
+ * @file This file contains helper functions for generating page specific schemas that are used in the context of manifest properties.
4
+ * The functionality is implicitly tested by the more complex unit-tests for generic schema generation and generic import in test-folder unit/genericSchemaHandling.
5
+ */
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.DISALLOWED_WITHOUT_EXPLANATION = void 0;
11
+ exports.hasPropertyTypeError = hasPropertyTypeError;
12
+ exports.handleDisallowedProperty = handleDisallowedProperty;
13
+ exports.getSyncRuleForManifestProperty = getSyncRuleForManifestProperty;
14
+ const ux_specification_types_1 = require("@sap/ux-specification-types");
15
+ const extensionLogger_1 = require("../../../extensionLogger");
16
+ const i18next_1 = __importDefault(require("i18next"));
17
+ const utils_1 = require("../utils");
18
+ /**
19
+ * Type check for properties coming from the manifest.
20
+ *
21
+ * @param parent - the parent object in manifest which may contain the property.
22
+ * @param propertyName - name of the property name to be checked
23
+ * @param logger - a logger which may receive the error message in case a type error is detected
24
+ * @param expectedType - the expected type of the value of the property (if it is not undefined)
25
+ * @param mandatory - specifies handling of null and undefined: If parent is null this is always considered an error.
26
+ * undefined value for parent or its specified property is considered an error when parameter mandatory is true.
27
+ * null value for the specified property is considered an error when mandatory is true or the expected type is not 'object'.
28
+ * @returns the information whether a type error was detected.
29
+ */
30
+ function hasPropertyTypeError(parent, propertyName, logger, expectedType = 'string', mandatory = false) {
31
+ let hasTypeError;
32
+ if (parent === undefined) {
33
+ hasTypeError = mandatory;
34
+ }
35
+ else if (parent === null || typeof parent !== 'object') {
36
+ hasTypeError = true;
37
+ }
38
+ else {
39
+ const propValue = parent[propertyName];
40
+ if (propValue === undefined) {
41
+ hasTypeError = mandatory;
42
+ }
43
+ else {
44
+ hasTypeError = typeof propValue !== expectedType || (propValue === null && mandatory);
45
+ }
46
+ }
47
+ if (hasTypeError) {
48
+ (0, extensionLogger_1.log)(logger, {
49
+ severity: "error" /* LogSeverity.Error */,
50
+ message: i18next_1.default.t('TYPEERROR', { propertyName: propertyName, expectedType: expectedType })
51
+ });
52
+ }
53
+ return hasTypeError;
54
+ }
55
+ /**
56
+ * This symbol is used to indicate that a property is not allowed in the current context and that it should be hidden without any explanation.
57
+ */
58
+ exports.DISALLOWED_WITHOUT_EXPLANATION = Symbol('Property is suppressed without explanation');
59
+ /**
60
+ * Helper function to be called within elementAdapters of syncRules.
61
+ * The function should be called when a property defined in the generic schema is not valid
62
+ * for the page the specific schema is currently generated for.
63
+ * We distinguish two cases:
64
+ * - The property is present in the manifest (although it should not)
65
+ * - The property is not present in the manifest (as expected)
66
+ * In the first case the corresponding property should still be present in the schema.
67
+ * However, a warning message is added to the schema in order to make the user aware of this inconsistency.
68
+ * In the second case the property should not be shown to the user. So, preferably we would
69
+ * remove the property from the schema.
70
+ * However, this is currently not possible due to a flaw in the undo/redo logic which results in schemas
71
+ * being used to process the export that do not exactly fit to the current state of the config.
72
+ * For these cases we need the manifest path which is stored with the definition of the property in the schema.
73
+ * Therefore, we set the hidden flag of the property to true. This will be changed as soon as the undo/redo logic has been refactored.
74
+ *
75
+ * @param disallowedReason - The truthy description how the disallowed property should be handled
76
+ * @param element - the element in the schema representing the property
77
+ * @param value - the value of the property in the manifest
78
+ * @param manifestPath - the path to the property in the manifest
79
+ * @returns the ProcessingRule for element, resp. undefined if the element should not be removed from the page specific schema.
80
+ * Note that the second case will only occur after the refactoring of the undo/redo logic.
81
+ */
82
+ function handleDisallowedProperty(disallowedReason, element, value, manifestPath) {
83
+ delete element.$ref;
84
+ if (value === undefined || disallowedReason === exports.DISALLOWED_WITHOUT_EXPLANATION) {
85
+ element[ux_specification_types_1.SchemaTag.hidden] = true;
86
+ }
87
+ else {
88
+ if (typeof value === 'object') {
89
+ element.type = 'object';
90
+ }
91
+ element[ux_specification_types_1.SchemaTag.messages] = [
92
+ {
93
+ text: disallowedReason,
94
+ deletable: true,
95
+ type: ux_specification_types_1.PropertyMessageType.Warning
96
+ }
97
+ ];
98
+ }
99
+ return {
100
+ manifestPath
101
+ };
102
+ }
103
+ /**
104
+ * This function can be used to generate a SyncRule for a manifest property that may be omitted in the page specific schema
105
+ * depending on the context of the page.
106
+ *
107
+ * @param property - the name of the property in the manifest the SyncRule should be generated for
108
+ * @param analyze - provides the ManifestRule for the property
109
+ * @param adapt - an optional function that can be used to adapt the schema element representing the manifest property
110
+ * @param provideReferenceAdaptation - an optional function that can be used to provide the ReferenceAdaptationInfo for the manifest property
111
+ * @param expectedType - the expected type of the value of the property (if it is not undefined)
112
+ * @returns the SyncRule for the manifest property
113
+ */
114
+ function getSyncRuleForManifestProperty(property, analyze, adapt, provideReferenceAdaptation, expectedType) {
115
+ return {
116
+ manifest: {},
117
+ elementAdapter: function (element, schemaHandlingParams, generateParameters) {
118
+ const { manifestPath, disallowedReason } = analyze(element, schemaHandlingParams, generateParameters);
119
+ if (disallowedReason === exports.DISALLOWED_WITHOUT_EXPLANATION) {
120
+ return; // Suppress the property even if it is present in the current manifest -> no further processing needed
121
+ }
122
+ // What is the state of the property in the current manifest?
123
+ const { value, parent } = (0, utils_1.getManifestPropertyByPath)(generateParameters.manifest, manifestPath, property);
124
+ if (disallowedReason) {
125
+ return handleDisallowedProperty(disallowedReason, element, value, manifestPath);
126
+ }
127
+ // The property is applicable.
128
+ // But it can still be that its current content does not have the correct type.
129
+ // Type errors are logged. Note that the user can also see these errors.
130
+ const hasTypeErrors = expectedType
131
+ ? hasPropertyTypeError(parent, property, generateParameters.logger, expectedType)
132
+ : false;
133
+ if (hasTypeErrors && (expectedType === 'object' || typeof value === 'object')) {
134
+ // either value in manifest is an object but should be scalar or it is scalar but should be an object.
135
+ // This inconsistency must be removed in the text file of the manifest -> do not provide this property at all
136
+ return;
137
+ }
138
+ if (adapt) {
139
+ adapt(element, schemaHandlingParams, generateParameters, value);
140
+ }
141
+ const referenceAdaptation = provideReferenceAdaptation
142
+ ? provideReferenceAdaptation(schemaHandlingParams, generateParameters)
143
+ : undefined;
144
+ return {
145
+ manifestPath,
146
+ referenceAdaptation
147
+ };
148
+ }
149
+ };
150
+ }
151
+ //# sourceMappingURL=manifestPropertyUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifestPropertyUtils.js","sourceRoot":"","sources":["../../../../../../src/sync/v2/generate/manifestPropertyUtils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AA8BH,oDA2BC;AAwCD,4DAwBC;AA4ED,wEA8CC;AAxOD,wEAA0F;AAG1F,8DAA+C;AAC/C,sDAA8B;AAC9B,oCAAqD;AAErD;;;;;;;;;;;GAWG;AACH,SAAgB,oBAAoB,CAChC,MAAe,EACf,YAAoB,EACpB,MAAwB,EACxB,eAAuB,QAAQ,EAC/B,YAAqB,KAAK;IAE1B,IAAI,YAAqB,CAAC;IAC1B,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACvB,YAAY,GAAG,SAAS,CAAC;IAC7B,CAAC;SAAM,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QACvD,YAAY,GAAG,IAAI,CAAC;IACxB,CAAC;SAAM,CAAC;QACJ,MAAM,SAAS,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC;QACvC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CAAC;YAChB,OAAO;gBACH,YAAY;gBACZ,mBAAmB;aACtB,CAAC;QACN,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -1,8 +1,8 @@
1
1
  /**
2
- * This file provides a function that generically creates a page specific schema out of a generic schema for a page
2
+ * @file This file provides a function that generically creates a page specific schema out of a generic schema for a page
3
3
  * of a FE v2 app (function getAdaptedSchema).
4
4
  * In addition to that it exposes some generic helper functions that can be used to configure the generation process.
5
- * Unit tests for this class are located in test.unit.genericSchemaHandling.schemaAdaptation.test.ts
5
+ * Unit tests for this class are located in test.unit.genericSchemaHandling.schemaAdaptation.test.ts.
6
6
  */
7
7
  import type { Definition } from 'typescript-json-schema';
8
8
  import type { AccessorPath, ExtensionLogger, FileData, Manifest } from '@sap/ux-specification-types';