Skip to main content

Shared protocol interfaces for Belgie

Project description

Belgie Proto: Shared Protocol Interfaces for Belgie Packages

[!WARNING] belgie-proto is intentionally low-level. It defines the contracts that other Belgie packages depend on, so changes here can ripple across adapters, plugins, and app code that implements these protocols directly.

belgie-proto is the contract layer for the Belgie workspace. It defines the runtime-checkable protocols for users, accounts, sessions, OAuth state, adapters, organizations, invitations, teams, and database connections so the rest of the stack can stay typed without hard-coding a particular ORM or persistence model.

Use it when you are implementing your own adapter, building custom integrations on top of belgie-core, or depending on shared interfaces across multiple Belgie packages. If you want a working SQLAlchemy implementation, start with belgie-alchemy.

Installation

uv add belgie-proto

[!NOTE] Most applications do not need to install belgie-proto directly. It is already pulled in by higher-level Belgie packages such as belgie-core and belgie-alchemy.

What It Defines

  • Core auth protocols for User, Account, Session, and OAuthState.
  • DBConnection for the async database/session object passed through Belgie.
  • AdapterProtocol for core auth persistence operations.
  • OrganizationAdapterProtocol and OrganizationTeamAdapterProtocol for org-aware adapters.
  • TeamAdapterProtocol for team-aware adapters.
  • Shared organization and team model protocols plus error types such as PendingInvitationConflictError.

Quick Start

Here is a minimal adapter surface using the core protocols:

from belgie_proto.core import AdapterProtocol, DBConnection, UserProtocol


class MyUser(UserProtocol):
    ...


class MyAdapter(AdapterProtocol):
    async def get_user_by_email(self, session: DBConnection, email: str) -> MyUser | None:
        ...

    async def create_user(
        self,
        session: DBConnection,
        email: str,
        name: str | None = None,
        image: str | None = None,
        *,
        email_verified_at=None,
    ) -> MyUser:
        ...

    # implement the rest of AdapterProtocol

The important constraint is not inheritance from a base class. It is satisfying the protocol shape that Belgie expects. That keeps the integration flexible while preserving type checking across packages.

Namespaces

  • Import core auth contracts from belgie_proto.core.
  • Import organization contracts from belgie_proto.organization.
  • Import team contracts from belgie_proto.team.

When To Reach For It

  • You are writing a custom adapter instead of using belgie-alchemy.
  • You want package boundaries enforced by protocols instead of concrete ORM models.
  • You are extending Belgie with org or team support and need the shared adapter contracts.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

belgie_proto-0.12.3.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

belgie_proto-0.12.3-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

Details for the file belgie_proto-0.12.3.tar.gz.

File metadata

  • Download URL: belgie_proto-0.12.3.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for belgie_proto-0.12.3.tar.gz
Algorithm Hash digest
SHA256 4549e3cb0b8cd383d491239f67de6e42a206365a0bfb7f1e7f1bbbe8ac3d653e
MD5 b941dfd047b03e1415e37fe4dc15a649
BLAKE2b-256 323e8d1b632f7aeeeb7e81111e0e18f0fa17c6b4d12d9e95c20f5f45c37cf8cc

See more details on using hashes here.

File details

Details for the file belgie_proto-0.12.3-py3-none-any.whl.

File metadata

  • Download URL: belgie_proto-0.12.3-py3-none-any.whl
  • Upload date:
  • Size: 13.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for belgie_proto-0.12.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0fbb0dcebfd8df5bda58f08437969f3f00e895e8d99a9b6b6f6395d6179e5a51
MD5 dfc1e779ae779d4b247fe5e08c6d1044
BLAKE2b-256 78de8a27f398d2a9c1287838da81189fe8e40d6d8910c8e5622f59906cf3a68c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page