Skip to content

feat: add ShareLink domain model and storage mixin#21

Merged
yilu331 merged 7 commits intomainfrom
feat/share-link-domain-model
Apr 16, 2026
Merged

feat: add ShareLink domain model and storage mixin#21
yilu331 merged 7 commits intomainfrom
feat/share-link-domain-model

Conversation

@yilu331
Copy link
Copy Markdown
Collaborator

@yilu331 yilu331 commented Apr 16, 2026

Summary

Adds the ShareLink domain model and storage layer (ShareLinkMixin) to the open-source package. This is the open-source half of moving share links from an auth-side (Reflexio-managed) database to the per-customer data storage, so that share link records live alongside the resources they reference.

Changes

  • Domain model (models/api_schema/domain/entities.py) — new ShareLink Pydantic class with id: int, org_id, token, resource_type, resource_id, created_at, expires_at, created_by_email.
  • Storage protocol (server/services/storage/storage_base/_share_links.py) — abstract ShareLinkMixin with 6 methods: create_share_link, get_share_link_by_token, get_share_link_by_resource, get_share_links, delete_share_link, delete_all_share_links. BaseStorage now inherits this mixin.
  • SQLite implementation (server/services/storage/sqlite_storage/_share_links.py, _base.py) — SQLiteShareLinkMixin plus the share_links table DDL (auto-created at startup). Uses the shared _epoch_now() helper and self._execute/_fetchone/_fetchall helpers for thread-safe queries.
  • Disk stub (server/services/storage/disk_storage/_share_links.py) — DiskShareLinkMixin that raises NotImplementedError for each method (disk storage does not support share links).

Storage instances are org-scoped

None of the new methods take an org_id parameter — the storage instance is already bound to a specific org. This matches the pattern used by every other mixin.

Test plan

  • New contract tests in tests/server/services/storage/test_sqlite_share_links.py cover create / get-by-token / get-by-resource / list / delete / delete-all (12 tests, all passing)
  • Full storage test sweep: 148 tests passing (no regressions)
  • ruff check / ruff format --check clean
  • pyright clean on all new files

@yilu331 yilu331 merged commit 7658e66 into main Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant