Skip to main content

Materi Event Schema - Python bindings for Protocol Buffer event definitions

Project description

@materi/proto (Python)

Python bindings for Materi Event Schema - Protocol Buffer event definitions.

Installation

pip install materi-proto

Usage

from materi_proto import (
    DomainEvent,
    UserCreatedEvent,
    DocumentCreatedEvent,
    Status,
    SourceService,
)

# Create a user event
user_event = UserCreatedEvent(
    user_id="user-123",
    email="alice@example.com",
    name="Alice",
)

# Wrap in domain envelope
envelope = DomainEvent(
    event_id="evt-456",
    event_type="user.created",
    aggregate_id="user-123",
    aggregate_type="user",
    version=1,
)

# Serialize to bytes
data = envelope.SerializeToString()

# Parse from bytes
parsed = DomainEvent()
parsed.ParseFromString(data)

Direct Domain Access

For more granular imports:

from materi_proto.domains import user_pb2, document_pb2
from materi_proto.shared import shared_pb2

event = user_pb2.UserCreatedEvent(user_id="user-123")
status = shared_pb2.Status.STATUS_ACTIVE

Available Domains

Domain Module Events
Envelope envelope_pb2 DomainEvent, EventAcknowledgment
User user_pb2 UserCreated, UserUpdated, UserDeleted, UserLogin, etc.
Document document_pb2 DocumentCreated, DocumentUpdated, DocumentDeleted, DocumentShared
Workspace workspace_pb2 WorkspaceCreated, WorkspaceMemberAdded, etc.
Collaboration collaboration_pb2 SessionStarted, OperationApplied, PresenceUpdated, etc.
Aria aria_pb2 AnalysisStarted, AnalysisComplete, SafetyGatePassed, etc.
Notification notification_pb2 EmailSent, NotificationPublished, etc.
Audit audit_pb2 PermissionDenied, DataAccessLogged, AuditLogCreated

Shared Types

from materi_proto import Status, SourceService, PermissionLevel, OperationType

# Enums
Status.STATUS_ACTIVE
Status.STATUS_INACTIVE
Status.STATUS_DELETED

SourceService.SOURCE_SERVICE_API
SourceService.SOURCE_SERVICE_RELAY
SourceService.SOURCE_SERVICE_SHIELD

PermissionLevel.PERMISSION_LEVEL_OWNER
PermissionLevel.PERMISSION_LEVEL_EDITOR
PermissionLevel.PERMISSION_LEVEL_VIEWER

OperationType.OPERATION_TYPE_INSERT
OperationType.OPERATION_TYPE_DELETE
OperationType.OPERATION_TYPE_RETAIN

Type Hints

This package includes py.typed marker and .pyi stub files for full type checking support:

from materi_proto import UserCreatedEvent

def process_user(event: UserCreatedEvent) -> str:
    return event.user_id  # Type-safe access

Development

Regenerate from Proto

cd ../.msx
make compile-py

Run Tests

pip install -e ".[dev]"
pytest

Type Checking

mypy src/materi_proto

License

MIT

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

materi_proto-0.1.3.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

materi_proto-0.1.3-py3-none-any.whl (29.4 kB view details)

Uploaded Python 3

File details

Details for the file materi_proto-0.1.3.tar.gz.

File metadata

  • Download URL: materi_proto-0.1.3.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for materi_proto-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6bc570039abbb2ac2f276b80e01b0391b4a970ca3d62718e739ef871c472cfde
MD5 e4782a8d0aebe8a9099b948ae6183169
BLAKE2b-256 a2d932bb57e26177e2756637db0b42279694a75fb230c098277f9770c0ffec43

See more details on using hashes here.

File details

Details for the file materi_proto-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: materi_proto-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 29.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for materi_proto-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 489b0c2863d72b2093e908e9942a3931479a797414d0dbe455076ff8821ef78d
MD5 fb783f8e116e06bc5b402319674de3d9
BLAKE2b-256 4fbd855627f19732821f99a2a68940572ac159b2d078759f390246f3b7bc96f2

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