simple-module-hosting 0.0.42__tar.gz → 0.0.43__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/.gitignore +3 -0
  2. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/PKG-INFO +6 -6
  3. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/pyproject.toml +6 -6
  4. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_db_health.py +2 -5
  5. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_error_handlers.py +15 -0
  6. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_error_negotiation.py +2 -3
  7. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_error_page.py +9 -1
  8. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_inertia_shared.py +36 -34
  9. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_lease_redis.py +30 -5
  10. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_lifespan.py +22 -55
  11. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_middleware_pipeline.py +15 -25
  12. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_observability.py +4 -2
  13. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_preapp_config.py +2 -1
  14. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_rate_limit.py +6 -2
  15. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_spa_mount.py +41 -1
  16. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/health.py +25 -15
  17. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/host_settings.py +13 -2
  18. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/i18n_middleware.py +20 -8
  19. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/inertia_deps.py +14 -2
  20. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/inertia_utils.py +7 -9
  21. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/log_sinks.py +4 -0
  22. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/maintenance.py +4 -2
  23. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/middleware.py +39 -25
  24. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/migrations.py +5 -0
  25. simple_module_hosting-0.0.43/simple_module_hosting/path_matching.py +8 -0
  26. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_gate.py +8 -12
  27. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_wizard/migrate.py +12 -3
  28. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_wizard/payloads.py +4 -5
  29. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_wizard/routes.py +4 -4
  30. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/shared_props.py +2 -1
  31. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_boot_drift_check.py +40 -7
  32. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_error_page_shared_props.py +16 -37
  33. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_grant_sources.py +2 -1
  34. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_health.py +1 -1
  35. simple_module_hosting-0.0.43/tests/test_hosting_config_sources.py +85 -0
  36. simple_module_hosting-0.0.43/tests/test_hosting_csp_nonce.py +138 -0
  37. simple_module_hosting-0.0.42/tests/test_csp_providers.py → simple_module_hosting-0.0.43/tests/test_hosting_csp_providers.py +3 -1
  38. simple_module_hosting-0.0.43/tests/test_hosting_health_bounded.py +86 -0
  39. simple_module_hosting-0.0.43/tests/test_hosting_inertia_body_validation.py +115 -0
  40. simple_module_hosting-0.0.43/tests/test_hosting_inertia_cache.py +23 -0
  41. simple_module_hosting-0.0.43/tests/test_hosting_inertia_validation_errors.py +78 -0
  42. simple_module_hosting-0.0.43/tests/test_hosting_lazy_layout_catalogs.py +198 -0
  43. simple_module_hosting-0.0.43/tests/test_hosting_lease_timeouts.py +163 -0
  44. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_log_sinks.py +37 -0
  45. simple_module_hosting-0.0.43/tests/test_hosting_migration_target.py +78 -0
  46. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_permissions.py +6 -5
  47. simple_module_hosting-0.0.43/tests/test_hosting_public_path_boundaries.py +77 -0
  48. simple_module_hosting-0.0.43/tests/test_hosting_spa_mount_nonce.py +61 -0
  49. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_inertia_i18n_shared_props.py +41 -30
  50. simple_module_hosting-0.0.43/tests/test_inertia_protocol_middleware.py +90 -0
  51. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_inertia_shared_providers.py +28 -13
  52. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_locale_middleware.py +35 -0
  53. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_maintenance_mode.py +11 -11
  54. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_menu_providers_wiring.py +18 -17
  55. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_middleware_order.py +8 -20
  56. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_migration_listing.py +7 -2
  57. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_spa_mounts_541.py +2 -10
  58. simple_module_hosting-0.0.42/simple_module_hosting/_inertia_cache.py +0 -104
  59. simple_module_hosting-0.0.42/tests/test_inertia_cache.py +0 -187
  60. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/LICENSE +0 -0
  61. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/README.md +0 -0
  62. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/__init__.py +0 -0
  63. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/__main__.py +0 -0
  64. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_anonymous.py +0 -0
  65. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_api_version.py +0 -0
  66. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_app_boot.py +0 -0
  67. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_body_limit.py +0 -0
  68. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_boot_checks.py +0 -0
  69. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_cors.py +0 -0
  70. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_csp_dynamic.py +0 -0
  71. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_deferred_startup.py +0 -0
  72. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_dev_boot.py +0 -0
  73. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_favicon.py +0 -0
  74. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_forwarded_host.py +0 -0
  75. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_host_services.py +0 -0
  76. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_host_settings_support.py +0 -0
  77. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_hydrate_step.py +0 -0
  78. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_i18n_build.py +0 -0
  79. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_i18n_target.py +0 -0
  80. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_inertia_setup.py +0 -0
  81. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_insecure_transport.py +0 -0
  82. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_module_routes.py +0 -0
  83. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_openapi.py +0 -0
  84. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_phase_helpers.py +0 -0
  85. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_process_services.py +0 -0
  86. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_project_root.py +0 -0
  87. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_rate_limit_keys.py +0 -0
  88. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_rate_limit_store.py +0 -0
  89. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_registrations.py +0 -0
  90. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_request_guard_responses.py +0 -0
  91. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_route_access.py +0 -0
  92. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_route_guard.py +0 -0
  93. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_route_paths.py +0 -0
  94. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_secret_key.py +0 -0
  95. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_settings_registration.py +0 -0
  96. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/_tenant.py +0 -0
  97. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/app_builder.py +0 -0
  98. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/assets.py +0 -0
  99. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/bootstrap_settings.py +0 -0
  100. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/csrf.py +0 -0
  101. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/data_compatibility.py +0 -0
  102. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/db_options.py +0 -0
  103. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/errors.py +0 -0
  104. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/host_cli.py +0 -0
  105. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/i18n_deps.py +0 -0
  106. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/i18n_manifest.py +0 -0
  107. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/i18n_routes.py +0 -0
  108. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/leases.py +0 -0
  109. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/locales/de.json +0 -0
  110. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/locales/en.json +0 -0
  111. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/locales/es.json +0 -0
  112. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/logging.py +0 -0
  113. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/manifest.py +0 -0
  114. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/page_globs.py +0 -0
  115. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/pagination.py +0 -0
  116. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/permissions.py +0 -0
  117. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/public_access.py +0 -0
  118. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/py.typed +0 -0
  119. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/rate_limit_deps.py +0 -0
  120. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/redirects.py +0 -0
  121. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/resource_deps.py +0 -0
  122. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/sentry.py +0 -0
  123. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/sentry_scrub.py +0 -0
  124. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/sentry_scrub_text.py +0 -0
  125. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/session.py +0 -0
  126. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/settings.py +0 -0
  127. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_wizard/__init__.py +0 -0
  128. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_wizard/_migration_lock.py +0 -0
  129. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_wizard/components/ConnectionList.tsx +0 -0
  130. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_wizard/components/StepForm.tsx +0 -0
  131. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/setup_wizard/pages/Wizard.tsx +0 -0
  132. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/static_files.py +0 -0
  133. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/tenancy.py +0 -0
  134. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/token_guard.py +0 -0
  135. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/ui_locales/de.json +0 -0
  136. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/ui_locales/en.json +0 -0
  137. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/simple_module_hosting/ui_locales/es.json +0 -0
  138. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/_hosting_settings_db.py +0 -0
  139. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/_resacc_models.py +0 -0
  140. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/_sentry_transport.py +0 -0
  141. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/conftest.py +0 -0
  142. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_api_error_negotiation.py +0 -0
  143. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_app.py +0 -0
  144. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_auth_provider_setting.py +0 -0
  145. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_boot_config_hardening.py +0 -0
  146. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_branding_head.py +0 -0
  147. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_build_time_settings_marked.py +0 -0
  148. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_check_migrations.py +0 -0
  149. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_check_migrations_expression_note.py +0 -0
  150. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_csp_module_sources.py +0 -0
  151. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_db_health_check.py +0 -0
  152. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_design_packs_wiring.py +0 -0
  153. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_diagnostics_state.py +0 -0
  154. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_error_status_coverage.py +0 -0
  155. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_favicon_default.py +0 -0
  156. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_forwarded_host.py +0 -0
  157. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_home_url_default.py +0 -0
  158. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_host_cli.py +0 -0
  159. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_host_settings_fields.py +0 -0
  160. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_asset_version.py +0 -0
  161. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_cors_api.py +0 -0
  162. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_cors_unset.py +0 -0
  163. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_csrf.py +0 -0
  164. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_csrf_shared_prop.py +0 -0
  165. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_data_compatibility.py +0 -0
  166. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_error_handling_policy.py +0 -0
  167. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_error_json_and_session_cookie.py +0 -0
  168. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_lease_backends.py +0 -0
  169. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_lease_selection.py +0 -0
  170. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_lifespan_cleanup.py +0 -0
  171. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_openapi.py +0 -0
  172. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_openapi_security.py +0 -0
  173. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_pagination_deps.py +0 -0
  174. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_public_access.py +0 -0
  175. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_public_error_page.py +0 -0
  176. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_sentry.py +0 -0
  177. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_sentry_scrub.py +0 -0
  178. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_hosting_sentry_scrub_gaps.py +0 -0
  179. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_i18n_build_overrides.py +0 -0
  180. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_i18n_manifest.py +0 -0
  181. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_i18n_manifest_published_target.py +0 -0
  182. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_i18n_routes.py +0 -0
  183. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_i18n_types_cover_installed_modules.py +0 -0
  184. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_i18n_ui_namespace.py +0 -0
  185. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_insecure_transport_warning.py +0 -0
  186. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_invalidation_wiring.py +0 -0
  187. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_lifespan_deferred_startup.py +0 -0
  188. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_lifespan_order.py +0 -0
  189. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_logging.py +0 -0
  190. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_manifest.py +0 -0
  191. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_menu_urls_are_canonical.py +0 -0
  192. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_merge_host_settings_strict.py +0 -0
  193. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_migration_multihead.py +0 -0
  194. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_native_link_prefixes_strip.py +0 -0
  195. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_preapp_config.py +0 -0
  196. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_preapp_invalid_values.py +0 -0
  197. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_preapp_read_failures.py +0 -0
  198. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_precompressed_static.py +0 -0
  199. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_principal_permissions_claim.py +0 -0
  200. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_proxy_headers.py +0 -0
  201. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_rate_limit_rules_redis.py +0 -0
  202. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_rate_limit_rules_registry.py +0 -0
  203. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_rate_limit_store_shared.py +0 -0
  204. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_redirects.py +0 -0
  205. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_request_guard_auth_parity.py +0 -0
  206. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_request_guard_body_limit.py +0 -0
  207. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_request_guard_body_limit_middleware_read.py +0 -0
  208. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_request_guard_body_limit_started.py +0 -0
  209. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_request_guard_rate_limit.py +0 -0
  210. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_resource_deps.py +0 -0
  211. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_resource_policy_owned.py +0 -0
  212. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_resource_policy_parity.py +0 -0
  213. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_resource_types_wiring.py +0 -0
  214. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_response_compression.py +0 -0
  215. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_route_guard.py +0 -0
  216. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_route_guard_fastapi_contract.py +0 -0
  217. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_route_paths.py +0 -0
  218. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_secret_key_bootstrap.py +0 -0
  219. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_server_rendered_head.py +0 -0
  220. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_session_cookie_secure.py +0 -0
  221. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_session_cookie_security.py +0 -0
  222. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_session_cookie_window.py +0 -0
  223. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_session_vary_dedupe.py +0 -0
  224. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_settings_i18n.py +0 -0
  225. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_settings_secrets.py +0 -0
  226. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_setup_gate.py +0 -0
  227. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_setup_gate_single_flight.py +0 -0
  228. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_setup_migrate_error_redaction.py +0 -0
  229. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_setup_migrate_worker_lock.py +0 -0
  230. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_setup_public_routes.py +0 -0
  231. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_setup_registry.py +0 -0
  232. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_setup_routes.py +0 -0
  233. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_sqlite_path_anchor.py +0 -0
  234. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_static_caching.py +0 -0
  235. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_strict_discovery_wiring.py +0 -0
  236. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_tenancy_api.py +0 -0
  237. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_tenant_middleware.py +0 -0
  238. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_tenant_resolver_diagnostic.py +0 -0
  239. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_tenant_resolver_types.py +0 -0
  240. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_tenant_scope_helpers.py +0 -0
  241. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_tenant_source.py +0 -0
  242. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_token_guard_effective_route.py +0 -0
  243. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_token_route_guard.py +0 -0
  244. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_translator_dep.py +0 -0
  245. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests/test_view_prefixes.py +0 -0
  246. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tests-js/hosting_SetupWizard.test.tsx +0 -0
  247. {simple_module_hosting-0.0.42 → simple_module_hosting-0.0.43}/tsconfig.json +0 -0
@@ -22,6 +22,9 @@ node_modules/
22
22
 
23
23
  # Database
24
24
  *.db
25
+ *.db-wal
26
+ *.db-shm
27
+ *.db-journal
25
28
  *.sqlite3
26
29
 
27
30
  # Module-managed runtime state (e.g. uploaded dataset files,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: simple_module_hosting
3
- Version: 0.0.42
3
+ Version: 0.0.43
4
4
  Summary: FastAPI + Inertia.js host runtime for simple_module — app_builder, middleware stack, CLI (sm / simple-module), scaffolding
5
5
  Project-URL: Homepage, https://github.com/antosubash/simple_module_python
6
6
  Project-URL: Repository, https://github.com/antosubash/simple_module_python
@@ -22,18 +22,18 @@ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
22
  Classifier: Typing :: Typed
23
23
  Requires-Python: >=3.12
24
24
  Requires-Dist: click<9,>=8.1
25
- Requires-Dist: fastapi<0.160,>=0.140
25
+ Requires-Dist: fastapi<0.163,>=0.140
26
26
  Requires-Dist: httpx<0.29,>=0.27
27
27
  Requires-Dist: itsdangerous<3,>=2.0
28
28
  Requires-Dist: jinja2<4,>=3.1
29
- Requires-Dist: simple-module-core==0.0.42
30
- Requires-Dist: simple-module-db==0.0.42
31
- Requires-Dist: simple-module-inertia==0.0.42
29
+ Requires-Dist: simple-module-core==0.0.43
30
+ Requires-Dist: simple-module-db==0.0.43
31
+ Requires-Dist: simple-module-inertia==0.0.43
32
32
  Requires-Dist: starlette<2,>=0.44
33
33
  Requires-Dist: tomlkit<0.16,>=0.13
34
34
  Requires-Dist: uvicorn[standard]<0.55,>=0.34
35
35
  Provides-Extra: redis
36
- Requires-Dist: redis<7,>=5; extra == 'redis'
36
+ Requires-Dist: redis<9,>=5; extra == 'redis'
37
37
  Provides-Extra: sentry
38
38
  Requires-Dist: sentry-sdk[celery,fastapi]<3,>=2.20; extra == 'sentry'
39
39
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "simple_module_hosting"
3
- version = "0.0.42"
3
+ version = "0.0.43"
4
4
  description = "FastAPI + Inertia.js host runtime for simple_module — app_builder, middleware stack, CLI (sm / simple-module), scaffolding"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -22,16 +22,16 @@ classifiers = [
22
22
  ]
23
23
  dependencies = [
24
24
  "click>=8.1,<9",
25
- "fastapi>=0.140,<0.160",
25
+ "fastapi>=0.140,<0.163",
26
26
  "httpx>=0.27,<0.29",
27
27
  # SessionMiddleware (starlette.middleware.sessions) imports itsdangerous at
28
28
  # module import time; starlette treats it as an optional extra, so declare
29
29
  # it directly — out-of-tree hosts have nothing else pulling it in.
30
30
  "itsdangerous>=2.0,<3",
31
31
  "jinja2>=3.1,<4",
32
- "simple_module_core==0.0.42",
33
- "simple_module_db==0.0.42",
34
- "simple_module_inertia==0.0.42",
32
+ "simple_module_core==0.0.43",
33
+ "simple_module_db==0.0.43",
34
+ "simple_module_inertia==0.0.43",
35
35
  "starlette>=0.44,<2",
36
36
  "tomlkit>=0.13,<0.16",
37
37
  "uvicorn[standard]>=0.34,<0.55",
@@ -39,7 +39,7 @@ dependencies = [
39
39
 
40
40
  [project.optional-dependencies]
41
41
  # Shared rate-limiter store (SM_REDIS_URL). Without it the limiter counts per worker.
42
- redis = ["redis>=5,<7"]
42
+ redis = ["redis>=5,<9"]
43
43
  # Error reporting (SM_SENTRY_DSN). Never imported unless the DSN is set.
44
44
  sentry = ["sentry-sdk[fastapi,celery]>=2.20,<3"]
45
45
 
@@ -29,11 +29,8 @@ def build_database_check(db_state):
29
29
  """Return an async check issuing the cheapest possible round trip."""
30
30
 
31
31
  async def check() -> HealthCheckResult:
32
- try:
33
- async with db_state.session_factory() as session:
34
- await session.execute(text("SELECT 1"))
35
- except Exception as exc:
36
- return HealthCheckResult(status=HealthStatus.UNHEALTHY, detail=str(exc))
32
+ async with db_state.session_factory() as session:
33
+ await session.execute(text("SELECT 1"))
37
34
  return HealthCheckResult(status=HealthStatus.HEALTHY, detail="Database reachable")
38
35
 
39
36
  return check
@@ -9,6 +9,7 @@ from fastapi.exceptions import RequestValidationError
9
9
  from fastapi.responses import JSONResponse
10
10
  from simple_module_core.exceptions import NotFoundError
11
11
  from simple_module_core.permission_denied import PermissionDenied
12
+ from simple_module_inertia import errors_from_validation, is_inertia_request
12
13
  from starlette.exceptions import HTTPException
13
14
  from starlette.requests import Request
14
15
  from starlette.responses import Response
@@ -16,10 +17,12 @@ from starlette.responses import Response
16
17
  from simple_module_hosting._error_negotiation import _wants_json
17
18
  from simple_module_hosting._error_page import render_error_page
18
19
  from simple_module_hosting._observability import CorrelationIdMiddleware
20
+ from simple_module_hosting.inertia_utils import redirect_back_with_errors
19
21
 
20
22
  logger = logging.getLogger(__name__)
21
23
 
22
24
  _INERTIA_ERROR_STATUSES = frozenset({401, 403, 404, 413, 419, 422, 429, 500, 503})
25
+ _FORM_METHODS = frozenset({"POST", "PUT", "PATCH", "DELETE"})
23
26
 
24
27
 
25
28
  async def http_exception_handler(request: Request, exc: HTTPException) -> Response:
@@ -51,7 +54,19 @@ async def request_validation_error_handler(
51
54
 
52
55
  Same negotiation rule as 403/404/500 (``_wants_json``), so one request
53
56
  never sees two different error shapes depending on the error class.
57
+
58
+ An Inertia form submission whose *body* is invalid is the exception: like
59
+ a hand-written ``redirect_back_with_errors``, it goes back to the form with
60
+ one message per field, so ``useForm`` shows them in place. Invalid path,
61
+ query or header values keep the error page: no form field can show them,
62
+ and a GET redirected back could loop.
54
63
  """
64
+ if request.method in _FORM_METHODS and is_inertia_request(request.scope):
65
+ body_errors = [error for error in exc.errors() if tuple(error["loc"][:1]) == ("body",)]
66
+ if body_errors:
67
+ # Only body errors: a bad path/query value alongside them is no form field.
68
+ errors = errors_from_validation(body_errors, request_source=True)
69
+ return redirect_back_with_errors(request, errors)
55
70
  if _wants_json(request):
56
71
  return JSONResponse(status_code=422, content={"detail": jsonable_encoder(exc.errors())})
57
72
  return await render_error_page(request, 422, "The requested URL contains invalid parameters.")
@@ -1,9 +1,8 @@
1
1
  """Choose JSON or HTML for framework error responses."""
2
2
 
3
+ from simple_module_inertia import is_inertia_request
3
4
  from starlette.requests import Request
4
5
 
5
- from simple_module_hosting._inertia_shared import _INERTIA_HEADER
6
-
7
6
 
8
7
  def _explicit_accept_q(accept: str, media_type: str) -> float | None:
9
8
  """Quality the Accept header gives ``media_type`` by explicit listing, or
@@ -51,7 +50,7 @@ def _wants_json(request: Request) -> bool:
51
50
  view path keeps its pre-existing default and an ``/api/*`` path keeps
52
51
  getting JSON either way.
53
52
  """
54
- if request.headers.get(_INERTIA_HEADER):
53
+ if is_inertia_request(request.scope):
55
54
  return False
56
55
  accept = request.headers.get("accept", "")
57
56
  html_q = _explicit_accept_q(accept, "text/html")
@@ -17,6 +17,8 @@ from simple_module_inertia import (
17
17
  from starlette.requests import Request
18
18
  from starlette.responses import Response
19
19
 
20
+ from simple_module_hosting._inertia_shared import resolve_inertia_shared
21
+
20
22
  logger = logging.getLogger(__name__)
21
23
 
22
24
  # Statuses whose remedy is "sign in", so the page offers that as its primary
@@ -103,7 +105,13 @@ async def render_error_page(
103
105
  # repeated here. Without it the error page renders raw translation keys
104
106
  # (ui.error_page.not_found_title) and loses auth/menus, so a signed-in
105
107
  # user's 404 has no layout.
106
- shared = getattr(request.state, "inertia_shared", None)
108
+ try:
109
+ shared = await resolve_inertia_shared(request)
110
+ except Exception:
111
+ # Building the layout is what failed (a DB outage in the menus, say):
112
+ # still render the page, just without the shared layout props.
113
+ logger.warning("Error page: layout props unavailable", exc_info=True)
114
+ shared = {}
107
115
  if shared:
108
116
  inertia.share(**shared)
109
117
  # The correlation id is the only handle a user has on their own failed
@@ -2,6 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
+ import asyncio
5
6
  import inspect
6
7
  import logging
7
8
  from collections.abc import Callable
@@ -9,6 +10,7 @@ from typing import Any
9
10
 
10
11
  from simple_module_core.app_state import get_inertia_shared_providers, get_services
11
12
  from simple_module_core.i18n import Translator
13
+ from simple_module_inertia import is_inertia_request
12
14
  from starlette.datastructures import Headers
13
15
  from starlette.requests import Request
14
16
  from starlette.types import Scope
@@ -19,8 +21,7 @@ logger = logging.getLogger(__name__)
19
21
 
20
22
  _I18N_SESSION_LOCALE_KEY = "__i18n_locale"
21
23
  _I18N_SESSION_AUDIENCE_KEY = "__i18n_audience"
22
- _INERTIA_HEADER = "x-inertia"
23
- _INERTIA_HEADER_TRUE = "true"
24
+ I18N_CATALOG_HEADER = "X-SM-I18n"
24
25
  #: Shared-prop key the frontend API client reads its ``X-CSRF-Token`` from (#504).
25
26
  CSRF_SHARED_PROP = "csrfToken"
26
27
 
@@ -35,9 +36,9 @@ def build_i18n_block(scope: Scope, request: Request, *, is_authenticated: bool =
35
36
  Rules:
36
37
 
37
38
  * No registry / no locale → serve an empty English block and log once.
38
- * Inertia XHR partials (``X-Inertia: true``) reuse the client-side
39
- cached messages; send ``messages: None`` unless the locale — or the
40
- audience, see below — differs from what was last served this session.
39
+ * Inertia visits (header presence) report their tab's cached catalog in
40
+ ``X-SM-I18n: <locale>:<audience>``. Send messages only on a mismatch;
41
+ clients without that header retain the legacy session comparison.
41
42
  * Full page loads and locale transitions ship the complete dict.
42
43
  * Anonymous visitors receive the public snapshot: catalogs of modules
43
44
  declaring ``i18n_audience="admin"`` are withheld (issue #248). A login
@@ -58,36 +59,25 @@ def build_i18n_block(scope: Scope, request: Request, *, is_authenticated: bool =
58
59
  )
59
60
  return {"locale": "en", "supportedLocales": ["en"], "messages": {}}
60
61
 
61
- is_inertia = Headers(scope=scope).get(_INERTIA_HEADER) == _INERTIA_HEADER_TRUE
62
+ is_inertia = is_inertia_request(scope)
62
63
  audience = "full" if is_authenticated else "public"
63
- session_dict = scope.get("session")
64
- # When the session is absent (pre-session-middleware routes, WebSocket
65
- # upgrades), treat locale as "unchanged" so Inertia XHR requests still
66
- # skip the messages payload. Non-Inertia requests will always ship them
67
- # regardless of the session state.
68
- if session_dict is not None:
69
- # Remembering the locale only pays off for a client that will come back
70
- # with an Inertia XHR (to skip re-sending the catalog). A bare API or
71
- # health-check call from a cookie-less client will not, and writing
72
- # here would make Starlette's SessionMiddleware emit a two-week
73
- # Set-Cookie on every anonymous response, which keeps shared caches
74
- # from storing it (GH #349). So persist only when a session already
75
- # exists (it has data) or the caller is page-shaped.
76
- persist = bool(session_dict) or is_inertia or _accepts_html(scope)
77
- last_locale = session_dict.get(_I18N_SESSION_LOCALE_KEY)
78
- locale_changed = last_locale != locale
79
- if locale_changed and persist:
80
- session_dict[_I18N_SESSION_LOCALE_KEY] = locale
81
- last_audience = session_dict.get(_I18N_SESSION_AUDIENCE_KEY)
82
- audience_changed = last_audience != audience
83
- if audience_changed and persist:
84
- session_dict[_I18N_SESSION_AUDIENCE_KEY] = audience
64
+ cached_catalog = Headers(scope=scope).get(I18N_CATALOG_HEADER)
65
+ if cached_catalog is not None:
66
+ send_messages = not is_inertia or cached_catalog != f"{locale}:{audience}"
85
67
  else:
86
- locale_changed = False
87
- audience_changed = False
88
- send_messages = (not is_inertia) or locale_changed or audience_changed
68
+ session = scope.get("session")
69
+ changed = session is not None and (
70
+ session.get(_I18N_SESSION_LOCALE_KEY) != locale
71
+ or session.get(_I18N_SESSION_AUDIENCE_KEY) != audience
72
+ )
73
+ # Legacy clients remember only page-shaped requests, never raw fetches.
74
+ if session is not None and (is_inertia or _accepts_html(scope)):
75
+ session[_I18N_SESSION_LOCALE_KEY] = locale
76
+ session[_I18N_SESSION_AUDIENCE_KEY] = audience
77
+ send_messages = not is_inertia or changed
89
78
  return {
90
79
  "locale": locale,
80
+ "audience": audience,
91
81
  "supportedLocales": registry.available_locales(),
92
82
  "messages": (
93
83
  registry.messages_snapshot(locale, include_admin=is_authenticated)
@@ -116,9 +106,8 @@ def lazy_csrf_shared_prop(
116
106
  ) -> dict[str, Callable[[], str]]:
117
107
  """Like :func:`csrf_shared_prop`, but the token is resolved at render time.
118
108
 
119
- The shared props are built for every request; a JSON call or a download
120
- never renders a page, so minting eagerly would write the session (a
121
- ``Set-Cookie``) on responses that have no use for the token. Inertia calls
109
+ The token stays lazy even after layout resolution, so an Inertia partial
110
+ that excludes it does not mint an unused session token. Inertia calls
122
111
  the callable only when it serialises props.
123
112
  """
124
113
  if not is_authenticated or request.scope.get("session") is None:
@@ -191,3 +180,16 @@ def default_home_url(app: Any) -> str:
191
180
  sm = get_services(app)
192
181
  prefix = getattr(sm, "view_prefixes", {}).get("Dashboard")
193
182
  return f"{prefix}/" if prefix else "/"
183
+
184
+
185
+ async def resolve_inertia_shared(request: Request) -> dict:
186
+ """Build layout props once on demand, keeping the resolved state dict public."""
187
+ factory = getattr(request.state, "inertia_shared_factory", None)
188
+ if factory is not None:
189
+ task = getattr(request.state, "inertia_shared_task", None)
190
+ if task is None:
191
+ context = getattr(request.state, "inertia_shared_context", None)
192
+ task = asyncio.create_task(factory(), context=context)
193
+ request.state.inertia_shared_task = task
194
+ request.state.inertia_shared = await task
195
+ return getattr(request.state, "inertia_shared", None) or {}
@@ -8,16 +8,21 @@
8
8
  members whose score has passed, then admits while ``ZCARD < slots``.
9
9
  * ``INCR <key>:fence`` hands out the fencing token, inside the same script.
10
10
 
11
- Unlike the rate limiter there is no per-process fallback: a lease that Redis
12
- could not confirm must not be reported as held, so errors propagate.
11
+ There is no per-process fallback: unavailable Redis cannot confirm a lease.
12
+ Acquire connectivity errors become ConnectionError for the lease handle;
13
+ release connectivity errors are logged and return False. Refresh errors propagate.
13
14
  """
14
15
 
15
16
  from __future__ import annotations
16
17
 
17
18
  import asyncio
19
+ import logging
18
20
  import os
19
21
  from typing import Any
20
22
 
23
+ logger = logging.getLogger(__name__)
24
+ _SOCKET_TIMEOUT = 2.0
25
+
21
26
  # Holder and fence-counter keys live under disjoint prefixes: a name is never
22
27
  # parsed, so ``foo:fence`` cannot collide with the counter of ``foo``.
23
28
  _HOLDER_PREFIX = "sm:lease:h:"
@@ -113,13 +118,33 @@ class RedisLeaseBackend:
113
118
  self._client = self._factory()
114
119
  else:
115
120
  import redis.asyncio as aioredis
116
-
117
- self._client = aioredis.from_url(self._url)
121
+ from redis.asyncio.retry import Retry
122
+ from redis.backoff import NoBackoff
123
+
124
+ self._client = aioredis.from_url(
125
+ self._url,
126
+ socket_timeout=_SOCKET_TIMEOUT,
127
+ socket_connect_timeout=_SOCKET_TIMEOUT,
128
+ # One reconnect, no backoff: a stale pooled connection gets a fresh
129
+ # socket, while the 2 s timeouts keep the worst case bounded.
130
+ retry=Retry(NoBackoff(), 1),
131
+ )
118
132
  self._owner = owner
119
133
  return self._client
120
134
 
121
135
  async def _eval(self, script: str, keys: list[str], *args: Any) -> int:
122
- return int(await self._redis().eval(script, len(keys), *keys, *args))
136
+ from redis.exceptions import ConnectionError as RedisConnectionError
137
+ from redis.exceptions import TimeoutError as RedisTimeoutError
138
+
139
+ try:
140
+ return int(await self._redis().eval(script, len(keys), *keys, *args))
141
+ except (RedisConnectionError, RedisTimeoutError) as exc:
142
+ if script in (_ACQUIRE, _SEM_ACQUIRE):
143
+ raise ConnectionError("Redis lease acquire unavailable") from exc
144
+ if script not in (_RELEASE, _SEM_RELEASE):
145
+ raise
146
+ logger.warning("Redis lease release unavailable (%s)", type(exc).__name__)
147
+ return 0
123
148
 
124
149
  @staticmethod
125
150
  def _lease_keys(name: str) -> list[str]:
@@ -30,67 +30,35 @@ logger = logging.getLogger(__name__)
30
30
 
31
31
 
32
32
  async def _is_first_run(app: FastAPI) -> bool:
33
- """Whether this install has never been set up at all.
34
-
35
- The distinction the boot check turns on. Two very different situations both
36
- leave ``host.migrations`` outstanding:
37
-
38
- - A **fresh deployment**: nothing is configured, so the administrator step
39
- is pending too. Serving the wizard is exactly right — running the
40
- migrations is one of the things it exists to do.
41
- - A **configured install whose schema drifted**: someone deployed code
42
- ahead of the migration job. It has administrators; only the schema is
43
- behind.
44
-
45
- Treating the second as "setup mode" is wrong twice over. It serves traffic
46
- against a schema the code does not match — the failure ``SM010`` exists to
47
- prevent — and it re-opens ``/setup``, whose migration endpoint is
48
- unauthenticated, letting an anonymous request trigger an Alembic run on a
49
- live system.
50
-
51
- So: first run means *something other than the schema* is also outstanding.
52
- ``False`` when no registry exists, since an app built outside
53
- ``create_app`` has no steps to reason about and the old raising behaviour
54
- is the safer default there.
55
-
56
- Deliberately does not delegate to ``registry.incomplete()``: that method
57
- treats a step whose predicate raises as *complete*, which is right for
58
- ``SetupMiddleware``'s steady-state gate (a transient DB error must not
59
- lock a working install out) but wrong here. On a genuinely fresh
60
- database the non-migration steps' own tables don't exist yet — the
61
- administrator check is a query against a table migrations create — so it
62
- raises too, and swallowing that would make every step but the schema
63
- look satisfied, exactly the "is setup complete" trap this function
64
- exists to avoid. A required step raising counts as pending only with
65
- positive evidence the install is new: the database has never been
66
- migrated at all (no ``alembic_version``). On a database with migration
67
- history the same exception is far more likely a transient error on an
68
- established install, and treating that as first run would serve the
69
- unauthenticated migration endpoint on a live system — so boot fails
70
- instead, with the "behind head" error.
33
+ """Whether this install has never been set up, so boot serves ``/setup``.
34
+
35
+ Needs positive evidence on both counts. The database must never have been
36
+ migrated (no ``alembic_version``): a pending step on a database with
37
+ migration history is a configured install whose schema drifted, and serving
38
+ the unauthenticated migration endpoint there would run Alembic on a live
39
+ system. And no other required step may already report complete: a
40
+ never-migrated database that holds accounts (built with ``create_all``) is
41
+ not empty either. A step that raises counts as pending, since on a fresh
42
+ database its tables do not exist yet. An install whose only required step
43
+ is the migrations step (Keycloak) qualifies (#784).
71
44
  """
72
45
  registry = getattr(app.state.sm, "setup_registry", None)
73
- if not registry:
46
+ migration = get_migration_status(app)
47
+ if not registry or migration is None or migration.get("current_revision", "") is not None:
74
48
  return False
75
49
  for step in registry.required_steps:
76
50
  if step.id == STEP_MIGRATIONS:
77
51
  continue
78
52
  try:
79
- done = await step.is_complete(app)
53
+ if await step.is_complete(app):
54
+ return False
80
55
  except Exception:
81
- migration = get_migration_status(app) or {}
82
- never_migrated = migration.get("current_revision") is None
83
- if not never_migrated:
84
- logger.warning(
85
- "Setup step %s failed on a database with migration history; "
86
- "not treating this install as new",
87
- step.id,
88
- exc_info=True,
89
- )
90
- return never_migrated
91
- if not done:
92
- return True
93
- return False
56
+ logger.warning(
57
+ "Setup step %s raised on a never-migrated database; counting it as pending",
58
+ step.id,
59
+ exc_info=True,
60
+ )
61
+ return True
94
62
 
95
63
 
96
64
  def build_lifespan(modules: Sequence) -> Callable:
@@ -105,8 +73,7 @@ def build_lifespan(modules: Sequence) -> Callable:
105
73
  # running the migrations is one of the things that wizard does, and
106
74
  # check_migrations' RuntimeError would make it unreachable. Anywhere
107
75
  # else the original behaviour stands: a schema the code does not match
108
- # fails the boot. See _is_first_run for why those two cases cannot be
109
- # told apart by "is setup complete".
76
+ # fails the boot. See _is_first_run for how the two are told apart.
110
77
  app.state.migration = await migration_status(app.state.sm.db.engine)
111
78
  if not app.state.migration["is_current"] and not await _is_first_run(app):
112
79
  raise RuntimeError(
@@ -8,6 +8,7 @@ from fastapi import FastAPI
8
8
  from simple_module_core.app_state import get_body_limits
9
9
  from simple_module_core.environments import NON_PROD_ENVIRONMENTS
10
10
  from simple_module_db import CommitBeforeResponseMiddleware
11
+ from simple_module_inertia import InertiaMiddleware
11
12
  from starlette.middleware.gzip import GZipMiddleware
12
13
  from uvicorn.middleware.proxy_headers import ProxyHeadersMiddleware
13
14
 
@@ -15,7 +16,6 @@ from simple_module_hosting import sentry
15
16
  from simple_module_hosting._body_limit import BodyLimitMiddleware
16
17
  from simple_module_hosting._cors import CorsMiddleware, host_policy
17
18
  from simple_module_hosting._forwarded_host import ForwardedHostMiddleware
18
- from simple_module_hosting._inertia_cache import InertiaCacheMiddleware
19
19
  from simple_module_hosting._rate_limit import RateLimitMiddleware
20
20
  from simple_module_hosting._route_access import API_PREFIX
21
21
  from simple_module_hosting.i18n_middleware import LocaleMiddleware
@@ -88,43 +88,28 @@ def install_middleware(
88
88
  Order matters: last added = first executed. Execution order:
89
89
  (ForwardedHost, if trusted_proxy and forwarded_host_allowlist) →
90
90
  (ProxyHeaders, if trusted_proxy) → CorrelationId → RequestLogging → CORS
91
- → BodyLimit → GZip → Security → Session → [module] → (Tenant, if
92
- multi_tenant) → Locale → Inertia → InertiaCache → RateLimit → Setup
93
- → Maintenance → CommitBeforeResponse.
91
+ → BodyLimit → GZip → Security → Session → InertiaMiddleware → [module] →
92
+ (Tenant, if multi_tenant) → Locale → InertiaLayoutData →
93
+ RateLimit → Setup → Maintenance → CommitBeforeResponse.
94
94
  """
95
95
  # Added first, so it is innermost and its send-wrapper is the first to see
96
96
  # the response: the request's DB work commits before any byte reaches the
97
97
  # client, instead of in get_db's post-response exit code (GH #257).
98
98
  app.add_middleware(CommitBeforeResponseMiddleware)
99
- # Inside InertiaCache, so its short-circuit is still governed by it. The
100
- # maintenance 503 renders through Inertia and carries this user's auth
101
- # block and menus like any other payload; short-circuiting *outside* the
102
- # cache guard would ship exactly the per-user payload GH #272 exists to
103
- # keep out of caches. Added before Inertia so it *executes* after it: the
104
- # page needs the shared props (auth, menus, i18n) to render with a layout,
105
- # and auth + locale — both further out — to know who is asking and in which
106
- # language to answer.
99
+ # Auth, locale and lazy layout resolution must precede the maintenance page.
100
+ # The outer adapter middleware applies protocol and cache rules to it: the
101
+ # 503 renders through Inertia with this user's auth block and menus, so it
102
+ # must stay non-cacheable like any other payload (GH #272).
107
103
  app.add_middleware(MaintenanceMiddleware)
108
- # Added after Maintenance so it *executes* before it: an install that has
109
- # never been set up has nothing meaningful to put into maintenance mode,
110
- # and the setup redirect should win. Inside InertiaCache for the same
111
- # reason Maintenance is — this short-circuits, and the redirect must not
112
- # be stored by any cache.
104
+ # An install awaiting setup takes precedence over maintenance mode.
113
105
  app.add_middleware(SetupMiddleware)
114
- # Added before InertiaCache so it executes just after it: auth has run (it
115
- # can tell anonymous from signed-in), locale/shared props are in place for
116
- # the error page, and a 429 is still marked non-cacheable.
106
+ # Auth and locale are available when rendering a rate-limit error page.
117
107
  app.add_middleware(
118
108
  RateLimitMiddleware,
119
109
  public_rate=settings.rate_limit_public,
120
110
  authenticated_rate=settings.rate_limit_authenticated,
121
111
  store=rate_limit_store,
122
112
  )
123
- # Paired with InertiaLayoutDataMiddleware below, which is what puts this
124
- # user's auth, permissions and menus into every Inertia payload: this one
125
- # makes sure the payload that results is never stored where a page request
126
- # can be answered with it.
127
- app.add_middleware(InertiaCacheMiddleware)
128
113
  app.add_middleware(
129
114
  InertiaLayoutDataMiddleware,
130
115
  menu_registry=menu_registry,
@@ -144,6 +129,11 @@ def install_middleware(
144
129
  app.add_middleware(TenantMiddleware, fixed=settings.default_tenant)
145
130
  for mod in modules:
146
131
  mod.register_middleware(app)
132
+ # Outside every module middleware and the cache guard, so it normalises
133
+ # the final response — including redirects a module middleware issues
134
+ # itself (an expired session's login redirect after a DELETE must still
135
+ # become a 303) — while Session, further out, still sees its result.
136
+ app.add_middleware(InertiaMiddleware)
147
137
  app.add_middleware(
148
138
  SessionMiddleware,
149
139
  secret_key=settings.secret_key,
@@ -10,6 +10,7 @@ from starlette.datastructures import Headers, MutableHeaders
10
10
  from starlette.types import ASGIApp, Message, Receive, Scope, Send
11
11
 
12
12
  from simple_module_hosting.logging import correlation_id
13
+ from simple_module_hosting.path_matching import matches_path
13
14
 
14
15
  _LOGGER_NAME = "simple_module.request"
15
16
  _request_logger = logging.getLogger(_LOGGER_NAME)
@@ -20,7 +21,8 @@ _EVENT_REQUEST_STARTED = "request.started"
20
21
  _EVENT_REQUEST_COMPLETED = "request.completed"
21
22
 
22
23
  # Paths that produce noisy, low-value log entries
23
- _QUIET_PREFIXES = ("/health", "/static/")
24
+ _QUIET_EXACT = ("/health",)
25
+ _QUIET_PREFIXES = ("/health/", "/static/")
24
26
 
25
27
 
26
28
  class CorrelationIdMiddleware:
@@ -77,7 +79,7 @@ class RequestLoggingMiddleware:
77
79
  return
78
80
 
79
81
  path = scope["path"]
80
- if any(path.startswith(p) for p in _QUIET_PREFIXES):
82
+ if matches_path(path, exact=_QUIET_EXACT, prefixes=_QUIET_PREFIXES):
81
83
  await self.app(scope, receive, send)
82
84
  return
83
85
 
@@ -228,7 +228,8 @@ def merge_host_settings(
228
228
  # relative sqlite paths against the discovered project root, and
229
229
  # reconstructing Settings from env alone would redo that resolution
230
230
  # against whatever the cwd happens to be.
231
- fixed = {"secret_key": secret_key, "database_url": bootstrap.database_url}
231
+ fixed = bootstrap.model_dump(include=bootstrap.model_fields_set)
232
+ fixed.update(secret_key=secret_key, database_url=bootstrap.database_url)
232
233
  # Lenient, like the lifespan hydration: a stored value that parses but no
233
234
  # longer validates (a Literal narrowed in an upgrade) falls back to its
234
235
  # default with a WARNING instead of taking down every worker — and with
@@ -39,6 +39,7 @@ from starlette.types import ASGIApp, Receive, Scope, Send
39
39
 
40
40
  from simple_module_hosting._rate_limit_keys import KEY_IP, KEY_USER_OR_IP, rule_bucket, rule_key
41
41
  from simple_module_hosting._request_guard_responses import send_guard_response
42
+ from simple_module_hosting.path_matching import matches_path
42
43
  from simple_module_hosting.public_access import is_public
43
44
 
44
45
  __all__ = ["RateLimitMiddleware"]
@@ -46,7 +47,8 @@ __all__ = ["RateLimitMiddleware"]
46
47
  logger = logging.getLogger("simple_module.request_guard")
47
48
 
48
49
  _MESSAGE = "Too many requests. Please slow down and try again shortly."
49
- _OPERATIONAL_PREFIXES = ("/health", "/static/")
50
+ _OPERATIONAL_EXACT = ("/health",)
51
+ _OPERATIONAL_PREFIXES = ("/health/", "/static/")
50
52
 
51
53
 
52
54
  class RateLimitMiddleware:
@@ -76,7 +78,9 @@ class RateLimitMiddleware:
76
78
  flag = is_public(scope["app"], scope["method"], scope["path"])
77
79
  if not flag:
78
80
  return None
79
- if rule is None and scope["path"].startswith(_OPERATIONAL_PREFIXES):
81
+ if rule is None and matches_path(
82
+ scope["path"], exact=_OPERATIONAL_EXACT, prefixes=_OPERATIONAL_PREFIXES
83
+ ):
80
84
  return None # health probes and static assets are not an API surface
81
85
  if rule is not None and rule.rate is not None:
82
86
  spec = rule.rate_spec