simple-module-sharing 0.0.42__tar.gz → 0.0.44__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/PKG-INFO +6 -6
  2. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/README.md +1 -1
  3. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/package.json +1 -1
  4. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/pyproject.toml +5 -5
  5. simple_module_sharing-0.0.44/sharing/constants.py +11 -0
  6. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/sharing/contracts/schemas.py +1 -1
  7. simple_module_sharing-0.0.44/sharing/core/__init__.py +5 -0
  8. {simple_module_sharing-0.0.42/sharing → simple_module_sharing-0.0.44/sharing/core}/constants.py +5 -0
  9. {simple_module_sharing-0.0.42/sharing → simple_module_sharing-0.0.44/sharing/core}/policy.py +2 -2
  10. {simple_module_sharing-0.0.42/sharing → simple_module_sharing-0.0.44/sharing/core}/service.py +4 -4
  11. {simple_module_sharing-0.0.42/sharing → simple_module_sharing-0.0.44/sharing/core}/services.py +1 -1
  12. {simple_module_sharing-0.0.42/sharing → simple_module_sharing-0.0.44/sharing/core}/user_cleanup.py +1 -1
  13. simple_module_sharing-0.0.44/sharing/endpoints/__init__.py +1 -0
  14. simple_module_sharing-0.0.44/sharing/endpoints/api.py +11 -0
  15. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/sharing/models.py +1 -1
  16. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/sharing/module.py +9 -9
  17. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/sharing/pages/Admin.tsx +2 -2
  18. simple_module_sharing-0.0.44/sharing/policy.py +11 -0
  19. simple_module_sharing-0.0.44/sharing/web/__init__.py +1 -0
  20. {simple_module_sharing-0.0.42/sharing → simple_module_sharing-0.0.44/sharing/web}/deps.py +2 -2
  21. {simple_module_sharing-0.0.42/sharing → simple_module_sharing-0.0.44/sharing/web}/endpoints/api.py +4 -4
  22. {simple_module_sharing-0.0.42/sharing → simple_module_sharing-0.0.44/sharing/web}/endpoints/views.py +4 -4
  23. {simple_module_sharing-0.0.42/sharing → simple_module_sharing-0.0.44/sharing/web}/present.py +1 -1
  24. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/tests/_sharing_support.py +1 -1
  25. simple_module_sharing-0.0.44/tests/conftest.py +4 -0
  26. {simple_module_sharing-0.0.42/tests → simple_module_sharing-0.0.44/tests/core/service}/test_sharing_custom_roles.py +3 -3
  27. {simple_module_sharing-0.0.42/tests → simple_module_sharing-0.0.44/tests/core/service}/test_sharing_service.py +2 -2
  28. {simple_module_sharing-0.0.42/tests → simple_module_sharing-0.0.44/tests/web/endpoints}/test_sharing_http.py +5 -5
  29. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/.gitignore +0 -0
  30. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/LICENSE +0 -0
  31. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/sharing/__init__.py +0 -0
  32. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/sharing/contracts/__init__.py +0 -0
  33. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/sharing/contracts/cleanup.py +0 -0
  34. {simple_module_sharing-0.0.42/sharing → simple_module_sharing-0.0.44/sharing/core}/audience.py +0 -0
  35. {simple_module_sharing-0.0.42/sharing → simple_module_sharing-0.0.44/sharing/core}/settings.py +0 -0
  36. {simple_module_sharing-0.0.42/sharing → simple_module_sharing-0.0.44/sharing/core}/tenant_cleanup.py +0 -0
  37. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/sharing/locales/de.json +0 -0
  38. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/sharing/locales/en.json +0 -0
  39. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/sharing/py.typed +0 -0
  40. {simple_module_sharing-0.0.42/sharing/pages → simple_module_sharing-0.0.44/sharing/ui}/components/ShareTable.tsx +0 -0
  41. {simple_module_sharing-0.0.42/sharing/pages → simple_module_sharing-0.0.44/sharing/ui}/types.ts +0 -0
  42. {simple_module_sharing-0.0.42/sharing → simple_module_sharing-0.0.44/sharing/web}/endpoints/__init__.py +0 -0
  43. {simple_module_sharing-0.0.42/tests → simple_module_sharing-0.0.44/tests/core/audience}/test_sharing_tenant_audience.py +0 -0
  44. {simple_module_sharing-0.0.42/tests → simple_module_sharing-0.0.44/tests/core/cleanup}/test_sharing_resource_cleanup.py +0 -0
  45. {simple_module_sharing-0.0.42/tests → simple_module_sharing-0.0.44/tests/core/cleanup}/test_sharing_tenant_cleanup.py +0 -0
  46. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/tests-js/sharing_Admin.test.tsx +0 -0
  47. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/tests-js/sharing_Admin_errors.test.tsx +0 -0
  48. {simple_module_sharing-0.0.42 → simple_module_sharing-0.0.44}/tsconfig.json +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: simple_module_sharing
3
- Version: 0.0.42
3
+ Version: 0.0.44
4
4
  Summary: Generic resource shares (owner / shared-with-user) for simple_module resource-scoped access
5
5
  Project-URL: Homepage, https://github.com/antosubash/simple_module_python
6
6
  Project-URL: Repository, https://github.com/antosubash/simple_module_python
@@ -11,10 +11,10 @@ License-Expression: MIT
11
11
  License-File: LICENSE
12
12
  Keywords: access-control,permissions,sharing,simple-module
13
13
  Requires-Python: >=3.12
14
- Requires-Dist: simple-module-core==0.0.42
15
- Requires-Dist: simple-module-db==0.0.42
16
- Requires-Dist: simple-module-hosting==0.0.42
17
- Requires-Dist: simple-module-inertia==0.0.42
14
+ Requires-Dist: simple-module-core==0.0.44
15
+ Requires-Dist: simple-module-db==0.0.44
16
+ Requires-Dist: simple-module-hosting==0.0.44
17
+ Requires-Dist: simple-module-inertia==0.0.44
18
18
  Description-Content-Type: text/markdown
19
19
 
20
20
  # simple_module_sharing
@@ -43,7 +43,7 @@ Declare the resource type in the owning module and hand the policy a
43
43
  `share_exists` factory:
44
44
 
45
45
  ```python
46
- from sharing.policy import share_exists_for
46
+ from sharing.core.policy import share_exists_for
47
47
 
48
48
  NOTE_POLICY = OwnedResourcePolicy(
49
49
  Note.owner_id,
@@ -24,7 +24,7 @@ Declare the resource type in the owning module and hand the policy a
24
24
  `share_exists` factory:
25
25
 
26
26
  ```python
27
- from sharing.policy import share_exists_for
27
+ from sharing.core.policy import share_exists_for
28
28
 
29
29
  NOTE_POLICY = OwnedResourcePolicy(
30
30
  Note.owner_id,
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simple-module-py/sharing",
3
- "version": "0.0.42",
3
+ "version": "0.0.44",
4
4
  "private": true,
5
5
  "description": "Frontend assets for the Sharing module",
6
6
  "peerDependencies": {
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "simple_module_sharing"
3
- version = "0.0.42"
3
+ version = "0.0.44"
4
4
  description = "Generic resource shares (owner / shared-with-user) for simple_module resource-scoped access"
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -9,10 +9,10 @@ requires-python = ">=3.12"
9
9
  authors = [{ name = "Anto Subash", email = "antosubash@live.com" }]
10
10
  keywords = ["simple-module", "sharing", "permissions", "access-control"]
11
11
  dependencies = [
12
- "simple_module_core==0.0.42",
13
- "simple_module_db==0.0.42",
14
- "simple_module_hosting==0.0.42",
15
- "simple_module_inertia==0.0.42",
12
+ "simple_module_core==0.0.44",
13
+ "simple_module_db==0.0.44",
14
+ "simple_module_hosting==0.0.44",
15
+ "simple_module_inertia==0.0.44",
16
16
  ]
17
17
 
18
18
  [project.entry-points.simple_module]
@@ -0,0 +1,11 @@
1
+ """Moved to :mod:`sharing.core.constants`; this alias goes in 0.0.46 (module layout)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib
6
+ import sys
7
+
8
+ from simple_module_core.deprecation import deprecated_module
9
+
10
+ deprecated_module("sharing.constants", remove_in="0.0.46", use="sharing.core.constants")
11
+ sys.modules[__name__] = importlib.import_module("sharing.core.constants")
@@ -8,7 +8,7 @@ from datetime import datetime
8
8
  from simple_module_core.resources import ACTION_VIEW
9
9
  from sqlmodel import Field, SQLModel
10
10
 
11
- from sharing.constants import RESOURCE_ID_MAX, RESOURCE_TYPE_MAX, ROLE_MAX, SUBJECT_ID_MAX
11
+ from sharing.core.constants import RESOURCE_ID_MAX, RESOURCE_TYPE_MAX, ROLE_MAX, SUBJECT_ID_MAX
12
12
 
13
13
 
14
14
  class ShareGrant(SQLModel):
@@ -0,0 +1,5 @@
1
+ """What every sharing feature builds on.
2
+
3
+ Constants, settings, the services container, the share service, policies,
4
+ audiences and cleanup hooks.
5
+ """
@@ -63,3 +63,8 @@ ERR_UNKNOWN_GRANTEE: Final = "Unknown user"
63
63
  ERR_BAD_ROLE: Final = "This role cannot be granted on this resource type"
64
64
  ERR_EXPIRED: Final = "expires_at must be in the future"
65
65
  ERR_SELF: Final = "You cannot share a resource with yourself"
66
+
67
+ # Durable handler names key undelivered outbox rows, so they keep the import
68
+ # path the handlers had before the module-layout move (renaming strands rows).
69
+ TENANT_CLEANUP_HANDLER: Final = "sharing.tenant_cleanup.purge_tenant_data"
70
+ USER_CLEANUP_HANDLER: Final = "sharing.user_cleanup.purge_user_shares"
@@ -2,7 +2,7 @@
2
2
 
3
3
  ::
4
4
 
5
- from sharing.policy import share_exists_for
5
+ from sharing.core.policy import share_exists_for
6
6
 
7
7
  NOTE_POLICY = OwnedResourcePolicy(
8
8
  Note.owner_id,
@@ -22,7 +22,7 @@ from simple_module_core.resources import ResourcePrincipal
22
22
  from sqlalchemy import String, cast, func, inspect, or_
23
23
  from sqlmodel import exists, select
24
24
 
25
- from sharing.constants import ROLE_IMPLIES, SUBJECT_USER
25
+ from sharing.core.constants import ROLE_IMPLIES, SUBJECT_USER
26
26
  from sharing.models import ResourceShare
27
27
 
28
28
 
@@ -25,8 +25,9 @@ from sqlalchemy.exc import IntegrityError
25
25
  from sqlalchemy.ext.asyncio import AsyncSession
26
26
  from sqlmodel import select
27
27
 
28
- from sharing.audience import Audience, OpenAudience
29
- from sharing.constants import (
28
+ from sharing.contracts.schemas import ShareGrant
29
+ from sharing.core.audience import Audience, OpenAudience
30
+ from sharing.core.constants import (
30
31
  ERR_BAD_ROLE,
31
32
  ERR_EXPIRED,
32
33
  ERR_FORBIDDEN,
@@ -37,9 +38,8 @@ from sharing.constants import (
37
38
  PERM_MANAGE,
38
39
  SUBJECT_USER,
39
40
  )
40
- from sharing.contracts.schemas import ShareGrant
41
+ from sharing.core.policy import resolve_roles, row_id
41
42
  from sharing.models import ResourceShare
42
- from sharing.policy import resolve_roles, row_id
43
43
 
44
44
 
45
45
  class SharingError(Exception):
@@ -12,7 +12,7 @@ from __future__ import annotations
12
12
 
13
13
  from dataclasses import dataclass
14
14
 
15
- from sharing.settings import SharingSettings
15
+ from sharing.core.settings import SharingSettings
16
16
 
17
17
 
18
18
  @dataclass
@@ -8,7 +8,7 @@ from simple_module_core.durable_events import DurableContext
8
8
  from simple_module_db import all_tenants
9
9
  from sqlmodel import col, delete
10
10
 
11
- from sharing.constants import SUBJECT_USER
11
+ from sharing.core.constants import SUBJECT_USER
12
12
  from sharing.models import ResourceShare
13
13
 
14
14
  if TYPE_CHECKING:
@@ -0,0 +1 @@
1
+ """Deprecated package path: the endpoints moved to :mod:`sharing.web.endpoints` (module layout)."""
@@ -0,0 +1,11 @@
1
+ """Moved to :mod:`sharing.web.endpoints.api`; this alias goes in 0.0.46 (module layout)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib
6
+ import sys
7
+
8
+ from simple_module_core.deprecation import deprecated_module
9
+
10
+ deprecated_module("sharing.endpoints.api", remove_in="0.0.46", use="sharing.web.endpoints.api")
11
+ sys.modules[__name__] = importlib.import_module("sharing.web.endpoints.api")
@@ -10,7 +10,7 @@ from simple_module_db.mixins import AuditMixin, MultiTenantMixin
10
10
  from sqlalchemy import Index, UniqueConstraint
11
11
  from sqlmodel import Field
12
12
 
13
- from sharing.constants import (
13
+ from sharing.core.constants import (
14
14
  IX_SHARE_RESOURCE,
15
15
  RESOURCE_ID_MAX,
16
16
  RESOURCE_TYPE_MAX,
@@ -12,7 +12,7 @@ from simple_module_core.menu import MenuItem, MenuRegistry, MenuSection
12
12
  from simple_module_core.module_settings import register_module_settings
13
13
  from simple_module_core.tenancy import TenantRole, tenant_role
14
14
 
15
- from sharing import constants as c
15
+ from sharing.core import constants as c
16
16
 
17
17
  if TYPE_CHECKING:
18
18
  from fastapi import APIRouter, FastAPI
@@ -31,27 +31,27 @@ class SharingModule(ModuleBase):
31
31
  def register_event_handlers(self, bus: EventBus, app: FastAPI | None = None) -> None:
32
32
  from simple_module_core.tenant_events import TenantDeleted
33
33
 
34
- from sharing.tenant_cleanup import purge_tenant_data
34
+ from sharing.core.tenant_cleanup import purge_tenant_data
35
35
 
36
- bus.subscribe_durable(TenantDeleted, purge_tenant_data)
36
+ bus.subscribe_durable(TenantDeleted, purge_tenant_data, name=c.TENANT_CLEANUP_HANDLER)
37
37
 
38
38
  from simple_module_core.user_events import UserDeleted
39
39
 
40
- from sharing.user_cleanup import purge_user_shares
40
+ from sharing.core.user_cleanup import purge_user_shares
41
41
 
42
- bus.subscribe_durable(UserDeleted, purge_user_shares)
42
+ bus.subscribe_durable(UserDeleted, purge_user_shares, name=c.USER_CLEANUP_HANDLER)
43
43
 
44
44
  def register_settings(self, app: FastAPI) -> None:
45
- from sharing.services import SharingServices
46
- from sharing.settings import SharingSettings
45
+ from sharing.core.services import SharingServices
46
+ from sharing.core.settings import SharingSettings
47
47
 
48
48
  register_module_settings(
49
49
  app, c.MODULE_PACKAGE, SharingSettings, lambda s: SharingServices(settings=s)
50
50
  )
51
51
 
52
52
  def register_routes(self, api_router: APIRouter, view_router: APIRouter) -> None:
53
- from sharing.endpoints.api import router as api
54
- from sharing.endpoints.views import router as views
53
+ from sharing.web.endpoints.api import router as api
54
+ from sharing.web.endpoints.views import router as views
55
55
 
56
56
  api_router.include_router(api)
57
57
  view_router.include_router(views)
@@ -8,8 +8,8 @@ import { AdminLayout } from '@simple-module-py/ui/layouts/AdminLayout';
8
8
  import { Building2, Trash2 } from 'lucide-react';
9
9
  import { useState } from 'react';
10
10
  import { toast } from 'sonner';
11
- import { ShareTable } from './components/ShareTable';
12
- import type { Share } from './types';
11
+ import { ShareTable } from '../ui/components/ShareTable';
12
+ import type { Share } from '../ui/types';
13
13
 
14
14
  interface Props {
15
15
  shares: Share[];
@@ -0,0 +1,11 @@
1
+ """Moved to :mod:`sharing.core.policy`; this alias goes in 0.0.46 (module layout)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import importlib
6
+ import sys
7
+
8
+ from simple_module_core.deprecation import deprecated_module
9
+
10
+ deprecated_module("sharing.policy", remove_in="0.0.46", use="sharing.core.policy")
11
+ sys.modules[__name__] = importlib.import_module("sharing.core.policy")
@@ -0,0 +1 @@
1
+ """The HTTP side: request deps, share presentation and the REST and Inertia endpoints."""
@@ -9,8 +9,8 @@ from simple_module_core.user_directory import get_user_directory
9
9
  from simple_module_db.deps import get_db
10
10
  from sqlalchemy.ext.asyncio import AsyncSession
11
11
 
12
- from sharing.audience import Audience
13
- from sharing.service import SharingError, SharingService
12
+ from sharing.core.audience import Audience
13
+ from sharing.core.service import SharingError, SharingService
14
14
 
15
15
 
16
16
  async def get_sharing_service(
@@ -14,11 +14,11 @@ from simple_module_core.user_directory import get_user_directory
14
14
  from simple_module_hosting.permissions import RequiresPermission
15
15
  from simple_module_hosting.resource_deps import resource_principal
16
16
 
17
- from sharing.constants import PERM_SHARE
18
17
  from sharing.contracts.schemas import ShareGrant, ShareOut
19
- from sharing.deps import SharingServiceDep, http_error
20
- from sharing.present import present_shares
21
- from sharing.service import SharingError
18
+ from sharing.core.constants import PERM_SHARE
19
+ from sharing.core.service import SharingError
20
+ from sharing.web.deps import SharingServiceDep, http_error
21
+ from sharing.web.present import present_shares
22
22
 
23
23
  router = APIRouter(prefix="/shares", dependencies=[Depends(RequiresPermission(PERM_SHARE))])
24
24
 
@@ -16,11 +16,11 @@ from simple_module_inertia import InertiaResponse
16
16
  from sqlmodel import col, select
17
17
  from starlette.responses import RedirectResponse
18
18
 
19
- from sharing.constants import ADMIN_URL, PAGE_ADMIN, PERM_MANAGE, PERM_VIEW
20
- from sharing.deps import SharingServiceDep, http_error
19
+ from sharing.core.constants import ADMIN_URL, PAGE_ADMIN, PERM_MANAGE, PERM_VIEW
20
+ from sharing.core.service import SharingError
21
21
  from sharing.models import ResourceShare
22
- from sharing.present import present_shares
23
- from sharing.service import SharingError
22
+ from sharing.web.deps import SharingServiceDep, http_error
23
+ from sharing.web.present import present_shares
24
24
 
25
25
  router = APIRouter()
26
26
 
@@ -8,8 +8,8 @@ from typing import Any
8
8
 
9
9
  from simple_module_core.user_directory import UserDirectory, resolve_user_labels
10
10
 
11
- from sharing.audience import Audience, OpenAudience
12
11
  from sharing.contracts.schemas import ShareOut
12
+ from sharing.core.audience import Audience, OpenAudience
13
13
  from sharing.models import ResourceShare
14
14
 
15
15
 
@@ -6,7 +6,7 @@ import uuid
6
6
  from collections.abc import Collection
7
7
  from typing import Any
8
8
 
9
- from sharing.policy import share_exists_for
9
+ from sharing.core.policy import share_exists_for
10
10
  from simple_module_core.resources import ResourceType, ResourceTypeRegistry
11
11
  from simple_module_core.user_directory import DirectoryUser
12
12
  from simple_module_db.resource_policy import OwnedResourcePolicy, select_by_id
@@ -0,0 +1,4 @@
1
+ """Fixtures shared by every sharing test folder.
2
+
3
+ Its presence puts this directory on ``sys.path``, so ``_sharing_support`` imports.
4
+ """
@@ -7,10 +7,10 @@ from datetime import timedelta
7
7
 
8
8
  import pytest
9
9
  from _sharing_support import FakeDirectory, SharingTestNote, create_note_table
10
- from sharing.constants import ROLE_MAX
11
10
  from sharing.contracts.schemas import ShareGrant
12
- from sharing.policy import roles_granting, share_exists_for
13
- from sharing.service import SharingError, SharingService
11
+ from sharing.core.constants import ROLE_MAX
12
+ from sharing.core.policy import roles_granting, share_exists_for
13
+ from sharing.core.service import SharingError, SharingService
14
14
  from simple_module_core.datetimes import utcnow
15
15
  from simple_module_core.resources import (
16
16
  ACTION_EDIT,
@@ -14,10 +14,10 @@ from _sharing_support import (
14
14
  create_note_table,
15
15
  register_note_type,
16
16
  )
17
- from sharing.constants import PERM_MANAGE
18
17
  from sharing.contracts.schemas import ShareGrant
18
+ from sharing.core.constants import PERM_MANAGE
19
+ from sharing.core.service import SharingError, SharingService
19
20
  from sharing.models import ResourceShare
20
- from sharing.service import SharingError, SharingService
21
21
  from simple_module_core.resources import (
22
22
  ACTION_EDIT,
23
23
  ACTION_SHARE,
@@ -6,8 +6,8 @@ import uuid
6
6
 
7
7
  import pytest
8
8
  from _sharing_support import NOTE_TYPE, SharingTestNote, create_note_table, register_note_type
9
- from sharing.constants import PERM_SHARE
10
- from sharing.policy import share_exists_for
9
+ from sharing.core.constants import PERM_SHARE
10
+ from sharing.core.policy import share_exists_for
11
11
  from simple_module_core.resources import ACTION_SHARE, ACTION_VIEW, ResourceType
12
12
  from simple_module_core.tenancy import TenantRole
13
13
  from simple_module_db.resource_policy import OwnedResourcePolicy, select_by_id
@@ -70,10 +70,10 @@ async def test_grant_refusals(note_app, tenant_client):
70
70
 
71
71
 
72
72
  async def test_admin_page_lists_tenant_shares(note_app, tenant_client):
73
- from tenants.constants import SESSION_ACTIVE_TENANT
73
+ from tenants.core.constants import SESSION_ACTIVE_TENANT
74
74
  from tenants.models import Membership
75
- from tenants.resolver import forget
76
- from users.bootstrap import create_admin
75
+ from tenants.resolution.resolver import forget
76
+ from users.core.bootstrap import create_admin
77
77
 
78
78
  async with tenant_client(TenantRole.OWNER) as owner:
79
79
  async with tenant_client(TenantRole.MEMBER, tenant_id=owner.tenant_id) as friend: