simple-module-core 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.
Files changed (175) hide show
  1. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/.gitignore +6 -0
  2. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/PKG-INFO +4 -2
  3. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/pyproject.toml +4 -2
  4. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/__init__.py +6 -1
  5. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/__main__.py +7 -1
  6. simple_module_core-0.0.48/simple_module_core/_auth_providers.py +38 -0
  7. simple_module_core-0.0.48/simple_module_core/_invalidation_message.py +91 -0
  8. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/_migration_doctor.py +20 -18
  9. simple_module_core-0.0.48/simple_module_core/_module_conventions.py +34 -0
  10. simple_module_core-0.0.48/simple_module_core/_module_ordering.py +125 -0
  11. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/_request_hooks.py +4 -2
  12. simple_module_core-0.0.48/simple_module_core/admin_surface.py +53 -0
  13. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/cors.py +11 -2
  14. simple_module_core-0.0.48/simple_module_core/crypto.py +11 -0
  15. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/data_compatibility.py +10 -3
  16. simple_module_core-0.0.48/simple_module_core/diagnostics/_auth.py +52 -0
  17. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/diagnostics/_expression_index.py +44 -4
  18. simple_module_core-0.0.48/simple_module_core/diagnostics/_js_workspace.py +45 -0
  19. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/diagnostics/_migration.py +9 -9
  20. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/diagnostics/_module.py +41 -42
  21. simple_module_core-0.0.48/simple_module_core/diagnostics/_runner.py +208 -0
  22. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/diagnostics/_tenancy.py +2 -1
  23. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/discovery.py +61 -118
  24. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/durable_events.py +14 -0
  25. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/events.py +17 -0
  26. simple_module_core-0.0.48/simple_module_core/file_access.py +67 -0
  27. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/invalidation.py +17 -78
  28. simple_module_core-0.0.48/simple_module_core/mail.py +294 -0
  29. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/menu.py +36 -4
  30. simple_module_core-0.0.48/simple_module_core/migration_support/__init__.py +67 -0
  31. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/module.py +62 -24
  32. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/module_meta.py +24 -4
  33. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/path_rules.py +64 -12
  34. simple_module_core-0.0.48/simple_module_core/permission_catalogue.py +29 -0
  35. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/permissions.py +47 -3
  36. simple_module_core-0.0.48/simple_module_core/principal_permissions.py +194 -0
  37. simple_module_core-0.0.48/simple_module_core/principals.py +58 -0
  38. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/public_routes.py +23 -28
  39. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/rate_limit.py +18 -0
  40. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/redirect_safety.py +5 -3
  41. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/resources.py +25 -24
  42. simple_module_core-0.0.48/simple_module_core/role_directory.py +71 -0
  43. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/settings_hydrate.py +1 -5
  44. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/setup_steps.py +7 -0
  45. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/tenancy.py +6 -5
  46. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/user_directory.py +29 -3
  47. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/versioning.py +0 -11
  48. simple_module_core-0.0.48/tests/test_admin_surface.py +104 -0
  49. simple_module_core-0.0.48/tests/test_admin_surface_diagnostics.py +56 -0
  50. simple_module_core-0.0.48/tests/test_auth_provider_capability.py +68 -0
  51. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_auth_provider_selection.py +2 -4
  52. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_core_data_compatibility_doctor.py +6 -2
  53. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_core_discovery_stale_sys_path.py +2 -0
  54. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_core_module_settings.py +16 -5
  55. simple_module_core-0.0.48/tests/test_core_role_directory.py +46 -0
  56. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_deprecation_helper.py +1 -15
  57. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_diagnostics.py +6 -7
  58. simple_module_core-0.0.48/tests/test_diagnostics_encoding.py +55 -0
  59. simple_module_core-0.0.48/tests/test_diagnostics_fd_output.py +192 -0
  60. simple_module_core-0.0.48/tests/test_diagnostics_output.py +181 -0
  61. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_discovery.py +2 -0
  62. simple_module_core-0.0.48/tests/test_discovery_selection.py +186 -0
  63. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_doctor_cli_overrides.py +15 -1
  64. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_expression_index_diagnostics.py +41 -0
  65. simple_module_core-0.0.48/tests/test_invalidation_dedup.py +98 -0
  66. simple_module_core-0.0.48/tests/test_key_derivation.py +26 -0
  67. simple_module_core-0.0.48/tests/test_mail_attachments.py +193 -0
  68. simple_module_core-0.0.48/tests/test_mail_reply_to.py +137 -0
  69. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_module_base.py +1 -1
  70. simple_module_core-0.0.48/tests/test_module_defaults.py +183 -0
  71. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_module_diagnostics.py +13 -15
  72. simple_module_core-0.0.48/tests/test_module_discovery_versions.py +105 -0
  73. simple_module_core-0.0.48/tests/test_module_package_conventions.py +98 -0
  74. simple_module_core-0.0.48/tests/test_permission_catalogue.py +63 -0
  75. simple_module_core-0.0.48/tests/test_principal_composition.py +50 -0
  76. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_redirect_safety.py +3 -1
  77. simple_module_core-0.0.48/tests/test_registry_overrides.py +132 -0
  78. simple_module_core-0.0.46/simple_module_core/diagnostics/_js_workspace.py +0 -42
  79. simple_module_core-0.0.46/simple_module_core/diagnostics/_runner.py +0 -108
  80. simple_module_core-0.0.46/simple_module_core/mail.py +0 -121
  81. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/LICENSE +0 -0
  82. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/README.md +0 -0
  83. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/_data_doctor.py +0 -0
  84. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/_entry_point_errors.py +0 -0
  85. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/_i18n_flatten.py +0 -0
  86. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/_i18n_translator.py +0 -0
  87. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/_permission_grants.py +0 -0
  88. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/activity_feed.py +0 -0
  89. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/app_state.py +0 -0
  90. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/audit_links.py +0 -0
  91. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/body_limits.py +0 -0
  92. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/correlation.py +0 -0
  93. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/csp.py +0 -0
  94. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/datetimes.py +0 -0
  95. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/deprecation.py +0 -0
  96. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/design_packs.py +0 -0
  97. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/diagnostics/__init__.py +0 -0
  98. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/diagnostics/_coupling.py +0 -0
  99. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/diagnostics/_css.py +0 -0
  100. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/diagnostics/_db_extensions.py +0 -0
  101. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/diagnostics/_dependencies.py +0 -0
  102. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/diagnostics/_durable_names.py +0 -0
  103. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/diagnostics/_heavy_task_imports.py +0 -0
  104. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/diagnostics/_i18n.py +0 -0
  105. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/diagnostics/_inertia_api.py +0 -0
  106. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/diagnostics/_pages.py +0 -0
  107. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/diagnostics/_spa_mount.py +0 -0
  108. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/diagnostics/_types.py +0 -0
  109. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/dotenv.py +0 -0
  110. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/environments.py +0 -0
  111. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/exceptions.py +0 -0
  112. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/feature_flags.py +0 -0
  113. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/health.py +0 -0
  114. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/i18n.py +0 -0
  115. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/i18n_overrides.py +0 -0
  116. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/invalidation_refresh.py +0 -0
  117. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/leases.py +0 -0
  118. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/module_settings.py +0 -0
  119. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/permission_denied.py +0 -0
  120. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/py.typed +0 -0
  121. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/secret_fields.py +0 -0
  122. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/services.py +0 -0
  123. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/settings_base.py +0 -0
  124. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/singleflight.py +0 -0
  125. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/spa_mount.py +0 -0
  126. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/stored_settings.py +0 -0
  127. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/tenant_events.py +0 -0
  128. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/simple_module_core/user_events.py +0 -0
  129. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_audit_links.py +0 -0
  130. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_core_app_state.py +0 -0
  131. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_core_datetimes.py +0 -0
  132. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_core_inline_delivery_context.py +0 -0
  133. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_core_invalidation_refresh.py +0 -0
  134. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_core_leases.py +0 -0
  135. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_core_lifecycle_docs.py +0 -0
  136. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_core_mail_resolution.py +0 -0
  137. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_core_settings_source_cache.py +0 -0
  138. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_core_singleflight.py +0 -0
  139. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_core_user_directory.py +0 -0
  140. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_csp_registry.py +0 -0
  141. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_css_diagnostics.py +0 -0
  142. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_css_scanner.py +0 -0
  143. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_db_extensions_diagnostics.py +0 -0
  144. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_design_packs.py +0 -0
  145. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_diagnostics_tenancy.py +0 -0
  146. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_discovery_missing_deps.py +0 -0
  147. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_dotenv.py +0 -0
  148. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_durable_events.py +0 -0
  149. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_environments.py +0 -0
  150. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_events.py +0 -0
  151. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_events_inline.py +0 -0
  152. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_feature_flags.py +0 -0
  153. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_feature_flags_decorator.py +0 -0
  154. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_health_registry.py +0 -0
  155. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_heavy_task_imports_diagnostics.py +0 -0
  156. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_i18n.py +0 -0
  157. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_i18n_diagnostics.py +0 -0
  158. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_i18n_overrides.py +0 -0
  159. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_invalidation.py +0 -0
  160. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_invalidation_handlers.py +0 -0
  161. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_menu.py +0 -0
  162. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_path_rule_registries.py +0 -0
  163. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_permission_sources.py +0 -0
  164. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_permissions.py +0 -0
  165. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_permissions_admin_principal.py +0 -0
  166. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_public_routes.py +0 -0
  167. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_public_routes_rate_precedence.py +0 -0
  168. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_services.py +0 -0
  169. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_settings_base.py +0 -0
  170. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_sm003_page_render.py +0 -0
  171. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_sm009_dynamic_coupling.py +0 -0
  172. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_sm034_durable_names.py +0 -0
  173. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_tenant_exists.py +0 -0
  174. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_tenant_roles.py +0 -0
  175. {simple_module_core-0.0.46 → simple_module_core-0.0.48}/tests/test_versioning.py +0 -0
@@ -67,3 +67,9 @@ host/client_app/.playwright-cli/*
67
67
  .verify/
68
68
  /openapi.json
69
69
  qa-shots/
70
+
71
+ host/client_app/.module-tsconfig
72
+
73
+ # Incremental generation cache
74
+ .smpy/gen.json
75
+ .smpy/gen.*.tmp
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: simple_module_core
3
- Version: 0.0.46
3
+ Version: 0.0.48
4
4
  Summary: Module-system primitives for the simple_module framework — ModuleBase, discovery, diagnostics, events
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,11 +22,13 @@ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
22
22
  Classifier: Typing :: Typed
23
23
  Requires-Python: >=3.12
24
24
  Requires-Dist: babel<3,>=2.14
25
+ Requires-Dist: cryptography>=42
25
26
  Requires-Dist: fastapi<0.163,>=0.140
26
27
  Requires-Dist: packaging<27,>=23.0
27
28
  Requires-Dist: pydantic-settings<3,>=2.0
28
29
  Requires-Dist: pydantic<3,>=2.0
29
- Requires-Dist: pyee<15,>=12.0
30
+ Requires-Dist: pyee<17,>=12.0
31
+ Requires-Dist: sqlmodel<0.1,>=0.0.22
30
32
  Description-Content-Type: text/markdown
31
33
 
32
34
  # simple_module_core
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "simple_module_core"
3
- version = "0.0.46"
3
+ version = "0.0.48"
4
4
  description = "Module-system primitives for the simple_module framework — ModuleBase, discovery, diagnostics, events"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -22,11 +22,13 @@ classifiers = [
22
22
  ]
23
23
  dependencies = [
24
24
  "babel>=2.14,<3",
25
+ "cryptography>=42",
25
26
  "fastapi>=0.140,<0.163",
26
27
  "packaging>=23.0,<27",
27
28
  "pydantic>=2.0,<3",
28
29
  "pydantic-settings>=2.0,<3",
29
- "pyee>=12.0,<15",
30
+ "pyee>=12.0,<17",
31
+ "sqlmodel>=0.0.22,<0.1",
30
32
  ]
31
33
 
32
34
  [project.urls]
@@ -1,5 +1,6 @@
1
1
  """SimpleModule Core - Module system, menu, permissions, events, and diagnostics."""
2
2
 
3
+ from simple_module_core.admin_surface import AdminSurface
3
4
  from simple_module_core.audit_links import AuditLink, AuditLinkRegistry, LabelResolver
4
5
  from simple_module_core.body_limits import BodyLimitRegistry
5
6
  from simple_module_core.cors import CorsPolicy, CorsPolicyRegistry
@@ -53,7 +54,8 @@ from simple_module_core.invalidation import (
53
54
  )
54
55
  from simple_module_core.menu import MenuItem, MenuRegistry, MenuSection
55
56
  from simple_module_core.module import ModuleBase, ModuleMeta
56
- from simple_module_core.permissions import PermissionRegistry
57
+ from simple_module_core.permissions import PermissionCatalogue, PermissionRegistry
58
+ from simple_module_core.principals import PrincipalRegistry
57
59
  from simple_module_core.public_routes import PublicRoute, PublicRouteRegistry
58
60
  from simple_module_core.resources import (
59
61
  ResourcePolicy,
@@ -71,6 +73,7 @@ __all__ = [
71
73
  "DEFAULT_AUTH_PROVIDER",
72
74
  "FRAMEWORK_API_VERSION",
73
75
  "TENANT_ROLE_PREFIX",
76
+ "AdminSurface",
74
77
  "AuditLink",
75
78
  "AuditLinkRegistry",
76
79
  "BodyLimitRegistry",
@@ -110,7 +113,9 @@ __all__ = [
110
113
  "ModuleError",
111
114
  "ModuleMeta",
112
115
  "NotFoundError",
116
+ "PermissionCatalogue",
113
117
  "PermissionRegistry",
118
+ "PrincipalRegistry",
114
119
  "PublicRoute",
115
120
  "PublicRouteRegistry",
116
121
  "ResourcePolicy",
@@ -33,6 +33,7 @@ from simple_module_core.diagnostics import (
33
33
  run_diagnostics,
34
34
  )
35
35
  from simple_module_core.diagnostics._dependencies import CODE as MISSING_DEPENDENCY_CODE
36
+ from simple_module_core.diagnostics._expression_index import sqlite_file_index_names
36
37
  from simple_module_core.diagnostics._i18n import unknown_overrides_for
37
38
  from simple_module_core.discovery import (
38
39
  discover_modules,
@@ -194,15 +195,20 @@ def main() -> int:
194
195
  i18n_extra_sources=extra,
195
196
  i18n_unknown_overrides=unknown_overrides,
196
197
  database_dialect=_database_dialect(),
198
+ existing_index_names=sqlite_file_index_names(_database_url()),
197
199
  )
198
200
  diagnostics.extend(override_findings)
199
- diagnostics.extend(migration_diagnostics(modules, _database_url(), find_env_file().parent))
201
+ diagnostics.extend(migration_diagnostics(modules, _database_url()))
200
202
  diagnostics.extend(data_compatibility_diagnostics(modules, _database_url()))
201
203
  # A missing dependency only warns at a dev boot, but production refuses
202
204
  # to start with it (GH #501), so doctor reports it as what it will be.
203
205
  for finding in diagnostics:
204
206
  if finding.code == MISSING_DEPENDENCY_CODE:
205
207
  finding.level = DiagnosticLevel.ERROR
208
+ if not diagnostics:
209
+ noun = "module" if len(modules) == 1 else "modules"
210
+ print(f"✓ No issues found: {len(modules)} {noun} checked", file=sys.stderr)
211
+ return 0
206
212
  print_diagnostics(diagnostics)
207
213
 
208
214
  errors = [d for d in diagnostics if d.level == DiagnosticLevel.ERROR]
@@ -0,0 +1,38 @@
1
+ """Auth capability declaration and the dated class-marker fallback (#960)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+ from weakref import WeakSet
7
+
8
+ from simple_module_core.deprecation import deprecate
9
+
10
+ if TYPE_CHECKING:
11
+ from simple_module_core.module import ModuleBase
12
+
13
+ _LEGACY_MARKER = deprecate(
14
+ "ModuleBase._is_auth_provider",
15
+ remove_in="0.1.0",
16
+ use="ModuleMeta(provides_auth=True)",
17
+ )
18
+ _WARNED: WeakSet[type] = WeakSet()
19
+
20
+
21
+ def provides_auth(module: ModuleBase) -> bool:
22
+ """Use the public declaration, accepting legacy providers until removal."""
23
+ legacy = bool(getattr(module, "_is_auth_provider", False))
24
+ if legacy and type(module) not in _WARNED:
25
+ _LEGACY_MARKER.warn(stacklevel=2)
26
+ _WARNED.add(type(module))
27
+ return module.meta.provides_auth or legacy
28
+
29
+
30
+ def resembles_auth_provider(module: ModuleBase) -> bool:
31
+ """Recognize the protocol shape on the module without importing a plugin.
32
+
33
+ Separate provider objects created by register_settings are not visible here.
34
+ """
35
+ return isinstance(getattr(module, "name", None), str) and all(
36
+ callable(getattr(module, method, None))
37
+ for method in ("resolve_user", "get_login_url", "get_logout_url", "is_bearer_request")
38
+ )
@@ -0,0 +1,91 @@
1
+ """Versioned invalidation messages, compatible with legacy publishers (#986)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import json
6
+ import logging
7
+ from dataclasses import dataclass
8
+
9
+ logger = logging.getLogger(__name__)
10
+ _decode_failure_warned = False
11
+
12
+ WIRE_VERSION = 1
13
+ """Bumped for incompatible wire changes; version 1 accepts additive fields.
14
+
15
+ A message carrying any other version is dropped rather than guessed at, so a
16
+ rolling deploy in which half the workers run new code degrades to "no
17
+ cross-process invalidation between the two halves" instead of to a decode
18
+ exception in the listener loop.
19
+ """
20
+
21
+
22
+ @dataclass(frozen=True, slots=True)
23
+ class Invalidation:
24
+ """One "this cached thing changed" notice.
25
+
26
+ Deliberately not a :class:`~simple_module_core.events.Event`: a domain event
27
+ describes something that happened in the business ("an order was placed")
28
+ and its handlers may do anything, while this describes something that
29
+ stopped being true in a *cache* and its handlers may only forget. Sharing
30
+ the type would invite a handler that writes to the database on a message
31
+ that carries no delivery guarantee.
32
+ """
33
+
34
+ #: Who cares. Convention is ``<module>.<cache>`` — ``users.session_version``.
35
+ channel: str
36
+ #: Which entry, or ``None`` for "the whole channel". A string because it has
37
+ #: to survive JSON; a consumer keyed by something else converts on the way
38
+ #: back in (see ``users.accounts.session_revocation``).
39
+ key: str | None = None
40
+ #: The publishing process's :attr:`InvalidationBus.origin`. Lets a bus
41
+ #: ignore its own broadcast coming back off the transport, which it has
42
+ #: already applied locally.
43
+ origin: str = ""
44
+ #: Optional for compatibility with pre-bridge publishers on wire version 1.
45
+ message_id: str | None = None
46
+
47
+ def to_wire(self) -> str:
48
+ """JSON, because a transport is free to be anything that moves text."""
49
+ return json.dumps(
50
+ {
51
+ "v": WIRE_VERSION,
52
+ "channel": self.channel,
53
+ "key": self.key,
54
+ "origin": self.origin,
55
+ "id": self.message_id,
56
+ }
57
+ )
58
+
59
+ @classmethod
60
+ def from_wire(cls, message: str | bytes) -> Invalidation | None:
61
+ """Parse a wire message, or ``None`` when it isn't one of ours.
62
+
63
+ Returns rather than raises on anything unexpected. A Redis database is
64
+ routinely shared — with another app, with a stray ``redis-cli publish``,
65
+ with the previous version of this code — and a listener loop that dies
66
+ on one malformed payload takes cross-process invalidation down for the
67
+ life of the process. Decode exceptions warn once per process with a
68
+ traceback; unsupported shapes remain ordinary shared-database traffic.
69
+ """
70
+ try:
71
+ data = json.loads(message)
72
+ if not isinstance(data, dict) or data.get("v") != WIRE_VERSION:
73
+ logger.debug("Ignoring invalidation message with unknown shape: %r", message)
74
+ return None
75
+ channel = data["channel"]
76
+ key = data.get("key")
77
+ message_id = data.get("id")
78
+ if (
79
+ not isinstance(channel, str)
80
+ or not isinstance(key, str | None)
81
+ or not isinstance(message_id, str | None)
82
+ ):
83
+ logger.debug("Ignoring invalidation message with bad field types: %r", message)
84
+ return None
85
+ return cls(channel, key, str(data.get("origin") or ""), message_id)
86
+ except Exception:
87
+ global _decode_failure_warned
88
+ if not _decode_failure_warned:
89
+ _decode_failure_warned = True
90
+ logger.warning("Ignoring undecodable invalidation message", exc_info=True)
91
+ return None
@@ -3,30 +3,32 @@
3
3
  import asyncio
4
4
  import importlib.util
5
5
  from collections.abc import Sequence
6
- from pathlib import Path
7
6
 
8
7
  from simple_module_core.diagnostics import Diagnostic, DiagnosticLevel
9
- from simple_module_core.diagnostics._migration import MigrationDiagnostics, module_table_names
8
+ from simple_module_core.diagnostics._migration import (
9
+ MIGRATION_DRIFT_CODE,
10
+ MIGRATION_OWNER,
11
+ MigrationDiagnostics,
12
+ module_table_names,
13
+ )
14
+ from simple_module_core.migration_support import NO_ALEMBIC_CONFIG, resolve_alembic_ini
10
15
  from simple_module_core.module import ModuleBase
11
16
 
12
17
 
13
- def _alembic_ini(project_root: Path) -> Path | None:
14
- """``alembic.ini`` at the project root, else ``host/alembic.ini``, as the CLI resolves it."""
15
- for candidate in (project_root / "alembic.ini", project_root / "host" / "alembic.ini"):
16
- if candidate.is_file():
17
- return candidate
18
- return None
19
-
20
-
21
- def migration_diagnostics(
22
- modules: Sequence[ModuleBase], database_url: str, project_root: Path
23
- ) -> list[Diagnostic]:
18
+ def migration_diagnostics(modules: Sequence[ModuleBase], database_url: str) -> list[Diagnostic]:
24
19
  # Core-only installations have neither Alembic nor a database runtime.
25
20
  if importlib.util.find_spec("simple_module_db") is None:
26
21
  return []
27
- ini = _alembic_ini(project_root)
22
+ ini = resolve_alembic_ini()
28
23
  if ini is None:
29
- return []
24
+ return [
25
+ Diagnostic(
26
+ level=DiagnosticLevel.WARNING,
27
+ code=MIGRATION_DRIFT_CODE,
28
+ message=NO_ALEMBIC_CONFIG,
29
+ module_name=MIGRATION_OWNER,
30
+ )
31
+ ]
30
32
  from simple_module_db.migration_state import read_migration_state
31
33
 
32
34
  try:
@@ -38,10 +40,10 @@ def migration_diagnostics(
38
40
  return [
39
41
  Diagnostic(
40
42
  level=DiagnosticLevel.WARNING,
41
- code="SM010",
43
+ code=MIGRATION_DRIFT_CODE,
42
44
  message="Could not read the migration state (database or Alembic revisions); "
43
- "SM010 and SM011 were not checked",
44
- module_name="migrations",
45
+ f"{MIGRATION_DRIFT_CODE} and SM011 were not checked",
46
+ module_name=MIGRATION_OWNER,
45
47
  suggestion="Check SM_DATABASE_URL and that the database is running, and that "
46
48
  "the revisions load (`make migration-history`).",
47
49
  )
@@ -0,0 +1,34 @@
1
+ """Locate optional conventional modules without hiding broken imports."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import sys
6
+ from importlib.machinery import ModuleSpec
7
+ from importlib.util import find_spec
8
+ from typing import TYPE_CHECKING
9
+
10
+ if TYPE_CHECKING:
11
+ from simple_module_core.module import ModuleBase
12
+
13
+
14
+ def get_module_package_name(module: ModuleBase | str) -> str:
15
+ """Return the parent package of a class's defining module or its import name."""
16
+ name = module if isinstance(module, str) else type(module).__module__
17
+ return name.rpartition(".")[0] or name
18
+
19
+
20
+ def package_spec(package: str) -> ModuleSpec | None:
21
+ """Inline modules have no spec and cannot contribute conventional files."""
22
+ if package in sys.modules and getattr(sys.modules[package], "__spec__", None) is None:
23
+ return None
24
+ return find_spec(package)
25
+
26
+
27
+ def has_conventional_module(package: str, suffix: str) -> bool:
28
+ parts = f"{package}.{suffix}".split(".")
29
+ # Inspect parents first: find_spec(child) raises when a parent is a plain module.
30
+ for length in range(1, len(parts)):
31
+ spec = package_spec(".".join(parts[:length]))
32
+ if spec is None or spec.submodule_search_locations is None:
33
+ return False
34
+ return find_spec(".".join(parts)) is not None
@@ -0,0 +1,125 @@
1
+ """Dependency ordering and duplicate protection for discovered modules."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import logging
6
+ from collections.abc import Sequence
7
+
8
+ from simple_module_core.exceptions import (
9
+ CircularDependencyError,
10
+ InvalidModuleError,
11
+ MissingDependencyError,
12
+ )
13
+ from simple_module_core.module import ModuleBase
14
+
15
+ logger = logging.getLogger("simple_module_core.discovery")
16
+
17
+
18
+ def missing_dependencies(modules: Sequence[ModuleBase]) -> list[tuple[str, str]]:
19
+ """Every ``(module, dependency)`` pair whose dependency is not in *modules*."""
20
+ names = {m.meta.name for m in modules}
21
+ return [
22
+ (mod.meta.name, dep) for mod in modules for dep in mod.meta.depends_on if dep not in names
23
+ ]
24
+
25
+
26
+ def _ordering_deps(mod: ModuleBase, loaded: dict[str, ModuleBase]) -> list[str]:
27
+ """The loaded modules *mod* must sort after: required and optional alike."""
28
+ wanted = [*mod.meta.depends_on, *mod.meta.optional_depends_on]
29
+ return [dep for dep in dict.fromkeys(wanted) if dep in loaded]
30
+
31
+
32
+ def topological_sort(modules: Sequence[ModuleBase], *, strict: bool = False) -> list[ModuleBase]:
33
+ """Sort modules so dependencies come before dependents.
34
+
35
+ ``optional_depends_on`` orders the same way when present and is never
36
+ missing. A ``depends_on`` entry naming a module that is not loaded is
37
+ logged and ignored; with ``strict`` every such pair is collected and
38
+ raised at once as :class:`MissingDependencyError`. The host passes
39
+ ``strict`` outside development: a module whose dependency is absent would
40
+ otherwise boot and fail later, or silently query another module's empty
41
+ tables (GH #501).
42
+
43
+ Raises ``CircularDependencyError`` if a cycle is detected.
44
+ """
45
+ by_name: dict[str, ModuleBase] = {}
46
+ for mod in modules:
47
+ if mod.meta.name in by_name:
48
+ first = type(by_name[mod.meta.name])
49
+ later = type(mod)
50
+ message = (
51
+ f"SM008 Duplicate module name '{mod.meta.name}': "
52
+ f"{first.__module__}.{first.__qualname__} and "
53
+ f"{later.__module__}.{later.__qualname__}"
54
+ )
55
+ if strict:
56
+ raise InvalidModuleError(message)
57
+ logger.warning("%s — skipping later module", message)
58
+ continue
59
+ by_name[mod.meta.name] = mod
60
+
61
+ missing = missing_dependencies(list(by_name.values()))
62
+ if missing and strict:
63
+ raise MissingDependencyError(missing)
64
+ for name, dep in missing:
65
+ logger.warning("Module '%s' depends on '%s' which is not installed — ignoring", name, dep)
66
+
67
+ # Kahn's algorithm
68
+ in_degree: dict[str, int] = dict.fromkeys(by_name, 0)
69
+ dependents: dict[str, list[str]] = {name: [] for name in by_name}
70
+
71
+ edges = {m.meta.name: _ordering_deps(m, by_name) for m in by_name.values()}
72
+ for name, deps in edges.items():
73
+ for dep_name in deps:
74
+ in_degree[name] += 1
75
+ dependents[dep_name].append(name)
76
+
77
+ queue: list[str] = [name for name, deg in in_degree.items() if deg == 0]
78
+ result: list[str] = []
79
+
80
+ while queue:
81
+ # Sort queue for deterministic ordering
82
+ queue.sort()
83
+ current = queue.pop(0)
84
+ result.append(current)
85
+ for dependent in dependents[current]:
86
+ in_degree[dependent] -= 1
87
+ if in_degree[dependent] == 0:
88
+ queue.append(dependent)
89
+
90
+ if len(result) != len(by_name):
91
+ # Find the cycle for a helpful error message
92
+ remaining = set(by_name.keys()) - set(result)
93
+ cycle = _find_cycle(remaining, edges)
94
+ raise CircularDependencyError(cycle)
95
+
96
+ return [by_name[name] for name in result]
97
+
98
+
99
+ def _find_cycle(nodes: set[str], deps: dict[str, list[str]]) -> list[str]:
100
+ """Find one cycle in the dependency graph for error reporting."""
101
+ visited: set[str] = set()
102
+ path: list[str] = []
103
+
104
+ def dfs(node: str) -> list[str] | None:
105
+ if node in visited:
106
+ idx = path.index(node) if node in path else 0
107
+ return [*path[idx:], node]
108
+ visited.add(node)
109
+ path.append(node)
110
+ for dep in deps.get(node, []):
111
+ if dep in nodes:
112
+ result = dfs(dep)
113
+ if result:
114
+ return result
115
+ path.pop()
116
+ return None
117
+
118
+ for node in nodes:
119
+ visited.clear()
120
+ path.clear()
121
+ cycle = dfs(node)
122
+ if cycle:
123
+ return cycle
124
+
125
+ return list(nodes) # fallback
@@ -61,8 +61,10 @@ class RequestHooksMixin:
61
61
  def register_middleware(self, app: FastAPI) -> None:
62
62
  """Add middleware to the application.
63
63
 
64
- Called after core middleware (session, security headers) positioning
65
- is established but before the app starts.
64
+ ``app.add_middleware`` keeps the default tier, outside Tenant/Locale.
65
+ ``simple_module_hosting.add_middleware(app, cls, after="tenant")``
66
+ runs inside both; ``stage="before_session"`` runs outside Session.
67
+ The hook signature and dependency/LIFO ordering remain unchanged.
66
68
  """
67
69
 
68
70
  def register_exception_handlers(self, app: FastAPI) -> None:
@@ -0,0 +1,53 @@
1
+ """Opt-in routing and presentation defaults; deliberately no authorization."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+ from dataclasses import dataclass, replace
7
+ from typing import TYPE_CHECKING
8
+ from urllib.parse import urlsplit
9
+
10
+ if TYPE_CHECKING:
11
+ from simple_module_core.menu import MenuItem
12
+
13
+
14
+ @dataclass(frozen=True)
15
+ class AdminSurface:
16
+ """An admin router plus defaults for its menus and Inertia pages.
17
+
18
+ ``routes`` is ``python.module:router``; omitted uses the conventional
19
+ ``<package>.web.endpoints.admin:router``. ``layout`` is a JS module:named-export
20
+ pair, imported by gen-pages. Neither declaration grants any permission.
21
+ """
22
+
23
+ prefix: str
24
+ routes: str = ""
25
+ menu_group: str = ""
26
+ menu_group_key: str = ""
27
+ layout: str = "@simple-module-py/ui/layouts/AdminLayout:AdminLayout"
28
+
29
+ def __post_init__(self) -> None:
30
+ if (
31
+ not self.prefix.startswith("/")
32
+ or self.prefix.endswith("/")
33
+ or urlsplit(self.prefix).path != self.prefix
34
+ or self.prefix.startswith("//")
35
+ ):
36
+ raise ValueError(
37
+ "AdminSurface.prefix must be an absolute path without a trailing slash"
38
+ )
39
+ module, sep, export = self.layout.rpartition(":")
40
+ if not sep or not module or not re.fullmatch(r"[A-Za-z_$][\w$]*", export):
41
+ raise ValueError("AdminSurface.layout must be a JS module:named-export pair")
42
+
43
+ def menu_defaults(self, item: MenuItem) -> MenuItem:
44
+ """Apply defaults only to this surface's URLs; explicit choices win."""
45
+ from simple_module_core.menu import MenuSection
46
+
47
+ path = urlsplit(item.url).path
48
+ if path != self.prefix and not path.startswith(f"{self.prefix}/"):
49
+ return item
50
+ section = MenuSection.ADMIN_SIDEBAR if item._default_section else item.section
51
+ group = item.group or self.menu_group
52
+ group_key = item.group_key or (self.menu_group_key if not item.group else "")
53
+ return replace(item, section=section, group=group, group_key=group_key)
@@ -63,9 +63,18 @@ class CorsPolicyRegistry:
63
63
  ) -> None:
64
64
  self._rules.add(KIND_REGEX, pattern, policy, enabled=enabled)
65
65
 
66
- def match(self, method: str, path: str) -> CorsPolicy | None:
66
+ def match(
67
+ self, method: str, path: str, *, fallback: tuple[str, CorsPolicy] | None = None
68
+ ) -> CorsPolicy | None:
67
69
  """The governing policy for this request, or ``None`` (no CORS headers)."""
68
- return self._rules.match(method, path)
70
+ found = self._rules.match_entry(method, path)
71
+ if fallback is not None:
72
+ prefix, policy = fallback
73
+ if path.startswith(prefix) and (
74
+ found is None or (found[0] == KIND_PREFIX and len(found[1]) < len(prefix))
75
+ ):
76
+ return policy
77
+ return None if found is None else found[2]
69
78
 
70
79
  def __len__(self) -> int:
71
80
  return len(self._rules)
@@ -0,0 +1,11 @@
1
+ """Purpose-separated keys derived from the resolved application root secret."""
2
+
3
+ from cryptography.hazmat.primitives import hashes
4
+ from cryptography.hazmat.primitives.kdf.hkdf import HKDF
5
+
6
+
7
+ def derive_key(secret: str, info: bytes) -> bytes:
8
+ """Derive 32 bytes with HKDF-SHA256; keep each purpose's label stable."""
9
+ if not secret.strip():
10
+ raise ValueError("The root secret must not be blank")
11
+ return HKDF(algorithm=hashes.SHA256(), length=32, salt=None, info=info).derive(secret.encode())
@@ -6,6 +6,8 @@ from collections.abc import Sequence
6
6
  from dataclasses import dataclass
7
7
  from typing import TYPE_CHECKING, Any, Literal
8
8
 
9
+ from simple_module_core.migration_support import data_upgrade_entry_points
10
+
9
11
  if TYPE_CHECKING:
10
12
  from simple_module_core.module import ModuleBase
11
13
 
@@ -17,9 +19,14 @@ class DataCompatibilityIssue:
17
19
  upgrade_id: str
18
20
  message: str
19
21
  severity: Literal["warning", "error"]
20
-
21
- def remediation(self) -> str:
22
- return f"smpy migrations prepare {self.upgrade_id} --head <host-head-or-label@head>"
22
+ remediation_text: str | None = None
23
+
24
+ def remediation(self) -> str | None:
25
+ if self.remediation_text is not None:
26
+ return self.remediation_text
27
+ if len(data_upgrade_entry_points().select(name=self.upgrade_id)) == 1:
28
+ return f"smpy migrations prepare {self.upgrade_id} --head <host-head-or-label@head>"
29
+ return None
23
30
 
24
31
 
25
32
  async def collect_data_compatibility(
@@ -0,0 +1,52 @@
1
+ """SM020/SM021 — declared auth providers and detectable undeclared ones."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import TYPE_CHECKING
6
+
7
+ from simple_module_core._auth_providers import provides_auth, resembles_auth_provider
8
+ from simple_module_core.diagnostics._types import Diagnostic, DiagnosticLevel
9
+
10
+ if TYPE_CHECKING:
11
+ from simple_module_core.module import ModuleBase
12
+
13
+
14
+ def check_auth_providers(modules: list[ModuleBase]) -> list[Diagnostic]:
15
+ providers = [m for m in modules if provides_auth(m)]
16
+ diags: list[Diagnostic] = []
17
+ for mod in modules:
18
+ if not provides_auth(mod) and resembles_auth_provider(mod):
19
+ diags.append(
20
+ Diagnostic(
21
+ level=DiagnosticLevel.WARNING,
22
+ code="SM020",
23
+ message=f"Module '{mod.meta.name}' resembles an undeclared AuthProvider",
24
+ module_name=mod.meta.name,
25
+ suggestion="Declare ModuleMeta(provides_auth=True) for provider selection",
26
+ )
27
+ )
28
+ if len(providers) > 1:
29
+ names = ", ".join(m.meta.name for m in providers)
30
+ diags.append(
31
+ Diagnostic(
32
+ level=DiagnosticLevel.ERROR,
33
+ code="SM020",
34
+ message=f"Multiple auth provider modules installed: {names}",
35
+ module_name=providers[0].meta.name,
36
+ suggestion="Select one provider with SM_AUTH_PROVIDER or enable only one",
37
+ )
38
+ )
39
+ elif not providers:
40
+ diags.append(
41
+ Diagnostic(
42
+ level=DiagnosticLevel.WARNING,
43
+ code="SM021",
44
+ message="No auth provider module installed",
45
+ module_name="(none)",
46
+ suggestion=(
47
+ "Install an auth provider module "
48
+ "(e.g. 'simple-module-users' or 'simple-module-keycloak')"
49
+ ),
50
+ )
51
+ )
52
+ return diags