simple-module-settings 0.0.47__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_settings-0.0.47 → simple_module_settings-0.0.48}/.gitignore +6 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/PKG-INFO +6 -6
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/README.md +2 -2
- simple_module_settings-0.0.48/package.json +7 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/pyproject.toml +4 -4
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/core/_listing.py +12 -6
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/core/constants.py +27 -9
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/core/errors.py +6 -0
- simple_module_settings-0.0.48/settings/core/exceptions.py +12 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/core/service.py +14 -2
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/module.py +6 -18
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/module_settings/discovery.py +3 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/module_settings/props.py +1 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/module_settings/reload.py +14 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/pages/api.generated.ts +4 -0
- simple_module_settings-0.0.48/settings/pages/i18n.generated.ts +291 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/ui/components/FieldInput.tsx +19 -36
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/ui/components/ModuleForm.tsx +1 -1
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/web/endpoints/_create_form.py +2 -1
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/web/endpoints/api.py +6 -9
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/web/endpoints/module_api.py +4 -4
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/web/endpoints/tenant_api.py +2 -2
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/web/endpoints/views.py +9 -11
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/contracts/test_settings_framework_reexports.py +1 -22
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/module/test_settings_cli_import.py +5 -1
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/secrets/test_settings_store_secret_masking.py +3 -3
- simple_module_settings-0.0.48/tests/core/service/test_settings_internal_metadata.py +92 -0
- simple_module_settings-0.0.48/tests/module_settings/fields/test_settings_control_hint.py +18 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/module_settings/fields/test_settings_field_sources.py +5 -3
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/module_settings/fields/test_settings_lenient_related_fields_validators.py +11 -13
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/web/api/test_settings_module_api.py +47 -6
- simple_module_settings-0.0.48/tests-js/FieldInput.extensions.test.tsx +62 -0
- simple_module_settings-0.0.47/package.json +0 -18
- simple_module_settings-0.0.47/settings/_secrets.py +0 -11
- simple_module_settings-0.0.47/settings/constants.py +0 -11
- simple_module_settings-0.0.47/settings/core/exceptions.py +0 -5
- simple_module_settings-0.0.47/settings/hydrate.py +0 -36
- simple_module_settings-0.0.47/settings/module_registry.py +0 -17
- simple_module_settings-0.0.47/settings/pages/api.ts +0 -9
- simple_module_settings-0.0.47/settings/registration.py +0 -17
- simple_module_settings-0.0.47/settings/store.py +0 -11
- simple_module_settings-0.0.47/tsconfig.json +0 -10
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/LICENSE +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/__init__.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/cli.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/contracts/__init__.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/contracts/accessor.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/contracts/events.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/contracts/invalidation.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/contracts/registry.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/contracts/schemas.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/core/__init__.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/core/_announce.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/core/_managed_keys.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/core/_row_masking.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/core/_secrets.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/core/_unique_write.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/core/env_vars.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/core/invalidation.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/core/services.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/core/settings.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/core/tenant_scope.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/core/tenant_view.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/locales/de.json +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/locales/en.json +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/models.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/module_settings/__init__.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/module_settings/_field_meta.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/module_settings/store.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/pages/Browse.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/pages/Create.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/pages/Edit.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/pages/ModulesEdit.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/pages/routes.ts +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/pages/types.ts +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/py.typed +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/ui/components/FieldSource.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/ui/components/FormLevelError.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/ui/components/JsonInput.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/ui/components/KeyField.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/ui/components/ModuleFieldRow.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/ui/components/ResolvedValue.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/ui/components/ScopeTabs.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/ui/components/StoreCards.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/ui/components/StoreTable.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/ui/components/TestConnectionButton.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/ui/components/ValueInput.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/ui/components/last-test.ts +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/ui/components/validation-errors.ts +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/web/__init__.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/web/browse_query.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/web/deps.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/web/endpoints/__init__.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/web/known_keys.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/contracts/test_settings_accessor.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/contracts/test_settings_events.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/contracts/test_settings_schemas.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/module/test_settings_host_restart_flags.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/module/test_settings_module.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/secrets/test_settings_secret_json_roundtrip.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/secrets/test_settings_secret_masking.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/secrets/test_settings_secret_urls.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/secrets/test_settings_typed_secret_masking.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/service/test_settings_commit_invalidation.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/service/test_settings_concurrent_overrides.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/service/test_settings_default_clears_override.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/service/test_settings_domain_errors.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/service/test_settings_duplicate_and_race.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/service/test_settings_generic_module_guard.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/service/test_settings_group_metadata.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/service/test_settings_service.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/core/tenant/test_settings_tenant_settings.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/module_settings/fields/test_settings_env_pinned.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/module_settings/fields/test_settings_env_unprefixed.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/module_settings/fields/test_settings_module_settings.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/module_settings/fields/test_settings_module_settings_render.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/module_settings/fields/test_settings_module_settings_serialize.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/module_settings/fields/test_settings_testable_checks.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/module_settings/hydrate/test_settings_hydrate.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/module_settings/hydrate/test_settings_hydrate_related_fields.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/module_settings/hydrate/test_settings_module_registry.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/module_settings/hydrate/test_settings_registration.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/module_settings/hydrate/test_settings_reload.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/module_settings/store/test_settings_store.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/module_settings/store/test_settings_store_filters.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/web/api/test_settings_api.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/web/api/test_settings_clear_route_per_scope.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/web/api/test_settings_known_keys_meta.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/web/api/test_settings_module_api_json_fields.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/web/api/test_settings_upload_key_delete.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests/web/api/test_settings_view_authz.py +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests-js/JsonFields.test.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests-js/ModuleForm.test.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests-js/ModulesEdit.test.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests-js/RestartHint.test.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests-js/ScopeTabs.test.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests-js/settings_FormLevelError.test.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests-js/settings_ModuleFieldLayout.test.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests-js/settings_ModuleFormRevert.test.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests-js/settings_TestConnectionButton.test.tsx +0 -0
- {simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/tests-js/settings_validation-errors.test.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: simple_module_settings
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.48
|
|
4
4
|
Summary: Runtime settings UI — modules plug their own settings panels into a shared admin view
|
|
5
5
|
Project-URL: Homepage, https://github.com/antosubash/simple_module_python
|
|
6
6
|
Project-URL: Repository, https://github.com/antosubash/simple_module_python
|
|
@@ -21,9 +21,9 @@ Classifier: Topic :: Internet :: WWW/HTTP
|
|
|
21
21
|
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
22
22
|
Classifier: Typing :: Typed
|
|
23
23
|
Requires-Python: >=3.12
|
|
24
|
-
Requires-Dist: simple-module-core==0.0.
|
|
25
|
-
Requires-Dist: simple-module-db==0.0.
|
|
26
|
-
Requires-Dist: simple-module-hosting==0.0.
|
|
24
|
+
Requires-Dist: simple-module-core==0.0.48
|
|
25
|
+
Requires-Dist: simple-module-db==0.0.48
|
|
26
|
+
Requires-Dist: simple-module-hosting==0.0.48
|
|
27
27
|
Requires-Dist: typer<0.28,>=0.12
|
|
28
28
|
Description-Content-Type: text/markdown
|
|
29
29
|
|
|
@@ -39,7 +39,7 @@ pip install simple_module_settings
|
|
|
39
39
|
|
|
40
40
|
## What it provides
|
|
41
41
|
|
|
42
|
-
- `/settings` admin page (and `/settings/modules`) aggregating every installed module's settings into one editable view.
|
|
42
|
+
- `/admin/settings` admin page (and `/admin/settings/modules`) aggregating every installed module's settings into one editable view.
|
|
43
43
|
- `register_module_settings(app, package, SettingsClass, services_factory)` helper — a module calls this from its own `register_settings(app)` hook to record its `BaseSettings` class; the UI renders its fields automatically (no panel/page wiring needed).
|
|
44
44
|
- DB-backed runtime settings store (hydrated into each module's `BaseSettings` at startup, before module `on_startup` hooks run) for values admins change at runtime.
|
|
45
45
|
|
|
@@ -64,7 +64,7 @@ class OrdersModule(ModuleBase):
|
|
|
64
64
|
)
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
That surfaces the module's settings fields under `/admin/settings/`, hydrated from the DB store at startup. The settings class is normally a `simple_module_core.settings_base.DbBackedSettings` (DB is the only source). Registration and hydration live in the framework (#500); this module adds the admin editor, hot reload and the key/value API.
|
|
67
|
+
That surfaces the module's settings fields under `/admin/settings/`, hydrated from the DB store at startup. The settings class is normally a `simple_module_core.settings_base.DbBackedSettings` (DB is the only source). Registration and hydration live in the framework (#500); this module adds the admin editor, hot reload and the key/value API.
|
|
68
68
|
|
|
69
69
|
## Depends on
|
|
70
70
|
|
|
@@ -10,7 +10,7 @@ pip install simple_module_settings
|
|
|
10
10
|
|
|
11
11
|
## What it provides
|
|
12
12
|
|
|
13
|
-
- `/settings` admin page (and `/settings/modules`) aggregating every installed module's settings into one editable view.
|
|
13
|
+
- `/admin/settings` admin page (and `/admin/settings/modules`) aggregating every installed module's settings into one editable view.
|
|
14
14
|
- `register_module_settings(app, package, SettingsClass, services_factory)` helper — a module calls this from its own `register_settings(app)` hook to record its `BaseSettings` class; the UI renders its fields automatically (no panel/page wiring needed).
|
|
15
15
|
- DB-backed runtime settings store (hydrated into each module's `BaseSettings` at startup, before module `on_startup` hooks run) for values admins change at runtime.
|
|
16
16
|
|
|
@@ -35,7 +35,7 @@ class OrdersModule(ModuleBase):
|
|
|
35
35
|
)
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
That surfaces the module's settings fields under `/admin/settings/`, hydrated from the DB store at startup. The settings class is normally a `simple_module_core.settings_base.DbBackedSettings` (DB is the only source). Registration and hydration live in the framework (#500); this module adds the admin editor, hot reload and the key/value API.
|
|
38
|
+
That surfaces the module's settings fields under `/admin/settings/`, hydrated from the DB store at startup. The settings class is normally a `simple_module_core.settings_base.DbBackedSettings` (DB is the only source). Registration and hydration live in the framework (#500); this module adds the admin editor, hot reload and the key/value API.
|
|
39
39
|
|
|
40
40
|
## Depends on
|
|
41
41
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "simple_module_settings"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.48"
|
|
4
4
|
description = "Runtime settings UI — modules plug their own settings panels into a shared admin view"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -21,9 +21,9 @@ classifiers = [
|
|
|
21
21
|
"Typing :: Typed",
|
|
22
22
|
]
|
|
23
23
|
dependencies = [
|
|
24
|
-
"simple_module_core==0.0.
|
|
25
|
-
"simple_module_db==0.0.
|
|
26
|
-
"simple_module_hosting==0.0.
|
|
24
|
+
"simple_module_core==0.0.48",
|
|
25
|
+
"simple_module_db==0.0.48",
|
|
26
|
+
"simple_module_hosting==0.0.48",
|
|
27
27
|
"typer>=0.12,<0.28",
|
|
28
28
|
]
|
|
29
29
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from simple_module_db import LIKE_ESCAPE_CHAR, like_contains_pattern
|
|
6
|
-
from simple_module_db.stored_settings import SYSTEM_SCOPE_ID, Setting
|
|
6
|
+
from simple_module_db.stored_settings import INTERNAL_SETTING_KEYS, SYSTEM_SCOPE_ID, Setting
|
|
7
7
|
from sqlalchemy import func, select
|
|
8
8
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
9
9
|
from sqlmodel import col
|
|
@@ -22,7 +22,9 @@ class SettingListing:
|
|
|
22
22
|
|
|
23
23
|
async def list_all(self) -> list[SettingOut]:
|
|
24
24
|
result = await self.db.execute(
|
|
25
|
-
select(Setting)
|
|
25
|
+
select(Setting)
|
|
26
|
+
.where(Setting.key.not_in(INTERNAL_SETTING_KEYS))
|
|
27
|
+
.order_by(Setting.scope, Setting.scope_id, Setting.key)
|
|
26
28
|
)
|
|
27
29
|
return [out(row) for row in result.scalars()]
|
|
28
30
|
|
|
@@ -70,7 +72,7 @@ class SettingListing:
|
|
|
70
72
|
|
|
71
73
|
@staticmethod
|
|
72
74
|
def _filter_conditions(scope: SettingScope | None, q: str | None) -> list:
|
|
73
|
-
conditions = []
|
|
75
|
+
conditions = [Setting.key.not_in(INTERNAL_SETTING_KEYS)]
|
|
74
76
|
if scope is not None:
|
|
75
77
|
conditions.append(Setting.scope == scope.value)
|
|
76
78
|
needle = (q or "").strip()
|
|
@@ -100,8 +102,8 @@ class SettingListing:
|
|
|
100
102
|
screen: ``SettingsStore`` feeds these values back into the live module
|
|
101
103
|
settings objects at boot, so a masked read writes a row of dots over the
|
|
102
104
|
real secret — a mailer that cannot authenticate, and a
|
|
103
|
-
``
|
|
104
|
-
|
|
105
|
+
``oauth_google_client_secret`` that no longer authenticates with Google.
|
|
106
|
+
This is the one read that must see through the mask, and it is
|
|
105
107
|
spelled out rather than reached by passing a flag so that every caller
|
|
106
108
|
of it is one grep away.
|
|
107
109
|
"""
|
|
@@ -112,6 +114,10 @@ class SettingListing:
|
|
|
112
114
|
def _scope_stmt(scope: SettingScope, scope_id: str):
|
|
113
115
|
return (
|
|
114
116
|
select(Setting)
|
|
115
|
-
.where(
|
|
117
|
+
.where(
|
|
118
|
+
col(Setting.scope) == scope.value,
|
|
119
|
+
col(Setting.scope_id) == scope_id,
|
|
120
|
+
Setting.key.not_in(INTERNAL_SETTING_KEYS),
|
|
121
|
+
)
|
|
116
122
|
.order_by(Setting.key)
|
|
117
123
|
)
|
|
@@ -10,6 +10,9 @@ from __future__ import annotations
|
|
|
10
10
|
|
|
11
11
|
from typing import Final
|
|
12
12
|
|
|
13
|
+
from simple_module_core.deprecation import deprecate
|
|
14
|
+
from simple_module_core.permissions import PermissionCatalogue
|
|
15
|
+
|
|
13
16
|
# Re-exported (#500): these now live with the table in the framework.
|
|
14
17
|
from simple_module_db.stored_settings import ( # noqa: F401
|
|
15
18
|
ALL_VALUE_TYPES,
|
|
@@ -82,15 +85,30 @@ MENU_ORDER: Final = 200
|
|
|
82
85
|
|
|
83
86
|
# ── Permissions ──────────────────────────────────────────────────────
|
|
84
87
|
PERM_GROUP: Final = MODULE_NAME
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class Permissions(PermissionCatalogue, group=PERM_GROUP, label_key="settings.permission_group"):
|
|
91
|
+
VIEW = "settings.view"
|
|
92
|
+
CREATE = "settings.create"
|
|
93
|
+
EDIT = "settings.edit"
|
|
94
|
+
DELETE = "settings.delete"
|
|
95
|
+
# Edit only the active tenant's overridable keys; mapped to owner/admin.
|
|
96
|
+
# The four permissions above remain platform-operator permissions.
|
|
97
|
+
TENANT_EDIT = "settings.tenant.edit"
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
deprecate(
|
|
101
|
+
"settings PERM_* constants",
|
|
102
|
+
remove_in="0.0.50",
|
|
103
|
+
use="settings.core.constants.Permissions",
|
|
104
|
+
)
|
|
105
|
+
PERM_VIEW: Final = Permissions.VIEW
|
|
106
|
+
PERM_CREATE: Final = Permissions.CREATE
|
|
107
|
+
PERM_EDIT: Final = Permissions.EDIT
|
|
108
|
+
PERM_DELETE: Final = Permissions.DELETE
|
|
109
|
+
PERM_TENANT_EDIT: Final = Permissions.TENANT_EDIT
|
|
110
|
+
|
|
111
|
+
ALL_PERMISSIONS: Final = tuple(Permissions)
|
|
94
112
|
|
|
95
113
|
# ── Cache invalidation ───────────────────────────────────────────────
|
|
96
114
|
# Published (after commit) for every SYSTEM / TENANT write, keyed per
|
|
@@ -7,6 +7,7 @@ from fastapi.responses import JSONResponse, Response
|
|
|
7
7
|
|
|
8
8
|
from settings.core._managed_keys import ManagedKeyError, ModuleKeyError
|
|
9
9
|
from settings.core.constants import STATUS_UNPROCESSABLE
|
|
10
|
+
from settings.core.exceptions import InternalKeyError
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
async def _managed_key(request: Request, exc: Exception) -> Response:
|
|
@@ -26,3 +27,8 @@ async def _module_key(request: Request, exc: Exception) -> Response:
|
|
|
26
27
|
def install_exception_handlers(app: FastAPI) -> None:
|
|
27
28
|
app.add_exception_handler(ManagedKeyError, _managed_key)
|
|
28
29
|
app.add_exception_handler(ModuleKeyError, _module_key)
|
|
30
|
+
app.add_exception_handler(InternalKeyError, _internal_key)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
async def _internal_key(request: Request, exc: Exception) -> Response:
|
|
34
|
+
return JSONResponse({"detail": str(exc)}, status_code=STATUS_UNPROCESSABLE)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""Transport-independent settings business failures."""
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SettingsError(Exception):
|
|
5
|
+
"""Base for errors raised by settings services."""
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class InternalKeyError(SettingsError):
|
|
9
|
+
"""Internal metadata cannot be edited through configuration interfaces."""
|
|
10
|
+
|
|
11
|
+
def __init__(self) -> None:
|
|
12
|
+
super().__init__("Internal metadata cannot be edited as a setting")
|
|
@@ -4,7 +4,12 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from typing import TYPE_CHECKING
|
|
6
6
|
|
|
7
|
-
from simple_module_db.stored_settings import
|
|
7
|
+
from simple_module_db.stored_settings import (
|
|
8
|
+
INTERNAL_SETTING_KEYS,
|
|
9
|
+
SYSTEM_SCOPE_ID,
|
|
10
|
+
VALUE_TYPE_STRING,
|
|
11
|
+
Setting,
|
|
12
|
+
)
|
|
8
13
|
from sqlalchemy import select
|
|
9
14
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
10
15
|
from sqlmodel import col
|
|
@@ -22,6 +27,7 @@ from settings.core._managed_keys import ModuleKeyError, TenantIsLive, ensure_del
|
|
|
22
27
|
from settings.core._row_masking import drop_placeholder_write, is_placeholder_write, out
|
|
23
28
|
from settings.core._unique_write import DuplicateSettingError, insert_if_free
|
|
24
29
|
from settings.core.constants import VIEW_PREFIX
|
|
30
|
+
from settings.core.exceptions import InternalKeyError
|
|
25
31
|
|
|
26
32
|
if TYPE_CHECKING:
|
|
27
33
|
from simple_module_core.invalidation import InvalidationBus
|
|
@@ -64,6 +70,8 @@ class SettingService(SettingListing):
|
|
|
64
70
|
Tenant (and user) rows stay writable here: a ``tenant_overridable``
|
|
65
71
|
module key's per-tenant override has no other platform route (#690).
|
|
66
72
|
"""
|
|
73
|
+
if key in INTERNAL_SETTING_KEYS:
|
|
74
|
+
raise InternalKeyError
|
|
67
75
|
if SettingScope(scope) is not SettingScope.SYSTEM:
|
|
68
76
|
return
|
|
69
77
|
package, sep, field = key.partition(".")
|
|
@@ -78,7 +86,7 @@ class SettingService(SettingListing):
|
|
|
78
86
|
|
|
79
87
|
async def get_by_id(self, setting_id: int) -> SettingOut | None:
|
|
80
88
|
entity = await self.db.get(Setting, setting_id)
|
|
81
|
-
if entity is None:
|
|
89
|
+
if entity is None or entity.key in INTERNAL_SETTING_KEYS:
|
|
82
90
|
return None
|
|
83
91
|
return out(entity)
|
|
84
92
|
|
|
@@ -208,6 +216,8 @@ class SettingService(SettingListing):
|
|
|
208
216
|
self, scope: SettingScope, scope_id: str, key: str, *, as_owner: bool = False
|
|
209
217
|
) -> bool:
|
|
210
218
|
"""Delete one row; ``as_owner`` is for the module that reaps a ``clear_via`` key's file."""
|
|
219
|
+
if key in INTERNAL_SETTING_KEYS:
|
|
220
|
+
raise InternalKeyError
|
|
211
221
|
entity = await self._find(scope, scope_id, key)
|
|
212
222
|
if entity is None:
|
|
213
223
|
return False
|
|
@@ -228,6 +238,8 @@ class SettingService(SettingListing):
|
|
|
228
238
|
# ── Internals ───────────────────────────────────────────────────
|
|
229
239
|
|
|
230
240
|
async def _find(self, scope: SettingScope, scope_id: str, key: str) -> Setting | None:
|
|
241
|
+
if key in INTERNAL_SETTING_KEYS:
|
|
242
|
+
return None
|
|
231
243
|
stmt = select(Setting).where(
|
|
232
244
|
col(Setting.scope) == scope.value,
|
|
233
245
|
col(Setting.scope_id) == scope_id,
|
|
@@ -2,8 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
import importlib.resources
|
|
6
|
-
from pathlib import Path
|
|
7
5
|
from typing import TYPE_CHECKING
|
|
8
6
|
|
|
9
7
|
from fastapi import APIRouter, FastAPI
|
|
@@ -13,19 +11,15 @@ from simple_module_core.module import ModuleBase, ModuleMeta
|
|
|
13
11
|
from simple_module_core.permissions import PermissionRegistry
|
|
14
12
|
|
|
15
13
|
from settings.core.constants import (
|
|
16
|
-
ALL_PERMISSIONS,
|
|
17
14
|
API_PREFIX,
|
|
18
|
-
LOCALE_NAMESPACE,
|
|
19
15
|
MENU_ICON,
|
|
20
16
|
MENU_LABEL,
|
|
21
17
|
MENU_ORDER,
|
|
22
18
|
MENU_URL,
|
|
23
19
|
MODULE_NAME,
|
|
24
20
|
MODULE_PACKAGE,
|
|
25
|
-
PERM_GROUP,
|
|
26
|
-
PERM_TENANT_EDIT,
|
|
27
|
-
PERM_VIEW,
|
|
28
21
|
VIEW_PREFIX,
|
|
22
|
+
Permissions,
|
|
29
23
|
)
|
|
30
24
|
|
|
31
25
|
if TYPE_CHECKING:
|
|
@@ -54,6 +48,8 @@ async def _resolve_setting_labels(db: AsyncSession, ids: list[str]) -> dict[str,
|
|
|
54
48
|
|
|
55
49
|
|
|
56
50
|
class SettingsModule(ModuleBase):
|
|
51
|
+
permissions = Permissions
|
|
52
|
+
|
|
57
53
|
meta = ModuleMeta(
|
|
58
54
|
name=MODULE_NAME,
|
|
59
55
|
route_prefix=API_PREFIX,
|
|
@@ -124,23 +120,19 @@ class SettingsModule(ModuleBase):
|
|
|
124
120
|
group_key="ui.nav_groups.system",
|
|
125
121
|
# Mirrors the view router's guard, so the entry is not offered
|
|
126
122
|
# to accounts whose click would 403.
|
|
127
|
-
permissions=[
|
|
123
|
+
permissions=[Permissions.VIEW],
|
|
128
124
|
)
|
|
129
125
|
)
|
|
130
126
|
|
|
131
127
|
def register_permissions(self, registry: PermissionRegistry) -> None:
|
|
132
128
|
from simple_module_core.tenancy import TenantRole, tenant_role
|
|
133
129
|
|
|
134
|
-
|
|
135
|
-
PERM_GROUP,
|
|
136
|
-
list(ALL_PERMISSIONS),
|
|
137
|
-
label_key=f"{LOCALE_NAMESPACE}.permission_group",
|
|
138
|
-
)
|
|
130
|
+
super().register_permissions(registry)
|
|
139
131
|
# Tenant owners and admins edit their own tenant's overridable keys
|
|
140
132
|
# (#382). The one permission for it — ``tenants`` no longer ships its
|
|
141
133
|
# own unused ``tenants.settings.manage``. Members get nothing here.
|
|
142
134
|
for role in (TenantRole.OWNER, TenantRole.ADMIN):
|
|
143
|
-
registry.map_role(tenant_role(role), [
|
|
135
|
+
registry.map_role(tenant_role(role), [Permissions.TENANT_EDIT])
|
|
144
136
|
|
|
145
137
|
def register_audit_links(self, registry: AuditLinkRegistry) -> None:
|
|
146
138
|
from simple_module_db.stored_settings import Setting
|
|
@@ -154,7 +146,3 @@ class SettingsModule(ModuleBase):
|
|
|
154
146
|
label_resolver=_resolve_setting_labels,
|
|
155
147
|
)
|
|
156
148
|
)
|
|
157
|
-
|
|
158
|
-
def locale_dirs(self) -> dict[str, Path]:
|
|
159
|
-
base = Path(str(importlib.resources.files(__package__) / "locales"))
|
|
160
|
-
return {LOCALE_NAMESPACE: base}
|
|
@@ -81,6 +81,8 @@ class ModuleSettingField:
|
|
|
81
81
|
"""Editor control: ``type`` with an ``X | None`` unwrapped to ``X``."""
|
|
82
82
|
nullable: bool = False
|
|
83
83
|
"""``None`` is a valid value; the editor sends it for an empty input."""
|
|
84
|
+
control: str | None = None
|
|
85
|
+
"""Optional frontend renderer registered under this name."""
|
|
84
86
|
|
|
85
87
|
@property
|
|
86
88
|
def source(self) -> str:
|
|
@@ -194,6 +196,7 @@ def _field_view(
|
|
|
194
196
|
choices=choices_for(info),
|
|
195
197
|
input_type=input_type,
|
|
196
198
|
nullable=nullable,
|
|
199
|
+
control=control if isinstance(control := extra.get("control"), str) else None,
|
|
197
200
|
)
|
|
198
201
|
|
|
199
202
|
|
{simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/module_settings/reload.py
RENAMED
|
@@ -18,6 +18,7 @@ from simple_module_core.settings_hydrate import (
|
|
|
18
18
|
)
|
|
19
19
|
|
|
20
20
|
from settings.core.invalidation import reload_on_commit
|
|
21
|
+
from settings.module_settings._field_meta import choices_for
|
|
21
22
|
from settings.module_settings.store import SettingsStore
|
|
22
23
|
|
|
23
24
|
|
|
@@ -133,6 +134,19 @@ async def apply_changes_and_reload(
|
|
|
133
134
|
|
|
134
135
|
merged.update(diff)
|
|
135
136
|
validated = cls(**merged)
|
|
137
|
+
# Dynamic registries expose choices through the same metadata as the UI.
|
|
138
|
+
# Check normalized values; existing field validators may accept other spellings.
|
|
139
|
+
for name in diff:
|
|
140
|
+
value = getattr(validated, name)
|
|
141
|
+
choices = choices_for(cls.model_fields[name])
|
|
142
|
+
if choices and value not in choices:
|
|
143
|
+
error = ValueError(
|
|
144
|
+
f"Unknown choice for {name}: {value!r}; choices: {', '.join(choices)}"
|
|
145
|
+
)
|
|
146
|
+
raise ValidationError.from_exception_data(
|
|
147
|
+
cls.__name__,
|
|
148
|
+
[{"type": "value_error", "loc": (name,), "input": value, "ctx": {"error": error}}],
|
|
149
|
+
)
|
|
136
150
|
dumped_all = validated.model_dump()
|
|
137
151
|
|
|
138
152
|
# A json field stores what validated, not what was sent: a field validator
|
{simple_module_settings-0.0.47 → simple_module_settings-0.0.48}/settings/pages/api.generated.ts
RENAMED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
// AUTO-GENERATED by `smpy openapi gen-types` from the Settings module's /api
|
|
2
2
|
// operations — do not edit. Regenerate with `smpy openapi gen-types --module settings`
|
|
3
3
|
// (`make gen-api-types` in the framework repo).
|
|
4
|
+
import { createApi } from '@simple-module-py/ui/lib/api';
|
|
5
|
+
|
|
4
6
|
/**
|
|
5
7
|
* This file was auto-generated by openapi-typescript.
|
|
6
8
|
* Do not make direct changes to the file.
|
|
@@ -1041,3 +1043,5 @@ export interface operations {
|
|
|
1041
1043
|
};
|
|
1042
1044
|
};
|
|
1043
1045
|
}
|
|
1046
|
+
|
|
1047
|
+
export const api = createApi<paths>();
|