@siliconst/metaui 1.0.2 → 1.2.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.
Files changed (183) hide show
  1. package/README.md +134 -123
  2. package/package.json +3 -2
  3. package/src/nz/co/siliconst/ui5/metaui/.library +7 -7
  4. package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost-dbg.js +299 -163
  5. package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost-dbg.js.map +1 -1
  6. package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.d.ts +54 -6
  7. package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.d.ts.map +1 -1
  8. package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.js +1 -1
  9. package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.js.map +1 -1
  10. package/src/nz/co/siliconst/ui5/metaui/controls/GeneratorHost.ts +292 -162
  11. package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine-dbg.js +51 -43
  12. package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine-dbg.js.map +1 -1
  13. package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.d.ts +5 -0
  14. package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.d.ts.map +1 -1
  15. package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.js +1 -1
  16. package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.js.map +1 -1
  17. package/src/nz/co/siliconst/ui5/metaui/core/ConditionEngine.ts +49 -40
  18. package/src/nz/co/siliconst/ui5/metaui/core/Engine-dbg.js +81 -58
  19. package/src/nz/co/siliconst/ui5/metaui/core/Engine-dbg.js.map +1 -1
  20. package/src/nz/co/siliconst/ui5/metaui/core/Engine.d.ts +5 -12
  21. package/src/nz/co/siliconst/ui5/metaui/core/Engine.d.ts.map +1 -1
  22. package/src/nz/co/siliconst/ui5/metaui/core/Engine.js +1 -1
  23. package/src/nz/co/siliconst/ui5/metaui/core/Engine.js.map +1 -1
  24. package/src/nz/co/siliconst/ui5/metaui/core/Engine.ts +82 -56
  25. package/src/nz/co/siliconst/ui5/metaui/core/EventBus-dbg.js +65 -50
  26. package/src/nz/co/siliconst/ui5/metaui/core/EventBus-dbg.js.map +1 -1
  27. package/src/nz/co/siliconst/ui5/metaui/core/EventBus.d.ts +9 -0
  28. package/src/nz/co/siliconst/ui5/metaui/core/EventBus.d.ts.map +1 -1
  29. package/src/nz/co/siliconst/ui5/metaui/core/EventBus.js +1 -1
  30. package/src/nz/co/siliconst/ui5/metaui/core/EventBus.js.map +1 -1
  31. package/src/nz/co/siliconst/ui5/metaui/core/EventBus.ts +60 -45
  32. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry-dbg.js +72 -59
  33. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry-dbg.js.map +1 -1
  34. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.d.ts +6 -4
  35. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.d.ts.map +1 -1
  36. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.js +1 -1
  37. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.js.map +1 -1
  38. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.ts +71 -56
  39. package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer-dbg.js +145 -36
  40. package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer-dbg.js.map +1 -1
  41. package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.d.ts +13 -8
  42. package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.d.ts.map +1 -1
  43. package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.js +1 -1
  44. package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.js.map +1 -1
  45. package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.ts +157 -31
  46. package/src/nz/co/siliconst/ui5/metaui/core/StateManager-dbg.js +55 -55
  47. package/src/nz/co/siliconst/ui5/metaui/core/StateManager-dbg.js.map +1 -1
  48. package/src/nz/co/siliconst/ui5/metaui/core/StateManager.d.ts.map +1 -1
  49. package/src/nz/co/siliconst/ui5/metaui/core/StateManager.js.map +1 -1
  50. package/src/nz/co/siliconst/ui5/metaui/core/StateManager.ts +56 -56
  51. package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus-dbg.js +1 -1
  52. package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus-dbg.js.map +1 -1
  53. package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus.d.ts.map +1 -1
  54. package/src/nz/co/siliconst/ui5/metaui/interfaces/IEventBus.ts +29 -29
  55. package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager-dbg.js +1 -1
  56. package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager-dbg.js.map +1 -1
  57. package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager.d.ts +6 -12
  58. package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager.d.ts.map +1 -1
  59. package/src/nz/co/siliconst/ui5/metaui/interfaces/ILayoutManager.ts +21 -26
  60. package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin-dbg.js +1 -1
  61. package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin-dbg.js.map +1 -1
  62. package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin.d.ts +3 -20
  63. package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin.d.ts.map +1 -1
  64. package/src/nz/co/siliconst/ui5/metaui/interfaces/IPlugin.ts +14 -33
  65. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema-dbg.js +1 -1
  66. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema-dbg.js.map +1 -1
  67. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.d.ts +33 -43
  68. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.d.ts.map +1 -1
  69. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.ts +70 -70
  70. package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout-dbg.js +23 -38
  71. package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout-dbg.js.map +1 -1
  72. package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.d.ts +4 -17
  73. package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.d.ts.map +1 -1
  74. package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.js +1 -1
  75. package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.js.map +1 -1
  76. package/src/nz/co/siliconst/ui5/metaui/layouts/BaseLayout.ts +22 -34
  77. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout-dbg.js +98 -56
  78. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout-dbg.js.map +1 -1
  79. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.d.ts +7 -7
  80. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.d.ts.map +1 -1
  81. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.js +1 -1
  82. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.js.map +1 -1
  83. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.ts +97 -60
  84. package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout-dbg.js +102 -90
  85. package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout-dbg.js.map +1 -1
  86. package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.d.ts +4 -8
  87. package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.d.ts.map +1 -1
  88. package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.js +1 -1
  89. package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.js.map +1 -1
  90. package/src/nz/co/siliconst/ui5/metaui/layouts/TableLayout.ts +119 -102
  91. package/src/nz/co/siliconst/ui5/metaui/library-dbg.js +43 -32
  92. package/src/nz/co/siliconst/ui5/metaui/library-dbg.js.map +1 -1
  93. package/src/nz/co/siliconst/ui5/metaui/library-preload.js +22 -17
  94. package/src/nz/co/siliconst/ui5/metaui/library-preload.js.map +1 -1
  95. package/src/nz/co/siliconst/ui5/metaui/library.d.ts.map +1 -1
  96. package/src/nz/co/siliconst/ui5/metaui/library.js +1 -1
  97. package/src/nz/co/siliconst/ui5/metaui/library.js.map +1 -1
  98. package/src/nz/co/siliconst/ui5/metaui/library.ts +55 -43
  99. package/src/nz/co/siliconst/ui5/metaui/manifest.json +1 -0
  100. package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin-dbg.js +68 -0
  101. package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin-dbg.js.map +1 -0
  102. package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.d.ts +15 -0
  103. package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.d.ts.map +1 -0
  104. package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.js +2 -0
  105. package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.js.map +1 -0
  106. package/src/nz/co/siliconst/ui5/metaui/plugins/ArrayPlugin.ts +71 -0
  107. package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin-dbg.js +54 -59
  108. package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin-dbg.js.map +1 -1
  109. package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.d.ts +8 -27
  110. package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.d.ts.map +1 -1
  111. package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.js +1 -1
  112. package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.js.map +1 -1
  113. package/src/nz/co/siliconst/ui5/metaui/plugins/BasePlugin.ts +56 -58
  114. package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin-dbg.js +41 -42
  115. package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin-dbg.js.map +1 -1
  116. package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.d.ts +2 -2
  117. package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.d.ts.map +1 -1
  118. package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.js +1 -1
  119. package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.js.map +1 -1
  120. package/src/nz/co/siliconst/ui5/metaui/plugins/BooleanPlugin.ts +41 -42
  121. package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin-dbg.js +68 -60
  122. package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin-dbg.js.map +1 -1
  123. package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.d.ts +2 -2
  124. package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.d.ts.map +1 -1
  125. package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.js +1 -1
  126. package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.js.map +1 -1
  127. package/src/nz/co/siliconst/ui5/metaui/plugins/DatePlugin.ts +69 -63
  128. package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin-dbg.js +68 -0
  129. package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin-dbg.js.map +1 -0
  130. package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.d.ts +18 -0
  131. package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.d.ts.map +1 -0
  132. package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.js +2 -0
  133. package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.js.map +1 -0
  134. package/src/nz/co/siliconst/ui5/metaui/plugins/DateTimePlugin.ts +68 -0
  135. package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin-dbg.js +66 -66
  136. package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin-dbg.js.map +1 -1
  137. package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.d.ts +2 -2
  138. package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.d.ts.map +1 -1
  139. package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.js +1 -1
  140. package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.js.map +1 -1
  141. package/src/nz/co/siliconst/ui5/metaui/plugins/DropdownPlugin.ts +65 -65
  142. package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin-dbg.js +55 -53
  143. package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin-dbg.js.map +1 -1
  144. package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.d.ts +3 -3
  145. package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.d.ts.map +1 -1
  146. package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.js +1 -1
  147. package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.js.map +1 -1
  148. package/src/nz/co/siliconst/ui5/metaui/plugins/NumberPlugin.ts +56 -55
  149. package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin-dbg.js +56 -53
  150. package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin-dbg.js.map +1 -1
  151. package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.d.ts +2 -2
  152. package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.d.ts.map +1 -1
  153. package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.js +1 -1
  154. package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.js.map +1 -1
  155. package/src/nz/co/siliconst/ui5/metaui/plugins/StringPlugin.ts +58 -55
  156. package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin-dbg.js +43 -0
  157. package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin-dbg.js.map +1 -0
  158. package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.d.ts +18 -0
  159. package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.d.ts.map +1 -0
  160. package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.js +2 -0
  161. package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.js.map +1 -0
  162. package/src/nz/co/siliconst/ui5/metaui/plugins/SwitchPlugin.ts +42 -0
  163. package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin-dbg.js +58 -0
  164. package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin-dbg.js.map +1 -0
  165. package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.d.ts +18 -0
  166. package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.d.ts.map +1 -0
  167. package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.js +2 -0
  168. package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.js.map +1 -0
  169. package/src/nz/co/siliconst/ui5/metaui/plugins/TextAreaPlugin.ts +58 -0
  170. package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin-dbg.js +74 -0
  171. package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin-dbg.js.map +1 -0
  172. package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.d.ts +18 -0
  173. package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.d.ts.map +1 -0
  174. package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.js +2 -0
  175. package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.js.map +1 -0
  176. package/src/nz/co/siliconst/ui5/metaui/plugins/TimePlugin.ts +71 -0
  177. package/ui5.yaml +3 -3
  178. package/test-resources/App.js +0 -11
  179. package/test-resources/Main.controller.js +0 -73
  180. package/test-resources/Main.view.xml +0 -42
  181. package/test-resources/index.html +0 -21
  182. package/test-resources/mockData.json +0 -27
  183. package/test-resources/mockSchema.json +0 -98
@@ -1,37 +1,146 @@
1
- sap.ui.define([], function () {
2
- "use strict";
3
-
4
- /**
5
- * @file SchemaNormalizer.ts
6
- * @description Transforms and validates incoming JSON payloads into the strict ISchema matrix.
7
- */
8
-
9
- /**
10
- * Utility class ensuring data fidelity before layout construction begins.
11
- */
12
- class SchemaNormalizer {
13
- /**
14
- * Validates that the provided raw payload conforms to the required ISchema structures.
15
- * @param rawSchema The heterogeneous JSON object provided to the Engine.
16
- * @returns The strictly cast ISchema matrix.
17
- * @throws Error if the mandatory schema properties are missing.
18
- */
19
- static normalize(rawSchema) {
20
- if (!rawSchema || typeof rawSchema !== 'object') {
21
- throw new Error("[MetaUI] Invalid Schema Payload: Payload is not an object.");
22
- }
23
- if (!rawSchema.mode || !rawSchema.rootFields || !rawSchema.tables) {
24
- throw new Error("[MetaUI] Invalid Schema Payload: Missing required structures (mode, rootFields, tables).");
25
- }
26
-
27
- // Return the strongly typed and validated schema block.
28
- return rawSchema;
29
- }
30
- }
31
- var __exports = {
32
- __esModule: true
33
- };
34
- __exports.SchemaNormalizer = SchemaNormalizer;
35
- return __exports;
36
- });
1
+ sap.ui.define([], function () {
2
+ "use strict";
3
+
4
+ /**
5
+ * @file SchemaNormalizer.ts
6
+ * @description Transforms and validates incoming JSON payloads into the strict v2 ISchema dictionary matrix.
7
+ */
8
+
9
+ class SchemaNormalizer {
10
+ /**
11
+ * Validates that the provided raw payload conforms to the required ISchema structures.
12
+ */
13
+ static normalize(rawSchema, data) {
14
+ let schemaObj = rawSchema;
15
+ if (typeof schemaObj === "string") {
16
+ try {
17
+ schemaObj = JSON.parse(schemaObj);
18
+ } catch (e) {
19
+ console.warn("[MetaUI] Failed to parse schema string, falling back to inference.", e);
20
+ schemaObj = null;
21
+ }
22
+ }
23
+ if (!schemaObj || typeof schemaObj !== 'object' || Array.isArray(schemaObj)) {
24
+ return this.inferSchemaFromData(data);
25
+ }
26
+
27
+ // It is an object. Ensure it conforms to v2 structure.
28
+ const normalized = {
29
+ title: schemaObj.title || "MetaUI Generated Form",
30
+ type: schemaObj.type || (schemaObj.items ? "array" : "object")
31
+ };
32
+ if (normalized.type === "object") {
33
+ normalized.properties = this.normalizeProperties(schemaObj.properties || {});
34
+ } else if (normalized.type === "array") {
35
+ normalized.items = this.normalizePropertyMetadata(schemaObj.items || {
36
+ type: "object",
37
+ properties: {}
38
+ }, "items");
39
+ }
40
+ return normalized;
41
+ }
42
+ static normalizeProperties(properties) {
43
+ const normalizedProps = {};
44
+ for (const key of Object.keys(properties)) {
45
+ normalizedProps[key] = this.normalizePropertyMetadata(properties[key], key);
46
+ }
47
+ return normalizedProps;
48
+ }
49
+ static normalizePropertyMetadata(prop, keyName) {
50
+ const normalized = {
51
+ type: prop.type || "string",
52
+ ui: {
53
+ label: prop.ui?.label || this.generateLabel(keyName),
54
+ isKey: !!prop.ui?.isKey,
55
+ readOnly: !!prop.ui?.readOnly,
56
+ widget: prop.ui?.widget,
57
+ group: prop.ui?.group,
58
+ visibleOn: prop.ui?.visibleOn,
59
+ enabledOn: prop.ui?.enabledOn,
60
+ format: prop.ui?.format
61
+ },
62
+ required: !!prop.required,
63
+ maxLength: prop.maxLength,
64
+ minimum: prop.minimum,
65
+ maximum: prop.maximum,
66
+ pattern: prop.pattern,
67
+ precision: prop.precision,
68
+ scale: prop.scale,
69
+ valueHelp: prop.valueHelp
70
+ };
71
+ if (normalized.type === "object" && prop.properties) {
72
+ normalized.properties = this.normalizeProperties(prop.properties);
73
+ } else if (normalized.type === "array" && prop.items) {
74
+ normalized.items = this.normalizePropertyMetadata(prop.items, "items");
75
+ }
76
+ return normalized;
77
+ }
78
+
79
+ /**
80
+ * Generates a Title Case label from camelCase or snake_case technical names.
81
+ */
82
+ static generateLabel(name) {
83
+ if (!name) return "";
84
+ let spaced = name.replace(/([A-Z])/g, " $1").replace(/_/g, " ");
85
+ return spaced.split(' ').filter(w => w.length > 0).map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase()).join(' ').trim();
86
+ }
87
+
88
+ /**
89
+ * Infers a v2 ISchema structure dynamically from a plain data payload.
90
+ */
91
+ static inferSchemaFromData(data) {
92
+ const schema = {
93
+ type: "object",
94
+ properties: {}
95
+ };
96
+ if (!data || typeof data !== "object") {
97
+ return schema;
98
+ }
99
+ if (Array.isArray(data)) {
100
+ schema.type = "array";
101
+ schema.items = {
102
+ type: "object",
103
+ properties: data.length > 0 ? this.inferPropertiesFromObject(data[0]) : {}
104
+ };
105
+ } else {
106
+ schema.type = "object";
107
+ schema.properties = this.inferPropertiesFromObject(data);
108
+ }
109
+ return schema;
110
+ }
111
+ static inferPropertiesFromObject(obj) {
112
+ const properties = {};
113
+ if (!obj || typeof obj !== "object") return properties;
114
+ for (const key of Object.keys(obj)) {
115
+ const val = obj[key];
116
+ if (val === null || val === undefined) continue;
117
+ if (typeof val === "object" && !Array.isArray(val)) continue;
118
+ let type = "string";
119
+ let items;
120
+ if (typeof val === "number") type = "number";else if (typeof val === "boolean") type = "boolean";else if (Array.isArray(val)) {
121
+ type = "array";
122
+ items = {
123
+ type: "object",
124
+ properties: val.length > 0 ? this.inferPropertiesFromObject(val[0]) : {}
125
+ };
126
+ }
127
+ properties[key] = {
128
+ type,
129
+ items,
130
+ ui: {
131
+ label: this.generateLabel(key),
132
+ isKey: false,
133
+ readOnly: false
134
+ }
135
+ };
136
+ }
137
+ return properties;
138
+ }
139
+ }
140
+ var __exports = {
141
+ __esModule: true
142
+ };
143
+ __exports.SchemaNormalizer = SchemaNormalizer;
144
+ return __exports;
145
+ });
37
146
  //# sourceMappingURL=SchemaNormalizer-dbg.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaNormalizer-dbg.js","names":["SchemaNormalizer","normalize","rawSchema","Error","mode","rootFields","tables","__exports","__esModule"],"sources":["SchemaNormalizer.ts"],"sourcesContent":["/**\r\n * @file SchemaNormalizer.ts\r\n * @description Transforms and validates incoming JSON payloads into the strict ISchema matrix.\r\n */\r\n\r\nimport { ISchema } from \"../interfaces/ISchema\";\r\n\r\n/**\r\n * Utility class ensuring data fidelity before layout construction begins.\r\n */\r\nexport class SchemaNormalizer {\r\n \r\n /**\r\n * Validates that the provided raw payload conforms to the required ISchema structures.\r\n * @param rawSchema The heterogeneous JSON object provided to the Engine.\r\n * @returns The strictly cast ISchema matrix.\r\n * @throws Error if the mandatory schema properties are missing.\r\n */\r\n public static normalize(rawSchema: any): ISchema {\r\n if (!rawSchema || typeof rawSchema !== 'object') {\r\n throw new Error(\"[MetaUI] Invalid Schema Payload: Payload is not an object.\");\r\n }\r\n \r\n if (!rawSchema.mode || !rawSchema.rootFields || !rawSchema.tables) {\r\n throw new Error(\"[MetaUI] Invalid Schema Payload: Missing required structures (mode, rootFields, tables).\");\r\n }\r\n\r\n // Return the strongly typed and validated schema block.\r\n return rawSchema as ISchema;\r\n }\r\n}\r\n"],"mappings":";;;EAAA;AACA;AACA;AACA;;EAIA;AACA;AACA;EACO,MAAMA,gBAAgB,CAAC;IAE1B;AACJ;AACA;AACA;AACA;AACA;IACI,OAAcC,SAASA,CAACC,SAAc,EAAW;MAC7C,IAAI,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,EAAE;QAC7C,MAAM,IAAIC,KAAK,CAAC,4DAA4D,CAAC;MACjF;MAEA,IAAI,CAACD,SAAS,CAACE,IAAI,IAAI,CAACF,SAAS,CAACG,UAAU,IAAI,CAACH,SAAS,CAACI,MAAM,EAAE;QAC/D,MAAM,IAAIH,KAAK,CAAC,0FAA0F,CAAC;MAC/G;;MAEA;MACA,OAAOD,SAAS;IACpB;EACJ;EAAC,IAAAK,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAAP,gBAAA,GAAAA,gBAAA;EAAA,OAAAO,SAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"SchemaNormalizer-dbg.js","names":["SchemaNormalizer","normalize","rawSchema","data","schemaObj","JSON","parse","e","console","warn","Array","isArray","inferSchemaFromData","normalized","title","type","items","properties","normalizeProperties","normalizePropertyMetadata","normalizedProps","key","Object","keys","prop","keyName","ui","label","generateLabel","isKey","readOnly","widget","group","visibleOn","enabledOn","format","required","maxLength","minimum","maximum","pattern","precision","scale","valueHelp","name","spaced","replace","split","filter","w","length","map","word","charAt","toUpperCase","slice","toLowerCase","join","trim","schema","inferPropertiesFromObject","obj","val","undefined","__exports","__esModule"],"sources":["SchemaNormalizer.ts"],"sourcesContent":["/**\n * @file SchemaNormalizer.ts\n * @description Transforms and validates incoming JSON payloads into the strict v2 ISchema dictionary matrix.\n */\n\nimport { ISchema, IPropertyMetadata, FieldType } from \"../interfaces/ISchema\";\n\nexport class SchemaNormalizer {\n \n /**\n * Validates that the provided raw payload conforms to the required ISchema structures.\n */\n public static normalize(rawSchema?: any, data?: any): ISchema {\n let schemaObj = rawSchema;\n\n if (typeof schemaObj === \"string\") {\n try {\n schemaObj = JSON.parse(schemaObj);\n } catch (e) {\n console.warn(\"[MetaUI] Failed to parse schema string, falling back to inference.\", e);\n schemaObj = null;\n }\n }\n\n if (!schemaObj || typeof schemaObj !== 'object' || Array.isArray(schemaObj)) {\n return this.inferSchemaFromData(data);\n }\n\n // It is an object. Ensure it conforms to v2 structure.\n const normalized: ISchema = {\n title: schemaObj.title || \"MetaUI Generated Form\",\n type: schemaObj.type || (schemaObj.items ? \"array\" : \"object\"),\n };\n\n if (normalized.type === \"object\") {\n normalized.properties = this.normalizeProperties(schemaObj.properties || {});\n } else if (normalized.type === \"array\") {\n normalized.items = this.normalizePropertyMetadata(schemaObj.items || { type: \"object\", properties: {} }, \"items\");\n }\n\n return normalized;\n }\n\n private static normalizeProperties(properties: any): Record<string, IPropertyMetadata> {\n const normalizedProps: Record<string, IPropertyMetadata> = {};\n for (const key of Object.keys(properties)) {\n normalizedProps[key] = this.normalizePropertyMetadata(properties[key], key);\n }\n return normalizedProps;\n }\n\n private static normalizePropertyMetadata(prop: any, keyName: string): IPropertyMetadata {\n const normalized: IPropertyMetadata = {\n type: prop.type || \"string\",\n ui: {\n label: prop.ui?.label || this.generateLabel(keyName),\n isKey: !!prop.ui?.isKey,\n readOnly: !!prop.ui?.readOnly,\n widget: prop.ui?.widget,\n group: prop.ui?.group,\n visibleOn: prop.ui?.visibleOn,\n enabledOn: prop.ui?.enabledOn,\n format: prop.ui?.format\n },\n required: !!prop.required,\n maxLength: prop.maxLength,\n minimum: prop.minimum,\n maximum: prop.maximum,\n pattern: prop.pattern,\n precision: prop.precision,\n scale: prop.scale,\n valueHelp: prop.valueHelp\n };\n\n if (normalized.type === \"object\" && prop.properties) {\n normalized.properties = this.normalizeProperties(prop.properties);\n } else if (normalized.type === \"array\" && prop.items) {\n normalized.items = this.normalizePropertyMetadata(prop.items, \"items\");\n }\n\n return normalized;\n }\n\n /**\n * Generates a Title Case label from camelCase or snake_case technical names.\n */\n private static generateLabel(name: string): string {\n if (!name) return \"\";\n let spaced = name.replace(/([A-Z])/g, \" $1\").replace(/_/g, \" \");\n return spaced.split(' ')\n .filter(w => w.length > 0)\n .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(' ')\n .trim();\n }\n\n /**\n * Infers a v2 ISchema structure dynamically from a plain data payload.\n */\n private static inferSchemaFromData(data: any): ISchema {\n const schema: ISchema = { type: \"object\", properties: {} };\n \n if (!data || typeof data !== \"object\") {\n return schema;\n }\n\n if (Array.isArray(data)) {\n schema.type = \"array\";\n schema.items = {\n type: \"object\",\n properties: data.length > 0 ? this.inferPropertiesFromObject(data[0]) : {}\n };\n } else {\n schema.type = \"object\";\n schema.properties = this.inferPropertiesFromObject(data);\n }\n\n return schema;\n }\n\n private static inferPropertiesFromObject(obj: any): Record<string, IPropertyMetadata> {\n const properties: Record<string, IPropertyMetadata> = {};\n if (!obj || typeof obj !== \"object\") return properties;\n\n for (const key of Object.keys(obj)) {\n const val = obj[key];\n if (val === null || val === undefined) continue;\n \n if (typeof val === \"object\" && !Array.isArray(val)) continue;\n\n let type: FieldType = \"string\";\n let items: IPropertyMetadata | undefined;\n\n if (typeof val === \"number\") type = \"number\";\n else if (typeof val === \"boolean\") type = \"boolean\";\n else if (Array.isArray(val)) {\n type = \"array\";\n items = {\n type: \"object\",\n properties: val.length > 0 ? this.inferPropertiesFromObject(val[0]) : {}\n };\n }\n \n properties[key] = {\n type,\n items,\n ui: {\n label: this.generateLabel(key),\n isKey: false,\n readOnly: false\n }\n };\n }\n\n return properties;\n }\n}\n"],"mappings":";;;EAAA;AACA;AACA;AACA;;EAIO,MAAMA,gBAAgB,CAAC;IAE1B;AACJ;AACA;IACI,OAAcC,SAASA,CAACC,SAAe,EAAEC,IAAU,EAAW;MAC1D,IAAIC,SAAS,GAAGF,SAAS;MAEzB,IAAI,OAAOE,SAAS,KAAK,QAAQ,EAAE;QAC/B,IAAI;UACAA,SAAS,GAAGC,IAAI,CAACC,KAAK,CAACF,SAAS,CAAC;QACrC,CAAC,CAAC,OAAOG,CAAC,EAAE;UACRC,OAAO,CAACC,IAAI,CAAC,oEAAoE,EAAEF,CAAC,CAAC;UACrFH,SAAS,GAAG,IAAI;QACpB;MACJ;MAEA,IAAI,CAACA,SAAS,IAAI,OAAOA,SAAS,KAAK,QAAQ,IAAIM,KAAK,CAACC,OAAO,CAACP,SAAS,CAAC,EAAE;QACzE,OAAO,IAAI,CAACQ,mBAAmB,CAACT,IAAI,CAAC;MACzC;;MAEA;MACA,MAAMU,UAAmB,GAAG;QACxBC,KAAK,EAAEV,SAAS,CAACU,KAAK,IAAI,uBAAuB;QACjDC,IAAI,EAAEX,SAAS,CAACW,IAAI,KAAKX,SAAS,CAACY,KAAK,GAAG,OAAO,GAAG,QAAQ;MACjE,CAAC;MAED,IAAIH,UAAU,CAACE,IAAI,KAAK,QAAQ,EAAE;QAC9BF,UAAU,CAACI,UAAU,GAAG,IAAI,CAACC,mBAAmB,CAACd,SAAS,CAACa,UAAU,IAAI,CAAC,CAAC,CAAC;MAChF,CAAC,MAAM,IAAIJ,UAAU,CAACE,IAAI,KAAK,OAAO,EAAE;QACpCF,UAAU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C,GAAG,KAAK,SAAS,EAAE/C,IAAI,GAAG,SAAS,CAAC,KAC/C,IAAIL,KAAK,CAACC,OAAO,CAACmD,GAAG,CAAC,EAAE;UACzB/C,IAAI,GAAG,OAAO;UACdC,KAAK,GAAG;YACJD,IAAI,EAAE,QAAQ;YACdE,UAAU,EAAE6C,GAAG,CAACZ,MAAM,GAAG,CAAC,GAAG,IAAI,CAACU,yBAAyB,CAACE,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;UAC3E,CAAC;QACL;QAEA7C,UAAU,CAACI,GAAG,CAAC,GAAG;UACdN,IAAI;UACJC,KAAK;UACLU,EAAE,EAAE;YACAC,KAAK,EAAE,IAAI,CAACC,aAAa,CAACP,GAAG,CAAC;YAC9BQ,KAAK,EAAE,KAAK;YACZC,QAAQ,EAAE;UACd;QACJ,CAAC;MACL;MAEA,OAAOb,UAAU;IACrB;EACJ;EAAC,IAAA+C,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAAhE,gBAAA,GAAAA,gBAAA;EAAA,OAAAgE,SAAA;AAAA","ignoreList":[]}
@@ -1,20 +1,25 @@
1
1
  declare module "nz/co/siliconst/ui5/metaui/core/SchemaNormalizer" {
2
2
  /**
3
3
  * @file SchemaNormalizer.ts
4
- * @description Transforms and validates incoming JSON payloads into the strict ISchema matrix.
4
+ * @description Transforms and validates incoming JSON payloads into the strict v2 ISchema dictionary matrix.
5
5
  */
6
6
  import { ISchema } from "nz/co/siliconst/ui5/metaui/interfaces/ISchema";
7
- /**
8
- * Utility class ensuring data fidelity before layout construction begins.
9
- */
10
7
  export class SchemaNormalizer {
11
8
  /**
12
9
  * Validates that the provided raw payload conforms to the required ISchema structures.
13
- * @param rawSchema The heterogeneous JSON object provided to the Engine.
14
- * @returns The strictly cast ISchema matrix.
15
- * @throws Error if the mandatory schema properties are missing.
16
10
  */
17
- static normalize(rawSchema: any): ISchema;
11
+ static normalize(rawSchema?: any, data?: any): ISchema;
12
+ private static normalizeProperties;
13
+ private static normalizePropertyMetadata;
14
+ /**
15
+ * Generates a Title Case label from camelCase or snake_case technical names.
16
+ */
17
+ private static generateLabel;
18
+ /**
19
+ * Infers a v2 ISchema structure dynamically from a plain data payload.
20
+ */
21
+ private static inferSchemaFromData;
22
+ private static inferPropertiesFromObject;
18
23
  }
19
24
  }
20
25
  //# sourceMappingURL=SchemaNormalizer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaNormalizer.d.ts","sourceRoot":"..\\..\\..\\..\\..\\..\\..\\..","sources":["src\\nz\\co\\siliconst\\ui5\\metaui\\core\\SchemaNormalizer.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,kDAAkD,CAAC;IAClE;;;OAGG;IAEH,OAAO,EAAE,OAAO,EAAE,MAAM,+CAA+C,CAAC;IAExE;;OAEG;IACH,MAAa,gBAAgB;QAEzB;;;;;WAKG;eACW,SAAS,CAAC,SAAS,EAAE,GAAG,GAAG,OAAO;KAYnD;CAEA"}
1
+ {"version":3,"file":"SchemaNormalizer.d.ts","sourceRoot":"../../../../../../../..","sources":["src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,kDAAkD,CAAC;IAClE;;;OAGG;IAEH,OAAO,EAAE,OAAO,EAAgC,MAAM,+CAA+C,CAAC;IAEtG,MAAa,gBAAgB;QAEzB;;WAEG;eACW,SAAS,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,OAAO;QA+B7D,OAAO,CAAC,MAAM,CAAC,mBAAmB;QAQlC,OAAO,CAAC,MAAM,CAAC,yBAAyB;QAgCxC;;WAEG;QACH,OAAO,CAAC,MAAM,CAAC,aAAa;QAU5B;;WAEG;QACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;QAqBlC,OAAO,CAAC,MAAM,CAAC,yBAAyB;KAoC3C;CAEA"}
@@ -1,2 +1,2 @@
1
- sap.ui.define([],function(){"use strict";class e{static normalize(e){if(!e||typeof e!=="object"){throw new Error("[MetaUI] Invalid Schema Payload: Payload is not an object.")}if(!e.mode||!e.rootFields||!e.tables){throw new Error("[MetaUI] Invalid Schema Payload: Missing required structures (mode, rootFields, tables).")}return e}}var r={__esModule:true};r.SchemaNormalizer=e;return r});
1
+ sap.ui.define([],function(){"use strict";class e{static normalize(e,t){let r=e;if(typeof r==="string"){try{r=JSON.parse(r)}catch(e){console.warn("[MetaUI] Failed to parse schema string, falling back to inference.",e);r=null}}if(!r||typeof r!=="object"||Array.isArray(r)){return this.inferSchemaFromData(t)}const i={title:r.title||"MetaUI Generated Form",type:r.type||(r.items?"array":"object")};if(i.type==="object"){i.properties=this.normalizeProperties(r.properties||{})}else if(i.type==="array"){i.items=this.normalizePropertyMetadata(r.items||{type:"object",properties:{}},"items")}return i}static normalizeProperties(e){const t={};for(const r of Object.keys(e)){t[r]=this.normalizePropertyMetadata(e[r],r)}return t}static normalizePropertyMetadata(e,t){const r={type:e.type||"string",ui:{label:e.ui?.label||this.generateLabel(t),isKey:!!e.ui?.isKey,readOnly:!!e.ui?.readOnly,widget:e.ui?.widget,group:e.ui?.group,visibleOn:e.ui?.visibleOn,enabledOn:e.ui?.enabledOn,format:e.ui?.format},required:!!e.required,maxLength:e.maxLength,minimum:e.minimum,maximum:e.maximum,pattern:e.pattern,precision:e.precision,scale:e.scale,valueHelp:e.valueHelp};if(r.type==="object"&&e.properties){r.properties=this.normalizeProperties(e.properties)}else if(r.type==="array"&&e.items){r.items=this.normalizePropertyMetadata(e.items,"items")}return r}static generateLabel(e){if(!e)return"";let t=e.replace(/([A-Z])/g," $1").replace(/_/g," ");return t.split(" ").filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ").trim()}static inferSchemaFromData(e){const t={type:"object",properties:{}};if(!e||typeof e!=="object"){return t}if(Array.isArray(e)){t.type="array";t.items={type:"object",properties:e.length>0?this.inferPropertiesFromObject(e[0]):{}}}else{t.type="object";t.properties=this.inferPropertiesFromObject(e)}return t}static inferPropertiesFromObject(e){const t={};if(!e||typeof e!=="object")return t;for(const r of Object.keys(e)){const i=e[r];if(i===null||i===undefined)continue;if(typeof i==="object"&&!Array.isArray(i))continue;let a="string";let s;if(typeof i==="number")a="number";else if(typeof i==="boolean")a="boolean";else if(Array.isArray(i)){a="array";s={type:"object",properties:i.length>0?this.inferPropertiesFromObject(i[0]):{}}}t[r]={type:a,items:s,ui:{label:this.generateLabel(r),isKey:false,readOnly:false}}}return t}}var t={__esModule:true};t.SchemaNormalizer=e;return t});
2
2
  //# sourceMappingURL=SchemaNormalizer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SchemaNormalizer.js","names":["SchemaNormalizer","normalize","rawSchema","Error","mode","rootFields","tables","__exports","__esModule"],"sources":["SchemaNormalizer.ts"],"sourcesContent":["/**\r\n * @file SchemaNormalizer.ts\r\n * @description Transforms and validates incoming JSON payloads into the strict ISchema matrix.\r\n */\r\n\r\nimport { ISchema } from \"../interfaces/ISchema\";\r\n\r\n/**\r\n * Utility class ensuring data fidelity before layout construction begins.\r\n */\r\nexport class SchemaNormalizer {\r\n \r\n /**\r\n * Validates that the provided raw payload conforms to the required ISchema structures.\r\n * @param rawSchema The heterogeneous JSON object provided to the Engine.\r\n * @returns The strictly cast ISchema matrix.\r\n * @throws Error if the mandatory schema properties are missing.\r\n */\r\n public static normalize(rawSchema: any): ISchema {\r\n if (!rawSchema || typeof rawSchema !== 'object') {\r\n throw new Error(\"[MetaUI] Invalid Schema Payload: Payload is not an object.\");\r\n }\r\n \r\n if (!rawSchema.mode || !rawSchema.rootFields || !rawSchema.tables) {\r\n throw new Error(\"[MetaUI] Invalid Schema Payload: Missing required structures (mode, rootFields, tables).\");\r\n }\r\n\r\n // Return the strongly typed and validated schema block.\r\n return rawSchema as ISchema;\r\n }\r\n}\r\n"],"mappings":"yCAUO,MAAMA,EAQT,gBAAcC,CAAUC,GACpB,IAAKA,UAAoBA,IAAc,SAAU,CAC7C,MAAM,IAAIC,MAAM,6DACpB,CAEA,IAAKD,EAAUE,OAASF,EAAUG,aAAeH,EAAUI,OAAQ,CAC/D,MAAM,IAAIH,MAAM,2FACpB,CAGA,OAAOD,CACX,EACH,IAAAK,EAAA,CAAAC,WAAA,MAAAD,EAAAP,mBAAA,OAAAO,CAAA","ignoreList":[]}
1
+ {"version":3,"file":"SchemaNormalizer.js","names":["SchemaNormalizer","normalize","rawSchema","data","schemaObj","JSON","parse","e","console","warn","Array","isArray","this","inferSchemaFromData","normalized","title","type","items","properties","normalizeProperties","normalizePropertyMetadata","normalizedProps","key","Object","keys","prop","keyName","ui","label","generateLabel","isKey","readOnly","widget","group","visibleOn","enabledOn","format","required","maxLength","minimum","maximum","pattern","precision","scale","valueHelp","name","spaced","replace","split","filter","w","length","map","word","charAt","toUpperCase","slice","toLowerCase","join","trim","schema","inferPropertiesFromObject","obj","val","undefined","__exports","__esModule"],"sources":["SchemaNormalizer.ts"],"sourcesContent":["/**\n * @file SchemaNormalizer.ts\n * @description Transforms and validates incoming JSON payloads into the strict v2 ISchema dictionary matrix.\n */\n\nimport { ISchema, IPropertyMetadata, FieldType } from \"../interfaces/ISchema\";\n\nexport class SchemaNormalizer {\n \n /**\n * Validates that the provided raw payload conforms to the required ISchema structures.\n */\n public static normalize(rawSchema?: any, data?: any): ISchema {\n let schemaObj = rawSchema;\n\n if (typeof schemaObj === \"string\") {\n try {\n schemaObj = JSON.parse(schemaObj);\n } catch (e) {\n console.warn(\"[MetaUI] Failed to parse schema string, falling back to inference.\", e);\n schemaObj = null;\n }\n }\n\n if (!schemaObj || typeof schemaObj !== 'object' || Array.isArray(schemaObj)) {\n return this.inferSchemaFromData(data);\n }\n\n // It is an object. Ensure it conforms to v2 structure.\n const normalized: ISchema = {\n title: schemaObj.title || \"MetaUI Generated Form\",\n type: schemaObj.type || (schemaObj.items ? \"array\" : \"object\"),\n };\n\n if (normalized.type === \"object\") {\n normalized.properties = this.normalizeProperties(schemaObj.properties || {});\n } else if (normalized.type === \"array\") {\n normalized.items = this.normalizePropertyMetadata(schemaObj.items || { type: \"object\", properties: {} }, \"items\");\n }\n\n return normalized;\n }\n\n private static normalizeProperties(properties: any): Record<string, IPropertyMetadata> {\n const normalizedProps: Record<string, IPropertyMetadata> = {};\n for (const key of Object.keys(properties)) {\n normalizedProps[key] = this.normalizePropertyMetadata(properties[key], key);\n }\n return normalizedProps;\n }\n\n private static normalizePropertyMetadata(prop: any, keyName: string): IPropertyMetadata {\n const normalized: IPropertyMetadata = {\n type: prop.type || \"string\",\n ui: {\n label: prop.ui?.label || this.generateLabel(keyName),\n isKey: !!prop.ui?.isKey,\n readOnly: !!prop.ui?.readOnly,\n widget: prop.ui?.widget,\n group: prop.ui?.group,\n visibleOn: prop.ui?.visibleOn,\n enabledOn: prop.ui?.enabledOn,\n format: prop.ui?.format\n },\n required: !!prop.required,\n maxLength: prop.maxLength,\n minimum: prop.minimum,\n maximum: prop.maximum,\n pattern: prop.pattern,\n precision: prop.precision,\n scale: prop.scale,\n valueHelp: prop.valueHelp\n };\n\n if (normalized.type === \"object\" && prop.properties) {\n normalized.properties = this.normalizeProperties(prop.properties);\n } else if (normalized.type === \"array\" && prop.items) {\n normalized.items = this.normalizePropertyMetadata(prop.items, \"items\");\n }\n\n return normalized;\n }\n\n /**\n * Generates a Title Case label from camelCase or snake_case technical names.\n */\n private static generateLabel(name: string): string {\n if (!name) return \"\";\n let spaced = name.replace(/([A-Z])/g, \" $1\").replace(/_/g, \" \");\n return spaced.split(' ')\n .filter(w => w.length > 0)\n .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())\n .join(' ')\n .trim();\n }\n\n /**\n * Infers a v2 ISchema structure dynamically from a plain data payload.\n */\n private static inferSchemaFromData(data: any): ISchema {\n const schema: ISchema = { type: \"object\", properties: {} };\n \n if (!data || typeof data !== \"object\") {\n return schema;\n }\n\n if (Array.isArray(data)) {\n schema.type = \"array\";\n schema.items = {\n type: \"object\",\n properties: data.length > 0 ? this.inferPropertiesFromObject(data[0]) : {}\n };\n } else {\n schema.type = \"object\";\n schema.properties = this.inferPropertiesFromObject(data);\n }\n\n return schema;\n }\n\n private static inferPropertiesFromObject(obj: any): Record<string, IPropertyMetadata> {\n const properties: Record<string, IPropertyMetadata> = {};\n if (!obj || typeof obj !== \"object\") return properties;\n\n for (const key of Object.keys(obj)) {\n const val = obj[key];\n if (val === null || val === undefined) continue;\n \n if (typeof val === \"object\" && !Array.isArray(val)) continue;\n\n let type: FieldType = \"string\";\n let items: IPropertyMetadata | undefined;\n\n if (typeof val === \"number\") type = \"number\";\n else if (typeof val === \"boolean\") type = \"boolean\";\n else if (Array.isArray(val)) {\n type = \"array\";\n items = {\n type: \"object\",\n properties: val.length > 0 ? this.inferPropertiesFromObject(val[0]) : {}\n };\n }\n \n properties[key] = {\n type,\n items,\n ui: {\n label: this.generateLabel(key),\n isKey: false,\n readOnly: false\n }\n };\n }\n\n return properties;\n }\n}\n"],"mappings":"yCAOO,MAAMA,EAKT,gBAAcC,CAAUC,EAAiBC,GACrC,IAAIC,EAAYF,EAEhB,UAAWE,IAAc,SAAU,CAC/B,IACIA,EAAYC,KAAKC,MAAMF,EAC3B,CAAE,MAAOG,GACLC,QAAQC,KAAK,qEAAsEF,GACnFH,EAAY,IAChB,CACJ,CAEA,IAAKA,UAAoBA,IAAc,UAAYM,MAAMC,QAAQP,GAAY,CACzE,OAAOQ,KAAKC,oBAAoBV,EACpC,CAGA,MAAMW,EAAsB,CACxBC,MAAOX,EAAUW,OAAS,wBAC1BC,KAAMZ,EAAUY,OAASZ,EAAUa,MAAQ,QAAU,WAGzD,GAAIH,EAAWE,OAAS,SAAU,CAC9BF,EAAWI,WAAaN,KAAKO,oBAAoBf,EAAUc,YAAc,CAAC,EAC9E,MAAO,GAAIJ,EAAWE,OAAS,QAAS,CACpCF,EAAWG,MAAQL,KAAKQ,0BAA0BhB,EAAUa,OAAS,CAAED,KAAM,SAAUE,WAAY,CAAC,GAAK,QAC7G,CA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,GAC/B,MAAMyD,EAAkB,CAAE5C,KAAM,SAAUE,WAAY,CAAC,GAEvD,IAAKf,UAAeA,IAAS,SAAU,CACnC,OAAOyD,CACX,CAEA,GAAIlD,MAAMC,QAAQR,GAAO,CACrByD,EAAO5C,KAAO,QACd4C,EAAO3C,MAAQ,CACXD,KAAM,SACNE,WAAYf,EAAKgD,OAAS,EAAIvC,KAAKiD,0BAA0B1D,EAAK,IAAM,CAAC,EAEjF,KAAO,CACHyD,EAAO5C,KAAO,SACd4C,EAAO1C,WAAaN,KAAKiD,0BAA0B1D,EACvD,CAEA,OAAOyD,CACX,CAEA,gCAAeC,CAA0BC,GACrC,MAAM5C,EAAgD,CAAC,EACvD,IAAK4C,UAAcA,IAAQ,SAAU,OAAO5C,EAE5C,IAAK,MAAMI,KAAOC,OAAOC,KAAKsC,GAAM,CAChC,MAAMC,EAAMD,EAAIxC,GAChB,GAAIyC,IAAQ,MAAQA,IAAQC,UAAW,SAEvC,UAAWD,IAAQ,WAAarD,MAAMC,QAAQoD,GAAM,SAEpD,IAAI/C,EAAkB,SACtB,IAAIC,EAEJ,UAAW8C,IAAQ,SAAU/C,EAAO,cAC/B,UAAW+C,IAAQ,UAAW/C,EAAO,eACrC,GAAIN,MAAMC,QAAQoD,GAAM,CACzB/C,EAAO,QACPC,EAAQ,CACJD,KAAM,SACNE,WAAY6C,EAAIZ,OAAS,EAAIvC,KAAKiD,0BAA0BE,EAAI,IAAM,CAAC,EAE/E,CAEA7C,EAAWI,GAAO,CACdN,OACAC,QACAU,GAAI,CACAC,MAAOhB,KAAKiB,cAAcP,GAC1BQ,MAAO,MACPC,SAAU,OAGtB,CAEA,OAAOb,CACX,EACH,IAAA+C,EAAA,CAAAC,WAAA,MAAAD,EAAAjE,mBAAA,OAAAiE,CAAA","ignoreList":[]}
@@ -1,31 +1,157 @@
1
- /**
2
- * @file SchemaNormalizer.ts
3
- * @description Transforms and validates incoming JSON payloads into the strict ISchema matrix.
4
- */
5
-
6
- import { ISchema } from "../interfaces/ISchema";
7
-
8
- /**
9
- * Utility class ensuring data fidelity before layout construction begins.
10
- */
11
- export class SchemaNormalizer {
12
-
13
- /**
14
- * Validates that the provided raw payload conforms to the required ISchema structures.
15
- * @param rawSchema The heterogeneous JSON object provided to the Engine.
16
- * @returns The strictly cast ISchema matrix.
17
- * @throws Error if the mandatory schema properties are missing.
18
- */
19
- public static normalize(rawSchema: any): ISchema {
20
- if (!rawSchema || typeof rawSchema !== 'object') {
21
- throw new Error("[MetaUI] Invalid Schema Payload: Payload is not an object.");
22
- }
23
-
24
- if (!rawSchema.mode || !rawSchema.rootFields || !rawSchema.tables) {
25
- throw new Error("[MetaUI] Invalid Schema Payload: Missing required structures (mode, rootFields, tables).");
26
- }
27
-
28
- // Return the strongly typed and validated schema block.
29
- return rawSchema as ISchema;
30
- }
31
- }
1
+ /**
2
+ * @file SchemaNormalizer.ts
3
+ * @description Transforms and validates incoming JSON payloads into the strict v2 ISchema dictionary matrix.
4
+ */
5
+
6
+ import { ISchema, IPropertyMetadata, FieldType } from "../interfaces/ISchema";
7
+
8
+ export class SchemaNormalizer {
9
+
10
+ /**
11
+ * Validates that the provided raw payload conforms to the required ISchema structures.
12
+ */
13
+ public static normalize(rawSchema?: any, data?: any): ISchema {
14
+ let schemaObj = rawSchema;
15
+
16
+ if (typeof schemaObj === "string") {
17
+ try {
18
+ schemaObj = JSON.parse(schemaObj);
19
+ } catch (e) {
20
+ console.warn("[MetaUI] Failed to parse schema string, falling back to inference.", e);
21
+ schemaObj = null;
22
+ }
23
+ }
24
+
25
+ if (!schemaObj || typeof schemaObj !== 'object' || Array.isArray(schemaObj)) {
26
+ return this.inferSchemaFromData(data);
27
+ }
28
+
29
+ // It is an object. Ensure it conforms to v2 structure.
30
+ const normalized: ISchema = {
31
+ title: schemaObj.title || "MetaUI Generated Form",
32
+ type: schemaObj.type || (schemaObj.items ? "array" : "object"),
33
+ };
34
+
35
+ if (normalized.type === "object") {
36
+ normalized.properties = this.normalizeProperties(schemaObj.properties || {});
37
+ } else if (normalized.type === "array") {
38
+ normalized.items = this.normalizePropertyMetadata(schemaObj.items || { type: "object", properties: {} }, "items");
39
+ }
40
+
41
+ return normalized;
42
+ }
43
+
44
+ private static normalizeProperties(properties: any): Record<string, IPropertyMetadata> {
45
+ const normalizedProps: Record<string, IPropertyMetadata> = {};
46
+ for (const key of Object.keys(properties)) {
47
+ normalizedProps[key] = this.normalizePropertyMetadata(properties[key], key);
48
+ }
49
+ return normalizedProps;
50
+ }
51
+
52
+ private static normalizePropertyMetadata(prop: any, keyName: string): IPropertyMetadata {
53
+ const normalized: IPropertyMetadata = {
54
+ type: prop.type || "string",
55
+ ui: {
56
+ label: prop.ui?.label || this.generateLabel(keyName),
57
+ isKey: !!prop.ui?.isKey,
58
+ readOnly: !!prop.ui?.readOnly,
59
+ widget: prop.ui?.widget,
60
+ group: prop.ui?.group,
61
+ visibleOn: prop.ui?.visibleOn,
62
+ enabledOn: prop.ui?.enabledOn,
63
+ format: prop.ui?.format
64
+ },
65
+ required: !!prop.required,
66
+ maxLength: prop.maxLength,
67
+ minimum: prop.minimum,
68
+ maximum: prop.maximum,
69
+ pattern: prop.pattern,
70
+ precision: prop.precision,
71
+ scale: prop.scale,
72
+ valueHelp: prop.valueHelp
73
+ };
74
+
75
+ if (normalized.type === "object" && prop.properties) {
76
+ normalized.properties = this.normalizeProperties(prop.properties);
77
+ } else if (normalized.type === "array" && prop.items) {
78
+ normalized.items = this.normalizePropertyMetadata(prop.items, "items");
79
+ }
80
+
81
+ return normalized;
82
+ }
83
+
84
+ /**
85
+ * Generates a Title Case label from camelCase or snake_case technical names.
86
+ */
87
+ private static generateLabel(name: string): string {
88
+ if (!name) return "";
89
+ let spaced = name.replace(/([A-Z])/g, " $1").replace(/_/g, " ");
90
+ return spaced.split(' ')
91
+ .filter(w => w.length > 0)
92
+ .map(word => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
93
+ .join(' ')
94
+ .trim();
95
+ }
96
+
97
+ /**
98
+ * Infers a v2 ISchema structure dynamically from a plain data payload.
99
+ */
100
+ private static inferSchemaFromData(data: any): ISchema {
101
+ const schema: ISchema = { type: "object", properties: {} };
102
+
103
+ if (!data || typeof data !== "object") {
104
+ return schema;
105
+ }
106
+
107
+ if (Array.isArray(data)) {
108
+ schema.type = "array";
109
+ schema.items = {
110
+ type: "object",
111
+ properties: data.length > 0 ? this.inferPropertiesFromObject(data[0]) : {}
112
+ };
113
+ } else {
114
+ schema.type = "object";
115
+ schema.properties = this.inferPropertiesFromObject(data);
116
+ }
117
+
118
+ return schema;
119
+ }
120
+
121
+ private static inferPropertiesFromObject(obj: any): Record<string, IPropertyMetadata> {
122
+ const properties: Record<string, IPropertyMetadata> = {};
123
+ if (!obj || typeof obj !== "object") return properties;
124
+
125
+ for (const key of Object.keys(obj)) {
126
+ const val = obj[key];
127
+ if (val === null || val === undefined) continue;
128
+
129
+ if (typeof val === "object" && !Array.isArray(val)) continue;
130
+
131
+ let type: FieldType = "string";
132
+ let items: IPropertyMetadata | undefined;
133
+
134
+ if (typeof val === "number") type = "number";
135
+ else if (typeof val === "boolean") type = "boolean";
136
+ else if (Array.isArray(val)) {
137
+ type = "array";
138
+ items = {
139
+ type: "object",
140
+ properties: val.length > 0 ? this.inferPropertiesFromObject(val[0]) : {}
141
+ };
142
+ }
143
+
144
+ properties[key] = {
145
+ type,
146
+ items,
147
+ ui: {
148
+ label: this.generateLabel(key),
149
+ isKey: false,
150
+ readOnly: false
151
+ }
152
+ };
153
+ }
154
+
155
+ return properties;
156
+ }
157
+ }
@@ -1,56 +1,56 @@
1
- sap.ui.define(["sap/ui/model/json/JSONModel"], function (JSONModel) {
2
- "use strict";
3
-
4
- /**
5
- * Manages the isolated internal data payload for the MetaUI engine.
6
- */
7
- class StateManager {
8
- /**
9
- * Initializes the state manager with an optional initial payload.
10
- * @param initialData The initial JSON payload to populate the fields.
11
- */
12
- constructor(initialData = {}) {
13
- // Deep copy to ensure no reference leakage from the host application
14
- const safeData = JSON.parse(JSON.stringify(initialData));
15
- this.model = new JSONModel(safeData);
16
- this.model.setDefaultBindingMode("TwoWay");
17
- }
18
-
19
- /**
20
- * Retrieves the isolated JSONModel instance to attach to the root GeneratorHost control.
21
- * @returns The internal JSONModel.
22
- */
23
- getModel() {
24
- return this.model;
25
- }
26
-
27
- /**
28
- * Binds a generated UI control property to a path in the internal model.
29
- * @param control The target UI5 Control.
30
- * @param property The UI5 property name (e.g., 'value').
31
- * @param bindingPath The exact path in the JSON payload.
32
- */
33
- bindControl(control, property, bindingPath) {
34
- control.bindProperty(property, {
35
- path: bindingPath,
36
- model: "meta" // Assumes the model is bound to the root container with the name 'meta'
37
- });
38
- }
39
-
40
- /**
41
- * Extracts the flat JavaScript object representing the current state of the UI.
42
- * @returns A serialized record of the data payload, free of UI5 wrappers.
43
- */
44
- extractPayload() {
45
- // Create a deep copy to prevent accidental mutations by the host
46
- const data = this.model.getData();
47
- return JSON.parse(JSON.stringify(data));
48
- }
49
- }
50
- var __exports = {
51
- __esModule: true
52
- };
53
- __exports.StateManager = StateManager;
54
- return __exports;
55
- });
1
+ sap.ui.define(["sap/ui/model/json/JSONModel"], function (JSONModel) {
2
+ "use strict";
3
+
4
+ /**
5
+ * Manages the isolated internal data payload for the MetaUI engine.
6
+ */
7
+ class StateManager {
8
+ /**
9
+ * Initializes the state manager with an optional initial payload.
10
+ * @param initialData The initial JSON payload to populate the fields.
11
+ */
12
+ constructor(initialData = {}) {
13
+ // Deep copy to ensure no reference leakage from the host application
14
+ const safeData = JSON.parse(JSON.stringify(initialData));
15
+ this.model = new JSONModel(safeData);
16
+ this.model.setDefaultBindingMode("TwoWay");
17
+ }
18
+
19
+ /**
20
+ * Retrieves the isolated JSONModel instance to attach to the root GeneratorHost control.
21
+ * @returns The internal JSONModel.
22
+ */
23
+ getModel() {
24
+ return this.model;
25
+ }
26
+
27
+ /**
28
+ * Binds a generated UI control property to a path in the internal model.
29
+ * @param control The target UI5 Control.
30
+ * @param property The UI5 property name (e.g., 'value').
31
+ * @param bindingPath The exact path in the JSON payload.
32
+ */
33
+ bindControl(control, property, bindingPath) {
34
+ control.bindProperty(property, {
35
+ path: bindingPath,
36
+ model: "meta" // Assumes the model is bound to the root container with the name 'meta'
37
+ });
38
+ }
39
+
40
+ /**
41
+ * Extracts the flat JavaScript object representing the current state of the UI.
42
+ * @returns A serialized record of the data payload, free of UI5 wrappers.
43
+ */
44
+ extractPayload() {
45
+ // Create a deep copy to prevent accidental mutations by the host
46
+ const data = this.model.getData();
47
+ return JSON.parse(JSON.stringify(data));
48
+ }
49
+ }
50
+ var __exports = {
51
+ __esModule: true
52
+ };
53
+ __exports.StateManager = StateManager;
54
+ return __exports;
55
+ });
56
56
  //# sourceMappingURL=StateManager-dbg.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StateManager-dbg.js","names":["StateManager","constructor","initialData","safeData","JSON","parse","stringify","model","JSONModel","setDefaultBindingMode","getModel","bindControl","control","property","bindingPath","bindProperty","path","extractPayload","data","getData","__exports","__esModule"],"sources":["StateManager.ts"],"sourcesContent":["/**\r\n * @file StateManager.ts\r\n * @description Isolated internal state management. Decouples the MetaUI engine from external host models.\r\n */\r\n\r\nimport JSONModel from \"sap/ui/model/json/JSONModel\";\r\nimport ManagedObject from \"sap/ui/base/ManagedObject\";\r\n\r\n/**\r\n * Manages the isolated internal data payload for the MetaUI engine.\r\n */\r\nexport class StateManager {\r\n private model: JSONModel;\r\n\r\n /**\r\n * Initializes the state manager with an optional initial payload.\r\n * @param initialData The initial JSON payload to populate the fields.\r\n */\r\n constructor(initialData: Record<string, any> = {}) {\r\n // Deep copy to ensure no reference leakage from the host application\r\n const safeData = JSON.parse(JSON.stringify(initialData));\r\n this.model = new JSONModel(safeData);\r\n this.model.setDefaultBindingMode(\"TwoWay\");\r\n }\r\n\r\n /**\r\n * Retrieves the isolated JSONModel instance to attach to the root GeneratorHost control.\r\n * @returns The internal JSONModel.\r\n */\r\n public getModel(): JSONModel {\r\n return this.model;\r\n }\r\n\r\n /**\r\n * Binds a generated UI control property to a path in the internal model.\r\n * @param control The target UI5 Control.\r\n * @param property The UI5 property name (e.g., 'value').\r\n * @param bindingPath The exact path in the JSON payload.\r\n */\r\n public bindControl(control: ManagedObject, property: string, bindingPath: string): void {\r\n control.bindProperty(property, {\r\n path: bindingPath,\r\n model: \"meta\" // Assumes the model is bound to the root container with the name 'meta'\r\n });\r\n }\r\n\r\n /**\r\n * Extracts the flat JavaScript object representing the current state of the UI.\r\n * @returns A serialized record of the data payload, free of UI5 wrappers.\r\n */\r\n public extractPayload(): Record<string, any> {\r\n // Create a deep copy to prevent accidental mutations by the host\r\n const data = this.model.getData();\r\n return JSON.parse(JSON.stringify(data));\r\n }\r\n}\r\n"],"mappings":";;;EAQA;AACA;AACA;EACO,MAAMA,YAAY,CAAC;IAGtB;AACJ;AACA;AACA;IACIC,WAAWA,CAACC,WAAgC,GAAG,CAAC,CAAC,EAAE;MAC/C;MACA,MAAMC,QAAQ,GAAGC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,SAAS,CAACJ,WAAW,CAAC,CAAC;MACxD,IAAI,CAACK,KAAK,GAAG,IAAIC,SAAS,CAACL,QAAQ,CAAC;MACpC,IAAI,CAACI,KAAK,CAACE,qBAAqB,CAAC,QAAQ,CAAC;IAC9C;;IAEA;AACJ;AACA;AACA;IACWC,QAAQA,CAAA,EAAc;MACzB,OAAO,IAAI,CAACH,KAAK;IACrB;;IAEA;AACJ;AACA;AACA;AACA;AACA;IACWI,WAAWA,CAACC,OAAsB,EAAEC,QAAgB,EAAEC,WAAmB,EAAQ;MACpFF,OAAO,CAACG,YAAY,CAACF,QAAQ,EAAE;QAC3BG,IAAI,EAAEF,WAAW;QACjBP,KAAK,EAAE,MAAM,CAAC;MAClB,CAAC,CAAC;IACN;;IAEA;AACJ;AACA;AACA;IACWU,cAAcA,CAAA,EAAwB;MACzC;MACA,MAAMC,IAAI,GAAG,IAAI,CAACX,KAAK,CAACY,OAAO,CAAC,CAAC;MACjC,OAAOf,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,SAAS,CAACY,IAAI,CAAC,CAAC;IAC3C;EACJ;EAAC,IAAAE,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAApB,YAAA,GAAAA,YAAA;EAAA,OAAAoB,SAAA;AAAA","ignoreList":[]}
1
+ {"version":3,"file":"StateManager-dbg.js","names":["StateManager","constructor","initialData","safeData","JSON","parse","stringify","model","JSONModel","setDefaultBindingMode","getModel","bindControl","control","property","bindingPath","bindProperty","path","extractPayload","data","getData","__exports","__esModule"],"sources":["StateManager.ts"],"sourcesContent":["/**\n * @file StateManager.ts\n * @description Isolated internal state management. Decouples the MetaUI engine from external host models.\n */\n\nimport JSONModel from \"sap/ui/model/json/JSONModel\";\nimport ManagedObject from \"sap/ui/base/ManagedObject\";\n\n/**\n * Manages the isolated internal data payload for the MetaUI engine.\n */\nexport class StateManager {\n private model: JSONModel;\n\n /**\n * Initializes the state manager with an optional initial payload.\n * @param initialData The initial JSON payload to populate the fields.\n */\n constructor(initialData: Record<string, any> = {}) {\n // Deep copy to ensure no reference leakage from the host application\n const safeData = JSON.parse(JSON.stringify(initialData));\n this.model = new JSONModel(safeData);\n this.model.setDefaultBindingMode(\"TwoWay\");\n }\n\n /**\n * Retrieves the isolated JSONModel instance to attach to the root GeneratorHost control.\n * @returns The internal JSONModel.\n */\n public getModel(): JSONModel {\n return this.model;\n }\n\n /**\n * Binds a generated UI control property to a path in the internal model.\n * @param control The target UI5 Control.\n * @param property The UI5 property name (e.g., 'value').\n * @param bindingPath The exact path in the JSON payload.\n */\n public bindControl(control: ManagedObject, property: string, bindingPath: string): void {\n control.bindProperty(property, {\n path: bindingPath,\n model: \"meta\" // Assumes the model is bound to the root container with the name 'meta'\n });\n }\n\n /**\n * Extracts the flat JavaScript object representing the current state of the UI.\n * @returns A serialized record of the data payload, free of UI5 wrappers.\n */\n public extractPayload(): Record<string, any> {\n // Create a deep copy to prevent accidental mutations by the host\n const data = this.model.getData();\n return JSON.parse(JSON.stringify(data));\n }\n}\n"],"mappings":";;;EAQA;AACA;AACA;EACO,MAAMA,YAAY,CAAC;IAGtB;AACJ;AACA;AACA;IACIC,WAAWA,CAACC,WAAgC,GAAG,CAAC,CAAC,EAAE;MAC/C;MACA,MAAMC,QAAQ,GAAGC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,SAAS,CAACJ,WAAW,CAAC,CAAC;MACxD,IAAI,CAACK,KAAK,GAAG,IAAIC,SAAS,CAACL,QAAQ,CAAC;MACpC,IAAI,CAACI,KAAK,CAACE,qBAAqB,CAAC,QAAQ,CAAC;IAC9C;;IAEA;AACJ;AACA;AACA;IACWC,QAAQA,CAAA,EAAc;MACzB,OAAO,IAAI,CAACH,KAAK;IACrB;;IAEA;AACJ;AACA;AACA;AACA;AACA;IACWI,WAAWA,CAACC,OAAsB,EAAEC,QAAgB,EAAEC,WAAmB,EAAQ;MACpFF,OAAO,CAACG,YAAY,CAACF,QAAQ,EAAE;QAC3BG,IAAI,EAAEF,WAAW;QACjBP,KAAK,EAAE,MAAM,CAAC;MAClB,CAAC,CAAC;IACN;;IAEA;AACJ;AACA;AACA;IACWU,cAAcA,CAAA,EAAwB;MACzC;MACA,MAAMC,IAAI,GAAG,IAAI,CAACX,KAAK,CAACY,OAAO,CAAC,CAAC;MACjC,OAAOf,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,SAAS,CAACY,IAAI,CAAC,CAAC;IAC3C;EACJ;EAAC,IAAAE,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAApB,YAAA,GAAAA,YAAA;EAAA,OAAAoB,SAAA;AAAA","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"StateManager.d.ts","sourceRoot":"..\\..\\..\\..\\..\\..\\..\\..","sources":["src\\nz\\co\\siliconst\\ui5\\metaui\\core\\StateManager.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,8CAA8C,CAAC;IAC9D;;;OAGG;IAEH,OAAO,SAAS,MAAM,6BAA6B,CAAC;IACpD,OAAO,aAAa,MAAM,2BAA2B,CAAC;IAEtD;;OAEG;IACH,MAAa,YAAY;QACrB,OAAO,CAAC,KAAK,CAAY;QAEzB;;;WAGG;oBACS,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;QAOjD;;;WAGG;QACI,QAAQ,IAAI,SAAS;QAI5B;;;;;WAKG;QACI,WAAW,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;QAOvF;;;WAGG;QACI,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;KAK/C;CAEA"}
1
+ {"version":3,"file":"StateManager.d.ts","sourceRoot":"../../../../../../../..","sources":["src/nz/co/siliconst/ui5/metaui/core/StateManager.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,8CAA8C,CAAC;IAC9D;;;OAGG;IAEH,OAAO,SAAS,MAAM,6BAA6B,CAAC;IACpD,OAAO,aAAa,MAAM,2BAA2B,CAAC;IAEtD;;OAEG;IACH,MAAa,YAAY;QACrB,OAAO,CAAC,KAAK,CAAY;QAEzB;;;WAGG;oBACS,WAAW,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;QAOjD;;;WAGG;QACI,QAAQ,IAAI,SAAS;QAI5B;;;;;WAKG;QACI,WAAW,CAAC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;QAOvF;;;WAGG;QACI,cAAc,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;KAK/C;CAEA"}