simple-module-feature-flags 0.0.49__tar.gz → 0.0.51__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.49 → simple_module_feature_flags-0.0.51}/PKG-INFO +5 -5
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/README.md +1 -1
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/core/constants.py +1 -11
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/core/invalidation.py +2 -2
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/core/service.py +16 -7
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/core/tenant_cleanup.py +1 -1
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/models.py +2 -2
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/module.py +5 -5
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/pages/i18n.generated.ts +1 -1
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/ui/components/FlagTable.tsx +5 -5
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/ui/components/ScopeCard.tsx +2 -1
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/web/deps.py +3 -3
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/web/endpoints/api.py +2 -2
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/web/endpoints/views.py +11 -4
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/pyproject.toml +4 -4
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/tests/core/invalidation/test_feature_flags_commit_invalidation.py +3 -3
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/tests/core/module/test_feature_flags_audit_links.py +1 -1
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/tests/core/module/test_feature_flags_menu_section.py +2 -2
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/tests/core/service/test_feature_flags_description_i18n.py +2 -2
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/tests/core/service/test_feature_flags_service.py +25 -2
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/tests/core/service/test_feature_flags_store_outage_fallback.py +1 -1
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/tests/core/tenancy/test_feature_flags_tenancy.py +5 -5
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/tests/core/tenant_cleanup/test_feature_flags_tenant_cleanup.py +4 -4
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/tests-js/feature_flags_Browse.test.tsx +21 -3
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/.gitignore +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/LICENSE +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/__init__.py +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/contracts/__init__.py +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/contracts/schemas.py +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/core/__init__.py +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/locales/de.json +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/locales/en.json +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/pages/Browse.tsx +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/py.typed +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/ui/components/TenantPicker.tsx +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/ui/components/ToggleConfirmDialog.tsx +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/ui/types.ts +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/web/__init__.py +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/web/endpoints/__init__.py +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/package.json +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/tests/conftest.py +0 -0
- {simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/tests/web/endpoints/test_feature_flags_api.py +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.51
|
|
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.51
|
|
25
|
+
Requires-Dist: simple-module-db==0.0.51
|
|
26
|
+
Requires-Dist: simple-module-hosting==0.0.51
|
|
27
27
|
Description-Content-Type: text/markdown
|
|
28
28
|
|
|
29
29
|
# simple_module_feature_flags
|
|
@@ -48,7 +48,7 @@ pip install simple_module_feature_flags
|
|
|
48
48
|
Declare a flag in your module:
|
|
49
49
|
|
|
50
50
|
```python
|
|
51
|
-
from simple_module_core.feature_flags import FeatureFlagDefinition, FeatureFlagRegistry
|
|
51
|
+
from simple_module_core.web.feature_flags import FeatureFlagDefinition, FeatureFlagRegistry
|
|
52
52
|
|
|
53
53
|
|
|
54
54
|
class OrdersModule(ModuleBase):
|
|
@@ -20,7 +20,7 @@ pip install simple_module_feature_flags
|
|
|
20
20
|
Declare a flag in your module:
|
|
21
21
|
|
|
22
22
|
```python
|
|
23
|
-
from simple_module_core.feature_flags import FeatureFlagDefinition, FeatureFlagRegistry
|
|
23
|
+
from simple_module_core.web.feature_flags import FeatureFlagDefinition, FeatureFlagRegistry
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
class OrdersModule(ModuleBase):
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"""Stable identifiers for the feature_flags module."""
|
|
2
2
|
|
|
3
|
-
from simple_module_core.
|
|
4
|
-
from simple_module_core.permissions import PermissionCatalogue
|
|
3
|
+
from simple_module_core.access.permissions import PermissionCatalogue
|
|
5
4
|
|
|
6
5
|
# Shown as a heading in the role editor, so it follows the same sentence case
|
|
7
6
|
# as the menu label and the page title rather than reading "Feature Flags"
|
|
@@ -16,15 +15,6 @@ class Permissions(
|
|
|
16
15
|
MANAGE = "feature_flags.manage"
|
|
17
16
|
|
|
18
17
|
|
|
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
|
-
|
|
28
18
|
# Prefix is load-bearing on SQLite, which has no per-module schemas.
|
|
29
19
|
TABLE_OVERRIDE = "feature_flags_override"
|
|
30
20
|
UQ_OVERRIDE_SCOPE_NAME = "uq_feature_flags_override_scope_scope_id_name"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"""Re-read flag overrides after commit or a remote invalidation."""
|
|
2
2
|
|
|
3
3
|
from fastapi import FastAPI
|
|
4
|
-
from simple_module_core.invalidation import Invalidation, InvalidationBus
|
|
5
|
-
from simple_module_core.invalidation_refresh import InvalidationRefresh
|
|
4
|
+
from simple_module_core.eventing.invalidation import Invalidation, InvalidationBus
|
|
5
|
+
from simple_module_core.eventing.invalidation_refresh import InvalidationRefresh
|
|
6
6
|
from simple_module_core.tenant_events import TENANT_DELETED_CHANNEL
|
|
7
7
|
|
|
8
8
|
from feature_flags.core.service import FeatureFlagService
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""FeatureFlagService — manages persisted overrides and syncs them to the registry.
|
|
2
2
|
|
|
3
3
|
Resolution semantics (tenant > system > default) live in
|
|
4
|
-
``simple_module_core.feature_flags``; this layer only persists overrides and
|
|
4
|
+
``simple_module_core.web.feature_flags``; this layer only persists overrides and
|
|
5
5
|
mirrors mutations into the registry.
|
|
6
6
|
"""
|
|
7
7
|
|
|
@@ -10,8 +10,9 @@ from __future__ import annotations
|
|
|
10
10
|
from collections.abc import Callable
|
|
11
11
|
|
|
12
12
|
from fastapi import FastAPI
|
|
13
|
-
from simple_module_core.feature_flags import FeatureFlagDefinition, FeatureFlagRegistry
|
|
13
|
+
from simple_module_core.web.feature_flags import FeatureFlagDefinition, FeatureFlagRegistry
|
|
14
14
|
from sqlalchemy import select
|
|
15
|
+
from sqlalchemy.exc import IntegrityError
|
|
15
16
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
16
17
|
from sqlmodel import col
|
|
17
18
|
|
|
@@ -172,11 +173,19 @@ class FeatureFlagService:
|
|
|
172
173
|
"""Upsert an override at the given scope and mirror it to the registry."""
|
|
173
174
|
existing = await self._find(scope, scope_id, name)
|
|
174
175
|
if existing is None:
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
176
|
+
try:
|
|
177
|
+
async with self.db.begin_nested():
|
|
178
|
+
existing = FeatureFlagOverride(
|
|
179
|
+
scope=scope, scope_id=scope_id, name=name, enabled=enabled
|
|
180
|
+
)
|
|
181
|
+
self.db.add(existing)
|
|
182
|
+
await self.db.flush()
|
|
183
|
+
except IntegrityError:
|
|
184
|
+
existing = await self._find(scope, scope_id, name)
|
|
185
|
+
if existing is None:
|
|
186
|
+
raise
|
|
187
|
+
existing.enabled = enabled
|
|
188
|
+
await self.db.flush()
|
|
180
189
|
elif existing.enabled != enabled:
|
|
181
190
|
existing.enabled = enabled
|
|
182
191
|
await self.db.flush()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"""Durable cleanup of tenant-scoped feature flag overrides."""
|
|
2
2
|
|
|
3
|
-
from simple_module_core.durable_events import DurableContext
|
|
3
|
+
from simple_module_core.eventing.durable_events import DurableContext
|
|
4
4
|
from simple_module_core.tenant_events import TenantDeleted
|
|
5
5
|
from sqlmodel import col, delete
|
|
6
6
|
|
{simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/models.py
RENAMED
|
@@ -12,8 +12,8 @@ A row's ``scope`` selects whether the override applies globally
|
|
|
12
12
|
|
|
13
13
|
from __future__ import annotations
|
|
14
14
|
|
|
15
|
-
from simple_module_db.base import create_module_base
|
|
16
|
-
from simple_module_db.mixins import AuditMixin
|
|
15
|
+
from simple_module_db.models.base import create_module_base
|
|
16
|
+
from simple_module_db.models.mixins import AuditMixin
|
|
17
17
|
from sqlalchemy import UniqueConstraint
|
|
18
18
|
from sqlmodel import Field
|
|
19
19
|
|
{simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/module.py
RENAMED
|
@@ -6,9 +6,9 @@ import logging
|
|
|
6
6
|
from typing import TYPE_CHECKING
|
|
7
7
|
|
|
8
8
|
from fastapi import FastAPI
|
|
9
|
-
from simple_module_core.
|
|
10
|
-
from simple_module_core.
|
|
11
|
-
from simple_module_core.
|
|
9
|
+
from simple_module_core.modules.module import ModuleBase, ModuleMeta
|
|
10
|
+
from simple_module_core.web.audit_links import AuditLink, AuditLinkRegistry
|
|
11
|
+
from simple_module_core.web.menu import MenuItem, MenuRegistry, MenuSection
|
|
12
12
|
|
|
13
13
|
from feature_flags.core.constants import (
|
|
14
14
|
AUDIT_LINK_LABEL,
|
|
@@ -24,8 +24,8 @@ from feature_flags.core.constants import (
|
|
|
24
24
|
)
|
|
25
25
|
|
|
26
26
|
if TYPE_CHECKING:
|
|
27
|
-
from simple_module_core.events import EventBus
|
|
28
|
-
from simple_module_core.invalidation import InvalidationBus
|
|
27
|
+
from simple_module_core.eventing.events import EventBus
|
|
28
|
+
from simple_module_core.eventing.invalidation import InvalidationBus
|
|
29
29
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
30
30
|
|
|
31
31
|
_logger = logging.getLogger(__name__)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '@simple-module-py/i18n';
|
|
2
2
|
|
|
3
|
-
// AUTO-GENERATED by simple_module_hosting.i18n_manifest — do not edit by hand.
|
|
3
|
+
// AUTO-GENERATED by simple_module_hosting.i18n.i18n_manifest — do not edit by hand.
|
|
4
4
|
// Regenerate by booting the host in development mode or `make gen-i18n`.
|
|
5
5
|
|
|
6
6
|
export const keys = {
|
|
@@ -31,7 +31,7 @@ interface Props {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
const HEAD =
|
|
34
|
-
'bg-secondary/40 text-[11px] font-semibold uppercase tracking-[0.08em] ' +
|
|
34
|
+
'bg-secondary/40 text-[11px] max-lg:text-xs font-semibold uppercase tracking-[0.08em] ' +
|
|
35
35
|
'text-muted-foreground sm:px-6';
|
|
36
36
|
|
|
37
37
|
export function FlagTable({ flags, tenantId, canManage, onToggle, onClear }: Props) {
|
|
@@ -44,7 +44,7 @@ export function FlagTable({ flags, tenantId, canManage, onToggle, onClear }: Pro
|
|
|
44
44
|
<Button
|
|
45
45
|
variant="link"
|
|
46
46
|
size="sm"
|
|
47
|
-
className="h-auto p-0 text-primary-
|
|
47
|
+
className="h-auto p-0 text-primary-text max-sm:min-h-11"
|
|
48
48
|
onClick={() => onClear(flag)}
|
|
49
49
|
>
|
|
50
50
|
{t(keys.feature_flags.table.clear_override)}
|
|
@@ -66,7 +66,7 @@ export function FlagTable({ flags, tenantId, canManage, onToggle, onClear }: Pro
|
|
|
66
66
|
<TableHeader>
|
|
67
67
|
<TableRow>
|
|
68
68
|
<TableHead className={HEAD}>{t(keys.feature_flags.table.name)}</TableHead>
|
|
69
|
-
<TableHead className={cn(HEAD, 'hidden
|
|
69
|
+
<TableHead className={cn(HEAD, 'hidden lg:table-cell')}>
|
|
70
70
|
{t(keys.feature_flags.table.description)}
|
|
71
71
|
</TableHead>
|
|
72
72
|
<TableHead className={cn(HEAD, 'hidden sm:table-cell')}>
|
|
@@ -89,13 +89,13 @@ export function FlagTable({ flags, tenantId, canManage, onToggle, onClear }: Pro
|
|
|
89
89
|
<div className="flex flex-wrap items-center gap-2">
|
|
90
90
|
<code className="font-mono text-sm font-medium">{flag.name}</code>
|
|
91
91
|
{flag.overridden && (
|
|
92
|
-
<Badge variant="outline" className="border-primary text-primary-
|
|
92
|
+
<Badge variant="outline" className="border-primary text-primary-text">
|
|
93
93
|
{t(keys.feature_flags.table.overridden)}
|
|
94
94
|
</Badge>
|
|
95
95
|
)}
|
|
96
96
|
</div>
|
|
97
97
|
</TableCell>
|
|
98
|
-
<TableCell className="hidden
|
|
98
|
+
<TableCell className="hidden lg:table-cell sm:px-6">
|
|
99
99
|
<span className="line-clamp-2 text-sm text-muted-foreground">
|
|
100
100
|
{flag.description || '—'}
|
|
101
101
|
</span>
|
|
@@ -2,6 +2,7 @@ import { Link } from '@inertiajs/react';
|
|
|
2
2
|
import { keys, useT } from '@simple-module-py/i18n';
|
|
3
3
|
import { InterpolatedText } from '@simple-module-py/ui/components/InterpolatedText';
|
|
4
4
|
import { Card } from '@simple-module-py/ui/components/ui/card';
|
|
5
|
+
import { TOUCH_TARGET_CLASS } from '@simple-module-py/ui/lib/utils';
|
|
5
6
|
import { TenantPicker } from './TenantPicker';
|
|
6
7
|
|
|
7
8
|
interface Props {
|
|
@@ -42,7 +43,7 @@ export function ScopeCard({ tenantId, tenants, auditLogUrl, onSelect }: Props) {
|
|
|
42
43
|
{auditLogUrl && (
|
|
43
44
|
<Link
|
|
44
45
|
href={auditLogUrl}
|
|
45
|
-
className=
|
|
46
|
+
className={`inline-flex items-center text-xs font-medium text-primary-text hover:underline sm:ml-auto ${TOUCH_TARGET_CLASS}`}
|
|
46
47
|
>
|
|
47
48
|
{t(keys.feature_flags.browse.view_history)}
|
|
48
49
|
</Link>
|
{simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/web/deps.py
RENAMED
|
@@ -5,9 +5,9 @@ from __future__ import annotations
|
|
|
5
5
|
from typing import Annotated
|
|
6
6
|
|
|
7
7
|
from fastapi import Depends, HTTPException, Request
|
|
8
|
-
from simple_module_core.
|
|
9
|
-
from simple_module_core.
|
|
10
|
-
from simple_module_db.deps import get_db
|
|
8
|
+
from simple_module_core.access.tenancy import tenant_exists
|
|
9
|
+
from simple_module_core.web.feature_flags import FeatureFlagRegistry
|
|
10
|
+
from simple_module_db.engine.deps import get_db
|
|
11
11
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
12
12
|
|
|
13
13
|
from feature_flags.core.service import FeatureFlagService
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from fastapi import APIRouter, Depends, HTTPException
|
|
6
|
-
from simple_module_core.feature_flags import FeatureFlagRegistry
|
|
7
|
-
from simple_module_hosting.permissions import RequiresPermission
|
|
6
|
+
from simple_module_core.web.feature_flags import FeatureFlagRegistry
|
|
7
|
+
from simple_module_hosting.auth.permissions import RequiresPermission
|
|
8
8
|
|
|
9
9
|
from feature_flags.contracts.schemas import FeatureFlagView, ToggleRequest
|
|
10
10
|
from feature_flags.core.constants import SCOPE_TENANT, Permissions
|
|
@@ -9,9 +9,10 @@ frontend doesn't need separate routes per scope.
|
|
|
9
9
|
from __future__ import annotations
|
|
10
10
|
|
|
11
11
|
from fastapi import APIRouter, Depends, Request
|
|
12
|
-
from simple_module_hosting.
|
|
13
|
-
from simple_module_hosting.
|
|
14
|
-
from simple_module_hosting.
|
|
12
|
+
from simple_module_hosting.auth.api_equivalent import api_equivalent
|
|
13
|
+
from simple_module_hosting.auth.permissions import RequiresPermission
|
|
14
|
+
from simple_module_hosting.frontend.inertia_deps import InertiaDep
|
|
15
|
+
from simple_module_hosting.i18n.i18n_deps import TranslatorDep
|
|
15
16
|
from simple_module_inertia import InertiaResponse
|
|
16
17
|
from starlette.responses import RedirectResponse
|
|
17
18
|
|
|
@@ -96,6 +97,8 @@ async def browse(
|
|
|
96
97
|
response_model=None,
|
|
97
98
|
dependencies=[
|
|
98
99
|
Depends(RequiresPermission(Permissions.MANAGE)),
|
|
100
|
+
Depends(api_equivalent("PUT", "/api/feature_flags/{name}")),
|
|
101
|
+
Depends(api_equivalent("PUT", "/api/feature_flags/tenant/{tenant_id}/{name}")),
|
|
99
102
|
Depends(require_known_tenant),
|
|
100
103
|
],
|
|
101
104
|
)
|
|
@@ -117,7 +120,11 @@ async def toggle_action(
|
|
|
117
120
|
@router.post(
|
|
118
121
|
"/{name}/clear",
|
|
119
122
|
response_model=None,
|
|
120
|
-
dependencies=[
|
|
123
|
+
dependencies=[
|
|
124
|
+
Depends(RequiresPermission(Permissions.MANAGE)),
|
|
125
|
+
Depends(api_equivalent("DELETE", "/api/feature_flags/{name}")),
|
|
126
|
+
Depends(api_equivalent("DELETE", "/api/feature_flags/tenant/{tenant_id}/{name}")),
|
|
127
|
+
],
|
|
121
128
|
)
|
|
122
129
|
async def clear_action(
|
|
123
130
|
name: str,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "simple_module_feature_flags"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.51"
|
|
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.51",
|
|
25
|
+
"simple_module_db==0.0.51",
|
|
26
|
+
"simple_module_hosting==0.0.51",
|
|
27
27
|
]
|
|
28
28
|
|
|
29
29
|
[project.entry-points.simple_module]
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
import pytest
|
|
4
4
|
from feature_flags.core.service import FeatureFlagService
|
|
5
5
|
from feature_flags.models import FeatureFlagOverride
|
|
6
|
-
from simple_module_core.
|
|
7
|
-
from simple_module_core.
|
|
8
|
-
from simple_module_db.transaction import finalize_session, rollback_session
|
|
6
|
+
from simple_module_core.eventing.invalidation import Invalidation
|
|
7
|
+
from simple_module_core.web.feature_flags import FeatureFlagDefinition, FeatureFlagRegistry
|
|
8
|
+
from simple_module_db.engine.transaction import finalize_session, rollback_session
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
@pytest.mark.parametrize("commit", [False, True])
|
|
@@ -24,7 +24,7 @@ from feature_flags.core.constants import (
|
|
|
24
24
|
from feature_flags.models import FeatureFlagOverride
|
|
25
25
|
from feature_flags.module import FeatureFlagsModule
|
|
26
26
|
from feature_flags.web.endpoints.views import _audit_log_url
|
|
27
|
-
from simple_module_core.audit_links import AuditLinkRegistry
|
|
27
|
+
from simple_module_core.web.audit_links import AuditLinkRegistry
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
def _request_with_modules(*names: str):
|
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from feature_flags.core.constants import MENU_URL
|
|
6
6
|
from feature_flags.module import FeatureFlagsModule
|
|
7
|
-
from simple_module_core.menu import MenuRegistry, MenuSection
|
|
7
|
+
from simple_module_core.web.menu import MenuRegistry, MenuSection
|
|
8
8
|
|
|
9
9
|
|
|
10
10
|
def test_feature_flags_menu_item_is_in_admin_sidebar() -> None:
|
|
@@ -19,7 +19,7 @@ def test_permission_group_matches_the_menu_label() -> None:
|
|
|
19
19
|
"""The role editor lists this group beside the sidebar entry it governs;
|
|
20
20
|
"Feature Flags" next to "Feature flags" reads as two different things."""
|
|
21
21
|
from feature_flags.core.constants import MENU_LABEL, PERM_GROUP
|
|
22
|
-
from simple_module_core.permissions import PermissionRegistry
|
|
22
|
+
from simple_module_core.access.permissions import PermissionRegistry
|
|
23
23
|
|
|
24
24
|
registry = PermissionRegistry()
|
|
25
25
|
FeatureFlagsModule().register_permissions(registry)
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
5
|
from feature_flags.core.service import FeatureFlagService
|
|
6
|
-
from simple_module_core.
|
|
7
|
-
from simple_module_core.
|
|
6
|
+
from simple_module_core.localization.i18n import Translator
|
|
7
|
+
from simple_module_core.web.feature_flags import FeatureFlagDefinition, FeatureFlagRegistry
|
|
8
8
|
|
|
9
9
|
PUBLIC_UPLOADS = "file_storage.public_uploads"
|
|
10
10
|
|
|
@@ -4,8 +4,8 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
from feature_flags.core.constants import SCOPE_TENANT
|
|
6
6
|
from feature_flags.core.service import FeatureFlagService
|
|
7
|
-
from simple_module_core.feature_flags import FeatureFlagDefinition, FeatureFlagRegistry
|
|
8
|
-
from simple_module_db.transaction import finalize_session
|
|
7
|
+
from simple_module_core.web.feature_flags import FeatureFlagDefinition, FeatureFlagRegistry
|
|
8
|
+
from simple_module_db.engine.transaction import finalize_session
|
|
9
9
|
from sqlalchemy.ext.asyncio import AsyncSession
|
|
10
10
|
|
|
11
11
|
|
|
@@ -219,3 +219,26 @@ class TestFeatureFlagsModuleLifecycle:
|
|
|
219
219
|
assert sm.feature_flags.is_enabled("file_storage.public_uploads", tenant_id="acme") is False
|
|
220
220
|
# other tenant: still inherits system
|
|
221
221
|
assert sm.feature_flags.is_enabled("file_storage.public_uploads", tenant_id="other") is True
|
|
222
|
+
|
|
223
|
+
|
|
224
|
+
async def test_racing_override_insert_recovers_without_rolling_back_other_writes(
|
|
225
|
+
db_session, monkeypatch
|
|
226
|
+
):
|
|
227
|
+
from feature_flags.models import FeatureFlagOverride
|
|
228
|
+
|
|
229
|
+
svc = FeatureFlagService(db_session)
|
|
230
|
+
await svc.set_override("raced", False)
|
|
231
|
+
await svc.set_override("unrelated", True)
|
|
232
|
+
find = svc._find
|
|
233
|
+
calls = 0
|
|
234
|
+
|
|
235
|
+
async def miss_once(*args):
|
|
236
|
+
nonlocal calls
|
|
237
|
+
calls += 1
|
|
238
|
+
return None if calls == 1 else await find(*args)
|
|
239
|
+
|
|
240
|
+
monkeypatch.setattr(svc, "_find", miss_once)
|
|
241
|
+
result = await svc.set_override("raced", True)
|
|
242
|
+
assert result.enabled is True
|
|
243
|
+
assert {row.name for row in await svc.list_overrides()} == {"raced", "unrelated"}
|
|
244
|
+
assert await db_session.get(FeatureFlagOverride, result.id) is not None
|
|
@@ -15,7 +15,7 @@ from unittest.mock import MagicMock
|
|
|
15
15
|
|
|
16
16
|
import pytest
|
|
17
17
|
from feature_flags.module import FeatureFlagsModule
|
|
18
|
-
from simple_module_core.feature_flags import FeatureFlagDefinition, FeatureFlagRegistry
|
|
18
|
+
from simple_module_core.web.feature_flags import FeatureFlagDefinition, FeatureFlagRegistry
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
class _BoomService:
|
|
@@ -9,10 +9,10 @@ from __future__ import annotations
|
|
|
9
9
|
|
|
10
10
|
import pytest
|
|
11
11
|
from fastapi import Depends
|
|
12
|
-
from feature_flags.core.constants import
|
|
12
|
+
from feature_flags.core.constants import Permissions
|
|
13
13
|
from feature_flags.core.service import FeatureFlagService
|
|
14
|
-
from simple_module_core.
|
|
15
|
-
from simple_module_core.
|
|
14
|
+
from simple_module_core.access.tenancy import TenantRole, tenant_role
|
|
15
|
+
from simple_module_core.web.feature_flags import FeatureFlagRegistry, require_flag
|
|
16
16
|
|
|
17
17
|
FLAG = "file_storage.public_uploads" # default off
|
|
18
18
|
SYSTEM = f"/api/feature_flags/{FLAG}"
|
|
@@ -102,8 +102,8 @@ class TestTenantRolesNeverManageFlags:
|
|
|
102
102
|
@pytest.mark.parametrize("role", list(TenantRole))
|
|
103
103
|
def test_no_tenant_role_holds_flag_permissions(self, app, role):
|
|
104
104
|
mapped = set(app.state.sm.permissions.role_map[tenant_role(role)])
|
|
105
|
-
assert
|
|
106
|
-
assert
|
|
105
|
+
assert Permissions.MANAGE not in mapped
|
|
106
|
+
assert Permissions.VIEW not in mapped
|
|
107
107
|
|
|
108
108
|
@pytest.mark.parametrize("role", list(TenantRole))
|
|
109
109
|
async def test_tenant_member_cannot_reach_the_admin_endpoints(self, tenant_client, role):
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
from feature_flags.core.constants import SCOPE_SYSTEM, SCOPE_TENANT
|
|
4
4
|
from feature_flags.models import FeatureFlagOverride
|
|
5
5
|
from feature_flags.module import FeatureFlagsModule
|
|
6
|
-
from simple_module_core.durable_events import DurableContext, event_key
|
|
7
|
-
from simple_module_core.events import EventBus
|
|
6
|
+
from simple_module_core.eventing.durable_events import DurableContext, event_key
|
|
7
|
+
from simple_module_core.eventing.events import EventBus
|
|
8
8
|
from simple_module_core.tenant_events import TenantDeleted
|
|
9
9
|
from sqlmodel import select
|
|
10
10
|
|
|
@@ -38,7 +38,7 @@ async def test_feature_flags_tenant_event_clears_only_deleted_tenant():
|
|
|
38
38
|
from types import SimpleNamespace
|
|
39
39
|
|
|
40
40
|
from fastapi import FastAPI
|
|
41
|
-
from simple_module_core.feature_flags import FeatureFlagRegistry
|
|
41
|
+
from simple_module_core.web.feature_flags import FeatureFlagRegistry
|
|
42
42
|
|
|
43
43
|
app = FastAPI()
|
|
44
44
|
registry = FeatureFlagRegistry()
|
|
@@ -57,7 +57,7 @@ async def test_feature_flags_tenant_event_clears_only_deleted_tenant():
|
|
|
57
57
|
|
|
58
58
|
|
|
59
59
|
async def test_feature_flags_remote_tenant_deletion_clears_registry(app):
|
|
60
|
-
from simple_module_core.invalidation import Invalidation
|
|
60
|
+
from simple_module_core.eventing.invalidation import Invalidation
|
|
61
61
|
from simple_module_core.tenant_events import TENANT_DELETED_CHANNEL
|
|
62
62
|
|
|
63
63
|
registry = app.state.sm.feature_flags
|
|
@@ -11,9 +11,7 @@ const visit = vi.hoisted(() => vi.fn());
|
|
|
11
11
|
|
|
12
12
|
vi.mock('@inertiajs/react', () => ({
|
|
13
13
|
Head: () => null,
|
|
14
|
-
Link: ({ children,
|
|
15
|
-
<a href={href}>{children}</a>
|
|
16
|
-
),
|
|
14
|
+
Link: ({ children, ...props }: React.ComponentProps<'a'>) => <a {...props}>{children}</a>,
|
|
17
15
|
router: { post, visit },
|
|
18
16
|
usePage: () => ({ props: state.props }),
|
|
19
17
|
}));
|
|
@@ -193,3 +191,23 @@ describe('feature_flags Browse', () => {
|
|
|
193
191
|
expect(visit).toHaveBeenCalledWith('/admin/feature-flags/?tenant_id=new-co');
|
|
194
192
|
});
|
|
195
193
|
});
|
|
194
|
+
|
|
195
|
+
it('keeps descriptions out of the tablet column budget (#1184)', () => {
|
|
196
|
+
setProps();
|
|
197
|
+
render(<Browse {...(state.props as ComponentProps<typeof Browse>)} />);
|
|
198
|
+
expect(screen.getByRole('columnheader', { name: table.description })).toHaveClass(
|
|
199
|
+
'hidden',
|
|
200
|
+
'lg:table-cell',
|
|
201
|
+
);
|
|
202
|
+
expect(screen.getByText('New search').closest('td')).toHaveClass('hidden', 'lg:table-cell');
|
|
203
|
+
expect(screen.getByRole('switch', { name: 'beta_search' })).toBeInTheDocument();
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('gives the history link a narrow/coarse touch target (#1184)', () => {
|
|
207
|
+
setProps({ audit_log_url: '/admin/audit-log/' });
|
|
208
|
+
render(<Browse {...(state.props as ComponentProps<typeof Browse>)} />);
|
|
209
|
+
expect(screen.getByRole('link', { name: browse.view_history })).toHaveClass(
|
|
210
|
+
'max-lg:min-h-11',
|
|
211
|
+
'pointer-coarse:min-h-11',
|
|
212
|
+
);
|
|
213
|
+
});
|
|
File without changes
|
|
File without changes
|
{simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/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
|
{simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/py.typed
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{simple_module_feature_flags-0.0.49 → simple_module_feature_flags-0.0.51}/feature_flags/ui/types.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|