simple-module-hosting 0.0.46__tar.gz → 0.0.48__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.
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/.gitignore +6 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/PKG-INFO +4 -4
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/pyproject.toml +4 -4
- simple_module_hosting-0.0.48/simple_module_hosting/__init__.py +64 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_app_boot.py +21 -7
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_body_limit.py +4 -1
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_boot_checks.py +5 -10
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_cors.py +10 -28
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_deferred_startup.py +2 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_dev_boot.py +27 -3
- simple_module_hosting-0.0.48/simple_module_hosting/_fallback_routes.py +65 -0
- simple_module_hosting-0.0.48/simple_module_hosting/_generated_files.py +23 -0
- simple_module_hosting-0.0.48/simple_module_hosting/_host_services.py +26 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_host_settings_support.py +1 -1
- simple_module_hosting-0.0.48/simple_module_hosting/_i18n_modules.py +62 -0
- simple_module_hosting-0.0.48/simple_module_hosting/_i18n_target.py +60 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_inertia_setup.py +3 -1
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_inertia_shared.py +14 -8
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_lifespan.py +25 -54
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_middleware_pipeline.py +16 -26
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_module_routes.py +19 -1
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_phase_helpers.py +1 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_preapp_config.py +63 -29
- simple_module_hosting-0.0.48/simple_module_hosting/_project_root.py +12 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_rate_limit.py +10 -4
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_registrations.py +3 -28
- simple_module_hosting-0.0.48/simple_module_hosting/_request_policy.py +51 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_secret_key.py +33 -92
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_security_headers.py +4 -4
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_settings_registration.py +2 -2
- simple_module_hosting-0.0.48/simple_module_hosting/_stored_identity.py +98 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_table_coverage.py +4 -2
- simple_module_hosting-0.0.48/simple_module_hosting/admin_surfaces.py +30 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/app_builder.py +57 -13
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/assets.py +5 -3
- simple_module_hosting-0.0.48/simple_module_hosting/auth_policy.py +31 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/csrf.py +4 -5
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/data_compatibility.py +3 -1
- simple_module_hosting-0.0.48/simple_module_hosting/frontend_extensions.py +54 -0
- simple_module_hosting-0.0.48/simple_module_hosting/host.py +101 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/host_cli.py +69 -13
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/host_settings.py +28 -11
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/i18n_manifest.py +53 -33
- simple_module_hosting-0.0.48/simple_module_hosting/installation.py +29 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/locales/de.json +4 -1
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/locales/en.json +4 -1
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/locales/es.json +4 -1
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/manifest.py +18 -22
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/middleware.py +0 -3
- simple_module_hosting-0.0.48/simple_module_hosting/middleware_config.py +156 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/migrations.py +69 -68
- simple_module_hosting-0.0.48/simple_module_hosting/migrations_env.py +118 -0
- simple_module_hosting-0.0.48/simple_module_hosting/module_tsconfig.py +144 -0
- simple_module_hosting-0.0.48/simple_module_hosting/permissions.py +202 -0
- simple_module_hosting-0.0.48/simple_module_hosting/public_access.py +12 -0
- simple_module_hosting-0.0.48/simple_module_hosting/public_urls.py +10 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/resource_deps.py +15 -6
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/session.py +29 -2
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/settings.py +15 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/setup_gate.py +43 -3
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/setup_wizard/components/StepForm.tsx +8 -2
- simple_module_hosting-0.0.48/simple_module_hosting/setup_wizard/composition.py +47 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/setup_wizard/migrate.py +45 -16
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/setup_wizard/pages/Wizard.tsx +14 -4
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/setup_wizard/payloads.py +18 -2
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/setup_wizard/routes.py +13 -1
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/shared_props.py +16 -1
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/token_guard.py +4 -4
- simple_module_hosting-0.0.48/tests/conftest.py +34 -0
- simple_module_hosting-0.0.48/tests/test_admin_surface.py +92 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_app.py +12 -5
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_boot_config_hardening.py +9 -11
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_boot_drift_check.py +34 -3
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_build_time_settings_marked.py +15 -1
- simple_module_hosting-0.0.48/tests/test_check_migrations.py +173 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_check_migrations_expression_note.py +18 -2
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_csp_module_sources.py +20 -0
- simple_module_hosting-0.0.48/tests/test_customize_registries.py +198 -0
- simple_module_hosting-0.0.48/tests/test_database_injection.py +95 -0
- simple_module_hosting-0.0.48/tests/test_dev_boot_exit.py +44 -0
- simple_module_hosting-0.0.48/tests/test_dev_boot_output.py +196 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_diagnostics_state.py +12 -3
- simple_module_hosting-0.0.48/tests/test_fallback_finalization.py +233 -0
- simple_module_hosting-0.0.48/tests/test_fallback_routes.py +254 -0
- simple_module_hosting-0.0.48/tests/test_file_access_registration.py +45 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_forwarded_host.py +1 -1
- simple_module_hosting-0.0.48/tests/test_frontend_extensions.py +155 -0
- simple_module_hosting-0.0.48/tests/test_generated_file_writes.py +54 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_host_cli.py +38 -0
- simple_module_hosting-0.0.48/tests/test_host_factory.py +261 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_cors_api.py +4 -1
- simple_module_hosting-0.0.48/tests/test_hosting_csrf_partial.py +112 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_data_compatibility.py +7 -8
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_error_handling_policy.py +2 -2
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_migration_target.py +63 -10
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_public_access.py +6 -25
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_sentry.py +8 -2
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_server_timing.py +3 -1
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_i18n_manifest_published_target.py +15 -17
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_inertia_i18n_shared_props.py +36 -6
- simple_module_hosting-0.0.48/tests/test_installation_id.py +59 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_invalidation_wiring.py +2 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_lifespan_deferred_startup.py +2 -2
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_lifespan_order.py +1 -1
- simple_module_hosting-0.0.48/tests/test_live_request_guards.py +185 -0
- simple_module_hosting-0.0.48/tests/test_login_redirect_setting.py +43 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_maintenance_mode.py +9 -27
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_middleware_order.py +59 -5
- simple_module_hosting-0.0.48/tests/test_middleware_overrides.py +168 -0
- simple_module_hosting-0.0.48/tests/test_middleware_session_replacement.py +144 -0
- simple_module_hosting-0.0.48/tests/test_middleware_stages.py +77 -0
- simple_module_hosting-0.0.48/tests/test_migrations_env.py +97 -0
- simple_module_hosting-0.0.48/tests/test_module_tsconfig.py +240 -0
- simple_module_hosting-0.0.48/tests/test_module_tsconfig_coverage.py +87 -0
- simple_module_hosting-0.0.48/tests/test_permission_any_of.py +38 -0
- simple_module_hosting-0.0.48/tests/test_portable_i18n_typecheck.py +78 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_preapp_read_failures.py +19 -0
- simple_module_hosting-0.0.48/tests/test_principal_builder.py +211 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_rate_limit_store_shared.py +1 -1
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_request_guard_auth_parity.py +2 -2
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_secret_key_bootstrap.py +22 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_session_cookie_security.py +1 -1
- simple_module_hosting-0.0.48/tests/test_session_root.py +79 -0
- simple_module_hosting-0.0.48/tests/test_settings_secrets.py +49 -0
- simple_module_hosting-0.0.48/tests/test_setup_composition.py +177 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_setup_migrate_error_redaction.py +36 -0
- simple_module_hosting-0.0.48/tests/test_setup_migrate_worker_lock.py +86 -0
- simple_module_hosting-0.0.48/tests/test_setup_secret_key.py +77 -0
- simple_module_hosting-0.0.48/tests/test_shared_host_policy.py +76 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_strict_discovery_wiring.py +1 -1
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests-js/hosting_SetupWizard.test.tsx +69 -0
- simple_module_hosting-0.0.46/simple_module_hosting/__init__.py +0 -22
- simple_module_hosting-0.0.46/simple_module_hosting/_host_services.py +0 -21
- simple_module_hosting-0.0.46/simple_module_hosting/_i18n_target.py +0 -40
- simple_module_hosting-0.0.46/simple_module_hosting/_project_root.py +0 -39
- simple_module_hosting-0.0.46/simple_module_hosting/permissions.py +0 -282
- simple_module_hosting-0.0.46/simple_module_hosting/public_access.py +0 -33
- simple_module_hosting-0.0.46/tests/conftest.py +0 -15
- simple_module_hosting-0.0.46/tests/test_check_migrations.py +0 -96
- simple_module_hosting-0.0.46/tests/test_settings_secrets.py +0 -25
- simple_module_hosting-0.0.46/tests/test_setup_migrate_worker_lock.py +0 -74
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/LICENSE +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/README.md +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/__main__.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_anonymous.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_api_version.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_csp_dynamic.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_db_health.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_error_handlers.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_error_negotiation.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_error_page.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_favicon.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_forwarded_host.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_hydrate_step.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_i18n_build.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_i18n_json.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_insecure_transport.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_lease_redis.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_observability.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_openapi.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_process_services.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_rate_limit_keys.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_rate_limit_store.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_request_guard_responses.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_route_access.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_route_guard.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_route_paths.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_server_timing.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_spa_mount.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_tenant.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/admin_overview/__init__.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/admin_overview/pages/Overview.tsx +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/admin_overview/routes.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/bootstrap_settings.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/db_options.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/errors.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/health.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/i18n_deps.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/i18n_middleware.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/i18n_routes.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/inertia_deps.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/inertia_utils.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/leases.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/log_sinks.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/logging.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/maintenance.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/page_globs.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/pagination.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/path_matching.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/py.typed +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/rate_limit_deps.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/redirects.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/sentry.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/sentry_scrub.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/sentry_scrub_text.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/setup_wizard/__init__.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/setup_wizard/_migration_lock.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/setup_wizard/components/ConnectionList.tsx +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/static_files.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/tenancy.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/ui_locales/de.json +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/ui_locales/en.json +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/ui_locales/es.json +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/_hosting_settings_db.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/_resacc_models.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/_sentry_transport.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_api_error_negotiation.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_auth_provider_setting.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_branding_head.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_db_health_check.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_design_packs_wiring.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_error_page_shared_props.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_error_status_coverage.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_favicon_default.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_grant_sources.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_health.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_home_url_default.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_host_settings_fields.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_api_version_cache.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_asset_version.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_catalog_json_cache.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_config_sources.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_cors_unset.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_csp_nonce.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_csp_providers.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_csrf.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_csrf_shared_prop.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_error_json_and_session_cookie.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_framework_pages_reserved.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_health_bounded.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_inertia_body_validation.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_inertia_cache.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_inertia_validation_errors.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_lazy_layout_catalogs.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_lease_backends.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_lease_selection.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_lease_timeouts.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_lifespan_cleanup.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_log_sinks.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_openapi.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_openapi_security.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_pagination_deps.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_permissions.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_platform_permissions.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_public_error_page.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_public_path_boundaries.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_security_static_headers.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_sentry_scrub.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_sentry_scrub_gaps.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_spa_mount_nonce.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_table_coverage.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_hosting_ui_assets.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_i18n_build_overrides.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_i18n_manifest.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_i18n_routes.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_i18n_types_cover_installed_modules.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_i18n_ui_namespace.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_inertia_protocol_middleware.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_inertia_shared_providers.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_insecure_transport_warning.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_locale_middleware.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_logging.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_manifest.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_menu_providers_wiring.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_menu_urls_are_canonical.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_merge_host_settings_strict.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_migration_listing.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_migration_multihead.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_migration_script_cache.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_native_link_prefixes_strip.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_preapp_config.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_preapp_invalid_values.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_precompressed_static.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_principal_permissions_claim.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_proxy_headers.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_rate_limit_rules_redis.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_rate_limit_rules_registry.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_redirects.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_request_guard_body_limit.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_request_guard_body_limit_middleware_read.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_request_guard_body_limit_started.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_request_guard_rate_limit.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_resource_deps.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_resource_policy_owned.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_resource_policy_parity.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_resource_types_wiring.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_response_compression.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_route_guard.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_route_guard_fastapi_contract.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_route_paths.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_server_rendered_head.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_session_cookie_secure.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_session_cookie_window.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_session_vary_dedupe.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_settings_i18n.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_setup_gate.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_setup_gate_single_flight.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_setup_public_routes.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_setup_registry.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_setup_routes.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_spa_mounts_541.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_sqlite_path_anchor.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_static_caching.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_tenancy_api.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_tenant_middleware.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_tenant_resolver_diagnostic.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_tenant_resolver_types.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_tenant_scope_helpers.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_tenant_source.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_token_guard_effective_route.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_token_route_guard.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_translator_dep.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests/test_view_prefixes.py +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tests-js/hosting_AdminOverview.test.tsx +0 -0
- {simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/tsconfig.json +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: simple_module_hosting
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.48
|
|
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
|
|
@@ -26,9 +26,9 @@ 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.
|
|
30
|
-
Requires-Dist: simple-module-db==0.0.
|
|
31
|
-
Requires-Dist: simple-module-inertia==0.0.
|
|
29
|
+
Requires-Dist: simple-module-core==0.0.48
|
|
30
|
+
Requires-Dist: simple-module-db==0.0.48
|
|
31
|
+
Requires-Dist: simple-module-inertia==0.0.48
|
|
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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "simple_module_hosting"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.48"
|
|
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"
|
|
@@ -29,9 +29,9 @@ dependencies = [
|
|
|
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.
|
|
33
|
-
"simple_module_db==0.0.
|
|
34
|
-
"simple_module_inertia==0.0.
|
|
32
|
+
"simple_module_core==0.0.48",
|
|
33
|
+
"simple_module_db==0.0.48",
|
|
34
|
+
"simple_module_inertia==0.0.48",
|
|
35
35
|
"starlette>=0.44,<2",
|
|
36
36
|
"tomlkit>=0.13,<0.16",
|
|
37
37
|
"uvicorn[standard]>=0.34,<0.55",
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"""SimpleModule Hosting - App builder, module loader, middleware pipeline."""
|
|
2
|
+
|
|
3
|
+
from importlib import import_module
|
|
4
|
+
from typing import TYPE_CHECKING
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from simple_module_hosting._preapp_config import merge_host_settings as merge_host_settings
|
|
8
|
+
from simple_module_hosting.app_builder import create_app as create_app
|
|
9
|
+
from simple_module_hosting.errors import render_error_page as render_error_page
|
|
10
|
+
from simple_module_hosting.logging import correlation_id as correlation_id
|
|
11
|
+
from simple_module_hosting.logging import setup_logging as setup_logging
|
|
12
|
+
from simple_module_hosting.middleware_config import MiddlewareStage as MiddlewareStage
|
|
13
|
+
from simple_module_hosting.middleware_config import add_middleware as add_middleware
|
|
14
|
+
from simple_module_hosting.middleware_config import disable_middleware as disable_middleware
|
|
15
|
+
from simple_module_hosting.middleware_config import replace_middleware as replace_middleware
|
|
16
|
+
from simple_module_hosting.settings import Settings as Settings
|
|
17
|
+
from simple_module_hosting.shared_props import SharedPropsProvider as SharedPropsProvider
|
|
18
|
+
from simple_module_hosting.shared_props import (
|
|
19
|
+
register_inertia_shared_provider as register_inertia_shared_provider,
|
|
20
|
+
)
|
|
21
|
+
from simple_module_hosting.shared_props import (
|
|
22
|
+
replace_inertia_shared_prop as replace_inertia_shared_prop,
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
__all__ = [
|
|
26
|
+
"MiddlewareStage",
|
|
27
|
+
"Settings",
|
|
28
|
+
"SharedPropsProvider",
|
|
29
|
+
"add_middleware",
|
|
30
|
+
"correlation_id",
|
|
31
|
+
"create_app",
|
|
32
|
+
"disable_middleware",
|
|
33
|
+
"merge_host_settings",
|
|
34
|
+
"register_inertia_shared_provider",
|
|
35
|
+
"render_error_page",
|
|
36
|
+
"replace_inertia_shared_prop",
|
|
37
|
+
"replace_middleware",
|
|
38
|
+
"setup_logging",
|
|
39
|
+
]
|
|
40
|
+
|
|
41
|
+
_EXPORT_MODULES = {
|
|
42
|
+
"MiddlewareStage": "middleware_config",
|
|
43
|
+
"add_middleware": "middleware_config",
|
|
44
|
+
"disable_middleware": "middleware_config",
|
|
45
|
+
"replace_middleware": "middleware_config",
|
|
46
|
+
"Settings": "settings",
|
|
47
|
+
"SharedPropsProvider": "shared_props",
|
|
48
|
+
"correlation_id": "logging",
|
|
49
|
+
"create_app": "app_builder",
|
|
50
|
+
"merge_host_settings": "_preapp_config",
|
|
51
|
+
"register_inertia_shared_provider": "shared_props",
|
|
52
|
+
"replace_inertia_shared_prop": "shared_props",
|
|
53
|
+
"render_error_page": "errors",
|
|
54
|
+
"setup_logging": "logging",
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
def __getattr__(name: str):
|
|
59
|
+
# The host factory must load dotenv before importing settings or app_builder.
|
|
60
|
+
if name not in _EXPORT_MODULES:
|
|
61
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
62
|
+
value = getattr(import_module(f"{__name__}.{_EXPORT_MODULES[name]}"), name)
|
|
63
|
+
globals()[name] = value
|
|
64
|
+
return value
|
{simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_app_boot.py
RENAMED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
import logging
|
|
6
|
+
from collections.abc import Callable
|
|
6
7
|
from pathlib import Path
|
|
7
8
|
|
|
8
9
|
from fastapi import Depends, FastAPI
|
|
@@ -14,7 +15,7 @@ from simple_module_core.permissions import PermissionRegistry
|
|
|
14
15
|
from simple_module_core.public_routes import PublicRouteRegistry
|
|
15
16
|
from simple_module_db.listeners import register_listeners
|
|
16
17
|
from simple_module_db.query_stats import install_query_stats
|
|
17
|
-
from simple_module_db.session import init_db
|
|
18
|
+
from simple_module_db.session import DatabaseState, init_db
|
|
18
19
|
|
|
19
20
|
from simple_module_hosting._db_health import register_database_check
|
|
20
21
|
from simple_module_hosting._openapi import (
|
|
@@ -56,6 +57,8 @@ def build_fastapi_app(settings: Settings, lifespan) -> FastAPI:
|
|
|
56
57
|
)
|
|
57
58
|
|
|
58
59
|
install_openapi_filter(app) # AuthMiddleware reads openapi_url: anonymous iff served
|
|
60
|
+
# Module settings register before the complete Services container exists.
|
|
61
|
+
app.state.boot_settings = settings
|
|
59
62
|
app.state.openapi_url = API_OPENAPI_URL if serve_openapi else None
|
|
60
63
|
return app
|
|
61
64
|
|
|
@@ -80,12 +83,21 @@ def log_registration_summary(
|
|
|
80
83
|
)
|
|
81
84
|
|
|
82
85
|
|
|
83
|
-
def init_database(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
86
|
+
def init_database(
|
|
87
|
+
settings: Settings,
|
|
88
|
+
health_registry: HealthRegistry,
|
|
89
|
+
database: DatabaseState | Callable[[Settings], DatabaseState] | None = None,
|
|
90
|
+
) -> DatabaseState:
|
|
91
|
+
if database is None:
|
|
92
|
+
db_state = init_db(
|
|
93
|
+
settings.database_url,
|
|
94
|
+
echo=settings.debug,
|
|
95
|
+
**database_options(settings),
|
|
96
|
+
)
|
|
97
|
+
elif isinstance(database, DatabaseState):
|
|
98
|
+
db_state = database
|
|
99
|
+
else:
|
|
100
|
+
db_state = database(settings)
|
|
89
101
|
# Multi-tenant installs fail closed: a tenant-scoped query with no tenant
|
|
90
102
|
# context raises instead of reading every tenant's rows.
|
|
91
103
|
db_state.tenant_strict = settings.multi_tenant
|
|
@@ -106,6 +118,8 @@ def init_database(settings: Settings, health_registry: HealthRegistry):
|
|
|
106
118
|
|
|
107
119
|
def mount_host_static(app: FastAPI, project_root: Path) -> None:
|
|
108
120
|
static_dir = project_root / "host" / _STATIC_DIR_NAME
|
|
121
|
+
if not static_dir.is_dir():
|
|
122
|
+
static_dir = project_root / _STATIC_DIR_NAME
|
|
109
123
|
if static_dir.is_dir():
|
|
110
124
|
static = PrecompressedStaticFiles(directory=static_dir)
|
|
111
125
|
app.mount(_STATIC_MOUNT_PATH, static, name=_STATIC_DIR_NAME)
|
{simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_body_limit.py
RENAMED
|
@@ -24,6 +24,7 @@ from starlette.types import ASGIApp, Message, Receive, Scope, Send
|
|
|
24
24
|
|
|
25
25
|
from simple_module_hosting._error_negotiation import _wants_json
|
|
26
26
|
from simple_module_hosting._request_guard_responses import send_guard_response
|
|
27
|
+
from simple_module_hosting._request_policy import request_policy
|
|
27
28
|
|
|
28
29
|
logger = logging.getLogger("simple_module.request_guard")
|
|
29
30
|
|
|
@@ -50,7 +51,9 @@ class BodyLimitMiddleware:
|
|
|
50
51
|
override = None
|
|
51
52
|
if self.registry is not None:
|
|
52
53
|
override = self.registry.limit_for(scope["method"], scope["path"], scope.get("app"))
|
|
53
|
-
|
|
54
|
+
policy = request_policy(scope)
|
|
55
|
+
default = self.max_bytes if policy is None else policy.max_bytes
|
|
56
|
+
return default if override is None else override
|
|
54
57
|
|
|
55
58
|
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
|
|
56
59
|
if scope["type"] != "http":
|
{simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_boot_checks.py
RENAMED
|
@@ -14,7 +14,7 @@ import logging
|
|
|
14
14
|
from typing import TYPE_CHECKING, Any
|
|
15
15
|
|
|
16
16
|
from simple_module_core.app_state import get_tenant_resolver
|
|
17
|
-
from simple_module_core.diagnostics import Diagnostic, check_tenant_resolver
|
|
17
|
+
from simple_module_core.diagnostics import Diagnostic, check_tenant_resolver
|
|
18
18
|
|
|
19
19
|
from simple_module_hosting._route_access import check_unguarded_api_routes
|
|
20
20
|
|
|
@@ -37,12 +37,9 @@ def report_tenant_resolution(
|
|
|
37
37
|
) -> list[Diagnostic]:
|
|
38
38
|
"""SM025: report, and fold into the Doctor screen's results when it has a runner."""
|
|
39
39
|
found = _tenant_checks(app, settings)
|
|
40
|
-
if found:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
else:
|
|
44
|
-
for diag in found:
|
|
45
|
-
logger.warning("%s", diag)
|
|
40
|
+
if found and not settings.is_development:
|
|
41
|
+
for diag in found:
|
|
42
|
+
logger.warning("%s", diag)
|
|
46
43
|
runner = diagnostics_state.runner
|
|
47
44
|
if runner is not None:
|
|
48
45
|
diagnostics_state.runner = lambda: [*runner(), *_tenant_checks(app, settings)]
|
|
@@ -51,10 +48,8 @@ def report_tenant_resolution(
|
|
|
51
48
|
|
|
52
49
|
|
|
53
50
|
def report_unguarded_routes(app: FastAPI, diagnostics_state: DiagnosticsState) -> list[Diagnostic]:
|
|
54
|
-
"""SM031 (dev boot only
|
|
51
|
+
"""SM031 (dev boot only): retain for serving-process output and Doctor."""
|
|
55
52
|
found = check_unguarded_api_routes(app)
|
|
56
|
-
if found:
|
|
57
|
-
print_diagnostics(found)
|
|
58
53
|
runner = diagnostics_state.runner
|
|
59
54
|
if runner is not None:
|
|
60
55
|
diagnostics_state.runner = lambda: [*runner(), *check_unguarded_api_routes(app)]
|
{simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_cors.py
RENAMED
|
@@ -16,32 +16,8 @@ from simple_module_core.cors import CorsPolicy, CorsPolicyRegistry
|
|
|
16
16
|
from starlette.middleware.cors import CORSMiddleware
|
|
17
17
|
from starlette.types import ASGIApp, Receive, Scope, Send
|
|
18
18
|
|
|
19
|
-
from simple_module_hosting.
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
def host_policy(settings: HostSettings) -> CorsPolicy | None:
|
|
23
|
-
"""The ``/api/`` policy from ``cors_*`` settings; ``None`` when no origin is set."""
|
|
24
|
-
# Every field is read even when unset: they are restart-required, and the
|
|
25
|
-
# build-time-settings guard learns that from the reads.
|
|
26
|
-
fields = (
|
|
27
|
-
settings.cors_allow_origins,
|
|
28
|
-
settings.cors_allow_credentials,
|
|
29
|
-
settings.cors_allow_methods,
|
|
30
|
-
settings.cors_allow_headers,
|
|
31
|
-
settings.cors_expose_headers,
|
|
32
|
-
settings.cors_max_age,
|
|
33
|
-
)
|
|
34
|
-
origins, credentials, methods, headers, expose, max_age = fields
|
|
35
|
-
if not origins:
|
|
36
|
-
return None
|
|
37
|
-
return CorsPolicy(
|
|
38
|
-
origins=tuple(origins),
|
|
39
|
-
allow_credentials=credentials,
|
|
40
|
-
methods=tuple(methods),
|
|
41
|
-
headers=tuple(headers),
|
|
42
|
-
expose_headers=tuple(expose),
|
|
43
|
-
max_age=max_age,
|
|
44
|
-
)
|
|
19
|
+
from simple_module_hosting._request_policy import host_policy, request_policy # noqa: F401
|
|
20
|
+
from simple_module_hosting._route_access import API_PREFIX
|
|
45
21
|
|
|
46
22
|
|
|
47
23
|
class CorsMiddleware:
|
|
@@ -62,14 +38,20 @@ class CorsMiddleware:
|
|
|
62
38
|
expose_headers=list(policy.expose_headers),
|
|
63
39
|
max_age=policy.max_age,
|
|
64
40
|
)
|
|
41
|
+
if len(self._handlers) >= 32:
|
|
42
|
+
self._handlers.clear()
|
|
65
43
|
self._handlers[policy] = handler
|
|
66
44
|
return handler
|
|
67
45
|
|
|
68
46
|
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
|
|
69
|
-
if scope["type"] != "http"
|
|
47
|
+
if scope["type"] != "http":
|
|
70
48
|
await self.app(scope, receive, send)
|
|
71
49
|
return
|
|
72
|
-
|
|
50
|
+
snapshot = request_policy(scope)
|
|
51
|
+
host = snapshot.cors if snapshot is not None else None
|
|
52
|
+
policy = self.registry.match(
|
|
53
|
+
scope["method"], scope["path"], fallback=(API_PREFIX, host) if host else None
|
|
54
|
+
)
|
|
73
55
|
if policy is None:
|
|
74
56
|
await self.app(scope, receive, send)
|
|
75
57
|
return
|
|
@@ -11,6 +11,7 @@ from simple_module_core.module_settings import get_module_settings_registry
|
|
|
11
11
|
from simple_module_db.stored_settings import SessionOverrideSource, settings_table_exists
|
|
12
12
|
|
|
13
13
|
from simple_module_hosting._hydrate_step import hydrate_all
|
|
14
|
+
from simple_module_hosting._secret_key import persist_pending_secret_key
|
|
14
15
|
from simple_module_hosting._table_coverage import add_table_coverage
|
|
15
16
|
from simple_module_hosting.data_compatibility import check_data_compatibility
|
|
16
17
|
|
|
@@ -50,6 +51,7 @@ async def run_deferred_startup(app: FastAPI) -> None:
|
|
|
50
51
|
committed. Compatibility checks run first and still raise: an incompatible
|
|
51
52
|
security state must keep the setup gate closed.
|
|
52
53
|
"""
|
|
54
|
+
await persist_pending_secret_key(app)
|
|
53
55
|
pending_checks = getattr(app.state, "deferred_data_compatibility", None)
|
|
54
56
|
if pending_checks:
|
|
55
57
|
await check_data_compatibility(app, pending_checks)
|
{simple_module_hosting-0.0.46 → simple_module_hosting-0.0.48}/simple_module_hosting/_dev_boot.py
RENAMED
|
@@ -10,11 +10,20 @@ path.
|
|
|
10
10
|
|
|
11
11
|
from __future__ import annotations
|
|
12
12
|
|
|
13
|
+
import asyncio
|
|
13
14
|
import logging
|
|
15
|
+
import threading
|
|
16
|
+
from contextlib import suppress
|
|
14
17
|
from pathlib import Path
|
|
15
18
|
from typing import TYPE_CHECKING
|
|
16
19
|
|
|
17
|
-
from simple_module_core.diagnostics import
|
|
20
|
+
from simple_module_core.diagnostics import (
|
|
21
|
+
Diagnostic,
|
|
22
|
+
DiagnosticLevel,
|
|
23
|
+
print_diagnostics,
|
|
24
|
+
run_diagnostics,
|
|
25
|
+
)
|
|
26
|
+
from simple_module_core.diagnostics._expression_index import sqlite_file_index_names
|
|
18
27
|
|
|
19
28
|
from simple_module_hosting.i18n_manifest import emit_frontend_types_for_modules
|
|
20
29
|
|
|
@@ -25,10 +34,23 @@ if TYPE_CHECKING:
|
|
|
25
34
|
from simple_module_hosting.settings import Settings
|
|
26
35
|
|
|
27
36
|
logger = logging.getLogger(__name__)
|
|
37
|
+
_OUTPUT_TIMEOUT = 2.0
|
|
28
38
|
|
|
29
39
|
__all__ = ["run_dev_boot"]
|
|
30
40
|
|
|
31
41
|
|
|
42
|
+
async def print_boot_diagnostics(diagnostics: list[Diagnostic]) -> None:
|
|
43
|
+
"""Bound the lifespan wait; boot reports isolate any blocked file-stream lock."""
|
|
44
|
+
writer = threading.Thread(
|
|
45
|
+
target=print_diagnostics, args=(diagnostics,), kwargs={"once": True}, daemon=True
|
|
46
|
+
)
|
|
47
|
+
writer.start()
|
|
48
|
+
with suppress(TimeoutError):
|
|
49
|
+
async with asyncio.timeout(_OUTPUT_TIMEOUT):
|
|
50
|
+
while writer.is_alive():
|
|
51
|
+
await asyncio.sleep(0.01)
|
|
52
|
+
|
|
53
|
+
|
|
32
54
|
def run_dev_boot(
|
|
33
55
|
settings: Settings,
|
|
34
56
|
modules: list[ModuleBase],
|
|
@@ -57,14 +79,16 @@ def run_dev_boot(
|
|
|
57
79
|
i18n_extra_sources=i18n_extra,
|
|
58
80
|
i18n_unknown_overrides=i18n_unknown_overrides,
|
|
59
81
|
database_dialect=settings.database_url.split(":", 1)[0].split("+", 1)[0],
|
|
82
|
+
existing_index_names=sqlite_file_index_names(settings.database_url),
|
|
60
83
|
)
|
|
61
84
|
diagnostics = diagnostics_state.rerun()
|
|
62
85
|
errors = [d for d in diagnostics if d.level == DiagnosticLevel.ERROR]
|
|
63
|
-
if diagnostics:
|
|
64
|
-
print_diagnostics(diagnostics)
|
|
65
86
|
if errors:
|
|
87
|
+
print_diagnostics(diagnostics, once=True)
|
|
66
88
|
raise SystemExit(f"Module diagnostics: {len(errors)} error(s). Fix before continuing.")
|
|
67
89
|
|
|
90
|
+
# Nonfatal findings print in lifespan, never in a generator/reloader supervisor.
|
|
91
|
+
|
|
68
92
|
_write_pages_manifest(modules, project_root)
|
|
69
93
|
emit_frontend_types_for_modules(settings, installed_modules, project_root)
|
|
70
94
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""Finalize last-resort routes after hosts have finished composing the app."""
|
|
2
|
+
|
|
3
|
+
from threading import Lock
|
|
4
|
+
|
|
5
|
+
from fastapi import FastAPI
|
|
6
|
+
from starlette.requests import Request
|
|
7
|
+
from starlette.responses import RedirectResponse
|
|
8
|
+
from starlette.routing import Mount, Route
|
|
9
|
+
from starlette.types import ASGIApp, Receive, Scope, Send
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def mark_fallback_routes(app: FastAPI, start: int) -> None:
|
|
13
|
+
"""Mark the actual entries added by an include, including lazy router entries."""
|
|
14
|
+
for route in app.routes[start:]:
|
|
15
|
+
route._sm_fallback = True
|
|
16
|
+
if not getattr(app.state, "fallback_routes_registered", False):
|
|
17
|
+
app.state.fallback_routes_lock = Lock()
|
|
18
|
+
app.add_middleware(_FinalizeFallbackRoutes, host=app)
|
|
19
|
+
app.state.fallback_routes_registered = True
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def finalize_fallback_routes(app: FastAPI) -> None:
|
|
23
|
+
"""Keep ordinary routes, mount redirects, then fallbacks, each in stable order."""
|
|
24
|
+
if not getattr(app.state, "fallback_routes_registered", False):
|
|
25
|
+
return
|
|
26
|
+
with app.state.fallback_routes_lock:
|
|
27
|
+
ordinary, fallbacks = [], []
|
|
28
|
+
for route in tuple(app.routes):
|
|
29
|
+
if isinstance(route, _MountRedirect):
|
|
30
|
+
continue
|
|
31
|
+
target = fallbacks if getattr(route, "_sm_fallback", False) else ordinary
|
|
32
|
+
target.append(route)
|
|
33
|
+
# Starlette only attempts slash redirects after *all* routes fail to match.
|
|
34
|
+
redirects = []
|
|
35
|
+
if app.router.redirect_slashes:
|
|
36
|
+
redirects = [
|
|
37
|
+
_MountRedirect(route.path)
|
|
38
|
+
for route in ordinary
|
|
39
|
+
if isinstance(route, Mount) and route.path
|
|
40
|
+
]
|
|
41
|
+
app.router.routes = ordinary + redirects + fallbacks
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class _MountRedirect(Route):
|
|
45
|
+
def __init__(self, path: str) -> None:
|
|
46
|
+
# Other methods must preserve an ordinary route's partial match (405).
|
|
47
|
+
super().__init__(path, self.redirect, methods=["GET", "HEAD"], include_in_schema=False)
|
|
48
|
+
|
|
49
|
+
async def redirect(self, request: Request) -> RedirectResponse:
|
|
50
|
+
return RedirectResponse(request.url.replace(path=f"{request.url.path}/"))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class _FinalizeFallbackRoutes:
|
|
54
|
+
"""Also finalize before dispatch when an ASGI client skips lifespan."""
|
|
55
|
+
|
|
56
|
+
def __init__(self, app: ASGIApp, host: FastAPI) -> None:
|
|
57
|
+
self.app = app
|
|
58
|
+
self.host = host
|
|
59
|
+
self.finalized = False
|
|
60
|
+
|
|
61
|
+
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
|
|
62
|
+
if not self.finalized and scope["type"] in {"http", "websocket"}:
|
|
63
|
+
finalize_fallback_routes(self.host)
|
|
64
|
+
self.finalized = True
|
|
65
|
+
await self.app(scope, receive, send)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Content-aware atomic writes for files consumed by frontend tools."""
|
|
2
|
+
|
|
3
|
+
import os
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from tempfile import mkstemp
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _write_if_changed(path: Path, payload: str) -> bool:
|
|
9
|
+
"""Publish complete replacements; keep unchanged mtimes to avoid spurious Vite HMR."""
|
|
10
|
+
try:
|
|
11
|
+
if path.read_text(encoding="utf-8") == payload:
|
|
12
|
+
return False
|
|
13
|
+
except FileNotFoundError:
|
|
14
|
+
pass
|
|
15
|
+
fd, name = mkstemp(dir=path.parent, suffix=".tmp")
|
|
16
|
+
temporary = Path(name)
|
|
17
|
+
try:
|
|
18
|
+
with os.fdopen(fd, "w", encoding="utf-8") as writer:
|
|
19
|
+
writer.write(payload)
|
|
20
|
+
temporary.replace(path)
|
|
21
|
+
finally:
|
|
22
|
+
temporary.unlink(missing_ok=True)
|
|
23
|
+
return True
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Host settings and their compiled request policy, swapped on hydration/reload."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from simple_module_hosting._request_policy import RequestGuardPolicy
|
|
6
|
+
from simple_module_hosting.host_settings import HostSettings
|
|
7
|
+
|
|
8
|
+
__all__ = ["_HostServices"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class _HostServices:
|
|
12
|
+
def __init__(self, settings: HostSettings) -> None:
|
|
13
|
+
self.settings = settings
|
|
14
|
+
|
|
15
|
+
@property
|
|
16
|
+
def settings(self) -> HostSettings:
|
|
17
|
+
return self._current[0]
|
|
18
|
+
|
|
19
|
+
@settings.setter
|
|
20
|
+
def settings(self, settings: HostSettings) -> None:
|
|
21
|
+
# Compile before publishing: a failure leaves the previous pair intact.
|
|
22
|
+
self._current = (settings, RequestGuardPolicy.from_settings(settings))
|
|
23
|
+
|
|
24
|
+
@property
|
|
25
|
+
def request_guards(self) -> RequestGuardPolicy:
|
|
26
|
+
return self._current[1]
|
|
@@ -16,7 +16,7 @@ if TYPE_CHECKING:
|
|
|
16
16
|
# admin UI can say so rather than letting the edit look like it took effect.
|
|
17
17
|
_RESTART_DB = {"requires_restart": True, "group": "Database"}
|
|
18
18
|
_RESTART_GUARD = {"requires_restart": True, "group": "Request guards"}
|
|
19
|
-
|
|
19
|
+
DEFAULT_LOGIN_REDIRECT_URL = "/dashboard/"
|
|
20
20
|
_RESTART_API = {"requires_restart": True, "group": "API"}
|
|
21
21
|
|
|
22
22
|
# Consumed while create_app builds the tenant middleware, the strict tenant
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"""Portable module key constants, generated only in editable source projects."""
|
|
2
|
+
|
|
3
|
+
import importlib.resources
|
|
4
|
+
import logging
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from simple_module_core import ModuleBase, get_module_package_name
|
|
8
|
+
from simple_module_core.i18n import I18nRegistry
|
|
9
|
+
|
|
10
|
+
from simple_module_hosting._generated_files import _write_if_changed
|
|
11
|
+
from simple_module_hosting.settings import Settings
|
|
12
|
+
|
|
13
|
+
logger = logging.getLogger(__name__)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def module_key_outputs(modules: list[ModuleBase]) -> list[tuple[ModuleBase, Path]]:
|
|
17
|
+
outputs = []
|
|
18
|
+
for module in modules:
|
|
19
|
+
name = get_module_package_name(module)
|
|
20
|
+
package = Path(str(importlib.resources.files(name)))
|
|
21
|
+
# Wheels ship these files; a consuming app must not write into site-packages.
|
|
22
|
+
project = package.parents[name.count(".")]
|
|
23
|
+
if not (project / "pyproject.toml").is_file():
|
|
24
|
+
continue
|
|
25
|
+
area = next((package / a for a in ("pages", "ui") if (package / a).is_dir()), None)
|
|
26
|
+
if area is not None and module.locale_dirs():
|
|
27
|
+
outputs.append((module, area / "i18n.generated.ts"))
|
|
28
|
+
return outputs
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def write_module_keys(
|
|
32
|
+
locale_dirs: dict[str, Path], output: Path, *, default_locale: str = "en"
|
|
33
|
+
) -> None:
|
|
34
|
+
from simple_module_hosting.i18n_manifest import _render_keys
|
|
35
|
+
|
|
36
|
+
registry = I18nRegistry(default_locale=default_locale, supported_locales=[default_locale])
|
|
37
|
+
for namespace, directory in locale_dirs.items():
|
|
38
|
+
registry.add_source(namespace, directory)
|
|
39
|
+
registry.load()
|
|
40
|
+
keys = sorted(registry.messages(default_locale))
|
|
41
|
+
source = "import '@simple-module-py/i18n';\n\n" + _render_keys(keys)
|
|
42
|
+
source += "\ntype ModuleTranslationResources = {\n"
|
|
43
|
+
source += "".join(f" readonly '{key}': '';\n" for key in keys)
|
|
44
|
+
source += (
|
|
45
|
+
"};\n\ndeclare module '@simple-module-py/i18n' {\n"
|
|
46
|
+
" interface TranslationResources extends ModuleTranslationResources {}\n"
|
|
47
|
+
"}\n"
|
|
48
|
+
)
|
|
49
|
+
output.parent.mkdir(parents=True, exist_ok=True)
|
|
50
|
+
_write_if_changed(output, source)
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def emit_module_keys(modules: list[ModuleBase], settings: Settings, *, strict: bool) -> None:
|
|
54
|
+
for module, output in module_key_outputs(modules):
|
|
55
|
+
try:
|
|
56
|
+
write_module_keys(
|
|
57
|
+
module.locale_dirs(), output, default_locale=settings.i18n_default_locale
|
|
58
|
+
)
|
|
59
|
+
except OSError:
|
|
60
|
+
if strict:
|
|
61
|
+
raise
|
|
62
|
+
logger.exception("Cannot write module i18n keys to %s", output)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"""Locate app-owned generated i18n files without mutating npm installations."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import re
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
|
|
8
|
+
RESOURCE_KEY_RE = re.compile(r"^\s+'([^']+)': '',$", re.MULTILINE)
|
|
9
|
+
|
|
10
|
+
_PUBLISHED_PKG = Path("node_modules") / "@simple-module-py" / "i18n" / "src"
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def resolve_i18n_types_dir(project_root: Path) -> tuple[Path | None, bool]:
|
|
14
|
+
"""Return the compatibility workspace target or the app's own aggregate.
|
|
15
|
+
|
|
16
|
+
The boolean identifies the app-owned target (formerly the published target).
|
|
17
|
+
An npm install is still required, but never used as an output directory.
|
|
18
|
+
"""
|
|
19
|
+
local = project_root / "packages/i18n/src"
|
|
20
|
+
if local.is_dir():
|
|
21
|
+
return local, False
|
|
22
|
+
root = project_root.resolve()
|
|
23
|
+
client = next((p for p in (root / "host/client_app", root / "client_app") if p.is_dir()), None)
|
|
24
|
+
for base in (root, root / "client_app", *root.parents):
|
|
25
|
+
if (base / _PUBLISHED_PKG).is_dir():
|
|
26
|
+
return (client / "i18n" if client else root / "i18n"), True
|
|
27
|
+
return None, False
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def app_i18n_dir(project_root: Path) -> Path | None:
|
|
31
|
+
for client in (project_root / "host/client_app", project_root / "client_app"):
|
|
32
|
+
if client.is_dir():
|
|
33
|
+
return client / "i18n"
|
|
34
|
+
return None
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def read_resource_keys(resources_path: Path) -> frozenset[str]:
|
|
38
|
+
"""Keys listed in an existing ``generated-resources.ts`` (empty if unreadable)."""
|
|
39
|
+
try:
|
|
40
|
+
return frozenset(RESOURCE_KEY_RE.findall(resources_path.read_text(encoding="utf-8")))
|
|
41
|
+
except OSError:
|
|
42
|
+
return frozenset()
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def app_i18n_import(client: Path) -> str:
|
|
46
|
+
return (
|
|
47
|
+
"import './i18n/keys.generated';\n" if (client / "i18n/keys.generated.ts").is_file() else ""
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def attach_app_i18n(client: Path) -> None:
|
|
52
|
+
"""Older app resolvers import this manifest; register their custom keys too."""
|
|
53
|
+
from simple_module_hosting._generated_files import _write_if_changed
|
|
54
|
+
|
|
55
|
+
manifest = client / "modules.generated.ts"
|
|
56
|
+
if manifest.is_file():
|
|
57
|
+
source = manifest.read_text(encoding="utf-8")
|
|
58
|
+
statement = app_i18n_import(client)
|
|
59
|
+
if statement and statement not in source:
|
|
60
|
+
_write_if_changed(manifest, statement + source)
|
|
@@ -71,7 +71,9 @@ def branding_head(request: Request) -> dict:
|
|
|
71
71
|
def site_info(request: Request) -> SiteInfo:
|
|
72
72
|
"""The public base URL (operator setting, never the request ``Host``) and app name."""
|
|
73
73
|
host = get_host_services(request.app)
|
|
74
|
-
|
|
74
|
+
from simple_module_hosting.public_urls import public_origin
|
|
75
|
+
|
|
76
|
+
base_url = public_origin(getattr(host, "settings", None))
|
|
75
77
|
return SiteInfo(base_url=base_url, app_name=branding_head(request)["app_name"])
|
|
76
78
|
|
|
77
79
|
|