mxrb 0.1.5 → 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.
- checksums.yaml +4 -4
- data/README.de-DE.md +4 -1
- data/README.md +11 -3
- data/README.pt-BR.md +5 -2
- data/bin/mxrb +509 -358
- data/docker/java-actions/Dockerfile +44 -0
- data/docker/java-actions/src/com/mendix/core/Core.java +491 -0
- data/docker/java-actions/src/com/mendix/core/CoreException.java +11 -0
- data/docker/java-actions/src/com/mendix/core/CoreRuntimeException.java +10 -0
- data/docker/java-actions/src/com/mendix/core/actionmanagement/MicroflowCallBuilder.java +19 -0
- data/docker/java-actions/src/com/mendix/core/conf/Configuration.java +60 -0
- data/docker/java-actions/src/com/mendix/core/conf/RuntimeVersion.java +38 -0
- data/docker/java-actions/src/com/mendix/core/internal/ICore.java +5 -0
- data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixAutoNumber.java +10 -0
- data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixBinary.java +48 -0
- data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixBoolean.java +10 -0
- data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixDateTime.java +15 -0
- data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixDecimal.java +10 -0
- data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixEnum.java +18 -0
- data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixHashString.java +10 -0
- data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixInteger.java +10 -0
- data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixLong.java +10 -0
- data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixObjectMember.java +73 -0
- data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixObjectReference.java +20 -0
- data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixObjectReferenceSet.java +22 -0
- data/docker/java-actions/src/com/mendix/core/objectmanagement/member/MendixString.java +10 -0
- data/docker/java-actions/src/com/mendix/datastorage/DataStorage.java +5 -0
- data/docker/java-actions/src/com/mendix/datastorage/XPathBasicQuery.java +29 -0
- data/docker/java-actions/src/com/mendix/datastorage/XPathQuery.java +41 -0
- data/docker/java-actions/src/com/mendix/externalinterface/connector/RequestHandler.java +38 -0
- data/docker/java-actions/src/com/mendix/http/Http.java +5 -0
- data/docker/java-actions/src/com/mendix/integration/Integration.java +5 -0
- data/docker/java-actions/src/com/mendix/integration/WebserviceException.java +24 -0
- data/docker/java-actions/src/com/mendix/logging/ILogNode.java +35 -0
- data/docker/java-actions/src/com/mendix/logging/LogLevel.java +4 -0
- data/docker/java-actions/src/com/mendix/logging/LogMessage.java +18 -0
- data/docker/java-actions/src/com/mendix/logging/LogSubscriber.java +22 -0
- data/docker/java-actions/src/com/mendix/m2ee/api/IMxRuntimeRequest.java +20 -0
- data/docker/java-actions/src/com/mendix/m2ee/api/IMxRuntimeResponse.java +50 -0
- data/docker/java-actions/src/com/mendix/metrics/Counter.java +7 -0
- data/docker/java-actions/src/com/mendix/metrics/Gauge.java +7 -0
- data/docker/java-actions/src/com/mendix/metrics/Metric.java +17 -0
- data/docker/java-actions/src/com/mendix/metrics/Metrics.java +75 -0
- data/docker/java-actions/src/com/mendix/metrics/Timer.java +10 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/MendixException.java +9 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/MendixRuntimeException.java +9 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/data/IDataColumnSchema.java +7 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/data/IDataRow.java +14 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/data/IDataTable.java +11 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/data/IDataTableSchema.java +13 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/requests/IParameterMap.java +9 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/requests/IRetrievalSchema.java +9 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/requests/ISortExpression.java +7 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/requests/types/IGetRequest.java +9 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/requests/types/IOQLTextGetRequest.java +5 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/connectionbus/requests/types/ITextGetRequest.java +12 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/IContext.java +28 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/IDataType.java +20 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/IEntityProxy.java +27 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/IFeedback.java +10 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/ILanguage.java +11 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/IMendixIdentifier.java +8 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/IMendixObject.java +65 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/IMendixObjectMember.java +20 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/ISession.java +16 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/IUser.java +11 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/UserAction.java +25 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/meta/IMetaAssociation.java +15 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/meta/IMetaEnumValue.java +9 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/meta/IMetaEnumeration.java +9 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/meta/IMetaObject.java +39 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/meta/IMetaObjectMember.java +6 -0
- data/docker/java-actions/src/com/mendix/systemwideinterfaces/core/meta/IMetaPrimitive.java +19 -0
- data/docker/java-actions/src/com/mendix/thirdparty/org/json/JSONArray.java +249 -0
- data/docker/java-actions/src/com/mendix/thirdparty/org/json/JSONException.java +14 -0
- data/docker/java-actions/src/com/mendix/thirdparty/org/json/JSONObject.java +279 -0
- data/docker/java-actions/src/com/mendix/thirdparty/org/json/JSONValues.java +273 -0
- data/docker/java-actions/src/com/mendix/utils/ListUtils.java +27 -0
- data/docker/java-actions/src/com/mendix/webui/CustomJavaAction.java +11 -0
- data/docker/java-actions/src/com/mendix/webui/FeedbackHelper.java +30 -0
- data/docker/java-actions/src/javax/servlet/http/Cookie.java +69 -0
- data/docker/java-actions/src/javax/servlet/http/HttpServletRequest.java +21 -0
- data/docker/java-actions/src/javax/servlet/http/HttpServletResponse.java +27 -0
- data/docker/java-actions/src/mxrb/sidecar/Aggregate.java +70 -0
- data/docker/java-actions/src/mxrb/sidecar/Background.java +84 -0
- data/docker/java-actions/src/mxrb/sidecar/Bridge.java +306 -0
- data/docker/java-actions/src/mxrb/sidecar/Build.java +131 -0
- data/docker/java-actions/src/mxrb/sidecar/Captions.java +52 -0
- data/docker/java-actions/src/mxrb/sidecar/Handlers.java +27 -0
- data/docker/java-actions/src/mxrb/sidecar/Invoker.java +110 -0
- data/docker/java-actions/src/mxrb/sidecar/Json.java +234 -0
- data/docker/java-actions/src/mxrb/sidecar/Metadata.java +119 -0
- data/docker/java-actions/src/mxrb/sidecar/MxContext.java +100 -0
- data/docker/java-actions/src/mxrb/sidecar/MxDataTable.java +172 -0
- data/docker/java-actions/src/mxrb/sidecar/MxDataType.java +100 -0
- data/docker/java-actions/src/mxrb/sidecar/MxIdentifier.java +47 -0
- data/docker/java-actions/src/mxrb/sidecar/MxLogNode.java +50 -0
- data/docker/java-actions/src/mxrb/sidecar/MxMetaAssociation.java +62 -0
- data/docker/java-actions/src/mxrb/sidecar/MxMetaEnumeration.java +64 -0
- data/docker/java-actions/src/mxrb/sidecar/MxMetaObject.java +234 -0
- data/docker/java-actions/src/mxrb/sidecar/MxMetaPrimitive.java +88 -0
- data/docker/java-actions/src/mxrb/sidecar/MxMicroflowCall.java +36 -0
- data/docker/java-actions/src/mxrb/sidecar/MxObject.java +258 -0
- data/docker/java-actions/src/mxrb/sidecar/MxOqlRequest.java +101 -0
- data/docker/java-actions/src/mxrb/sidecar/MxRuntimeRequest.java +182 -0
- data/docker/java-actions/src/mxrb/sidecar/MxRuntimeResponse.java +122 -0
- data/docker/java-actions/src/mxrb/sidecar/MxSession.java +91 -0
- data/docker/java-actions/src/mxrb/sidecar/MxXPathQuery.java +127 -0
- data/docker/java-actions/src/mxrb/sidecar/RubyException.java +17 -0
- data/docker/java-actions/src/mxrb/sidecar/Server.java +56 -0
- data/docs/agent-relay/20260901-083127.md +15 -0
- data/docs/agent-relay/20260901-091655.md +16 -0
- data/docs/agent-relay/20260901-094201.md +16 -0
- data/docs/agent-relay/20260901-140415.md +28 -0
- data/docs/de-DE/README.md +2 -0
- data/docs/de-DE/architectural-standard.md +19 -0
- data/docs/de-DE/certificacao-ruby-typescript.md +40 -0
- data/docs/de-DE/cobertura-ruby-nativa.md +265 -0
- data/docs/de-DE/compiler.md +22 -7
- data/docs/de-DE/demanda-projeto-ruby-typescript-convencional.md +37 -0
- data/docs/de-DE/design-system.md +59 -2
- data/docs/de-DE/entity-dsl.md +12 -0
- data/docs/de-DE/method-oriented-flows.md +66 -0
- data/docs/de-DE/portabilidade-ruby-typescript.md +1050 -0
- data/docs/de-DE/project-structure.md +34 -10
- data/docs/de-DE/ruby-first-roadmap.md +286 -0
- data/docs/de-DE/runtime-ruby.md +329 -6
- data/docs/de-DE/scaffolds.md +8 -4
- data/docs/de-DE/studio-backend.md +352 -0
- data/docs/de-DE/validation-matrix.md +235 -19
- data/docs/de-DE/vetclinic-acceptance.md +4 -3
- data/docs/de-DE/windows-studio-pro.md +88 -0
- data/docs/de-DE/writing.md +3 -1
- data/docs/en-US/README.md +2 -0
- data/docs/en-US/architectural-patterns.md +2 -3
- data/docs/en-US/architectural-standard.md +21 -1
- data/docs/en-US/certificacao-ruby-typescript.md +40 -0
- data/docs/en-US/cobertura-ruby-nativa.md +381 -0
- data/docs/en-US/compiler.md +33 -6
- data/docs/en-US/conventions.md +1 -2
- data/docs/en-US/demanda-projeto-ruby-typescript-convencional.md +36 -0
- data/docs/en-US/design-system.md +55 -1
- data/docs/en-US/entity-dsl.md +12 -0
- data/docs/en-US/method-oriented-flows.md +62 -0
- data/docs/en-US/portabilidade-ruby-typescript.md +1050 -0
- data/docs/en-US/project-structure.md +31 -8
- data/docs/en-US/ruby-first-roadmap.md +271 -2
- data/docs/en-US/runtime-ruby.md +313 -7
- data/docs/en-US/scaffolds.md +7 -4
- data/docs/en-US/studio-backend.md +342 -0
- data/docs/en-US/validation-matrix.md +173 -48
- data/docs/en-US/vetclinic-acceptance.md +4 -2
- data/docs/en-US/windows-studio-pro.md +84 -0
- data/docs/en-US/writing.md +8 -3
- data/docs/guides/benchmark-budget.pt-BR.md +99 -0
- data/docs/guides/certificacao-edicoes.pt-BR.md +116 -0
- data/docs/guides/teste-manual-vetclinic-ruby.pt-BR.md +480 -0
- data/docs/planning/backlog.pt-BR.md +101 -0
- data/docs/planning/ruby-editability.pt-BR.md +277 -0
- data/docs/pt-BR/README.md +4 -0
- data/docs/pt-BR/architectural-standard.md +21 -1
- data/docs/pt-BR/certificacao-ruby-typescript.md +116 -0
- data/docs/pt-BR/cobertura-ruby-nativa.md +408 -0
- data/docs/pt-BR/compiler.md +38 -7
- data/docs/pt-BR/demanda-projeto-ruby-typescript-convencional.md +41 -0
- data/docs/pt-BR/design-system.md +58 -2
- data/docs/pt-BR/entity-dsl.md +12 -0
- data/docs/pt-BR/method-oriented-flows.md +158 -0
- data/docs/pt-BR/oql-sql.md +11 -1
- data/docs/pt-BR/portabilidade-ruby-typescript.md +1311 -0
- data/docs/pt-BR/project-structure.md +46 -8
- data/docs/pt-BR/ruby-first-roadmap.md +390 -2
- data/docs/pt-BR/runtime-ruby.md +321 -11
- data/docs/pt-BR/scaffolds.md +17 -4
- data/docs/pt-BR/studio-backend.md +363 -0
- data/docs/pt-BR/validation-matrix.md +211 -21
- data/docs/pt-BR/vetclinic-acceptance.md +4 -5
- data/docs/pt-BR/windows-studio-pro.md +85 -0
- data/docs/pt-BR/writing.md +4 -0
- data/docs/reviews/ruby-code-review-2026-09-05.pt-BR.md +385 -0
- data/examples/modbus_application.rb +105 -0
- data/examples/modbus_tcp_simulator.rb +137 -0
- data/examples/sudoku_evaluation.rb +5 -5
- data/examples/sudoku_functional_test.rb +12 -12
- data/lib/mxrb/architecture/graph.rb +2 -2
- data/lib/mxrb/architecture/validator.rb +5 -3
- data/lib/mxrb/benchmark_fixture.rb +19 -0
- data/lib/mxrb/caption.rb +107 -0
- data/lib/mxrb/cli/help.rb +47 -8
- data/lib/mxrb/compare.rb +236 -74
- data/lib/mxrb/compiler/activity_caption.rb +168 -0
- data/lib/mxrb/compiler/artifact_document_compiler.rb +2 -1
- data/lib/mxrb/compiler/attribute_type_index.rb +57 -0
- data/lib/mxrb/compiler/client_model_materializer.rb +3 -4
- data/lib/mxrb/compiler/code_action_document_compiler.rb +4 -1
- data/lib/mxrb/compiler/compatibility_analyzer.rb +53 -0
- data/lib/mxrb/compiler/constants_materializer.rb +7 -1
- data/lib/mxrb/compiler/data_grid_bundle_compiler.rb +14 -12
- data/lib/mxrb/compiler/database_connector_action_compiler.rb +2 -2
- data/lib/mxrb/compiler/deployment_materializer.rb +3 -2
- data/lib/mxrb/compiler/deployment_metadata.rb +7 -1
- data/lib/mxrb/compiler/domain_document_compiler.rb +26 -2
- data/lib/mxrb/compiler/domain_model_materializer.rb +30 -6
- data/lib/mxrb/compiler/domain_security_compiler.rb +9 -12
- data/lib/mxrb/compiler/java_proxy_generator.rb +34 -2
- data/lib/mxrb/compiler/languages.rb +30 -0
- data/lib/mxrb/compiler/legacy_data_grid_compiler.rb +19 -3
- data/lib/mxrb/compiler/legacy_page_builder.rb +96 -20
- data/lib/mxrb/compiler/mapping_materializer.rb +94 -0
- data/lib/mxrb/compiler/microflow_document_compiler.rb +5 -19
- data/lib/mxrb/compiler/microflow_materializer.rb +12 -1
- data/lib/mxrb/compiler/microflow_node_compiler.rb +257 -20
- data/lib/mxrb/compiler/model_values.rb +26 -0
- data/lib/mxrb/compiler/navigation_document_compiler.rb +73 -66
- data/lib/mxrb/compiler/navigation_grid_compiler.rb +112 -0
- data/lib/mxrb/compiler/page_bundle_builder.rb +17 -1
- data/lib/mxrb/compiler/page_bundle_compiler.rb +783 -147
- data/lib/mxrb/compiler/page_document_compiler.rb +17 -23
- data/lib/mxrb/compiler/published_rest_materializer.rb +117 -0
- data/lib/mxrb/compiler/published_rest_open_api.rb +131 -0
- data/lib/mxrb/compiler/runtime_nodes.rb +68 -0
- data/lib/mxrb/compiler/schemas/forms-11.12.1.json +19781 -0
- data/lib/mxrb/compiler/schemas/languages-10.24.0.73019.json +658 -0
- data/lib/mxrb/compiler/schemas/languages-11.12.1.json +670 -0
- data/lib/mxrb/compiler/schemas/runtime-10.24.0.73019.json +442 -0
- data/lib/mxrb/compiler/schemas/runtime-11.json +176 -0
- data/lib/mxrb/compiler/security_materializer.rb +13 -6
- data/lib/mxrb/compiler/settings_document_compiler.rb +14 -2
- data/lib/mxrb/compiler/settings_materializer.rb +2 -1
- data/lib/mxrb/compiler/source_model.rb +8 -10
- data/lib/mxrb/compiler/synchronized_entities.rb +76 -0
- data/lib/mxrb/compiler/url_segment_compiler.rb +82 -0
- data/lib/mxrb/compiler/user_role_resolver.rb +33 -0
- data/lib/mxrb/compiler/web_list_data_source.rb +6 -2
- data/lib/mxrb/compiler/web_shell_materializer.rb +14 -0
- data/lib/mxrb/compiler/web_widget_inventory.rb +72 -0
- data/lib/mxrb/converter.rb +125 -0
- data/lib/mxrb/dsl/artifact_documents.rb +56 -0
- data/lib/mxrb/dsl/asset_documents.rb +94 -0
- data/lib/mxrb/dsl/builder.rb +102 -1630
- data/lib/mxrb/dsl/code_actions.rb +201 -0
- data/lib/mxrb/dsl/data_view_builder.rb +162 -0
- data/lib/mxrb/dsl/document_builders.rb +185 -0
- data/lib/mxrb/dsl/entity_builder.rb +188 -0
- data/lib/mxrb/dsl/flow_body_dsl.rb +538 -0
- data/lib/mxrb/dsl/flow_builders.rb +362 -0
- data/lib/mxrb/dsl/flow_page_builder.rb +58 -0
- data/lib/mxrb/dsl/flow_program.rb +101 -0
- data/lib/mxrb/dsl/flow_rest_builder.rb +40 -0
- data/lib/mxrb/dsl/flow_text_builder.rb +55 -0
- data/lib/mxrb/dsl/integration_documents.rb +1634 -0
- data/lib/mxrb/dsl/layout_builders.rb +373 -0
- data/lib/mxrb/dsl/module_builder.rb +408 -0
- data/lib/mxrb/dsl/navigation_builders.rb +264 -0
- data/lib/mxrb/dsl/page_builder.rb +219 -0
- data/lib/mxrb/dsl/presentation_documents.rb +161 -0
- data/lib/mxrb/dsl/project_documents.rb +60 -0
- data/lib/mxrb/dsl/security_builder.rb +215 -0
- data/lib/mxrb/dsl/widget_builders.rb +251 -0
- data/lib/mxrb/dsl/widget_design.rb +61 -0
- data/lib/mxrb/dsl/widget_dsl.rb +553 -0
- data/lib/mxrb/dsl/widget_event_arguments.rb +52 -0
- data/lib/mxrb/dsl/workflows.rb +520 -0
- data/lib/mxrb/errors.rb +3 -0
- data/lib/mxrb/evaluation.rb +9 -8
- data/lib/mxrb/exporter/code_action_declarations.rb +133 -0
- data/lib/mxrb/exporter/data_sources.rb +144 -0
- data/lib/mxrb/exporter/domain_document_declarations.rb +222 -0
- data/lib/mxrb/exporter/flow_action_sources.rb +545 -0
- data/lib/mxrb/exporter/flow_linearization.rb +649 -0
- data/lib/mxrb/exporter/integration_declarations.rb +763 -0
- data/lib/mxrb/exporter/method_flow_source.rb +208 -0
- data/lib/mxrb/exporter/model_sources.rb +381 -0
- data/lib/mxrb/exporter/page_sources.rb +756 -0
- data/lib/mxrb/exporter/presentation_declarations.rb +161 -0
- data/lib/mxrb/exporter/project_sources.rb +306 -0
- data/lib/mxrb/exporter/rest_declarations.rb +509 -0
- data/lib/mxrb/exporter/workflow_declarations.rb +652 -0
- data/lib/mxrb/exporter.rb +677 -1491
- data/lib/mxrb/forms/catalog.rb +175 -0
- data/lib/mxrb/forms/certification.rb +115 -0
- data/lib/mxrb/forms/coverage.rb +130 -0
- data/lib/mxrb/forms/input_presentation.rb +55 -0
- data/lib/mxrb/forms/mpr_codec.rb +821 -0
- data/lib/mxrb/forms/node.rb +213 -0
- data/lib/mxrb/forms/source_emitter.rb +296 -0
- data/lib/mxrb/forms/storage_naming.rb +120 -0
- data/lib/mxrb/forms/values.rb +226 -0
- data/lib/mxrb/frontend/migrator.rb +2 -0
- data/lib/mxrb/functional.rb +47 -43
- data/lib/mxrb/github/annotator.rb +31 -27
- data/lib/mxrb/http/server.rb +10 -2
- data/lib/mxrb/integrity/validator.rb +70 -22
- data/lib/mxrb/io/bson_codec.rb +61 -35
- data/lib/mxrb/io/mpr_file.rb +638 -105
- data/lib/mxrb/io/mxunit_codec.rb +3 -3
- data/lib/mxrb/marketplace.rb +77 -73
- data/lib/mxrb/modbus/client.rb +162 -0
- data/lib/mxrb/modbus/rtu_transport.rb +150 -0
- data/lib/mxrb/modbus/stream_io.rb +43 -0
- data/lib/mxrb/modbus/tcp_transport.rb +47 -0
- data/lib/mxrb/modbus.rb +32 -0
- data/lib/mxrb/model/association.rb +28 -28
- data/lib/mxrb/model/attribute.rb +51 -35
- data/lib/mxrb/model/domain_model.rb +33 -16
- data/lib/mxrb/model/entity.rb +80 -70
- data/lib/mxrb/model/menu.rb +54 -13
- data/lib/mxrb/model/microflow.rb +48 -46
- data/lib/mxrb/model/module.rb +85 -42
- data/lib/mxrb/model/navigation.rb +232 -9
- data/lib/mxrb/model/page.rb +1137 -247
- data/lib/mxrb/model/project.rb +61 -15
- data/lib/mxrb/model/unit.rb +10 -9
- data/lib/mxrb/native_fragment_store.rb +184 -0
- data/lib/mxrb/official_marketplace/content_api.rb +13 -1
- data/lib/mxrb/official_marketplace/dependency_resolver.rb +6 -1
- data/lib/mxrb/official_marketplace/widget_package_installer.rb +2 -1
- data/lib/mxrb/oql/server.rb +8 -8
- data/lib/mxrb/pluggable/catalog.rb +179 -0
- data/lib/mxrb/pluggable/mpr_codec.rb +765 -0
- data/lib/mxrb/pluggable/node.rb +347 -0
- data/lib/mxrb/pluggable/schema_dsl.rb +179 -0
- data/lib/mxrb/pluggable/schema_source_emitter.rb +134 -0
- data/lib/mxrb/project_lifecycle.rb +5 -2
- data/lib/mxrb/protocols/entry.rb +29 -0
- data/lib/mxrb/protocols/registry.rb +59 -0
- data/lib/mxrb/protocols.rb +84 -70
- data/lib/mxrb/public_source_audit.rb +201 -0
- data/lib/mxrb/ruby_app/access_rule_builder.rb +27 -0
- data/lib/mxrb/ruby_app/application/offline_synchronization.rb +138 -0
- data/lib/mxrb/ruby_app/application/record_access.rb +402 -0
- data/lib/mxrb/ruby_app/application/request_handlers.rb +45 -0
- data/lib/mxrb/ruby_app/application/schema_security.rb +193 -0
- data/lib/mxrb/ruby_app/application/service_invocation.rb +261 -0
- data/lib/mxrb/ruby_app/application/session_access.rb +97 -0
- data/lib/mxrb/ruby_app/application/value_serialization.rb +148 -0
- data/lib/mxrb/ruby_app/application.rb +201 -0
- data/lib/mxrb/ruby_app/async_invocations.rb +97 -0
- data/lib/mxrb/ruby_app/compilation.rb +64 -0
- data/lib/mxrb/ruby_app/constant.rb +99 -0
- data/lib/mxrb/ruby_app/controller.rb +112 -0
- data/lib/mxrb/ruby_app/dataset.rb +87 -0
- data/lib/mxrb/ruby_app/design_classes.rb +177 -0
- data/lib/mxrb/ruby_app/design_declarations.rb +193 -0
- data/lib/mxrb/ruby_app/domain_rule_builders.rb +123 -0
- data/lib/mxrb/ruby_app/enumeration.rb +91 -0
- data/lib/mxrb/ruby_app/exporter/data_widget_sources.rb +614 -0
- data/lib/mxrb/ruby_app/exporter/document_exports.rb +216 -0
- data/lib/mxrb/ruby_app/exporter/domain_behaviors.rb +67 -0
- data/lib/mxrb/ruby_app/exporter/domain_manifests.rb +283 -0
- data/lib/mxrb/ruby_app/exporter/frontend_pages.rb +161 -0
- data/lib/mxrb/ruby_app/exporter/frontend_types.rb +500 -0
- data/lib/mxrb/ruby_app/exporter/model_sources.rb +376 -0
- data/lib/mxrb/ruby_app/exporter/module_exports.rb +211 -0
- data/lib/mxrb/ruby_app/exporter/nanoflow_typescript.rb +590 -0
- data/lib/mxrb/ruby_app/exporter/project_files.rb +398 -0
- data/lib/mxrb/ruby_app/exporter/support_files.rb +357 -0
- data/lib/mxrb/ruby_app/exporter/widget_manifests.rb +134 -0
- data/lib/mxrb/ruby_app/exporter/widget_sources.rb +510 -0
- data/lib/mxrb/ruby_app/exporter.rb +398 -2320
- data/lib/mxrb/ruby_app/file_content.rb +133 -0
- data/lib/mxrb/ruby_app/flow_metadata.rb +72 -0
- data/lib/mxrb/ruby_app/frontend_package.rb +54 -0
- data/lib/mxrb/ruby_app/frontend_template/package-lock.json +4790 -0
- data/lib/mxrb/ruby_app/frontend_template/src/app/App.tsx +5 -0
- data/lib/mxrb/ruby_app/frontend_template/src/app/router.tsx +18 -0
- data/lib/mxrb/ruby_app/frontend_template/src/components/auth/LoginForm.test.tsx +18 -0
- data/lib/mxrb/ruby_app/frontend_template/src/components/auth/LoginForm.tsx +80 -0
- data/lib/mxrb/ruby_app/frontend_template/src/components/feedback/AppFeedback.tsx +31 -0
- data/lib/mxrb/ruby_app/frontend_template/src/components/navigation/AppNavigation.tsx +45 -0
- data/lib/mxrb/ruby_app/frontend_template/src/core/errors.ts +3 -0
- data/lib/mxrb/ruby_app/frontend_template/src/features/README.md +4 -0
- data/lib/mxrb/ruby_app/frontend_template/src/features/routes.tsx +9 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/ApplicationRuntime.test.tsx +174 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/ApplicationRuntime.tsx +959 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/AsyncInvocation.test.ts +61 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/AsyncInvocation.ts +47 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/ClientActions.test.tsx +234 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/ClientEvents.test.tsx +174 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/CreateActions.test.tsx +114 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/OfflineStartup.test.tsx +154 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/PageDataSource.ts +26 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/PageEdits.test.ts +85 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/PageEdits.ts +132 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/PageVariables.test.tsx +107 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/PageVariables.tsx +272 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/PopupRuntime.test.tsx +226 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/StartupAuthentication.test.tsx +101 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/api.ts +35 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/calendar.test.ts +93 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/calendar.ts +134 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/captions.test.tsx +201 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/captions.ts +235 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/clientFunctions.test.ts +195 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/clientFunctions.ts +182 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/clientServices.ts +24 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/commonsStorage.test.ts +77 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/commonsStorage.ts +44 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/BoundField.test.tsx +339 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/BoundField.tsx +442 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/CoreWidgets.test.tsx +306 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/DataGrid.test.tsx +417 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/DataGrid.tsx +944 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/FieldPolicy.test.ts +96 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/FieldPolicy.tsx +106 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/FileWidget.tsx +152 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/GridIcon.tsx +92 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/LanguageSelector.test.tsx +109 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/LanguageSelector.tsx +130 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceChart.test.tsx +580 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceChart.tsx +576 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceControls.test.tsx +192 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceControls.tsx +193 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceDataWidgets.test.tsx +194 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceGridFilter.test.tsx +213 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceGridFilter.tsx +95 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceInteractive.test.tsx +202 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceInteractive.tsx +246 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceLegacy.test.tsx +171 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceLegacy.tsx +189 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceMenus.tsx +114 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplacePlotly.test.tsx +96 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplacePlotly.tsx +162 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceSelection.test.tsx +170 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceSelection.tsx +204 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceTimeline.tsx +116 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/MarketplaceTreeNode.tsx +91 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeDataGrid.tsx +336 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeDataWidgets.test.tsx +233 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeDataWidgets.tsx +288 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeLayout.test.tsx +100 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeLayout.tsx +111 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeScrollContainer.tsx +206 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeSignature.tsx +104 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeWidgets.test.tsx +855 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/NativeWidgets.tsx +1142 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/PageOutlet.test.tsx +74 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/PageOutlet.tsx +63 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/PageTitleContext.ts +7 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/Popup.tsx +181 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/PresentationWidgets.test.tsx +490 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/PresentationWidgets.tsx +566 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/ReferenceSetCombobox.tsx +183 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/SelectionScope.tsx +28 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/TabControl.tsx +88 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/VariableScope.ts +8 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/WidgetRenderer.test.tsx +574 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/WidgetRenderer.tsx +1076 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/autofocus.test.ts +79 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/autofocus.ts +58 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/components/marketplaceData.ts +126 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/contracts.ts +53 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/dateFormatting.ts +297 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/dateParsing.test.ts +189 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/decimal.test.ts +75 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/decimal.ts +132 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/decimalParsing.test.ts +44 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/decimalParsing.ts +123 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/expression.test.ts +139 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/expression.ts +391 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/expressionClient.test.ts +163 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackCapture.test.ts +75 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackCapture.ts +51 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackCaptureWidget.test.tsx +136 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackCaptureWidget.tsx +79 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackFiles.test.ts +92 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackFiles.ts +84 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackMetadata.test.ts +142 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackMetadata.ts +49 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackStorage.test.ts +110 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/feedbackStorage.ts +93 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/legacy/LegacyWidgetHost.tsx +218 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/legacy/amd.ts +104 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/legacy/dojo.ts +474 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/legacy/legacy.test.tsx +518 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/legacy/mx.ts +722 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/legacy/mxGlobal.ts +13 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/legacy/nativeUnavailable.ts +20 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/legacy/session.ts +26 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/listSource.test.tsx +299 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/listSource.ts +177 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/marketplace.tsx +326 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/marketplaceWidgets.json +203 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/marketplaceWidgets.test.tsx +38 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/mendixFilters.test.ts +66 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/mendixFilters.ts +101 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nanoflow.ts +594 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nanoflowCommons.test.ts +89 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nanoflowCommons.ts +57 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nanoflowData.test.ts +199 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nanoflowLists.test.ts +34 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nanoflowOffline.test.ts +130 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nativeMobileActions.test.ts +310 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nativeMobileActions.ts +493 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/nativeOnlyJavaScriptActions.test.ts +12 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/objectRestore.test.ts +164 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/objectRestore.ts +123 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/objectStorage.test.ts +179 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/objectStorage.ts +94 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/offlineStore.test.ts +147 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/offlineStore.ts +226 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/plotly.test.ts +55 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/plotly.ts +94 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/pluggableHost.test.tsx +231 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/pluggableHost.tsx +461 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/projectJavaScriptActions.test.ts +158 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/projectJavaScriptActions.ts +91 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/qrCode.test.ts +79 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/qrCode.ts +309 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/schemaLookup.ts +46 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/sort.test.ts +114 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/synchronize.test.ts +167 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/synchronize.ts +156 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/useActionExecution.tsx +100 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/useWidgetEvent.ts +132 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/value.test.ts +89 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/value.ts +319 -0
- data/lib/mxrb/ruby_app/frontend_template/src/generated/bridge/widgetContract.test.ts +32 -0
- data/lib/mxrb/ruby_app/frontend_template/src/layouts/AppLayout.tsx +19 -0
- data/lib/mxrb/ruby_app/frontend_template/src/main.tsx +16 -0
- data/lib/mxrb/ruby_app/frontend_template/src/plotly.d.ts +4 -0
- data/lib/mxrb/ruby_app/frontend_template/src/styles/index.css +1281 -0
- data/lib/mxrb/ruby_app/frontend_template/src/test/setup.ts +1 -0
- data/lib/mxrb/ruby_app/frontend_template/tsconfig.json +23 -0
- data/lib/mxrb/ruby_app/frontend_template/vitest.config.ts +10 -0
- data/lib/mxrb/ruby_app/java_actions_package.rb +118 -0
- data/lib/mxrb/ruby_app/known_community_commons_actions.rb +316 -0
- data/lib/mxrb/ruby_app/known_encryption_actions.rb +162 -0
- data/lib/mxrb/ruby_app/known_feedback_widget.rb +43 -0
- data/lib/mxrb/ruby_app/known_java_actions.rb +66 -0
- data/lib/mxrb/ruby_app/known_javascript_actions.rb +173 -0
- data/lib/mxrb/ruby_app/known_mx_model_reflection_actions.rb +353 -0
- data/lib/mxrb/ruby_app/known_oql_actions.rb +43 -0
- data/lib/mxrb/ruby_app/known_oql_module_actions.rb +101 -0
- data/lib/mxrb/ruby_app/known_startup_actions.rb +115 -0
- data/lib/mxrb/ruby_app/legacy_service_source_migration.rb +142 -0
- data/lib/mxrb/ruby_app/legacy_widget_source_migration.rb +64 -0
- data/lib/mxrb/ruby_app/manifest.rb +41 -0
- data/lib/mxrb/ruby_app/member_identity.rb +135 -0
- data/lib/mxrb/ruby_app/metamodel.rb +197 -0
- data/lib/mxrb/ruby_app/module_security.rb +51 -0
- data/lib/mxrb/ruby_app/native_bridge.rb +96 -0
- data/lib/mxrb/ruby_app/native_edit_patch.rb +69 -0
- data/lib/mxrb/ruby_app/page.rb +321 -0
- data/lib/mxrb/ruby_app/page_data_sources.rb +184 -0
- data/lib/mxrb/ruby_app/page_design_identity.rb +182 -0
- data/lib/mxrb/ruby_app/page_edit_bindings.rb +168 -0
- data/lib/mxrb/ruby_app/page_edit_contracts.rb +144 -0
- data/lib/mxrb/ruby_app/page_edit_properties.rb +93 -0
- data/lib/mxrb/ruby_app/page_edit_texts.rb +104 -0
- data/lib/mxrb/ruby_app/page_edit_translations.rb +67 -0
- data/lib/mxrb/ruby_app/page_edits.rb +662 -0
- data/lib/mxrb/ruby_app/page_widget_renames.rb +40 -0
- data/lib/mxrb/ruby_app/pluggable_context.rb +149 -0
- data/lib/mxrb/ruby_app/pluggable_properties.rb +715 -0
- data/lib/mxrb/ruby_app/pluggable_schemas.rb +28 -0
- data/lib/mxrb/ruby_app/portability_report.rb +127 -0
- data/lib/mxrb/ruby_app/presentation.rb +137 -0
- data/lib/mxrb/ruby_app/presentation_contracts.rb +132 -0
- data/lib/mxrb/ruby_app/presentation_edits.rb +179 -0
- data/lib/mxrb/ruby_app/presentation_exporter.rb +201 -0
- data/lib/mxrb/ruby_app/presentation_projection.rb +62 -0
- data/lib/mxrb/ruby_app/presentation_references.rb +53 -0
- data/lib/mxrb/ruby_app/preset.rb +37 -1
- data/lib/mxrb/ruby_app/project_javascript_actions.rb +78 -0
- data/lib/mxrb/ruby_app/project_security.rb +200 -0
- data/lib/mxrb/ruby_app/project_widget_bundle.rb +74 -0
- data/lib/mxrb/ruby_app/rack_adapter.rb +73 -0
- data/lib/mxrb/ruby_app/record.rb +388 -0
- data/lib/mxrb/ruby_app/record_identity.rb +209 -0
- data/lib/mxrb/ruby_app/record_inheritance.rb +65 -0
- data/lib/mxrb/ruby_app/record_validation.rb +175 -0
- data/lib/mxrb/ruby_app/registry.rb +149 -0
- data/lib/mxrb/ruby_app/regular_expression.rb +58 -0
- data/lib/mxrb/ruby_app/runtime_catalog.rb +106 -0
- data/lib/mxrb/ruby_app/runtime_project.rb +163 -0
- data/lib/mxrb/ruby_app/schedule_builder.rb +134 -0
- data/lib/mxrb/ruby_app/scheduled_event.rb +59 -0
- data/lib/mxrb/ruby_app/security_builders.rb +97 -0
- data/lib/mxrb/ruby_app/security_identity.rb +182 -0
- data/lib/mxrb/ruby_app/server.rb +436 -0
- data/lib/mxrb/ruby_app/service.rb +114 -0
- data/lib/mxrb/ruby_app/session_manager.rb +79 -16
- data/lib/mxrb/ruby_app/sidecar_services.rb +92 -0
- data/lib/mxrb/ruby_app/source_identity.rb +401 -0
- data/lib/mxrb/ruby_app/source_reloader.rb +38 -0
- data/lib/mxrb/ruby_app/supervisor.rb +139 -0
- data/lib/mxrb/ruby_app/synchronizer/document_synchronization.rb +281 -0
- data/lib/mxrb/ruby_app/synchronizer/entity_synchronization.rb +239 -0
- data/lib/mxrb/ruby_app/synchronizer.rb +127 -0
- data/lib/mxrb/ruby_app/thumbnail.rb +54 -0
- data/lib/mxrb/ruby_app/widget_styles.rb +73 -0
- data/lib/mxrb/ruby_app/widget_support.rb +76 -0
- data/lib/mxrb/ruby_app.rb +101 -1307
- data/lib/mxrb/runtime/access_control.rb +54 -101
- data/lib/mxrb/runtime/calendar_functions.rb +142 -0
- data/lib/mxrb/runtime/calendar_ranges.rb +93 -0
- data/lib/mxrb/runtime/client_drafts.rb +167 -0
- data/lib/mxrb/runtime/clipboard.rb +9 -2
- data/lib/mxrb/runtime/constants.rb +66 -0
- data/lib/mxrb/runtime/database_workspace.rb +282 -43
- data/lib/mxrb/runtime/date_formatting.rb +120 -0
- data/lib/mxrb/runtime/date_parse_fields.rb +144 -0
- data/lib/mxrb/runtime/date_parse_matchers.rb +39 -0
- data/lib/mxrb/runtime/date_parsing.rb +102 -0
- data/lib/mxrb/runtime/decimal_formatting.rb +56 -0
- data/lib/mxrb/runtime/decimal_parsing.rb +134 -0
- data/lib/mxrb/runtime/decimal_values.rb +121 -0
- data/lib/mxrb/runtime/docker_executor.rb +15 -14
- data/lib/mxrb/runtime/docker_workspace.rb +8 -8
- data/lib/mxrb/runtime/enumerations.rb +135 -0
- data/lib/mxrb/runtime/executor.rb +25 -25
- data/lib/mxrb/runtime/expression_functions.rb +83 -0
- data/lib/mxrb/runtime/import_mapping.rb +191 -0
- data/lib/mxrb/runtime/java_action_context.rb +224 -0
- data/lib/mxrb/runtime/java_http_exchange.rb +33 -0
- data/lib/mxrb/runtime/java_regex.rb +244 -0
- data/lib/mxrb/runtime/java_sidecar.rb +449 -0
- data/lib/mxrb/runtime/languages.rb +85 -0
- data/lib/mxrb/runtime/lifecycle.rb +21 -0
- data/lib/mxrb/runtime/native.rb +977 -155
- data/lib/mxrb/runtime/oql_case_grammar.rb +56 -0
- data/lib/mxrb/runtime/oql_datasets.rb +96 -0
- data/lib/mxrb/runtime/oql_expression_grammar.rb +128 -0
- data/lib/mxrb/runtime/oql_function_grammar.rb +114 -0
- data/lib/mxrb/runtime/oql_join_sources.rb +125 -0
- data/lib/mxrb/runtime/oql_membership.rb +35 -0
- data/lib/mxrb/runtime/oql_module_query.rb +88 -0
- data/lib/mxrb/runtime/oql_nesting.rb +51 -0
- data/lib/mxrb/runtime/oql_parameters.rb +40 -0
- data/lib/mxrb/runtime/oql_predicate.rb +322 -0
- data/lib/mxrb/runtime/oql_projection_view.rb +90 -0
- data/lib/mxrb/runtime/oql_query_shape.rb +34 -0
- data/lib/mxrb/runtime/oql_relational_query.rb +137 -0
- data/lib/mxrb/runtime/oql_relational_view.rb +100 -0
- data/lib/mxrb/runtime/oql_relations.rb +185 -0
- data/lib/mxrb/runtime/oql_scalar.rb +121 -0
- data/lib/mxrb/runtime/oql_selection.rb +127 -0
- data/lib/mxrb/runtime/oql_selection_terms.rb +50 -0
- data/lib/mxrb/runtime/oql_subquery.rb +40 -0
- data/lib/mxrb/runtime/oql_subquery_grammar.rb +68 -0
- data/lib/mxrb/runtime/oql_table.rb +117 -0
- data/lib/mxrb/runtime/oql_table_query.rb +116 -0
- data/lib/mxrb/runtime/oql_union.rb +31 -0
- data/lib/mxrb/runtime/oql_view_query.rb +62 -0
- data/lib/mxrb/runtime/oql_views.rb +107 -0
- data/lib/mxrb/runtime/password_policy.rb +59 -0
- data/lib/mxrb/runtime/scheduler.rb +61 -10
- data/lib/mxrb/runtime/schema_migrator.rb +133 -19
- data/lib/mxrb/runtime/sort_order.rb +51 -0
- data/lib/mxrb/runtime/sort_path.rb +44 -0
- data/lib/mxrb/runtime/sqlite_store.rb +352 -39
- data/lib/mxrb/runtime/string_functions.rb +42 -0
- data/lib/mxrb/runtime/system_domain.rb +140 -0
- data/lib/mxrb/runtime/system_metamodel.rb +48 -0
- data/lib/mxrb/runtime/system_metamodel_10.24.0.json +5111 -0
- data/lib/mxrb/runtime/system_metamodel_11.12.1.json +5790 -0
- data/lib/mxrb/runtime/system_sign_in.rb +53 -0
- data/lib/mxrb/runtime/time_zones.rb +85 -0
- data/lib/mxrb/runtime/toolchain.rb +16 -16
- data/lib/mxrb/runtime/xpath.rb +414 -0
- data/lib/mxrb/runtime/xpath_dates.rb +101 -0
- data/lib/mxrb/runtime/xpath_functions.rb +82 -0
- data/lib/mxrb/scaffold/cli.rb +14 -13
- data/lib/mxrb/scaffold/generator.rb +29 -7
- data/lib/mxrb/scaffold/help.rb +4 -0
- data/lib/mxrb/scaffold/recipes.rb +43 -4
- data/lib/mxrb/scaffold/templates.rb +101 -19
- data/lib/mxrb/schema/tables.rb +13 -13
- data/lib/mxrb/semantic/analyzer.rb +11 -10
- data/lib/mxrb/semantic/batch_plan.rb +8 -8
- data/lib/mxrb/semantic/domain_mutator.rb +149 -85
- data/lib/mxrb/semantic/extractor.rb +74 -75
- data/lib/mxrb/semantic/index.rb +86 -88
- data/lib/mxrb/semantic/inliner.rb +60 -60
- data/lib/mxrb/semantic/mover.rb +7 -7
- data/lib/mxrb/semantic/remover.rb +1 -1
- data/lib/mxrb/semantic/renamer.rb +23 -22
- data/lib/mxrb/settings/model.rb +330 -0
- data/lib/mxrb/settings/mpr_codec.rb +157 -0
- data/lib/mxrb/settings/source_emitter.rb +105 -0
- data/lib/mxrb/settings/value_contracts.rb +141 -0
- data/lib/mxrb/stored_fields.rb +86 -0
- data/lib/mxrb/studio/artifacts.rb +67 -0
- data/lib/mxrb/studio/backend.rb +36 -0
- data/lib/mxrb/studio/catalog.rb +249 -0
- data/lib/mxrb/studio/data_connections.rb +77 -0
- data/lib/mxrb/studio/data_explorer.rb +288 -0
- data/lib/mxrb/studio/documents.rb +260 -0
- data/lib/mxrb/studio/files.rb +321 -0
- data/lib/mxrb/studio/history.rb +181 -0
- data/lib/mxrb/studio/isolated.rb +123 -0
- data/lib/mxrb/studio/model_operations.rb +304 -0
- data/lib/mxrb/studio/parity.json +1019 -0
- data/lib/mxrb/studio/parity.rb +75 -0
- data/lib/mxrb/studio/preview_comparison.rb +106 -0
- data/lib/mxrb/studio/preview_sandbox.rb +142 -0
- data/lib/mxrb/studio/preview_sources.rb +80 -0
- data/lib/mxrb/studio/preview_worker.rb +23 -0
- data/lib/mxrb/studio/protocol.rb +116 -0
- data/lib/mxrb/studio/request_context.rb +141 -0
- data/lib/mxrb/studio/ruby_document.rb +252 -0
- data/lib/mxrb/studio/ruby_document_aggregates.rb +167 -0
- data/lib/mxrb/studio/ruby_project.rb +214 -0
- data/lib/mxrb/studio/server.rb +145 -0
- data/lib/mxrb/studio/service.rb +525 -0
- data/lib/mxrb/studio/snapshot.rb +163 -0
- data/lib/mxrb/studio/structure.rb +381 -0
- data/lib/mxrb/studio/sync.rb +1070 -0
- data/lib/mxrb/studio/sync_preview.rb +108 -0
- data/lib/mxrb/studio/task_configurations.rb +118 -0
- data/lib/mxrb/studio/text_merge.rb +185 -0
- data/lib/mxrb/studio/write_lock.rb +87 -0
- data/lib/mxrb/studio.rb +4 -0
- data/lib/mxrb/studio_compatibility/loss_audit.rb +136 -0
- data/lib/mxrb/studio_compatibility.rb +401 -0
- data/lib/mxrb/studio_schema_catalog.rb +375 -0
- data/lib/mxrb/system_texts.rb +322 -0
- data/lib/mxrb/version.rb +1 -1
- data/lib/mxrb/web_ui/assets/chunk-2GNONHZU.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-2P46CC5S.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-2SHOE7BM.js +200 -0
- data/lib/mxrb/web_ui/assets/chunk-32QEQT5X.js +1 -0
- data/lib/mxrb/web_ui/assets/{chunk-5VM5RSS4-ZNzvKenW.js → chunk-34FZNJLO.js} +2 -2
- data/lib/mxrb/web_ui/assets/chunk-35N2E2ST.js +88 -0
- data/lib/mxrb/web_ui/assets/chunk-3EBRCLBH.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-3F3S4FN6.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-3PZDNKEG.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-3UGOMMAO.js +3 -0
- data/lib/mxrb/web_ui/assets/chunk-4NYRXXLN.js +106 -0
- data/lib/mxrb/web_ui/assets/chunk-4R2TVXEB.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-4SGPCOHB.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-5BHXSKDK.js +292 -0
- data/lib/mxrb/web_ui/assets/chunk-5EVG4O6T.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-5G5NQYC6.js +34 -0
- data/lib/mxrb/web_ui/assets/chunk-5HFJOAW4.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-5TNNO4YZ.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-63IIJIEV.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-66OX7QNZ.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-6B4DUFPC.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-6HSV3Q4G.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-6KV64GIT.js +98 -0
- data/lib/mxrb/web_ui/assets/chunk-6ZPGWQKV.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-72H3YDZV.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-77A6STIF.js +66 -0
- data/lib/mxrb/web_ui/assets/chunk-7B4ZTT6G.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-7E4ON25K.js +7 -0
- data/lib/mxrb/web_ui/assets/chunk-7GXBVQXL.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-7ONEZDBB.js +291 -0
- data/lib/mxrb/web_ui/assets/chunk-7UWVQTN5.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-AFDXKSZJ.js +2 -0
- data/lib/mxrb/web_ui/assets/chunk-BUBLNEPX.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-CBAMBU3T.js +30 -0
- data/lib/mxrb/web_ui/assets/chunk-CYCQ4VLZ.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-CYUZI6LQ.js +213 -0
- data/lib/mxrb/web_ui/assets/chunk-D246GO7Q.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-DHQUYWHD.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-E2RCGYXT.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-E5A22KZX.js +70 -0
- data/lib/mxrb/web_ui/assets/chunk-E64VJRVG.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-EBM2OVIK.js +120 -0
- data/lib/mxrb/web_ui/assets/chunk-ELCFKSFF.js +41 -0
- data/lib/mxrb/web_ui/assets/chunk-EQTVJ2VI.js +36 -0
- data/lib/mxrb/web_ui/assets/chunk-FAGUL7T6.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-FHZHQJRK.js +38 -0
- data/lib/mxrb/web_ui/assets/chunk-FUKAUTTF.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-GMUATS3X.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-GVPVJSW7.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-H3FJWUNC.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-H4QZ3SLG.js +257 -0
- data/lib/mxrb/web_ui/assets/chunk-H57W7YI5.js +62 -0
- data/lib/mxrb/web_ui/assets/chunk-H6EH3XA3.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-HB5VHJFM.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-HCKYS7KE.js +139 -0
- data/lib/mxrb/web_ui/assets/chunk-HQBVNVYC.js +39 -0
- data/lib/mxrb/web_ui/assets/chunk-HSA6P35M.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-HUYRUGAK.js +135 -0
- data/lib/mxrb/web_ui/assets/chunk-I5PKQWBH.js +140 -0
- data/lib/mxrb/web_ui/assets/chunk-ID2OERHW.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-IDAIL53S.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-IWZI7GPK.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-IXXNJOS3.js +24 -0
- data/lib/mxrb/web_ui/assets/chunk-K5MIAU7K.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-K6CUQC6N.js +136 -0
- data/lib/mxrb/web_ui/assets/chunk-KE3NT6QN.js +0 -0
- data/lib/mxrb/web_ui/assets/chunk-KI74YC4J.js +72 -0
- data/lib/mxrb/web_ui/assets/chunk-KOJL4E5L.js +370 -0
- data/lib/mxrb/web_ui/assets/chunk-KPUKEWCZ.js +169 -0
- data/lib/mxrb/web_ui/assets/chunk-LEZ2D244.js +2 -0
- data/lib/mxrb/web_ui/assets/chunk-LJWZZILO.js +8 -0
- data/lib/mxrb/web_ui/assets/chunk-LOYCYQTD.js +24 -0
- data/lib/mxrb/web_ui/assets/chunk-M2T56PG5.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-NI5QL3P3.js +2 -0
- data/lib/mxrb/web_ui/assets/chunk-NM5LBQV6.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-NNFAPT7B.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-NTAWMNDE.js +7 -0
- data/lib/mxrb/web_ui/assets/chunk-NUGW2EXC.js +27 -0
- data/lib/mxrb/web_ui/assets/chunk-OKEQR3I2.js +99 -0
- data/lib/mxrb/web_ui/assets/chunk-OUPEVUDM.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-OZ3S3DQH.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-PBU4ZVTM.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-PQQBOQJI.js +217 -0
- data/lib/mxrb/web_ui/assets/chunk-Q63GKT34.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-QJHVSIW7.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-QMUNJBVF.js +2 -0
- data/lib/mxrb/web_ui/assets/chunk-RKTVQ6NQ.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-RQ6DNNSS.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-RVFML3W7.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-S5TKGUWG.js +3 -0
- data/lib/mxrb/web_ui/assets/chunk-SBICTFKY.js +2 -0
- data/lib/mxrb/web_ui/assets/chunk-SOO7HOBB.js +89 -0
- data/lib/mxrb/web_ui/assets/chunk-SQ2BDVUY.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-T5KDILTJ.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-TJ2A3WRV.js +14 -0
- data/lib/mxrb/web_ui/assets/chunk-UITAI6UC.js +78 -0
- data/lib/mxrb/web_ui/assets/chunk-UL26XZ4V.js +10 -0
- data/lib/mxrb/web_ui/assets/chunk-URTGGQPX.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-UZTYCEEY.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-VFXGN725.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-VJRJYCFG.js +84 -0
- data/lib/mxrb/web_ui/assets/chunk-W6DARM7I.js +1 -0
- data/lib/mxrb/web_ui/assets/chunk-WLRR7NCQ.js +40 -0
- data/lib/mxrb/web_ui/assets/chunk-XIMEPMUW.js +32 -0
- data/lib/mxrb/web_ui/assets/chunk-XRM2LTMZ.js +4 -0
- data/lib/mxrb/web_ui/assets/chunk-Y5TK5PAP.js +62 -0
- data/lib/mxrb/web_ui/assets/chunk-ZH3OWPCF.js +339 -0
- data/lib/mxrb/web_ui/assets/chunk-ZIHGYIEK.js +1 -0
- data/lib/mxrb/web_ui/assets/domain-STH3BZOK.js +1 -0
- data/lib/mxrb/web_ui/assets/domain-VYBHNQGI.css +1 -0
- data/lib/mxrb/web_ui/assets/modeler-S2X4PVYN.js +1 -0
- data/lib/mxrb/web_ui/assets/modeler-SWHOK6BD.css +1 -0
- data/lib/mxrb/web_ui/assets/studio/studio-3F773TXK.css +1 -0
- data/lib/mxrb/web_ui/assets/studio/studio-DSAUONWT.js +68 -0
- data/lib/mxrb/web_ui/assets/uml-6G73GOJ4.css +1 -0
- data/lib/mxrb/web_ui/assets/uml-ENRAUICA.js +18 -0
- data/lib/mxrb/web_ui/domain.html +1 -3
- data/lib/mxrb/web_ui/modeler.html +1 -4
- data/lib/mxrb/web_ui/studio.html +5 -0
- data/lib/mxrb/web_ui/uml.html +1 -19
- data/lib/mxrb/widget_certification.rb +1 -8
- data/lib/mxrb/widget_development.rb +57 -0
- data/lib/mxrb/widget_package.rb +18 -12
- data/lib/mxrb/writer/data_sources.rb +149 -0
- data/lib/mxrb/writer/page_overlay.rb +542 -0
- data/lib/mxrb/writer.rb +6143 -1598
- data/lib/mxrb.rb +198 -158
- data/marketplace/modules/shared-kernel/module.rb +1 -1
- metadata +729 -108
- data/lib/mxrb/web_ui/assets/abnfDiagram-N423BO3Z-C4JD3cEC.js +0 -1
- data/lib/mxrb/web_ui/assets/arc-3Z53kgFp.js +0 -1
- data/lib/mxrb/web_ui/assets/architecture-TIHT7OUA-BStBTLea.js +0 -1
- data/lib/mxrb/web_ui/assets/architectureDiagram-T3A2C74G-DBwqnM4J.js +0 -36
- data/lib/mxrb/web_ui/assets/array-BifhSqXX.js +0 -1
- data/lib/mxrb/web_ui/assets/blockDiagram-VBNYF7ZC-DLtuHt-j.js +0 -132
- data/lib/mxrb/web_ui/assets/c4Diagram-5PPSVZJV-ConSk_pe.js +0 -10
- data/lib/mxrb/web_ui/assets/channel-BhPvD7Dt.js +0 -1
- data/lib/mxrb/web_ui/assets/chunk-2GRJ4B5K-D2HpWsf_.js +0 -1
- data/lib/mxrb/web_ui/assets/chunk-2Q5K7J3B-C1jixKkw.js +0 -1
- data/lib/mxrb/web_ui/assets/chunk-4I5QYGJK-CiIdNwaF.js +0 -1
- data/lib/mxrb/web_ui/assets/chunk-5RXB4S5H-Bu_AaEkE.js +0 -231
- data/lib/mxrb/web_ui/assets/chunk-6Q2QTUOP-wQkNmt_X.js +0 -88
- data/lib/mxrb/web_ui/assets/chunk-7BUUIJ7U-Bb538aSH.js +0 -1
- data/lib/mxrb/web_ui/assets/chunk-GF5L2VYU-G8MmiBzU.js +0 -206
- data/lib/mxrb/web_ui/assets/chunk-I66GZJ75-CulcrLPh.js +0 -127
- data/lib/mxrb/web_ui/assets/chunk-JQJVKLGR-ukjzcdlL.js +0 -156
- data/lib/mxrb/web_ui/assets/chunk-JWPE2WC7-DVXcaiue.js +0 -1
- data/lib/mxrb/web_ui/assets/chunk-KBJHAD2P-Wm35lYov.js +0 -1
- data/lib/mxrb/web_ui/assets/chunk-KEIR6QF5-BICK3FdT.js +0 -161
- data/lib/mxrb/web_ui/assets/chunk-NSK5VX7P-D2nYrCY4.js +0 -2
- data/lib/mxrb/web_ui/assets/chunk-QR6OTTB3-BrdIzg4Q.js +0 -62
- data/lib/mxrb/web_ui/assets/chunk-RYQCIY6F-CCfZMcW6.js +0 -1
- data/lib/mxrb/web_ui/assets/chunk-UBXNYLIW-BPEVYsFK.js +0 -1
- data/lib/mxrb/web_ui/assets/chunk-W5SLKNZC-2E6OPhA4.js +0 -1
- data/lib/mxrb/web_ui/assets/chunk-WRU74C26-CBIvOyWp.js +0 -70
- data/lib/mxrb/web_ui/assets/chunk-XXDRQBXY-pH58XAyl.js +0 -1
- data/lib/mxrb/web_ui/assets/chunk-Y2CYZVJY-DsF7k-Jl.js +0 -1
- data/lib/mxrb/web_ui/assets/classDiagram-JCYQIIEL-xiqo4D89.js +0 -1
- data/lib/mxrb/web_ui/assets/classDiagram-v2-OCEON4UE-xiqo4D89.js +0 -1
- data/lib/mxrb/web_ui/assets/cose-bilkent-JH36ORCC-t_flPpii.js +0 -1
- data/lib/mxrb/web_ui/assets/cynefin-VYW2F7L2-BIqktTEv.js +0 -1
- data/lib/mxrb/web_ui/assets/cynefinDiagram-MW4NZA55-C2d--lut.js +0 -62
- data/lib/mxrb/web_ui/assets/cytoscape.esm-B-NFISlW.js +0 -321
- data/lib/mxrb/web_ui/assets/dagre-Buvkdvvj.js +0 -1
- data/lib/mxrb/web_ui/assets/dagre-VZM6K2ZE-CSz2_tb5.js +0 -4
- data/lib/mxrb/web_ui/assets/defaultLocale-BFoDCU3G.js +0 -1
- data/lib/mxrb/web_ui/assets/diagram-7IWD3JNH-DCt7u7V_.js +0 -30
- data/lib/mxrb/web_ui/assets/diagram-B4RE2ZJO-DqZBqkMu.js +0 -3
- data/lib/mxrb/web_ui/assets/diagram-LBJQPF4R-ClIYbIsI.js +0 -24
- data/lib/mxrb/web_ui/assets/diagram-Q27KOJAE-DFxhvthJ.js +0 -24
- data/lib/mxrb/web_ui/assets/diagram-UB23O5K3-BSUTXptv.js +0 -41
- data/lib/mxrb/web_ui/assets/dist-D2qOEbeJ.js +0 -1
- data/lib/mxrb/web_ui/assets/domain-mGOZ1KCG.css +0 -1
- data/lib/mxrb/web_ui/assets/domain-qsjXhy4v.js +0 -1
- data/lib/mxrb/web_ui/assets/ebnfDiagram-BXEA7PRR-B5reICEi.js +0 -1
- data/lib/mxrb/web_ui/assets/erDiagram-JOGREHBK-Co5Mxn2p.js +0 -85
- data/lib/mxrb/web_ui/assets/eventmodeling-45OFAUF4-C1ylhSks.js +0 -1
- data/lib/mxrb/web_ui/assets/flowDiagram-UKHOOZJN-CHXaJIaS.js +0 -1
- data/lib/mxrb/web_ui/assets/ganttDiagram-PKOTCBZU-DPPPaWaz.js +0 -292
- data/lib/mxrb/web_ui/assets/gitGraph-TEB2WS4Q-qS77ywA9.js +0 -1
- data/lib/mxrb/web_ui/assets/gitGraphDiagram-DS77QQ5N-DpAv6-BT.js +0 -106
- data/lib/mxrb/web_ui/assets/graphlib-DS17s2tU.js +0 -1
- data/lib/mxrb/web_ui/assets/info-DKCQHKI2-C9VD1Y4e.js +0 -1
- data/lib/mxrb/web_ui/assets/infoDiagram-6WML65LV-Bk1kbcCy.js +0 -2
- data/lib/mxrb/web_ui/assets/init-C-OQMol4.js +0 -1
- data/lib/mxrb/web_ui/assets/ishikawaDiagram-WSZJBQD7-0gcISBFR.js +0 -70
- data/lib/mxrb/web_ui/assets/journeyDiagram-NVQOT4AX-Dt0RQnlh.js +0 -139
- data/lib/mxrb/web_ui/assets/jsx-runtime-DV0a5kSb.js +0 -9
- data/lib/mxrb/web_ui/assets/kanban-definition-27J2QSJJ-DIPQM7w9.js +0 -89
- data/lib/mxrb/web_ui/assets/katex-CXMH3UgJ.js +0 -257
- data/lib/mxrb/web_ui/assets/line-C0rYD-tL.js +0 -1
- data/lib/mxrb/web_ui/assets/linear-BPPxWorj.js +0 -1
- data/lib/mxrb/web_ui/assets/map-BaFkSB1l.js +0 -1
- data/lib/mxrb/web_ui/assets/mermaid-parser.core-B_UPzTxa.js +0 -7
- data/lib/mxrb/web_ui/assets/mindmap-definition-FAOFIHXS-CdJRSMuk.js +0 -96
- data/lib/mxrb/web_ui/assets/modeler-BNqHthwk.css +0 -1
- data/lib/mxrb/web_ui/assets/modeler-CQmqflbg.js +0 -1
- data/lib/mxrb/web_ui/assets/ordinal-BDEzSJ7C.js +0 -1
- data/lib/mxrb/web_ui/assets/packet-7NZHBO7P-CwQ4NSBs.js +0 -1
- data/lib/mxrb/web_ui/assets/path-fybaL0A-.js +0 -1
- data/lib/mxrb/web_ui/assets/pegDiagram-VL7TDLO6-D40S7ppx.js +0 -1
- data/lib/mxrb/web_ui/assets/pie-RZYD4A2V-CJroHMKh.js +0 -1
- data/lib/mxrb/web_ui/assets/pieDiagram-7S7Q4E2Y-QB54__BV.js +0 -39
- data/lib/mxrb/web_ui/assets/quadrantDiagram-CIZ2JOQS-DBhDS6ag.js +0 -7
- data/lib/mxrb/web_ui/assets/radar-I7S5WNFK-DdIUwd2d.js +0 -1
- data/lib/mxrb/web_ui/assets/railroad-3IZDKUUU-B1Lw6Xyq.js +0 -1
- data/lib/mxrb/web_ui/assets/railroad-abnf-AHOZXSZD-CQgQoeak.js +0 -1
- data/lib/mxrb/web_ui/assets/railroad-ebnf-EBAXGLYW-D7qEQ2x8.js +0 -1
- data/lib/mxrb/web_ui/assets/railroad-peg-LSFZ7HO6-C005Vxbb.js +0 -1
- data/lib/mxrb/web_ui/assets/railroadDiagram-AXF67PYL-BBP2qk7M.js +0 -1
- data/lib/mxrb/web_ui/assets/requirementDiagram-LRYGKXZP-D2cLsAoI.js +0 -84
- data/lib/mxrb/web_ui/assets/rough.esm-Dy-Kn_BL.js +0 -1
- data/lib/mxrb/web_ui/assets/sankeyDiagram-W5VNT64P-Bpi3FiP2.js +0 -40
- data/lib/mxrb/web_ui/assets/sequenceDiagram-SI44F4Z6-DCRcDlVe.js +0 -162
- data/lib/mxrb/web_ui/assets/sizeCapture-X5ZJPWSS-B0uUizjq.js +0 -1
- data/lib/mxrb/web_ui/assets/src-CvxfUak2.js +0 -1
- data/lib/mxrb/web_ui/assets/stateDiagram-OKZ733FA-C2GCEoxl.js +0 -1
- data/lib/mxrb/web_ui/assets/stateDiagram-v2-UEYNNEHI-D2gWgedh.js +0 -1
- data/lib/mxrb/web_ui/assets/swimlanes-SLNWSIFB-CRI9irEW.js +0 -2
- data/lib/mxrb/web_ui/assets/swimlanesDiagram-ULZ7WXOC-C5Wb_-hZ.js +0 -8
- data/lib/mxrb/web_ui/assets/theme-_mxc7BdY.css +0 -1
- data/lib/mxrb/web_ui/assets/timeline-definition-Z64GVDOM-B1-mNg-h.js +0 -120
- data/lib/mxrb/web_ui/assets/treeView-QDETBFTQ-7CTvIwKq.js +0 -1
- data/lib/mxrb/web_ui/assets/treemap-6X3UGDF4-CtL22pq5.js +0 -1
- data/lib/mxrb/web_ui/assets/uml-C3KAFGTq.js +0 -51
- data/lib/mxrb/web_ui/assets/uml-Dn-qd01X.css +0 -1
- data/lib/mxrb/web_ui/assets/vennDiagram-T6HMQDX7-BzVnUEAy.js +0 -34
- data/lib/mxrb/web_ui/assets/wardley-OPB4EBWU-JNi-QNag.js +0 -1
- data/lib/mxrb/web_ui/assets/wardleyDiagram-T6FBY63Y-BUwmAQ-B.js +0 -78
- data/lib/mxrb/web_ui/assets/xychartDiagram-ELKLHX3M-DEQS8sKp.js +0 -7
|
@@ -1,9 +1,33 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'base64'
|
|
3
4
|
require 'digest'
|
|
4
5
|
require 'fileutils'
|
|
5
6
|
require 'find'
|
|
6
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'
|
|
7
31
|
|
|
8
32
|
module Mxrb
|
|
9
33
|
module RubyApp
|
|
@@ -11,18 +35,34 @@ module Mxrb
|
|
|
11
35
|
# retaining the complete Mendix-mode tree as the reversible sidecar.
|
|
12
36
|
# rubocop:disable Metrics
|
|
13
37
|
class Exporter
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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__)
|
|
20
53
|
RUBY_KEYWORDS = %w[
|
|
21
54
|
alias and begin break case class def defined do else elsif end ensure false
|
|
22
55
|
for if in module next nil not or redo rescue retry return self super then
|
|
23
56
|
true undef unless until when while yield
|
|
24
57
|
].freeze
|
|
25
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
|
|
26
66
|
|
|
27
67
|
def initialize(mpr_path, output_dir, mendix_sidecar:)
|
|
28
68
|
@mpr_path = File.expand_path(mpr_path)
|
|
@@ -32,732 +72,412 @@ module Mxrb
|
|
|
32
72
|
|
|
33
73
|
def export!
|
|
34
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
|
|
35
79
|
runtime_mpr = copy_runtime_mpr
|
|
36
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'
|
|
37
87
|
Mxrb.open(@mpr_path) do |project|
|
|
38
88
|
@project = project
|
|
89
|
+
@known_entity_names = project.modules.flat_map do |mod|
|
|
90
|
+
mod.entities.map { "#{mod.name}.#{_1.name}" }
|
|
91
|
+
end.freeze
|
|
39
92
|
@coverage = []
|
|
40
93
|
@nanoflow_entries = []
|
|
41
94
|
@page_entries = []
|
|
42
|
-
|
|
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)
|
|
43
104
|
@module_manifests = modules
|
|
44
105
|
write_support_files
|
|
106
|
+
copy_round_trip_metadata
|
|
107
|
+
write_design_classes(project)
|
|
108
|
+
@widget_ids = WidgetStyles.widget_ids(project)
|
|
45
109
|
copy_frontend_theme
|
|
46
110
|
restore_embedded_sources(embedded_sources)
|
|
111
|
+
refresh_native_frontend_sources(project, modules, embedded_sources)
|
|
112
|
+
write_page_baselines(modules)
|
|
47
113
|
write_manifest(project, modules, runtime_mpr)
|
|
48
114
|
end
|
|
49
115
|
@output_dir
|
|
50
116
|
ensure
|
|
51
117
|
@project = nil
|
|
118
|
+
@embedded_sources = nil
|
|
119
|
+
@embedded_source_paths = nil
|
|
120
|
+
@embedded_identities = nil
|
|
52
121
|
@module_manifests = nil
|
|
122
|
+
@security_manifest = nil
|
|
123
|
+
@known_entity_names = nil
|
|
124
|
+
@native_fragment_store = nil
|
|
125
|
+
@rest_response_metadata = nil
|
|
53
126
|
end
|
|
54
127
|
|
|
55
128
|
private
|
|
56
129
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
|
60
138
|
ensure
|
|
61
|
-
|
|
139
|
+
@native_fragment_store = previous
|
|
62
140
|
end
|
|
63
141
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
raise SerializationError, "embedded Ruby source checksum mismatch: #{file.fetch(:path)}" \
|
|
69
|
-
unless checksum == file.fetch(:sha256)
|
|
70
|
-
|
|
71
|
-
path = RubyApp.safe_source_path(@output_dir, file.fetch(:path))
|
|
72
|
-
FileUtils.mkdir_p(File.dirname(path))
|
|
73
|
-
File.binwrite(path, contents)
|
|
74
|
-
File.chmod(RubyApp.safe_source_mode(file[:mode], file.fetch(:path)), path)
|
|
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')))
|
|
75
146
|
end
|
|
147
|
+
PresentationEdits.write_baselines(@output_dir)
|
|
76
148
|
end
|
|
77
149
|
|
|
78
|
-
def
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
source_contents = File.join(File.dirname(@mpr_path), 'mprcontents')
|
|
84
|
-
FileUtils.cp_r(source_contents, directory, remove_destination: true) if File.directory?(source_contents)
|
|
85
|
-
destination
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
def export_module(mod)
|
|
89
|
-
namespace = ruby_constant(mod.name)
|
|
90
|
-
root = underscore(mod.name)
|
|
91
|
-
entities = mod.entities.map { export_entity(_1, mod, namespace, root) }
|
|
92
|
-
microflows = mod.microflows.map { export_service(_1, mod, namespace, root, :microflow) }
|
|
93
|
-
nanoflows = mod.nanoflows.map { export_nanoflow(_1, mod, root) }
|
|
94
|
-
pages = mod.pages.map { export_page(_1, mod, namespace, root) }
|
|
95
|
-
endpoints = export_endpoints(mod)
|
|
96
|
-
{
|
|
97
|
-
'name' => mod.name, 'ruby_namespace' => namespace,
|
|
98
|
-
'module_roles' => runtime_value(mod.module_roles),
|
|
99
|
-
'models' => entities.reject { _1['dto'] },
|
|
100
|
-
'dtos' => entities.select { _1['dto'] },
|
|
101
|
-
'services' => microflows, 'nanoflows' => nanoflows, 'pages' => pages,
|
|
102
|
-
'endpoints' => endpoints,
|
|
103
|
-
'enumerations' => mod.enumerations.map { enumeration_manifest(mod, _1) },
|
|
104
|
-
'associations' => mod.associations.map { association_manifest(mod, _1) },
|
|
105
|
-
'scheduled_events' => mod.scheduled_events.map { runtime_value(_1) }
|
|
106
|
-
}
|
|
150
|
+
def read_embedded_sources
|
|
151
|
+
mpr = IO::MprFile.open(@mpr_path, readonly: true)
|
|
152
|
+
mpr.ruby_app_sources
|
|
153
|
+
ensure
|
|
154
|
+
mpr&.close
|
|
107
155
|
end
|
|
108
156
|
|
|
109
|
-
def
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
base_name = underscore(entity.name)
|
|
113
|
-
base_name = "#{base_name}_dto" if dto && !base_name.end_with?('_dto')
|
|
114
|
-
category = dto ? 'dtos' : 'models'
|
|
115
|
-
relative = File.join('app', category, root, "#{base_name}.rb")
|
|
116
|
-
qualified = "#{mod.name}.#{entity.name}"
|
|
117
|
-
attributes = entity.attributes.map { attribute_manifest(_1) }
|
|
118
|
-
write(
|
|
119
|
-
relative,
|
|
120
|
-
entity_source(
|
|
121
|
-
namespace, class_name, qualified, entity.id, attributes,
|
|
122
|
-
dto:, persistable: entity.persistable == true
|
|
123
|
-
)
|
|
124
|
-
)
|
|
125
|
-
add_coverage(entity.id, qualified, dto ? 'dto' : 'model', relative, 'executable_bidirectional')
|
|
126
|
-
{
|
|
127
|
-
'name' => qualified, 'id' => entity.id, 'ruby_class' => "#{namespace}::#{class_name}",
|
|
128
|
-
'path' => relative, 'dto' => dto, 'persistable' => entity.persistable == true,
|
|
129
|
-
'attributes' => attributes,
|
|
130
|
-
'system_members' => runtime_value(entity.system_members || {}),
|
|
131
|
-
'access_rules' => runtime_value(entity.access_rules || []),
|
|
132
|
-
'lifecycle' => runtime_value(entity.respond_to?(:lifecycle) ? entity.lifecycle : [])
|
|
133
|
-
}
|
|
134
|
-
end
|
|
157
|
+
def read_rest_response_metadata
|
|
158
|
+
path = File.join(@mendix_sidecar, '.mxrb', 'rest_metadata.json')
|
|
159
|
+
return [] unless File.file?(path)
|
|
135
160
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
[entity.id.to_s, "#{project_module.name}.#{entity.name}"]
|
|
140
|
-
end
|
|
141
|
-
end.to_h
|
|
142
|
-
{
|
|
143
|
-
'name' => "#{mod.name}.#{association.name}", 'id' => association.id,
|
|
144
|
-
'type' => association.association_type.to_s,
|
|
145
|
-
'from_entity' => entities[association.from_entity_id.to_s] || association.from_entity_id.to_s,
|
|
146
|
-
'to_entity' => entities[association.to_entity_id.to_s] || association.to_entity_id.to_s
|
|
147
|
-
}
|
|
161
|
+
JSON.parse(File.read(path)).fetch('operations')
|
|
162
|
+
rescue JSON::ParserError, KeyError => e
|
|
163
|
+
raise SerializationError, "invalid REST metadata sidecar #{path}: #{e.message}"
|
|
148
164
|
end
|
|
149
165
|
|
|
150
|
-
def
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
qualified = "#{mod.name}.#{flow.name}"
|
|
154
|
-
write(relative, service_source(namespace, class_name, qualified, flow.id))
|
|
155
|
-
add_coverage(flow.id, qualified, kind.to_s, relative, 'runtime_source_preserved')
|
|
156
|
-
{
|
|
157
|
-
'name' => qualified, 'id' => flow.id,
|
|
158
|
-
'ruby_class' => "#{namespace}::#{class_name}", 'path' => relative,
|
|
159
|
-
'kind' => kind.to_s, 'parameters' => flow.parameters.map { flow_parameter_manifest(_1) },
|
|
160
|
-
'allowed_module_roles' => flow.allowed_module_roles.map(&:to_s)
|
|
161
|
-
}
|
|
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'))
|
|
162
169
|
end
|
|
163
170
|
|
|
164
|
-
def
|
|
165
|
-
|
|
166
|
-
{
|
|
167
|
-
'name' => parameter['Name'].to_s,
|
|
168
|
-
'type' => variable_type['$Type'].to_s,
|
|
169
|
-
'entity' => variable_type['Entity'],
|
|
170
|
-
'required' => parameter['IsRequired'] != false
|
|
171
|
-
}.compact
|
|
171
|
+
def embedded_identity_path(kind, id)
|
|
172
|
+
embedded_identity(kind, id)&.fetch('path')
|
|
172
173
|
end
|
|
173
174
|
|
|
174
|
-
def
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
rest_service_manifest(mod, document)
|
|
179
|
-
end
|
|
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
|
|
180
178
|
end
|
|
181
179
|
|
|
182
|
-
def
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
IO::BsonCodec.parse_array(resource['Operations'])[:items].map do |operation|
|
|
186
|
-
rest_operation_manifest(mod, source, resource, operation)
|
|
187
|
-
end
|
|
188
|
-
end
|
|
189
|
-
add_coverage(
|
|
190
|
-
document.fetch(:id), "#{mod.name}.#{document.fetch(:name)}", 'published_rest_service',
|
|
191
|
-
relative(@mendix_sidecar), 'executable_backend_route'
|
|
192
|
-
)
|
|
193
|
-
{
|
|
194
|
-
'name' => "#{mod.name}.#{document.fetch(:name)}", 'path' => source['Path'].to_s,
|
|
195
|
-
'version' => source['Version'].to_s, 'enable_cors' => source['EnableCors'] == true,
|
|
196
|
-
'requires_authentication' => source['RequiresAuthentication'] == true,
|
|
197
|
-
'operations' => operations
|
|
198
|
-
}
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
def rest_operation_manifest(mod, service, resource, operation)
|
|
202
|
-
microflow = operation['Microflow'].to_s
|
|
203
|
-
microflow = "#{mod.name}.#{microflow}" unless microflow.empty? || microflow.include?('.')
|
|
204
|
-
service_path = service['Path'].to_s.sub(%r{\A/+}, '').sub(%r{/+\z}, '')
|
|
205
|
-
operation_path = operation['Path'].to_s.sub(%r{\A/+}, '')
|
|
206
|
-
{
|
|
207
|
-
'name' => resource['Name'].to_s, 'method' => operation['HttpMethod'].to_s.upcase,
|
|
208
|
-
'path' => "/#{[service_path, operation_path].reject(&:empty?).join('/')}",
|
|
209
|
-
'microflow' => microflow, 'success_status' => rest_success_status(operation['SuccessStatusCode'])
|
|
210
|
-
}
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
def rest_success_status(value)
|
|
214
|
-
return 200 if value.nil? || value.to_s.empty?
|
|
180
|
+
def restore_embedded_sources(files)
|
|
181
|
+
files.each do |file|
|
|
182
|
+
next if file.fetch(:path).start_with?('frontend/src/generated/')
|
|
215
183
|
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
184
|
+
contents = file.fetch(:contents)
|
|
185
|
+
checksum = Digest::SHA256.hexdigest(contents)
|
|
186
|
+
raise SerializationError, "embedded Ruby source checksum mismatch: #{file.fetch(:path)}" \
|
|
187
|
+
unless checksum == file.fetch(:sha256)
|
|
219
188
|
|
|
220
|
-
|
|
221
|
-
|
|
189
|
+
contents = LegacyServiceSourceMigration.new(
|
|
190
|
+
path: file.fetch(:path), source: contents
|
|
191
|
+
).migrate
|
|
222
192
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
entry
|
|
234
|
-
end
|
|
193
|
+
path = RubyApp.safe_source_path(@output_dir, file.fetch(:path))
|
|
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
|
|
235
203
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
parameters = nanoflow_parameter_type(flow.parameters)
|
|
239
|
-
result_type = nanoflow_result_type(flow.respond_to?(:return_type) ? flow.return_type : nil)
|
|
240
|
-
start = plan.fetch('objects').find { _1['type'] == 'StartEvent' }
|
|
241
|
-
cases = plan.fetch('objects').filter_map do |object|
|
|
242
|
-
nanoflow_typescript_case(object, plan.fetch('flows'), result_type)
|
|
204
|
+
File.binwrite(path, contents)
|
|
205
|
+
File.chmod(RubyApp.safe_source_mode(file[:mode], file.fetch(:path)), path)
|
|
243
206
|
end
|
|
244
|
-
<<~TS
|
|
245
|
-
import { defineNanoflow } from '../../runtime/nanoflow';
|
|
246
|
-
import type { EntityTypeMap, NanoflowParameters, RuntimeValue } from '../../types';
|
|
247
|
-
|
|
248
|
-
type Parameters = NanoflowParameters & #{parameters};
|
|
249
|
-
|
|
250
|
-
export default defineNanoflow<Parameters, #{result_type}>({
|
|
251
|
-
name: #{JSON.generate(qualified)},
|
|
252
|
-
id: #{JSON.generate(flow.id.to_s)},
|
|
253
|
-
parameters: #{JSON.generate(plan.fetch('parameters'))}
|
|
254
|
-
}, runtime => {
|
|
255
|
-
let current = #{JSON.generate(start && start['id'])};
|
|
256
|
-
for (let step = 0; step < 10_000; step += 1) {
|
|
257
|
-
switch (current) {
|
|
258
|
-
#{cases.join("\n")}
|
|
259
|
-
default:
|
|
260
|
-
throw runtime.missing(current);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
throw runtime.exceeded();
|
|
264
|
-
});
|
|
265
|
-
TS
|
|
266
207
|
end
|
|
267
208
|
|
|
268
|
-
def
|
|
269
|
-
|
|
270
|
-
|
|
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)
|
|
271
212
|
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
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']
|
|
276
216
|
|
|
277
|
-
|
|
278
|
-
|
|
217
|
+
embedded.match?(
|
|
218
|
+
/def\s+call\(\*\*arguments\)\s+(?:native_call|execute_flow)\(arguments\)\s+end/m
|
|
219
|
+
)
|
|
279
220
|
end
|
|
280
221
|
|
|
281
|
-
def
|
|
282
|
-
|
|
283
|
-
kind = (type['$Type'] || type['Type']).to_s
|
|
284
|
-
entity = type['Entity'].to_s
|
|
285
|
-
return "EntityTypeMap[#{JSON.generate(entity)}] | null" if kind.end_with?('ObjectType') && !entity.empty?
|
|
286
|
-
return "Array<EntityTypeMap[#{JSON.generate(entity)}]>" if kind.end_with?('ListType') && !entity.empty?
|
|
287
|
-
return 'boolean' if kind.match?(/Boolean/)
|
|
288
|
-
return 'number' if kind.match?(/Integer|Long|Decimal|Float/)
|
|
289
|
-
return 'string' if kind.match?(/String|DateTime|Enumeration/)
|
|
290
|
-
return 'undefined' if kind.empty? || kind.match?(/Void|MicroflowReturnType/)
|
|
291
|
-
|
|
292
|
-
'RuntimeValue | undefined'
|
|
293
|
-
end
|
|
222
|
+
def regenerate_legacy_widget_page?(file, generated_path)
|
|
223
|
+
return false unless File.file?(generated_path)
|
|
294
224
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
body = case object['type']
|
|
300
|
-
when 'EndEvent' then nanoflow_end_source(object, result_type)
|
|
301
|
-
when 'ExclusiveSplit' then nanoflow_split_source(object, outgoing)
|
|
302
|
-
when 'ActionActivity' then nanoflow_action_source(object['action']) + nanoflow_next_source(outgoing)
|
|
303
|
-
else nanoflow_next_source(outgoing)
|
|
304
|
-
end
|
|
305
|
-
<<~TS.chomp
|
|
306
|
-
case #{JSON.generate(object['id'])}: {
|
|
307
|
-
#{indent(body, 10)}
|
|
308
|
-
}
|
|
309
|
-
TS
|
|
225
|
+
LegacyWidgetSourceMigration.new(
|
|
226
|
+
path: file.fetch(:path), embedded_source: file.fetch(:contents),
|
|
227
|
+
generated_source: File.binread(generated_path)
|
|
228
|
+
).regenerate?
|
|
310
229
|
end
|
|
311
230
|
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
end
|
|
321
|
-
"return runtime.complete(#{value});"
|
|
322
|
-
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?
|
|
323
239
|
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
fallback = flows.find { _1['case'].to_s.empty? }
|
|
329
|
-
default = if fallback
|
|
330
|
-
"current = #{JSON.generate(fallback['destination'])}; break;"
|
|
331
|
-
else
|
|
332
|
-
"throw runtime.stopped(#{JSON.generate(object['type'])});"
|
|
333
|
-
end
|
|
334
|
-
<<~TS.chomp
|
|
335
|
-
switch (String(runtime.condition(#{JSON.generate(object['condition'].to_s)}))) {
|
|
336
|
-
#{indent(cases.join("\n"), 2)}
|
|
337
|
-
default: #{default}
|
|
338
|
-
}
|
|
339
|
-
break;
|
|
340
|
-
TS
|
|
341
|
-
end
|
|
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'))
|
|
342
244
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
when 'LogMessage'
|
|
347
|
-
"runtime.log(#{JSON.generate(action['message'].to_s)});\n"
|
|
348
|
-
when 'CreateVariable', 'ChangeVariable'
|
|
349
|
-
"runtime.set(#{JSON.generate(action['variable'].to_s)}, " \
|
|
350
|
-
"runtime.value(#{JSON.generate(action['value'].to_s)}));\n"
|
|
351
|
-
when 'Change'
|
|
352
|
-
changes = action.fetch('changes', []).to_h do |change|
|
|
353
|
-
[change['member'].to_s, change['value'].to_s]
|
|
245
|
+
page_name = page.fetch('name').split('.', 2).last
|
|
246
|
+
export_frontend_page(page, root, page_name)
|
|
247
|
+
@page_entries.pop
|
|
354
248
|
end
|
|
355
|
-
"runtime.change(#{JSON.generate(action['variable'].to_s)}, #{JSON.generate(changes)});\n"
|
|
356
|
-
else
|
|
357
|
-
"throw runtime.unsupported(#{JSON.generate(action['type'].to_s)});\n"
|
|
358
249
|
end
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
prefix = ' ' * spaces
|
|
370
|
-
source.to_s.lines.map { "#{prefix}#{_1}" }.join.chomp
|
|
371
|
-
end
|
|
372
|
-
|
|
373
|
-
def nanoflow_plan(flow, qualified)
|
|
374
|
-
{
|
|
375
|
-
'name' => qualified, 'id' => flow.id,
|
|
376
|
-
'parameters' => flow.parameters.filter_map { _1['Name'] if _1.is_a?(Hash) },
|
|
377
|
-
'objects' => flow.objects.filter_map { nanoflow_object(_1) },
|
|
378
|
-
'flows' => flow.flows.reject { _1['IsErrorHandler'] == true }.map do |edge|
|
|
379
|
-
{
|
|
380
|
-
'origin' => native_identifier(edge['OriginPointer']),
|
|
381
|
-
'destination' => native_identifier(edge['DestinationPointer']),
|
|
382
|
-
'case' => nanoflow_case(edge)
|
|
383
|
-
}
|
|
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))
|
|
384
260
|
end
|
|
385
|
-
}
|
|
386
|
-
end
|
|
387
|
-
|
|
388
|
-
def nanoflow_object(object)
|
|
389
|
-
return unless object.is_a?(Hash)
|
|
390
|
-
|
|
391
|
-
type = object['$Type'].to_s.delete_prefix('Microflows$')
|
|
392
|
-
result = { 'id' => native_identifier(object), 'type' => type }
|
|
393
|
-
result['return'] = object['ReturnValue'].to_s if type == 'EndEvent'
|
|
394
|
-
result['condition'] = object.dig('SplitCondition', 'Expression').to_s if type == 'ExclusiveSplit'
|
|
395
|
-
result['action'] = nanoflow_action(object['Action']) if type == 'ActionActivity'
|
|
396
|
-
result
|
|
397
|
-
end
|
|
398
|
-
|
|
399
|
-
def nanoflow_action(action)
|
|
400
|
-
return {} unless action.is_a?(Hash)
|
|
401
|
-
|
|
402
|
-
type = action['$Type'].to_s.delete_prefix('Microflows$').delete_suffix('Action')
|
|
403
|
-
result = { 'type' => type }
|
|
404
|
-
case type
|
|
405
|
-
when 'CreateVariable'
|
|
406
|
-
result.merge!('variable' => action['VariableName'].to_s, 'value' => action['InitialValue'].to_s)
|
|
407
|
-
when 'ChangeVariable'
|
|
408
|
-
result.merge!('variable' => action['ChangeVariableName'].to_s, 'value' => action['Value'].to_s)
|
|
409
|
-
when 'Change'
|
|
410
|
-
changes = native_items(action['Items']).map do |item|
|
|
411
|
-
member = (item['Attribute'].to_s.empty? ? item['Association'] : item['Attribute']).to_s
|
|
412
|
-
{ 'member' => member.split(%r{[./]}).last, 'value' => item['Value'].to_s }
|
|
413
|
-
end
|
|
414
|
-
result.merge!('variable' => action['ChangeVariableName'].to_s, 'changes' => changes)
|
|
415
|
-
when 'LogMessage'
|
|
416
|
-
result['message'] = action.dig('MessageTemplate', 'Text').to_s
|
|
417
261
|
end
|
|
418
|
-
|
|
262
|
+
write_generated_frontend_contract
|
|
419
263
|
end
|
|
420
264
|
|
|
421
|
-
def
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
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})
|
|
425
268
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
rescue StandardError
|
|
429
|
-
Array(value).drop(value.is_a?(Array) && value.first.is_a?(Integer) ? 1 : 0)
|
|
430
|
-
end
|
|
431
|
-
|
|
432
|
-
def native_identifier(value)
|
|
433
|
-
IO::BsonCodec.extract_id(value.is_a?(Hash) ? value['$ID'] : value).to_s
|
|
434
|
-
end
|
|
435
|
-
|
|
436
|
-
def export_page(page, mod, namespace, root)
|
|
437
|
-
class_name = ruby_constant(page.name, suffix: 'Page')
|
|
438
|
-
relative = File.join('app', 'pages', root, "#{underscore(page.name)}_page.rb")
|
|
439
|
-
qualified = "#{mod.name}.#{page.name}"
|
|
440
|
-
widgets = page.widgets.map { widget_manifest(_1) }
|
|
441
|
-
write(
|
|
442
|
-
relative,
|
|
443
|
-
page_source(namespace, class_name, qualified, page.id, page.title, widgets,
|
|
444
|
-
appearance_class: page.appearance_class,
|
|
445
|
-
appearance_style: page.appearance_style,
|
|
446
|
-
data_source: page.data_source)
|
|
447
|
-
)
|
|
448
|
-
add_coverage(page.id, qualified, 'page', relative, 'native_projection_source_preserved')
|
|
449
|
-
manifest = {
|
|
450
|
-
'name' => qualified, 'id' => page.id, 'title' => page.title,
|
|
451
|
-
'ruby_class' => "#{namespace}::#{class_name}", 'path' => relative,
|
|
452
|
-
'appearance_class' => page.appearance_class,
|
|
453
|
-
'appearance_style' => page.appearance_style,
|
|
454
|
-
'data_source' => page.data_source,
|
|
455
|
-
'allowed_module_roles' => page.allowed_module_roles.map(&:to_s),
|
|
456
|
-
'widgets' => widgets
|
|
457
|
-
}
|
|
458
|
-
export_frontend_page(manifest, root, page.name)
|
|
459
|
-
manifest
|
|
460
|
-
end
|
|
461
|
-
|
|
462
|
-
def export_frontend_page(manifest, root, page_name)
|
|
463
|
-
relative = File.join('frontend', 'src', 'pages', root, "#{underscore(page_name)}.tsx")
|
|
464
|
-
component = "#{typescript_identifier(manifest.fetch('name'))}Page"
|
|
465
|
-
definition = manifest.slice('name', 'title', 'appearance_class', 'appearance_style', 'widgets')
|
|
466
|
-
declarations = []
|
|
467
|
-
compiled_widgets = definition.fetch('widgets').each_with_index.map do |widget, index|
|
|
468
|
-
frontend_widget_jsx(widget, [index], declarations, 6)
|
|
469
|
-
end
|
|
470
|
-
widget_tree = compiled_widgets.map(&:first).join("\n")
|
|
471
|
-
definition_source = frontend_page_definition_source(definition, compiled_widgets.map(&:last))
|
|
472
|
-
write(relative, <<~TS)
|
|
473
|
-
import type { PageComponentProps, PageDefinition, WidgetDefinition } from '../../types';
|
|
474
|
-
|
|
475
|
-
#{declarations.join("\n\n")}
|
|
476
|
-
|
|
477
|
-
export const definition = #{definition_source} satisfies PageDefinition;
|
|
478
|
-
|
|
479
|
-
export default function #{component}({ busy, Widget: PageWidget }: PageComponentProps) {
|
|
480
|
-
return <main className="mxrb-page region-content mx-scrollcontainer-wrapper"
|
|
481
|
-
aria-busy={busy} data-page={definition.name}>
|
|
482
|
-
#{widget_tree}
|
|
483
|
-
</main>;
|
|
484
|
-
}
|
|
485
|
-
TS
|
|
486
|
-
@page_entries << {
|
|
487
|
-
'name' => manifest.fetch('name'), 'path' => relative,
|
|
488
|
-
'import_name' => component
|
|
489
|
-
}
|
|
490
|
-
end
|
|
269
|
+
source = file.fetch(:contents).to_s
|
|
270
|
+
next unless source.match?(/^\s*native(?:\s|\()/)
|
|
491
271
|
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
compiled = widget.reject { |key, _value| key == 'children' }
|
|
496
|
-
nested_widgets = children.each_with_index.map do |child, index|
|
|
497
|
-
frontend_widget_jsx(child, path + [index], declarations, indent + 2)
|
|
498
|
-
end
|
|
499
|
-
source = JSON.pretty_generate(compiled)
|
|
500
|
-
unless nested_widgets.empty?
|
|
501
|
-
source = source.sub(/\n}\z/, ",\n \"children\": [#{nested_widgets.map(&:last).join(', ')}]\n}")
|
|
502
|
-
end
|
|
503
|
-
declarations << "const #{identifier} = #{source} satisfies WidgetDefinition;"
|
|
504
|
-
padding = ' ' * indent
|
|
505
|
-
return ["#{padding}<PageWidget widget={#{identifier}} index={#{path.last}} />", identifier] if children.empty?
|
|
506
|
-
|
|
507
|
-
nested = nested_widgets.map(&:first).join("\n")
|
|
508
|
-
jsx = <<~TS.chomp
|
|
509
|
-
#{padding}<PageWidget widget={#{identifier}} index={#{path.last}}>
|
|
510
|
-
#{nested}
|
|
511
|
-
#{padding}</PageWidget>
|
|
512
|
-
TS
|
|
513
|
-
[jsx, identifier]
|
|
272
|
+
match = source.match(/^\s*mendix_name\s+(['"])([^'"]+)\1/)
|
|
273
|
+
match && match[2]
|
|
274
|
+
end.uniq
|
|
514
275
|
end
|
|
515
276
|
|
|
516
|
-
def
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
'default' => attribute.default_value, 'id' => attribute.id
|
|
526
|
-
}
|
|
527
|
-
enumeration = native_identifier(attribute.respond_to?(:enumeration) ? attribute.enumeration : nil)
|
|
528
|
-
value['enumeration'] = enumeration unless enumeration.empty?
|
|
529
|
-
value
|
|
530
|
-
end
|
|
531
|
-
|
|
532
|
-
def enumeration_manifest(mod, enumeration)
|
|
533
|
-
name = enumeration['Name'].to_s
|
|
534
|
-
{
|
|
535
|
-
'name' => "#{mod.name}.#{name}",
|
|
536
|
-
'id' => native_identifier(enumeration['$ID']),
|
|
537
|
-
'values' => native_items(enumeration['Values']).map do |value|
|
|
538
|
-
value_name = value['Name'].to_s
|
|
539
|
-
{ 'name' => value_name, 'caption' => translated_caption(value['Caption'], value_name) }
|
|
540
|
-
end
|
|
541
|
-
}
|
|
542
|
-
end
|
|
543
|
-
|
|
544
|
-
def translated_caption(caption, fallback)
|
|
545
|
-
translation = native_items(caption.is_a?(Hash) ? caption['Items'] : nil).first
|
|
546
|
-
text = translation.is_a?(Hash) ? translation['Text'].to_s : ''
|
|
547
|
-
text.empty? ? fallback : text
|
|
548
|
-
end
|
|
549
|
-
|
|
550
|
-
def widget_manifest(widget)
|
|
551
|
-
options = runtime_value(widget.fetch(:options, {}))
|
|
552
|
-
value = { 'type' => runtime_widget_type(widget), 'name' => widget.fetch(:name, '').to_s }
|
|
553
|
-
value['options'] = options unless options.empty?
|
|
554
|
-
caption = options['caption']
|
|
555
|
-
value['caption'] = caption unless caption.to_s.empty?
|
|
556
|
-
events = runtime_value(widget.fetch(:events, []))
|
|
557
|
-
value['events'] = events unless events.empty?
|
|
558
|
-
children = Array(widget[:children]).map { widget_manifest(_1) }
|
|
559
|
-
value['children'] = children unless children.empty?
|
|
560
|
-
value
|
|
561
|
-
end
|
|
562
|
-
|
|
563
|
-
def runtime_widget_type(widget)
|
|
564
|
-
type = widget.fetch(:type).to_s
|
|
565
|
-
return type unless type == 'text_box'
|
|
566
|
-
|
|
567
|
-
path = widget.dig(:options, :attribute).to_s.tr('/', '.')
|
|
568
|
-
module_name, entity_name, attribute_name = path.split('.', 3)
|
|
569
|
-
return type unless attribute_name
|
|
570
|
-
|
|
571
|
-
entity = @project.modules.find { _1.name == module_name }
|
|
572
|
-
&.entities&.find { _1.name == entity_name }
|
|
573
|
-
attribute = entity&.attributes&.find { _1.name == attribute_name }
|
|
574
|
-
%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
|
|
575
286
|
end
|
|
576
287
|
|
|
577
|
-
def
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
when Array then value.map { runtime_value(_1) }
|
|
586
|
-
when Symbol then value.to_s
|
|
587
|
-
when String, Numeric, TrueClass, FalseClass, NilClass then value
|
|
588
|
-
else value.to_s
|
|
589
|
-
end
|
|
590
|
-
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)
|
|
591
296
|
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
"mendix_name: #{attribute.fetch('name').inspect}, required: #{attribute.fetch('required')}, " \
|
|
596
|
-
"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)
|
|
597
300
|
end
|
|
598
|
-
<<~RUBY
|
|
599
|
-
# frozen_string_literal: true
|
|
600
|
-
|
|
601
|
-
module #{namespace}
|
|
602
|
-
class #{class_name} < Mxrb::RubyApp::#{dto ? 'DTO' : 'Record'}
|
|
603
|
-
mendix_name #{qualified.inspect}, id: #{id.inspect}
|
|
604
|
-
persistence #{persistable}
|
|
605
|
-
#{declarations.join("\n")}
|
|
606
|
-
end
|
|
607
|
-
end
|
|
608
|
-
RUBY
|
|
609
301
|
end
|
|
610
302
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
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
|
|
618
437
|
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
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
|
|
625
445
|
end
|
|
626
446
|
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
data_source: #{data_source.inspect}
|
|
639
|
-
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"
|
|
640
458
|
end
|
|
641
|
-
RUBY
|
|
642
|
-
end
|
|
643
|
-
|
|
644
|
-
def write_support_files
|
|
645
|
-
write('Gemfile', gemfile)
|
|
646
|
-
write('.gitignore', ruby_gitignore)
|
|
647
|
-
write('.env.example', ruby_env_example)
|
|
648
|
-
%w[development qa staging production].each do |name|
|
|
649
|
-
write(File.join('config', 'environments', "#{name}.env.example"), environment_example(name))
|
|
650
459
|
end
|
|
651
|
-
|
|
652
|
-
write(File.join('config', 'application.rb'), application_source)
|
|
653
|
-
write(File.join('config', 'adapters.rb'), adapters_source)
|
|
654
|
-
write(File.join('bin', 'server'), server_source)
|
|
655
|
-
File.chmod(0o755, File.join(@output_dir, 'bin', 'server'))
|
|
656
|
-
write(File.join('frontend', 'package.json'), frontend_package)
|
|
657
|
-
write(File.join('frontend', 'vite.config.ts'), vite_config)
|
|
658
|
-
write(File.join('frontend', 'tsconfig.json'), frontend_tsconfig)
|
|
659
|
-
write(File.join('frontend', 'index.html'), frontend_index)
|
|
660
|
-
write(File.join('frontend', 'src', 'vite-env.d.ts'), "/// <reference types=\"vite/client\" />\n")
|
|
661
|
-
write(File.join('frontend', 'src', 'main.tsx'), frontend_main)
|
|
662
|
-
write(File.join('frontend', 'src', 'types.ts'), frontend_types)
|
|
663
|
-
write(File.join('frontend', 'src', 'api', 'client.ts'), frontend_api_client)
|
|
664
|
-
write(File.join('frontend', 'src', 'runtime', 'nanoflow.ts'), frontend_nanoflow_runtime)
|
|
665
|
-
write(File.join('frontend', 'src', 'runtime', 'marketplace.tsx'), frontend_marketplace_runtime)
|
|
666
|
-
write(File.join('frontend', 'src', 'nanoflows.ts'), frontend_nanoflows)
|
|
667
|
-
write(File.join('frontend', 'src', 'pages.ts'), frontend_pages)
|
|
668
|
-
write(File.join('frontend', 'src', 'app', 'App.tsx'), frontend_app)
|
|
669
|
-
write(File.join('frontend', 'src', 'App.tsx'), "export { default } from './app/App';\n")
|
|
670
|
-
write(File.join('frontend', 'src', 'app.css'), frontend_css)
|
|
671
|
-
write('README.md', readme)
|
|
460
|
+
duplicate_groups.values.flatten.map { _1.id.to_s }.uniq.freeze
|
|
672
461
|
end
|
|
673
462
|
|
|
674
|
-
def
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
%w[theme themesource].each do |directory|
|
|
678
|
-
source = File.join(@mendix_sidecar, directory)
|
|
679
|
-
next unless File.directory?(source)
|
|
463
|
+
def flow_file_stem(flow, duplicate_name:)
|
|
464
|
+
base = underscore(flow.name)
|
|
465
|
+
return base unless duplicate_name
|
|
680
466
|
|
|
681
|
-
|
|
682
|
-
end
|
|
683
|
-
fallback = File.join(root, 'theme', 'web', 'main.scss')
|
|
684
|
-
write(relative(fallback), '') unless File.file?(fallback)
|
|
467
|
+
"#{base}_#{flow_identity_suffix(flow)}"
|
|
685
468
|
end
|
|
686
469
|
|
|
687
|
-
def
|
|
688
|
-
|
|
689
|
-
Find.find(source) do |path|
|
|
690
|
-
relative_path = path.delete_prefix("#{source}/")
|
|
691
|
-
Find.prune if File.directory?(path) && relative_path.split(File::SEPARATOR).include?('native')
|
|
692
|
-
next if path == source
|
|
693
|
-
next if File.file?(path) && %w[.js .jsx].include?(File.extname(path).downcase)
|
|
694
|
-
|
|
695
|
-
target = File.join(destination, relative_path)
|
|
696
|
-
if File.directory?(path)
|
|
697
|
-
FileUtils.mkdir_p(target)
|
|
698
|
-
else
|
|
699
|
-
FileUtils.mkdir_p(File.dirname(target))
|
|
700
|
-
FileUtils.cp(path, target)
|
|
701
|
-
end
|
|
702
|
-
end
|
|
703
|
-
end
|
|
470
|
+
def flow_ruby_constant(flow, duplicate_name:)
|
|
471
|
+
return ruby_constant(flow.name) unless duplicate_name
|
|
704
472
|
|
|
705
|
-
|
|
706
|
-
native_coverage(project)
|
|
707
|
-
payload = {
|
|
708
|
-
'format_version' => 1, 'mode' => 'ruby',
|
|
709
|
-
'project' => { 'name' => project.name, 'mendix_version' => project.mendix_version },
|
|
710
|
-
'navigation' => runtime_value(project.navigation.to_h),
|
|
711
|
-
'source' => {
|
|
712
|
-
'name' => File.basename(@mpr_path),
|
|
713
|
-
'sha256' => Digest::SHA256.file(@mpr_path).hexdigest
|
|
714
|
-
},
|
|
715
|
-
'modules' => modules, 'coverage' => @coverage,
|
|
716
|
-
'frontend' => {
|
|
717
|
-
'framework' => 'react', 'language' => 'typescript', 'bundler' => 'vite',
|
|
718
|
-
'source' => 'frontend/src', 'types' => 'frontend/src/types.ts',
|
|
719
|
-
'typecheck' => 'npm run typecheck', 'build' => 'frontend/dist'
|
|
720
|
-
},
|
|
721
|
-
'round_trip' => {
|
|
722
|
-
'compiler' => 'project.rb',
|
|
723
|
-
'mendix_project' => relative(File.join(@mendix_sidecar, 'project.rb')),
|
|
724
|
-
'runtime_mpr' => relative(runtime_mpr),
|
|
725
|
-
'editable_mendix_source' => relative(@mendix_sidecar)
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
preset = Preset.detect(@output_dir)
|
|
729
|
-
payload['ruby_stack'] = Preset.manifest(preset) if preset
|
|
730
|
-
write(MANIFEST_PATH, JSON.pretty_generate(payload) << "\n")
|
|
473
|
+
ruby_constant("#{flow.name}_#{flow_identity_suffix(flow)}")
|
|
731
474
|
end
|
|
732
475
|
|
|
733
|
-
def
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
next if known_ids[unit.fetch('UnitID').to_s]
|
|
737
|
-
|
|
738
|
-
document = project.parse_bson(unit)
|
|
739
|
-
name = document['Name'] || document['name'] || document['$Type']
|
|
740
|
-
add_coverage(
|
|
741
|
-
unit['UnitID'], name.to_s, document['$Type'].to_s,
|
|
742
|
-
relative(@mendix_sidecar), 'preserved_native'
|
|
743
|
-
)
|
|
744
|
-
end
|
|
745
|
-
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?
|
|
746
479
|
|
|
747
|
-
|
|
748
|
-
@coverage << {
|
|
749
|
-
'id' => id.to_s, 'name' => name.to_s, 'kind' => kind.to_s,
|
|
750
|
-
'ruby_path' => path, 'status' => status
|
|
751
|
-
}
|
|
752
|
-
end
|
|
753
|
-
|
|
754
|
-
def ruby_constant(value, suffix: nil)
|
|
755
|
-
parts = value.to_s.gsub(/([a-z\d])([A-Z])/, '\\1_\\2')
|
|
756
|
-
.split(/[^A-Za-z0-9]+/).reject(&:empty?)
|
|
757
|
-
constant = parts.map { _1[0].upcase + _1[1..].to_s.downcase }.join
|
|
758
|
-
constant = "Artifact#{constant}" if constant.empty? || constant.match?(/\A\d/)
|
|
759
|
-
constant = "#{constant}#{suffix}" if suffix && !constant.end_with?(suffix)
|
|
760
|
-
constant
|
|
480
|
+
identifier
|
|
761
481
|
end
|
|
762
482
|
|
|
763
483
|
def ruby_method_name(value)
|
|
@@ -778,1684 +498,28 @@ module Mxrb
|
|
|
778
498
|
|
|
779
499
|
def write(relative_path, contents)
|
|
780
500
|
path = File.join(@output_dir, relative_path)
|
|
501
|
+
claim_declaration_path(relative_path, contents)
|
|
781
502
|
FileUtils.mkdir_p(File.dirname(path))
|
|
782
503
|
File.write(path, contents)
|
|
783
504
|
end
|
|
784
505
|
|
|
785
|
-
|
|
786
|
-
<<~RUBY
|
|
787
|
-
# frozen_string_literal: true
|
|
788
|
-
|
|
789
|
-
source 'https://rubygems.org'
|
|
790
|
-
gem 'mxrb'
|
|
791
|
-
RUBY
|
|
792
|
-
end
|
|
793
|
-
|
|
794
|
-
def ruby_gitignore
|
|
795
|
-
<<~TEXT
|
|
796
|
-
.env
|
|
797
|
-
.env.*
|
|
798
|
-
!.env.example
|
|
799
|
-
config/environments/*.env
|
|
800
|
-
!config/environments/*.env.example
|
|
801
|
-
.mxrb/runtime/*.sqlite3
|
|
802
|
-
frontend/node_modules/
|
|
803
|
-
frontend/dist/
|
|
804
|
-
TEXT
|
|
805
|
-
end
|
|
806
|
-
|
|
807
|
-
def ruby_env_example
|
|
808
|
-
<<~TEXT
|
|
809
|
-
# Base values; environment profiles override this file.
|
|
810
|
-
MXRB_ENV=development
|
|
811
|
-
TEXT
|
|
812
|
-
end
|
|
813
|
-
|
|
814
|
-
def environment_example(name)
|
|
815
|
-
<<~TEXT
|
|
816
|
-
# Copy to #{name}.env. Process ENV has highest precedence.
|
|
817
|
-
MXRB_DATABASE_PATH=.mxrb/runtime/#{name}.sqlite3
|
|
818
|
-
MXRB_SHARED_STORE_PATH=.mxrb/runtime/#{name}-shared.sqlite3
|
|
819
|
-
MXRB_SESSION_TTL=3600
|
|
820
|
-
MXRB_SCHEDULER_LEASE_TTL=300
|
|
821
|
-
MXRB_ALLOW_DESTRUCTIVE_MIGRATIONS=false
|
|
822
|
-
MXRB_AUTH_TOKENS=
|
|
823
|
-
MXRB_USERS_JSON=
|
|
824
|
-
TEXT
|
|
825
|
-
end
|
|
826
|
-
|
|
827
|
-
def project_source
|
|
828
|
-
<<~RUBY
|
|
829
|
-
# frozen_string_literal: true
|
|
830
|
-
|
|
831
|
-
require 'mxrb'
|
|
832
|
-
|
|
833
|
-
mendix_version = #{@project.mendix_version.inspect}
|
|
834
|
-
Mxrb::RubyApp.compile(__dir__, mendix_version:)
|
|
835
|
-
RUBY
|
|
836
|
-
end
|
|
837
|
-
|
|
838
|
-
def application_source
|
|
839
|
-
<<~RUBY
|
|
840
|
-
# frozen_string_literal: true
|
|
841
|
-
|
|
842
|
-
require 'mxrb'
|
|
843
|
-
|
|
844
|
-
MXRB_APPLICATION_ROOT = File.expand_path('..', __dir__)
|
|
845
|
-
RUBY
|
|
846
|
-
end
|
|
847
|
-
|
|
848
|
-
def adapters_source
|
|
849
|
-
<<~RUBY
|
|
850
|
-
# frozen_string_literal: true
|
|
851
|
-
|
|
852
|
-
# Register only the integrations this application uses. Credentials
|
|
853
|
-
# belong in ignored environment files or a deployment secret manager.
|
|
854
|
-
#
|
|
855
|
-
# Mxrb::RubyApp::Registry.register_adapter(:app_service) do |name, document, variables|
|
|
856
|
-
# MyAppServiceClient.call(name, document:, variables:)
|
|
857
|
-
# end
|
|
858
|
-
#
|
|
859
|
-
# Legacy Custom Actions use Ruby implementations only. Register every
|
|
860
|
-
# permitted action explicitly by its qualified Mendix name.
|
|
861
|
-
#
|
|
862
|
-
# Mxrb::RubyApp::Registry.register_java_custom_action('MyModule.MyAction') do |arguments|
|
|
863
|
-
# MyRubyAction.call(arguments)
|
|
864
|
-
# end
|
|
865
|
-
#
|
|
866
|
-
# Supported kinds: :app_service, :web_service, :import_xml,
|
|
867
|
-
# :import_mapping, :export_mapping, and :document.
|
|
868
|
-
RUBY
|
|
869
|
-
end
|
|
870
|
-
|
|
871
|
-
def server_source
|
|
872
|
-
<<~RUBY
|
|
873
|
-
#!/usr/bin/env ruby
|
|
874
|
-
# frozen_string_literal: true
|
|
875
|
-
|
|
876
|
-
require_relative '../config/application'
|
|
877
|
-
|
|
878
|
-
host = ENV.fetch('HOST', '127.0.0.1')
|
|
879
|
-
port = Integer(ENV.fetch('PORT', '9292'))
|
|
880
|
-
frontend_port = Integer(ENV.fetch('FRONTEND_PORT', '5173'))
|
|
881
|
-
supervisor = Mxrb::RubyApp::Supervisor.new(
|
|
882
|
-
MXRB_APPLICATION_ROOT, host:, api_port: port, frontend_port:
|
|
883
|
-
)
|
|
884
|
-
puts "[mxrb] Ruby API: http://\#{host}:\#{port}"
|
|
885
|
-
puts "[mxrb] React + Vite: http://\#{host}:\#{frontend_port}"
|
|
886
|
-
trap('INT') { Thread.new { supervisor.shutdown } }
|
|
887
|
-
supervisor.start
|
|
888
|
-
RUBY
|
|
889
|
-
end
|
|
890
|
-
|
|
891
|
-
def frontend_package
|
|
892
|
-
JSON.pretty_generate(
|
|
893
|
-
'name' => underscore(@project.name), 'private' => true, 'version' => '0.0.0',
|
|
894
|
-
'type' => 'module',
|
|
895
|
-
'scripts' => {
|
|
896
|
-
'dev' => 'vite', 'typecheck' => 'tsc --noEmit',
|
|
897
|
-
'build' => 'npm run typecheck && vite build', 'preview' => 'vite preview'
|
|
898
|
-
},
|
|
899
|
-
'dependencies' => { 'react' => '^19.2.8', 'react-dom' => '^19.2.8' },
|
|
900
|
-
'devDependencies' => {
|
|
901
|
-
'@types/node' => '^26.2.0', '@types/react' => '^19.2.18',
|
|
902
|
-
'@types/react-dom' => '^19.2.4', '@vitejs/plugin-react' => '^6.0.5',
|
|
903
|
-
'sass-embedded' => '^1.90.0', 'typescript' => '^7.0.2', 'vite' => '^8.2.1'
|
|
904
|
-
}
|
|
905
|
-
) << "\n"
|
|
906
|
-
end
|
|
907
|
-
|
|
908
|
-
def frontend_tsconfig
|
|
909
|
-
JSON.pretty_generate(
|
|
910
|
-
'compilerOptions' => {
|
|
911
|
-
'target' => 'ES2022', 'useDefineForClassFields' => true,
|
|
912
|
-
'lib' => %w[ES2022 DOM DOM.Iterable], 'allowJs' => false,
|
|
913
|
-
'skipLibCheck' => true, 'esModuleInterop' => true,
|
|
914
|
-
'allowSyntheticDefaultImports' => true, 'strict' => true,
|
|
915
|
-
'noImplicitAny' => true, 'useUnknownInCatchVariables' => true,
|
|
916
|
-
'forceConsistentCasingInFileNames' => true, 'module' => 'ESNext',
|
|
917
|
-
'moduleResolution' => 'Bundler', 'resolveJsonModule' => true,
|
|
918
|
-
'isolatedModules' => true, 'noEmit' => true, 'jsx' => 'react-jsx'
|
|
919
|
-
},
|
|
920
|
-
'include' => ['src', 'vite.config.ts']
|
|
921
|
-
) << "\n"
|
|
922
|
-
end
|
|
923
|
-
|
|
924
|
-
def vite_config
|
|
925
|
-
<<~JS
|
|
926
|
-
import { defineConfig } from 'vite';
|
|
927
|
-
import react from '@vitejs/plugin-react';
|
|
928
|
-
|
|
929
|
-
const apiPort = process.env.MXRB_API_PORT || '9292';
|
|
930
|
-
|
|
931
|
-
export default defineConfig({
|
|
932
|
-
plugins: [react()],
|
|
933
|
-
css: {
|
|
934
|
-
preprocessorOptions: {
|
|
935
|
-
scss: {
|
|
936
|
-
// Mendix Atlas still depends on the legacy global Sass module model.
|
|
937
|
-
silenceDeprecations: ['import', 'global-builtin']
|
|
938
|
-
}
|
|
939
|
-
}
|
|
940
|
-
},
|
|
941
|
-
server: { proxy: { '/api': `http://127.0.0.1:${apiPort}` } }
|
|
942
|
-
});
|
|
943
|
-
JS
|
|
944
|
-
end
|
|
945
|
-
|
|
946
|
-
def frontend_index
|
|
947
|
-
<<~HTML
|
|
948
|
-
<!doctype html>
|
|
949
|
-
<html lang="en">
|
|
950
|
-
<head>
|
|
951
|
-
<meta charset="utf-8">
|
|
952
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
953
|
-
<title>#{escape_html(@project.name)} · MXRB Ruby</title>
|
|
954
|
-
</head>
|
|
955
|
-
<body>
|
|
956
|
-
<div id="root"></div>
|
|
957
|
-
<script type="module" src="/src/main.tsx"></script>
|
|
958
|
-
</body>
|
|
959
|
-
</html>
|
|
960
|
-
HTML
|
|
961
|
-
end
|
|
962
|
-
|
|
963
|
-
def frontend_main
|
|
964
|
-
<<~JS
|
|
965
|
-
import React from 'react';
|
|
966
|
-
import { createRoot } from 'react-dom/client';
|
|
967
|
-
import App from './app/App';
|
|
968
|
-
import './app.css';
|
|
969
|
-
import './mendix/theme/web/main.scss';
|
|
970
|
-
|
|
971
|
-
const root = document.getElementById('root');
|
|
972
|
-
if (!root) throw new Error('MXRB frontend root element is missing');
|
|
973
|
-
|
|
974
|
-
createRoot(root).render(
|
|
975
|
-
<React.StrictMode><App /></React.StrictMode>
|
|
976
|
-
);
|
|
977
|
-
JS
|
|
978
|
-
end
|
|
979
|
-
|
|
980
|
-
def frontend_nanoflows
|
|
981
|
-
imports = @nanoflow_entries.map do |entry|
|
|
982
|
-
relative = entry.fetch('path').delete_prefix('frontend/src/')
|
|
983
|
-
"import #{entry.fetch('import_name')} from './#{relative.delete_suffix('.ts')}';"
|
|
984
|
-
end
|
|
985
|
-
mappings = @nanoflow_entries.map do |entry|
|
|
986
|
-
" #{entry.fetch('name').inspect}: #{entry.fetch('import_name')}"
|
|
987
|
-
end
|
|
988
|
-
<<~TS
|
|
989
|
-
import type { RegisteredNanoflow } from './types';
|
|
506
|
+
DECLARATION_ROOTS = %w[app/ frontend/src/generated/pages/ frontend/src/generated/nanoflows/].freeze
|
|
990
507
|
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
export default nanoflows;
|
|
998
|
-
TS
|
|
999
|
-
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)
|
|
1000
514
|
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
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"
|
|
1005
520
|
end
|
|
1006
|
-
mappings = @page_entries.map do |entry|
|
|
1007
|
-
" #{JSON.generate(entry.fetch('name'))}: #{entry.fetch('import_name')}"
|
|
1008
|
-
end
|
|
1009
|
-
<<~TS
|
|
1010
|
-
import type { ComponentType } from 'react';
|
|
1011
|
-
import type { PageComponentProps } from './types';
|
|
1012
|
-
|
|
1013
|
-
#{imports.join("\n")}
|
|
1014
|
-
|
|
1015
|
-
const pages: Record<string, ComponentType<PageComponentProps>> = {
|
|
1016
|
-
#{mappings.join(",\n")}
|
|
1017
|
-
};
|
|
1018
|
-
|
|
1019
|
-
export default pages;
|
|
1020
|
-
TS
|
|
1021
|
-
end
|
|
1022
|
-
|
|
1023
|
-
def frontend_api_client
|
|
1024
|
-
<<~'TS'
|
|
1025
|
-
import type { ApiFailure, RuntimeValue } from '../types';
|
|
1026
|
-
|
|
1027
|
-
const errorMessage = (payload: unknown, status: number): string => {
|
|
1028
|
-
if (payload && typeof payload === 'object' && 'error' in payload) {
|
|
1029
|
-
const error = payload.error;
|
|
1030
|
-
if (error && typeof error === 'object' && 'message' in error) return String(error.message);
|
|
1031
|
-
}
|
|
1032
|
-
return `HTTP ${status}`;
|
|
1033
|
-
};
|
|
1034
|
-
|
|
1035
|
-
export const api = async <T = RuntimeValue | undefined>(
|
|
1036
|
-
path: string, options: RequestInit = {}, token: string | null = null
|
|
1037
|
-
): Promise<T> => {
|
|
1038
|
-
const headers = new Headers(options.headers);
|
|
1039
|
-
headers.set('Content-Type', 'application/json');
|
|
1040
|
-
if (token) headers.set('Authorization', `Bearer ${token}`);
|
|
1041
|
-
const response = await fetch(path, { ...options, headers });
|
|
1042
|
-
const payload: unknown = await response.json();
|
|
1043
|
-
if (!response.ok) {
|
|
1044
|
-
const error: ApiFailure = new Error(errorMessage(payload, response.status));
|
|
1045
|
-
error.status = response.status;
|
|
1046
|
-
throw error;
|
|
1047
|
-
}
|
|
1048
|
-
return payload as T;
|
|
1049
|
-
};
|
|
1050
|
-
TS
|
|
1051
|
-
end
|
|
1052
521
|
|
|
1053
|
-
|
|
1054
|
-
<<~'TS'
|
|
1055
|
-
import type {
|
|
1056
|
-
EntityRecord, NanoflowExecution, NanoflowMetadata, NanoflowParameters,
|
|
1057
|
-
RegisteredNanoflow, RuntimeValue
|
|
1058
|
-
} from '../types';
|
|
1059
|
-
|
|
1060
|
-
type ChangeExpressions = Record<string, string>;
|
|
1061
|
-
type Comparable = string | number;
|
|
1062
|
-
|
|
1063
|
-
const isRecord = (value: RuntimeValue | undefined): value is EntityRecord => {
|
|
1064
|
-
return Boolean(value && typeof value === 'object'
|
|
1065
|
-
&& 'id' in value && 'type' in value && 'attributes' in value);
|
|
1066
|
-
};
|
|
1067
|
-
|
|
1068
|
-
const attributes = (value: RuntimeValue | undefined): Record<string, RuntimeValue | undefined> => {
|
|
1069
|
-
return isRecord(value) ? value.attributes : {};
|
|
1070
|
-
};
|
|
1071
|
-
|
|
1072
|
-
const memberName = (value: string): string => value.split(/[./]/).at(-1) || value;
|
|
1073
|
-
|
|
1074
|
-
export class NanoflowRuntime<P extends NanoflowParameters = NanoflowParameters> {
|
|
1075
|
-
readonly variables: NanoflowParameters;
|
|
1076
|
-
readonly #changes = new Map<string, EntityRecord>();
|
|
1077
|
-
|
|
1078
|
-
constructor(parameters: P, readonly metadata: NanoflowMetadata) {
|
|
1079
|
-
this.variables = structuredClone(parameters);
|
|
1080
|
-
}
|
|
1081
|
-
|
|
1082
|
-
value(source: string | undefined, context: EntityRecord | null = null): RuntimeValue | undefined {
|
|
1083
|
-
const text = (source || '').trim();
|
|
1084
|
-
if (/\s(?:and|or)\s|(?:=|!=|>=|<=|>|<)/.test(text)) {
|
|
1085
|
-
return this.condition(text, context);
|
|
1086
|
-
}
|
|
1087
|
-
const wrapped = text.match(/^toString\((.*)\)$/);
|
|
1088
|
-
if (wrapped) return this.string(wrapped[1], context);
|
|
1089
|
-
if (text === '$currentObject') return context;
|
|
1090
|
-
const variable = text.match(/^\$([A-Za-z_]\w*)$/);
|
|
1091
|
-
if (variable) return this.variables[variable[1]] ?? context;
|
|
1092
|
-
const member = text.match(/^\$([A-Za-z_]\w*)\/([A-Za-z_][\w.]*)$/);
|
|
1093
|
-
if (member) {
|
|
1094
|
-
return attributes(this.variables[member[1]] ?? context)[memberName(member[2])];
|
|
1095
|
-
}
|
|
1096
|
-
if (text === 'empty') return null;
|
|
1097
|
-
if (text === 'true') return true;
|
|
1098
|
-
if (text === 'false') return false;
|
|
1099
|
-
if (/^-?\d+(?:\.\d+)?$/.test(text)) return Number(text);
|
|
1100
|
-
if (/^'.*'$/.test(text)) return text.slice(1, -1).replaceAll("''", "'");
|
|
1101
|
-
return text;
|
|
1102
|
-
}
|
|
1103
|
-
|
|
1104
|
-
condition(source: string | undefined, context: EntityRecord | null = null): boolean {
|
|
1105
|
-
const text = (source || '').trim().replace(/^\((.*)\)$/, '$1');
|
|
1106
|
-
const orParts = text.split(/\s+or\s+/);
|
|
1107
|
-
if (orParts.length > 1) return orParts.some(part => this.condition(part, context));
|
|
1108
|
-
const andParts = text.split(/\s+and\s+/);
|
|
1109
|
-
if (andParts.length > 1) return andParts.every(part => this.condition(part, context));
|
|
1110
|
-
const comparison = text.match(/^(.*?)\s*(=|!=|>=|<=|>|<)\s*(.*?)$/);
|
|
1111
|
-
if (!comparison) return Boolean(this.value(text, context));
|
|
1112
|
-
const left = this.value(comparison[1], context);
|
|
1113
|
-
const right = this.value(comparison[3], context);
|
|
1114
|
-
switch (comparison[2]) {
|
|
1115
|
-
case '=': return left === right;
|
|
1116
|
-
case '!=': return left !== right;
|
|
1117
|
-
case '>': return this.comparable(left) > this.comparable(right);
|
|
1118
|
-
case '<': return this.comparable(left) < this.comparable(right);
|
|
1119
|
-
case '>=': return this.comparable(left) >= this.comparable(right);
|
|
1120
|
-
case '<=': return this.comparable(left) <= this.comparable(right);
|
|
1121
|
-
default: return false;
|
|
1122
|
-
}
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
boolean(source: string | undefined, context: EntityRecord | null = null): boolean {
|
|
1126
|
-
return this.condition(source, context);
|
|
1127
|
-
}
|
|
1128
|
-
|
|
1129
|
-
number(source: string | undefined, context: EntityRecord | null = null): number {
|
|
1130
|
-
return Number(this.value(source, context));
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
string(source: string | undefined, context: EntityRecord | null = null): string {
|
|
1134
|
-
return String(this.value(source, context) ?? '');
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
set(name: string, value: RuntimeValue | undefined): void {
|
|
1138
|
-
this.variables[name] = value;
|
|
1139
|
-
}
|
|
1140
|
-
|
|
1141
|
-
log(message: string): void {
|
|
1142
|
-
console.info(`[nanoflow] ${message || this.metadata.name}`);
|
|
1143
|
-
}
|
|
1144
|
-
|
|
1145
|
-
change(variable: string, expressions: ChangeExpressions): void {
|
|
1146
|
-
const record = this.variables[variable];
|
|
1147
|
-
if (!isRecord(record)) throw new Error(`Nanoflow object $${variable} is missing`);
|
|
1148
|
-
Object.entries(expressions).forEach(([member, expression]) => {
|
|
1149
|
-
record.attributes[member] = this.value(expression, record);
|
|
1150
|
-
});
|
|
1151
|
-
this.#changes.set(`${record.type}:${record.id}`, record);
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
complete<R>(result: R): NanoflowExecution<R> {
|
|
1155
|
-
return { result, variables: this.variables, changes: [...this.#changes.values()] };
|
|
1156
|
-
}
|
|
1157
|
-
|
|
1158
|
-
missing(current: string | null): Error {
|
|
1159
|
-
return new Error(`Nanoflow ${this.metadata.name} points to missing object ${current || '(none)'}`);
|
|
1160
|
-
}
|
|
1161
|
-
|
|
1162
|
-
stopped(type: string): Error {
|
|
1163
|
-
return new Error(`Nanoflow ${this.metadata.name} stops at ${type}`);
|
|
1164
|
-
}
|
|
1165
|
-
|
|
1166
|
-
unsupported(type: string): Error {
|
|
1167
|
-
return new Error(`Unsupported frontend nanoflow action: ${type || '(empty)'}`);
|
|
1168
|
-
}
|
|
1169
|
-
|
|
1170
|
-
exceeded(): Error {
|
|
1171
|
-
return new Error(`Nanoflow ${this.metadata.name} exceeded 10000 steps`);
|
|
1172
|
-
}
|
|
1173
|
-
|
|
1174
|
-
private comparable(value: RuntimeValue | undefined): Comparable {
|
|
1175
|
-
return typeof value === 'number' ? value : String(value ?? '');
|
|
1176
|
-
}
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
export const defineNanoflow = <P extends NanoflowParameters, R extends RuntimeValue | undefined>(
|
|
1180
|
-
metadata: NanoflowMetadata,
|
|
1181
|
-
compiled: (runtime: NanoflowRuntime<P>) => NanoflowExecution<R> | Promise<NanoflowExecution<R>>
|
|
1182
|
-
): RegisteredNanoflow => ({
|
|
1183
|
-
...metadata,
|
|
1184
|
-
execute: async parameters => compiled(new NanoflowRuntime(parameters as P, metadata))
|
|
1185
|
-
});
|
|
1186
|
-
TS
|
|
1187
|
-
end
|
|
1188
|
-
|
|
1189
|
-
def frontend_marketplace_runtime
|
|
1190
|
-
<<~'TS'
|
|
1191
|
-
import { useState } from 'react';
|
|
1192
|
-
import type { ReactNode } from 'react';
|
|
1193
|
-
import type { EntityRecord, RuntimeValue, WidgetDefinition } from '../types';
|
|
1194
|
-
|
|
1195
|
-
export interface MarketplaceWidgetProps {
|
|
1196
|
-
widget: WidgetDefinition;
|
|
1197
|
-
context: EntityRecord | null;
|
|
1198
|
-
children?: ReactNode;
|
|
1199
|
-
onChange(attribute: string | undefined, value: RuntimeValue): unknown;
|
|
1200
|
-
}
|
|
1201
|
-
|
|
1202
|
-
type Properties = Record<string, unknown>;
|
|
1203
|
-
|
|
1204
|
-
const asProperties = (value: unknown): Properties =>
|
|
1205
|
-
value && typeof value === 'object' && !Array.isArray(value) ? value as Properties : {};
|
|
1206
|
-
|
|
1207
|
-
const firstText = (properties: Properties, keys: string[], fallback: string): string => {
|
|
1208
|
-
for (const key of keys) {
|
|
1209
|
-
const value = properties[key];
|
|
1210
|
-
if (typeof value === 'string' && value.trim()) return value;
|
|
1211
|
-
if (typeof value === 'number' || typeof value === 'boolean') return String(value);
|
|
1212
|
-
}
|
|
1213
|
-
return fallback;
|
|
1214
|
-
};
|
|
1215
|
-
|
|
1216
|
-
const findAttribute = (value: unknown): string | undefined => {
|
|
1217
|
-
if (!value || typeof value !== 'object') return undefined;
|
|
1218
|
-
if (Array.isArray(value)) {
|
|
1219
|
-
for (const child of value) {
|
|
1220
|
-
const found = findAttribute(child);
|
|
1221
|
-
if (found) return found;
|
|
1222
|
-
}
|
|
1223
|
-
return undefined;
|
|
1224
|
-
}
|
|
1225
|
-
for (const [key, child] of Object.entries(value as Properties)) {
|
|
1226
|
-
if (/attribute/i.test(key) && typeof child === 'string' && child.includes('.')) return child;
|
|
1227
|
-
const found = findAttribute(child);
|
|
1228
|
-
if (found) return found;
|
|
1229
|
-
}
|
|
1230
|
-
return undefined;
|
|
1231
|
-
};
|
|
1232
|
-
|
|
1233
|
-
const memberName = (value: string | undefined): string =>
|
|
1234
|
-
(value || '').split(/[./]/).pop() || '';
|
|
1235
|
-
|
|
1236
|
-
const numericValue = (value: RuntimeValue | undefined, fallback = 0): number => {
|
|
1237
|
-
const number = Number(value);
|
|
1238
|
-
return Number.isFinite(number) ? number : fallback;
|
|
1239
|
-
};
|
|
1240
|
-
|
|
1241
|
-
const chart = (name: string, children?: ReactNode) => <>
|
|
1242
|
-
<figure className="mxrb-marketplace-chart">
|
|
1243
|
-
<svg viewBox="0 0 240 100" role="img" aria-label={name}>
|
|
1244
|
-
<title>{name}</title>
|
|
1245
|
-
<polyline points="8,82 48,55 88,68 128,25 168,42 228,12" fill="none"
|
|
1246
|
-
stroke="currentColor" strokeWidth="4" />
|
|
1247
|
-
<line x1="8" y1="90" x2="232" y2="90" stroke="currentColor" />
|
|
1248
|
-
</svg>
|
|
1249
|
-
<figcaption>{name}</figcaption>
|
|
1250
|
-
</figure>
|
|
1251
|
-
{children}
|
|
1252
|
-
</>;
|
|
1253
|
-
|
|
1254
|
-
export function MarketplaceWidget({ widget, context, children, onChange }: MarketplaceWidgetProps) {
|
|
1255
|
-
const options = widget.options || {};
|
|
1256
|
-
const properties = asProperties(options.properties);
|
|
1257
|
-
const id = String(options.widget_id || options.native_type || widget.name).toLowerCase();
|
|
1258
|
-
const name = String(options.widget_name || widget.name);
|
|
1259
|
-
const attribute = findAttribute(properties);
|
|
1260
|
-
const current = context?.attributes?.[memberName(attribute)];
|
|
1261
|
-
const [localValue, setLocalValue] = useState<RuntimeValue>(current ?? 0);
|
|
1262
|
-
const update = (value: RuntimeValue) => {
|
|
1263
|
-
setLocalValue(value);
|
|
1264
|
-
return onChange(attribute, value);
|
|
1265
|
-
};
|
|
1266
|
-
const label = firstText(
|
|
1267
|
-
properties,
|
|
1268
|
-
['label', 'value', 'caption', 'title', 'legend', 'textMessage', 'alternativeText'],
|
|
1269
|
-
name
|
|
1270
|
-
);
|
|
1271
|
-
|
|
1272
|
-
if (/(area|bar|bubble|column|custom|heatmap|line|pie|time)chart/.test(id)
|
|
1273
|
-
|| id.includes('timeseries') || id.includes('heatmap')) return chart(name, children);
|
|
1274
|
-
if (id.includes('progresscircle') || id.includes('progressbar')) {
|
|
1275
|
-
const value = numericValue(current ?? localValue, 50);
|
|
1276
|
-
return <label>{label}<progress value={value} max={100}>{value}%</progress></label>;
|
|
1277
|
-
}
|
|
1278
|
-
if (id.includes('rangeslider')) {
|
|
1279
|
-
const start = Array.isArray(localValue) ? numericValue(localValue[0]) : numericValue(localValue);
|
|
1280
|
-
return <label>{label}<input aria-label={`${label} minimum`} type="range" value={start}
|
|
1281
|
-
onChange={event => update(Number(event.target.value))} /></label>;
|
|
1282
|
-
}
|
|
1283
|
-
if (id.includes('slider')) {
|
|
1284
|
-
return <label>{label}<input aria-label={label} type="range"
|
|
1285
|
-
value={numericValue(current ?? localValue)}
|
|
1286
|
-
onChange={event => update(Number(event.target.value))} /></label>;
|
|
1287
|
-
}
|
|
1288
|
-
if (id.includes('starrating') || id.endsWith('.rating')) {
|
|
1289
|
-
const rating = numericValue(current ?? localValue);
|
|
1290
|
-
return <fieldset className="mxrb-marketplace-rating"><legend>{label}</legend>
|
|
1291
|
-
{[1, 2, 3, 4, 5].map(value => <button type="button" key={value}
|
|
1292
|
-
aria-label={`${value} stars`} aria-pressed={value <= rating}
|
|
1293
|
-
onClick={() => update(value)}>{value <= rating ? '★' : '☆'}</button>)}
|
|
1294
|
-
</fieldset>;
|
|
1295
|
-
}
|
|
1296
|
-
if (id.includes('switch')) {
|
|
1297
|
-
return <label><input type="checkbox" checked={Boolean(current ?? localValue)}
|
|
1298
|
-
onChange={event => update(event.target.checked)} />{label}</label>;
|
|
1299
|
-
}
|
|
1300
|
-
if (id.includes('badgebutton')) return <button type="button">{label}</button>;
|
|
1301
|
-
if (id.includes('badge')) return <output className="mxrb-marketplace-badge">{label}</output>;
|
|
1302
|
-
if (id.includes('accordion')) return <details><summary>{label}</summary>{children}</details>;
|
|
1303
|
-
if (id.includes('fieldset')) return <fieldset><legend>{label}</legend>{children}</fieldset>;
|
|
1304
|
-
if (id.includes('accessibilityhelper')) return <div aria-live="polite">{children}</div>;
|
|
1305
|
-
if (id.includes('htmlelement')) return <article>{children || label}</article>;
|
|
1306
|
-
if (id.endsWith('.image')) {
|
|
1307
|
-
const source = firstText(properties, ['imageUrl', 'url'], '');
|
|
1308
|
-
return source ? <img src={source} alt={label} /> : <span>{label}</span>;
|
|
1309
|
-
}
|
|
1310
|
-
if (id.includes('languageselector')) return <label>{label}<select defaultValue="pt-BR">
|
|
1311
|
-
<option value="pt-BR">Português</option><option value="en-US">English</option>
|
|
1312
|
-
</select></label>;
|
|
1313
|
-
if (id.includes('popupmenu')) return <details><summary>{label}</summary>{children || 'Menu'}</details>;
|
|
1314
|
-
if (id.includes('timeline')) return <ol className="mxrb-marketplace-timeline"><li>{label}</li>{children}</ol>;
|
|
1315
|
-
if (id.includes('tooltip')) return <span title={label}>{children || label}</span>;
|
|
1316
|
-
if (id.includes('treenode') || id.includes('treeview')) return <ul><li>{label}{children}</li></ul>;
|
|
1317
|
-
if (id.includes('videoplayer')) {
|
|
1318
|
-
const source = firstText(properties, ['videoUrl', 'videoURL', 'url'], '');
|
|
1319
|
-
return <video controls src={source || undefined}>{label}</video>;
|
|
1320
|
-
}
|
|
1321
|
-
if (id.includes('barcodescanner')) return <button type="button">{label}</button>;
|
|
1322
|
-
|
|
1323
|
-
return <section className="mxrb-marketplace-generic" aria-label={name}>
|
|
1324
|
-
<strong>{name}</strong>{children}
|
|
1325
|
-
</section>;
|
|
1326
|
-
}
|
|
1327
|
-
TS
|
|
1328
|
-
end
|
|
1329
|
-
|
|
1330
|
-
def frontend_types # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
|
1331
|
-
modules = @module_manifests || []
|
|
1332
|
-
entities = modules.flat_map { |mod| Array(mod['models']) + Array(mod['dtos']) }
|
|
1333
|
-
pages = modules.flat_map { |mod| Array(mod['pages']) }
|
|
1334
|
-
enumerations = modules.flat_map { |mod| Array(mod['enumerations']) }
|
|
1335
|
-
enumeration_types = enumerations.map do |enumeration|
|
|
1336
|
-
name = typescript_identifier(enumeration.fetch('name'))
|
|
1337
|
-
values = enumeration.fetch('values', []).map { JSON.generate(_1.fetch('name')) }
|
|
1338
|
-
"export type #{name} = #{values.empty? ? 'never' : values.join(' | ')};"
|
|
1339
|
-
end
|
|
1340
|
-
entity_types = entities.flat_map do |entity|
|
|
1341
|
-
name = typescript_identifier(entity.fetch('name'))
|
|
1342
|
-
attributes = entity.fetch('attributes', []).map do |attribute|
|
|
1343
|
-
optional = attribute['required'] ? '' : '?'
|
|
1344
|
-
type = typescript_attribute_type(attribute, enumerations)
|
|
1345
|
-
" #{JSON.generate(attribute.fetch('name'))}#{optional}: #{type};"
|
|
1346
|
-
end
|
|
1347
|
-
[
|
|
1348
|
-
"export interface #{name}Attributes {\n#{attributes.join("\n")}\n}",
|
|
1349
|
-
"export type #{name}Record = EntityRecord<#{name}Attributes, #{JSON.generate(entity.fetch('name'))}>;"
|
|
1350
|
-
]
|
|
1351
|
-
end
|
|
1352
|
-
entity_map = entities.map do |entity|
|
|
1353
|
-
" #{JSON.generate(entity.fetch('name'))}: #{typescript_identifier(entity.fetch('name'))}Record;"
|
|
1354
|
-
end
|
|
1355
|
-
page_types = pages.map do |page|
|
|
1356
|
-
name = typescript_identifier(page.fetch('name'))
|
|
1357
|
-
widgets = page.fetch('widgets', []).flat_map { frontend_widget_names(_1) }.uniq
|
|
1358
|
-
widget_names = widgets.empty? ? 'never' : widgets.map { JSON.generate(_1) }.join(' | ')
|
|
1359
|
-
"export type #{name}WidgetName = #{widget_names};"
|
|
1360
|
-
end
|
|
1361
|
-
page_map = pages.map do |page|
|
|
1362
|
-
name = typescript_identifier(page.fetch('name'))
|
|
1363
|
-
qualified = JSON.generate(page.fetch('name'))
|
|
1364
|
-
" #{qualified}: PageDefinition<#{qualified}, #{name}WidgetName>;"
|
|
1365
|
-
end
|
|
1366
|
-
<<~TS
|
|
1367
|
-
// Generated from the Mendix domain, page, widget, effect, and API contracts.
|
|
1368
|
-
import type { ComponentType, ReactNode } from 'react';
|
|
1369
|
-
|
|
1370
|
-
export type RuntimeScalar = string | number | boolean | null;
|
|
1371
|
-
export type RuntimeValue = RuntimeScalar | EntityRecord | RuntimeValue[] | { [key: string]: RuntimeValue };
|
|
1372
|
-
export type RuntimeVariables = Record<string, RuntimeValue | undefined>;
|
|
1373
|
-
|
|
1374
|
-
export interface EntityRecord<
|
|
1375
|
-
Attributes extends object = Record<string, RuntimeValue | undefined>,
|
|
1376
|
-
Name extends string = string
|
|
1377
|
-
> {
|
|
1378
|
-
id: string;
|
|
1379
|
-
type: Name;
|
|
1380
|
-
attributes: Attributes;
|
|
1381
|
-
transient?: boolean;
|
|
1382
|
-
}
|
|
1383
|
-
|
|
1384
|
-
export interface WidgetEvent {
|
|
1385
|
-
event: string;
|
|
1386
|
-
kind: 'microflow' | 'nanoflow' | 'page' | string;
|
|
1387
|
-
handler: string;
|
|
1388
|
-
arguments?: Record<string, string>;
|
|
1389
|
-
}
|
|
1390
|
-
|
|
1391
|
-
export interface WidgetColumn {
|
|
1392
|
-
name?: string;
|
|
1393
|
-
attribute?: string;
|
|
1394
|
-
caption?: string;
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
export interface WidgetTab {
|
|
1398
|
-
name: string;
|
|
1399
|
-
caption?: string;
|
|
1400
|
-
widgets?: WidgetDefinition[];
|
|
1401
|
-
}
|
|
1402
|
-
|
|
1403
|
-
export interface WidgetOptions {
|
|
1404
|
-
[key: string]: unknown;
|
|
1405
|
-
association?: string;
|
|
1406
|
-
attribute?: string;
|
|
1407
|
-
caption?: string;
|
|
1408
|
-
class?: string;
|
|
1409
|
-
columns?: WidgetColumn[];
|
|
1410
|
-
display_attribute?: string;
|
|
1411
|
-
dynamic_class?: string;
|
|
1412
|
-
entity?: string;
|
|
1413
|
-
items?: RuntimeValue[] | Record<string, RuntimeValue>;
|
|
1414
|
-
lines?: number;
|
|
1415
|
-
native_type?: string;
|
|
1416
|
-
options?: RuntimeValue[] | Record<string, RuntimeValue>;
|
|
1417
|
-
pageSize?: number;
|
|
1418
|
-
page_size?: number;
|
|
1419
|
-
parameters?: string[];
|
|
1420
|
-
read_only?: boolean;
|
|
1421
|
-
sort?: Array<{ attribute: string; direction?: string }>;
|
|
1422
|
-
style?: string;
|
|
1423
|
-
tabs?: WidgetTab[];
|
|
1424
|
-
target_entity?: string;
|
|
1425
|
-
toolbar?: { buttons?: Array<{ type: string }> };
|
|
1426
|
-
values?: RuntimeValue[] | Record<string, RuntimeValue>;
|
|
1427
|
-
visible?: string | boolean;
|
|
1428
|
-
platform?: string;
|
|
1429
|
-
properties?: Record<string, unknown>;
|
|
1430
|
-
widget_id?: string;
|
|
1431
|
-
widget_name?: string;
|
|
1432
|
-
}
|
|
1433
|
-
|
|
1434
|
-
export interface WidgetDefinition<Name extends string = string> {
|
|
1435
|
-
type: string;
|
|
1436
|
-
name: Name;
|
|
1437
|
-
caption?: string;
|
|
1438
|
-
options?: WidgetOptions;
|
|
1439
|
-
events?: WidgetEvent[];
|
|
1440
|
-
children?: WidgetDefinition[];
|
|
1441
|
-
}
|
|
1442
|
-
|
|
1443
|
-
export interface PageDefinition<Name extends string = string, WidgetName extends string = string> {
|
|
1444
|
-
name: Name;
|
|
1445
|
-
title: string;
|
|
1446
|
-
appearance_class?: string;
|
|
1447
|
-
appearance_style?: string;
|
|
1448
|
-
data_source?: { kind: 'microflow' | 'nanoflow' | string; name: string } | null;
|
|
1449
|
-
widgets: WidgetDefinition<WidgetName>[];
|
|
1450
|
-
}
|
|
1451
|
-
|
|
1452
|
-
export interface PageComponentProps {
|
|
1453
|
-
busy: boolean;
|
|
1454
|
-
Widget: ComponentType<PageWidgetProps>;
|
|
1455
|
-
}
|
|
1456
|
-
|
|
1457
|
-
export interface PageWidgetProps {
|
|
1458
|
-
widget: WidgetDefinition;
|
|
1459
|
-
index: number;
|
|
1460
|
-
children?: ReactNode;
|
|
1461
|
-
}
|
|
1462
|
-
|
|
1463
|
-
export interface AttributeDefinition {
|
|
1464
|
-
name: string;
|
|
1465
|
-
type: string;
|
|
1466
|
-
enumeration?: string;
|
|
1467
|
-
}
|
|
1468
|
-
|
|
1469
|
-
export interface EntityDefinition {
|
|
1470
|
-
name: string;
|
|
1471
|
-
attributes?: AttributeDefinition[];
|
|
1472
|
-
}
|
|
1473
|
-
|
|
1474
|
-
export interface EnumerationDefinition {
|
|
1475
|
-
id: string;
|
|
1476
|
-
name: string;
|
|
1477
|
-
values: Array<{ name: string; caption: string }>;
|
|
1478
|
-
}
|
|
1479
|
-
|
|
1480
|
-
export interface AssociationDefinition {
|
|
1481
|
-
name: string;
|
|
1482
|
-
from_entity: string;
|
|
1483
|
-
to_entity: string;
|
|
1484
|
-
type: string;
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
export interface NavigationItem {
|
|
1488
|
-
page?: string;
|
|
1489
|
-
caption?: Record<string, string>;
|
|
1490
|
-
items?: NavigationItem[];
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
export interface NavigationProfile {
|
|
1494
|
-
kind: string;
|
|
1495
|
-
home_page?: string;
|
|
1496
|
-
items?: NavigationItem[];
|
|
1497
|
-
}
|
|
1498
|
-
|
|
1499
|
-
export interface RuntimeModule {
|
|
1500
|
-
name: string;
|
|
1501
|
-
models?: EntityDefinition[];
|
|
1502
|
-
dtos?: EntityDefinition[];
|
|
1503
|
-
pages: PageDefinition[];
|
|
1504
|
-
enumerations?: EnumerationDefinition[];
|
|
1505
|
-
associations?: AssociationDefinition[];
|
|
1506
|
-
}
|
|
1507
|
-
|
|
1508
|
-
export interface ApplicationSchema {
|
|
1509
|
-
project: { name: string; mendix_version: string };
|
|
1510
|
-
navigation?: { profiles?: NavigationProfile[] };
|
|
1511
|
-
modules: RuntimeModule[];
|
|
1512
|
-
}
|
|
1513
|
-
|
|
1514
|
-
export interface OpenPageEffect {
|
|
1515
|
-
type: 'open_page';
|
|
1516
|
-
page: string;
|
|
1517
|
-
arguments?: Record<string, RuntimeValue>;
|
|
1518
|
-
}
|
|
1519
|
-
|
|
1520
|
-
export interface RuntimeEffect {
|
|
1521
|
-
type: string;
|
|
1522
|
-
[key: string]: RuntimeValue | undefined;
|
|
1523
|
-
}
|
|
1524
|
-
|
|
1525
|
-
export interface InvocationResult {
|
|
1526
|
-
result?: RuntimeValue;
|
|
1527
|
-
context?: EntityRecord | null;
|
|
1528
|
-
effects?: Array<OpenPageEffect | RuntimeEffect>;
|
|
1529
|
-
}
|
|
1530
|
-
|
|
1531
|
-
export interface EntityCollectionResponse<T extends EntityRecord = EntityRecord> {
|
|
1532
|
-
records: T[];
|
|
1533
|
-
}
|
|
1534
|
-
|
|
1535
|
-
export interface Session {
|
|
1536
|
-
id?: string;
|
|
1537
|
-
username?: string;
|
|
1538
|
-
[key: string]: RuntimeValue | undefined;
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
|
-
export interface LoginResponse {
|
|
1542
|
-
token: string;
|
|
1543
|
-
}
|
|
1544
|
-
|
|
1545
|
-
export interface ApiFailure extends Error {
|
|
1546
|
-
status?: number;
|
|
1547
|
-
}
|
|
1548
|
-
|
|
1549
|
-
export type ApiRequest = <T = RuntimeValue | undefined>(
|
|
1550
|
-
path: string, options?: RequestInit
|
|
1551
|
-
) => Promise<T>;
|
|
1552
|
-
|
|
1553
|
-
export type NanoflowParameters = RuntimeVariables;
|
|
1554
|
-
|
|
1555
|
-
export interface NanoflowMetadata {
|
|
1556
|
-
name: string;
|
|
1557
|
-
id: string;
|
|
1558
|
-
parameters: string[];
|
|
1559
|
-
}
|
|
1560
|
-
|
|
1561
|
-
export interface NanoflowExecution<R = RuntimeValue | undefined> {
|
|
1562
|
-
result: R;
|
|
1563
|
-
variables: NanoflowParameters;
|
|
1564
|
-
changes: EntityRecord[];
|
|
1565
|
-
}
|
|
1566
|
-
|
|
1567
|
-
export interface RegisteredNanoflow extends NanoflowMetadata {
|
|
1568
|
-
execute(parameters: NanoflowParameters): Promise<NanoflowExecution>;
|
|
1569
|
-
}
|
|
1570
|
-
|
|
1571
|
-
#{enumeration_types.join("\n")}
|
|
1572
|
-
|
|
1573
|
-
#{entity_types.join("\n\n")}
|
|
1574
|
-
|
|
1575
|
-
export interface EntityTypeMap {
|
|
1576
|
-
#{entity_map.join("\n")}
|
|
1577
|
-
}
|
|
1578
|
-
export type EntityName = keyof EntityTypeMap;
|
|
1579
|
-
|
|
1580
|
-
#{page_types.join("\n")}
|
|
1581
|
-
|
|
1582
|
-
export interface PageTypeMap {
|
|
1583
|
-
#{page_map.join("\n")}
|
|
1584
|
-
}
|
|
1585
|
-
export type PageName = keyof PageTypeMap;
|
|
1586
|
-
TS
|
|
1587
|
-
end # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
|
1588
|
-
|
|
1589
|
-
def frontend_widget_names(widget)
|
|
1590
|
-
[widget['name'].to_s, *Array(widget['children']).flat_map { frontend_widget_names(_1) }]
|
|
1591
|
-
.reject(&:empty?)
|
|
1592
|
-
end
|
|
1593
|
-
|
|
1594
|
-
def typescript_attribute_type(attribute, enumerations)
|
|
1595
|
-
if attribute['type'] == 'enum'
|
|
1596
|
-
enumeration = enumerations.find do |candidate|
|
|
1597
|
-
[candidate['id'], candidate['name']].include?(attribute['enumeration'])
|
|
1598
|
-
end
|
|
1599
|
-
return typescript_identifier(enumeration['name']) if enumeration
|
|
1600
|
-
end
|
|
1601
|
-
|
|
1602
|
-
{
|
|
1603
|
-
'boolean' => 'boolean', 'integer' => 'number', 'long' => 'number',
|
|
1604
|
-
'autonumber' => 'number', 'decimal' => 'number', 'datetime' => 'string',
|
|
1605
|
-
'binary' => 'string'
|
|
1606
|
-
}.fetch(attribute['type'].to_s, 'string')
|
|
1607
|
-
end
|
|
1608
|
-
|
|
1609
|
-
def typescript_identifier(value)
|
|
1610
|
-
parts = value.to_s.split(/[^A-Za-z0-9]+/).reject(&:empty?)
|
|
1611
|
-
identifier = parts.map { _1[0].to_s.upcase + _1[1..].to_s }.join
|
|
1612
|
-
return 'MxrbType' if identifier.empty?
|
|
1613
|
-
|
|
1614
|
-
identifier.match?(/\A[A-Za-z_]/) ? identifier : "Mx#{identifier}"
|
|
1615
|
-
end
|
|
1616
|
-
|
|
1617
|
-
def frontend_app
|
|
1618
|
-
<<~'JS'
|
|
1619
|
-
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
1620
|
-
import type { CSSProperties, FormEvent, ReactNode } from 'react';
|
|
1621
|
-
import { api } from '../api/client';
|
|
1622
|
-
import { MarketplaceWidget } from '../runtime/marketplace';
|
|
1623
|
-
import nanoflows from '../nanoflows';
|
|
1624
|
-
import pages from '../pages';
|
|
1625
|
-
import type {
|
|
1626
|
-
ApiFailure, ApiRequest, ApplicationSchema, EntityCollectionResponse, EntityRecord,
|
|
1627
|
-
InvocationResult, LoginResponse, NavigationItem, OpenPageEffect, PageDefinition,
|
|
1628
|
-
PageWidgetProps, RuntimeValue, RuntimeVariables, Session, WidgetDefinition,
|
|
1629
|
-
WidgetEvent, WidgetOptions
|
|
1630
|
-
} from '../types';
|
|
1631
|
-
|
|
1632
|
-
const TOKEN_KEY = 'mxrb.session.token';
|
|
1633
|
-
|
|
1634
|
-
type ErrorHandler = (failure: unknown) => void;
|
|
1635
|
-
type SaveRecord = (
|
|
1636
|
-
record: EntityRecord | null, changes: Record<string, RuntimeValue | undefined>
|
|
1637
|
-
) => Promise<EntityRecord | null>;
|
|
1638
|
-
type InvokeHandler = (
|
|
1639
|
-
name: string, parameters?: RuntimeVariables, contextOverride?: EntityRecord | null
|
|
1640
|
-
) => Promise<unknown>;
|
|
1641
|
-
type NavigateHandler = (name: string, context?: EntityRecord | null) => Promise<unknown>;
|
|
1642
|
-
type SelectRecord = (record: EntityRecord | null) => void;
|
|
1643
|
-
|
|
1644
|
-
interface WidgetRuntimeProps {
|
|
1645
|
-
widget: WidgetDefinition;
|
|
1646
|
-
children?: ReactNode;
|
|
1647
|
-
moduleName: string;
|
|
1648
|
-
invoke: InvokeHandler;
|
|
1649
|
-
invokeNanoflow: InvokeHandler;
|
|
1650
|
-
navigate: NavigateHandler;
|
|
1651
|
-
context?: EntityRecord | null;
|
|
1652
|
-
pageContext: EntityRecord | null;
|
|
1653
|
-
revision: number;
|
|
1654
|
-
schema: ApplicationSchema;
|
|
1655
|
-
request: ApiRequest;
|
|
1656
|
-
saveRecord: SaveRecord;
|
|
1657
|
-
onError: ErrorHandler;
|
|
1658
|
-
onMutation: () => void;
|
|
1659
|
-
onSelectRecord: SelectRecord;
|
|
1660
|
-
}
|
|
1661
|
-
|
|
1662
|
-
interface BoundFieldProps {
|
|
1663
|
-
widget: WidgetDefinition;
|
|
1664
|
-
record: EntityRecord | null;
|
|
1665
|
-
schema: ApplicationSchema;
|
|
1666
|
-
request: ApiRequest;
|
|
1667
|
-
saveRecord: SaveRecord;
|
|
1668
|
-
revision: number;
|
|
1669
|
-
onChanged?: (record: EntityRecord) => unknown;
|
|
1670
|
-
onError: ErrorHandler;
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
interface DataGridProps {
|
|
1674
|
-
widget: WidgetDefinition;
|
|
1675
|
-
request: ApiRequest;
|
|
1676
|
-
pageContext: EntityRecord | null;
|
|
1677
|
-
revision: number;
|
|
1678
|
-
onError: ErrorHandler;
|
|
1679
|
-
onMutation: () => void;
|
|
1680
|
-
onRowAction: (record: EntityRecord) => unknown;
|
|
1681
|
-
onSelectRecord: SelectRecord;
|
|
1682
|
-
}
|
|
1683
|
-
|
|
1684
|
-
type GalleryProps = Omit<WidgetRuntimeProps, 'context'>;
|
|
1685
|
-
|
|
1686
|
-
interface LoginProps {
|
|
1687
|
-
onLogin: (username: string, password: string) => Promise<void>;
|
|
1688
|
-
error: ApiFailure | null;
|
|
1689
|
-
busy: boolean;
|
|
1690
|
-
}
|
|
1691
|
-
|
|
1692
|
-
const classes = (...values: Array<string | false | null | undefined>): string =>
|
|
1693
|
-
values.filter(Boolean).join(' ');
|
|
1694
|
-
const isEntityRecord = (value: RuntimeValue | undefined): value is EntityRecord =>
|
|
1695
|
-
Boolean(value && typeof value === 'object' && !Array.isArray(value)
|
|
1696
|
-
&& 'id' in value && 'type' in value && 'attributes' in value);
|
|
1697
|
-
const attributes = (object: RuntimeValue | undefined): Record<string, RuntimeValue | undefined> =>
|
|
1698
|
-
isEntityRecord(object) ? object.attributes : {};
|
|
1699
|
-
const memberName = (value: string | undefined): string =>
|
|
1700
|
-
(value || '').split(/[./]/).pop() || '';
|
|
1701
|
-
const entityCollectionPath = (
|
|
1702
|
-
entity: string, association: string | undefined, context: EntityRecord | null
|
|
1703
|
-
): string => {
|
|
1704
|
-
const path = `/api/entities/${encodeURIComponent(entity)}`;
|
|
1705
|
-
if (!association || !context?.type || !context?.id) return path;
|
|
1706
|
-
const query = new URLSearchParams({
|
|
1707
|
-
association, context_type: context.type, context_id: context.id
|
|
1708
|
-
});
|
|
1709
|
-
return `${path}?${query}`;
|
|
1710
|
-
};
|
|
1711
|
-
const expressionValue = (
|
|
1712
|
-
source: string | undefined, context: EntityRecord | null,
|
|
1713
|
-
variables: RuntimeVariables = {}
|
|
1714
|
-
): RuntimeValue | undefined => {
|
|
1715
|
-
const text = (source || '').trim();
|
|
1716
|
-
const wrapped = text.match(/^toString\((.*)\)$/);
|
|
1717
|
-
if (wrapped) return String(expressionValue(wrapped[1], context, variables) ?? '');
|
|
1718
|
-
if (text === '$currentObject') return context;
|
|
1719
|
-
const variable = text.match(/^\$([A-Za-z_]\w*)$/);
|
|
1720
|
-
if (variable) return variables[variable[1]] ?? context;
|
|
1721
|
-
const member = text.match(/^\$([A-Za-z_]\w*)\/([A-Za-z_][\w.]*)$/);
|
|
1722
|
-
if (member) return attributes(variables[member[1]] ?? context)[memberName(member[2])];
|
|
1723
|
-
if (text === 'empty') return null;
|
|
1724
|
-
if (text === 'true') return true;
|
|
1725
|
-
if (text === 'false') return false;
|
|
1726
|
-
if (/^'.*'$/.test(text)) return text.slice(1, -1).replaceAll("''", "'");
|
|
1727
|
-
return text;
|
|
1728
|
-
};
|
|
1729
|
-
const conditionValue = (
|
|
1730
|
-
source: string | undefined, context: EntityRecord | null,
|
|
1731
|
-
variables: RuntimeVariables = {}
|
|
1732
|
-
): boolean => {
|
|
1733
|
-
const text = (source || '').trim().replace(/^\((.*)\)$/, '$1');
|
|
1734
|
-
const orParts = text.split(/\s+or\s+/);
|
|
1735
|
-
if (orParts.length > 1) return orParts.some(part => conditionValue(part, context, variables));
|
|
1736
|
-
const andParts = text.split(/\s+and\s+/);
|
|
1737
|
-
if (andParts.length > 1) return andParts.every(part => conditionValue(part, context, variables));
|
|
1738
|
-
const comparison = text.match(/^(.*?)\s*(=|!=|>=|<=|>|<)\s*(.*?)$/);
|
|
1739
|
-
if (!comparison) return Boolean(expressionValue(text, context, variables));
|
|
1740
|
-
const left = expressionValue(comparison[1], context, variables);
|
|
1741
|
-
const right = expressionValue(comparison[3], context, variables);
|
|
1742
|
-
if (comparison[2] === '=') return left === right;
|
|
1743
|
-
if (comparison[2] === '!=') return left !== right;
|
|
1744
|
-
const comparable = (value: RuntimeValue | undefined): string | number =>
|
|
1745
|
-
typeof value === 'number' ? value : String(value ?? '');
|
|
1746
|
-
if (comparison[2] === '>') return comparable(left) > comparable(right);
|
|
1747
|
-
if (comparison[2] === '<') return comparable(left) < comparable(right);
|
|
1748
|
-
if (comparison[2] === '>=') return comparable(left) >= comparable(right);
|
|
1749
|
-
return comparable(left) <= comparable(right);
|
|
1750
|
-
};
|
|
1751
|
-
const isVisible = (source: string | boolean | undefined, context: EntityRecord | null): boolean => {
|
|
1752
|
-
if (typeof source === 'boolean') return source;
|
|
1753
|
-
return !source || conditionValue(source, context);
|
|
1754
|
-
};
|
|
1755
|
-
const dynamicClass = (source: string | undefined, context: EntityRecord | null): string => {
|
|
1756
|
-
let text = source || '';
|
|
1757
|
-
text = text.replace(/\(?if\s+(.+?)\s+then\s+'([^']*)'\s+else\s+'([^']*)'\)?/g,
|
|
1758
|
-
(_match: string, condition: string, yes: string, no: string) =>
|
|
1759
|
-
conditionValue(condition, context) ? yes : no);
|
|
1760
|
-
text = text.replace(/toString\(\$[A-Za-z_]\w*\/([A-Za-z_][\w.]*)\)/g,
|
|
1761
|
-
(_match: string, member: string) => String(attributes(context)[memberName(member)] ?? ''));
|
|
1762
|
-
text = text.replace(/\$[A-Za-z_]\w*\/([A-Za-z_][\w.]*)/g,
|
|
1763
|
-
(_match: string, member: string) => String(attributes(context)[memberName(member)] ?? ''));
|
|
1764
|
-
return text.replace(/[+()']/g, ' ').replace(/\s+/g, ' ').trim();
|
|
1765
|
-
};
|
|
1766
|
-
const caption = (
|
|
1767
|
-
widget: WidgetDefinition, options: WidgetOptions, context: EntityRecord | null
|
|
1768
|
-
): string => {
|
|
1769
|
-
let value = options.caption || widget.caption || widget.name;
|
|
1770
|
-
(options.parameters || []).forEach((parameter, index) => {
|
|
1771
|
-
value = value.replaceAll(`{${index + 1}}`, String(expressionValue(parameter, context) ?? ''));
|
|
1772
|
-
});
|
|
1773
|
-
return value;
|
|
1774
|
-
};
|
|
1775
|
-
const inlineStyle = (value: string | undefined): CSSProperties =>
|
|
1776
|
-
Object.fromEntries((value || '').split(';').filter(Boolean).map((rule: string) => {
|
|
1777
|
-
const [property, ...parts] = rule.split(':');
|
|
1778
|
-
const name = property.trim().replace(/-([a-z])/g,
|
|
1779
|
-
(_match: string, letter: string) => letter.toUpperCase());
|
|
1780
|
-
return [name, parts.join(':').trim()];
|
|
1781
|
-
}));
|
|
1782
|
-
|
|
1783
|
-
const eventArguments = (event: WidgetEvent | undefined, context: EntityRecord | null): RuntimeVariables => Object.fromEntries(
|
|
1784
|
-
Object.entries(event?.arguments || {}).map(([name, expression]) => [name, expressionValue(expression, context)])
|
|
1785
|
-
);
|
|
1786
|
-
|
|
1787
|
-
const recordValue = (record: EntityRecord | null, attribute: string | undefined): RuntimeValue | undefined =>
|
|
1788
|
-
attributes(record || undefined)[memberName(attribute)];
|
|
1789
|
-
const displayValue = (value: RuntimeValue | undefined): string | number | boolean => {
|
|
1790
|
-
if (value == null) return '';
|
|
1791
|
-
if (Array.isArray(value)) return value.map(displayValue).join(', ');
|
|
1792
|
-
if (isEntityRecord(value)) return Object.values(value.attributes).find(item =>
|
|
1793
|
-
['string', 'number', 'boolean'].includes(typeof item)) as string | number | boolean || value.id;
|
|
1794
|
-
if (typeof value === 'object') return JSON.stringify(value);
|
|
1795
|
-
return String(value);
|
|
1796
|
-
};
|
|
1797
|
-
|
|
1798
|
-
const choiceValue = (value: RuntimeValue, key: string): RuntimeValue | undefined => {
|
|
1799
|
-
if (isEntityRecord(value)) return key === 'id' ? value.id : value.attributes[key];
|
|
1800
|
-
if (value && typeof value === 'object' && !Array.isArray(value)) return value[key];
|
|
1801
|
-
return undefined;
|
|
1802
|
-
};
|
|
1803
|
-
|
|
1804
|
-
const draftValue = (value: RuntimeValue | undefined): string | number | boolean => {
|
|
1805
|
-
if (isEntityRecord(value)) return value.id;
|
|
1806
|
-
return ['string', 'number', 'boolean'].includes(typeof value)
|
|
1807
|
-
? value as string | number | boolean : '';
|
|
1808
|
-
};
|
|
1809
|
-
|
|
1810
|
-
const apiFailure = (failure: unknown): ApiFailure => {
|
|
1811
|
-
if (failure instanceof Error) return failure as ApiFailure;
|
|
1812
|
-
return new Error(String(failure));
|
|
1813
|
-
};
|
|
1814
|
-
|
|
1815
|
-
const sortRecords = (
|
|
1816
|
-
records: EntityRecord[], sortings: Array<{ attribute: string; direction?: string }> = []
|
|
1817
|
-
) => {
|
|
1818
|
-
const result = records.slice();
|
|
1819
|
-
sortings.slice().reverse().forEach(sorting => {
|
|
1820
|
-
const member = memberName(sorting.attribute);
|
|
1821
|
-
const direction = sorting.direction === 'Descending' ? -1 : 1;
|
|
1822
|
-
result.sort((left, right) => direction * String(
|
|
1823
|
-
left.attributes?.[member] ?? ''
|
|
1824
|
-
).localeCompare(String(right.attributes?.[member] ?? ''), undefined, { numeric: true }));
|
|
1825
|
-
});
|
|
1826
|
-
return result;
|
|
1827
|
-
};
|
|
1828
|
-
|
|
1829
|
-
function BoundField({
|
|
1830
|
-
widget, record, schema, request, saveRecord, revision, onChanged, onError
|
|
1831
|
-
}: BoundFieldProps) {
|
|
1832
|
-
const options = widget.options || {};
|
|
1833
|
-
const member = memberName(options.attribute || widget.name);
|
|
1834
|
-
const kind = widget.type;
|
|
1835
|
-
const value = recordValue(record, member);
|
|
1836
|
-
const [draft, setDraft] = useState<string | number | boolean>(
|
|
1837
|
-
kind === 'check_box' ? Boolean(value) : draftValue(value)
|
|
1838
|
-
);
|
|
1839
|
-
const [references, setReferences] = useState<EntityRecord[]>([]);
|
|
1840
|
-
const associations = (schema?.modules || []).flatMap(module => module.associations || []);
|
|
1841
|
-
const association = associations.find(item =>
|
|
1842
|
-
item.name === options.attribute || memberName(item.name) === member
|
|
1843
|
-
);
|
|
1844
|
-
const referenceEntity = options.entity || options.target_entity || association?.to_entity;
|
|
1845
|
-
const entityDefinition = (schema?.modules || []).flatMap(module =>
|
|
1846
|
-
[...(module.models || []), ...(module.dtos || [])]
|
|
1847
|
-
).find(entity => entity.name === record?.type);
|
|
1848
|
-
const attributeDefinition = (entityDefinition?.attributes || []).find(attribute =>
|
|
1849
|
-
attribute.name === member
|
|
1850
|
-
);
|
|
1851
|
-
const enumeration = (schema?.modules || []).flatMap(module =>
|
|
1852
|
-
module.enumerations || []
|
|
1853
|
-
).find(item => item.id === attributeDefinition?.enumeration
|
|
1854
|
-
|| item.name === attributeDefinition?.enumeration);
|
|
1855
|
-
|
|
1856
|
-
useEffect(() => {
|
|
1857
|
-
setDraft(kind === 'check_box' ? Boolean(value) : draftValue(value));
|
|
1858
|
-
}, [kind, record?.id, value]);
|
|
1859
|
-
|
|
1860
|
-
useEffect(() => {
|
|
1861
|
-
if (kind !== 'reference_selector' || !referenceEntity) return;
|
|
1862
|
-
request<EntityCollectionResponse>(`/api/entities/${encodeURIComponent(referenceEntity)}`)
|
|
1863
|
-
.then(payload => setReferences(payload.records || [])).catch(onError);
|
|
1864
|
-
}, [kind, referenceEntity, revision, request, onError]);
|
|
1865
|
-
|
|
1866
|
-
const persist = (next: string | number | boolean) => {
|
|
1867
|
-
setDraft(next);
|
|
1868
|
-
if (!record?.type || !record?.id || !member) return Promise.resolve(record);
|
|
1869
|
-
let normalized: RuntimeValue = next;
|
|
1870
|
-
if (kind === 'number_input') normalized = next === '' ? null : Number(next);
|
|
1871
|
-
if (kind === 'reference_selector') {
|
|
1872
|
-
normalized = references.find(item => item.id === next) || null;
|
|
1873
|
-
}
|
|
1874
|
-
return saveRecord(record, { [member]: normalized }).then(updated => {
|
|
1875
|
-
if (!updated) return null;
|
|
1876
|
-
if (onChanged) return onChanged(updated);
|
|
1877
|
-
return updated;
|
|
1878
|
-
});
|
|
1879
|
-
};
|
|
1880
|
-
const disabled = !record?.id || !member || options.read_only === true;
|
|
1881
|
-
|
|
1882
|
-
if (kind === 'text_area') {
|
|
1883
|
-
return <textarea rows={options.lines || 4} value={String(draft)} disabled={disabled}
|
|
1884
|
-
onChange={event => setDraft(event.target.value)} onBlur={() => persist(draft)} />;
|
|
1885
|
-
}
|
|
1886
|
-
if (kind === 'check_box') {
|
|
1887
|
-
return <input type="checkbox" checked={Boolean(draft)} disabled={disabled}
|
|
1888
|
-
onChange={event => persist(event.target.checked)} />;
|
|
1889
|
-
}
|
|
1890
|
-
if (kind === 'drop_down' || kind === 'reference_selector') {
|
|
1891
|
-
const enumValues = (enumeration?.values || []).map(item => ({
|
|
1892
|
-
id: item.name, label: item.caption || item.name
|
|
1893
|
-
}));
|
|
1894
|
-
const configuredValue = options.values || options.items || options.options || enumValues;
|
|
1895
|
-
const configured: RuntimeValue[] = Array.isArray(configuredValue)
|
|
1896
|
-
? configuredValue : configuredValue ? Object.values(configuredValue) : [];
|
|
1897
|
-
const choices: RuntimeValue[] = kind === 'reference_selector' ? references : configured;
|
|
1898
|
-
return <select value={String(draft)} disabled={disabled} onChange={event => persist(event.target.value)}>
|
|
1899
|
-
<option value="">—</option>
|
|
1900
|
-
{draft && !choices.some(item => (choiceValue(item, 'id') || choiceValue(item, 'value') || item) === draft) ?
|
|
1901
|
-
<option value={String(draft)}>{displayValue(value)}</option> : null}
|
|
1902
|
-
{choices.map((item, index) => <option
|
|
1903
|
-
key={String(choiceValue(item, 'id') || choiceValue(item, 'value') || index)}
|
|
1904
|
-
value={String(choiceValue(item, 'id') || choiceValue(item, 'value') || item)}>
|
|
1905
|
-
{displayValue(choiceValue(item, 'label') || choiceValue(item, 'caption')
|
|
1906
|
-
|| (isEntityRecord(item) ? recordValue(item, options.display_attribute) : undefined)
|
|
1907
|
-
|| choiceValue(item, 'id') || choiceValue(item, 'value') || item)}
|
|
1908
|
-
</option>)}
|
|
1909
|
-
</select>;
|
|
1910
|
-
}
|
|
1911
|
-
const inputType = kind === 'date_picker' ? 'date' : kind === 'number_input' ? 'number' : 'text';
|
|
1912
|
-
const inputValue = inputType === 'date' ? String(draft).slice(0, 10)
|
|
1913
|
-
: typeof draft === 'boolean' ? String(draft) : draft;
|
|
1914
|
-
return <input type={inputType} value={inputValue} disabled={disabled}
|
|
1915
|
-
onChange={event => setDraft(event.target.value)} onBlur={() => persist(draft)} />;
|
|
1916
|
-
}
|
|
1917
|
-
|
|
1918
|
-
function DataGrid({ widget, request, pageContext, revision, onError, onMutation,
|
|
1919
|
-
onRowAction, onSelectRecord }: DataGridProps) {
|
|
1920
|
-
const options = widget.options || {};
|
|
1921
|
-
const [records, setRecords] = useState<EntityRecord[]>([]);
|
|
1922
|
-
const [pageNumber, setPageNumber] = useState(0);
|
|
1923
|
-
const [reload, setReload] = useState(0);
|
|
1924
|
-
const [selected, setSelected] = useState<EntityRecord | null>(null);
|
|
1925
|
-
const [loading, setLoading] = useState(false);
|
|
1926
|
-
const pageSize = Math.max(1, Number(options.page_size || options.pageSize || 20));
|
|
1927
|
-
|
|
1928
|
-
useEffect(() => {
|
|
1929
|
-
if (!options.entity) return;
|
|
1930
|
-
setLoading(true);
|
|
1931
|
-
request<EntityCollectionResponse>(
|
|
1932
|
-
entityCollectionPath(options.entity, options.association, pageContext)
|
|
1933
|
-
).then(payload => {
|
|
1934
|
-
let values = payload.records || [];
|
|
1935
|
-
values = sortRecords(values, options.sort || []);
|
|
1936
|
-
setRecords(values);
|
|
1937
|
-
setPageNumber(current => Math.min(current, Math.max(0, Math.ceil(values.length / pageSize) - 1)));
|
|
1938
|
-
}).catch(onError).finally(() => setLoading(false));
|
|
1939
|
-
}, [options.entity, options.association, pageContext?.type, pageContext?.id,
|
|
1940
|
-
pageSize, reload, revision, request, onError]);
|
|
1941
|
-
|
|
1942
|
-
const mutate = <T,>(operation: Promise<T>): Promise<T> => operation.then(result => {
|
|
1943
|
-
setReload(value => value + 1);
|
|
1944
|
-
onMutation();
|
|
1945
|
-
return result;
|
|
1946
|
-
}).catch(failure => {
|
|
1947
|
-
onError(failure);
|
|
1948
|
-
throw failure;
|
|
1949
|
-
});
|
|
1950
|
-
const createRecord = () => mutate(request<EntityRecord>(`/api/entities/${encodeURIComponent(options.entity || '')}`, {
|
|
1951
|
-
method: 'POST', body: '{}'
|
|
1952
|
-
})).then(record => {
|
|
1953
|
-
setSelected(record);
|
|
1954
|
-
if (record) onSelectRecord(record);
|
|
1955
|
-
});
|
|
1956
|
-
const deleteRecord = () => selected && mutate(request(
|
|
1957
|
-
`/api/entities/${encodeURIComponent(options.entity || '')}/${encodeURIComponent(selected.id)}`,
|
|
1958
|
-
{ method: 'DELETE' }
|
|
1959
|
-
)).then(() => { setSelected(null); onSelectRecord(null); });
|
|
1960
|
-
const toolbar = options.toolbar?.buttons || [{ type: 'new' }, { type: 'delete' }];
|
|
1961
|
-
const pageCount = Math.max(1, Math.ceil(records.length / pageSize));
|
|
1962
|
-
const visible = records.slice(pageNumber * pageSize, (pageNumber + 1) * pageSize);
|
|
1963
|
-
|
|
1964
|
-
return <div className={classes('mxrb-data-grid-runtime', loading && 'is-loading')}
|
|
1965
|
-
data-entity={options.entity || ''}>
|
|
1966
|
-
<div className="mxrb-grid-toolbar">
|
|
1967
|
-
{toolbar.some(button => button.type === 'new') ? <button type="button" onClick={createRecord}>New</button> : null}
|
|
1968
|
-
{toolbar.some(button => button.type === 'delete') ? <button type="button" disabled={!selected} onClick={deleteRecord}>Delete</button> : null}
|
|
1969
|
-
<button type="button" onClick={() => setReload(value => value + 1)}>Reload</button>
|
|
1970
|
-
</div>
|
|
1971
|
-
<table><thead><tr>{(options.columns || []).map(column =>
|
|
1972
|
-
<th key={column.name || column.attribute}>{column.caption || column.name}</th>)}</tr></thead>
|
|
1973
|
-
<tbody>{visible.map(record => <tr key={record.id}
|
|
1974
|
-
className={selected?.id === record.id ? 'is-selected' : ''}
|
|
1975
|
-
onClick={() => { setSelected(record); onSelectRecord(record); onRowAction(record); }}>
|
|
1976
|
-
{(options.columns || []).map(column => <td key={column.name || column.attribute}>
|
|
1977
|
-
{displayValue(recordValue(record, column.attribute || column.name))}
|
|
1978
|
-
</td>)}
|
|
1979
|
-
</tr>)}</tbody></table>
|
|
1980
|
-
<div className="mxrb-grid-pagination">
|
|
1981
|
-
<button type="button" disabled={pageNumber === 0}
|
|
1982
|
-
onClick={() => setPageNumber(value => value - 1)}>Previous</button>
|
|
1983
|
-
<span>Page {pageNumber + 1} of {pageCount} · {records.length} rows</span>
|
|
1984
|
-
<button type="button" disabled={pageNumber + 1 >= pageCount}
|
|
1985
|
-
onClick={() => setPageNumber(value => value + 1)}>Next</button>
|
|
1986
|
-
</div>
|
|
1987
|
-
</div>;
|
|
1988
|
-
}
|
|
1989
|
-
|
|
1990
|
-
function Gallery({ widget, moduleName, invoke, invokeNanoflow, navigate, pageContext, revision,
|
|
1991
|
-
schema, request, saveRecord, onError, onMutation, onSelectRecord }: GalleryProps) {
|
|
1992
|
-
const options = widget.options || {};
|
|
1993
|
-
const [records, setRecords] = useState<EntityRecord[]>([]);
|
|
1994
|
-
useEffect(() => {
|
|
1995
|
-
if (!options.entity) return;
|
|
1996
|
-
request<EntityCollectionResponse>(
|
|
1997
|
-
entityCollectionPath(options.entity, options.association, pageContext)
|
|
1998
|
-
).then(payload => {
|
|
1999
|
-
setRecords(sortRecords(payload.records || [], options.sort || []));
|
|
2000
|
-
}).catch(onError);
|
|
2001
|
-
}, [options.entity, options.association, pageContext?.type, pageContext?.id,
|
|
2002
|
-
revision, request, onError]);
|
|
2003
|
-
return <div className={classes('mxrb-widget', 'mxrb-gallery', options.class)}
|
|
2004
|
-
data-widget-name={widget.name} data-widget-type={widget.type}>
|
|
2005
|
-
<div className="mxrb-gallery-items gallery-items">
|
|
2006
|
-
{records.map(record => <div className="mxrb-gallery-item gallery-item" key={record.id}>
|
|
2007
|
-
{(widget.children || []).map((child, index) => <Widget key={`${child.name}-${index}`}
|
|
2008
|
-
widget={child} moduleName={moduleName} invoke={invoke} invokeNanoflow={invokeNanoflow}
|
|
2009
|
-
navigate={navigate} context={record} schema={schema} request={request}
|
|
2010
|
-
saveRecord={saveRecord} onError={onError} onMutation={onMutation}
|
|
2011
|
-
onSelectRecord={onSelectRecord}
|
|
2012
|
-
pageContext={pageContext} revision={revision} />)}
|
|
2013
|
-
</div>)}
|
|
2014
|
-
</div>
|
|
2015
|
-
</div>;
|
|
2016
|
-
}
|
|
2017
|
-
|
|
2018
|
-
function Widget({ widget, children: compiledChildren, moduleName, invoke, invokeNanoflow, navigate,
|
|
2019
|
-
context, pageContext, revision, schema, request, saveRecord,
|
|
2020
|
-
onError, onMutation, onSelectRecord }: WidgetRuntimeProps) {
|
|
2021
|
-
const options = widget.options || {};
|
|
2022
|
-
if (!isVisible(options.visible, context || pageContext)) return null;
|
|
2023
|
-
const className = classes('mxrb-widget', `mxrb-${widget.type}`, `mx-name-${widget.name}`,
|
|
2024
|
-
options.class,
|
|
2025
|
-
dynamicClass(options.dynamic_class, context || pageContext));
|
|
2026
|
-
const runtimeProps = {
|
|
2027
|
-
'data-widget-name': widget.name,
|
|
2028
|
-
'data-widget-type': widget.type
|
|
2029
|
-
};
|
|
2030
|
-
const children = compiledChildren ?? (widget.children || []).map((child, index) =>
|
|
2031
|
-
<Widget key={`${child.name}-${index}`} widget={child} moduleName={moduleName} invoke={invoke}
|
|
2032
|
-
invokeNanoflow={invokeNanoflow} navigate={navigate}
|
|
2033
|
-
context={context} pageContext={pageContext} revision={revision} schema={schema}
|
|
2034
|
-
request={request} saveRecord={saveRecord} onError={onError} onMutation={onMutation}
|
|
2035
|
-
onSelectRecord={onSelectRecord} />);
|
|
2036
|
-
const click = (widget.events || []).find(event => event.event === 'on_click');
|
|
2037
|
-
const change = (widget.events || []).find(event => event.event === 'on_change');
|
|
2038
|
-
const runEvent = (
|
|
2039
|
-
event: WidgetEvent | undefined, eventContext: EntityRecord | null = context || pageContext
|
|
2040
|
-
): Promise<unknown> => {
|
|
2041
|
-
if (!event) return Promise.resolve();
|
|
2042
|
-
const handler = event.handler.includes('.') ? event.handler : `${moduleName}.${event.handler}`;
|
|
2043
|
-
const parameters = eventArguments(event, eventContext);
|
|
2044
|
-
if (event.kind === 'nanoflow') return invokeNanoflow(handler, parameters, eventContext);
|
|
2045
|
-
if (event.kind === 'page') {
|
|
2046
|
-
const candidate = Object.values(parameters)[0];
|
|
2047
|
-
const targetContext = isEntityRecord(candidate) ? candidate : pageContext || context || null;
|
|
2048
|
-
return navigate(handler, targetContext);
|
|
2049
|
-
}
|
|
2050
|
-
return invoke(handler, parameters, eventContext);
|
|
2051
|
-
};
|
|
2052
|
-
const onClick = click ? () => runEvent(click) : undefined;
|
|
2053
|
-
const onChanged = (updated: EntityRecord) => runEvent(change, updated);
|
|
2054
|
-
|
|
2055
|
-
switch (widget.type) {
|
|
2056
|
-
case 'container':
|
|
2057
|
-
return <div {...runtimeProps} className={className} style={inlineStyle(options.style)} onClick={onClick}
|
|
2058
|
-
role={onClick ? 'button' : undefined} tabIndex={onClick ? 0 : undefined}>
|
|
2059
|
-
{children}
|
|
2060
|
-
</div>;
|
|
2061
|
-
case 'text':
|
|
2062
|
-
return <span {...runtimeProps} className={className}>{caption(widget, options, context || pageContext)}</span>;
|
|
2063
|
-
case 'button':
|
|
2064
|
-
return <button {...runtimeProps} type="button" className={className} onClick={onClick}>
|
|
2065
|
-
{caption(widget, options, context || pageContext)}
|
|
2066
|
-
</button>;
|
|
2067
|
-
case 'text_area':
|
|
2068
|
-
return <label {...runtimeProps} className={className}>{caption(widget, options, context || pageContext)}
|
|
2069
|
-
<BoundField widget={widget} record={context || pageContext} schema={schema}
|
|
2070
|
-
request={request} saveRecord={saveRecord} revision={revision}
|
|
2071
|
-
onChanged={onChanged} onError={onError} />
|
|
2072
|
-
</label>;
|
|
2073
|
-
case 'text_box':
|
|
2074
|
-
case 'number_input':
|
|
2075
|
-
return <label {...runtimeProps} className={className}>{caption(widget, options, context || pageContext)}
|
|
2076
|
-
<BoundField widget={widget} record={context || pageContext} schema={schema}
|
|
2077
|
-
request={request} saveRecord={saveRecord} revision={revision}
|
|
2078
|
-
onChanged={onChanged} onError={onError} />
|
|
2079
|
-
</label>;
|
|
2080
|
-
case 'check_box':
|
|
2081
|
-
return <label {...runtimeProps} className={className}>
|
|
2082
|
-
<BoundField widget={widget} record={context || pageContext} schema={schema}
|
|
2083
|
-
request={request} saveRecord={saveRecord} revision={revision}
|
|
2084
|
-
onChanged={onChanged} onError={onError} />
|
|
2085
|
-
{caption(widget, options, context || pageContext)}
|
|
2086
|
-
</label>;
|
|
2087
|
-
case 'date_picker':
|
|
2088
|
-
return <label {...runtimeProps} className={className}>{caption(widget, options, context || pageContext)}
|
|
2089
|
-
<BoundField widget={widget} record={context || pageContext} schema={schema}
|
|
2090
|
-
request={request} saveRecord={saveRecord} revision={revision}
|
|
2091
|
-
onChanged={onChanged} onError={onError} />
|
|
2092
|
-
</label>;
|
|
2093
|
-
case 'drop_down':
|
|
2094
|
-
case 'reference_selector':
|
|
2095
|
-
return <label {...runtimeProps} className={className}>{caption(widget, options, context || pageContext)}
|
|
2096
|
-
<BoundField widget={widget} record={context || pageContext} schema={schema}
|
|
2097
|
-
request={request} saveRecord={saveRecord} revision={revision}
|
|
2098
|
-
onChanged={onChanged} onError={onError} />
|
|
2099
|
-
</label>;
|
|
2100
|
-
case 'tab_control':
|
|
2101
|
-
return <div {...runtimeProps} className={className}>{(options.tabs || []).map(tab =>
|
|
2102
|
-
<section key={tab.name}><h3>{tab.caption || tab.name}</h3>
|
|
2103
|
-
{(tab.widgets || []).map((child, index) =>
|
|
2104
|
-
<Widget key={`${child.name}-${index}`} widget={child} moduleName={moduleName} invoke={invoke}
|
|
2105
|
-
invokeNanoflow={invokeNanoflow} navigate={navigate}
|
|
2106
|
-
context={context} pageContext={pageContext} revision={revision} schema={schema}
|
|
2107
|
-
request={request} saveRecord={saveRecord} onError={onError} onMutation={onMutation}
|
|
2108
|
-
onSelectRecord={onSelectRecord} />)}
|
|
2109
|
-
</section>)}</div>;
|
|
2110
|
-
case 'data_grid':
|
|
2111
|
-
return <div {...runtimeProps} className={className}><DataGrid widget={widget} request={request}
|
|
2112
|
-
pageContext={pageContext} revision={revision} onError={onError}
|
|
2113
|
-
onMutation={onMutation} onSelectRecord={onSelectRecord}
|
|
2114
|
-
onRowAction={record => runEvent(change || click, record)} />
|
|
2115
|
-
</div>;
|
|
2116
|
-
case 'gallery':
|
|
2117
|
-
return <Gallery widget={widget} moduleName={moduleName} invoke={invoke}
|
|
2118
|
-
invokeNanoflow={invokeNanoflow} navigate={navigate}
|
|
2119
|
-
pageContext={pageContext} revision={revision} schema={schema} request={request}
|
|
2120
|
-
saveRecord={saveRecord} onError={onError} onMutation={onMutation}
|
|
2121
|
-
onSelectRecord={onSelectRecord} />;
|
|
2122
|
-
case 'pluggable_widget':
|
|
2123
|
-
return <div {...runtimeProps} className={classes(className, 'mxrb-marketplace-widget')}
|
|
2124
|
-
data-widget-id={options.widget_id || ''}>
|
|
2125
|
-
<MarketplaceWidget widget={widget} context={context || pageContext}
|
|
2126
|
-
onChange={(attribute, value) => {
|
|
2127
|
-
const active = context || pageContext;
|
|
2128
|
-
const member = memberName(attribute);
|
|
2129
|
-
if (!active || !member) return Promise.resolve(active);
|
|
2130
|
-
return saveRecord(active, { [member]: value }).then(updated => {
|
|
2131
|
-
if (updated) return onChanged(updated);
|
|
2132
|
-
return updated;
|
|
2133
|
-
});
|
|
2134
|
-
}}>{children}</MarketplaceWidget>
|
|
2135
|
-
</div>;
|
|
2136
|
-
case 'native_widget':
|
|
2137
|
-
return <div {...runtimeProps} className={classes(className, 'mxrb-native-widget')}
|
|
2138
|
-
data-native-type={options.native_type || ''} role="alert">
|
|
2139
|
-
Could not render widget {widget.name}: unsupported native type {options.native_type || 'unknown'}
|
|
2140
|
-
</div>;
|
|
2141
|
-
default:
|
|
2142
|
-
return <div {...runtimeProps} className={className} role="alert">
|
|
2143
|
-
Could not render widget {widget.name}: unsupported type {widget.type}
|
|
2144
|
-
</div>;
|
|
2145
|
-
}
|
|
2146
|
-
}
|
|
2147
|
-
|
|
2148
|
-
function navigationItems(items: NavigationItem[], openPage: (name: string) => unknown) {
|
|
2149
|
-
return (items || []).map((item, index) => <li key={`${item.page || item.caption?.en_US}-${index}`}>
|
|
2150
|
-
{item.page ? <button type="button" onClick={() => openPage(item.page!)}>
|
|
2151
|
-
{item.caption?.en_US || item.page}
|
|
2152
|
-
</button> : <span>{item.caption?.en_US || ''}</span>}
|
|
2153
|
-
{item.items?.length ? <ul>{navigationItems(item.items, openPage)}</ul> : null}
|
|
2154
|
-
</li>);
|
|
2155
|
-
}
|
|
2156
|
-
|
|
2157
|
-
function Login({ onLogin, error, busy }: LoginProps) {
|
|
2158
|
-
const [username, setUsername] = useState('');
|
|
2159
|
-
const [password, setPassword] = useState('');
|
|
2160
|
-
const submit = (event: FormEvent<HTMLFormElement>) => {
|
|
2161
|
-
event.preventDefault();
|
|
2162
|
-
onLogin(username, password).finally(() => setPassword(''));
|
|
2163
|
-
};
|
|
2164
|
-
return <main className="mxrb-login">
|
|
2165
|
-
<form onSubmit={submit}>
|
|
2166
|
-
<h1>Sign in</h1>
|
|
2167
|
-
<label>Username<input autoComplete="username" value={username}
|
|
2168
|
-
onChange={event => setUsername(event.target.value)} /></label>
|
|
2169
|
-
<label>Password<input type="password" autoComplete="current-password" value={password}
|
|
2170
|
-
onChange={event => setPassword(event.target.value)} /></label>
|
|
2171
|
-
<button type="submit" disabled={busy || !username || !password}>Sign in</button>
|
|
2172
|
-
{error ? <p role="alert">{error.message}</p> : null}
|
|
2173
|
-
</form>
|
|
2174
|
-
</main>;
|
|
2175
|
-
}
|
|
2176
|
-
|
|
2177
|
-
export default function App() {
|
|
2178
|
-
const [schema, setSchema] = useState<ApplicationSchema | null>(null);
|
|
2179
|
-
const [page, setPage] = useState<PageDefinition | null>(null);
|
|
2180
|
-
const [pageContext, setPageContext] = useState<EntityRecord | null>(null);
|
|
2181
|
-
const [error, setError] = useState<ApiFailure | null>(null);
|
|
2182
|
-
const [busy, setBusy] = useState(false);
|
|
2183
|
-
const initialLoadStarted = useRef(false);
|
|
2184
|
-
const invocationInFlight = useRef(false);
|
|
2185
|
-
const [revision, setRevision] = useState(0);
|
|
2186
|
-
const [token, setToken] = useState(() => localStorage.getItem(TOKEN_KEY));
|
|
2187
|
-
const [session, setSession] = useState<Session | null>(null);
|
|
2188
|
-
const [authRequired, setAuthRequired] = useState(false);
|
|
2189
|
-
|
|
2190
|
-
const handleError = useCallback((failure: unknown) => {
|
|
2191
|
-
const normalized = apiFailure(failure);
|
|
2192
|
-
if (normalized.status === 401) setAuthRequired(true);
|
|
2193
|
-
setError(normalized);
|
|
2194
|
-
}, []);
|
|
2195
|
-
const request: ApiRequest = useCallback(
|
|
2196
|
-
(path: string, options: RequestInit = {}) => api(path, options, token), [token]
|
|
2197
|
-
);
|
|
2198
|
-
|
|
2199
|
-
const openPage = async (
|
|
2200
|
-
name: string, context: EntityRecord | null = null, activeToken = token
|
|
2201
|
-
): Promise<void> => {
|
|
2202
|
-
try {
|
|
2203
|
-
const value = await api<PageDefinition>(
|
|
2204
|
-
`/api/pages/${encodeURIComponent(name)}`, {}, activeToken
|
|
2205
|
-
);
|
|
2206
|
-
let resolvedContext = context;
|
|
2207
|
-
if (!resolvedContext && value.data_source?.name) {
|
|
2208
|
-
if (value.data_source.kind === 'nanoflow') {
|
|
2209
|
-
const source = nanoflows[value.data_source.name as keyof typeof nanoflows];
|
|
2210
|
-
if (!source) throw new Error(`Page data source nanoflow not found: ${value.data_source.name}`);
|
|
2211
|
-
const execution = await source.execute({});
|
|
2212
|
-
resolvedContext = isEntityRecord(execution.result)
|
|
2213
|
-
? { ...execution.result, transient: true } : null;
|
|
2214
|
-
} else {
|
|
2215
|
-
const payload = await api<InvocationResult>(
|
|
2216
|
-
`/api/microflows/${encodeURIComponent(value.data_source.name)}`,
|
|
2217
|
-
{ method: 'POST', body: '{}' }, activeToken
|
|
2218
|
-
);
|
|
2219
|
-
const candidate = payload.context || payload.result;
|
|
2220
|
-
resolvedContext = isEntityRecord(candidate)
|
|
2221
|
-
? { ...candidate, transient: true } : null;
|
|
2222
|
-
}
|
|
2223
|
-
}
|
|
2224
|
-
setPage(value);
|
|
2225
|
-
setPageContext(resolvedContext);
|
|
2226
|
-
setRevision(current => current + 1);
|
|
2227
|
-
setError(null);
|
|
2228
|
-
} catch (failure) {
|
|
2229
|
-
handleError(failure);
|
|
2230
|
-
}
|
|
2231
|
-
};
|
|
2232
|
-
|
|
2233
|
-
const loadApplication = async (activeToken = token) => {
|
|
2234
|
-
try {
|
|
2235
|
-
if (activeToken) {
|
|
2236
|
-
const currentSession = await api<Session>('/api/session', {}, activeToken);
|
|
2237
|
-
setSession(currentSession);
|
|
2238
|
-
}
|
|
2239
|
-
const value = await api<ApplicationSchema>('/api/schema', {}, activeToken);
|
|
2240
|
-
setSchema(value);
|
|
2241
|
-
setAuthRequired(false);
|
|
2242
|
-
setError(null);
|
|
2243
|
-
const profile = value.navigation?.profiles?.find(item => item.kind === 'Responsive')
|
|
2244
|
-
|| value.navigation?.profiles?.[0];
|
|
2245
|
-
const fallback = value.modules.flatMap(module => module.pages)[0]?.name;
|
|
2246
|
-
await openPage(profile?.home_page || fallback, null, activeToken);
|
|
2247
|
-
} catch (failure) {
|
|
2248
|
-
const normalized = apiFailure(failure);
|
|
2249
|
-
if (normalized.status === 401) {
|
|
2250
|
-
localStorage.removeItem(TOKEN_KEY);
|
|
2251
|
-
setToken(null);
|
|
2252
|
-
setSession(null);
|
|
2253
|
-
setAuthRequired(true);
|
|
2254
|
-
}
|
|
2255
|
-
setError(normalized);
|
|
2256
|
-
}
|
|
2257
|
-
};
|
|
2258
|
-
|
|
2259
|
-
useEffect(() => {
|
|
2260
|
-
if (initialLoadStarted.current) return;
|
|
2261
|
-
initialLoadStarted.current = true;
|
|
2262
|
-
loadApplication(token);
|
|
2263
|
-
}, []);
|
|
2264
|
-
|
|
2265
|
-
const login = async (username: string, password: string): Promise<void> => {
|
|
2266
|
-
setBusy(true);
|
|
2267
|
-
try {
|
|
2268
|
-
const authenticated = await api<LoginResponse>('/api/login', {
|
|
2269
|
-
method: 'POST', body: JSON.stringify({ username, password })
|
|
2270
|
-
});
|
|
2271
|
-
localStorage.setItem(TOKEN_KEY, authenticated.token);
|
|
2272
|
-
setToken(authenticated.token);
|
|
2273
|
-
await loadApplication(authenticated.token);
|
|
2274
|
-
} catch (failure) {
|
|
2275
|
-
setError(apiFailure(failure));
|
|
2276
|
-
} finally {
|
|
2277
|
-
setBusy(false);
|
|
2278
|
-
}
|
|
2279
|
-
};
|
|
2280
|
-
|
|
2281
|
-
const logout = async () => {
|
|
2282
|
-
try {
|
|
2283
|
-
await api('/api/logout', { method: 'POST' }, token);
|
|
2284
|
-
} catch (failure) {
|
|
2285
|
-
const normalized = apiFailure(failure);
|
|
2286
|
-
if (normalized.status !== 401) setError(normalized);
|
|
2287
|
-
} finally {
|
|
2288
|
-
localStorage.removeItem(TOKEN_KEY);
|
|
2289
|
-
setToken(null);
|
|
2290
|
-
setSession(null);
|
|
2291
|
-
setSchema(null);
|
|
2292
|
-
setPage(null);
|
|
2293
|
-
setAuthRequired(true);
|
|
2294
|
-
}
|
|
2295
|
-
};
|
|
2296
|
-
|
|
2297
|
-
const refreshPageContext = () => {
|
|
2298
|
-
if (!pageContext?.type || !pageContext?.id) return Promise.resolve();
|
|
2299
|
-
return request<EntityRecord>(
|
|
2300
|
-
`/api/entities/${encodeURIComponent(pageContext.type)}/${encodeURIComponent(pageContext.id)}`
|
|
2301
|
-
).then(setPageContext).catch(handleError);
|
|
2302
|
-
};
|
|
2303
|
-
|
|
2304
|
-
const saveRecord: SaveRecord = useCallback((record, changes) => {
|
|
2305
|
-
if (!record?.type || !record?.id) return Promise.resolve(record);
|
|
2306
|
-
if (record.transient) {
|
|
2307
|
-
const updated: EntityRecord = {
|
|
2308
|
-
...record, attributes: { ...record.attributes, ...changes }
|
|
2309
|
-
};
|
|
2310
|
-
setPageContext(current => current?.id === updated.id ? updated : current);
|
|
2311
|
-
setRevision(value => value + 1);
|
|
2312
|
-
setError(null);
|
|
2313
|
-
return Promise.resolve(updated);
|
|
2314
|
-
}
|
|
2315
|
-
return request<EntityRecord>(`/api/entities/${encodeURIComponent(record.type)}/${encodeURIComponent(record.id)}`, {
|
|
2316
|
-
method: 'PATCH', body: JSON.stringify(changes)
|
|
2317
|
-
}).then(updated => {
|
|
2318
|
-
setPageContext(current => current?.id === updated.id ? updated : current);
|
|
2319
|
-
setRevision(value => value + 1);
|
|
2320
|
-
setError(null);
|
|
2321
|
-
return updated;
|
|
2322
|
-
}).catch(failure => {
|
|
2323
|
-
const normalized = apiFailure(failure);
|
|
2324
|
-
if (normalized.status === 404) {
|
|
2325
|
-
const updated: EntityRecord = {
|
|
2326
|
-
...record, attributes: { ...record.attributes, ...changes }
|
|
2327
|
-
};
|
|
2328
|
-
setPageContext(current => current?.id === updated.id ? updated : current);
|
|
2329
|
-
setRevision(value => value + 1);
|
|
2330
|
-
setError(null);
|
|
2331
|
-
return updated;
|
|
2332
|
-
}
|
|
2333
|
-
handleError(failure);
|
|
2334
|
-
return null;
|
|
2335
|
-
});
|
|
2336
|
-
}, [request, handleError]);
|
|
2337
|
-
|
|
2338
|
-
const markMutation = useCallback(() => setRevision(value => value + 1), []);
|
|
2339
|
-
const selectRecord: SelectRecord = useCallback(record => setPageContext(record), []);
|
|
2340
|
-
|
|
2341
|
-
const invoke: InvokeHandler = (name, parameters = {}, contextOverride = null) => {
|
|
2342
|
-
if (invocationInFlight.current) return Promise.resolve(null);
|
|
2343
|
-
invocationInFlight.current = true;
|
|
2344
|
-
setBusy(true);
|
|
2345
|
-
const activeContext = pageContext || contextOverride;
|
|
2346
|
-
return request<InvocationResult>(`/api/microflows/${encodeURIComponent(name)}`, {
|
|
2347
|
-
method: 'POST', body: JSON.stringify({
|
|
2348
|
-
...parameters, ...(activeContext ? { __mxrb_context: activeContext } : {})
|
|
2349
|
-
})
|
|
2350
|
-
})
|
|
2351
|
-
.then(payload => {
|
|
2352
|
-
setRevision(value => value + 1);
|
|
2353
|
-
if (payload.context) setPageContext(payload.context);
|
|
2354
|
-
const navigation = (payload.effects || []).find(
|
|
2355
|
-
(effect): effect is OpenPageEffect => effect.type === 'open_page'
|
|
2356
|
-
);
|
|
2357
|
-
if (navigation?.page) {
|
|
2358
|
-
const context = Object.values(navigation.arguments || {})[0]
|
|
2359
|
-
|| payload.context || payload.result || null;
|
|
2360
|
-
return openPage(navigation.page, context as EntityRecord | null).then(() => payload);
|
|
2361
|
-
}
|
|
2362
|
-
return payload.context ? Promise.resolve(payload) : refreshPageContext().then(() => payload);
|
|
2363
|
-
}).catch(handleError).finally(() => {
|
|
2364
|
-
invocationInFlight.current = false;
|
|
2365
|
-
setBusy(false);
|
|
2366
|
-
});
|
|
2367
|
-
};
|
|
2368
|
-
|
|
2369
|
-
const invokeNanoflow: InvokeHandler = async (
|
|
2370
|
-
name, parameters = {}, contextOverride = null
|
|
2371
|
-
) => {
|
|
2372
|
-
setBusy(true);
|
|
2373
|
-
try {
|
|
2374
|
-
const definition = nanoflows[name as keyof typeof nanoflows];
|
|
2375
|
-
const resolvedParameters: RuntimeVariables = { ...parameters };
|
|
2376
|
-
const activeContext = contextOverride || pageContext;
|
|
2377
|
-
if (definition?.parameters?.length === 1 && !(definition.parameters[0] in resolvedParameters)
|
|
2378
|
-
&& activeContext) {
|
|
2379
|
-
resolvedParameters[definition.parameters[0]] = activeContext;
|
|
2380
|
-
}
|
|
2381
|
-
if (!definition) throw new Error(`Nanoflow frontend not found: ${name}`);
|
|
2382
|
-
const execution = await definition.execute(resolvedParameters);
|
|
2383
|
-
for (const changed of execution.changes) {
|
|
2384
|
-
await saveRecord(changed, changed.attributes);
|
|
2385
|
-
}
|
|
2386
|
-
setError(null);
|
|
2387
|
-
return execution.result;
|
|
2388
|
-
} catch (failure) {
|
|
2389
|
-
setError(apiFailure(failure));
|
|
2390
|
-
return null;
|
|
2391
|
-
} finally {
|
|
2392
|
-
setBusy(false);
|
|
2393
|
-
}
|
|
2394
|
-
};
|
|
2395
|
-
|
|
2396
|
-
if (authRequired) return <Login onLogin={login} error={error} busy={busy} />;
|
|
2397
|
-
if (!schema || !page) return <main className="mxrb-loading">Loading application…</main>;
|
|
2398
|
-
const profile = schema.navigation?.profiles?.find(item => item.kind === 'Responsive')
|
|
2399
|
-
|| schema.navigation?.profiles?.[0];
|
|
2400
|
-
const moduleName = page.name.split('.')[0];
|
|
2401
|
-
const PageComponent = pages[page.name as keyof typeof pages];
|
|
2402
|
-
const PageWidget = ({ widget, children }: PageWidgetProps) =>
|
|
2403
|
-
<Widget widget={widget} moduleName={moduleName} invoke={invoke}
|
|
2404
|
-
invokeNanoflow={invokeNanoflow} navigate={openPage}
|
|
2405
|
-
context={pageContext} pageContext={pageContext} revision={revision} schema={schema}
|
|
2406
|
-
request={request} saveRecord={saveRecord} onError={handleError}
|
|
2407
|
-
onMutation={markMutation} onSelectRecord={selectRecord}>{children}</Widget>;
|
|
2408
|
-
|
|
2409
|
-
return <div className={classes('mxrb-app-shell', 'mx-page', page.appearance_class)} style={inlineStyle(page.appearance_style)}>
|
|
2410
|
-
{profile?.items?.length || session ? <nav className="mxrb-navigation region-sidebar">
|
|
2411
|
-
{profile?.items?.length ? <ul>{navigationItems(profile.items, openPage)}</ul> : null}
|
|
2412
|
-
{session ? <button type="button" onClick={logout}>Sign out</button> : null}
|
|
2413
|
-
</nav> : null}
|
|
2414
|
-
{PageComponent ? <PageComponent busy={busy} Widget={PageWidget} /> :
|
|
2415
|
-
<main className="mxrb-page region-content" role="alert">
|
|
2416
|
-
Generated React page not found: {page.name}
|
|
2417
|
-
</main>}
|
|
2418
|
-
{error ? <aside className="mxrb-runtime-error" role="alert">
|
|
2419
|
-
<button type="button" onClick={() => setError(null)}>×</button>{error.message}
|
|
2420
|
-
</aside> : null}
|
|
2421
|
-
</div>;
|
|
2422
|
-
}
|
|
2423
|
-
JS
|
|
2424
|
-
end
|
|
2425
|
-
|
|
2426
|
-
def frontend_css
|
|
2427
|
-
<<~CSS
|
|
2428
|
-
:root { font: 16px/1.5 system-ui, sans-serif; }
|
|
2429
|
-
* { box-sizing: border-box; }
|
|
2430
|
-
html, body, #root { min-height: 100%; margin: 0; }
|
|
2431
|
-
button, input, textarea, select { font: inherit; }
|
|
2432
|
-
.mxrb-app-shell { min-height: 100vh; }
|
|
2433
|
-
.mxrb-page { min-height: 100vh; }
|
|
2434
|
-
.mxrb-page[aria-busy='true'] { cursor: progress; pointer-events: none; }
|
|
2435
|
-
.mxrb-navigation { position: fixed; z-index: 20; right: 1rem; top: 1rem; }
|
|
2436
|
-
.mxrb-navigation ul { display: flex; gap: .5rem; margin: 0; padding: 0; list-style: none; }
|
|
2437
|
-
.mxrb-navigation button { border: 1px solid currentColor; border-radius: .4rem; background: transparent; color: inherit; cursor: pointer; }
|
|
2438
|
-
.mxrb-text { display: block; }
|
|
2439
|
-
.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; }
|
|
2440
|
-
.mxrb-runtime-error button { float: right; border: 0; background: transparent; color: inherit; cursor: pointer; }
|
|
2441
|
-
.mxrb-loading { display: grid; min-height: 100vh; place-items: center; }
|
|
2442
|
-
.mxrb-login { display: grid; min-height: 100vh; place-items: center; padding: 1rem; }
|
|
2443
|
-
.mxrb-login form { display: grid; width: min(24rem, 100%); gap: 1rem; padding: 2rem; border: 1px solid #d1d5db; border-radius: .75rem; }
|
|
2444
|
-
.mxrb-login label { display: grid; gap: .25rem; }
|
|
2445
|
-
.mxrb-marketplace-widget { display: block; min-width: 0; }
|
|
2446
|
-
.mxrb-marketplace-widget img, .mxrb-marketplace-widget video,
|
|
2447
|
-
.mxrb-marketplace-chart svg { display: block; width: 100%; height: 12rem; max-width: 100%; }
|
|
2448
|
-
.mxrb-marketplace-chart { margin: .5rem 0; }
|
|
2449
|
-
.mxrb-marketplace-rating { display: inline-flex; border: 0; padding: 0; }
|
|
2450
|
-
.mxrb-marketplace-rating button { border: 0; background: transparent; cursor: pointer; }
|
|
2451
|
-
.mxrb-marketplace-badge { display: inline-block; padding: .125rem .5rem; border-radius: 999px; background: #e5e7eb; }
|
|
2452
|
-
.mxrb-grid-toolbar, .mxrb-grid-pagination { display: flex; align-items: center; gap: .5rem; margin-block: .5rem; }
|
|
2453
|
-
.mxrb-data-grid-runtime table { width: 100%; border-collapse: collapse; }
|
|
2454
|
-
.mxrb-data-grid-runtime th, .mxrb-data-grid-runtime td { padding: .5rem; border-bottom: 1px solid #d1d5db; text-align: left; }
|
|
2455
|
-
.mxrb-data-grid-runtime tbody tr { cursor: pointer; }
|
|
2456
|
-
.mxrb-data-grid-runtime tbody tr.is-selected { background: #dbeafe; }
|
|
2457
|
-
.mxrb-native-widget:empty { min-height: 1px; }
|
|
2458
|
-
CSS
|
|
522
|
+
@declaration_contents[relative_path] = contents
|
|
2459
523
|
end
|
|
2460
524
|
|
|
2461
525
|
def readme
|
|
@@ -2468,7 +532,7 @@ module Mxrb
|
|
|
2468
532
|
|
|
2469
533
|
```sh
|
|
2470
534
|
bundle install
|
|
2471
|
-
npm
|
|
535
|
+
npm ci --prefix frontend
|
|
2472
536
|
bundle exec mxrb run .
|
|
2473
537
|
```
|
|
2474
538
|
|
|
@@ -2477,11 +541,25 @@ module Mxrb
|
|
|
2477
541
|
application. Use `--server-port` for Ruby and `--client-port` for Vite;
|
|
2478
542
|
`--api-port` and `--port` remain compatibility aliases. Generated models,
|
|
2479
543
|
DTOs, services, and pages live under `app/`.
|
|
2480
|
-
The generated `frontend/src/types.ts` covers domain records, pages, widgets,
|
|
544
|
+
The generated `frontend/src/generated/types.ts` covers domain records, pages, widgets,
|
|
2481
545
|
contexts, effects, and API payloads; `npm run typecheck` validates it strictly.
|
|
2482
546
|
Service bodies are ordinary Ruby; their default implementation delegates to
|
|
2483
547
|
MXRB's pure-Ruby interpreter.
|
|
2484
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
|
+
|
|
2485
563
|
Browser CRUD uses the same authenticated entity API as microflows. Configure
|
|
2486
564
|
users and bearer tokens through ignored environment files. External app/web
|
|
2487
565
|
services, mappings, XML imports, and documents are explicit Ruby integrations
|