@siliconst/metaui 1.4.13 → 1.4.17

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 (184) hide show
  1. package/package.json +1 -1
  2. package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost-dbg.js +50 -3
  3. package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost-dbg.js.map +1 -1
  4. package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost.d.ts +1 -1
  5. package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost.d.ts.map +1 -1
  6. package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost.js +1 -1
  7. package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost.js.map +1 -1
  8. package/src/nz/co/siliconst/ui5/metaui/controls/DynamicHost.ts +57 -4
  9. package/src/nz/co/siliconst/ui5/metaui/controls/host/GeneratorHost-dbg.js +44 -2
  10. package/src/nz/co/siliconst/ui5/metaui/controls/host/GeneratorHost-dbg.js.map +1 -1
  11. package/src/nz/co/siliconst/ui5/metaui/controls/host/GeneratorHost.d.ts +4 -0
  12. package/src/nz/co/siliconst/ui5/metaui/controls/host/GeneratorHost.d.ts.map +1 -1
  13. package/src/nz/co/siliconst/ui5/metaui/controls/host/GeneratorHost.js +1 -1
  14. package/src/nz/co/siliconst/ui5/metaui/controls/host/GeneratorHost.js.map +1 -1
  15. package/src/nz/co/siliconst/ui5/metaui/controls/host/GeneratorHost.ts +51 -4
  16. package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/DialogDelegate-dbg.js +42 -5
  17. package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/DialogDelegate-dbg.js.map +1 -1
  18. package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/DialogDelegate.d.ts +9 -2
  19. package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/DialogDelegate.d.ts.map +1 -1
  20. package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/DialogDelegate.js +1 -1
  21. package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/DialogDelegate.js.map +1 -1
  22. package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/DialogDelegate.ts +44 -5
  23. package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ValidationDelegate-dbg.js.map +1 -1
  24. package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ValidationDelegate.js.map +1 -1
  25. package/src/nz/co/siliconst/ui5/metaui/controls/host/delegates/ValidationDelegate.ts +2 -2
  26. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry-dbg.js +1 -0
  27. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry-dbg.js.map +1 -1
  28. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.d.ts.map +1 -1
  29. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.js +1 -1
  30. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.js.map +1 -1
  31. package/src/nz/co/siliconst/ui5/metaui/core/PluginRegistry.ts +1 -0
  32. package/src/nz/co/siliconst/ui5/metaui/core/SchemaBuilderRegistry-dbg.js +47 -0
  33. package/src/nz/co/siliconst/ui5/metaui/core/SchemaBuilderRegistry-dbg.js.map +1 -0
  34. package/src/nz/co/siliconst/ui5/metaui/core/SchemaBuilderRegistry.d.ts +23 -0
  35. package/src/nz/co/siliconst/ui5/metaui/core/SchemaBuilderRegistry.d.ts.map +1 -0
  36. package/src/nz/co/siliconst/ui5/metaui/core/SchemaBuilderRegistry.js +2 -0
  37. package/src/nz/co/siliconst/ui5/metaui/core/SchemaBuilderRegistry.js.map +1 -0
  38. package/src/nz/co/siliconst/ui5/metaui/core/SchemaBuilderRegistry.ts +45 -0
  39. package/src/nz/co/siliconst/ui5/metaui/core/SchemaNormalizer-dbg.js +17 -0
  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 +10 -1
  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 +19 -1
  46. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema-dbg.js.map +1 -1
  47. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.d.ts +7 -0
  48. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.d.ts.map +1 -1
  49. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchema.ts +9 -0
  50. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchemaBuilderPlugin-dbg.js +2 -0
  51. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchemaBuilderPlugin-dbg.js.map +1 -0
  52. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchemaBuilderPlugin.d.ts +23 -0
  53. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchemaBuilderPlugin.d.ts.map +1 -0
  54. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchemaBuilderPlugin.js +2 -0
  55. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchemaBuilderPlugin.js.map +1 -0
  56. package/src/nz/co/siliconst/ui5/metaui/interfaces/ISchemaBuilderPlugin.ts +23 -0
  57. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout-dbg.js +6 -1
  58. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout-dbg.js.map +1 -1
  59. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.d.ts.map +1 -1
  60. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.js +1 -1
  61. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.js.map +1 -1
  62. package/src/nz/co/siliconst/ui5/metaui/layouts/FormLayout.ts +6 -1
  63. package/src/nz/co/siliconst/ui5/metaui/library-preload.js +29 -20
  64. package/src/nz/co/siliconst/ui5/metaui/library-preload.js.map +1 -1
  65. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/BasePlugin-dbg.js +3 -20
  66. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/BasePlugin-dbg.js.map +1 -1
  67. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/BasePlugin.d.ts.map +1 -1
  68. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/BasePlugin.js +1 -1
  69. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/BasePlugin.js.map +1 -1
  70. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/BasePlugin.ts +3 -3
  71. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/BooleanPlugin-dbg.js +1 -0
  72. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/BooleanPlugin-dbg.js.map +1 -1
  73. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/BooleanPlugin.d.ts.map +1 -1
  74. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/BooleanPlugin.js +1 -1
  75. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/BooleanPlugin.js.map +1 -1
  76. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/BooleanPlugin.ts +1 -0
  77. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DatePlugin-dbg.js +1 -0
  78. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DatePlugin-dbg.js.map +1 -1
  79. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DatePlugin.d.ts.map +1 -1
  80. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DatePlugin.js +1 -1
  81. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DatePlugin.js.map +1 -1
  82. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DatePlugin.ts +1 -0
  83. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DateTimePlugin-dbg.js +1 -0
  84. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DateTimePlugin-dbg.js.map +1 -1
  85. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DateTimePlugin.d.ts.map +1 -1
  86. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DateTimePlugin.js +1 -1
  87. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DateTimePlugin.js.map +1 -1
  88. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DateTimePlugin.ts +1 -0
  89. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DropdownPlugin-dbg.js +1 -0
  90. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DropdownPlugin-dbg.js.map +1 -1
  91. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DropdownPlugin.d.ts.map +1 -1
  92. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DropdownPlugin.js +1 -1
  93. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DropdownPlugin.js.map +1 -1
  94. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/DropdownPlugin.ts +1 -0
  95. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/FileUploaderPlugin-dbg.js +1 -0
  96. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/FileUploaderPlugin-dbg.js.map +1 -1
  97. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/FileUploaderPlugin.d.ts.map +1 -1
  98. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/FileUploaderPlugin.js +1 -1
  99. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/FileUploaderPlugin.js.map +1 -1
  100. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/FileUploaderPlugin.ts +1 -0
  101. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MessageStripPlugin-dbg.js +1 -0
  102. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MessageStripPlugin-dbg.js.map +1 -1
  103. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MessageStripPlugin.d.ts.map +1 -1
  104. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MessageStripPlugin.js +1 -1
  105. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MessageStripPlugin.js.map +1 -1
  106. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MessageStripPlugin.ts +1 -0
  107. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MultiInputPlugin-dbg.js +30 -17
  108. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MultiInputPlugin-dbg.js.map +1 -1
  109. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MultiInputPlugin.d.ts.map +1 -1
  110. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MultiInputPlugin.js +1 -1
  111. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MultiInputPlugin.js.map +1 -1
  112. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MultiInputPlugin.ts +33 -15
  113. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MultiSelectPlugin-dbg.js +1 -0
  114. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MultiSelectPlugin-dbg.js.map +1 -1
  115. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MultiSelectPlugin.d.ts.map +1 -1
  116. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MultiSelectPlugin.js +1 -1
  117. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MultiSelectPlugin.js.map +1 -1
  118. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/MultiSelectPlugin.ts +1 -0
  119. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/NumberPlugin-dbg.js +35 -11
  120. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/NumberPlugin-dbg.js.map +1 -1
  121. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/NumberPlugin.d.ts +4 -4
  122. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/NumberPlugin.d.ts.map +1 -1
  123. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/NumberPlugin.js +1 -1
  124. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/NumberPlugin.js.map +1 -1
  125. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/NumberPlugin.ts +38 -14
  126. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/RatingIndicatorPlugin-dbg.js +1 -0
  127. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/RatingIndicatorPlugin-dbg.js.map +1 -1
  128. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/RatingIndicatorPlugin.d.ts.map +1 -1
  129. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/RatingIndicatorPlugin.js +1 -1
  130. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/RatingIndicatorPlugin.js.map +1 -1
  131. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/RatingIndicatorPlugin.ts +1 -0
  132. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/SliderPlugin-dbg.js +1 -0
  133. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/SliderPlugin-dbg.js.map +1 -1
  134. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/SliderPlugin.d.ts.map +1 -1
  135. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/SliderPlugin.js +1 -1
  136. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/SliderPlugin.js.map +1 -1
  137. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/SliderPlugin.ts +1 -0
  138. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/StepInputPlugin-dbg.js +79 -0
  139. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/StepInputPlugin-dbg.js.map +1 -0
  140. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/StepInputPlugin.d.ts +35 -0
  141. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/StepInputPlugin.d.ts.map +1 -0
  142. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/StepInputPlugin.js +2 -0
  143. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/StepInputPlugin.js.map +1 -0
  144. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/StepInputPlugin.ts +80 -0
  145. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/SwitchPlugin-dbg.js +1 -0
  146. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/SwitchPlugin-dbg.js.map +1 -1
  147. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/SwitchPlugin.d.ts.map +1 -1
  148. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/SwitchPlugin.js +1 -1
  149. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/SwitchPlugin.js.map +1 -1
  150. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/SwitchPlugin.ts +1 -0
  151. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/TimePlugin-dbg.js +1 -0
  152. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/TimePlugin-dbg.js.map +1 -1
  153. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/TimePlugin.d.ts.map +1 -1
  154. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/TimePlugin.js +1 -1
  155. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/TimePlugin.js.map +1 -1
  156. package/src/nz/co/siliconst/ui5/metaui/plugins/controls/TimePlugin.ts +1 -0
  157. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerBuilder-dbg.js +226 -0
  158. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerBuilder-dbg.js.map +1 -0
  159. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerBuilder.d.ts +63 -0
  160. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerBuilder.d.ts.map +1 -0
  161. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerBuilder.js +2 -0
  162. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerBuilder.js.map +1 -0
  163. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerBuilder.ts +233 -0
  164. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerRefResolver-dbg.js +43 -0
  165. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerRefResolver-dbg.js.map +1 -0
  166. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerRefResolver.d.ts +15 -0
  167. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerRefResolver.d.ts.map +1 -0
  168. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerRefResolver.js +2 -0
  169. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerRefResolver.js.map +1 -0
  170. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerRefResolver.ts +37 -0
  171. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerTypeMapper-dbg.js +37 -0
  172. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerTypeMapper-dbg.js.map +1 -0
  173. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerTypeMapper.d.ts +18 -0
  174. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerTypeMapper.d.ts.map +1 -0
  175. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerTypeMapper.js +2 -0
  176. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerTypeMapper.js.map +1 -0
  177. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerTypeMapper.ts +28 -0
  178. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerUIMapper-dbg.js +84 -0
  179. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerUIMapper-dbg.js.map +1 -0
  180. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerUIMapper.d.ts +27 -0
  181. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerUIMapper.d.ts.map +1 -0
  182. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerUIMapper.js +2 -0
  183. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerUIMapper.js.map +1 -0
  184. package/src/nz/co/siliconst/ui5/metaui/swagger/SwaggerUIMapper.ts +80 -0
@@ -0,0 +1,226 @@
1
+ sap.ui.define(["../utils/Logger", "./SwaggerTypeMapper", "./SwaggerUIMapper", "./SwaggerRefResolver"], function (___utils_Logger, ___SwaggerTypeMapper, ___SwaggerUIMapper, ___SwaggerRefResolver) {
2
+ "use strict";
3
+
4
+ /**
5
+ * @file SwaggerBuilder.ts
6
+ * @description Facade orchestration for translating Swagger/OpenAPI JSON into native MetaUI ISchema.
7
+ * Strict Single Responsibility architecture delegates mapping logic to dedicated utilities.
8
+ */
9
+ const Logger = ___utils_Logger["Logger"];
10
+ const SwaggerTypeMapper = ___SwaggerTypeMapper["SwaggerTypeMapper"];
11
+ const SwaggerUIMapper = ___SwaggerUIMapper["SwaggerUIMapper"];
12
+ const SwaggerRefResolver = ___SwaggerRefResolver["SwaggerRefResolver"];
13
+ class SwaggerBuilder {
14
+ /**
15
+ * Determines if the provided JSON payload is a Swagger or OpenAPI document.
16
+ *
17
+ * @param {any} rawSchema The raw JSON schema to test.
18
+ * @returns {boolean} True if the document contains 'openapi' or 'swagger' root keys.
19
+ */
20
+ canHandle(rawSchema) {
21
+ return !!(rawSchema && (rawSchema.openapi || rawSchema.swagger));
22
+ }
23
+
24
+ /**
25
+ * Builds a strict MetaUI ISchema from the provided OpenAPI payload.
26
+ *
27
+ * @param {any} rawSchema The OpenAPI root document.
28
+ * @returns {ISchema} The translated MetaUI schema.
29
+ */
30
+ build(rawSchema) {
31
+ return SwaggerBuilder.build(rawSchema);
32
+ }
33
+
34
+ /**
35
+ * Asynchronously fetches a remote OpenAPI document and compiles it into a MetaUI ISchema.
36
+ *
37
+ * @param {string} url The URL to fetch the JSON payload from.
38
+ * @param {string} [targetDefinition] Optional. The specific entity schema to extract.
39
+ * @returns {Promise<ISchema>} A Promise resolving to the compiled ISchema.
40
+ */
41
+ static async fetchAndBuild(url, targetDefinition) {
42
+ try {
43
+ const response = await fetch(url);
44
+ if (!response.ok) {
45
+ throw new Error(`HTTP error! status: ${response.status}`);
46
+ }
47
+ const swaggerRoot = await response.json();
48
+ return this.build(swaggerRoot, targetDefinition);
49
+ } catch (error) {
50
+ const msg = "Failed to fetch Swagger JSON from URL: " + error.message;
51
+ Logger.error("[MetaUI SwaggerBuilder]", msg);
52
+ throw new Error(msg);
53
+ }
54
+ }
55
+
56
+ /**
57
+ * Synchronously builds a MetaUI ISchema from a provided OpenAPI root document.
58
+ * Automatically extracts the requested definition from `components.schemas` or falls back to the first available.
59
+ *
60
+ * @param {any} swaggerRoot The OpenAPI root document.
61
+ * @param {string} [targetDefinition] Optional. The specific entity schema to extract.
62
+ * @returns {ISchema} The translated MetaUI schema.
63
+ */
64
+ static build(swaggerRoot, targetDefinition) {
65
+ if (!swaggerRoot || typeof swaggerRoot !== "object") {
66
+ throw new Error("[MetaUI SwaggerBuilder] Invalid Swagger root object provided.");
67
+ }
68
+ let targetObject = swaggerRoot;
69
+ if (!targetDefinition) {
70
+ if (swaggerRoot.components && swaggerRoot.components.schemas) {
71
+ const keys = Object.keys(swaggerRoot.components.schemas);
72
+ if (keys.length > 0) targetDefinition = keys[0];
73
+ } else if (swaggerRoot.definitions) {
74
+ const keys = Object.keys(swaggerRoot.definitions);
75
+ if (keys.length > 0) targetDefinition = keys[0];
76
+ }
77
+ }
78
+ if (targetDefinition) {
79
+ let found = false;
80
+ if (swaggerRoot.components && swaggerRoot.components.schemas && swaggerRoot.components.schemas[targetDefinition]) {
81
+ targetObject = swaggerRoot.components.schemas[targetDefinition];
82
+ found = true;
83
+ } else if (swaggerRoot.definitions && swaggerRoot.definitions[targetDefinition]) {
84
+ targetObject = swaggerRoot.definitions[targetDefinition];
85
+ found = true;
86
+ }
87
+ if (!found) {
88
+ throw new Error(`[MetaUI SwaggerBuilder] Could not find target definition '${targetDefinition}' in components/schemas or definitions.`);
89
+ }
90
+ }
91
+ const schema = {
92
+ title: targetObject.title || swaggerRoot.info?.title || targetDefinition,
93
+ type: targetObject.type === "array" ? "array" : "object",
94
+ layoutStrategy: targetObject.type === "array" ? "table" : "form"
95
+ };
96
+ if (targetObject.additionalProperties === true) {
97
+ schema.additionalProperties = true;
98
+ }
99
+ if (schema.type === "object") {
100
+ const requiredKeys = Array.isArray(targetObject.required) ? targetObject.required : [];
101
+ schema.properties = this.mapProperties(targetObject.properties || {}, requiredKeys, swaggerRoot);
102
+ } else if (schema.type === "array" && targetObject.items) {
103
+ schema.items = this.mapPropertyMetadata(targetObject.items, "items", false, swaggerRoot);
104
+ }
105
+ return schema;
106
+ }
107
+
108
+ /**
109
+ * Recursively traverses and translates an OpenAPI properties block into MetaUI IPropertyMetadata.
110
+ *
111
+ * @param {Record<string, any>} properties The OpenAPI properties object.
112
+ * @param {string[]} requiredKeys An array of keys marked as required in the parent schema.
113
+ * @param {any} swaggerRoot The root document (used for $ref resolution).
114
+ * @returns {Record<string, IPropertyMetadata>} The mapped MetaUI properties object.
115
+ */
116
+ static mapProperties(properties, requiredKeys, swaggerRoot) {
117
+ const normalizedProps = {};
118
+ for (const key of Object.keys(properties)) {
119
+ const isRequired = requiredKeys.includes(key);
120
+ let propDef = properties[key];
121
+ if (propDef.$ref) {
122
+ const resolved = SwaggerRefResolver.resolve(propDef.$ref, swaggerRoot);
123
+ if (resolved) {
124
+ propDef = {
125
+ ...resolved,
126
+ ...propDef
127
+ };
128
+ }
129
+ }
130
+ normalizedProps[key] = this.mapPropertyMetadata(propDef, key, isRequired, swaggerRoot);
131
+ }
132
+ return normalizedProps;
133
+ }
134
+
135
+ /**
136
+ * Translates a single OpenAPI property schema into a MetaUI IPropertyMetadata block.
137
+ * Handles local $ref resolution, allOf merging, type mapping, and UI directive injection.
138
+ *
139
+ * @param {any} swaggerProp The OpenAPI property definition.
140
+ * @param {string} keyName The technical key of the property.
141
+ * @param {boolean} isRequired Whether this property is strictly required.
142
+ * @param {any} swaggerRoot The root document (used for $ref resolution).
143
+ * @returns {IPropertyMetadata} The compiled MetaUI property metadata.
144
+ */
145
+ static mapPropertyMetadata(swaggerProp, keyName, isRequired, swaggerRoot) {
146
+ let currentProp = swaggerProp;
147
+ if (currentProp.$ref) {
148
+ const resolved = SwaggerRefResolver.resolve(currentProp.$ref, swaggerRoot);
149
+ if (resolved) {
150
+ currentProp = {
151
+ ...resolved,
152
+ ...currentProp
153
+ };
154
+ }
155
+ }
156
+ if (Array.isArray(currentProp.allOf)) {
157
+ let merged = {
158
+ ...currentProp
159
+ };
160
+ delete merged.allOf;
161
+ for (const subSchema of currentProp.allOf) {
162
+ let resolvedSub = subSchema;
163
+ if (subSchema.$ref) {
164
+ resolvedSub = SwaggerRefResolver.resolve(subSchema.$ref, swaggerRoot) || {};
165
+ }
166
+ merged = {
167
+ ...merged,
168
+ ...resolvedSub
169
+ };
170
+ }
171
+ currentProp = merged;
172
+ }
173
+ const type = SwaggerTypeMapper.mapType(currentProp.type);
174
+ const metaProp = {
175
+ type: type,
176
+ required: isRequired
177
+ };
178
+ const uiDirective = SwaggerUIMapper.build(currentProp, keyName);
179
+ if (Object.keys(uiDirective).length > 0) {
180
+ metaProp.ui = uiDirective;
181
+ }
182
+ if (typeof currentProp.maxLength === "number") metaProp.maxLength = currentProp.maxLength;
183
+ if (typeof currentProp.minLength === "number") metaProp.minLength = currentProp.minLength;
184
+ if (typeof currentProp.maximum === "number") metaProp.maximum = currentProp.maximum;
185
+ if (typeof currentProp.minimum === "number") metaProp.minimum = currentProp.minimum;
186
+ if (typeof currentProp.pattern === "string") metaProp.pattern = currentProp.pattern;
187
+ if (typeof currentProp.multipleOf === "number") metaProp.multipleOf = currentProp.multipleOf;
188
+ if (currentProp.default !== undefined) metaProp.default = currentProp.default;
189
+ if (typeof currentProp.nullable === "boolean") metaProp.nullable = currentProp.nullable;
190
+ if (typeof currentProp.writeOnly === "boolean") metaProp.writeOnly = currentProp.writeOnly;
191
+ if (currentProp.example !== undefined) metaProp.example = currentProp.example;
192
+ if (typeof currentProp.deprecated === "boolean") metaProp.deprecated = currentProp.deprecated;
193
+ if (currentProp.exclusiveMinimum !== undefined) metaProp.exclusiveMinimum = currentProp.exclusiveMinimum;
194
+ if (currentProp.exclusiveMaximum !== undefined) metaProp.exclusiveMaximum = currentProp.exclusiveMaximum;
195
+ if (Array.isArray(currentProp.enum)) {
196
+ metaProp.enum = currentProp.enum;
197
+ if (!metaProp.ui) metaProp.ui = {};
198
+ if (!metaProp.ui.widget) {
199
+ if (type === "array") {
200
+ metaProp.ui.widget = "multiSelect";
201
+ } else {
202
+ metaProp.ui.widget = "select";
203
+ }
204
+ }
205
+ }
206
+ if (type === "object") {
207
+ if (currentProp.properties) {
208
+ const childRequired = Array.isArray(currentProp.required) ? currentProp.required : [];
209
+ metaProp.properties = this.mapProperties(currentProp.properties, childRequired, swaggerRoot);
210
+ }
211
+ if (currentProp.additionalProperties === true) {
212
+ metaProp.additionalProperties = true;
213
+ }
214
+ } else if (type === "array" && currentProp.items) {
215
+ metaProp.items = this.mapPropertyMetadata(currentProp.items, "items", false, swaggerRoot);
216
+ }
217
+ return metaProp;
218
+ }
219
+ }
220
+ var __exports = {
221
+ __esModule: true
222
+ };
223
+ __exports.SwaggerBuilder = SwaggerBuilder;
224
+ return __exports;
225
+ });
226
+ //# sourceMappingURL=SwaggerBuilder-dbg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SwaggerBuilder-dbg.js","names":["Logger","___utils_Logger","SwaggerTypeMapper","___SwaggerTypeMapper","SwaggerUIMapper","___SwaggerUIMapper","SwaggerRefResolver","___SwaggerRefResolver","SwaggerBuilder","canHandle","rawSchema","openapi","swagger","build","fetchAndBuild","url","targetDefinition","response","fetch","ok","Error","status","swaggerRoot","json","error","msg","message","targetObject","components","schemas","keys","Object","length","definitions","found","schema","title","info","type","layoutStrategy","additionalProperties","requiredKeys","Array","isArray","required","properties","mapProperties","items","mapPropertyMetadata","normalizedProps","key","isRequired","includes","propDef","$ref","resolved","resolve","swaggerProp","keyName","currentProp","allOf","merged","subSchema","resolvedSub","mapType","metaProp","uiDirective","ui","maxLength","minLength","maximum","minimum","pattern","multipleOf","default","undefined","nullable","writeOnly","example","deprecated","exclusiveMinimum","exclusiveMaximum","enum","widget","childRequired","__exports","__esModule"],"sources":["SwaggerBuilder.ts"],"sourcesContent":["/**\n * @file SwaggerBuilder.ts\n * @description Facade orchestration for translating Swagger/OpenAPI JSON into native MetaUI ISchema.\n * Strict Single Responsibility architecture delegates mapping logic to dedicated utilities.\n */\n\nimport { ISchema, IPropertyMetadata } from \"../interfaces/ISchema\";\nimport { ISchemaBuilderPlugin } from \"../interfaces/ISchemaBuilderPlugin\";\nimport { Logger } from \"../utils/Logger\";\nimport { SwaggerTypeMapper } from \"./SwaggerTypeMapper\";\nimport { SwaggerUIMapper } from \"./SwaggerUIMapper\";\nimport { SwaggerRefResolver } from \"./SwaggerRefResolver\";\n\nexport class SwaggerBuilder implements ISchemaBuilderPlugin {\n\n /**\n * Determines if the provided JSON payload is a Swagger or OpenAPI document.\n * \n * @param {any} rawSchema The raw JSON schema to test.\n * @returns {boolean} True if the document contains 'openapi' or 'swagger' root keys.\n */\n public canHandle(rawSchema: any): boolean {\n return !!(rawSchema && (rawSchema.openapi || rawSchema.swagger));\n }\n\n /**\n * Builds a strict MetaUI ISchema from the provided OpenAPI payload.\n * \n * @param {any} rawSchema The OpenAPI root document.\n * @returns {ISchema} The translated MetaUI schema.\n */\n public build(rawSchema: any): ISchema {\n return SwaggerBuilder.build(rawSchema);\n }\n\n /**\n * Asynchronously fetches a remote OpenAPI document and compiles it into a MetaUI ISchema.\n * \n * @param {string} url The URL to fetch the JSON payload from.\n * @param {string} [targetDefinition] Optional. The specific entity schema to extract.\n * @returns {Promise<ISchema>} A Promise resolving to the compiled ISchema.\n */\n public static async fetchAndBuild(url: string, targetDefinition?: string): Promise<ISchema> {\n try {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n const swaggerRoot = await response.json();\n return this.build(swaggerRoot, targetDefinition);\n } catch (error) {\n const msg = \"Failed to fetch Swagger JSON from URL: \" + (error as Error).message;\n Logger.error(\"[MetaUI SwaggerBuilder]\", msg);\n throw new Error(msg);\n }\n }\n\n /**\n * Synchronously builds a MetaUI ISchema from a provided OpenAPI root document.\n * Automatically extracts the requested definition from `components.schemas` or falls back to the first available.\n * \n * @param {any} swaggerRoot The OpenAPI root document.\n * @param {string} [targetDefinition] Optional. The specific entity schema to extract.\n * @returns {ISchema} The translated MetaUI schema.\n */\n public static build(swaggerRoot: any, targetDefinition?: string): ISchema {\n if (!swaggerRoot || typeof swaggerRoot !== \"object\") {\n throw new Error(\"[MetaUI SwaggerBuilder] Invalid Swagger root object provided.\");\n }\n\n let targetObject = swaggerRoot;\n\n if (!targetDefinition) {\n if (swaggerRoot.components && swaggerRoot.components.schemas) {\n const keys = Object.keys(swaggerRoot.components.schemas);\n if (keys.length > 0) targetDefinition = keys[0];\n } else if (swaggerRoot.definitions) {\n const keys = Object.keys(swaggerRoot.definitions);\n if (keys.length > 0) targetDefinition = keys[0];\n }\n }\n\n if (targetDefinition) {\n let found = false;\n if (swaggerRoot.components && swaggerRoot.components.schemas && swaggerRoot.components.schemas[targetDefinition]) {\n targetObject = swaggerRoot.components.schemas[targetDefinition];\n found = true;\n } else if (swaggerRoot.definitions && swaggerRoot.definitions[targetDefinition]) {\n targetObject = swaggerRoot.definitions[targetDefinition];\n found = true;\n }\n\n if (!found) {\n throw new Error(`[MetaUI SwaggerBuilder] Could not find target definition '${targetDefinition}' in components/schemas or definitions.`);\n }\n }\n\n const schema: ISchema = {\n title: targetObject.title || swaggerRoot.info?.title || targetDefinition,\n type: targetObject.type === \"array\" ? \"array\" : \"object\",\n layoutStrategy: targetObject.type === \"array\" ? \"table\" : \"form\"\n };\n\n if (targetObject.additionalProperties === true) {\n schema.additionalProperties = true;\n }\n\n if (schema.type === \"object\") {\n const requiredKeys = Array.isArray(targetObject.required) ? targetObject.required : [];\n schema.properties = this.mapProperties(targetObject.properties || {}, requiredKeys, swaggerRoot);\n } else if (schema.type === \"array\" && targetObject.items) {\n schema.items = this.mapPropertyMetadata(targetObject.items, \"items\", false, swaggerRoot);\n }\n\n return schema;\n }\n\n /**\n * Recursively traverses and translates an OpenAPI properties block into MetaUI IPropertyMetadata.\n * \n * @param {Record<string, any>} properties The OpenAPI properties object.\n * @param {string[]} requiredKeys An array of keys marked as required in the parent schema.\n * @param {any} swaggerRoot The root document (used for $ref resolution).\n * @returns {Record<string, IPropertyMetadata>} The mapped MetaUI properties object.\n */\n private static mapProperties(properties: Record<string, any>, requiredKeys: string[], swaggerRoot: any): Record<string, IPropertyMetadata> {\n const normalizedProps: Record<string, IPropertyMetadata> = {};\n \n for (const key of Object.keys(properties)) {\n const isRequired = requiredKeys.includes(key);\n let propDef = properties[key];\n\n if (propDef.$ref) {\n const resolved = SwaggerRefResolver.resolve(propDef.$ref, swaggerRoot);\n if (resolved) {\n propDef = { ...resolved, ...propDef };\n }\n }\n\n normalizedProps[key] = this.mapPropertyMetadata(propDef, key, isRequired, swaggerRoot);\n }\n \n return normalizedProps;\n }\n\n /**\n * Translates a single OpenAPI property schema into a MetaUI IPropertyMetadata block.\n * Handles local $ref resolution, allOf merging, type mapping, and UI directive injection.\n * \n * @param {any} swaggerProp The OpenAPI property definition.\n * @param {string} keyName The technical key of the property.\n * @param {boolean} isRequired Whether this property is strictly required.\n * @param {any} swaggerRoot The root document (used for $ref resolution).\n * @returns {IPropertyMetadata} The compiled MetaUI property metadata.\n */\n private static mapPropertyMetadata(swaggerProp: any, keyName: string, isRequired: boolean, swaggerRoot: any): IPropertyMetadata {\n let currentProp = swaggerProp;\n\n if (currentProp.$ref) {\n const resolved = SwaggerRefResolver.resolve(currentProp.$ref, swaggerRoot);\n if (resolved) {\n currentProp = { ...resolved, ...currentProp };\n }\n }\n\n if (Array.isArray(currentProp.allOf)) {\n let merged = { ...currentProp };\n delete merged.allOf;\n for (const subSchema of currentProp.allOf) {\n let resolvedSub = subSchema;\n if (subSchema.$ref) {\n resolvedSub = SwaggerRefResolver.resolve(subSchema.$ref, swaggerRoot) || {};\n }\n merged = { ...merged, ...resolvedSub };\n }\n currentProp = merged;\n }\n\n const type = SwaggerTypeMapper.mapType(currentProp.type);\n\n const metaProp: IPropertyMetadata = {\n type: type,\n required: isRequired\n };\n\n const uiDirective = SwaggerUIMapper.build(currentProp, keyName);\n if (Object.keys(uiDirective).length > 0) {\n metaProp.ui = uiDirective;\n }\n\n if (typeof currentProp.maxLength === \"number\") metaProp.maxLength = currentProp.maxLength;\n if (typeof currentProp.minLength === \"number\") metaProp.minLength = currentProp.minLength;\n if (typeof currentProp.maximum === \"number\") metaProp.maximum = currentProp.maximum;\n if (typeof currentProp.minimum === \"number\") metaProp.minimum = currentProp.minimum;\n if (typeof currentProp.pattern === \"string\") metaProp.pattern = currentProp.pattern;\n\n if (typeof currentProp.multipleOf === \"number\") metaProp.multipleOf = currentProp.multipleOf;\n \n if (currentProp.default !== undefined) metaProp.default = currentProp.default;\n if (typeof currentProp.nullable === \"boolean\") metaProp.nullable = currentProp.nullable;\n if (typeof currentProp.writeOnly === \"boolean\") metaProp.writeOnly = currentProp.writeOnly;\n if (currentProp.example !== undefined) metaProp.example = currentProp.example;\n if (typeof currentProp.deprecated === \"boolean\") metaProp.deprecated = currentProp.deprecated;\n if (currentProp.exclusiveMinimum !== undefined) metaProp.exclusiveMinimum = currentProp.exclusiveMinimum;\n if (currentProp.exclusiveMaximum !== undefined) metaProp.exclusiveMaximum = currentProp.exclusiveMaximum;\n\n if (Array.isArray(currentProp.enum)) {\n metaProp.enum = currentProp.enum;\n if (!metaProp.ui) metaProp.ui = {};\n if (!metaProp.ui.widget) {\n if (type === \"array\") {\n metaProp.ui.widget = \"multiSelect\";\n } else {\n metaProp.ui.widget = \"select\";\n }\n }\n }\n\n if (type === \"object\") {\n if (currentProp.properties) {\n const childRequired = Array.isArray(currentProp.required) ? currentProp.required : [];\n metaProp.properties = this.mapProperties(currentProp.properties, childRequired, swaggerRoot);\n }\n if (currentProp.additionalProperties === true) {\n metaProp.additionalProperties = true;\n }\n } else if (type === \"array\" && currentProp.items) {\n metaProp.items = this.mapPropertyMetadata(currentProp.items, \"items\", false, swaggerRoot);\n }\n\n return metaProp;\n }\n}\n"],"mappings":";;;EAAA;AACA;AACA;AACA;AACA;EAJA,MAQSA,MAAM,GAAAC,eAAA;EAAA,MACNC,iBAAiB,GAAAC,oBAAA;EAAA,MACjBC,eAAe,GAAAC,kBAAA;EAAA,MACfC,kBAAkB,GAAAC,qBAAA;EAEpB,MAAMC,cAAc,CAAiC;IAExD;AACJ;AACA;AACA;AACA;AACA;IACWC,SAASA,CAACC,SAAc,EAAW;MACtC,OAAO,CAAC,EAAEA,SAAS,KAAKA,SAAS,CAACC,OAAO,IAAID,SAAS,CAACE,OAAO,CAAC,CAAC;IACpE;;IAEA;AACJ;AACA;AACA;AACA;AACA;IACWC,KAAKA,CAACH,SAAc,EAAW;MAClC,OAAOF,cAAc,CAACK,KAAK,CAACH,SAAS,CAAC;IAC1C;;IAEA;AACJ;AACA;AACA;AACA;AACA;AACA;IACI,aAAoBI,aAAaA,CAACC,GAAW,EAAEC,gBAAyB,EAAoB;MACxF,IAAI;QACA,MAAMC,QAAQ,GAAG,MAAMC,KAAK,CAACH,GAAG,CAAC;QACjC,IAAI,CAACE,QAAQ,CAACE,EAAE,EAAE;UACd,MAAM,IAAIC,KAAK,CAAC,uBAAuBH,QAAQ,CAACI,MAAM,EAAE,CAAC;QAC7D;QACA,MAAMC,WAAW,GAAG,MAAML,QAAQ,CAACM,IAAI,CAAC,CAAC;QACzC,OAAO,IAAI,CAACV,KAAK,CAACS,WAAW,EAAEN,gBAAgB,CAAC;MACpD,CAAC,CAAC,OAAOQ,KAAK,EAAE;QACZ,MAAMC,GAAG,GAAG,yCAAyC,GAAID,KAAK,CAAWE,OAAO;QAChF1B,MAAM,CAACwB,KAAK,CAAC,yBAAyB,EAAEC,GAAG,CAAC;QAC5C,MAAM,IAAIL,KAAK,CAACK,GAAG,CAAC;MACxB;IACJ;;IAEA;AACJ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;UACxB,MAAMuC,aAAa,GAAG1C,KAAK,CAACC,OAAO,CAACgB,WAAW,CAACf,QAAQ,CAAC,GAAGe,WAAW,CAACf,QAAQ,GAAG,EAAE;UACrFqB,QAAQ,CAACpB,UAAU,GAAG,IAAI,CAACC,aAAa,CAACa,WAAW,CAACd,UAAU,EAAEuC,aAAa,EAAE9D,WAAW,CAAC;QAChG;QACA,IAAIqC,WAAW,CAACnB,oBAAoB,KAAK,IAAI,EAAE;UAC3CyB,QAAQ,CAACzB,oBAAoB,GAAG,IAAI;QACxC;MACJ,CAAC,MAAM,IAAIF,IAAI,KAAK,OAAO,IAAIqB,WAAW,CAACZ,KAAK,EAAE;QAC9CkB,QAAQ,CAAClB,KAAK,GAAG,IAAI,CAACC,mBAAmB,CAACW,WAAW,CAACZ,KAAK,EAAE,OAAO,EAAE,KAAK,EAAEzB,WAAW,CAAC;MAC7F;MAEA,OAAO2C,QAAQ;IACnB;EACJ;EAAC,IAAAoB,SAAA;IAAAC,UAAA;EAAA;EAAAD,SAAA,CAAA7E,cAAA,GAAAA,cAAA;EAAA,OAAA6E,SAAA;AAAA","ignoreList":[]}
@@ -0,0 +1,63 @@
1
+ declare module "nz/co/siliconst/ui5/metaui/swagger/SwaggerBuilder" {
2
+ /**
3
+ * @file SwaggerBuilder.ts
4
+ * @description Facade orchestration for translating Swagger/OpenAPI JSON into native MetaUI ISchema.
5
+ * Strict Single Responsibility architecture delegates mapping logic to dedicated utilities.
6
+ */
7
+ import { ISchema } from "nz/co/siliconst/ui5/metaui/interfaces/ISchema";
8
+ import { ISchemaBuilderPlugin } from "nz/co/siliconst/ui5/metaui/interfaces/ISchemaBuilderPlugin";
9
+ export class SwaggerBuilder implements ISchemaBuilderPlugin {
10
+ /**
11
+ * Determines if the provided JSON payload is a Swagger or OpenAPI document.
12
+ *
13
+ * @param {any} rawSchema The raw JSON schema to test.
14
+ * @returns {boolean} True if the document contains 'openapi' or 'swagger' root keys.
15
+ */
16
+ canHandle(rawSchema: any): boolean;
17
+ /**
18
+ * Builds a strict MetaUI ISchema from the provided OpenAPI payload.
19
+ *
20
+ * @param {any} rawSchema The OpenAPI root document.
21
+ * @returns {ISchema} The translated MetaUI schema.
22
+ */
23
+ build(rawSchema: any): ISchema;
24
+ /**
25
+ * Asynchronously fetches a remote OpenAPI document and compiles it into a MetaUI ISchema.
26
+ *
27
+ * @param {string} url The URL to fetch the JSON payload from.
28
+ * @param {string} [targetDefinition] Optional. The specific entity schema to extract.
29
+ * @returns {Promise<ISchema>} A Promise resolving to the compiled ISchema.
30
+ */
31
+ static fetchAndBuild(url: string, targetDefinition?: string): Promise<ISchema>;
32
+ /**
33
+ * Synchronously builds a MetaUI ISchema from a provided OpenAPI root document.
34
+ * Automatically extracts the requested definition from `components.schemas` or falls back to the first available.
35
+ *
36
+ * @param {any} swaggerRoot The OpenAPI root document.
37
+ * @param {string} [targetDefinition] Optional. The specific entity schema to extract.
38
+ * @returns {ISchema} The translated MetaUI schema.
39
+ */
40
+ static build(swaggerRoot: any, targetDefinition?: string): ISchema;
41
+ /**
42
+ * Recursively traverses and translates an OpenAPI properties block into MetaUI IPropertyMetadata.
43
+ *
44
+ * @param {Record<string, any>} properties The OpenAPI properties object.
45
+ * @param {string[]} requiredKeys An array of keys marked as required in the parent schema.
46
+ * @param {any} swaggerRoot The root document (used for $ref resolution).
47
+ * @returns {Record<string, IPropertyMetadata>} The mapped MetaUI properties object.
48
+ */
49
+ private static mapProperties;
50
+ /**
51
+ * Translates a single OpenAPI property schema into a MetaUI IPropertyMetadata block.
52
+ * Handles local $ref resolution, allOf merging, type mapping, and UI directive injection.
53
+ *
54
+ * @param {any} swaggerProp The OpenAPI property definition.
55
+ * @param {string} keyName The technical key of the property.
56
+ * @param {boolean} isRequired Whether this property is strictly required.
57
+ * @param {any} swaggerRoot The root document (used for $ref resolution).
58
+ * @returns {IPropertyMetadata} The compiled MetaUI property metadata.
59
+ */
60
+ private static mapPropertyMetadata;
61
+ }
62
+ }
63
+ //# sourceMappingURL=SwaggerBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SwaggerBuilder.d.ts","sourceRoot":"../../../../../../../..","sources":["src/nz/co/siliconst/ui5/metaui/swagger/SwaggerBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,mDAAmD,CAAC;IACnE;;;;OAIG;IAEH,OAAO,EAAE,OAAO,EAAqB,MAAM,+CAA+C,CAAC;IAC3F,OAAO,EAAE,oBAAoB,EAAE,MAAM,4DAA4D,CAAC;IAMlG,MAAa,cAAe,YAAW,oBAAoB;QAEvD;;;;;WAKG;QACI,SAAS,CAAC,SAAS,EAAE,GAAG,GAAG,OAAO;QAIzC;;;;;WAKG;QACI,KAAK,CAAC,SAAS,EAAE,GAAG,GAAG,OAAO;QAIrC;;;;;;WAMG;eACiB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;QAe3F;;;;;;;WAOG;eACW,KAAK,CAAC,WAAW,EAAE,GAAG,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,OAAO;QAoDzE;;;;;;;WAOG;QACH,OAAO,CAAC,MAAM,CAAC,aAAa;QAoB5B;;;;;;;;;WASG;QACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;KA6ErC;CAEA"}
@@ -0,0 +1,2 @@
1
+ sap.ui.define(["../utils/Logger","./SwaggerTypeMapper","./SwaggerUIMapper","./SwaggerRefResolver"],function(e,t,i,r){"use strict";const a=e["Logger"];const n=t["SwaggerTypeMapper"];const s=i["SwaggerUIMapper"];const o=r["SwaggerRefResolver"];class f{canHandle(e){return!!(e&&(e.openapi||e.swagger))}build(e){return f.build(e)}static async fetchAndBuild(e,t){try{const i=await fetch(e);if(!i.ok){throw new Error(`HTTP error! status: ${i.status}`)}const r=await i.json();return this.build(r,t)}catch(e){const t="Failed to fetch Swagger JSON from URL: "+e.message;a.error("[MetaUI SwaggerBuilder]",t);throw new Error(t)}}static build(e,t){if(!e||typeof e!=="object"){throw new Error("[MetaUI SwaggerBuilder] Invalid Swagger root object provided.")}let i=e;if(!t){if(e.components&&e.components.schemas){const i=Object.keys(e.components.schemas);if(i.length>0)t=i[0]}else if(e.definitions){const i=Object.keys(e.definitions);if(i.length>0)t=i[0]}}if(t){let r=false;if(e.components&&e.components.schemas&&e.components.schemas[t]){i=e.components.schemas[t];r=true}else if(e.definitions&&e.definitions[t]){i=e.definitions[t];r=true}if(!r){throw new Error(`[MetaUI SwaggerBuilder] Could not find target definition '${t}' in components/schemas or definitions.`)}}const r={title:i.title||e.info?.title||t,type:i.type==="array"?"array":"object",layoutStrategy:i.type==="array"?"table":"form"};if(i.additionalProperties===true){r.additionalProperties=true}if(r.type==="object"){const t=Array.isArray(i.required)?i.required:[];r.properties=this.mapProperties(i.properties||{},t,e)}else if(r.type==="array"&&i.items){r.items=this.mapPropertyMetadata(i.items,"items",false,e)}return r}static mapProperties(e,t,i){const r={};for(const a of Object.keys(e)){const n=t.includes(a);let s=e[a];if(s.$ref){const e=o.resolve(s.$ref,i);if(e){s={...e,...s}}}r[a]=this.mapPropertyMetadata(s,a,n,i)}return r}static mapPropertyMetadata(e,t,i,r){let a=e;if(a.$ref){const e=o.resolve(a.$ref,r);if(e){a={...e,...a}}}if(Array.isArray(a.allOf)){let e={...a};delete e.allOf;for(const t of a.allOf){let i=t;if(t.$ref){i=o.resolve(t.$ref,r)||{}}e={...e,...i}}a=e}const f=n.mapType(a.type);const l={type:f,required:i};const u=s.build(a,t);if(Object.keys(u).length>0){l.ui=u}if(typeof a.maxLength==="number")l.maxLength=a.maxLength;if(typeof a.minLength==="number")l.minLength=a.minLength;if(typeof a.maximum==="number")l.maximum=a.maximum;if(typeof a.minimum==="number")l.minimum=a.minimum;if(typeof a.pattern==="string")l.pattern=a.pattern;if(typeof a.multipleOf==="number")l.multipleOf=a.multipleOf;if(a.default!==undefined)l.default=a.default;if(typeof a.nullable==="boolean")l.nullable=a.nullable;if(typeof a.writeOnly==="boolean")l.writeOnly=a.writeOnly;if(a.example!==undefined)l.example=a.example;if(typeof a.deprecated==="boolean")l.deprecated=a.deprecated;if(a.exclusiveMinimum!==undefined)l.exclusiveMinimum=a.exclusiveMinimum;if(a.exclusiveMaximum!==undefined)l.exclusiveMaximum=a.exclusiveMaximum;if(Array.isArray(a.enum)){l.enum=a.enum;if(!l.ui)l.ui={};if(!l.ui.widget){if(f==="array"){l.ui.widget="multiSelect"}else{l.ui.widget="select"}}}if(f==="object"){if(a.properties){const e=Array.isArray(a.required)?a.required:[];l.properties=this.mapProperties(a.properties,e,r)}if(a.additionalProperties===true){l.additionalProperties=true}}else if(f==="array"&&a.items){l.items=this.mapPropertyMetadata(a.items,"items",false,r)}return l}}var l={__esModule:true};l.SwaggerBuilder=f;return l});
2
+ //# sourceMappingURL=SwaggerBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SwaggerBuilder.js","names":["Logger","___utils_Logger","SwaggerTypeMapper","___SwaggerTypeMapper","SwaggerUIMapper","___SwaggerUIMapper","SwaggerRefResolver","___SwaggerRefResolver","SwaggerBuilder","canHandle","rawSchema","openapi","swagger","build","fetchAndBuild","url","targetDefinition","response","fetch","ok","Error","status","swaggerRoot","json","this","error","msg","message","targetObject","components","schemas","keys","Object","length","definitions","found","schema","title","info","type","layoutStrategy","additionalProperties","requiredKeys","Array","isArray","required","properties","mapProperties","items","mapPropertyMetadata","normalizedProps","key","isRequired","includes","propDef","$ref","resolved","resolve","swaggerProp","keyName","currentProp","allOf","merged","subSchema","resolvedSub","mapType","metaProp","uiDirective","ui","maxLength","minLength","maximum","minimum","pattern","multipleOf","default","undefined","nullable","writeOnly","example","deprecated","exclusiveMinimum","exclusiveMaximum","enum","widget","childRequired","__exports","__esModule"],"sources":["SwaggerBuilder.ts"],"sourcesContent":["/**\n * @file SwaggerBuilder.ts\n * @description Facade orchestration for translating Swagger/OpenAPI JSON into native MetaUI ISchema.\n * Strict Single Responsibility architecture delegates mapping logic to dedicated utilities.\n */\n\nimport { ISchema, IPropertyMetadata } from \"../interfaces/ISchema\";\nimport { ISchemaBuilderPlugin } from \"../interfaces/ISchemaBuilderPlugin\";\nimport { Logger } from \"../utils/Logger\";\nimport { SwaggerTypeMapper } from \"./SwaggerTypeMapper\";\nimport { SwaggerUIMapper } from \"./SwaggerUIMapper\";\nimport { SwaggerRefResolver } from \"./SwaggerRefResolver\";\n\nexport class SwaggerBuilder implements ISchemaBuilderPlugin {\n\n /**\n * Determines if the provided JSON payload is a Swagger or OpenAPI document.\n * \n * @param {any} rawSchema The raw JSON schema to test.\n * @returns {boolean} True if the document contains 'openapi' or 'swagger' root keys.\n */\n public canHandle(rawSchema: any): boolean {\n return !!(rawSchema && (rawSchema.openapi || rawSchema.swagger));\n }\n\n /**\n * Builds a strict MetaUI ISchema from the provided OpenAPI payload.\n * \n * @param {any} rawSchema The OpenAPI root document.\n * @returns {ISchema} The translated MetaUI schema.\n */\n public build(rawSchema: any): ISchema {\n return SwaggerBuilder.build(rawSchema);\n }\n\n /**\n * Asynchronously fetches a remote OpenAPI document and compiles it into a MetaUI ISchema.\n * \n * @param {string} url The URL to fetch the JSON payload from.\n * @param {string} [targetDefinition] Optional. The specific entity schema to extract.\n * @returns {Promise<ISchema>} A Promise resolving to the compiled ISchema.\n */\n public static async fetchAndBuild(url: string, targetDefinition?: string): Promise<ISchema> {\n try {\n const response = await fetch(url);\n if (!response.ok) {\n throw new Error(`HTTP error! status: ${response.status}`);\n }\n const swaggerRoot = await response.json();\n return this.build(swaggerRoot, targetDefinition);\n } catch (error) {\n const msg = \"Failed to fetch Swagger JSON from URL: \" + (error as Error).message;\n Logger.error(\"[MetaUI SwaggerBuilder]\", msg);\n throw new Error(msg);\n }\n }\n\n /**\n * Synchronously builds a MetaUI ISchema from a provided OpenAPI root document.\n * Automatically extracts the requested definition from `components.schemas` or falls back to the first available.\n * \n * @param {any} swaggerRoot The OpenAPI root document.\n * @param {string} [targetDefinition] Optional. The specific entity schema to extract.\n * @returns {ISchema} The translated MetaUI schema.\n */\n public static build(swaggerRoot: any, targetDefinition?: string): ISchema {\n if (!swaggerRoot || typeof swaggerRoot !== \"object\") {\n throw new Error(\"[MetaUI SwaggerBuilder] Invalid Swagger root object provided.\");\n }\n\n let targetObject = swaggerRoot;\n\n if (!targetDefinition) {\n if (swaggerRoot.components && swaggerRoot.components.schemas) {\n const keys = Object.keys(swaggerRoot.components.schemas);\n if (keys.length > 0) targetDefinition = keys[0];\n } else if (swaggerRoot.definitions) {\n const keys = Object.keys(swaggerRoot.definitions);\n if (keys.length > 0) targetDefinition = keys[0];\n }\n }\n\n if (targetDefinition) {\n let found = false;\n if (swaggerRoot.components && swaggerRoot.components.schemas && swaggerRoot.components.schemas[targetDefinition]) {\n targetObject = swaggerRoot.components.schemas[targetDefinition];\n found = true;\n } else if (swaggerRoot.definitions && swaggerRoot.definitions[targetDefinition]) {\n targetObject = swaggerRoot.definitions[targetDefinition];\n found = true;\n }\n\n if (!found) {\n throw new Error(`[MetaUI SwaggerBuilder] Could not find target definition '${targetDefinition}' in components/schemas or definitions.`);\n }\n }\n\n const schema: ISchema = {\n title: targetObject.title || swaggerRoot.info?.title || targetDefinition,\n type: targetObject.type === \"array\" ? \"array\" : \"object\",\n layoutStrategy: targetObject.type === \"array\" ? \"table\" : \"form\"\n };\n\n if (targetObject.additionalProperties === true) {\n schema.additionalProperties = true;\n }\n\n if (schema.type === \"object\") {\n const requiredKeys = Array.isArray(targetObject.required) ? targetObject.required : [];\n schema.properties = this.mapProperties(targetObject.properties || {}, requiredKeys, swaggerRoot);\n } else if (schema.type === \"array\" && targetObject.items) {\n schema.items = this.mapPropertyMetadata(targetObject.items, \"items\", false, swaggerRoot);\n }\n\n return schema;\n }\n\n /**\n * Recursively traverses and translates an OpenAPI properties block into MetaUI IPropertyMetadata.\n * \n * @param {Record<string, any>} properties The OpenAPI properties object.\n * @param {string[]} requiredKeys An array of keys marked as required in the parent schema.\n * @param {any} swaggerRoot The root document (used for $ref resolution).\n * @returns {Record<string, IPropertyMetadata>} The mapped MetaUI properties object.\n */\n private static mapProperties(properties: Record<string, any>, requiredKeys: string[], swaggerRoot: any): Record<string, IPropertyMetadata> {\n const normalizedProps: Record<string, IPropertyMetadata> = {};\n \n for (const key of Object.keys(properties)) {\n const isRequired = requiredKeys.includes(key);\n let propDef = properties[key];\n\n if (propDef.$ref) {\n const resolved = SwaggerRefResolver.resolve(propDef.$ref, swaggerRoot);\n if (resolved) {\n propDef = { ...resolved, ...propDef };\n }\n }\n\n normalizedProps[key] = this.mapPropertyMetadata(propDef, key, isRequired, swaggerRoot);\n }\n \n return normalizedProps;\n }\n\n /**\n * Translates a single OpenAPI property schema into a MetaUI IPropertyMetadata block.\n * Handles local $ref resolution, allOf merging, type mapping, and UI directive injection.\n * \n * @param {any} swaggerProp The OpenAPI property definition.\n * @param {string} keyName The technical key of the property.\n * @param {boolean} isRequired Whether this property is strictly required.\n * @param {any} swaggerRoot The root document (used for $ref resolution).\n * @returns {IPropertyMetadata} The compiled MetaUI property metadata.\n */\n private static mapPropertyMetadata(swaggerProp: any, keyName: string, isRequired: boolean, swaggerRoot: any): IPropertyMetadata {\n let currentProp = swaggerProp;\n\n if (currentProp.$ref) {\n const resolved = SwaggerRefResolver.resolve(currentProp.$ref, swaggerRoot);\n if (resolved) {\n currentProp = { ...resolved, ...currentProp };\n }\n }\n\n if (Array.isArray(currentProp.allOf)) {\n let merged = { ...currentProp };\n delete merged.allOf;\n for (const subSchema of currentProp.allOf) {\n let resolvedSub = subSchema;\n if (subSchema.$ref) {\n resolvedSub = SwaggerRefResolver.resolve(subSchema.$ref, swaggerRoot) || {};\n }\n merged = { ...merged, ...resolvedSub };\n }\n currentProp = merged;\n }\n\n const type = SwaggerTypeMapper.mapType(currentProp.type);\n\n const metaProp: IPropertyMetadata = {\n type: type,\n required: isRequired\n };\n\n const uiDirective = SwaggerUIMapper.build(currentProp, keyName);\n if (Object.keys(uiDirective).length > 0) {\n metaProp.ui = uiDirective;\n }\n\n if (typeof currentProp.maxLength === \"number\") metaProp.maxLength = currentProp.maxLength;\n if (typeof currentProp.minLength === \"number\") metaProp.minLength = currentProp.minLength;\n if (typeof currentProp.maximum === \"number\") metaProp.maximum = currentProp.maximum;\n if (typeof currentProp.minimum === \"number\") metaProp.minimum = currentProp.minimum;\n if (typeof currentProp.pattern === \"string\") metaProp.pattern = currentProp.pattern;\n\n if (typeof currentProp.multipleOf === \"number\") metaProp.multipleOf = currentProp.multipleOf;\n \n if (currentProp.default !== undefined) metaProp.default = currentProp.default;\n if (typeof currentProp.nullable === \"boolean\") metaProp.nullable = currentProp.nullable;\n if (typeof currentProp.writeOnly === \"boolean\") metaProp.writeOnly = currentProp.writeOnly;\n if (currentProp.example !== undefined) metaProp.example = currentProp.example;\n if (typeof currentProp.deprecated === \"boolean\") metaProp.deprecated = currentProp.deprecated;\n if (currentProp.exclusiveMinimum !== undefined) metaProp.exclusiveMinimum = currentProp.exclusiveMinimum;\n if (currentProp.exclusiveMaximum !== undefined) metaProp.exclusiveMaximum = currentProp.exclusiveMaximum;\n\n if (Array.isArray(currentProp.enum)) {\n metaProp.enum = currentProp.enum;\n if (!metaProp.ui) metaProp.ui = {};\n if (!metaProp.ui.widget) {\n if (type === \"array\") {\n metaProp.ui.widget = \"multiSelect\";\n } else {\n metaProp.ui.widget = \"select\";\n }\n }\n }\n\n if (type === \"object\") {\n if (currentProp.properties) {\n const childRequired = Array.isArray(currentProp.required) ? currentProp.required : [];\n metaProp.properties = this.mapProperties(currentProp.properties, childRequired, swaggerRoot);\n }\n if (currentProp.additionalProperties === true) {\n metaProp.additionalProperties = true;\n }\n } else if (type === \"array\" && currentProp.items) {\n metaProp.items = this.mapPropertyMetadata(currentProp.items, \"items\", false, swaggerRoot);\n }\n\n return metaProp;\n }\n}\n"],"mappings":"kIAAA,MAQSA,EAAMC,EAAA,gBACNC,EAAiBC,EAAA,2BACjBC,EAAeC,EAAA,yBACfC,EAAkBC,EAAA,sBAEpB,MA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AAO,CACjCjB,EAASiB,KAAOvB,EAAYuB,KAC5B,IAAKjB,EAASE,GAAIF,EAASE,GAAK,CAAC,EACjC,IAAKF,EAASE,GAAGgB,OAAQ,CACrB,GAAI7C,IAAS,QAAS,CAClB2B,EAASE,GAAGgB,OAAS,aACzB,KAAO,CACHlB,EAASE,GAAGgB,OAAS,QACzB,CACJ,CACJ,CAEA,GAAI7C,IAAS,SAAU,CACnB,GAAIqB,EAAYd,WAAY,CACxB,MAAMuC,EAAgB1C,MAAMC,QAAQgB,EAAYf,UAAYe,EAAYf,SAAW,GACnFqB,EAASpB,WAAatB,KAAKuB,cAAca,EAAYd,WAAYuC,EAAe/D,EACpF,CACA,GAAIsC,EAAYnB,uBAAyB,KAAM,CAC3CyB,EAASzB,qBAAuB,IACpC,CACJ,MAAO,GAAIF,IAAS,SAAWqB,EAAYZ,MAAO,CAC9CkB,EAASlB,MAAQxB,KAAKyB,oBAAoBW,EAAYZ,MAAO,QAAS,MAAO1B,EACjF,CAEA,OAAO4C,CACX,EACH,IAAAoB,EAAA,CAAAC,WAAA,MAAAD,EAAA9E,iBAAA,OAAA8E,CAAA","ignoreList":[]}
@@ -0,0 +1,233 @@
1
+ /**
2
+ * @file SwaggerBuilder.ts
3
+ * @description Facade orchestration for translating Swagger/OpenAPI JSON into native MetaUI ISchema.
4
+ * Strict Single Responsibility architecture delegates mapping logic to dedicated utilities.
5
+ */
6
+
7
+ import { ISchema, IPropertyMetadata } from "../interfaces/ISchema";
8
+ import { ISchemaBuilderPlugin } from "../interfaces/ISchemaBuilderPlugin";
9
+ import { Logger } from "../utils/Logger";
10
+ import { SwaggerTypeMapper } from "./SwaggerTypeMapper";
11
+ import { SwaggerUIMapper } from "./SwaggerUIMapper";
12
+ import { SwaggerRefResolver } from "./SwaggerRefResolver";
13
+
14
+ export class SwaggerBuilder implements ISchemaBuilderPlugin {
15
+
16
+ /**
17
+ * Determines if the provided JSON payload is a Swagger or OpenAPI document.
18
+ *
19
+ * @param {any} rawSchema The raw JSON schema to test.
20
+ * @returns {boolean} True if the document contains 'openapi' or 'swagger' root keys.
21
+ */
22
+ public canHandle(rawSchema: any): boolean {
23
+ return !!(rawSchema && (rawSchema.openapi || rawSchema.swagger));
24
+ }
25
+
26
+ /**
27
+ * Builds a strict MetaUI ISchema from the provided OpenAPI payload.
28
+ *
29
+ * @param {any} rawSchema The OpenAPI root document.
30
+ * @returns {ISchema} The translated MetaUI schema.
31
+ */
32
+ public build(rawSchema: any): ISchema {
33
+ return SwaggerBuilder.build(rawSchema);
34
+ }
35
+
36
+ /**
37
+ * Asynchronously fetches a remote OpenAPI document and compiles it into a MetaUI ISchema.
38
+ *
39
+ * @param {string} url The URL to fetch the JSON payload from.
40
+ * @param {string} [targetDefinition] Optional. The specific entity schema to extract.
41
+ * @returns {Promise<ISchema>} A Promise resolving to the compiled ISchema.
42
+ */
43
+ public static async fetchAndBuild(url: string, targetDefinition?: string): Promise<ISchema> {
44
+ try {
45
+ const response = await fetch(url);
46
+ if (!response.ok) {
47
+ throw new Error(`HTTP error! status: ${response.status}`);
48
+ }
49
+ const swaggerRoot = await response.json();
50
+ return this.build(swaggerRoot, targetDefinition);
51
+ } catch (error) {
52
+ const msg = "Failed to fetch Swagger JSON from URL: " + (error as Error).message;
53
+ Logger.error("[MetaUI SwaggerBuilder]", msg);
54
+ throw new Error(msg);
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Synchronously builds a MetaUI ISchema from a provided OpenAPI root document.
60
+ * Automatically extracts the requested definition from `components.schemas` or falls back to the first available.
61
+ *
62
+ * @param {any} swaggerRoot The OpenAPI root document.
63
+ * @param {string} [targetDefinition] Optional. The specific entity schema to extract.
64
+ * @returns {ISchema} The translated MetaUI schema.
65
+ */
66
+ public static build(swaggerRoot: any, targetDefinition?: string): ISchema {
67
+ if (!swaggerRoot || typeof swaggerRoot !== "object") {
68
+ throw new Error("[MetaUI SwaggerBuilder] Invalid Swagger root object provided.");
69
+ }
70
+
71
+ let targetObject = swaggerRoot;
72
+
73
+ if (!targetDefinition) {
74
+ if (swaggerRoot.components && swaggerRoot.components.schemas) {
75
+ const keys = Object.keys(swaggerRoot.components.schemas);
76
+ if (keys.length > 0) targetDefinition = keys[0];
77
+ } else if (swaggerRoot.definitions) {
78
+ const keys = Object.keys(swaggerRoot.definitions);
79
+ if (keys.length > 0) targetDefinition = keys[0];
80
+ }
81
+ }
82
+
83
+ if (targetDefinition) {
84
+ let found = false;
85
+ if (swaggerRoot.components && swaggerRoot.components.schemas && swaggerRoot.components.schemas[targetDefinition]) {
86
+ targetObject = swaggerRoot.components.schemas[targetDefinition];
87
+ found = true;
88
+ } else if (swaggerRoot.definitions && swaggerRoot.definitions[targetDefinition]) {
89
+ targetObject = swaggerRoot.definitions[targetDefinition];
90
+ found = true;
91
+ }
92
+
93
+ if (!found) {
94
+ throw new Error(`[MetaUI SwaggerBuilder] Could not find target definition '${targetDefinition}' in components/schemas or definitions.`);
95
+ }
96
+ }
97
+
98
+ const schema: ISchema = {
99
+ title: targetObject.title || swaggerRoot.info?.title || targetDefinition,
100
+ type: targetObject.type === "array" ? "array" : "object",
101
+ layoutStrategy: targetObject.type === "array" ? "table" : "form"
102
+ };
103
+
104
+ if (targetObject.additionalProperties === true) {
105
+ schema.additionalProperties = true;
106
+ }
107
+
108
+ if (schema.type === "object") {
109
+ const requiredKeys = Array.isArray(targetObject.required) ? targetObject.required : [];
110
+ schema.properties = this.mapProperties(targetObject.properties || {}, requiredKeys, swaggerRoot);
111
+ } else if (schema.type === "array" && targetObject.items) {
112
+ schema.items = this.mapPropertyMetadata(targetObject.items, "items", false, swaggerRoot);
113
+ }
114
+
115
+ return schema;
116
+ }
117
+
118
+ /**
119
+ * Recursively traverses and translates an OpenAPI properties block into MetaUI IPropertyMetadata.
120
+ *
121
+ * @param {Record<string, any>} properties The OpenAPI properties object.
122
+ * @param {string[]} requiredKeys An array of keys marked as required in the parent schema.
123
+ * @param {any} swaggerRoot The root document (used for $ref resolution).
124
+ * @returns {Record<string, IPropertyMetadata>} The mapped MetaUI properties object.
125
+ */
126
+ private static mapProperties(properties: Record<string, any>, requiredKeys: string[], swaggerRoot: any): Record<string, IPropertyMetadata> {
127
+ const normalizedProps: Record<string, IPropertyMetadata> = {};
128
+
129
+ for (const key of Object.keys(properties)) {
130
+ const isRequired = requiredKeys.includes(key);
131
+ let propDef = properties[key];
132
+
133
+ if (propDef.$ref) {
134
+ const resolved = SwaggerRefResolver.resolve(propDef.$ref, swaggerRoot);
135
+ if (resolved) {
136
+ propDef = { ...resolved, ...propDef };
137
+ }
138
+ }
139
+
140
+ normalizedProps[key] = this.mapPropertyMetadata(propDef, key, isRequired, swaggerRoot);
141
+ }
142
+
143
+ return normalizedProps;
144
+ }
145
+
146
+ /**
147
+ * Translates a single OpenAPI property schema into a MetaUI IPropertyMetadata block.
148
+ * Handles local $ref resolution, allOf merging, type mapping, and UI directive injection.
149
+ *
150
+ * @param {any} swaggerProp The OpenAPI property definition.
151
+ * @param {string} keyName The technical key of the property.
152
+ * @param {boolean} isRequired Whether this property is strictly required.
153
+ * @param {any} swaggerRoot The root document (used for $ref resolution).
154
+ * @returns {IPropertyMetadata} The compiled MetaUI property metadata.
155
+ */
156
+ private static mapPropertyMetadata(swaggerProp: any, keyName: string, isRequired: boolean, swaggerRoot: any): IPropertyMetadata {
157
+ let currentProp = swaggerProp;
158
+
159
+ if (currentProp.$ref) {
160
+ const resolved = SwaggerRefResolver.resolve(currentProp.$ref, swaggerRoot);
161
+ if (resolved) {
162
+ currentProp = { ...resolved, ...currentProp };
163
+ }
164
+ }
165
+
166
+ if (Array.isArray(currentProp.allOf)) {
167
+ let merged = { ...currentProp };
168
+ delete merged.allOf;
169
+ for (const subSchema of currentProp.allOf) {
170
+ let resolvedSub = subSchema;
171
+ if (subSchema.$ref) {
172
+ resolvedSub = SwaggerRefResolver.resolve(subSchema.$ref, swaggerRoot) || {};
173
+ }
174
+ merged = { ...merged, ...resolvedSub };
175
+ }
176
+ currentProp = merged;
177
+ }
178
+
179
+ const type = SwaggerTypeMapper.mapType(currentProp.type);
180
+
181
+ const metaProp: IPropertyMetadata = {
182
+ type: type,
183
+ required: isRequired
184
+ };
185
+
186
+ const uiDirective = SwaggerUIMapper.build(currentProp, keyName);
187
+ if (Object.keys(uiDirective).length > 0) {
188
+ metaProp.ui = uiDirective;
189
+ }
190
+
191
+ if (typeof currentProp.maxLength === "number") metaProp.maxLength = currentProp.maxLength;
192
+ if (typeof currentProp.minLength === "number") metaProp.minLength = currentProp.minLength;
193
+ if (typeof currentProp.maximum === "number") metaProp.maximum = currentProp.maximum;
194
+ if (typeof currentProp.minimum === "number") metaProp.minimum = currentProp.minimum;
195
+ if (typeof currentProp.pattern === "string") metaProp.pattern = currentProp.pattern;
196
+
197
+ if (typeof currentProp.multipleOf === "number") metaProp.multipleOf = currentProp.multipleOf;
198
+
199
+ if (currentProp.default !== undefined) metaProp.default = currentProp.default;
200
+ if (typeof currentProp.nullable === "boolean") metaProp.nullable = currentProp.nullable;
201
+ if (typeof currentProp.writeOnly === "boolean") metaProp.writeOnly = currentProp.writeOnly;
202
+ if (currentProp.example !== undefined) metaProp.example = currentProp.example;
203
+ if (typeof currentProp.deprecated === "boolean") metaProp.deprecated = currentProp.deprecated;
204
+ if (currentProp.exclusiveMinimum !== undefined) metaProp.exclusiveMinimum = currentProp.exclusiveMinimum;
205
+ if (currentProp.exclusiveMaximum !== undefined) metaProp.exclusiveMaximum = currentProp.exclusiveMaximum;
206
+
207
+ if (Array.isArray(currentProp.enum)) {
208
+ metaProp.enum = currentProp.enum;
209
+ if (!metaProp.ui) metaProp.ui = {};
210
+ if (!metaProp.ui.widget) {
211
+ if (type === "array") {
212
+ metaProp.ui.widget = "multiSelect";
213
+ } else {
214
+ metaProp.ui.widget = "select";
215
+ }
216
+ }
217
+ }
218
+
219
+ if (type === "object") {
220
+ if (currentProp.properties) {
221
+ const childRequired = Array.isArray(currentProp.required) ? currentProp.required : [];
222
+ metaProp.properties = this.mapProperties(currentProp.properties, childRequired, swaggerRoot);
223
+ }
224
+ if (currentProp.additionalProperties === true) {
225
+ metaProp.additionalProperties = true;
226
+ }
227
+ } else if (type === "array" && currentProp.items) {
228
+ metaProp.items = this.mapPropertyMetadata(currentProp.items, "items", false, swaggerRoot);
229
+ }
230
+
231
+ return metaProp;
232
+ }
233
+ }