mxrb 0.1.4 → 0.1.7

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 (949) hide show
  1. checksums.yaml +4 -4
  2. data/README.de-DE.md +4 -1
  3. data/README.md +11 -3
  4. data/README.pt-BR.md +5 -2
  5. data/bin/mxrb +509 -358
  6. data/docker/java-actions/Dockerfile +44 -0
  7. data/docker/java-actions/src/com/mendix/core/Core.java +491 -0
  8. data/docker/java-actions/src/com/mendix/core/CoreException.java +11 -0
  9. data/docker/java-actions/src/com/mendix/core/CoreRuntimeException.java +10 -0
  10. data/docker/java-actions/src/com/mendix/core/actionmanagement/MicroflowCallBuilder.java +19 -0
  11. data/docker/java-actions/src/com/mendix/core/conf/Configuration.java +60 -0
  12. data/docker/java-actions/src/com/mendix/core/conf/RuntimeVersion.java +38 -0
  13. data/docker/java-actions/src/com/mendix/core/internal/ICore.java +5 -0
  14. data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixAutoNumber.java +10 -0
  15. data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixBinary.java +48 -0
  16. data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixBoolean.java +10 -0
  17. data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixDateTime.java +15 -0
  18. data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixDecimal.java +10 -0
  19. data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixEnum.java +18 -0
  20. data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixHashString.java +10 -0
  21. data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixInteger.java +10 -0
  22. data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixLong.java +10 -0
  23. data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixObjectMember.java +73 -0
  24. data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixObjectReference.java +20 -0
  25. data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixObjectReferenceSet.java +22 -0
  26. data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixString.java +10 -0
  27. data/docker/java-actions/src/com/mendix/datastorage/DataStorage.java +5 -0
  28. data/docker/java-actions/src/com/mendix/datastorage/XPathBasicQuery.java +29 -0
  29. data/docker/java-actions/src/com/mendix/datastorage/XPathQuery.java +41 -0
  30. data/docker/java-actions/src/com/mendix/externalinterface/connector/RequestHandler.java +38 -0
  31. data/docker/java-actions/src/com/mendix/http/Http.java +5 -0
  32. data/docker/java-actions/src/com/mendix/integration/Integration.java +5 -0
  33. data/docker/java-actions/src/com/mendix/integration/WebserviceException.java +24 -0
  34. data/docker/java-actions/src/com/mendix/logging/ILogNode.java +35 -0
  35. data/docker/java-actions/src/com/mendix/logging/LogLevel.java +4 -0
  36. data/docker/java-actions/src/com/mendix/logging/LogMessage.java +18 -0
  37. data/docker/java-actions/src/com/mendix/logging/LogSubscriber.java +22 -0
  38. data/docker/java-actions/src/com/mendix/m2ee/api/IMxRuntimeRequest.java +20 -0
  39. data/docker/java-actions/src/com/mendix/m2ee/api/IMxRuntimeResponse.java +50 -0
  40. data/docker/java-actions/src/com/mendix/metrics/Counter.java +7 -0
  41. data/docker/java-actions/src/com/mendix/metrics/Gauge.java +7 -0
  42. data/docker/java-actions/src/com/mendix/metrics/Metric.java +17 -0
  43. data/docker/java-actions/src/com/mendix/metrics/Metrics.java +75 -0
  44. data/docker/java-actions/src/com/mendix/metrics/Timer.java +10 -0
  45. data/docker/java-actions/src/com/mendix/systemwideinterfaces/MendixException.java +9 -0
  46. data/docker/java-actions/src/com/mendix/systemwideinterfaces/MendixRuntimeException.java +9 -0
  47. data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/data/IDataColumnSchema.java +7 -0
  48. data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/data/IDataRow.java +14 -0
  49. data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/data/IDataTable.java +11 -0
  50. data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/data/IDataTableSchema.java +13 -0
  51. data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/requests/IParameterMap.java +9 -0
  52. data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/requests/IRetrievalSchema.java +9 -0
  53. data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/requests/ISortExpression.java +7 -0
  54. data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/requests/types/IGetRequest.java +9 -0
  55. data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/requests/types/IOQLTextGetRequest.java +5 -0
  56. data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/requests/types/ITextGetRequest.java +12 -0
  57. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/IContext.java +28 -0
  58. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/IDataType.java +20 -0
  59. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/IEntityProxy.java +27 -0
  60. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/IFeedback.java +10 -0
  61. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/ILanguage.java +11 -0
  62. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/IMendixIdentifier.java +8 -0
  63. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/IMendixObject.java +65 -0
  64. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/IMendixObjectMember.java +20 -0
  65. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/ISession.java +16 -0
  66. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/IUser.java +11 -0
  67. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/UserAction.java +25 -0
  68. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/meta/IMetaAssociation.java +15 -0
  69. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/meta/IMetaEnumValue.java +9 -0
  70. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/meta/IMetaEnumeration.java +9 -0
  71. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/meta/IMetaObject.java +39 -0
  72. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/meta/IMetaObjectMember.java +6 -0
  73. data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/meta/IMetaPrimitive.java +19 -0
  74. data/docker/java-actions/src/com/mendix/thirdparty/org/json/JSONArray.java +249 -0
  75. data/docker/java-actions/src/com/mendix/thirdparty/org/json/JSONException.java +14 -0
  76. data/docker/java-actions/src/com/mendix/thirdparty/org/json/JSONObject.java +279 -0
  77. data/docker/java-actions/src/com/mendix/thirdparty/org/json/JSONValues.java +273 -0
  78. data/docker/java-actions/src/com/mendix/utils/ListUtils.java +27 -0
  79. data/docker/java-actions/src/com/mendix/webui/CustomJavaAction.java +11 -0
  80. data/docker/java-actions/src/com/mendix/webui/FeedbackHelper.java +30 -0
  81. data/docker/java-actions/src/javax/servlet/http/Cookie.java +69 -0
  82. data/docker/java-actions/src/javax/servlet/http/HttpServletRequest.java +21 -0
  83. data/docker/java-actions/src/javax/servlet/http/HttpServletResponse.java +27 -0
  84. data/docker/java-actions/src/mxrb/sidecar/Aggregate.java +70 -0
  85. data/docker/java-actions/src/mxrb/sidecar/Background.java +84 -0
  86. data/docker/java-actions/src/mxrb/sidecar/Bridge.java +306 -0
  87. data/docker/java-actions/src/mxrb/sidecar/Build.java +131 -0
  88. data/docker/java-actions/src/mxrb/sidecar/Captions.java +52 -0
  89. data/docker/java-actions/src/mxrb/sidecar/Handlers.java +27 -0
  90. data/docker/java-actions/src/mxrb/sidecar/Invoker.java +110 -0
  91. data/docker/java-actions/src/mxrb/sidecar/Json.java +234 -0
  92. data/docker/java-actions/src/mxrb/sidecar/Metadata.java +119 -0
  93. data/docker/java-actions/src/mxrb/sidecar/MxContext.java +100 -0
  94. data/docker/java-actions/src/mxrb/sidecar/MxDataTable.java +172 -0
  95. data/docker/java-actions/src/mxrb/sidecar/MxDataType.java +100 -0
  96. data/docker/java-actions/src/mxrb/sidecar/MxIdentifier.java +47 -0
  97. data/docker/java-actions/src/mxrb/sidecar/MxLogNode.java +50 -0
  98. data/docker/java-actions/src/mxrb/sidecar/MxMetaAssociation.java +62 -0
  99. data/docker/java-actions/src/mxrb/sidecar/MxMetaEnumeration.java +64 -0
  100. data/docker/java-actions/src/mxrb/sidecar/MxMetaObject.java +234 -0
  101. data/docker/java-actions/src/mxrb/sidecar/MxMetaPrimitive.java +88 -0
  102. data/docker/java-actions/src/mxrb/sidecar/MxMicroflowCall.java +36 -0
  103. data/docker/java-actions/src/mxrb/sidecar/MxObject.java +258 -0
  104. data/docker/java-actions/src/mxrb/sidecar/MxOqlRequest.java +101 -0
  105. data/docker/java-actions/src/mxrb/sidecar/MxRuntimeRequest.java +182 -0
  106. data/docker/java-actions/src/mxrb/sidecar/MxRuntimeResponse.java +122 -0
  107. data/docker/java-actions/src/mxrb/sidecar/MxSession.java +91 -0
  108. data/docker/java-actions/src/mxrb/sidecar/MxXPathQuery.java +127 -0
  109. data/docker/java-actions/src/mxrb/sidecar/RubyException.java +17 -0
  110. data/docker/java-actions/src/mxrb/sidecar/Server.java +56 -0
  111. data/docs/agent-relay/20260901-083127.md +15 -0
  112. data/docs/agent-relay/20260901-091655.md +16 -0
  113. data/docs/agent-relay/20260901-094201.md +16 -0
  114. data/docs/agent-relay/20260901-140415.md +28 -0
  115. data/docs/de-DE/README.md +2 -0
  116. data/docs/de-DE/architectural-standard.md +19 -0
  117. data/docs/de-DE/certificacao-ruby-typescript.md +40 -0
  118. data/docs/de-DE/cobertura-ruby-nativa.md +265 -0
  119. data/docs/de-DE/compiler.md +22 -7
  120. data/docs/de-DE/demanda-projeto-ruby-typescript-convencional.md +37 -0
  121. data/docs/de-DE/design-system.md +59 -2
  122. data/docs/de-DE/entity-dsl.md +12 -0
  123. data/docs/de-DE/method-oriented-flows.md +66 -0
  124. data/docs/de-DE/portabilidade-ruby-typescript.md +1050 -0
  125. data/docs/de-DE/project-structure.md +34 -10
  126. data/docs/de-DE/ruby-first-roadmap.md +286 -0
  127. data/docs/de-DE/runtime-ruby.md +329 -6
  128. data/docs/de-DE/scaffolds.md +8 -4
  129. data/docs/de-DE/studio-backend.md +352 -0
  130. data/docs/de-DE/validation-matrix.md +235 -19
  131. data/docs/de-DE/vetclinic-acceptance.md +4 -3
  132. data/docs/de-DE/windows-studio-pro.md +88 -0
  133. data/docs/de-DE/writing.md +3 -1
  134. data/docs/en-US/README.md +2 -0
  135. data/docs/en-US/architectural-patterns.md +2 -3
  136. data/docs/en-US/architectural-standard.md +21 -1
  137. data/docs/en-US/certificacao-ruby-typescript.md +40 -0
  138. data/docs/en-US/cobertura-ruby-nativa.md +381 -0
  139. data/docs/en-US/compiler.md +33 -6
  140. data/docs/en-US/conventions.md +1 -2
  141. data/docs/en-US/demanda-projeto-ruby-typescript-convencional.md +36 -0
  142. data/docs/en-US/design-system.md +55 -1
  143. data/docs/en-US/entity-dsl.md +12 -0
  144. data/docs/en-US/method-oriented-flows.md +62 -0
  145. data/docs/en-US/portabilidade-ruby-typescript.md +1050 -0
  146. data/docs/en-US/project-structure.md +31 -8
  147. data/docs/en-US/ruby-first-roadmap.md +271 -2
  148. data/docs/en-US/runtime-ruby.md +313 -7
  149. data/docs/en-US/scaffolds.md +7 -4
  150. data/docs/en-US/studio-backend.md +342 -0
  151. data/docs/en-US/validation-matrix.md +173 -48
  152. data/docs/en-US/vetclinic-acceptance.md +4 -2
  153. data/docs/en-US/windows-studio-pro.md +84 -0
  154. data/docs/en-US/writing.md +8 -3
  155. data/docs/guides/benchmark-budget.pt-BR.md +99 -0
  156. data/docs/guides/certificacao-edicoes.pt-BR.md +116 -0
  157. data/docs/guides/teste-manual-vetclinic-ruby.pt-BR.md +480 -0
  158. data/docs/planning/backlog.pt-BR.md +101 -0
  159. data/docs/planning/ruby-editability.pt-BR.md +277 -0
  160. data/docs/pt-BR/README.md +4 -0
  161. data/docs/pt-BR/architectural-standard.md +21 -1
  162. data/docs/pt-BR/certificacao-ruby-typescript.md +116 -0
  163. data/docs/pt-BR/cobertura-ruby-nativa.md +408 -0
  164. data/docs/pt-BR/compiler.md +38 -7
  165. data/docs/pt-BR/demanda-projeto-ruby-typescript-convencional.md +41 -0
  166. data/docs/pt-BR/design-system.md +58 -2
  167. data/docs/pt-BR/entity-dsl.md +12 -0
  168. data/docs/pt-BR/method-oriented-flows.md +158 -0
  169. data/docs/pt-BR/oql-sql.md +11 -1
  170. data/docs/pt-BR/portabilidade-ruby-typescript.md +1311 -0
  171. data/docs/pt-BR/project-structure.md +46 -8
  172. data/docs/pt-BR/ruby-first-roadmap.md +390 -2
  173. data/docs/pt-BR/runtime-ruby.md +321 -11
  174. data/docs/pt-BR/scaffolds.md +17 -4
  175. data/docs/pt-BR/studio-backend.md +363 -0
  176. data/docs/pt-BR/validation-matrix.md +211 -21
  177. data/docs/pt-BR/vetclinic-acceptance.md +4 -5
  178. data/docs/pt-BR/windows-studio-pro.md +85 -0
  179. data/docs/pt-BR/writing.md +4 -0
  180. data/docs/reviews/ruby-code-review-2026-09-05.pt-BR.md +385 -0
  181. data/examples/modbus_application.rb +105 -0
  182. data/examples/modbus_tcp_simulator.rb +137 -0
  183. data/examples/sudoku_evaluation.rb +5 -5
  184. data/examples/sudoku_functional_test.rb +12 -12
  185. data/lib/mxrb/architecture/graph.rb +2 -2
  186. data/lib/mxrb/architecture/validator.rb +5 -3
  187. data/lib/mxrb/benchmark_fixture.rb +19 -0
  188. data/lib/mxrb/caption.rb +107 -0
  189. data/lib/mxrb/cli/help.rb +47 -8
  190. data/lib/mxrb/compare.rb +236 -74
  191. data/lib/mxrb/compiler/activity_caption.rb +168 -0
  192. data/lib/mxrb/compiler/artifact_document_compiler.rb +2 -1
  193. data/lib/mxrb/compiler/attribute_type_index.rb +57 -0
  194. data/lib/mxrb/compiler/client_model_materializer.rb +3 -4
  195. data/lib/mxrb/compiler/code_action_document_compiler.rb +4 -1
  196. data/lib/mxrb/compiler/compatibility_analyzer.rb +53 -0
  197. data/lib/mxrb/compiler/constants_materializer.rb +7 -1
  198. data/lib/mxrb/compiler/data_grid_bundle_compiler.rb +14 -12
  199. data/lib/mxrb/compiler/database_connector_action_compiler.rb +2 -2
  200. data/lib/mxrb/compiler/deployment_materializer.rb +3 -2
  201. data/lib/mxrb/compiler/deployment_metadata.rb +7 -1
  202. data/lib/mxrb/compiler/domain_document_compiler.rb +26 -2
  203. data/lib/mxrb/compiler/domain_model_materializer.rb +30 -6
  204. data/lib/mxrb/compiler/domain_security_compiler.rb +9 -12
  205. data/lib/mxrb/compiler/java_proxy_generator.rb +34 -2
  206. data/lib/mxrb/compiler/languages.rb +30 -0
  207. data/lib/mxrb/compiler/legacy_data_grid_compiler.rb +19 -3
  208. data/lib/mxrb/compiler/legacy_page_builder.rb +96 -20
  209. data/lib/mxrb/compiler/mapping_materializer.rb +94 -0
  210. data/lib/mxrb/compiler/microflow_document_compiler.rb +5 -19
  211. data/lib/mxrb/compiler/microflow_materializer.rb +12 -1
  212. data/lib/mxrb/compiler/microflow_node_compiler.rb +257 -20
  213. data/lib/mxrb/compiler/model_values.rb +26 -0
  214. data/lib/mxrb/compiler/navigation_document_compiler.rb +73 -66
  215. data/lib/mxrb/compiler/navigation_grid_compiler.rb +112 -0
  216. data/lib/mxrb/compiler/page_bundle_builder.rb +17 -1
  217. data/lib/mxrb/compiler/page_bundle_compiler.rb +783 -147
  218. data/lib/mxrb/compiler/page_document_compiler.rb +17 -23
  219. data/lib/mxrb/compiler/published_rest_materializer.rb +117 -0
  220. data/lib/mxrb/compiler/published_rest_open_api.rb +131 -0
  221. data/lib/mxrb/compiler/runtime_nodes.rb +68 -0
  222. data/lib/mxrb/compiler/schemas/forms-11.12.1.json +19781 -0
  223. data/lib/mxrb/compiler/schemas/languages-10.24.0.73019.json +658 -0
  224. data/lib/mxrb/compiler/schemas/languages-11.12.1.json +670 -0
  225. data/lib/mxrb/compiler/schemas/runtime-10.24.0.73019.json +442 -0
  226. data/lib/mxrb/compiler/schemas/runtime-11.json +176 -0
  227. data/lib/mxrb/compiler/security_materializer.rb +13 -6
  228. data/lib/mxrb/compiler/settings_document_compiler.rb +14 -2
  229. data/lib/mxrb/compiler/settings_materializer.rb +2 -1
  230. data/lib/mxrb/compiler/source_model.rb +8 -10
  231. data/lib/mxrb/compiler/synchronized_entities.rb +76 -0
  232. data/lib/mxrb/compiler/url_segment_compiler.rb +82 -0
  233. data/lib/mxrb/compiler/user_role_resolver.rb +33 -0
  234. data/lib/mxrb/compiler/web_list_data_source.rb +6 -2
  235. data/lib/mxrb/compiler/web_shell_materializer.rb +14 -0
  236. data/lib/mxrb/compiler/web_widget_inventory.rb +72 -0
  237. data/lib/mxrb/converter.rb +125 -0
  238. data/lib/mxrb/dsl/artifact_documents.rb +56 -0
  239. data/lib/mxrb/dsl/asset_documents.rb +94 -0
  240. data/lib/mxrb/dsl/builder.rb +102 -1630
  241. data/lib/mxrb/dsl/code_actions.rb +201 -0
  242. data/lib/mxrb/dsl/data_view_builder.rb +162 -0
  243. data/lib/mxrb/dsl/document_builders.rb +185 -0
  244. data/lib/mxrb/dsl/entity_builder.rb +188 -0
  245. data/lib/mxrb/dsl/flow_body_dsl.rb +538 -0
  246. data/lib/mxrb/dsl/flow_builders.rb +362 -0
  247. data/lib/mxrb/dsl/flow_page_builder.rb +58 -0
  248. data/lib/mxrb/dsl/flow_program.rb +101 -0
  249. data/lib/mxrb/dsl/flow_rest_builder.rb +40 -0
  250. data/lib/mxrb/dsl/flow_text_builder.rb +55 -0
  251. data/lib/mxrb/dsl/integration_documents.rb +1634 -0
  252. data/lib/mxrb/dsl/layout_builders.rb +373 -0
  253. data/lib/mxrb/dsl/module_builder.rb +408 -0
  254. data/lib/mxrb/dsl/navigation_builders.rb +264 -0
  255. data/lib/mxrb/dsl/page_builder.rb +219 -0
  256. data/lib/mxrb/dsl/presentation_documents.rb +161 -0
  257. data/lib/mxrb/dsl/project_documents.rb +60 -0
  258. data/lib/mxrb/dsl/security_builder.rb +215 -0
  259. data/lib/mxrb/dsl/widget_builders.rb +251 -0
  260. data/lib/mxrb/dsl/widget_design.rb +61 -0
  261. data/lib/mxrb/dsl/widget_dsl.rb +553 -0
  262. data/lib/mxrb/dsl/widget_event_arguments.rb +52 -0
  263. data/lib/mxrb/dsl/workflows.rb +520 -0
  264. data/lib/mxrb/errors.rb +3 -0
  265. data/lib/mxrb/evaluation.rb +9 -8
  266. data/lib/mxrb/exporter/code_action_declarations.rb +133 -0
  267. data/lib/mxrb/exporter/data_sources.rb +144 -0
  268. data/lib/mxrb/exporter/domain_document_declarations.rb +222 -0
  269. data/lib/mxrb/exporter/flow_action_sources.rb +545 -0
  270. data/lib/mxrb/exporter/flow_linearization.rb +649 -0
  271. data/lib/mxrb/exporter/integration_declarations.rb +763 -0
  272. data/lib/mxrb/exporter/method_flow_source.rb +208 -0
  273. data/lib/mxrb/exporter/model_sources.rb +381 -0
  274. data/lib/mxrb/exporter/page_sources.rb +756 -0
  275. data/lib/mxrb/exporter/presentation_declarations.rb +161 -0
  276. data/lib/mxrb/exporter/project_sources.rb +306 -0
  277. data/lib/mxrb/exporter/rest_declarations.rb +509 -0
  278. data/lib/mxrb/exporter/workflow_declarations.rb +652 -0
  279. data/lib/mxrb/exporter.rb +677 -1491
  280. data/lib/mxrb/forms/catalog.rb +175 -0
  281. data/lib/mxrb/forms/certification.rb +115 -0
  282. data/lib/mxrb/forms/coverage.rb +130 -0
  283. data/lib/mxrb/forms/input_presentation.rb +55 -0
  284. data/lib/mxrb/forms/mpr_codec.rb +821 -0
  285. data/lib/mxrb/forms/node.rb +213 -0
  286. data/lib/mxrb/forms/source_emitter.rb +296 -0
  287. data/lib/mxrb/forms/storage_naming.rb +120 -0
  288. data/lib/mxrb/forms/values.rb +226 -0
  289. data/lib/mxrb/frontend/migrator.rb +2 -0
  290. data/lib/mxrb/functional.rb +47 -43
  291. data/lib/mxrb/github/annotator.rb +31 -27
  292. data/lib/mxrb/http/server.rb +10 -2
  293. data/lib/mxrb/integrity/validator.rb +70 -22
  294. data/lib/mxrb/io/bson_codec.rb +61 -35
  295. data/lib/mxrb/io/mpr_file.rb +638 -105
  296. data/lib/mxrb/io/mxunit_codec.rb +3 -3
  297. data/lib/mxrb/marketplace.rb +77 -73
  298. data/lib/mxrb/modbus/client.rb +162 -0
  299. data/lib/mxrb/modbus/rtu_transport.rb +150 -0
  300. data/lib/mxrb/modbus/stream_io.rb +43 -0
  301. data/lib/mxrb/modbus/tcp_transport.rb +47 -0
  302. data/lib/mxrb/modbus.rb +32 -0
  303. data/lib/mxrb/model/association.rb +28 -28
  304. data/lib/mxrb/model/attribute.rb +51 -35
  305. data/lib/mxrb/model/domain_model.rb +33 -16
  306. data/lib/mxrb/model/entity.rb +80 -70
  307. data/lib/mxrb/model/menu.rb +54 -13
  308. data/lib/mxrb/model/microflow.rb +48 -46
  309. data/lib/mxrb/model/module.rb +85 -42
  310. data/lib/mxrb/model/navigation.rb +232 -9
  311. data/lib/mxrb/model/page.rb +1223 -204
  312. data/lib/mxrb/model/project.rb +61 -15
  313. data/lib/mxrb/model/unit.rb +10 -9
  314. data/lib/mxrb/native_fragment_store.rb +184 -0
  315. data/lib/mxrb/official_marketplace/content_api.rb +13 -1
  316. data/lib/mxrb/official_marketplace/dependency_resolver.rb +6 -1
  317. data/lib/mxrb/official_marketplace/widget_package_installer.rb +2 -1
  318. data/lib/mxrb/oql/server.rb +8 -8
  319. data/lib/mxrb/pluggable/catalog.rb +179 -0
  320. data/lib/mxrb/pluggable/mpr_codec.rb +765 -0
  321. data/lib/mxrb/pluggable/node.rb +347 -0
  322. data/lib/mxrb/pluggable/schema_dsl.rb +179 -0
  323. data/lib/mxrb/pluggable/schema_source_emitter.rb +134 -0
  324. data/lib/mxrb/project_lifecycle.rb +5 -2
  325. data/lib/mxrb/protocols/entry.rb +29 -0
  326. data/lib/mxrb/protocols/registry.rb +59 -0
  327. data/lib/mxrb/protocols.rb +84 -70
  328. data/lib/mxrb/public_source_audit.rb +201 -0
  329. data/lib/mxrb/ruby_app/access_rule_builder.rb +27 -0
  330. data/lib/mxrb/ruby_app/application/offline_synchronization.rb +138 -0
  331. data/lib/mxrb/ruby_app/application/record_access.rb +402 -0
  332. data/lib/mxrb/ruby_app/application/request_handlers.rb +45 -0
  333. data/lib/mxrb/ruby_app/application/schema_security.rb +193 -0
  334. data/lib/mxrb/ruby_app/application/service_invocation.rb +261 -0
  335. data/lib/mxrb/ruby_app/application/session_access.rb +97 -0
  336. data/lib/mxrb/ruby_app/application/value_serialization.rb +148 -0
  337. data/lib/mxrb/ruby_app/application.rb +201 -0
  338. data/lib/mxrb/ruby_app/async_invocations.rb +97 -0
  339. data/lib/mxrb/ruby_app/compilation.rb +64 -0
  340. data/lib/mxrb/ruby_app/constant.rb +99 -0
  341. data/lib/mxrb/ruby_app/controller.rb +112 -0
  342. data/lib/mxrb/ruby_app/dataset.rb +87 -0
  343. data/lib/mxrb/ruby_app/design_classes.rb +177 -0
  344. data/lib/mxrb/ruby_app/design_declarations.rb +193 -0
  345. data/lib/mxrb/ruby_app/domain_rule_builders.rb +123 -0
  346. data/lib/mxrb/ruby_app/enumeration.rb +91 -0
  347. data/lib/mxrb/ruby_app/exporter/data_widget_sources.rb +614 -0
  348. data/lib/mxrb/ruby_app/exporter/document_exports.rb +216 -0
  349. data/lib/mxrb/ruby_app/exporter/domain_behaviors.rb +67 -0
  350. data/lib/mxrb/ruby_app/exporter/domain_manifests.rb +283 -0
  351. data/lib/mxrb/ruby_app/exporter/frontend_pages.rb +161 -0
  352. data/lib/mxrb/ruby_app/exporter/frontend_types.rb +500 -0
  353. data/lib/mxrb/ruby_app/exporter/model_sources.rb +376 -0
  354. data/lib/mxrb/ruby_app/exporter/module_exports.rb +211 -0
  355. data/lib/mxrb/ruby_app/exporter/nanoflow_typescript.rb +590 -0
  356. data/lib/mxrb/ruby_app/exporter/project_files.rb +398 -0
  357. data/lib/mxrb/ruby_app/exporter/support_files.rb +357 -0
  358. data/lib/mxrb/ruby_app/exporter/widget_manifests.rb +134 -0
  359. data/lib/mxrb/ruby_app/exporter/widget_sources.rb +510 -0
  360. data/lib/mxrb/ruby_app/exporter.rb +402 -1565
  361. data/lib/mxrb/ruby_app/file_content.rb +133 -0
  362. data/lib/mxrb/ruby_app/flow_metadata.rb +72 -0
  363. data/lib/mxrb/ruby_app/frontend_package.rb +54 -0
  364. data/lib/mxrb/ruby_app/frontend_template/package-lock.json +4790 -0
  365. data/lib/mxrb/ruby_app/frontend_template/src/app/App.tsx +5 -0
  366. data/lib/mxrb/ruby_app/frontend_template/src/app/router.tsx +18 -0
  367. data/lib/mxrb/ruby_app/frontend_template/src/components/auth/LoginForm.test.tsx +18 -0
  368. data/lib/mxrb/ruby_app/frontend_template/src/components/auth/LoginForm.tsx +80 -0
  369. data/lib/mxrb/ruby_app/frontend_template/src/components/feedback/AppFeedback.tsx +31 -0
  370. data/lib/mxrb/ruby_app/frontend_template/src/components/navigation/AppNavigation.tsx +45 -0
  371. data/lib/mxrb/ruby_app/frontend_template/src/core/errors.ts +3 -0
  372. data/lib/mxrb/ruby_app/frontend_template/src/features/README.md +4 -0
  373. data/lib/mxrb/ruby_app/frontend_template/src/features/routes.tsx +9 -0
  374. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/ApplicationRuntime.test.tsx +174 -0
  375. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/ApplicationRuntime.tsx +959 -0
  376. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/AsyncInvocation.test.ts +61 -0
  377. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/AsyncInvocation.ts +47 -0
  378. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/ClientActions.test.tsx +234 -0
  379. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/ClientEvents.test.tsx +174 -0
  380. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/CreateActions.test.tsx +114 -0
  381. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/OfflineStartup.test.tsx +154 -0
  382. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/PageDataSource.ts +26 -0
  383. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/PageEdits.test.ts +85 -0
  384. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/PageEdits.ts +132 -0
  385. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/PageVariables.test.tsx +107 -0
  386. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/PageVariables.tsx +272 -0
  387. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/PopupRuntime.test.tsx +226 -0
  388. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/StartupAuthentication.test.tsx +101 -0
  389. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/api.ts +35 -0
  390. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/calendar.test.ts +93 -0
  391. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/calendar.ts +134 -0
  392. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/captions.test.tsx +201 -0
  393. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/captions.ts +235 -0
  394. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/clientFunctions.test.ts +195 -0
  395. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/clientFunctions.ts +182 -0
  396. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/clientServices.ts +24 -0
  397. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/commonsStorage.test.ts +77 -0
  398. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/commonsStorage.ts +44 -0
  399. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/BoundField.test.tsx +339 -0
  400. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/BoundField.tsx +442 -0
  401. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/CoreWidgets.test.tsx +306 -0
  402. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/DataGrid.test.tsx +417 -0
  403. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/DataGrid.tsx +944 -0
  404. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/FieldPolicy.test.ts +96 -0
  405. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/FieldPolicy.tsx +106 -0
  406. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/FileWidget.tsx +152 -0
  407. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/GridIcon.tsx +92 -0
  408. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/LanguageSelector.test.tsx +109 -0
  409. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/LanguageSelector.tsx +130 -0
  410. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceChart.test.tsx +580 -0
  411. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceChart.tsx +576 -0
  412. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceControls.test.tsx +192 -0
  413. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceControls.tsx +193 -0
  414. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceDataWidgets.test.tsx +194 -0
  415. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceGridFilter.test.tsx +213 -0
  416. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceGridFilter.tsx +95 -0
  417. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceInteractive.test.tsx +202 -0
  418. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceInteractive.tsx +246 -0
  419. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceLegacy.test.tsx +171 -0
  420. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceLegacy.tsx +189 -0
  421. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceMenus.tsx +114 -0
  422. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplacePlotly.test.tsx +96 -0
  423. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplacePlotly.tsx +162 -0
  424. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceSelection.test.tsx +170 -0
  425. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceSelection.tsx +204 -0
  426. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceTimeline.tsx +116 -0
  427. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceTreeNode.tsx +91 -0
  428. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeDataGrid.tsx +336 -0
  429. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeDataWidgets.test.tsx +233 -0
  430. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeDataWidgets.tsx +288 -0
  431. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeLayout.test.tsx +100 -0
  432. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeLayout.tsx +111 -0
  433. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeScrollContainer.tsx +206 -0
  434. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeSignature.tsx +104 -0
  435. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeWidgets.test.tsx +855 -0
  436. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeWidgets.tsx +1142 -0
  437. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/PageOutlet.test.tsx +74 -0
  438. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/PageOutlet.tsx +63 -0
  439. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/PageTitleContext.ts +7 -0
  440. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/Popup.tsx +181 -0
  441. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/PresentationWidgets.test.tsx +490 -0
  442. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/PresentationWidgets.tsx +566 -0
  443. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/ReferenceSetCombobox.tsx +183 -0
  444. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/SelectionScope.tsx +28 -0
  445. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/TabControl.tsx +88 -0
  446. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/VariableScope.ts +8 -0
  447. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/WidgetRenderer.test.tsx +574 -0
  448. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/WidgetRenderer.tsx +1076 -0
  449. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/autofocus.test.ts +79 -0
  450. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/autofocus.ts +58 -0
  451. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/marketplaceData.ts +126 -0
  452. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/contracts.ts +53 -0
  453. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/dateFormatting.ts +297 -0
  454. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/dateParsing.test.ts +189 -0
  455. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/decimal.test.ts +75 -0
  456. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/decimal.ts +132 -0
  457. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/decimalParsing.test.ts +44 -0
  458. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/decimalParsing.ts +123 -0
  459. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/expression.test.ts +139 -0
  460. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/expression.ts +391 -0
  461. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/expressionClient.test.ts +163 -0
  462. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackCapture.test.ts +75 -0
  463. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackCapture.ts +51 -0
  464. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackCaptureWidget.test.tsx +136 -0
  465. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackCaptureWidget.tsx +79 -0
  466. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackFiles.test.ts +92 -0
  467. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackFiles.ts +84 -0
  468. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackMetadata.test.ts +142 -0
  469. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackMetadata.ts +49 -0
  470. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackStorage.test.ts +110 -0
  471. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackStorage.ts +93 -0
  472. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/legacy/LegacyWidgetHost.tsx +218 -0
  473. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/legacy/amd.ts +104 -0
  474. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/legacy/dojo.ts +474 -0
  475. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/legacy/legacy.test.tsx +518 -0
  476. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/legacy/mx.ts +722 -0
  477. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/legacy/mxGlobal.ts +13 -0
  478. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/legacy/nativeUnavailable.ts +20 -0
  479. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/legacy/session.ts +26 -0
  480. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/listSource.test.tsx +299 -0
  481. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/listSource.ts +177 -0
  482. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/marketplace.tsx +326 -0
  483. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/marketplaceWidgets.json +203 -0
  484. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/marketplaceWidgets.test.tsx +38 -0
  485. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/mendixFilters.test.ts +66 -0
  486. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/mendixFilters.ts +101 -0
  487. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nanoflow.ts +594 -0
  488. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nanoflowCommons.test.ts +89 -0
  489. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nanoflowCommons.ts +57 -0
  490. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nanoflowData.test.ts +199 -0
  491. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nanoflowLists.test.ts +34 -0
  492. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nanoflowOffline.test.ts +130 -0
  493. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nativeMobileActions.test.ts +310 -0
  494. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nativeMobileActions.ts +493 -0
  495. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nativeOnlyJavaScriptActions.test.ts +12 -0
  496. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/objectRestore.test.ts +164 -0
  497. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/objectRestore.ts +123 -0
  498. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/objectStorage.test.ts +179 -0
  499. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/objectStorage.ts +94 -0
  500. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/offlineStore.test.ts +147 -0
  501. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/offlineStore.ts +226 -0
  502. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/plotly.test.ts +55 -0
  503. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/plotly.ts +94 -0
  504. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/pluggableHost.test.tsx +231 -0
  505. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/pluggableHost.tsx +461 -0
  506. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/projectJavaScriptActions.test.ts +158 -0
  507. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/projectJavaScriptActions.ts +91 -0
  508. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/qrCode.test.ts +79 -0
  509. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/qrCode.ts +309 -0
  510. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/schemaLookup.ts +46 -0
  511. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/sort.test.ts +114 -0
  512. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/synchronize.test.ts +167 -0
  513. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/synchronize.ts +156 -0
  514. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/useActionExecution.tsx +100 -0
  515. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/useWidgetEvent.ts +132 -0
  516. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/value.test.ts +89 -0
  517. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/value.ts +319 -0
  518. data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/widgetContract.test.ts +32 -0
  519. data/lib/mxrb/ruby_app/frontend_template/src/layouts/AppLayout.tsx +19 -0
  520. data/lib/mxrb/ruby_app/frontend_template/src/main.tsx +16 -0
  521. data/lib/mxrb/ruby_app/frontend_template/src/plotly.d.ts +4 -0
  522. data/lib/mxrb/ruby_app/frontend_template/src/styles/index.css +1281 -0
  523. data/lib/mxrb/ruby_app/frontend_template/src/test/setup.ts +1 -0
  524. data/lib/mxrb/ruby_app/frontend_template/tsconfig.json +23 -0
  525. data/lib/mxrb/ruby_app/frontend_template/vitest.config.ts +10 -0
  526. data/lib/mxrb/ruby_app/java_actions_package.rb +118 -0
  527. data/lib/mxrb/ruby_app/known_community_commons_actions.rb +316 -0
  528. data/lib/mxrb/ruby_app/known_encryption_actions.rb +162 -0
  529. data/lib/mxrb/ruby_app/known_feedback_widget.rb +43 -0
  530. data/lib/mxrb/ruby_app/known_java_actions.rb +66 -0
  531. data/lib/mxrb/ruby_app/known_javascript_actions.rb +173 -0
  532. data/lib/mxrb/ruby_app/known_mx_model_reflection_actions.rb +353 -0
  533. data/lib/mxrb/ruby_app/known_oql_actions.rb +43 -0
  534. data/lib/mxrb/ruby_app/known_oql_module_actions.rb +101 -0
  535. data/lib/mxrb/ruby_app/known_startup_actions.rb +115 -0
  536. data/lib/mxrb/ruby_app/legacy_service_source_migration.rb +142 -0
  537. data/lib/mxrb/ruby_app/legacy_widget_source_migration.rb +64 -0
  538. data/lib/mxrb/ruby_app/manifest.rb +41 -0
  539. data/lib/mxrb/ruby_app/member_identity.rb +135 -0
  540. data/lib/mxrb/ruby_app/metamodel.rb +197 -0
  541. data/lib/mxrb/ruby_app/module_security.rb +51 -0
  542. data/lib/mxrb/ruby_app/native_bridge.rb +96 -0
  543. data/lib/mxrb/ruby_app/native_edit_patch.rb +69 -0
  544. data/lib/mxrb/ruby_app/page.rb +321 -0
  545. data/lib/mxrb/ruby_app/page_data_sources.rb +184 -0
  546. data/lib/mxrb/ruby_app/page_design_identity.rb +182 -0
  547. data/lib/mxrb/ruby_app/page_edit_bindings.rb +168 -0
  548. data/lib/mxrb/ruby_app/page_edit_contracts.rb +144 -0
  549. data/lib/mxrb/ruby_app/page_edit_properties.rb +93 -0
  550. data/lib/mxrb/ruby_app/page_edit_texts.rb +104 -0
  551. data/lib/mxrb/ruby_app/page_edit_translations.rb +67 -0
  552. data/lib/mxrb/ruby_app/page_edits.rb +662 -0
  553. data/lib/mxrb/ruby_app/page_widget_renames.rb +40 -0
  554. data/lib/mxrb/ruby_app/pluggable_context.rb +149 -0
  555. data/lib/mxrb/ruby_app/pluggable_properties.rb +715 -0
  556. data/lib/mxrb/ruby_app/pluggable_schemas.rb +28 -0
  557. data/lib/mxrb/ruby_app/portability_report.rb +127 -0
  558. data/lib/mxrb/ruby_app/presentation.rb +137 -0
  559. data/lib/mxrb/ruby_app/presentation_contracts.rb +132 -0
  560. data/lib/mxrb/ruby_app/presentation_edits.rb +179 -0
  561. data/lib/mxrb/ruby_app/presentation_exporter.rb +201 -0
  562. data/lib/mxrb/ruby_app/presentation_projection.rb +62 -0
  563. data/lib/mxrb/ruby_app/presentation_references.rb +53 -0
  564. data/lib/mxrb/ruby_app/preset.rb +37 -1
  565. data/lib/mxrb/ruby_app/project_javascript_actions.rb +78 -0
  566. data/lib/mxrb/ruby_app/project_security.rb +200 -0
  567. data/lib/mxrb/ruby_app/project_widget_bundle.rb +74 -0
  568. data/lib/mxrb/ruby_app/rack_adapter.rb +73 -0
  569. data/lib/mxrb/ruby_app/record.rb +388 -0
  570. data/lib/mxrb/ruby_app/record_identity.rb +209 -0
  571. data/lib/mxrb/ruby_app/record_inheritance.rb +65 -0
  572. data/lib/mxrb/ruby_app/record_validation.rb +175 -0
  573. data/lib/mxrb/ruby_app/registry.rb +149 -0
  574. data/lib/mxrb/ruby_app/regular_expression.rb +58 -0
  575. data/lib/mxrb/ruby_app/runtime_catalog.rb +106 -0
  576. data/lib/mxrb/ruby_app/runtime_project.rb +163 -0
  577. data/lib/mxrb/ruby_app/schedule_builder.rb +134 -0
  578. data/lib/mxrb/ruby_app/scheduled_event.rb +59 -0
  579. data/lib/mxrb/ruby_app/security_builders.rb +97 -0
  580. data/lib/mxrb/ruby_app/security_identity.rb +182 -0
  581. data/lib/mxrb/ruby_app/server.rb +436 -0
  582. data/lib/mxrb/ruby_app/service.rb +114 -0
  583. data/lib/mxrb/ruby_app/session_manager.rb +79 -16
  584. data/lib/mxrb/ruby_app/sidecar_services.rb +92 -0
  585. data/lib/mxrb/ruby_app/source_identity.rb +401 -0
  586. data/lib/mxrb/ruby_app/source_reloader.rb +38 -0
  587. data/lib/mxrb/ruby_app/supervisor.rb +139 -0
  588. data/lib/mxrb/ruby_app/synchronizer/document_synchronization.rb +281 -0
  589. data/lib/mxrb/ruby_app/synchronizer/entity_synchronization.rb +239 -0
  590. data/lib/mxrb/ruby_app/synchronizer.rb +127 -0
  591. data/lib/mxrb/ruby_app/thumbnail.rb +54 -0
  592. data/lib/mxrb/ruby_app/widget_styles.rb +73 -0
  593. data/lib/mxrb/ruby_app/widget_support.rb +76 -0
  594. data/lib/mxrb/ruby_app.rb +101 -1299
  595. data/lib/mxrb/runtime/access_control.rb +54 -101
  596. data/lib/mxrb/runtime/calendar_functions.rb +142 -0
  597. data/lib/mxrb/runtime/calendar_ranges.rb +93 -0
  598. data/lib/mxrb/runtime/client_drafts.rb +167 -0
  599. data/lib/mxrb/runtime/clipboard.rb +9 -2
  600. data/lib/mxrb/runtime/constants.rb +66 -0
  601. data/lib/mxrb/runtime/database_workspace.rb +282 -43
  602. data/lib/mxrb/runtime/date_formatting.rb +120 -0
  603. data/lib/mxrb/runtime/date_parse_fields.rb +144 -0
  604. data/lib/mxrb/runtime/date_parse_matchers.rb +39 -0
  605. data/lib/mxrb/runtime/date_parsing.rb +102 -0
  606. data/lib/mxrb/runtime/decimal_formatting.rb +56 -0
  607. data/lib/mxrb/runtime/decimal_parsing.rb +134 -0
  608. data/lib/mxrb/runtime/decimal_values.rb +121 -0
  609. data/lib/mxrb/runtime/docker_executor.rb +15 -14
  610. data/lib/mxrb/runtime/docker_workspace.rb +8 -8
  611. data/lib/mxrb/runtime/enumerations.rb +135 -0
  612. data/lib/mxrb/runtime/executor.rb +25 -25
  613. data/lib/mxrb/runtime/expression_functions.rb +83 -0
  614. data/lib/mxrb/runtime/import_mapping.rb +191 -0
  615. data/lib/mxrb/runtime/java_action_context.rb +224 -0
  616. data/lib/mxrb/runtime/java_http_exchange.rb +33 -0
  617. data/lib/mxrb/runtime/java_regex.rb +244 -0
  618. data/lib/mxrb/runtime/java_sidecar.rb +449 -0
  619. data/lib/mxrb/runtime/languages.rb +85 -0
  620. data/lib/mxrb/runtime/lifecycle.rb +21 -0
  621. data/lib/mxrb/runtime/native.rb +977 -155
  622. data/lib/mxrb/runtime/oql_case_grammar.rb +56 -0
  623. data/lib/mxrb/runtime/oql_datasets.rb +96 -0
  624. data/lib/mxrb/runtime/oql_expression_grammar.rb +128 -0
  625. data/lib/mxrb/runtime/oql_function_grammar.rb +114 -0
  626. data/lib/mxrb/runtime/oql_join_sources.rb +125 -0
  627. data/lib/mxrb/runtime/oql_membership.rb +35 -0
  628. data/lib/mxrb/runtime/oql_module_query.rb +88 -0
  629. data/lib/mxrb/runtime/oql_nesting.rb +51 -0
  630. data/lib/mxrb/runtime/oql_parameters.rb +40 -0
  631. data/lib/mxrb/runtime/oql_predicate.rb +322 -0
  632. data/lib/mxrb/runtime/oql_projection_view.rb +90 -0
  633. data/lib/mxrb/runtime/oql_query_shape.rb +34 -0
  634. data/lib/mxrb/runtime/oql_relational_query.rb +137 -0
  635. data/lib/mxrb/runtime/oql_relational_view.rb +100 -0
  636. data/lib/mxrb/runtime/oql_relations.rb +185 -0
  637. data/lib/mxrb/runtime/oql_scalar.rb +121 -0
  638. data/lib/mxrb/runtime/oql_selection.rb +127 -0
  639. data/lib/mxrb/runtime/oql_selection_terms.rb +50 -0
  640. data/lib/mxrb/runtime/oql_subquery.rb +40 -0
  641. data/lib/mxrb/runtime/oql_subquery_grammar.rb +68 -0
  642. data/lib/mxrb/runtime/oql_table.rb +117 -0
  643. data/lib/mxrb/runtime/oql_table_query.rb +116 -0
  644. data/lib/mxrb/runtime/oql_union.rb +31 -0
  645. data/lib/mxrb/runtime/oql_view_query.rb +62 -0
  646. data/lib/mxrb/runtime/oql_views.rb +107 -0
  647. data/lib/mxrb/runtime/password_policy.rb +59 -0
  648. data/lib/mxrb/runtime/scheduler.rb +61 -10
  649. data/lib/mxrb/runtime/schema_migrator.rb +133 -19
  650. data/lib/mxrb/runtime/sort_order.rb +51 -0
  651. data/lib/mxrb/runtime/sort_path.rb +44 -0
  652. data/lib/mxrb/runtime/sqlite_store.rb +352 -39
  653. data/lib/mxrb/runtime/string_functions.rb +42 -0
  654. data/lib/mxrb/runtime/system_domain.rb +140 -0
  655. data/lib/mxrb/runtime/system_metamodel.rb +48 -0
  656. data/lib/mxrb/runtime/system_metamodel_10.24.0.json +5111 -0
  657. data/lib/mxrb/runtime/system_metamodel_11.12.1.json +5790 -0
  658. data/lib/mxrb/runtime/system_sign_in.rb +53 -0
  659. data/lib/mxrb/runtime/time_zones.rb +85 -0
  660. data/lib/mxrb/runtime/toolchain.rb +16 -16
  661. data/lib/mxrb/runtime/xpath.rb +414 -0
  662. data/lib/mxrb/runtime/xpath_dates.rb +101 -0
  663. data/lib/mxrb/runtime/xpath_functions.rb +82 -0
  664. data/lib/mxrb/scaffold/cli.rb +14 -13
  665. data/lib/mxrb/scaffold/generator.rb +29 -7
  666. data/lib/mxrb/scaffold/help.rb +4 -0
  667. data/lib/mxrb/scaffold/recipes.rb +43 -4
  668. data/lib/mxrb/scaffold/templates.rb +101 -19
  669. data/lib/mxrb/schema/tables.rb +13 -13
  670. data/lib/mxrb/semantic/analyzer.rb +11 -10
  671. data/lib/mxrb/semantic/batch_plan.rb +8 -8
  672. data/lib/mxrb/semantic/domain_mutator.rb +149 -85
  673. data/lib/mxrb/semantic/extractor.rb +74 -75
  674. data/lib/mxrb/semantic/index.rb +86 -88
  675. data/lib/mxrb/semantic/inliner.rb +60 -60
  676. data/lib/mxrb/semantic/mover.rb +7 -7
  677. data/lib/mxrb/semantic/remover.rb +1 -1
  678. data/lib/mxrb/semantic/renamer.rb +23 -22
  679. data/lib/mxrb/settings/model.rb +330 -0
  680. data/lib/mxrb/settings/mpr_codec.rb +157 -0
  681. data/lib/mxrb/settings/source_emitter.rb +105 -0
  682. data/lib/mxrb/settings/value_contracts.rb +141 -0
  683. data/lib/mxrb/stored_fields.rb +86 -0
  684. data/lib/mxrb/studio/artifacts.rb +67 -0
  685. data/lib/mxrb/studio/backend.rb +36 -0
  686. data/lib/mxrb/studio/catalog.rb +249 -0
  687. data/lib/mxrb/studio/data_connections.rb +77 -0
  688. data/lib/mxrb/studio/data_explorer.rb +288 -0
  689. data/lib/mxrb/studio/documents.rb +260 -0
  690. data/lib/mxrb/studio/files.rb +321 -0
  691. data/lib/mxrb/studio/history.rb +181 -0
  692. data/lib/mxrb/studio/isolated.rb +123 -0
  693. data/lib/mxrb/studio/model_operations.rb +304 -0
  694. data/lib/mxrb/studio/parity.json +1019 -0
  695. data/lib/mxrb/studio/parity.rb +75 -0
  696. data/lib/mxrb/studio/preview_comparison.rb +106 -0
  697. data/lib/mxrb/studio/preview_sandbox.rb +142 -0
  698. data/lib/mxrb/studio/preview_sources.rb +80 -0
  699. data/lib/mxrb/studio/preview_worker.rb +23 -0
  700. data/lib/mxrb/studio/protocol.rb +116 -0
  701. data/lib/mxrb/studio/request_context.rb +141 -0
  702. data/lib/mxrb/studio/ruby_document.rb +252 -0
  703. data/lib/mxrb/studio/ruby_document_aggregates.rb +167 -0
  704. data/lib/mxrb/studio/ruby_project.rb +214 -0
  705. data/lib/mxrb/studio/server.rb +145 -0
  706. data/lib/mxrb/studio/service.rb +525 -0
  707. data/lib/mxrb/studio/snapshot.rb +163 -0
  708. data/lib/mxrb/studio/structure.rb +381 -0
  709. data/lib/mxrb/studio/sync.rb +1070 -0
  710. data/lib/mxrb/studio/sync_preview.rb +108 -0
  711. data/lib/mxrb/studio/task_configurations.rb +118 -0
  712. data/lib/mxrb/studio/text_merge.rb +185 -0
  713. data/lib/mxrb/studio/write_lock.rb +87 -0
  714. data/lib/mxrb/studio.rb +4 -0
  715. data/lib/mxrb/studio_compatibility/loss_audit.rb +136 -0
  716. data/lib/mxrb/studio_compatibility.rb +401 -0
  717. data/lib/mxrb/studio_schema_catalog.rb +375 -0
  718. data/lib/mxrb/system_texts.rb +322 -0
  719. data/lib/mxrb/version.rb +1 -1
  720. data/lib/mxrb/web_ui/assets/chunk-2GNONHZU.js +1 -0
  721. data/lib/mxrb/web_ui/assets/chunk-2P46CC5S.js +1 -0
  722. data/lib/mxrb/web_ui/assets/chunk-2SHOE7BM.js +200 -0
  723. data/lib/mxrb/web_ui/assets/chunk-32QEQT5X.js +1 -0
  724. data/lib/mxrb/web_ui/assets/{chunk-5VM5RSS4-ZNzvKenW.js → chunk-34FZNJLO.js} +2 -2
  725. data/lib/mxrb/web_ui/assets/chunk-35N2E2ST.js +88 -0
  726. data/lib/mxrb/web_ui/assets/chunk-3EBRCLBH.js +1 -0
  727. data/lib/mxrb/web_ui/assets/chunk-3F3S4FN6.js +1 -0
  728. data/lib/mxrb/web_ui/assets/chunk-3PZDNKEG.js +1 -0
  729. data/lib/mxrb/web_ui/assets/chunk-3UGOMMAO.js +3 -0
  730. data/lib/mxrb/web_ui/assets/chunk-4NYRXXLN.js +106 -0
  731. data/lib/mxrb/web_ui/assets/chunk-4R2TVXEB.js +1 -0
  732. data/lib/mxrb/web_ui/assets/chunk-4SGPCOHB.js +1 -0
  733. data/lib/mxrb/web_ui/assets/chunk-5BHXSKDK.js +292 -0
  734. data/lib/mxrb/web_ui/assets/chunk-5EVG4O6T.js +1 -0
  735. data/lib/mxrb/web_ui/assets/chunk-5G5NQYC6.js +34 -0
  736. data/lib/mxrb/web_ui/assets/chunk-5HFJOAW4.js +1 -0
  737. data/lib/mxrb/web_ui/assets/chunk-5TNNO4YZ.js +1 -0
  738. data/lib/mxrb/web_ui/assets/chunk-63IIJIEV.js +1 -0
  739. data/lib/mxrb/web_ui/assets/chunk-66OX7QNZ.js +1 -0
  740. data/lib/mxrb/web_ui/assets/chunk-6B4DUFPC.js +1 -0
  741. data/lib/mxrb/web_ui/assets/chunk-6HSV3Q4G.js +1 -0
  742. data/lib/mxrb/web_ui/assets/chunk-6KV64GIT.js +98 -0
  743. data/lib/mxrb/web_ui/assets/chunk-6ZPGWQKV.js +1 -0
  744. data/lib/mxrb/web_ui/assets/chunk-72H3YDZV.js +1 -0
  745. data/lib/mxrb/web_ui/assets/chunk-77A6STIF.js +66 -0
  746. data/lib/mxrb/web_ui/assets/chunk-7B4ZTT6G.js +1 -0
  747. data/lib/mxrb/web_ui/assets/chunk-7E4ON25K.js +7 -0
  748. data/lib/mxrb/web_ui/assets/chunk-7GXBVQXL.js +1 -0
  749. data/lib/mxrb/web_ui/assets/chunk-7ONEZDBB.js +291 -0
  750. data/lib/mxrb/web_ui/assets/chunk-7UWVQTN5.js +1 -0
  751. data/lib/mxrb/web_ui/assets/chunk-AFDXKSZJ.js +2 -0
  752. data/lib/mxrb/web_ui/assets/chunk-BUBLNEPX.js +1 -0
  753. data/lib/mxrb/web_ui/assets/chunk-CBAMBU3T.js +30 -0
  754. data/lib/mxrb/web_ui/assets/chunk-CYCQ4VLZ.js +1 -0
  755. data/lib/mxrb/web_ui/assets/chunk-CYUZI6LQ.js +213 -0
  756. data/lib/mxrb/web_ui/assets/chunk-D246GO7Q.js +1 -0
  757. data/lib/mxrb/web_ui/assets/chunk-DHQUYWHD.js +1 -0
  758. data/lib/mxrb/web_ui/assets/chunk-E2RCGYXT.js +1 -0
  759. data/lib/mxrb/web_ui/assets/chunk-E5A22KZX.js +70 -0
  760. data/lib/mxrb/web_ui/assets/chunk-E64VJRVG.js +1 -0
  761. data/lib/mxrb/web_ui/assets/chunk-EBM2OVIK.js +120 -0
  762. data/lib/mxrb/web_ui/assets/chunk-ELCFKSFF.js +41 -0
  763. data/lib/mxrb/web_ui/assets/chunk-EQTVJ2VI.js +36 -0
  764. data/lib/mxrb/web_ui/assets/chunk-FAGUL7T6.js +1 -0
  765. data/lib/mxrb/web_ui/assets/chunk-FHZHQJRK.js +38 -0
  766. data/lib/mxrb/web_ui/assets/chunk-FUKAUTTF.js +1 -0
  767. data/lib/mxrb/web_ui/assets/chunk-GMUATS3X.js +1 -0
  768. data/lib/mxrb/web_ui/assets/chunk-GVPVJSW7.js +1 -0
  769. data/lib/mxrb/web_ui/assets/chunk-H3FJWUNC.js +1 -0
  770. data/lib/mxrb/web_ui/assets/chunk-H4QZ3SLG.js +257 -0
  771. data/lib/mxrb/web_ui/assets/chunk-H57W7YI5.js +62 -0
  772. data/lib/mxrb/web_ui/assets/chunk-H6EH3XA3.js +1 -0
  773. data/lib/mxrb/web_ui/assets/chunk-HB5VHJFM.js +1 -0
  774. data/lib/mxrb/web_ui/assets/chunk-HCKYS7KE.js +139 -0
  775. data/lib/mxrb/web_ui/assets/chunk-HQBVNVYC.js +39 -0
  776. data/lib/mxrb/web_ui/assets/chunk-HSA6P35M.js +1 -0
  777. data/lib/mxrb/web_ui/assets/chunk-HUYRUGAK.js +135 -0
  778. data/lib/mxrb/web_ui/assets/chunk-I5PKQWBH.js +140 -0
  779. data/lib/mxrb/web_ui/assets/chunk-ID2OERHW.js +1 -0
  780. data/lib/mxrb/web_ui/assets/chunk-IDAIL53S.js +1 -0
  781. data/lib/mxrb/web_ui/assets/chunk-IWZI7GPK.js +1 -0
  782. data/lib/mxrb/web_ui/assets/chunk-IXXNJOS3.js +24 -0
  783. data/lib/mxrb/web_ui/assets/chunk-K5MIAU7K.js +1 -0
  784. data/lib/mxrb/web_ui/assets/chunk-K6CUQC6N.js +136 -0
  785. data/lib/mxrb/web_ui/assets/chunk-KE3NT6QN.js +0 -0
  786. data/lib/mxrb/web_ui/assets/chunk-KI74YC4J.js +72 -0
  787. data/lib/mxrb/web_ui/assets/chunk-KOJL4E5L.js +370 -0
  788. data/lib/mxrb/web_ui/assets/chunk-KPUKEWCZ.js +169 -0
  789. data/lib/mxrb/web_ui/assets/chunk-LEZ2D244.js +2 -0
  790. data/lib/mxrb/web_ui/assets/chunk-LJWZZILO.js +8 -0
  791. data/lib/mxrb/web_ui/assets/chunk-LOYCYQTD.js +24 -0
  792. data/lib/mxrb/web_ui/assets/chunk-M2T56PG5.js +1 -0
  793. data/lib/mxrb/web_ui/assets/chunk-NI5QL3P3.js +2 -0
  794. data/lib/mxrb/web_ui/assets/chunk-NM5LBQV6.js +1 -0
  795. data/lib/mxrb/web_ui/assets/chunk-NNFAPT7B.js +1 -0
  796. data/lib/mxrb/web_ui/assets/chunk-NTAWMNDE.js +7 -0
  797. data/lib/mxrb/web_ui/assets/chunk-NUGW2EXC.js +27 -0
  798. data/lib/mxrb/web_ui/assets/chunk-OKEQR3I2.js +99 -0
  799. data/lib/mxrb/web_ui/assets/chunk-OUPEVUDM.js +1 -0
  800. data/lib/mxrb/web_ui/assets/chunk-OZ3S3DQH.js +1 -0
  801. data/lib/mxrb/web_ui/assets/chunk-PBU4ZVTM.js +1 -0
  802. data/lib/mxrb/web_ui/assets/chunk-PQQBOQJI.js +217 -0
  803. data/lib/mxrb/web_ui/assets/chunk-Q63GKT34.js +1 -0
  804. data/lib/mxrb/web_ui/assets/chunk-QJHVSIW7.js +1 -0
  805. data/lib/mxrb/web_ui/assets/chunk-QMUNJBVF.js +2 -0
  806. data/lib/mxrb/web_ui/assets/chunk-RKTVQ6NQ.js +1 -0
  807. data/lib/mxrb/web_ui/assets/chunk-RQ6DNNSS.js +1 -0
  808. data/lib/mxrb/web_ui/assets/chunk-RVFML3W7.js +1 -0
  809. data/lib/mxrb/web_ui/assets/chunk-S5TKGUWG.js +3 -0
  810. data/lib/mxrb/web_ui/assets/chunk-SBICTFKY.js +2 -0
  811. data/lib/mxrb/web_ui/assets/chunk-SOO7HOBB.js +89 -0
  812. data/lib/mxrb/web_ui/assets/chunk-SQ2BDVUY.js +1 -0
  813. data/lib/mxrb/web_ui/assets/chunk-T5KDILTJ.js +1 -0
  814. data/lib/mxrb/web_ui/assets/chunk-TJ2A3WRV.js +14 -0
  815. data/lib/mxrb/web_ui/assets/chunk-UITAI6UC.js +78 -0
  816. data/lib/mxrb/web_ui/assets/chunk-UL26XZ4V.js +10 -0
  817. data/lib/mxrb/web_ui/assets/chunk-URTGGQPX.js +1 -0
  818. data/lib/mxrb/web_ui/assets/chunk-UZTYCEEY.js +1 -0
  819. data/lib/mxrb/web_ui/assets/chunk-VFXGN725.js +1 -0
  820. data/lib/mxrb/web_ui/assets/chunk-VJRJYCFG.js +84 -0
  821. data/lib/mxrb/web_ui/assets/chunk-W6DARM7I.js +1 -0
  822. data/lib/mxrb/web_ui/assets/chunk-WLRR7NCQ.js +40 -0
  823. data/lib/mxrb/web_ui/assets/chunk-XIMEPMUW.js +32 -0
  824. data/lib/mxrb/web_ui/assets/chunk-XRM2LTMZ.js +4 -0
  825. data/lib/mxrb/web_ui/assets/chunk-Y5TK5PAP.js +62 -0
  826. data/lib/mxrb/web_ui/assets/chunk-ZH3OWPCF.js +339 -0
  827. data/lib/mxrb/web_ui/assets/chunk-ZIHGYIEK.js +1 -0
  828. data/lib/mxrb/web_ui/assets/domain-STH3BZOK.js +1 -0
  829. data/lib/mxrb/web_ui/assets/domain-VYBHNQGI.css +1 -0
  830. data/lib/mxrb/web_ui/assets/modeler-S2X4PVYN.js +1 -0
  831. data/lib/mxrb/web_ui/assets/modeler-SWHOK6BD.css +1 -0
  832. data/lib/mxrb/web_ui/assets/studio/studio-3F773TXK.css +1 -0
  833. data/lib/mxrb/web_ui/assets/studio/studio-DSAUONWT.js +68 -0
  834. data/lib/mxrb/web_ui/assets/uml-6G73GOJ4.css +1 -0
  835. data/lib/mxrb/web_ui/assets/uml-ENRAUICA.js +18 -0
  836. data/lib/mxrb/web_ui/domain.html +1 -3
  837. data/lib/mxrb/web_ui/modeler.html +1 -4
  838. data/lib/mxrb/web_ui/studio.html +5 -0
  839. data/lib/mxrb/web_ui/uml.html +1 -19
  840. data/lib/mxrb/widget_certification.rb +1 -8
  841. data/lib/mxrb/widget_development.rb +57 -0
  842. data/lib/mxrb/widget_package.rb +18 -12
  843. data/lib/mxrb/writer/data_sources.rb +149 -0
  844. data/lib/mxrb/writer/page_overlay.rb +542 -0
  845. data/lib/mxrb/writer.rb +6143 -1598
  846. data/lib/mxrb.rb +198 -158
  847. data/marketplace/modules/shared-kernel/module.rb +1 -1
  848. metadata +729 -108
  849. data/lib/mxrb/web_ui/assets/abnfDiagram-N423BO3Z-C4JD3cEC.js +0 -1
  850. data/lib/mxrb/web_ui/assets/arc-3Z53kgFp.js +0 -1
  851. data/lib/mxrb/web_ui/assets/architecture-TIHT7OUA-BStBTLea.js +0 -1
  852. data/lib/mxrb/web_ui/assets/architectureDiagram-T3A2C74G-DBwqnM4J.js +0 -36
  853. data/lib/mxrb/web_ui/assets/array-BifhSqXX.js +0 -1
  854. data/lib/mxrb/web_ui/assets/blockDiagram-VBNYF7ZC-DLtuHt-j.js +0 -132
  855. data/lib/mxrb/web_ui/assets/c4Diagram-5PPSVZJV-ConSk_pe.js +0 -10
  856. data/lib/mxrb/web_ui/assets/channel-BhPvD7Dt.js +0 -1
  857. data/lib/mxrb/web_ui/assets/chunk-2GRJ4B5K-D2HpWsf_.js +0 -1
  858. data/lib/mxrb/web_ui/assets/chunk-2Q5K7J3B-C1jixKkw.js +0 -1
  859. data/lib/mxrb/web_ui/assets/chunk-4I5QYGJK-CiIdNwaF.js +0 -1
  860. data/lib/mxrb/web_ui/assets/chunk-5RXB4S5H-Bu_AaEkE.js +0 -231
  861. data/lib/mxrb/web_ui/assets/chunk-6Q2QTUOP-wQkNmt_X.js +0 -88
  862. data/lib/mxrb/web_ui/assets/chunk-7BUUIJ7U-Bb538aSH.js +0 -1
  863. data/lib/mxrb/web_ui/assets/chunk-GF5L2VYU-G8MmiBzU.js +0 -206
  864. data/lib/mxrb/web_ui/assets/chunk-I66GZJ75-CulcrLPh.js +0 -127
  865. data/lib/mxrb/web_ui/assets/chunk-JQJVKLGR-ukjzcdlL.js +0 -156
  866. data/lib/mxrb/web_ui/assets/chunk-JWPE2WC7-DVXcaiue.js +0 -1
  867. data/lib/mxrb/web_ui/assets/chunk-KBJHAD2P-Wm35lYov.js +0 -1
  868. data/lib/mxrb/web_ui/assets/chunk-KEIR6QF5-BICK3FdT.js +0 -161
  869. data/lib/mxrb/web_ui/assets/chunk-NSK5VX7P-D2nYrCY4.js +0 -2
  870. data/lib/mxrb/web_ui/assets/chunk-QR6OTTB3-BrdIzg4Q.js +0 -62
  871. data/lib/mxrb/web_ui/assets/chunk-RYQCIY6F-CCfZMcW6.js +0 -1
  872. data/lib/mxrb/web_ui/assets/chunk-UBXNYLIW-BPEVYsFK.js +0 -1
  873. data/lib/mxrb/web_ui/assets/chunk-W5SLKNZC-2E6OPhA4.js +0 -1
  874. data/lib/mxrb/web_ui/assets/chunk-WRU74C26-CBIvOyWp.js +0 -70
  875. data/lib/mxrb/web_ui/assets/chunk-XXDRQBXY-pH58XAyl.js +0 -1
  876. data/lib/mxrb/web_ui/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +0 -1
  877. data/lib/mxrb/web_ui/assets/classDiagram-JCYQIIEL-xiqo4D89.js +0 -1
  878. data/lib/mxrb/web_ui/assets/classDiagram-v2-OCEON4UE-xiqo4D89.js +0 -1
  879. data/lib/mxrb/web_ui/assets/cose-bilkent-JH36ORCC-t_flPpii.js +0 -1
  880. data/lib/mxrb/web_ui/assets/cynefin-VYW2F7L2-BIqktTEv.js +0 -1
  881. data/lib/mxrb/web_ui/assets/cynefinDiagram-MW4NZA55-C2d--lut.js +0 -62
  882. data/lib/mxrb/web_ui/assets/cytoscape.esm-B-NFISlW.js +0 -321
  883. data/lib/mxrb/web_ui/assets/dagre-Buvkdvvj.js +0 -1
  884. data/lib/mxrb/web_ui/assets/dagre-VZM6K2ZE-CSz2_tb5.js +0 -4
  885. data/lib/mxrb/web_ui/assets/defaultLocale-BFoDCU3G.js +0 -1
  886. data/lib/mxrb/web_ui/assets/diagram-7IWD3JNH-DCt7u7V_.js +0 -30
  887. data/lib/mxrb/web_ui/assets/diagram-B4RE2ZJO-DqZBqkMu.js +0 -3
  888. data/lib/mxrb/web_ui/assets/diagram-LBJQPF4R-ClIYbIsI.js +0 -24
  889. data/lib/mxrb/web_ui/assets/diagram-Q27KOJAE-DFxhvthJ.js +0 -24
  890. data/lib/mxrb/web_ui/assets/diagram-UB23O5K3-BSUTXptv.js +0 -41
  891. data/lib/mxrb/web_ui/assets/dist-D2qOEbeJ.js +0 -1
  892. data/lib/mxrb/web_ui/assets/domain-mGOZ1KCG.css +0 -1
  893. data/lib/mxrb/web_ui/assets/domain-qsjXhy4v.js +0 -1
  894. data/lib/mxrb/web_ui/assets/ebnfDiagram-BXEA7PRR-B5reICEi.js +0 -1
  895. data/lib/mxrb/web_ui/assets/erDiagram-JOGREHBK-Co5Mxn2p.js +0 -85
  896. data/lib/mxrb/web_ui/assets/eventmodeling-45OFAUF4-C1ylhSks.js +0 -1
  897. data/lib/mxrb/web_ui/assets/flowDiagram-UKHOOZJN-CHXaJIaS.js +0 -1
  898. data/lib/mxrb/web_ui/assets/ganttDiagram-PKOTCBZU-DPPPaWaz.js +0 -292
  899. data/lib/mxrb/web_ui/assets/gitGraph-TEB2WS4Q-qS77ywA9.js +0 -1
  900. data/lib/mxrb/web_ui/assets/gitGraphDiagram-DS77QQ5N-DpAv6-BT.js +0 -106
  901. data/lib/mxrb/web_ui/assets/graphlib-DS17s2tU.js +0 -1
  902. data/lib/mxrb/web_ui/assets/info-DKCQHKI2-C9VD1Y4e.js +0 -1
  903. data/lib/mxrb/web_ui/assets/infoDiagram-6WML65LV-Bk1kbcCy.js +0 -2
  904. data/lib/mxrb/web_ui/assets/init-C-OQMol4.js +0 -1
  905. data/lib/mxrb/web_ui/assets/ishikawaDiagram-WSZJBQD7-0gcISBFR.js +0 -70
  906. data/lib/mxrb/web_ui/assets/journeyDiagram-NVQOT4AX-Dt0RQnlh.js +0 -139
  907. data/lib/mxrb/web_ui/assets/jsx-runtime-DV0a5kSb.js +0 -9
  908. data/lib/mxrb/web_ui/assets/kanban-definition-27J2QSJJ-DIPQM7w9.js +0 -89
  909. data/lib/mxrb/web_ui/assets/katex-CXMH3UgJ.js +0 -257
  910. data/lib/mxrb/web_ui/assets/line-C0rYD-tL.js +0 -1
  911. data/lib/mxrb/web_ui/assets/linear-BPPxWorj.js +0 -1
  912. data/lib/mxrb/web_ui/assets/map-BaFkSB1l.js +0 -1
  913. data/lib/mxrb/web_ui/assets/mermaid-parser.core-B_UPzTxa.js +0 -7
  914. data/lib/mxrb/web_ui/assets/mindmap-definition-FAOFIHXS-CdJRSMuk.js +0 -96
  915. data/lib/mxrb/web_ui/assets/modeler-BNqHthwk.css +0 -1
  916. data/lib/mxrb/web_ui/assets/modeler-CQmqflbg.js +0 -1
  917. data/lib/mxrb/web_ui/assets/ordinal-BDEzSJ7C.js +0 -1
  918. data/lib/mxrb/web_ui/assets/packet-7NZHBO7P-CwQ4NSBs.js +0 -1
  919. data/lib/mxrb/web_ui/assets/path-fybaL0A-.js +0 -1
  920. data/lib/mxrb/web_ui/assets/pegDiagram-VL7TDLO6-D40S7ppx.js +0 -1
  921. data/lib/mxrb/web_ui/assets/pie-RZYD4A2V-CJroHMKh.js +0 -1
  922. data/lib/mxrb/web_ui/assets/pieDiagram-7S7Q4E2Y-QB54__BV.js +0 -39
  923. data/lib/mxrb/web_ui/assets/quadrantDiagram-CIZ2JOQS-DBhDS6ag.js +0 -7
  924. data/lib/mxrb/web_ui/assets/radar-I7S5WNFK-DdIUwd2d.js +0 -1
  925. data/lib/mxrb/web_ui/assets/railroad-3IZDKUUU-B1Lw6Xyq.js +0 -1
  926. data/lib/mxrb/web_ui/assets/railroad-abnf-AHOZXSZD-CQgQoeak.js +0 -1
  927. data/lib/mxrb/web_ui/assets/railroad-ebnf-EBAXGLYW-D7qEQ2x8.js +0 -1
  928. data/lib/mxrb/web_ui/assets/railroad-peg-LSFZ7HO6-C005Vxbb.js +0 -1
  929. data/lib/mxrb/web_ui/assets/railroadDiagram-AXF67PYL-BBP2qk7M.js +0 -1
  930. data/lib/mxrb/web_ui/assets/requirementDiagram-LRYGKXZP-D2cLsAoI.js +0 -84
  931. data/lib/mxrb/web_ui/assets/rough.esm-Dy-Kn_BL.js +0 -1
  932. data/lib/mxrb/web_ui/assets/sankeyDiagram-W5VNT64P-Bpi3FiP2.js +0 -40
  933. data/lib/mxrb/web_ui/assets/sequenceDiagram-SI44F4Z6-DCRcDlVe.js +0 -162
  934. data/lib/mxrb/web_ui/assets/sizeCapture-X5ZJPWSS-B0uUizjq.js +0 -1
  935. data/lib/mxrb/web_ui/assets/src-CvxfUak2.js +0 -1
  936. data/lib/mxrb/web_ui/assets/stateDiagram-OKZ733FA-C2GCEoxl.js +0 -1
  937. data/lib/mxrb/web_ui/assets/stateDiagram-v2-UEYNNEHI-D2gWgedh.js +0 -1
  938. data/lib/mxrb/web_ui/assets/swimlanes-SLNWSIFB-CRI9irEW.js +0 -2
  939. data/lib/mxrb/web_ui/assets/swimlanesDiagram-ULZ7WXOC-C5Wb_-hZ.js +0 -8
  940. data/lib/mxrb/web_ui/assets/theme-_mxc7BdY.css +0 -1
  941. data/lib/mxrb/web_ui/assets/timeline-definition-Z64GVDOM-B1-mNg-h.js +0 -120
  942. data/lib/mxrb/web_ui/assets/treeView-QDETBFTQ-7CTvIwKq.js +0 -1
  943. data/lib/mxrb/web_ui/assets/treemap-6X3UGDF4-CtL22pq5.js +0 -1
  944. data/lib/mxrb/web_ui/assets/uml-C3KAFGTq.js +0 -51
  945. data/lib/mxrb/web_ui/assets/uml-Dn-qd01X.css +0 -1
  946. data/lib/mxrb/web_ui/assets/vennDiagram-T6HMQDX7-BzVnUEAy.js +0 -34
  947. data/lib/mxrb/web_ui/assets/wardley-OPB4EBWU-JNi-QNag.js +0 -1
  948. data/lib/mxrb/web_ui/assets/wardleyDiagram-T6FBY63Y-BUwmAQ-B.js +0 -78
  949. data/lib/mxrb/web_ui/assets/xychartDiagram-ELKLHX3M-DEQS8sKp.js +0 -7
@@ -1,8 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'base64'
3
4
  require 'digest'
4
5
  require 'fileutils'
6
+ require 'find'
5
7
  require 'json'
8
+ require 'pp'
9
+ require 'time'
10
+ require 'tmpdir'
11
+ require_relative '../native_fragment_store'
12
+ require_relative 'legacy_service_source_migration'
13
+ require_relative 'legacy_widget_source_migration'
14
+ require_relative 'exporter/domain_behaviors'
15
+ require_relative 'exporter/module_exports'
16
+ require_relative 'exporter/domain_manifests'
17
+ require_relative 'exporter/nanoflow_typescript'
18
+ require_relative 'exporter/frontend_pages'
19
+ require_relative 'exporter/document_exports'
20
+ require_relative 'exporter/widget_manifests'
21
+ require_relative 'exporter/model_sources'
22
+ require_relative 'exporter/widget_sources'
23
+ require_relative 'exporter/data_widget_sources'
24
+ require_relative 'exporter/support_files'
25
+ require_relative 'exporter/project_files'
26
+ require_relative 'exporter/frontend_types'
27
+ require_relative 'known_javascript_actions'
28
+ require_relative 'known_feedback_widget'
29
+ require_relative 'project_widget_bundle'
30
+ require_relative 'project_javascript_actions'
6
31
 
7
32
  module Mxrb
8
33
  module RubyApp
@@ -10,18 +35,34 @@ module Mxrb
10
35
  # retaining the complete Mendix-mode tree as the reversible sidecar.
11
36
  # rubocop:disable Metrics
12
37
  class Exporter
13
- REST_STATUS_CODES = {
14
- 'ok' => 200, 'created' => 201, 'accepted' => 202,
15
- 'nocontent' => 204, 'movedpermanently' => 301, 'found' => 302,
16
- 'badrequest' => 400, 'unauthorized' => 401, 'forbidden' => 403,
17
- 'notfound' => 404, 'conflict' => 409, 'internalservererror' => 500
18
- }.freeze
38
+ include DomainBehaviors
39
+ include ModuleExports
40
+ include DomainManifests
41
+ include NanoflowTypescript
42
+ include FrontendPages
43
+ include DocumentExports
44
+ include WidgetManifests
45
+ include ModelSources
46
+ include WidgetSources
47
+ include DataWidgetSources
48
+ include SupportFiles
49
+ include ProjectFiles
50
+ include FrontendTypes
51
+
52
+ FRONTEND_TEMPLATE_DIR = File.expand_path('frontend_template', __dir__)
19
53
  RUBY_KEYWORDS = %w[
20
54
  alias and begin break case class def defined do else elsif end ensure false
21
55
  for if in module next nil not or redo rescue retry return self super then
22
56
  true undef unless until when while yield
23
57
  ].freeze
24
58
  RECORD_RESERVED = %w[attributes id initialize mendix_id mendix_name to_h type].freeze
59
+ LEGACY_PUBLIC_PROJECTION_PATH = %r{\Aapp/(?:
60
+ constants|dtos|enumerations|models|pages|scheduled_events|security|services
61
+ )/.+\.rb\z}x
62
+ LEGACY_PUBLIC_IDENTITY = /^\s*(?:
63
+ mendix_name\s+['"][^'"]+['"],\s+id: |
64
+ mendix_id\s+['"]
65
+ )/x
25
66
 
26
67
  def initialize(mpr_path, output_dir, mendix_sidecar:)
27
68
  @mpr_path = File.expand_path(mpr_path)
@@ -31,27 +72,81 @@ module Mxrb
31
72
 
32
73
  def export!
33
74
  FileUtils.mkdir_p(@output_dir)
75
+ @native_fragment_store = NativeFragmentStore.new(
76
+ File.join(@output_dir, '.mxrb', 'native_fragments')
77
+ )
78
+ @rest_response_metadata = read_rest_response_metadata
34
79
  runtime_mpr = copy_runtime_mpr
35
80
  embedded_sources = read_embedded_sources
81
+ @embedded_sources = embedded_sources
82
+ @embedded_source_paths = embedded_sources.to_h { [_1.fetch(:path), true] }
83
+ @embedded_identities = SourceIdentity.read_bundle(embedded_sources).to_h do |identity|
84
+ [[identity.fetch('kind'), identity.fetch('id')], identity]
85
+ end
86
+ require_relative 'presentation_exporter'
36
87
  Mxrb.open(@mpr_path) do |project|
37
88
  @project = project
89
+ @known_entity_names = project.modules.flat_map do |mod|
90
+ mod.entities.map { "#{mod.name}.#{_1.name}" }
91
+ end.freeze
38
92
  @coverage = []
39
93
  @nanoflow_entries = []
40
- modules = project.modules.map { export_module(_1) }
94
+ @page_entries = []
95
+ @rendered_widget_ids = Set.new
96
+ @called_javascript_actions = Set.new
97
+ modules = PluggableProperties.with_mpr(project.mpr) do |context|
98
+ result = project.modules.map { export_module(_1) }
99
+ PresentationExporter.new(self, project).export!
100
+ context.export_schemas(@output_dir)
101
+ result
102
+ end
103
+ @security_manifest = export_project_security(project)
41
104
  @module_manifests = modules
42
105
  write_support_files
106
+ copy_round_trip_metadata
107
+ write_design_classes(project)
108
+ @widget_ids = WidgetStyles.widget_ids(project)
43
109
  copy_frontend_theme
44
110
  restore_embedded_sources(embedded_sources)
111
+ refresh_native_frontend_sources(project, modules, embedded_sources)
112
+ write_page_baselines(modules)
45
113
  write_manifest(project, modules, runtime_mpr)
46
114
  end
47
115
  @output_dir
48
116
  ensure
49
117
  @project = nil
118
+ @embedded_sources = nil
119
+ @embedded_source_paths = nil
120
+ @embedded_identities = nil
50
121
  @module_manifests = nil
122
+ @security_manifest = nil
123
+ @known_entity_names = nil
124
+ @native_fragment_store = nil
125
+ @rest_response_metadata = nil
51
126
  end
52
127
 
53
128
  private
54
129
 
130
+ # Shared presentation emits typed Forms or inline legacy declarations.
131
+ # Decoding fragments are intermediate values, not exported dependencies.
132
+ def with_presentation_fragments
133
+ previous = @native_fragment_store
134
+ Dir.mktmpdir('mxrb-presentation-fragments-') do |directory|
135
+ @native_fragment_store = NativeFragmentStore.new(directory)
136
+ yield
137
+ end
138
+ ensure
139
+ @native_fragment_store = previous
140
+ end
141
+
142
+ # Taken after embedded sources are restored: the document already holds their edits.
143
+ def write_page_baselines(modules)
144
+ modules.flat_map { _1.fetch('pages') }.each do |page|
145
+ PageEdits.write_baseline(@output_dir, page.fetch('id'), File.join(@output_dir, page.fetch('path')))
146
+ end
147
+ PresentationEdits.write_baselines(@output_dir)
148
+ end
149
+
55
150
  def read_embedded_sources
56
151
  mpr = IO::MprFile.open(@mpr_path, readonly: true)
57
152
  mpr.ruby_app_sources
@@ -59,487 +154,330 @@ module Mxrb
59
154
  mpr&.close
60
155
  end
61
156
 
157
+ def read_rest_response_metadata
158
+ path = File.join(@mendix_sidecar, '.mxrb', 'rest_metadata.json')
159
+ return [] unless File.file?(path)
160
+
161
+ JSON.parse(File.read(path)).fetch('operations')
162
+ rescue JSON::ParserError, KeyError => e
163
+ raise SerializationError, "invalid REST metadata sidecar #{path}: #{e.message}"
164
+ end
165
+
166
+ def embedded_identity(kind, id)
167
+ identity = @embedded_identities&.fetch([kind.to_s, id.to_s], nil)
168
+ identity if identity && @embedded_source_paths&.key?(identity.fetch('path'))
169
+ end
170
+
171
+ def embedded_identity_path(kind, id)
172
+ embedded_identity(kind, id)&.fetch('path')
173
+ end
174
+
175
+ def embedded_identity_class(kind, id, fallback)
176
+ name = embedded_identity(kind, id)&.fetch('ruby_class', nil).to_s
177
+ name.empty? ? fallback : name
178
+ end
179
+
62
180
  def restore_embedded_sources(files)
63
181
  files.each do |file|
182
+ next if file.fetch(:path).start_with?('frontend/src/generated/')
183
+
64
184
  contents = file.fetch(:contents)
65
185
  checksum = Digest::SHA256.hexdigest(contents)
66
186
  raise SerializationError, "embedded Ruby source checksum mismatch: #{file.fetch(:path)}" \
67
187
  unless checksum == file.fetch(:sha256)
68
188
 
189
+ contents = LegacyServiceSourceMigration.new(
190
+ path: file.fetch(:path), source: contents
191
+ ).migrate
192
+
69
193
  path = RubyApp.safe_source_path(@output_dir, file.fetch(:path))
70
194
  FileUtils.mkdir_p(File.dirname(path))
195
+ if regenerate_legacy_public_projection?(file.fetch(:path), contents, path)
196
+ File.chmod(RubyApp.safe_source_mode(file[:mode], file.fetch(:path)), path)
197
+ next
198
+ end
199
+ if regenerate_legacy_widget_page?(file, path)
200
+ File.chmod(RubyApp.safe_source_mode(file[:mode], file.fetch(:path)), path)
201
+ next
202
+ end
203
+
71
204
  File.binwrite(path, contents)
72
205
  File.chmod(RubyApp.safe_source_mode(file[:mode], file.fetch(:path)), path)
73
206
  end
74
207
  end
75
208
 
76
- def copy_runtime_mpr
77
- directory = File.join(@output_dir, '.mxrb', 'runtime')
78
- FileUtils.mkdir_p(directory)
79
- destination = File.join(directory, File.basename(@mpr_path))
80
- FileUtils.cp(@mpr_path, destination)
81
- source_contents = File.join(File.dirname(@mpr_path), 'mprcontents')
82
- FileUtils.cp_r(source_contents, directory, remove_destination: true) if File.directory?(source_contents)
83
- destination
84
- end
209
+ def regenerate_legacy_public_projection?(relative, embedded, generated)
210
+ return false unless LEGACY_PUBLIC_PROJECTION_PATH.match?(relative)
211
+ return false unless File.file?(generated) && embedded.match?(LEGACY_PUBLIC_IDENTITY)
85
212
 
86
- def export_module(mod)
87
- namespace = ruby_constant(mod.name)
88
- root = underscore(mod.name)
89
- entities = mod.entities.map { export_entity(_1, mod, namespace, root) }
90
- microflows = mod.microflows.map { export_service(_1, mod, namespace, root, :microflow) }
91
- nanoflows = mod.nanoflows.map { export_nanoflow(_1, mod, root) }
92
- pages = mod.pages.map { export_page(_1, mod, namespace, root) }
93
- endpoints = export_endpoints(mod)
94
- {
95
- 'name' => mod.name, 'ruby_namespace' => namespace,
96
- 'module_roles' => runtime_value(mod.module_roles),
97
- 'models' => entities.reject { _1['dto'] },
98
- 'dtos' => entities.select { _1['dto'] },
99
- 'services' => microflows, 'nanoflows' => nanoflows, 'pages' => pages,
100
- 'endpoints' => endpoints,
101
- 'enumerations' => mod.enumerations.map { enumeration_manifest(mod, _1) },
102
- 'associations' => mod.associations.map { association_manifest(mod, _1) },
103
- 'scheduled_events' => mod.scheduled_events.map { runtime_value(_1) }
104
- }
105
- end
213
+ definitions = embedded.scan(/^\s*def\s+(?:self\.)?([^\s(]+)/).flatten
214
+ return true if definitions.empty?
215
+ return false unless relative.start_with?('app/services/') && definitions == ['call']
106
216
 
107
- def export_entity(entity, mod, namespace, root)
108
- dto = !entity.persistable && !entity.oql_view?
109
- class_name = ruby_constant(entity.name, suffix: dto ? 'Dto' : nil)
110
- base_name = underscore(entity.name)
111
- base_name = "#{base_name}_dto" if dto && !base_name.end_with?('_dto')
112
- category = dto ? 'dtos' : 'models'
113
- relative = File.join('app', category, root, "#{base_name}.rb")
114
- qualified = "#{mod.name}.#{entity.name}"
115
- attributes = entity.attributes.map { attribute_manifest(_1) }
116
- write(
117
- relative,
118
- entity_source(
119
- namespace, class_name, qualified, entity.id, attributes,
120
- dto:, persistable: entity.persistable == true
121
- )
217
+ embedded.match?(
218
+ /def\s+call\(\*\*arguments\)\s+(?:native_call|execute_flow)\(arguments\)\s+end/m
122
219
  )
123
- add_coverage(entity.id, qualified, dto ? 'dto' : 'model', relative, 'executable_bidirectional')
124
- {
125
- 'name' => qualified, 'id' => entity.id, 'ruby_class' => "#{namespace}::#{class_name}",
126
- 'path' => relative, 'dto' => dto, 'persistable' => entity.persistable == true,
127
- 'attributes' => attributes,
128
- 'system_members' => runtime_value(entity.system_members || {}),
129
- 'access_rules' => runtime_value(entity.access_rules || []),
130
- 'lifecycle' => runtime_value(entity.respond_to?(:lifecycle) ? entity.lifecycle : [])
131
- }
132
220
  end
133
221
 
134
- def association_manifest(mod, association)
135
- entities = @project.modules.flat_map do |project_module|
136
- project_module.entities.map do |entity|
137
- [entity.id.to_s, "#{project_module.name}.#{entity.name}"]
138
- end
139
- end.to_h
140
- {
141
- 'name' => "#{mod.name}.#{association.name}", 'id' => association.id,
142
- 'type' => association.association_type.to_s,
143
- 'from_entity' => entities[association.from_entity_id.to_s] || association.from_entity_id.to_s,
144
- 'to_entity' => entities[association.to_entity_id.to_s] || association.to_entity_id.to_s
145
- }
146
- end
222
+ def regenerate_legacy_widget_page?(file, generated_path)
223
+ return false unless File.file?(generated_path)
147
224
 
148
- def export_service(flow, mod, namespace, root, kind)
149
- class_name = ruby_constant(flow.name)
150
- relative = File.join('app', 'services', root, "#{underscore(flow.name)}.rb")
151
- qualified = "#{mod.name}.#{flow.name}"
152
- write(relative, service_source(namespace, class_name, qualified, flow.id))
153
- add_coverage(flow.id, qualified, kind.to_s, relative, 'runtime_source_preserved')
154
- {
155
- 'name' => qualified, 'id' => flow.id,
156
- 'ruby_class' => "#{namespace}::#{class_name}", 'path' => relative,
157
- 'kind' => kind.to_s, 'parameters' => flow.parameters.map { flow_parameter_manifest(_1) },
158
- 'allowed_module_roles' => flow.allowed_module_roles.map(&:to_s)
159
- }
225
+ LegacyWidgetSourceMigration.new(
226
+ path: file.fetch(:path), embedded_source: file.fetch(:contents),
227
+ generated_source: File.binread(generated_path)
228
+ ).regenerate?
160
229
  end
161
230
 
162
- def flow_parameter_manifest(parameter)
163
- variable_type = parameter['VariableType'] || parameter['Type'] || {}
164
- {
165
- 'name' => parameter['Name'].to_s,
166
- 'type' => variable_type['$Type'].to_s,
167
- 'entity' => variable_type['Entity'],
168
- 'required' => parameter['IsRequired'] != false
169
- }.compact
170
- end
231
+ # Generated frontend projections normally remain user-editable and are
232
+ # restored byte-for-byte. A Ruby class with an explicit `native`
233
+ # declaration is authoritative, though, so its page/nanoflow projection
234
+ # must be refreshed from the just-compiled MPR instead of reviving stale
235
+ # TypeScript from the previous round trip.
236
+ def refresh_native_frontend_sources(project, modules, embedded_sources)
237
+ names = embedded_native_document_names(embedded_sources)
238
+ return if names.empty?
171
239
 
172
- def export_endpoints(mod)
173
- mod.infrastructure_documents.filter_map do |document|
174
- next unless document[:type] == 'Rest$PublishedRestService'
240
+ modules.each do |mod|
241
+ root = underscore(mod.fetch('name'))
242
+ mod.fetch('pages').each do |page|
243
+ next unless names.include?(page.fetch('name'))
175
244
 
176
- rest_service_manifest(mod, document)
177
- end
178
- end
179
-
180
- def rest_service_manifest(mod, document)
181
- source = document.fetch(:doc)
182
- operations = IO::BsonCodec.parse_array(source['Resources'])[:items].flat_map do |resource|
183
- IO::BsonCodec.parse_array(resource['Operations'])[:items].map do |operation|
184
- rest_operation_manifest(mod, source, resource, operation)
245
+ page_name = page.fetch('name').split('.', 2).last
246
+ export_frontend_page(page, root, page_name)
247
+ @page_entries.pop
185
248
  end
186
249
  end
187
- add_coverage(
188
- document.fetch(:id), "#{mod.name}.#{document.fetch(:name)}", 'published_rest_service',
189
- relative(@mendix_sidecar), 'executable_backend_route'
190
- )
191
- {
192
- 'name' => "#{mod.name}.#{document.fetch(:name)}", 'path' => source['Path'].to_s,
193
- 'version' => source['Version'].to_s, 'enable_cors' => source['EnableCors'] == true,
194
- 'requires_authentication' => source['RequiresAuthentication'] == true,
195
- 'operations' => operations
196
- }
197
- end
198
-
199
- def rest_operation_manifest(mod, service, resource, operation)
200
- microflow = operation['Microflow'].to_s
201
- microflow = "#{mod.name}.#{microflow}" unless microflow.empty? || microflow.include?('.')
202
- service_path = service['Path'].to_s.sub(%r{\A/+}, '').sub(%r{/+\z}, '')
203
- operation_path = operation['Path'].to_s.sub(%r{\A/+}, '')
204
- {
205
- 'name' => resource['Name'].to_s, 'method' => operation['HttpMethod'].to_s.upcase,
206
- 'path' => "/#{[service_path, operation_path].reject(&:empty?).join('/')}",
207
- 'microflow' => microflow, 'success_status' => rest_success_status(operation['SuccessStatusCode'])
208
- }
209
- end
210
-
211
- def rest_success_status(value)
212
- return 200 if value.nil? || value.to_s.empty?
213
-
214
- raw = value.is_a?(Hash) ? (value['Value'] || value['Name'] || value['$Type']) : value
215
- integer = raw.to_s[/\d{3}/]
216
- return integer.to_i if integer
217
-
218
- REST_STATUS_CODES.fetch(raw.to_s.gsub(/[^A-Za-z]/, '').downcase, 200)
219
- end
220
-
221
- def export_nanoflow(flow, mod, root)
222
- qualified = "#{mod.name}.#{flow.name}"
223
- relative = File.join('frontend', 'src', 'nanoflows', root, "#{underscore(flow.name)}.ts")
224
- plan = nanoflow_plan(flow, qualified)
225
- write(
226
- relative,
227
- "import type { NanoflowPlan } from '../../types';\n\n" \
228
- "export default #{JSON.pretty_generate(plan)} satisfies NanoflowPlan;\n"
229
- )
230
- entry = {
231
- 'name' => qualified, 'id' => flow.id, 'path' => relative,
232
- 'kind' => 'nanoflow', 'runtime' => 'frontend'
233
- }
234
- @nanoflow_entries << entry.merge('import_name' => "Nanoflow#{@nanoflow_entries.size}")
235
- add_coverage(flow.id, qualified, 'nanoflow', relative, 'frontend_executable')
236
- entry
237
- end
238
-
239
- def nanoflow_plan(flow, qualified)
240
- {
241
- 'name' => qualified, 'id' => flow.id,
242
- 'parameters' => flow.parameters.filter_map { _1['Name'] if _1.is_a?(Hash) },
243
- 'objects' => flow.objects.filter_map { nanoflow_object(_1) },
244
- 'flows' => flow.flows.reject { _1['IsErrorHandler'] == true }.map do |edge|
245
- {
246
- 'origin' => native_identifier(edge['OriginPointer']),
247
- 'destination' => native_identifier(edge['DestinationPointer']),
248
- 'case' => nanoflow_case(edge)
249
- }
250
- end
251
- }
252
- end
253
-
254
- def nanoflow_object(object)
255
- return unless object.is_a?(Hash)
256
-
257
- type = object['$Type'].to_s.delete_prefix('Microflows$')
258
- result = { 'id' => native_identifier(object), 'type' => type }
259
- result['return'] = object['ReturnValue'].to_s if type == 'EndEvent'
260
- result['condition'] = object.dig('SplitCondition', 'Expression').to_s if type == 'ExclusiveSplit'
261
- result['action'] = nanoflow_action(object['Action']) if type == 'ActionActivity'
262
- result
263
- end
264
-
265
- def nanoflow_action(action)
266
- return {} unless action.is_a?(Hash)
267
-
268
- type = action['$Type'].to_s.delete_prefix('Microflows$').delete_suffix('Action')
269
- result = { 'type' => type }
270
- case type
271
- when 'CreateVariable'
272
- result.merge!('variable' => action['VariableName'].to_s, 'value' => action['InitialValue'].to_s)
273
- when 'ChangeVariable'
274
- result.merge!('variable' => action['ChangeVariableName'].to_s, 'value' => action['Value'].to_s)
275
- when 'Change'
276
- changes = native_items(action['Items']).map do |item|
277
- member = (item['Attribute'].to_s.empty? ? item['Association'] : item['Attribute']).to_s
278
- { 'member' => member.split(%r{[./]}).last, 'value' => item['Value'].to_s }
250
+ project.modules.each do |mod|
251
+ root = underscore(mod.name)
252
+ mod.nanoflows.each do |flow|
253
+ qualified = "#{mod.name}.#{flow.name}"
254
+ next unless names.include?(qualified)
255
+
256
+ relative = File.join(
257
+ 'frontend', 'src', 'generated', 'nanoflows', root, "#{underscore(flow.name)}.ts"
258
+ )
259
+ write(relative, nanoflow_typescript(flow, qualified))
279
260
  end
280
- result.merge!('variable' => action['ChangeVariableName'].to_s, 'changes' => changes)
281
- when 'LogMessage'
282
- result['message'] = action.dig('MessageTemplate', 'Text').to_s
283
261
  end
284
- result
262
+ write_generated_frontend_contract
285
263
  end
286
264
 
287
- def nanoflow_case(edge)
288
- value = native_items(edge['CaseValues']).first || edge['NewCaseValue'] || {}
289
- value['$Type'] == 'Microflows$NoCase' ? '' : value['Value'].to_s
290
- end
265
+ def embedded_native_document_names(files)
266
+ files.filter_map do |file|
267
+ next unless file.fetch(:path).match?(%r{\Aapp/(?:pages|services)/.+\.rb\z})
291
268
 
292
- def native_items(value)
293
- IO::BsonCodec.parse_array(value)[:items]
294
- rescue StandardError
295
- Array(value).drop(value.is_a?(Array) && value.first.is_a?(Integer) ? 1 : 0)
296
- end
269
+ source = file.fetch(:contents).to_s
270
+ next unless source.match?(/^\s*native(?:\s|\()/)
297
271
 
298
- def native_identifier(value)
299
- IO::BsonCodec.extract_id(value.is_a?(Hash) ? value['$ID'] : value).to_s
272
+ match = source.match(/^\s*mendix_name\s+(['"])([^'"]+)\1/)
273
+ match && match[2]
274
+ end.uniq
300
275
  end
301
276
 
302
- def export_page(page, mod, namespace, root)
303
- class_name = ruby_constant(page.name, suffix: 'Page')
304
- relative = File.join('app', 'pages', root, "#{underscore(page.name)}_page.rb")
305
- qualified = "#{mod.name}.#{page.name}"
306
- widgets = page.widgets.map { widget_manifest(_1) }
307
- write(
308
- relative,
309
- page_source(namespace, class_name, qualified, page.id, page.title, widgets,
310
- appearance_class: page.appearance_class,
311
- appearance_style: page.appearance_style,
312
- data_source: page.data_source)
313
- )
314
- add_coverage(page.id, qualified, 'page', relative, 'native_projection_source_preserved')
315
- {
316
- 'name' => qualified, 'id' => page.id, 'title' => page.title,
317
- 'ruby_class' => "#{namespace}::#{class_name}", 'path' => relative,
318
- 'appearance_class' => page.appearance_class,
319
- 'appearance_style' => page.appearance_style,
320
- 'data_source' => page.data_source,
321
- 'allowed_module_roles' => page.allowed_module_roles.map(&:to_s),
322
- 'widgets' => widgets
323
- }
324
- end
325
-
326
- def attribute_manifest(attribute)
327
- value = {
328
- 'name' => attribute.name, 'ruby_name' => ruby_method_name(attribute.name),
329
- 'type' => attribute.type.to_s, 'required' => attribute.required == true,
330
- 'default' => attribute.default_value, 'id' => attribute.id
331
- }
332
- enumeration = native_identifier(attribute.respond_to?(:enumeration) ? attribute.enumeration : nil)
333
- value['enumeration'] = enumeration unless enumeration.empty?
334
- value
335
- end
336
-
337
- def enumeration_manifest(mod, enumeration)
338
- name = enumeration['Name'].to_s
339
- {
340
- 'name' => "#{mod.name}.#{name}",
341
- 'id' => native_identifier(enumeration['$ID']),
342
- 'values' => native_items(enumeration['Values']).map do |value|
343
- value_name = value['Name'].to_s
344
- { 'name' => value_name, 'caption' => translated_caption(value['Caption'], value_name) }
345
- end
346
- }
347
- end
348
-
349
- def translated_caption(caption, fallback)
350
- translation = native_items(caption.is_a?(Hash) ? caption['Items'] : nil).first
351
- text = translation.is_a?(Hash) ? translation['Text'].to_s : ''
352
- text.empty? ? fallback : text
353
- end
354
-
355
- def widget_manifest(widget)
356
- options = runtime_value(widget.fetch(:options, {}))
357
- value = { 'type' => runtime_widget_type(widget), 'name' => widget.fetch(:name, '').to_s }
358
- value['options'] = options unless options.empty?
359
- caption = options['caption']
360
- value['caption'] = caption unless caption.to_s.empty?
361
- events = runtime_value(widget.fetch(:events, []))
362
- value['events'] = events unless events.empty?
363
- children = Array(widget[:children]).map { widget_manifest(_1) }
364
- value['children'] = children unless children.empty?
365
- value
366
- end
367
-
368
- def runtime_widget_type(widget)
369
- type = widget.fetch(:type).to_s
370
- return type unless type == 'text_box'
371
-
372
- path = widget.dig(:options, :attribute).to_s.tr('/', '.')
373
- module_name, entity_name, attribute_name = path.split('.', 3)
374
- return type unless attribute_name
375
-
376
- entity = @project.modules.find { _1.name == module_name }
377
- &.entities&.find { _1.name == entity_name }
378
- attribute = entity&.attributes&.find { _1.name == attribute_name }
379
- %i[integer long decimal autonumber].include?(attribute&.type) ? 'number_input' : type
277
+ def copy_runtime_mpr
278
+ directory = File.join(@output_dir, '.mxrb', 'runtime')
279
+ FileUtils.mkdir_p(directory)
280
+ destination = File.join(directory, File.basename(@mpr_path))
281
+ FileUtils.cp(@mpr_path, destination)
282
+ source_contents = File.join(File.dirname(@mpr_path), 'mprcontents')
283
+ FileUtils.cp_r(source_contents, directory, remove_destination: true) if File.directory?(source_contents)
284
+ copy_runtime_project_assets(directory)
285
+ destination
380
286
  end
381
287
 
382
- def runtime_value(value)
383
- case value
384
- when Hash
385
- value.each_with_object({}) do |(key, child), result|
386
- next if key.to_s == 'deep_structure'
387
-
388
- result[key.to_s] = runtime_value(child)
389
- end
390
- when Array then value.map { runtime_value(_1) }
391
- when Symbol then value.to_s
392
- when String, Numeric, TrueClass, FalseClass, NilClass then value
393
- else value.to_s
394
- end
395
- end
288
+ def copy_runtime_project_assets(runtime_directory)
289
+ source_root = File.dirname(@mpr_path)
290
+ destination_root = File.join(runtime_directory, 'project')
291
+ directories = Model::DesignSystem::ASSET_DIRECTORIES + Mxrb::Exporter::PROJECT_FILES +
292
+ Mxrb::Exporter::MARKETPLACE_PROVENANCE
293
+ directories.each do |relative_path|
294
+ source = File.join(source_root, relative_path)
295
+ next unless File.exist?(source) && !File.symlink?(source)
396
296
 
397
- def entity_source(namespace, class_name, qualified, id, attributes, dto:, persistable:)
398
- declarations = attributes.map do |attribute|
399
- " attribute :#{attribute.fetch('ruby_name')}, type: :#{attribute.fetch('type')}, " \
400
- "mendix_name: #{attribute.fetch('name').inspect}, required: #{attribute.fetch('required')}, " \
401
- "default: #{attribute.fetch('default').inspect}"
297
+ target = File.join(destination_root, relative_path)
298
+ FileUtils.mkdir_p(File.dirname(target))
299
+ FileUtils.cp_r(source, target, remove_destination: true)
402
300
  end
403
- <<~RUBY
404
- # frozen_string_literal: true
405
-
406
- module #{namespace}
407
- class #{class_name} < Mxrb::RubyApp::#{dto ? 'DTO' : 'Record'}
408
- mendix_name #{qualified.inspect}, id: #{id.inspect}
409
- persistence #{persistable}
410
- #{declarations.join("\n")}
411
- end
412
- end
413
- RUBY
414
301
  end
415
302
 
416
- def service_source(namespace, class_name, qualified, id)
417
- <<~RUBY
418
- # frozen_string_literal: true
419
-
420
- module #{namespace}
421
- class #{class_name} < Mxrb::RubyApp::Service
422
- mendix_name #{qualified.inspect}, id: #{id.inspect}
303
+ # Widgets whose design is declared in Ruby resolve it when served; the
304
+ # recorded classes cover only typed native fragments without declarations.
305
+ def write_design_classes(project)
306
+ classes = DesignClasses.collect(project, File.dirname(@mpr_path)).filter_map do |document, widgets|
307
+ remaining = widgets.except(*declared_designs.fetch(document, []))
308
+ [document, remaining] unless remaining.empty?
309
+ end.to_h
310
+ write(DesignClasses::PATH, "#{JSON.pretty_generate(classes)}\n") unless classes.empty?
311
+ end
312
+
313
+ def record_declared_designs(document, keys)
314
+ declared_designs[document] = declared_designs.fetch(document, []) + keys
315
+ end
316
+
317
+ def declared_designs = (@declared_designs ||= {})
318
+
319
+ def copy_round_trip_metadata
320
+ source = File.join(@mendix_sidecar, '.mxrb', 'semantic_metadata.json')
321
+ return unless File.file?(source)
322
+
323
+ destination = File.join(@output_dir, '.mxrb', 'semantic_metadata.json')
324
+ FileUtils.mkdir_p(File.dirname(destination))
325
+ FileUtils.cp(source, destination)
326
+ end
327
+
328
+ DSL_SINK_OPTIONS = {
329
+ sidebar_toggle: %w[caption class style dynamic_class visible button_style tooltip icon],
330
+ button: %w[caption parameters class style dynamic_class visible visibility button_style icon render_type],
331
+ check_box: %w[attribute caption class style dynamic_class visible],
332
+ container: %w[class style dynamic_class visible],
333
+ date_picker: %w[attribute caption class style dynamic_class visible],
334
+ drop_down: %w[attribute caption class style dynamic_class visible],
335
+ file_manager: %w[
336
+ allowed_extensions editable max_file_size show_file_in_browser mode tab_index
337
+ class style dynamic_class visible
338
+ ],
339
+ gallery: %w[class style dynamic_class visible entity xpath association context_variable source sort],
340
+ image_uploader: %w[
341
+ allowed_extensions caption editable max_file_size thumbnail_width thumbnail_height
342
+ tab_index class style dynamic_class visible
343
+ ],
344
+ image_viewer: %w[
345
+ entity source alternative_text default_image force_full_objects width height width_unit
346
+ height_unit responsive show_as_thumbnail on_click_enlarge tab_index
347
+ class style dynamic_class visible
348
+ ],
349
+ menu_bar: %w[menu navigation_profile tab_index class style dynamic_class visible],
350
+ native_layout: %w[layout_type show_bottom_bar sidebar class style dynamic_class visible],
351
+ navigation_list: %w[tab_index class style dynamic_class visible],
352
+ navigation_tree: %w[menu navigation_profile tab_index class style dynamic_class visible],
353
+ number_input: %w[attribute caption class style dynamic_class visible],
354
+ page_title: %w[class style dynamic_class visible],
355
+ placeholder: %w[parameter],
356
+ pluggable_widget: %w[
357
+ widget_id widget_name properties class style dynamic_class visible platform
358
+ ],
359
+ radio_button_group: %w[attribute caption horizontal class style dynamic_class visible],
360
+ reference_selector: %w[attribute caption display_attribute class style dynamic_class visible],
361
+ reference_set_selector: %w[
362
+ association target_entity display_attribute association_steps association_path caption editable
363
+ selection number_of_rows selectable_xpath control_bar select_first show_empty_rows
364
+ paging tab_index width_unit class style dynamic_class visible
365
+ ],
366
+ scroll_container: %w[
367
+ alignment layout_mode hide_scrollbars scroll_behavior tab_index width width_mode region_options native_layout
368
+ class style dynamic_class visible
369
+ ],
370
+ snippet: %w[snippet arguments class style dynamic_class visible],
371
+ static_image: %w[
372
+ image alternative_text width height width_unit height_unit responsive
373
+ class style dynamic_class visible
374
+ ],
375
+ text: %w[caption parameters class style dynamic_class visible visibility render_mode],
376
+ text_area: %w[attribute caption lines class style dynamic_class visible],
377
+ text_box: %w[attribute caption class style dynamic_class visible]
378
+ }.freeze
379
+ DSL_SINK_BLOCK_METHODS = (DSL_SINK_OPTIONS.keys - %i[snippet placeholder]).freeze
380
+
381
+ # The widget types the runtime renders and the options it reads, with
382
+ # their TypeScript types. Generated declarations outside this contract
383
+ # use the explicit ExtensionWidgetDefinition.
384
+ TYPESCRIPT_WIDGET_TYPES = %w[
385
+ button check_box container data_grid data_view date_picker drop_down file_manager gallery
386
+ image_uploader image_viewer layout layout_grid menu_bar native_layout native_widget navigation_list
387
+ navigation_tree number_input page_title placeholder pluggable_widget radio_button_group
388
+ reference_selector reference_set_selector scroll_container sidebar_toggle snippet
389
+ static_image tab_control table text text_area text_box
390
+ ].freeze
391
+ TYPESCRIPT_WIDGET_OPTIONS = {
392
+ 'alignment' => 'string', 'allowed_extensions' => 'string', 'alternative_text' => 'string',
393
+ 'arguments' => 'Record<string, RuntimeValue>', 'aria_label' => 'string', 'aria_required' => 'boolean',
394
+ 'association' => 'string', 'association_path' => 'Array<{ association?: string; entity?: string }>',
395
+ 'association_steps' => 'number', 'attribute' => 'string', 'autocomplete' => 'string',
396
+ 'button_style' => 'string', 'caption' => 'string', 'class' => 'string', 'columns' => 'WidgetColumn[]',
397
+ 'columns_draggable' => 'boolean', 'columns_hidable' => 'boolean', 'columns_resizable' => 'boolean',
398
+ 'context_variable' => 'string', 'control_bar' => 'boolean', 'default_image' => 'string',
399
+ 'design' => 'Record<string, DesignValue>', 'design_class' => 'string',
400
+ 'design_properties' => 'RuntimeValue[]', 'desktop' => 'number | string',
401
+ 'display_attribute' => 'string', 'dynamic_class' => 'string',
402
+ 'editability' => 'RuntimeValue', 'editable' => 'string | boolean', 'entity' => 'string',
403
+ 'filter_attributes' => 'string[]', 'force_full_objects' => 'boolean',
404
+ 'gutters' => 'boolean', 'height' => 'number',
405
+ 'height_unit' => 'string', 'hide_scrollbars' => 'boolean', 'horizontal' => 'boolean',
406
+ 'horizontal_alignment' => 'string', 'icon' => 'string', 'image' => 'string',
407
+ 'items' => 'RuntimeValue[] | Record<string, RuntimeValue>', 'label_width' => 'number',
408
+ 'layout' => 'string', 'layout_mode' => 'string', 'layout_type' => 'string', 'lines' => 'number',
409
+ 'locale' => 'string',
410
+ 'max_file_size' => 'number',
411
+ 'max_length' => 'number', 'menu' => 'string', 'mode' => 'string',
412
+ 'native_fragment' => '{ digest: string }', 'native_layout' => 'boolean', 'native_type' => 'string',
413
+ 'navigation_profile' => 'string', 'no_entity_message' => 'string', 'number_of_rows' => 'number',
414
+ 'on_click_enlarge' => 'boolean', 'on_click_trigger' => "'single' | 'double'",
415
+ 'options' => 'RuntimeValue[] | Record<string, RuntimeValue>', 'pageSize' => 'number',
416
+ 'page_size' => 'number', 'paging' => 'string', 'parameter' => 'string', 'parameters' => 'string[]',
417
+ 'password' => 'boolean', 'phone' => 'number | string', 'placeholder' => 'string',
418
+ 'platform' => 'string', 'presentation' => 'string',
419
+ 'properties' => 'Record<string, unknown>', 'read_only' => 'boolean', 'read_only_style' => 'string',
420
+ 'region_options' => 'Record<string, Record<string, RuntimeValue>>', 'render_mode' => 'string',
421
+ 'render_type' => 'string', 'responsive' => 'boolean', 'rows' => 'RuntimeValue[]',
422
+ 'scroll_behavior' => 'string', 'select_first' => 'boolean', 'selectable_xpath' => 'string',
423
+ 'selection' => 'string', 'server_side' => 'boolean', 'show_as_thumbnail' => 'boolean',
424
+ 'show_bottom_bar' => 'boolean', 'show_empty_rows' => 'boolean', 'show_file_in_browser' => 'boolean',
425
+ 'show_footer' => 'boolean', 'sidebar' => 'boolean',
426
+ 'snippet' => 'string', 'sort' => 'Array<{ attribute: string; direction?: string }>',
427
+ 'source' => 'DataViewSource', 'source_variable' => 'RuntimeValue', 'style' => 'string',
428
+ 'tab_index' => 'number', 'tablet' => 'number | string', 'tabs' => 'WidgetTab[]',
429
+ 'target_entity' => 'string',
430
+ 'thumbnail_height' => 'number', 'thumbnail_width' => 'number',
431
+ 'toolbar' => '{ buttons?: Array<{ type: string }> }', 'tooltip' => 'string',
432
+ 'values' => 'RuntimeValue[] | Record<string, RuntimeValue>', 'vertical_alignment' => 'string',
433
+ 'visibility' => 'RuntimeValue',
434
+ 'visible' => 'string | boolean', 'widget_id' => 'string', 'widget_name' => 'string',
435
+ 'width' => 'number | string', 'width_mode' => 'string', 'width_unit' => 'string', 'xpath' => 'string'
436
+ }.freeze
423
437
 
424
- def call(**arguments)
425
- native_call(arguments)
426
- end
427
- end
428
- end
429
- RUBY
438
+ def ruby_constant(value, suffix: nil)
439
+ parts = value.to_s.gsub(/([a-z\d])([A-Z])/, '\\1_\\2')
440
+ .split(/[^A-Za-z0-9]+/).reject(&:empty?)
441
+ constant = parts.map { _1[0].upcase + _1[1..].to_s.downcase }.join
442
+ constant = "Artifact#{constant}" if constant.empty? || constant.match?(/\A\d/)
443
+ constant = "#{constant}#{suffix}" if suffix && !constant.end_with?(suffix)
444
+ constant
430
445
  end
431
446
 
432
- def page_source(namespace, class_name, qualified, id, title, widgets,
433
- appearance_class:, appearance_style:, data_source:)
434
- <<~RUBY
435
- # frozen_string_literal: true
436
-
437
- module #{namespace}
438
- class #{class_name} < Mxrb::RubyApp::Page
439
- mendix_name #{qualified.inspect}, id: #{id.inspect}
440
- configure title: #{title.inspect}, widgets: #{widgets.inspect},
441
- appearance_class: #{appearance_class.inspect},
442
- appearance_style: #{appearance_style.inspect},
443
- data_source: #{data_source.inspect}
444
- end
447
+ # Flows whose names coincide after normalization to a file stem or a
448
+ # Ruby constant receive their unit identity as a disambiguating suffix.
449
+ def duplicate_flow_ids(flows)
450
+ flows = Array(flows)
451
+ duplicate_groups = [flows.group_by { underscore(_1.name) }, flows.group_by { ruby_constant(_1.name) }]
452
+ .flat_map(&:values).select { _1.size > 1 }.to_h { [_1.first.name.to_s, _1] }
453
+ duplicate_groups.each do |name, group|
454
+ ids = group.map { _1.id.to_s }
455
+ if ids.any?(&:empty?) || ids.uniq.size != ids.size
456
+ raise SerializationError,
457
+ "duplicate flow #{name} requires distinct explicit unit ids"
445
458
  end
446
- RUBY
447
- end
448
-
449
- def write_support_files
450
- write('Gemfile', gemfile)
451
- write('.gitignore', ruby_gitignore)
452
- write('.env.example', ruby_env_example)
453
- %w[development qa staging production].each do |name|
454
- write(File.join('config', 'environments', "#{name}.env.example"), environment_example(name))
455
459
  end
456
- write('project.rb', project_source)
457
- write(File.join('config', 'application.rb'), application_source)
458
- write(File.join('config', 'adapters.rb'), adapters_source)
459
- write(File.join('bin', 'server'), server_source)
460
- File.chmod(0o755, File.join(@output_dir, 'bin', 'server'))
461
- write(File.join('frontend', 'package.json'), frontend_package)
462
- write(File.join('frontend', 'vite.config.ts'), vite_config)
463
- write(File.join('frontend', 'tsconfig.json'), frontend_tsconfig)
464
- write(File.join('frontend', 'index.html'), frontend_index)
465
- write(File.join('frontend', 'src', 'vite-env.d.ts'), "/// <reference types=\"vite/client\" />\n")
466
- write(File.join('frontend', 'src', 'main.tsx'), frontend_main)
467
- write(File.join('frontend', 'src', 'types.ts'), frontend_types)
468
- write(File.join('frontend', 'src', 'nanoflows.ts'), frontend_nanoflows)
469
- write(File.join('frontend', 'src', 'App.tsx'), frontend_app)
470
- write(File.join('frontend', 'src', 'app.css'), frontend_css)
471
- write('README.md', readme)
460
+ duplicate_groups.values.flatten.map { _1.id.to_s }.uniq.freeze
472
461
  end
473
462
 
474
- def copy_frontend_theme
475
- root = File.join(@output_dir, 'frontend', 'src', 'mendix')
476
- FileUtils.mkdir_p(root)
477
- %w[theme themesource].each do |directory|
478
- source = File.join(@mendix_sidecar, directory)
479
- next unless File.directory?(source)
463
+ def flow_file_stem(flow, duplicate_name:)
464
+ base = underscore(flow.name)
465
+ return base unless duplicate_name
480
466
 
481
- FileUtils.cp_r(source, File.join(root, directory), remove_destination: true)
482
- end
483
- fallback = File.join(root, 'theme', 'web', 'main.scss')
484
- write(relative(fallback), '') unless File.file?(fallback)
467
+ "#{base}_#{flow_identity_suffix(flow)}"
485
468
  end
486
469
 
487
- def write_manifest(project, modules, runtime_mpr)
488
- native_coverage(project)
489
- payload = {
490
- 'format_version' => 1, 'mode' => 'ruby',
491
- 'project' => { 'name' => project.name, 'mendix_version' => project.mendix_version },
492
- 'navigation' => runtime_value(project.navigation.to_h),
493
- 'source' => {
494
- 'name' => File.basename(@mpr_path),
495
- 'sha256' => Digest::SHA256.file(@mpr_path).hexdigest
496
- },
497
- 'modules' => modules, 'coverage' => @coverage,
498
- 'frontend' => {
499
- 'framework' => 'react', 'language' => 'typescript', 'bundler' => 'vite',
500
- 'source' => 'frontend/src', 'types' => 'frontend/src/types.ts',
501
- 'typecheck' => 'npm run typecheck', 'build' => 'frontend/dist'
502
- },
503
- 'round_trip' => {
504
- 'compiler' => 'project.rb',
505
- 'mendix_project' => relative(File.join(@mendix_sidecar, 'project.rb')),
506
- 'runtime_mpr' => relative(runtime_mpr),
507
- 'editable_mendix_source' => relative(@mendix_sidecar)
508
- }
509
- }
510
- preset = Preset.detect(@output_dir)
511
- payload['ruby_stack'] = Preset.manifest(preset) if preset
512
- write(MANIFEST_PATH, JSON.pretty_generate(payload) << "\n")
513
- end
470
+ def flow_ruby_constant(flow, duplicate_name:)
471
+ return ruby_constant(flow.name) unless duplicate_name
514
472
 
515
- def native_coverage(project)
516
- known_ids = @coverage.to_h { [_1.fetch('id').to_s, true] }
517
- project.all_units.each do |unit|
518
- next if known_ids[unit.fetch('UnitID').to_s]
519
-
520
- document = project.parse_bson(unit)
521
- name = document['Name'] || document['name'] || document['$Type']
522
- add_coverage(
523
- unit['UnitID'], name.to_s, document['$Type'].to_s,
524
- relative(@mendix_sidecar), 'preserved_native'
525
- )
526
- end
473
+ ruby_constant("#{flow.name}_#{flow_identity_suffix(flow)}")
527
474
  end
528
475
 
529
- def add_coverage(id, name, kind, path, status)
530
- @coverage << {
531
- 'id' => id.to_s, 'name' => name.to_s, 'kind' => kind.to_s,
532
- 'ruby_path' => path, 'status' => status
533
- }
534
- end
476
+ def flow_identity_suffix(flow)
477
+ identifier = underscore(flow.id)
478
+ raise SerializationError, "duplicate flow #{flow.name} has no unit id" if identifier.empty?
535
479
 
536
- def ruby_constant(value, suffix: nil)
537
- parts = value.to_s.gsub(/([a-z\d])([A-Z])/, '\\1_\\2')
538
- .split(/[^A-Za-z0-9]+/).reject(&:empty?)
539
- constant = parts.map { _1[0].upcase + _1[1..].to_s.downcase }.join
540
- constant = "Artifact#{constant}" if constant.empty? || constant.match?(/\A\d/)
541
- constant = "#{constant}#{suffix}" if suffix && !constant.end_with?(suffix)
542
- constant
480
+ identifier
543
481
  end
544
482
 
545
483
  def ruby_method_name(value)
@@ -560,1143 +498,28 @@ module Mxrb
560
498
 
561
499
  def write(relative_path, contents)
562
500
  path = File.join(@output_dir, relative_path)
501
+ claim_declaration_path(relative_path, contents)
563
502
  FileUtils.mkdir_p(File.dirname(path))
564
503
  File.write(path, contents)
565
504
  end
566
505
 
567
- def gemfile
568
- <<~RUBY
569
- # frozen_string_literal: true
570
-
571
- source 'https://rubygems.org'
572
- gem 'mxrb'
573
- RUBY
574
- end
575
-
576
- def ruby_gitignore
577
- <<~TEXT
578
- .env
579
- .env.*
580
- !.env.example
581
- config/environments/*.env
582
- !config/environments/*.env.example
583
- .mxrb/runtime/*.sqlite3
584
- frontend/node_modules/
585
- frontend/dist/
586
- TEXT
587
- end
588
-
589
- def ruby_env_example
590
- <<~TEXT
591
- # Base values; environment profiles override this file.
592
- MXRB_ENV=development
593
- TEXT
594
- end
595
-
596
- def environment_example(name)
597
- <<~TEXT
598
- # Copy to #{name}.env. Process ENV has highest precedence.
599
- MXRB_DATABASE_PATH=.mxrb/runtime/#{name}.sqlite3
600
- MXRB_SHARED_STORE_PATH=.mxrb/runtime/#{name}-shared.sqlite3
601
- MXRB_SESSION_TTL=3600
602
- MXRB_SCHEDULER_LEASE_TTL=300
603
- MXRB_ALLOW_DESTRUCTIVE_MIGRATIONS=false
604
- MXRB_AUTH_TOKENS=
605
- MXRB_USERS_JSON=
606
- TEXT
607
- end
506
+ DECLARATION_ROOTS = %w[app/ frontend/src/generated/pages/ frontend/src/generated/nanoflows/].freeze
608
507
 
609
- def project_source
610
- <<~RUBY
611
- # frozen_string_literal: true
612
-
613
- require 'mxrb'
614
-
615
- mendix_version = #{@project.mendix_version.inspect}
616
- Mxrb::RubyApp.compile(__dir__, mendix_version:)
617
- RUBY
618
- end
508
+ # Declaration files are named from normalized Mendix names, so two
509
+ # documents may map to one path. Infrastructure files are rewritten
510
+ # freely, and files the developer wrote are restored from embedded sources.
511
+ def claim_declaration_path(relative_path, contents)
512
+ return unless DECLARATION_ROOTS.any? { relative_path.to_s.start_with?(_1) }
513
+ return if @embedded_source_paths&.key?(relative_path.to_s)
619
514
 
620
- def application_source
621
- <<~RUBY
622
- # frozen_string_literal: true
623
-
624
- require 'mxrb'
625
-
626
- MXRB_APPLICATION_ROOT = File.expand_path('..', __dir__)
627
- RUBY
628
- end
629
-
630
- def adapters_source
631
- <<~RUBY
632
- # frozen_string_literal: true
633
-
634
- # Register only the integrations this application uses. Credentials
635
- # belong in ignored environment files or a deployment secret manager.
636
- #
637
- # Mxrb::RubyApp::Registry.register_adapter(:app_service) do |name, document, variables|
638
- # MyAppServiceClient.call(name, document:, variables:)
639
- # end
640
- #
641
- # Legacy Custom Actions use Ruby implementations only. Register every
642
- # permitted action explicitly by its qualified Mendix name.
643
- #
644
- # Mxrb::RubyApp::Registry.register_java_custom_action('MyModule.MyAction') do |arguments|
645
- # MyRubyAction.call(arguments)
646
- # end
647
- #
648
- # Supported kinds: :app_service, :web_service, :import_xml,
649
- # :import_mapping, :export_mapping, and :document.
650
- RUBY
651
- end
652
-
653
- def server_source
654
- <<~RUBY
655
- #!/usr/bin/env ruby
656
- # frozen_string_literal: true
657
-
658
- require_relative '../config/application'
659
-
660
- host = ENV.fetch('HOST', '127.0.0.1')
661
- port = Integer(ENV.fetch('PORT', '9292'))
662
- frontend_port = Integer(ENV.fetch('FRONTEND_PORT', '5173'))
663
- supervisor = Mxrb::RubyApp::Supervisor.new(
664
- MXRB_APPLICATION_ROOT, host:, api_port: port, frontend_port:
665
- )
666
- puts "[mxrb] Ruby API: http://\#{host}:\#{port}"
667
- puts "[mxrb] React + Vite: http://\#{host}:\#{frontend_port}"
668
- trap('INT') { Thread.new { supervisor.shutdown } }
669
- supervisor.start
670
- RUBY
671
- end
672
-
673
- def frontend_package
674
- JSON.pretty_generate(
675
- 'name' => underscore(@project.name), 'private' => true, 'version' => '0.0.0',
676
- 'type' => 'module',
677
- 'scripts' => {
678
- 'dev' => 'vite', 'typecheck' => 'tsc --noEmit',
679
- 'build' => 'npm run typecheck && vite build', 'preview' => 'vite preview'
680
- },
681
- 'dependencies' => { 'react' => '^19.2.8', 'react-dom' => '^19.2.8' },
682
- 'devDependencies' => {
683
- '@types/node' => '^26.2.0', '@types/react' => '^19.2.18',
684
- '@types/react-dom' => '^19.2.4', '@vitejs/plugin-react' => '^6.0.5',
685
- 'sass-embedded' => '^1.90.0', 'typescript' => '^7.0.2', 'vite' => '^8.2.1'
686
- }
687
- ) << "\n"
688
- end
689
-
690
- def frontend_tsconfig
691
- JSON.pretty_generate(
692
- 'compilerOptions' => {
693
- 'target' => 'ES2022', 'useDefineForClassFields' => true,
694
- 'lib' => %w[ES2022 DOM DOM.Iterable], 'allowJs' => false,
695
- 'skipLibCheck' => true, 'esModuleInterop' => true,
696
- 'allowSyntheticDefaultImports' => true, 'strict' => true,
697
- 'noImplicitAny' => false, 'useUnknownInCatchVariables' => false,
698
- 'forceConsistentCasingInFileNames' => true, 'module' => 'ESNext',
699
- 'moduleResolution' => 'Bundler', 'resolveJsonModule' => true,
700
- 'isolatedModules' => true, 'noEmit' => true, 'jsx' => 'react-jsx'
701
- },
702
- 'include' => ['src', 'vite.config.ts']
703
- ) << "\n"
704
- end
705
-
706
- def vite_config
707
- <<~JS
708
- import { defineConfig } from 'vite';
709
- import react from '@vitejs/plugin-react';
710
-
711
- const apiPort = process.env.MXRB_API_PORT || '9292';
712
-
713
- export default defineConfig({
714
- plugins: [react()],
715
- server: { proxy: { '/api': `http://127.0.0.1:${apiPort}` } }
716
- });
717
- JS
718
- end
719
-
720
- def frontend_index
721
- <<~HTML
722
- <!doctype html>
723
- <html lang="en">
724
- <head>
725
- <meta charset="utf-8">
726
- <meta name="viewport" content="width=device-width,initial-scale=1">
727
- <title>#{escape_html(@project.name)} · MXRB Ruby</title>
728
- </head>
729
- <body>
730
- <div id="root"></div>
731
- <script type="module" src="/src/main.tsx"></script>
732
- </body>
733
- </html>
734
- HTML
735
- end
736
-
737
- def frontend_main
738
- <<~JS
739
- import React from 'react';
740
- import { createRoot } from 'react-dom/client';
741
- import App from './App';
742
- import './app.css';
743
- import './mendix/theme/web/main.scss';
744
-
745
- const root = document.getElementById('root');
746
- if (!root) throw new Error('MXRB frontend root element is missing');
747
-
748
- createRoot(root).render(
749
- <React.StrictMode><App /></React.StrictMode>
750
- );
751
- JS
752
- end
753
-
754
- def frontend_nanoflows
755
- imports = @nanoflow_entries.map do |entry|
756
- relative = entry.fetch('path').delete_prefix('frontend/src/')
757
- "import #{entry.fetch('import_name')} from './#{relative.delete_suffix('.ts')}';"
758
- end
759
- mappings = @nanoflow_entries.map do |entry|
760
- " #{entry.fetch('name').inspect}: #{entry.fetch('import_name')}"
515
+ @declaration_contents ||= {}
516
+ previous = @declaration_contents[relative_path]
517
+ if previous && previous != contents
518
+ raise SerializationError,
519
+ "two declarations generate #{relative_path}; rename one whose name normalizes to the same file"
761
520
  end
762
- <<~TS
763
- import type { NanoflowPlan } from './types';
764
-
765
- #{imports.join("\n")}
766
521
 
767
- const nanoflows = {
768
- #{mappings.join(",\n")}
769
- } satisfies Record<string, NanoflowPlan>;
770
-
771
- export default nanoflows;
772
- TS
773
- end
774
-
775
- def frontend_types # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
776
- modules = @module_manifests || []
777
- entities = modules.flat_map { |mod| Array(mod['models']) + Array(mod['dtos']) }
778
- pages = modules.flat_map { |mod| Array(mod['pages']) }
779
- enumerations = modules.flat_map { |mod| Array(mod['enumerations']) }
780
- enumeration_types = enumerations.map do |enumeration|
781
- name = typescript_identifier(enumeration.fetch('name'))
782
- values = enumeration.fetch('values', []).map { JSON.generate(_1.fetch('name')) }
783
- "export type #{name} = #{values.empty? ? 'never' : values.join(' | ')};"
784
- end
785
- entity_types = entities.flat_map do |entity|
786
- name = typescript_identifier(entity.fetch('name'))
787
- attributes = entity.fetch('attributes', []).map do |attribute|
788
- optional = attribute['required'] ? '' : '?'
789
- type = typescript_attribute_type(attribute, enumerations)
790
- " #{JSON.generate(attribute.fetch('name'))}#{optional}: #{type};"
791
- end
792
- [
793
- "export interface #{name}Attributes {\n#{attributes.join("\n")}\n}",
794
- "export type #{name}Record = EntityRecord<#{name}Attributes, #{JSON.generate(entity.fetch('name'))}>;"
795
- ]
796
- end
797
- entity_map = entities.map do |entity|
798
- " #{JSON.generate(entity.fetch('name'))}: #{typescript_identifier(entity.fetch('name'))}Record;"
799
- end
800
- page_types = pages.map do |page|
801
- name = typescript_identifier(page.fetch('name'))
802
- widgets = page.fetch('widgets', []).flat_map { frontend_widget_names(_1) }.uniq
803
- widget_names = widgets.empty? ? 'never' : widgets.map { JSON.generate(_1) }.join(' | ')
804
- "export type #{name}WidgetName = #{widget_names};"
805
- end
806
- page_map = pages.map do |page|
807
- name = typescript_identifier(page.fetch('name'))
808
- qualified = JSON.generate(page.fetch('name'))
809
- " #{qualified}: PageDefinition<#{qualified}, #{name}WidgetName>;"
810
- end
811
- <<~TS
812
- // Generated from the Mendix domain, page, widget, effect, and API contracts.
813
- export type RuntimeScalar = string | number | boolean | null;
814
- export type RuntimeValue = RuntimeScalar | EntityRecord | RuntimeValue[] | { [key: string]: RuntimeValue };
815
- export type RuntimeVariables = Record<string, RuntimeValue | undefined>;
816
-
817
- export interface EntityRecord<
818
- Attributes extends object = Record<string, RuntimeValue | undefined>,
819
- Name extends string = string
820
- > {
821
- id: string;
822
- type: Name;
823
- attributes: Attributes;
824
- }
825
-
826
- export interface WidgetEvent {
827
- event: string;
828
- kind: 'microflow' | 'nanoflow' | 'page' | string;
829
- handler: string;
830
- arguments?: Record<string, string>;
831
- }
832
-
833
- export interface WidgetDefinition<Name extends string = string> {
834
- type: string;
835
- name: Name;
836
- caption?: string;
837
- options?: Record<string, any>;
838
- events?: WidgetEvent[];
839
- children?: WidgetDefinition[];
840
- }
841
-
842
- export interface PageDefinition<Name extends string = string, WidgetName extends string = string> {
843
- name: Name;
844
- title: string;
845
- appearance_class?: string;
846
- appearance_style?: string;
847
- widgets: WidgetDefinition<WidgetName>[];
848
- }
849
-
850
- export interface AttributeDefinition {
851
- name: string;
852
- type: string;
853
- enumeration?: string;
854
- }
855
-
856
- export interface EntityDefinition {
857
- name: string;
858
- attributes?: AttributeDefinition[];
859
- }
860
-
861
- export interface EnumerationDefinition {
862
- id: string;
863
- name: string;
864
- values: Array<{ name: string; caption: string }>;
865
- }
866
-
867
- export interface AssociationDefinition {
868
- name: string;
869
- from_entity: string;
870
- to_entity: string;
871
- type: string;
872
- }
873
-
874
- export interface NavigationItem {
875
- page?: string;
876
- caption?: Record<string, string>;
877
- items?: NavigationItem[];
878
- }
879
-
880
- export interface NavigationProfile {
881
- kind: string;
882
- home_page?: string;
883
- items?: NavigationItem[];
884
- }
885
-
886
- export interface RuntimeModule {
887
- name: string;
888
- models?: EntityDefinition[];
889
- dtos?: EntityDefinition[];
890
- pages: PageDefinition[];
891
- enumerations?: EnumerationDefinition[];
892
- associations?: AssociationDefinition[];
893
- }
894
-
895
- export interface ApplicationSchema {
896
- project: { name: string; mendix_version: string };
897
- navigation?: { profiles?: NavigationProfile[] };
898
- modules: RuntimeModule[];
899
- }
900
-
901
- export interface OpenPageEffect {
902
- type: 'open_page';
903
- page: string;
904
- arguments?: Record<string, RuntimeValue>;
905
- }
906
-
907
- export interface RuntimeEffect {
908
- type: string;
909
- [key: string]: RuntimeValue | undefined;
910
- }
911
-
912
- export interface InvocationResult {
913
- result?: RuntimeValue;
914
- context?: EntityRecord | null;
915
- effects?: Array<OpenPageEffect | RuntimeEffect>;
916
- }
917
-
918
- export interface EntityCollectionResponse<T extends EntityRecord = EntityRecord> {
919
- records: T[];
920
- }
921
-
922
- export interface Session {
923
- id?: string;
924
- username?: string;
925
- [key: string]: RuntimeValue | undefined;
926
- }
927
-
928
- export interface LoginResponse {
929
- token: string;
930
- }
931
-
932
- export interface ApiFailure extends Error {
933
- status?: number;
934
- }
935
-
936
- export type ApiRequest = <T = any>(path: string, options?: RequestInit) => Promise<T>;
937
-
938
- export interface NanoflowObject {
939
- id: string;
940
- type: string;
941
- action?: Record<string, any>;
942
- condition?: string;
943
- return?: string;
944
- }
945
-
946
- export interface NanoflowEdge {
947
- origin: string;
948
- destination: string;
949
- case?: string;
950
- }
951
-
952
- export interface NanoflowPlan {
953
- name: string;
954
- id: string;
955
- parameters: string[];
956
- objects: NanoflowObject[];
957
- flows: NanoflowEdge[];
958
- }
959
-
960
- #{enumeration_types.join("\n")}
961
-
962
- #{entity_types.join("\n\n")}
963
-
964
- export interface EntityTypeMap {
965
- #{entity_map.join("\n")}
966
- }
967
- export type EntityName = keyof EntityTypeMap;
968
-
969
- #{page_types.join("\n")}
970
-
971
- export interface PageTypeMap {
972
- #{page_map.join("\n")}
973
- }
974
- export type PageName = keyof PageTypeMap;
975
- TS
976
- end # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
977
-
978
- def frontend_widget_names(widget)
979
- [widget['name'].to_s, *Array(widget['children']).flat_map { frontend_widget_names(_1) }]
980
- .reject(&:empty?)
981
- end
982
-
983
- def typescript_attribute_type(attribute, enumerations)
984
- if attribute['type'] == 'enum'
985
- enumeration = enumerations.find do |candidate|
986
- [candidate['id'], candidate['name']].include?(attribute['enumeration'])
987
- end
988
- return typescript_identifier(enumeration['name']) if enumeration
989
- end
990
-
991
- {
992
- 'boolean' => 'boolean', 'integer' => 'number', 'long' => 'number',
993
- 'autonumber' => 'number', 'decimal' => 'number', 'datetime' => 'string',
994
- 'binary' => 'string'
995
- }.fetch(attribute['type'].to_s, 'string')
996
- end
997
-
998
- def typescript_identifier(value)
999
- parts = value.to_s.split(/[^A-Za-z0-9]+/).reject(&:empty?)
1000
- identifier = parts.map { _1[0].to_s.upcase + _1[1..].to_s }.join
1001
- return 'MxrbType' if identifier.empty?
1002
-
1003
- identifier.match?(/\A[A-Za-z_]/) ? identifier : "Mx#{identifier}"
1004
- end
1005
-
1006
- def frontend_app
1007
- <<~'JS'
1008
- import { useCallback, useEffect, useRef, useState } from 'react';
1009
- import nanoflows from './nanoflows';
1010
- import type {
1011
- ApiFailure, ApiRequest, ApplicationSchema, EntityRecord, InvocationResult,
1012
- LoginResponse, NanoflowPlan, NavigationItem, OpenPageEffect, PageDefinition, Session
1013
- } from './types';
1014
-
1015
- const TOKEN_KEY = 'mxrb.session.token';
1016
- const api = async <T = any>(path: string, options: RequestInit = {}, token: string | null = null): Promise<T> => {
1017
- const headers = new Headers(options.headers);
1018
- headers.set('Content-Type', 'application/json');
1019
- if (token) headers.set('Authorization', `Bearer ${token}`);
1020
- const response = await fetch(path, {
1021
- ...options, headers
1022
- });
1023
- const payload = await response.json();
1024
- if (!response.ok) {
1025
- const error: ApiFailure = new Error(payload.error?.message || `HTTP ${response.status}`);
1026
- error.status = response.status;
1027
- throw error;
1028
- }
1029
- return payload;
1030
- };
1031
-
1032
- const classes = (...values) => values.filter(Boolean).join(' ');
1033
- const attributes = object => object?.attributes || {};
1034
- const memberName = value => (value || '').split(/[./]/).pop();
1035
- const entityCollectionPath = (entity, association, context) => {
1036
- const path = `/api/entities/${encodeURIComponent(entity)}`;
1037
- if (!association || !context?.type || !context?.id) return path;
1038
- const query = new URLSearchParams({
1039
- association, context_type: context.type, context_id: context.id
1040
- });
1041
- return `${path}?${query}`;
1042
- };
1043
- const expressionValue = (source, context, variables = {}) => {
1044
- const text = (source || '').trim();
1045
- const wrapped = text.match(/^toString\((.*)\)$/);
1046
- if (wrapped) return String(expressionValue(wrapped[1], context, variables) ?? '');
1047
- if (text === '$currentObject') return context;
1048
- const variable = text.match(/^\$([A-Za-z_]\w*)$/);
1049
- if (variable) return variables[variable[1]] ?? context;
1050
- const member = text.match(/^\$([A-Za-z_]\w*)\/([A-Za-z_][\w.]*)$/);
1051
- if (member) return attributes(variables[member[1]] ?? context)[memberName(member[2])];
1052
- if (text === 'empty') return null;
1053
- if (text === 'true') return true;
1054
- if (text === 'false') return false;
1055
- if (/^'.*'$/.test(text)) return text.slice(1, -1).replaceAll("''", "'");
1056
- return text;
1057
- };
1058
- const conditionValue = (source, context, variables = {}) => {
1059
- const text = (source || '').trim().replace(/^\((.*)\)$/, '$1');
1060
- const orParts = text.split(/\s+or\s+/);
1061
- if (orParts.length > 1) return orParts.some(part => conditionValue(part, context, variables));
1062
- const andParts = text.split(/\s+and\s+/);
1063
- if (andParts.length > 1) return andParts.every(part => conditionValue(part, context, variables));
1064
- const comparison = text.match(/^(.*?)\s*(=|!=|>=|<=|>|<)\s*(.*?)$/);
1065
- if (!comparison) return Boolean(expressionValue(text, context, variables));
1066
- const left = expressionValue(comparison[1], context, variables);
1067
- const right = expressionValue(comparison[3], context, variables);
1068
- return ({
1069
- '=': left === right, '!=': left !== right, '>': left > right,
1070
- '<': left < right, '>=': left >= right, '<=': left <= right
1071
- })[comparison[2]];
1072
- };
1073
- const nanoflowValue = (source, context, variables = {}) => {
1074
- const text = (source || '').trim();
1075
- if (/\s(?:and|or)\s|(?:=|!=|>=|<=|>|<)/.test(text)) {
1076
- return conditionValue(text, context, variables);
1077
- }
1078
- return expressionValue(text, context, variables);
1079
- };
1080
- const isVisible = (source, context) => {
1081
- return !source || conditionValue(source, context);
1082
- };
1083
- const dynamicClass = (source, context) => {
1084
- let text = source || '';
1085
- text = text.replace(/\(?if\s+(.+?)\s+then\s+'([^']*)'\s+else\s+'([^']*)'\)?/g,
1086
- (_, condition, yes, no) => conditionValue(condition, context) ? yes : no);
1087
- text = text.replace(/toString\(\$[A-Za-z_]\w*\/([A-Za-z_][\w.]*)\)/g,
1088
- (_, member) => String(attributes(context)[memberName(member)] ?? ''));
1089
- text = text.replace(/\$[A-Za-z_]\w*\/([A-Za-z_][\w.]*)/g,
1090
- (_, member) => attributes(context)[memberName(member)] ?? '');
1091
- return text.replace(/[+()']/g, ' ').replace(/\s+/g, ' ').trim();
1092
- };
1093
- const caption = (widget, options, context) => {
1094
- let value = options.caption || widget.caption || widget.name;
1095
- (options.parameters || []).forEach((parameter, index) => {
1096
- value = value.replaceAll(`{${index + 1}}`, expressionValue(parameter, context) ?? '');
1097
- });
1098
- return value;
1099
- };
1100
- const inlineStyle = value => Object.fromEntries((value || '').split(';').filter(Boolean).map(rule => {
1101
- const [property, ...parts] = rule.split(':');
1102
- const name = property.trim().replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
1103
- return [name, parts.join(':').trim()];
1104
- }));
1105
-
1106
- const eventArguments = (event, context) => Object.fromEntries(
1107
- Object.entries(event?.arguments || {}).map(([name, expression]) => [name, expressionValue(expression, context)])
1108
- );
1109
-
1110
- const recordValue = (record, attribute) => attributes(record)[memberName(attribute)];
1111
- const displayValue = value => {
1112
- if (value == null) return '';
1113
- if (Array.isArray(value)) return value.map(displayValue).join(', ');
1114
- if (value?.attributes) return Object.values(value.attributes).find(item =>
1115
- ['string', 'number', 'boolean'].includes(typeof item)) ?? value.id;
1116
- if (typeof value === 'object') return value.id || JSON.stringify(value);
1117
- return String(value);
1118
- };
1119
-
1120
- const sortRecords = (
1121
- records: EntityRecord[], sortings: Array<{ attribute: string; direction?: string }> = []
1122
- ) => {
1123
- const result = records.slice();
1124
- sortings.slice().reverse().forEach(sorting => {
1125
- const member = memberName(sorting.attribute);
1126
- const direction = sorting.direction === 'Descending' ? -1 : 1;
1127
- result.sort((left, right) => direction * String(
1128
- left.attributes?.[member] ?? ''
1129
- ).localeCompare(String(right.attributes?.[member] ?? ''), undefined, { numeric: true }));
1130
- });
1131
- return result;
1132
- };
1133
-
1134
- const executeNanoflow = async (
1135
- plan: NanoflowPlan | undefined, parameters: Record<string, any>
1136
- ): Promise<{ result: any; variables: Record<string, any> }> => {
1137
- if (!plan) throw new Error('Nanoflow frontend not found');
1138
- const variables = structuredClone(parameters || {});
1139
- const objects = Object.fromEntries(plan.objects.map(object => [object.id, object]));
1140
- const outgoing = {};
1141
- plan.flows.forEach(flow => { (outgoing[flow.origin] ||= []).push(flow); });
1142
- let current = plan.objects.find(object => object.type === 'StartEvent');
1143
- for (let step = 0; step < 10000; step += 1) {
1144
- if (!current) throw new Error(`Nanoflow ${plan.name} points to a missing object`);
1145
- if (current.type === 'EndEvent') {
1146
- return { result: expressionValue(current.return, null, variables), variables };
1147
- }
1148
- if (current.type === 'ActionActivity') {
1149
- const action = current.action || {};
1150
- if (action.type === 'LogMessage') console.info(`[nanoflow] ${action.message || plan.name}`);
1151
- else if (action.type === 'CreateVariable' || action.type === 'ChangeVariable') {
1152
- variables[action.variable] = nanoflowValue(action.value, null, variables);
1153
- } else if (action.type === 'Change') {
1154
- const object = variables[action.variable];
1155
- if (!object?.attributes) throw new Error(`Nanoflow object $${action.variable} is missing`);
1156
- (action.changes || []).forEach(change => {
1157
- object.attributes[change.member] = nanoflowValue(change.value, object, variables);
1158
- });
1159
- } else throw new Error(`Unsupported frontend nanoflow action: ${action.type}`);
1160
- }
1161
- const edges = outgoing[current.id] || [];
1162
- let edge = edges[0];
1163
- if (current.type === 'ExclusiveSplit') {
1164
- const value = String(conditionValue(current.condition, null, variables));
1165
- edge = edges.find(item => item.case === value) || edges.find(item => !item.case);
1166
- }
1167
- if (!edge) throw new Error(`Nanoflow ${plan.name} stops at ${current.type}`);
1168
- current = objects[edge.destination];
1169
- }
1170
- throw new Error(`Nanoflow ${plan.name} exceeded 10000 steps`);
1171
- };
1172
-
1173
- function BoundField({ widget, record, schema, request, saveRecord, onChanged, onError }) {
1174
- const options = widget.options || {};
1175
- const member = memberName(options.attribute || widget.name);
1176
- const kind = widget.type;
1177
- const value = recordValue(record, member);
1178
- const [draft, setDraft] = useState(kind === 'check_box' ? Boolean(value) : (value ?? ''));
1179
- const [references, setReferences] = useState<EntityRecord[]>([]);
1180
- const associations = (schema?.modules || []).flatMap(module => module.associations || []);
1181
- const association = associations.find(item =>
1182
- item.name === options.attribute || memberName(item.name) === member
1183
- );
1184
- const referenceEntity = options.entity || options.target_entity || association?.to_entity;
1185
- const entityDefinition = (schema?.modules || []).flatMap(module =>
1186
- [...(module.models || []), ...(module.dtos || [])]
1187
- ).find(entity => entity.name === record?.type);
1188
- const attributeDefinition = (entityDefinition?.attributes || []).find(attribute =>
1189
- attribute.name === member
1190
- );
1191
- const enumeration = (schema?.modules || []).flatMap(module =>
1192
- module.enumerations || []
1193
- ).find(item => item.id === attributeDefinition?.enumeration
1194
- || item.name === attributeDefinition?.enumeration);
1195
-
1196
- useEffect(() => {
1197
- setDraft(kind === 'check_box' ? Boolean(value) : (value?.id || value || ''));
1198
- }, [kind, record?.id, value?.id, value]);
1199
-
1200
- useEffect(() => {
1201
- if (kind !== 'reference_selector' || !referenceEntity) return;
1202
- request(`/api/entities/${encodeURIComponent(referenceEntity)}`)
1203
- .then(payload => setReferences(payload.records || [])).catch(onError);
1204
- }, [kind, referenceEntity, request, onError]);
1205
-
1206
- const persist = next => {
1207
- setDraft(next);
1208
- if (!record?.type || !record?.id || !member) return Promise.resolve(record);
1209
- let normalized = next;
1210
- if (kind === 'number_input') normalized = next === '' ? null : Number(next);
1211
- if (kind === 'reference_selector') {
1212
- normalized = references.find(item => item.id === next) || null;
1213
- }
1214
- return saveRecord(record, { [member]: normalized }).then(updated => {
1215
- if (!updated) return null;
1216
- if (onChanged) return onChanged(updated);
1217
- return updated;
1218
- });
1219
- };
1220
- const disabled = !record?.id || !member || options.read_only === true;
1221
-
1222
- if (kind === 'text_area') {
1223
- return <textarea rows={options.lines || 4} value={draft} disabled={disabled}
1224
- onChange={event => setDraft(event.target.value)} onBlur={() => persist(draft)} />;
1225
- }
1226
- if (kind === 'check_box') {
1227
- return <input type="checkbox" checked={Boolean(draft)} disabled={disabled}
1228
- onChange={event => persist(event.target.checked)} />;
1229
- }
1230
- if (kind === 'drop_down' || kind === 'reference_selector') {
1231
- const enumValues = (enumeration?.values || []).map(item => ({
1232
- id: item.name, label: item.caption || item.name
1233
- }));
1234
- const configuredValue = options.values || options.items || options.options || enumValues;
1235
- const configured = Array.isArray(configuredValue) ? configuredValue : Object.values(configuredValue);
1236
- const choices = kind === 'reference_selector' ? references : configured.map(item =>
1237
- typeof item === 'object' ? item : { id: item, label: item }
1238
- );
1239
- return <select value={draft} disabled={disabled} onChange={event => persist(event.target.value)}>
1240
- <option value="">—</option>
1241
- {draft && !choices.some(item => (item.id || item.value) === draft) ?
1242
- <option value={draft}>{displayValue(value)}</option> : null}
1243
- {choices.map(item => <option key={item.id || item.value} value={item.id || item.value}>
1244
- {displayValue(item.label || item.caption || recordValue(item, options.display_attribute)
1245
- || item.id || item.value)}
1246
- </option>)}
1247
- </select>;
1248
- }
1249
- const inputType = kind === 'date_picker' ? 'date' : kind === 'number_input' ? 'number' : 'text';
1250
- const inputValue = inputType === 'date' ? String(draft).slice(0, 10) : draft;
1251
- return <input type={inputType} value={inputValue} disabled={disabled}
1252
- onChange={event => setDraft(event.target.value)} onBlur={() => persist(draft)} />;
1253
- }
1254
-
1255
- function DataGrid({ widget, request, pageContext, revision, onError, onMutation,
1256
- onRowAction, onSelectRecord }) {
1257
- const options = widget.options || {};
1258
- const [records, setRecords] = useState<EntityRecord[]>([]);
1259
- const [pageNumber, setPageNumber] = useState(0);
1260
- const [reload, setReload] = useState(0);
1261
- const [selected, setSelected] = useState<EntityRecord | null>(null);
1262
- const [loading, setLoading] = useState(false);
1263
- const pageSize = Math.max(1, Number(options.page_size || options.pageSize || 20));
1264
-
1265
- useEffect(() => {
1266
- if (!options.entity) return;
1267
- setLoading(true);
1268
- request(entityCollectionPath(options.entity, options.association, pageContext)).then(payload => {
1269
- let values = payload.records || [];
1270
- values = sortRecords(values, options.sort || []);
1271
- setRecords(values);
1272
- setPageNumber(current => Math.min(current, Math.max(0, Math.ceil(values.length / pageSize) - 1)));
1273
- }).catch(onError).finally(() => setLoading(false));
1274
- }, [options.entity, options.association, pageContext?.type, pageContext?.id,
1275
- pageSize, reload, revision, request, onError]);
1276
-
1277
- const mutate = operation => operation.then(result => {
1278
- setReload(value => value + 1);
1279
- onMutation();
1280
- return result;
1281
- }).catch(onError);
1282
- const createRecord = () => mutate(request(`/api/entities/${encodeURIComponent(options.entity)}`, {
1283
- method: 'POST', body: '{}'
1284
- })).then(record => {
1285
- setSelected(record);
1286
- if (record) onSelectRecord(record);
1287
- });
1288
- const deleteRecord = () => selected && mutate(request(
1289
- `/api/entities/${encodeURIComponent(options.entity)}/${encodeURIComponent(selected.id)}`,
1290
- { method: 'DELETE' }
1291
- )).then(() => { setSelected(null); onSelectRecord(null); });
1292
- const toolbar = options.toolbar?.buttons || [];
1293
- const pageCount = Math.max(1, Math.ceil(records.length / pageSize));
1294
- const visible = records.slice(pageNumber * pageSize, (pageNumber + 1) * pageSize);
1295
-
1296
- return <div className={classes('mxrb-data-grid-runtime', loading && 'is-loading')}
1297
- data-entity={options.entity || ''}>
1298
- <div className="mxrb-grid-toolbar">
1299
- {toolbar.some(button => button.type === 'new') ? <button type="button" onClick={createRecord}>New</button> : null}
1300
- {toolbar.some(button => button.type === 'delete') ? <button type="button" disabled={!selected} onClick={deleteRecord}>Delete</button> : null}
1301
- <button type="button" onClick={() => setReload(value => value + 1)}>Reload</button>
1302
- </div>
1303
- <table><thead><tr>{(options.columns || []).map(column =>
1304
- <th key={column.name || column.attribute}>{column.caption || column.name}</th>)}</tr></thead>
1305
- <tbody>{visible.map(record => <tr key={record.id}
1306
- className={selected?.id === record.id ? 'is-selected' : ''}
1307
- onClick={() => { setSelected(record); onSelectRecord(record); onRowAction(record); }}>
1308
- {(options.columns || []).map(column => <td key={column.name || column.attribute}>
1309
- {displayValue(recordValue(record, column.attribute || column.name))}
1310
- </td>)}
1311
- </tr>)}</tbody></table>
1312
- <div className="mxrb-grid-pagination">
1313
- <button type="button" disabled={pageNumber === 0}
1314
- onClick={() => setPageNumber(value => value - 1)}>Previous</button>
1315
- <span>Page {pageNumber + 1} of {pageCount} · {records.length} rows</span>
1316
- <button type="button" disabled={pageNumber + 1 >= pageCount}
1317
- onClick={() => setPageNumber(value => value + 1)}>Next</button>
1318
- </div>
1319
- </div>;
1320
- }
1321
-
1322
- function Gallery({ widget, moduleName, invoke, invokeNanoflow, navigate, pageContext, revision,
1323
- schema, request, saveRecord, onError, onMutation, onSelectRecord }) {
1324
- const options = widget.options || {};
1325
- const [records, setRecords] = useState<EntityRecord[]>([]);
1326
- useEffect(() => {
1327
- if (!options.entity) return;
1328
- request(entityCollectionPath(options.entity, options.association, pageContext)).then(payload => {
1329
- setRecords(sortRecords(payload.records || [], options.sort || []));
1330
- }).catch(onError);
1331
- }, [options.entity, options.association, pageContext?.type, pageContext?.id,
1332
- revision, request, onError]);
1333
- return <div className={classes('mxrb-widget', 'mxrb-gallery', options.class)}
1334
- data-widget-name={widget.name} data-widget-type={widget.type}>
1335
- <div className="mxrb-gallery-items gallery-items">
1336
- {records.map(record => <div className="mxrb-gallery-item gallery-item" key={record.id}>
1337
- {(widget.children || []).map((child, index) => <Widget key={`${child.name}-${index}`}
1338
- widget={child} moduleName={moduleName} invoke={invoke} invokeNanoflow={invokeNanoflow}
1339
- navigate={navigate} context={record} schema={schema} request={request}
1340
- saveRecord={saveRecord} onError={onError} onMutation={onMutation}
1341
- onSelectRecord={onSelectRecord}
1342
- pageContext={pageContext} revision={revision} />)}
1343
- </div>)}
1344
- </div>
1345
- </div>;
1346
- }
1347
-
1348
- function Widget({ widget, moduleName, invoke, invokeNanoflow, navigate,
1349
- context, pageContext, revision, schema, request, saveRecord,
1350
- onError, onMutation, onSelectRecord }) {
1351
- const options = widget.options || {};
1352
- if (!isVisible(options.visible, context || pageContext)) return null;
1353
- const className = classes('mxrb-widget', `mxrb-${widget.type}`, options.class,
1354
- dynamicClass(options.dynamic_class, context || pageContext));
1355
- const runtimeProps = {
1356
- 'data-widget-name': widget.name,
1357
- 'data-widget-type': widget.type
1358
- };
1359
- const children = (widget.children || []).map((child, index) =>
1360
- <Widget key={`${child.name}-${index}`} widget={child} moduleName={moduleName} invoke={invoke}
1361
- invokeNanoflow={invokeNanoflow} navigate={navigate}
1362
- context={context} pageContext={pageContext} revision={revision} schema={schema}
1363
- request={request} saveRecord={saveRecord} onError={onError} onMutation={onMutation}
1364
- onSelectRecord={onSelectRecord} />);
1365
- const click = (widget.events || []).find(event => event.event === 'on_click');
1366
- const change = (widget.events || []).find(event => event.event === 'on_change');
1367
- const runEvent = (event, eventContext = context || pageContext) => {
1368
- if (!event) return Promise.resolve();
1369
- const handler = event.handler.includes('.') ? event.handler : `${moduleName}.${event.handler}`;
1370
- const parameters = eventArguments(event, eventContext);
1371
- if (event.kind === 'nanoflow') return invokeNanoflow(handler, parameters, eventContext);
1372
- if (event.kind === 'page') {
1373
- const targetContext = Object.values(parameters)[0] || pageContext || context || null;
1374
- return navigate(handler, targetContext);
1375
- }
1376
- return invoke(handler, parameters, eventContext);
1377
- };
1378
- const onClick = click ? () => runEvent(click) : undefined;
1379
- const onChanged = updated => runEvent(change, updated);
1380
-
1381
- switch (widget.type) {
1382
- case 'container':
1383
- return <div {...runtimeProps} className={className} style={inlineStyle(options.style)} onClick={onClick}
1384
- role={onClick ? 'button' : undefined} tabIndex={onClick ? 0 : undefined}>
1385
- {children}
1386
- </div>;
1387
- case 'text':
1388
- return <span {...runtimeProps} className={className}>{caption(widget, options, context || pageContext)}</span>;
1389
- case 'button':
1390
- return <button {...runtimeProps} type="button" className={className} onClick={onClick}>
1391
- {caption(widget, options, context || pageContext)}
1392
- </button>;
1393
- case 'text_area':
1394
- return <label {...runtimeProps} className={className}>{caption(widget, options, context || pageContext)}
1395
- <BoundField widget={widget} record={context || pageContext} schema={schema}
1396
- request={request} saveRecord={saveRecord} onChanged={onChanged} onError={onError} />
1397
- </label>;
1398
- case 'text_box':
1399
- case 'number_input':
1400
- return <label {...runtimeProps} className={className}>{caption(widget, options, context || pageContext)}
1401
- <BoundField widget={widget} record={context || pageContext} schema={schema}
1402
- request={request} saveRecord={saveRecord} onChanged={onChanged} onError={onError} />
1403
- </label>;
1404
- case 'check_box':
1405
- return <label {...runtimeProps} className={className}>
1406
- <BoundField widget={widget} record={context || pageContext} schema={schema}
1407
- request={request} saveRecord={saveRecord} onChanged={onChanged} onError={onError} />
1408
- {caption(widget, options, context || pageContext)}
1409
- </label>;
1410
- case 'date_picker':
1411
- return <label {...runtimeProps} className={className}>{caption(widget, options, context || pageContext)}
1412
- <BoundField widget={widget} record={context || pageContext} schema={schema}
1413
- request={request} saveRecord={saveRecord} onChanged={onChanged} onError={onError} />
1414
- </label>;
1415
- case 'drop_down':
1416
- case 'reference_selector':
1417
- return <label {...runtimeProps} className={className}>{caption(widget, options, context || pageContext)}
1418
- <BoundField widget={widget} record={context || pageContext} schema={schema}
1419
- request={request} saveRecord={saveRecord} onChanged={onChanged} onError={onError} />
1420
- </label>;
1421
- case 'tab_control':
1422
- return <div {...runtimeProps} className={className}>{(options.tabs || []).map(tab =>
1423
- <section key={tab.name}><h3>{tab.caption || tab.name}</h3>
1424
- {(tab.widgets || []).map((child, index) =>
1425
- <Widget key={`${child.name}-${index}`} widget={child} moduleName={moduleName} invoke={invoke}
1426
- invokeNanoflow={invokeNanoflow} navigate={navigate}
1427
- context={context} pageContext={pageContext} revision={revision} schema={schema}
1428
- request={request} saveRecord={saveRecord} onError={onError} onMutation={onMutation}
1429
- onSelectRecord={onSelectRecord} />)}
1430
- </section>)}</div>;
1431
- case 'data_grid':
1432
- return <div {...runtimeProps} className={className}><DataGrid widget={widget} request={request}
1433
- pageContext={pageContext} revision={revision} onError={onError}
1434
- onMutation={onMutation} onSelectRecord={onSelectRecord}
1435
- onRowAction={record => runEvent(change || click, record)} />
1436
- </div>;
1437
- case 'gallery':
1438
- return <Gallery widget={widget} moduleName={moduleName} invoke={invoke}
1439
- invokeNanoflow={invokeNanoflow} navigate={navigate}
1440
- pageContext={pageContext} revision={revision} schema={schema} request={request}
1441
- saveRecord={saveRecord} onError={onError} onMutation={onMutation}
1442
- onSelectRecord={onSelectRecord} />;
1443
- case 'native_widget':
1444
- return <div {...runtimeProps} className={classes(className, 'mxrb-native-widget')}
1445
- data-native-type={options.native_type || ''} role="alert">
1446
- Could not render widget {widget.name}: unsupported native type {options.native_type || 'unknown'}
1447
- </div>;
1448
- default:
1449
- return <div {...runtimeProps} className={className} role="alert">
1450
- Could not render widget {widget.name}: unsupported type {widget.type}
1451
- </div>;
1452
- }
1453
- }
1454
-
1455
- function navigationItems(items: NavigationItem[], openPage: (name: string) => unknown) {
1456
- return (items || []).map((item, index) => <li key={`${item.page || item.caption?.en_US}-${index}`}>
1457
- {item.page ? <button type="button" onClick={() => openPage(item.page!)}>
1458
- {item.caption?.en_US || item.page}
1459
- </button> : <span>{item.caption?.en_US || ''}</span>}
1460
- {item.items?.length ? <ul>{navigationItems(item.items, openPage)}</ul> : null}
1461
- </li>);
1462
- }
1463
-
1464
- function Login({ onLogin, error, busy }) {
1465
- const [username, setUsername] = useState('');
1466
- const [password, setPassword] = useState('');
1467
- const submit = event => {
1468
- event.preventDefault();
1469
- onLogin(username, password).finally(() => setPassword(''));
1470
- };
1471
- return <main className="mxrb-login">
1472
- <form onSubmit={submit}>
1473
- <h1>Sign in</h1>
1474
- <label>Username<input autoComplete="username" value={username}
1475
- onChange={event => setUsername(event.target.value)} /></label>
1476
- <label>Password<input type="password" autoComplete="current-password" value={password}
1477
- onChange={event => setPassword(event.target.value)} /></label>
1478
- <button type="submit" disabled={busy || !username || !password}>Sign in</button>
1479
- {error ? <p role="alert">{error.message}</p> : null}
1480
- </form>
1481
- </main>;
1482
- }
1483
-
1484
- export default function App() {
1485
- const [schema, setSchema] = useState<ApplicationSchema | null>(null);
1486
- const [page, setPage] = useState<PageDefinition | null>(null);
1487
- const [pageContext, setPageContext] = useState<EntityRecord | null>(null);
1488
- const [error, setError] = useState<ApiFailure | null>(null);
1489
- const [busy, setBusy] = useState(false);
1490
- const invocationInFlight = useRef(false);
1491
- const [revision, setRevision] = useState(0);
1492
- const [token, setToken] = useState(() => localStorage.getItem(TOKEN_KEY));
1493
- const [session, setSession] = useState<Session | null>(null);
1494
- const [authRequired, setAuthRequired] = useState(false);
1495
-
1496
- const handleError = useCallback(failure => {
1497
- if (failure?.status === 401) setAuthRequired(true);
1498
- setError(failure);
1499
- }, []);
1500
- const request: ApiRequest = useCallback(
1501
- (path: string, options: RequestInit = {}) => api(path, options, token), [token]
1502
- );
1503
-
1504
- const openPage = (name: string, context: EntityRecord | null = null, activeToken = token) =>
1505
- api<PageDefinition>(`/api/pages/${encodeURIComponent(name)}`, {}, activeToken)
1506
- .then(value => { setPage(value); setPageContext(context); setError(null); })
1507
- .catch(handleError);
1508
-
1509
- const loadApplication = async (activeToken = token) => {
1510
- try {
1511
- if (activeToken) {
1512
- const currentSession = await api<Session>('/api/session', {}, activeToken);
1513
- setSession(currentSession);
1514
- }
1515
- const value = await api<ApplicationSchema>('/api/schema', {}, activeToken);
1516
- setSchema(value);
1517
- setAuthRequired(false);
1518
- setError(null);
1519
- const profile = value.navigation?.profiles?.find(item => item.kind === 'Responsive')
1520
- || value.navigation?.profiles?.[0];
1521
- const fallback = value.modules.flatMap(module => module.pages)[0]?.name;
1522
- await openPage(profile?.home_page || fallback, null, activeToken);
1523
- } catch (failure) {
1524
- if (failure?.status === 401) {
1525
- localStorage.removeItem(TOKEN_KEY);
1526
- setToken(null);
1527
- setSession(null);
1528
- setAuthRequired(true);
1529
- }
1530
- setError(failure);
1531
- }
1532
- };
1533
-
1534
- useEffect(() => {
1535
- loadApplication(token);
1536
- }, []);
1537
-
1538
- const login = async (username, password) => {
1539
- setBusy(true);
1540
- try {
1541
- const authenticated = await api<LoginResponse>('/api/login', {
1542
- method: 'POST', body: JSON.stringify({ username, password })
1543
- });
1544
- localStorage.setItem(TOKEN_KEY, authenticated.token);
1545
- setToken(authenticated.token);
1546
- await loadApplication(authenticated.token);
1547
- } catch (failure) {
1548
- setError(failure);
1549
- } finally {
1550
- setBusy(false);
1551
- }
1552
- };
1553
-
1554
- const logout = async () => {
1555
- try {
1556
- await api('/api/logout', { method: 'POST' }, token);
1557
- } catch (failure) {
1558
- if (failure?.status !== 401) setError(failure);
1559
- } finally {
1560
- localStorage.removeItem(TOKEN_KEY);
1561
- setToken(null);
1562
- setSession(null);
1563
- setSchema(null);
1564
- setPage(null);
1565
- setAuthRequired(true);
1566
- }
1567
- };
1568
-
1569
- const refreshPageContext = () => {
1570
- if (!pageContext?.type || !pageContext?.id) return Promise.resolve();
1571
- return request(
1572
- `/api/entities/${encodeURIComponent(pageContext.type)}/${encodeURIComponent(pageContext.id)}`
1573
- ).then(setPageContext).catch(handleError);
1574
- };
1575
-
1576
- const saveRecord = useCallback((record, changes) => {
1577
- if (!record?.type || !record?.id) return Promise.resolve(record);
1578
- return request<EntityRecord>(`/api/entities/${encodeURIComponent(record.type)}/${encodeURIComponent(record.id)}`, {
1579
- method: 'PATCH', body: JSON.stringify(changes)
1580
- }).then(updated => {
1581
- setPageContext(current => current?.id === updated.id ? updated : current);
1582
- setRevision(value => value + 1);
1583
- setError(null);
1584
- return updated;
1585
- }).catch(failure => {
1586
- handleError(failure);
1587
- return null;
1588
- });
1589
- }, [request, handleError]);
1590
-
1591
- const markMutation = useCallback(() => setRevision(value => value + 1), []);
1592
- const selectRecord = useCallback(record => setPageContext(record), []);
1593
-
1594
- const invoke = (name, parameters = {}, contextOverride = null) => {
1595
- if (invocationInFlight.current) return Promise.resolve(null);
1596
- invocationInFlight.current = true;
1597
- setBusy(true);
1598
- const activeContext = pageContext || contextOverride;
1599
- return request<InvocationResult>(`/api/microflows/${encodeURIComponent(name)}`, {
1600
- method: 'POST', body: JSON.stringify({
1601
- ...parameters, ...(activeContext ? { __mxrb_context: activeContext } : {})
1602
- })
1603
- })
1604
- .then(payload => {
1605
- setRevision(value => value + 1);
1606
- if (payload.context) setPageContext(payload.context);
1607
- const navigation = (payload.effects || []).find(
1608
- (effect): effect is OpenPageEffect => effect.type === 'open_page'
1609
- );
1610
- if (navigation?.page) {
1611
- const context = Object.values(navigation.arguments || {})[0]
1612
- || payload.context || payload.result || null;
1613
- return openPage(navigation.page, context as EntityRecord | null).then(() => payload);
1614
- }
1615
- return payload.context ? Promise.resolve(payload) : refreshPageContext().then(() => payload);
1616
- }).catch(handleError).finally(() => {
1617
- invocationInFlight.current = false;
1618
- setBusy(false);
1619
- });
1620
- };
1621
-
1622
- const invokeNanoflow = async (name, parameters = {}, contextOverride = null) => {
1623
- setBusy(true);
1624
- try {
1625
- const plan = nanoflows[name];
1626
- const resolvedParameters = { ...parameters };
1627
- const activeContext = contextOverride || pageContext;
1628
- if (plan?.parameters?.length === 1 && !(plan.parameters[0] in resolvedParameters)
1629
- && activeContext) {
1630
- resolvedParameters[plan.parameters[0]] = activeContext;
1631
- }
1632
- const execution = await executeNanoflow(plan, resolvedParameters);
1633
- const changedContext = Object.values(execution.variables).find(value =>
1634
- value?.id && value.id === activeContext?.id
1635
- );
1636
- if (changedContext) await saveRecord(changedContext, changedContext.attributes || {});
1637
- setError(null);
1638
- return execution.result;
1639
- } catch (failure) {
1640
- setError(failure);
1641
- return null;
1642
- } finally {
1643
- setBusy(false);
1644
- }
1645
- };
1646
-
1647
- if (authRequired) return <Login onLogin={login} error={error} busy={busy} />;
1648
- if (!schema || !page) return <main className="mxrb-loading">Loading application…</main>;
1649
- const profile = schema.navigation?.profiles?.find(item => item.kind === 'Responsive')
1650
- || schema.navigation?.profiles?.[0];
1651
- const moduleName = page.name.split('.')[0];
1652
-
1653
- return <div className={classes('mxrb-app-shell', 'mx-page', page.appearance_class)} style={inlineStyle(page.appearance_style)}>
1654
- {profile?.items?.length || session ? <nav className="mxrb-navigation region-sidebar">
1655
- {profile?.items?.length ? <ul>{navigationItems(profile.items, openPage)}</ul> : null}
1656
- {session ? <button type="button" onClick={logout}>Sign out</button> : null}
1657
- </nav> : null}
1658
- <main className="mxrb-page region-content mx-scrollcontainer-wrapper" aria-busy={busy}>
1659
- {(page.widgets || []).map((widget, index) =>
1660
- <Widget key={`${widget.name}-${index}`} widget={widget} moduleName={moduleName} invoke={invoke}
1661
- invokeNanoflow={invokeNanoflow} navigate={openPage}
1662
- context={pageContext} pageContext={pageContext} revision={revision} schema={schema}
1663
- request={request} saveRecord={saveRecord} onError={handleError}
1664
- onMutation={markMutation} onSelectRecord={selectRecord} />)}
1665
- </main>
1666
- {error ? <aside className="mxrb-runtime-error" role="alert">
1667
- <button type="button" onClick={() => setError(null)}>×</button>{error.message}
1668
- </aside> : null}
1669
- </div>;
1670
- }
1671
- JS
1672
- end
1673
-
1674
- def frontend_css
1675
- <<~CSS
1676
- :root { font: 16px/1.5 system-ui, sans-serif; }
1677
- * { box-sizing: border-box; }
1678
- html, body, #root { min-height: 100%; margin: 0; }
1679
- button, input, textarea, select { font: inherit; }
1680
- .mxrb-app-shell { min-height: 100vh; }
1681
- .mxrb-page { min-height: 100vh; }
1682
- .mxrb-page[aria-busy='true'] { cursor: progress; pointer-events: none; }
1683
- .mxrb-navigation { position: fixed; z-index: 20; right: 1rem; top: 1rem; }
1684
- .mxrb-navigation ul { display: flex; gap: .5rem; margin: 0; padding: 0; list-style: none; }
1685
- .mxrb-navigation button { border: 1px solid currentColor; border-radius: .4rem; background: transparent; color: inherit; cursor: pointer; }
1686
- .mxrb-text { display: block; }
1687
- .mxrb-runtime-error { position: fixed; z-index: 50; right: 1rem; bottom: 1rem; max-width: 34rem; padding: 1rem; border-radius: .5rem; background: #7f1d1d; color: white; box-shadow: 0 .5rem 2rem #0008; }
1688
- .mxrb-runtime-error button { float: right; border: 0; background: transparent; color: inherit; cursor: pointer; }
1689
- .mxrb-loading { display: grid; min-height: 100vh; place-items: center; }
1690
- .mxrb-login { display: grid; min-height: 100vh; place-items: center; padding: 1rem; }
1691
- .mxrb-login form { display: grid; width: min(24rem, 100%); gap: 1rem; padding: 2rem; border: 1px solid #d1d5db; border-radius: .75rem; }
1692
- .mxrb-login label { display: grid; gap: .25rem; }
1693
- .mxrb-grid-toolbar, .mxrb-grid-pagination { display: flex; align-items: center; gap: .5rem; margin-block: .5rem; }
1694
- .mxrb-data-grid-runtime table { width: 100%; border-collapse: collapse; }
1695
- .mxrb-data-grid-runtime th, .mxrb-data-grid-runtime td { padding: .5rem; border-bottom: 1px solid #d1d5db; text-align: left; }
1696
- .mxrb-data-grid-runtime tbody tr { cursor: pointer; }
1697
- .mxrb-data-grid-runtime tbody tr.is-selected { background: #dbeafe; }
1698
- .mxrb-native-widget:empty { min-height: 1px; }
1699
- CSS
522
+ @declaration_contents[relative_path] = contents
1700
523
  end
1701
524
 
1702
525
  def readme
@@ -1709,7 +532,7 @@ module Mxrb
1709
532
 
1710
533
  ```sh
1711
534
  bundle install
1712
- npm install --prefix frontend
535
+ npm ci --prefix frontend
1713
536
  bundle exec mxrb run .
1714
537
  ```
1715
538
 
@@ -1718,11 +541,25 @@ module Mxrb
1718
541
  application. Use `--server-port` for Ruby and `--client-port` for Vite;
1719
542
  `--api-port` and `--port` remain compatibility aliases. Generated models,
1720
543
  DTOs, services, and pages live under `app/`.
1721
- The generated `frontend/src/types.ts` covers domain records, pages, widgets,
544
+ The generated `frontend/src/generated/types.ts` covers domain records, pages, widgets,
1722
545
  contexts, effects, and API payloads; `npm run typecheck` validates it strictly.
1723
546
  Service bodies are ordinary Ruby; their default implementation delegates to
1724
547
  MXRB's pure-Ruby interpreter.
1725
548
 
549
+ The frontend follows a conventional application layout. Add product code under
550
+ `frontend/src/features`, `components`, `hooks`, `layouts`, `core`, or `styles`.
551
+ MXRB owns only `frontend/src/generated`, which contains the reversible bridge,
552
+ projected pages/flows, and schema types. Application-owned files are embedded in
553
+ the MPR and restored byte-for-byte; generated files are rebuilt on every export.
554
+
555
+ ```sh
556
+ npm ci --prefix frontend
557
+ npm run check --prefix frontend
558
+ ```
559
+
560
+ The complete gate runs Prettier, ESLint, Vitest/Testing Library, strict TypeScript,
561
+ and the production Vite build using the committed frontend lockfile.
562
+
1726
563
  Browser CRUD uses the same authenticated entity API as microflows. Configure
1727
564
  users and bearer tokens through ignored environment files. External app/web
1728
565
  services, mappings, XML imports, and documents are explicit Ruby integrations