simple-module-feature-flags 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_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/.gitignore +6 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/PKG-INFO +6 -6
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/README.md +2 -2
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/core/constants.py +20 -2
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/module.py +6 -31
- simple_module_feature_flags-0.0.48/feature_flags/pages/i18n.generated.ts +112 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/web/endpoints/api.py +8 -12
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/web/endpoints/views.py +4 -5
- simple_module_feature_flags-0.0.48/package.json +8 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/pyproject.toml +7 -4
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/tests/core/tenant_cleanup/test_feature_flags_tenant_cleanup.py +1 -1
- simple_module_feature_flags-0.0.46/package.json +0 -19
- simple_module_feature_flags-0.0.46/tsconfig.json +0 -10
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/LICENSE +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/__init__.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/contracts/__init__.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/contracts/schemas.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/core/__init__.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/core/invalidation.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/core/service.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/core/tenant_cleanup.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/locales/de.json +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/locales/en.json +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/models.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/pages/Browse.tsx +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/py.typed +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/ui/components/FlagTable.tsx +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/ui/components/ScopeCard.tsx +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/ui/components/TenantPicker.tsx +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/ui/components/ToggleConfirmDialog.tsx +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/ui/types.ts +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/web/__init__.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/web/deps.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/web/endpoints/__init__.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/tests/conftest.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/tests/core/invalidation/test_feature_flags_commit_invalidation.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/tests/core/module/test_feature_flags_audit_links.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/tests/core/module/test_feature_flags_menu_section.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/tests/core/service/test_feature_flags_description_i18n.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/tests/core/service/test_feature_flags_service.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/tests/core/service/test_feature_flags_store_outage_fallback.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/tests/core/tenancy/test_feature_flags_tenancy.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/tests/web/endpoints/test_feature_flags_api.py +0 -0
- {simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/tests-js/feature_flags_Browse.test.tsx +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: simple_module_feature_flags
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.48
|
|
4
4
|
Summary: Simple feature-flag module with per-tenant overrides and a consumer API for simple_module
|
|
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
|
Description-Content-Type: text/markdown
|
|
28
28
|
|
|
29
29
|
# simple_module_feature_flags
|
|
@@ -40,7 +40,7 @@ pip install simple_module_feature_flags
|
|
|
40
40
|
|
|
41
41
|
- Flags are *declared* via the framework `register_feature_flags` hook (`FeatureFlagDefinition(name, default_enabled=...)`); the module persists only *overrides* in the `feature_flags_override` SQLModel table (scoped by `scope` / `scope_id`).
|
|
42
42
|
- `FeatureFlagRegistry.is_enabled("flag.name", tenant_id=...)` consumer API (resolution order: tenant override > system override > declared default).
|
|
43
|
-
- Admin UI at `/
|
|
43
|
+
- Admin UI at `/admin/feature-flags` — toggle flags, add per-scope overrides.
|
|
44
44
|
- The registry is an in-memory cache hydrated from the DB so checking a flag on every request is cheap.
|
|
45
45
|
|
|
46
46
|
## Usage
|
|
@@ -73,7 +73,7 @@ async def new_feature(flags: FeatureFlagRegistryDep):
|
|
|
73
73
|
return {"rolled_out": True}
|
|
74
74
|
```
|
|
75
75
|
|
|
76
|
-
Overrides (system or per-tenant) are managed through the admin UI at `/
|
|
76
|
+
Overrides (system or per-tenant) are managed through the admin UI at `/admin/feature-flags`.
|
|
77
77
|
|
|
78
78
|
## Depends on
|
|
79
79
|
|
|
@@ -12,7 +12,7 @@ pip install simple_module_feature_flags
|
|
|
12
12
|
|
|
13
13
|
- Flags are *declared* via the framework `register_feature_flags` hook (`FeatureFlagDefinition(name, default_enabled=...)`); the module persists only *overrides* in the `feature_flags_override` SQLModel table (scoped by `scope` / `scope_id`).
|
|
14
14
|
- `FeatureFlagRegistry.is_enabled("flag.name", tenant_id=...)` consumer API (resolution order: tenant override > system override > declared default).
|
|
15
|
-
- Admin UI at `/
|
|
15
|
+
- Admin UI at `/admin/feature-flags` — toggle flags, add per-scope overrides.
|
|
16
16
|
- The registry is an in-memory cache hydrated from the DB so checking a flag on every request is cheap.
|
|
17
17
|
|
|
18
18
|
## Usage
|
|
@@ -45,7 +45,7 @@ async def new_feature(flags: FeatureFlagRegistryDep):
|
|
|
45
45
|
return {"rolled_out": True}
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
-
Overrides (system or per-tenant) are managed through the admin UI at `/
|
|
48
|
+
Overrides (system or per-tenant) are managed through the admin UI at `/admin/feature-flags`.
|
|
49
49
|
|
|
50
50
|
## Depends on
|
|
51
51
|
|
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
"""Stable identifiers for the feature_flags module."""
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
from simple_module_core.deprecation import deprecate
|
|
4
|
+
from simple_module_core.permissions import PermissionCatalogue
|
|
5
|
+
|
|
5
6
|
# Shown as a heading in the role editor, so it follows the same sentence case
|
|
6
7
|
# as the menu label and the page title rather than reading "Feature Flags"
|
|
7
8
|
# beside them.
|
|
8
9
|
PERM_GROUP = "Feature flags"
|
|
9
10
|
|
|
11
|
+
|
|
12
|
+
class Permissions(
|
|
13
|
+
PermissionCatalogue, group=PERM_GROUP, label_key="feature_flags.permission_group"
|
|
14
|
+
):
|
|
15
|
+
VIEW = "feature_flags.view"
|
|
16
|
+
MANAGE = "feature_flags.manage"
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
deprecate(
|
|
20
|
+
"feature_flags PERM_* constants",
|
|
21
|
+
remove_in="0.0.50",
|
|
22
|
+
use="feature_flags.core.constants.Permissions",
|
|
23
|
+
)
|
|
24
|
+
PERM_FEATURE_FLAGS_VIEW = Permissions.VIEW
|
|
25
|
+
PERM_FEATURE_FLAGS_MANAGE = Permissions.MANAGE
|
|
26
|
+
|
|
27
|
+
|
|
10
28
|
# Prefix is load-bearing on SQLite, which has no per-module schemas.
|
|
11
29
|
TABLE_OVERRIDE = "feature_flags_override"
|
|
12
30
|
UQ_OVERRIDE_SCOPE_NAME = "uq_feature_flags_override_scope_scope_id_name"
|
{simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/module.py
RENAMED
|
@@ -2,31 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
import importlib.resources
|
|
6
5
|
import logging
|
|
7
|
-
from pathlib import Path
|
|
8
6
|
from typing import TYPE_CHECKING
|
|
9
7
|
|
|
10
|
-
from fastapi import
|
|
8
|
+
from fastapi import FastAPI
|
|
11
9
|
from simple_module_core.audit_links import AuditLink, AuditLinkRegistry
|
|
12
10
|
from simple_module_core.menu import MenuItem, MenuRegistry, MenuSection
|
|
13
11
|
from simple_module_core.module import ModuleBase, ModuleMeta
|
|
14
|
-
from simple_module_core.permissions import PermissionRegistry
|
|
15
12
|
|
|
16
13
|
from feature_flags.core.constants import (
|
|
17
14
|
AUDIT_LINK_LABEL,
|
|
18
15
|
AUDIT_LINK_LABEL_KEY,
|
|
19
|
-
LOCALE_NAMESPACE,
|
|
20
16
|
MENU_ICON,
|
|
21
17
|
MENU_LABEL,
|
|
22
18
|
MENU_ORDER,
|
|
23
19
|
MENU_URL,
|
|
24
|
-
PERM_FEATURE_FLAGS_MANAGE,
|
|
25
|
-
PERM_FEATURE_FLAGS_VIEW,
|
|
26
|
-
PERM_GROUP,
|
|
27
20
|
QP_OVERRIDE,
|
|
28
21
|
TENANT_CLEANUP_HANDLER,
|
|
29
22
|
VIEW_PREFIX,
|
|
23
|
+
Permissions,
|
|
30
24
|
)
|
|
31
25
|
|
|
32
26
|
if TYPE_CHECKING:
|
|
@@ -63,6 +57,8 @@ async def _resolve_override_labels(db: AsyncSession, ids: list[str]) -> dict[str
|
|
|
63
57
|
|
|
64
58
|
|
|
65
59
|
class FeatureFlagsModule(ModuleBase):
|
|
60
|
+
permissions = Permissions
|
|
61
|
+
|
|
66
62
|
meta = ModuleMeta(
|
|
67
63
|
name="FeatureFlags",
|
|
68
64
|
route_prefix="/api/feature_flags",
|
|
@@ -70,7 +66,7 @@ class FeatureFlagsModule(ModuleBase):
|
|
|
70
66
|
i18n_audience="admin",
|
|
71
67
|
)
|
|
72
68
|
|
|
73
|
-
def register_event_handlers(self, bus: EventBus, app: FastAPI | None
|
|
69
|
+
def register_event_handlers(self, bus: EventBus, app: FastAPI | None) -> None:
|
|
74
70
|
from simple_module_core.tenant_events import TenantDeleted
|
|
75
71
|
|
|
76
72
|
from feature_flags.core.tenant_cleanup import purge_tenant_data
|
|
@@ -88,13 +84,6 @@ class FeatureFlagsModule(ModuleBase):
|
|
|
88
84
|
|
|
89
85
|
self._refresh = subscribe(bus, app)
|
|
90
86
|
|
|
91
|
-
def register_routes(self, api_router: APIRouter, view_router: APIRouter) -> None:
|
|
92
|
-
from feature_flags.web.endpoints.api import router as api
|
|
93
|
-
from feature_flags.web.endpoints.views import router as views
|
|
94
|
-
|
|
95
|
-
api_router.include_router(api)
|
|
96
|
-
view_router.include_router(views)
|
|
97
|
-
|
|
98
87
|
def register_menu_items(self, registry: MenuRegistry) -> None:
|
|
99
88
|
registry.add(
|
|
100
89
|
MenuItem(
|
|
@@ -108,7 +97,7 @@ class FeatureFlagsModule(ModuleBase):
|
|
|
108
97
|
group_key="ui.nav_groups.system",
|
|
109
98
|
# Mirrors the view router's guard. Without it the entry shows
|
|
110
99
|
# for every signed-in account and 403s on click.
|
|
111
|
-
permissions=[
|
|
100
|
+
permissions=[Permissions.VIEW],
|
|
112
101
|
)
|
|
113
102
|
)
|
|
114
103
|
|
|
@@ -133,20 +122,6 @@ class FeatureFlagsModule(ModuleBase):
|
|
|
133
122
|
)
|
|
134
123
|
)
|
|
135
124
|
|
|
136
|
-
def register_permissions(self, registry: PermissionRegistry) -> None:
|
|
137
|
-
registry.add_group(
|
|
138
|
-
PERM_GROUP,
|
|
139
|
-
[
|
|
140
|
-
PERM_FEATURE_FLAGS_VIEW,
|
|
141
|
-
PERM_FEATURE_FLAGS_MANAGE,
|
|
142
|
-
],
|
|
143
|
-
label_key="feature_flags.permission_group",
|
|
144
|
-
)
|
|
145
|
-
|
|
146
|
-
def locale_dirs(self) -> dict[str, Path]:
|
|
147
|
-
base = Path(str(importlib.resources.files(__package__) / "locales"))
|
|
148
|
-
return {LOCALE_NAMESPACE: base}
|
|
149
|
-
|
|
150
125
|
async def on_startup(self, app: FastAPI) -> None:
|
|
151
126
|
"""Load every persisted override into the in-memory registry.
|
|
152
127
|
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import '@simple-module-py/i18n';
|
|
2
|
+
|
|
3
|
+
// AUTO-GENERATED by simple_module_hosting.i18n_manifest — do not edit by hand.
|
|
4
|
+
// Regenerate by booting the host in development mode or `make gen-i18n`.
|
|
5
|
+
|
|
6
|
+
export const keys = {
|
|
7
|
+
feature_flags: {
|
|
8
|
+
audit: {
|
|
9
|
+
override: 'feature_flags.audit.override',
|
|
10
|
+
},
|
|
11
|
+
browse: {
|
|
12
|
+
audit_note: 'feature_flags.browse.audit_note',
|
|
13
|
+
cancel: 'feature_flags.browse.cancel',
|
|
14
|
+
description: 'feature_flags.browse.description',
|
|
15
|
+
empty_description: 'feature_flags.browse.empty_description',
|
|
16
|
+
empty_title: 'feature_flags.browse.empty_title',
|
|
17
|
+
go: 'feature_flags.browse.go',
|
|
18
|
+
scope_custom: 'feature_flags.browse.scope_custom',
|
|
19
|
+
scope_label: 'feature_flags.browse.scope_label',
|
|
20
|
+
scope_system: 'feature_flags.browse.scope_system',
|
|
21
|
+
tenant_id_label: 'feature_flags.browse.tenant_id_label',
|
|
22
|
+
tenant_id_placeholder: 'feature_flags.browse.tenant_id_placeholder',
|
|
23
|
+
title: 'feature_flags.browse.title',
|
|
24
|
+
view_history: 'feature_flags.browse.view_history',
|
|
25
|
+
viewing_system: 'feature_flags.browse.viewing_system',
|
|
26
|
+
viewing_tenant: 'feature_flags.browse.viewing_tenant',
|
|
27
|
+
},
|
|
28
|
+
confirm: {
|
|
29
|
+
cancel: 'feature_flags.confirm.cancel',
|
|
30
|
+
disable_action: 'feature_flags.confirm.disable_action',
|
|
31
|
+
disable_title: 'feature_flags.confirm.disable_title',
|
|
32
|
+
enable_action: 'feature_flags.confirm.enable_action',
|
|
33
|
+
enable_title: 'feature_flags.confirm.enable_title',
|
|
34
|
+
scope_system: 'feature_flags.confirm.scope_system',
|
|
35
|
+
scope_tenant: 'feature_flags.confirm.scope_tenant',
|
|
36
|
+
},
|
|
37
|
+
nav: {
|
|
38
|
+
feature_flags: 'feature_flags.nav.feature_flags',
|
|
39
|
+
},
|
|
40
|
+
permission_group: 'feature_flags.permission_group',
|
|
41
|
+
table: {
|
|
42
|
+
actions: 'feature_flags.table.actions',
|
|
43
|
+
clear_override: 'feature_flags.table.clear_override',
|
|
44
|
+
description: 'feature_flags.table.description',
|
|
45
|
+
disabled: 'feature_flags.table.disabled',
|
|
46
|
+
effective: 'feature_flags.table.effective',
|
|
47
|
+
enabled: 'feature_flags.table.enabled',
|
|
48
|
+
following_default: 'feature_flags.table.following_default',
|
|
49
|
+
following_system: 'feature_flags.table.following_system',
|
|
50
|
+
name: 'feature_flags.table.name',
|
|
51
|
+
off: 'feature_flags.table.off',
|
|
52
|
+
on: 'feature_flags.table.on',
|
|
53
|
+
overridden: 'feature_flags.table.overridden',
|
|
54
|
+
system: 'feature_flags.table.system',
|
|
55
|
+
},
|
|
56
|
+
toasts: {
|
|
57
|
+
cleared: 'feature_flags.toasts.cleared',
|
|
58
|
+
disabled: 'feature_flags.toasts.disabled',
|
|
59
|
+
enabled: 'feature_flags.toasts.enabled',
|
|
60
|
+
toggle_failed: 'feature_flags.toasts.toggle_failed',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
} as const;
|
|
64
|
+
|
|
65
|
+
type ModuleTranslationResources = {
|
|
66
|
+
readonly 'feature_flags.audit.override': '';
|
|
67
|
+
readonly 'feature_flags.browse.audit_note': '';
|
|
68
|
+
readonly 'feature_flags.browse.cancel': '';
|
|
69
|
+
readonly 'feature_flags.browse.description': '';
|
|
70
|
+
readonly 'feature_flags.browse.empty_description': '';
|
|
71
|
+
readonly 'feature_flags.browse.empty_title': '';
|
|
72
|
+
readonly 'feature_flags.browse.go': '';
|
|
73
|
+
readonly 'feature_flags.browse.scope_custom': '';
|
|
74
|
+
readonly 'feature_flags.browse.scope_label': '';
|
|
75
|
+
readonly 'feature_flags.browse.scope_system': '';
|
|
76
|
+
readonly 'feature_flags.browse.tenant_id_label': '';
|
|
77
|
+
readonly 'feature_flags.browse.tenant_id_placeholder': '';
|
|
78
|
+
readonly 'feature_flags.browse.title': '';
|
|
79
|
+
readonly 'feature_flags.browse.view_history': '';
|
|
80
|
+
readonly 'feature_flags.browse.viewing_system': '';
|
|
81
|
+
readonly 'feature_flags.browse.viewing_tenant': '';
|
|
82
|
+
readonly 'feature_flags.confirm.cancel': '';
|
|
83
|
+
readonly 'feature_flags.confirm.disable_action': '';
|
|
84
|
+
readonly 'feature_flags.confirm.disable_title': '';
|
|
85
|
+
readonly 'feature_flags.confirm.enable_action': '';
|
|
86
|
+
readonly 'feature_flags.confirm.enable_title': '';
|
|
87
|
+
readonly 'feature_flags.confirm.scope_system': '';
|
|
88
|
+
readonly 'feature_flags.confirm.scope_tenant': '';
|
|
89
|
+
readonly 'feature_flags.nav.feature_flags': '';
|
|
90
|
+
readonly 'feature_flags.permission_group': '';
|
|
91
|
+
readonly 'feature_flags.table.actions': '';
|
|
92
|
+
readonly 'feature_flags.table.clear_override': '';
|
|
93
|
+
readonly 'feature_flags.table.description': '';
|
|
94
|
+
readonly 'feature_flags.table.disabled': '';
|
|
95
|
+
readonly 'feature_flags.table.effective': '';
|
|
96
|
+
readonly 'feature_flags.table.enabled': '';
|
|
97
|
+
readonly 'feature_flags.table.following_default': '';
|
|
98
|
+
readonly 'feature_flags.table.following_system': '';
|
|
99
|
+
readonly 'feature_flags.table.name': '';
|
|
100
|
+
readonly 'feature_flags.table.off': '';
|
|
101
|
+
readonly 'feature_flags.table.on': '';
|
|
102
|
+
readonly 'feature_flags.table.overridden': '';
|
|
103
|
+
readonly 'feature_flags.table.system': '';
|
|
104
|
+
readonly 'feature_flags.toasts.cleared': '';
|
|
105
|
+
readonly 'feature_flags.toasts.disabled': '';
|
|
106
|
+
readonly 'feature_flags.toasts.enabled': '';
|
|
107
|
+
readonly 'feature_flags.toasts.toggle_failed': '';
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
declare module '@simple-module-py/i18n' {
|
|
111
|
+
interface TranslationResources extends ModuleTranslationResources {}
|
|
112
|
+
}
|
|
@@ -7,11 +7,7 @@ from simple_module_core.feature_flags import FeatureFlagRegistry
|
|
|
7
7
|
from simple_module_hosting.permissions import RequiresPermission
|
|
8
8
|
|
|
9
9
|
from feature_flags.contracts.schemas import FeatureFlagView, ToggleRequest
|
|
10
|
-
from feature_flags.core.constants import
|
|
11
|
-
PERM_FEATURE_FLAGS_MANAGE,
|
|
12
|
-
PERM_FEATURE_FLAGS_VIEW,
|
|
13
|
-
SCOPE_TENANT,
|
|
14
|
-
)
|
|
10
|
+
from feature_flags.core.constants import SCOPE_TENANT, Permissions
|
|
15
11
|
from feature_flags.web.deps import (
|
|
16
12
|
FeatureFlagRegistryDep,
|
|
17
13
|
FeatureFlagServiceDep,
|
|
@@ -30,7 +26,7 @@ def _ensure_registered(name: str, registry: FeatureFlagRegistry) -> None:
|
|
|
30
26
|
@router.get(
|
|
31
27
|
"/",
|
|
32
28
|
response_model=list[FeatureFlagView],
|
|
33
|
-
dependencies=[Depends(RequiresPermission(
|
|
29
|
+
dependencies=[Depends(RequiresPermission(Permissions.VIEW))],
|
|
34
30
|
)
|
|
35
31
|
async def list_flags(
|
|
36
32
|
service: FeatureFlagServiceDep,
|
|
@@ -42,7 +38,7 @@ async def list_flags(
|
|
|
42
38
|
@router.get(
|
|
43
39
|
"/{name}",
|
|
44
40
|
response_model=FeatureFlagView,
|
|
45
|
-
dependencies=[Depends(RequiresPermission(
|
|
41
|
+
dependencies=[Depends(RequiresPermission(Permissions.VIEW))],
|
|
46
42
|
)
|
|
47
43
|
async def get_flag(
|
|
48
44
|
name: str,
|
|
@@ -58,7 +54,7 @@ async def get_flag(
|
|
|
58
54
|
@router.put(
|
|
59
55
|
"/{name}",
|
|
60
56
|
response_model=FeatureFlagView,
|
|
61
|
-
dependencies=[Depends(RequiresPermission(
|
|
57
|
+
dependencies=[Depends(RequiresPermission(Permissions.MANAGE))],
|
|
62
58
|
)
|
|
63
59
|
async def set_override(
|
|
64
60
|
name: str,
|
|
@@ -78,7 +74,7 @@ async def set_override(
|
|
|
78
74
|
@router.delete(
|
|
79
75
|
"/{name}",
|
|
80
76
|
status_code=204,
|
|
81
|
-
dependencies=[Depends(RequiresPermission(
|
|
77
|
+
dependencies=[Depends(RequiresPermission(Permissions.MANAGE))],
|
|
82
78
|
)
|
|
83
79
|
async def clear_override(
|
|
84
80
|
name: str,
|
|
@@ -94,7 +90,7 @@ async def clear_override(
|
|
|
94
90
|
"/tenant/{tenant_id}",
|
|
95
91
|
response_model=list[FeatureFlagView],
|
|
96
92
|
dependencies=[
|
|
97
|
-
Depends(RequiresPermission(
|
|
93
|
+
Depends(RequiresPermission(Permissions.VIEW)),
|
|
98
94
|
Depends(require_known_tenant),
|
|
99
95
|
],
|
|
100
96
|
)
|
|
@@ -110,7 +106,7 @@ async def list_flags_for_tenant(
|
|
|
110
106
|
"/tenant/{tenant_id}/{name}",
|
|
111
107
|
response_model=FeatureFlagView,
|
|
112
108
|
dependencies=[
|
|
113
|
-
Depends(RequiresPermission(
|
|
109
|
+
Depends(RequiresPermission(Permissions.MANAGE)),
|
|
114
110
|
Depends(require_known_tenant),
|
|
115
111
|
],
|
|
116
112
|
)
|
|
@@ -137,7 +133,7 @@ async def set_tenant_override(
|
|
|
137
133
|
@router.delete(
|
|
138
134
|
"/tenant/{tenant_id}/{name}",
|
|
139
135
|
status_code=204,
|
|
140
|
-
dependencies=[Depends(RequiresPermission(
|
|
136
|
+
dependencies=[Depends(RequiresPermission(Permissions.MANAGE))],
|
|
141
137
|
)
|
|
142
138
|
async def clear_tenant_override(
|
|
143
139
|
tenant_id: str,
|
|
@@ -20,12 +20,11 @@ from feature_flags.core.constants import (
|
|
|
20
20
|
AUDIT_LOG_VIEW_URL,
|
|
21
21
|
MENU_URL,
|
|
22
22
|
PAGE_BROWSE,
|
|
23
|
-
PERM_FEATURE_FLAGS_MANAGE,
|
|
24
|
-
PERM_FEATURE_FLAGS_VIEW,
|
|
25
23
|
QP_TENANT_ID,
|
|
26
24
|
SCOPE_SYSTEM,
|
|
27
25
|
SCOPE_TENANT,
|
|
28
26
|
SYSTEM_SCOPE_ID,
|
|
27
|
+
Permissions,
|
|
29
28
|
)
|
|
30
29
|
from feature_flags.web.deps import (
|
|
31
30
|
FeatureFlagRegistryDep,
|
|
@@ -67,7 +66,7 @@ def _scope_args(tenant_id: str | None) -> dict[str, str]:
|
|
|
67
66
|
"/",
|
|
68
67
|
response_model=None,
|
|
69
68
|
dependencies=[
|
|
70
|
-
Depends(RequiresPermission(
|
|
69
|
+
Depends(RequiresPermission(Permissions.VIEW)),
|
|
71
70
|
Depends(require_known_tenant),
|
|
72
71
|
],
|
|
73
72
|
)
|
|
@@ -96,7 +95,7 @@ async def browse(
|
|
|
96
95
|
"/{name}/toggle",
|
|
97
96
|
response_model=None,
|
|
98
97
|
dependencies=[
|
|
99
|
-
Depends(RequiresPermission(
|
|
98
|
+
Depends(RequiresPermission(Permissions.MANAGE)),
|
|
100
99
|
Depends(require_known_tenant),
|
|
101
100
|
],
|
|
102
101
|
)
|
|
@@ -118,7 +117,7 @@ async def toggle_action(
|
|
|
118
117
|
@router.post(
|
|
119
118
|
"/{name}/clear",
|
|
120
119
|
response_model=None,
|
|
121
|
-
dependencies=[Depends(RequiresPermission(
|
|
120
|
+
dependencies=[Depends(RequiresPermission(Permissions.MANAGE))],
|
|
122
121
|
)
|
|
123
122
|
async def clear_action(
|
|
124
123
|
name: str,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "simple_module_feature_flags"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.48"
|
|
4
4
|
description = "Simple feature-flag module with per-tenant overrides and a consumer API for simple_module"
|
|
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
|
]
|
|
28
28
|
|
|
29
29
|
[project.entry-points.simple_module]
|
|
@@ -42,6 +42,9 @@ build-backend = "hatchling.build"
|
|
|
42
42
|
[tool.hatch.build.targets.wheel]
|
|
43
43
|
packages = ["feature_flags"]
|
|
44
44
|
|
|
45
|
+
[tool.hatch.build.targets.wheel.force-include]
|
|
46
|
+
"package.json" = "feature_flags/package.json"
|
|
47
|
+
|
|
45
48
|
[tool.uv.sources]
|
|
46
49
|
simple_module_core = { workspace = true }
|
|
47
50
|
simple_module_db = { workspace = true }
|
|
@@ -11,7 +11,7 @@ from sqlmodel import select
|
|
|
11
11
|
|
|
12
12
|
async def test_durable_tenant_cleanup_is_scoped_idempotent_and_transactional(db_session):
|
|
13
13
|
bus = EventBus()
|
|
14
|
-
FeatureFlagsModule().register_event_handlers(bus)
|
|
14
|
+
FeatureFlagsModule().register_event_handlers(bus, None)
|
|
15
15
|
names = bus.durable.handler_names(TenantDeleted)
|
|
16
16
|
assert len(names) == 1
|
|
17
17
|
subscription = bus.durable.lookup(event_key(TenantDeleted), names[0])
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@simple-module-py/feature_flags",
|
|
3
|
-
"version": "0.0.46",
|
|
4
|
-
"private": true,
|
|
5
|
-
"description": "Frontend assets for the FeatureFlags module",
|
|
6
|
-
"peerDependencies": {
|
|
7
|
-
"@inertiajs/react": "^3.11.0",
|
|
8
|
-
"@simple-module-py/ui": "*",
|
|
9
|
-
"react": "^19.0.0",
|
|
10
|
-
"react-dom": "^19.3.1"
|
|
11
|
-
},
|
|
12
|
-
"devDependencies": {
|
|
13
|
-
"@simple-module-py/tsconfig": "*"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"lucide-react": "^1.43.0",
|
|
17
|
-
"sonner": "^2.0.8"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
File without changes
|
{simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/models.py
RENAMED
|
File without changes
|
|
File without changes
|
{simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/ui/types.ts
RENAMED
|
File without changes
|
|
File without changes
|
{simple_module_feature_flags-0.0.46 → simple_module_feature_flags-0.0.48}/feature_flags/web/deps.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|