Skip to main content

Shared wire types, schemas, and reactive primitives for PondSocket.

Project description

pondsocket-common

Shared wire types, schemas, and reactive primitives consumed by both pondsocket (server) and (eventually) pondsocket-client (Python client). Mirrors the role of @eleven-am/pondsocket-common in the JavaScript monorepo.

This package has one runtime dependency: pydantic v2.

Install

pip install pondsocket-common

In a workspace it's installed automatically via uv sync.

What's in it

Module Purpose
pondsocket_common.enums ServerActions, ClientActions, ChannelState, PresenceEventTypes, ErrorTypes, ChannelReceiver, SystemSender, Events, PubSubEvents — all StrEnum with exact wire strings
pondsocket_common.schemas Pydantic v2 models: ClientMessage, ServerMessage, PresenceMessage, ChannelEvent, plus parse_client_message / parse_server_message / parse_presence_message / parse_channel_event with comnon-style ValidationError
pondsocket_common.types UserData, IncomingConnection, PresencePayload, PubSubEvent variants, type aliases (PondMessage, PondPresence, PondAssigns, JoinParams)
pondsocket_common.headers Headers — case-insensitive view over ASGI-shape list[tuple[bytes, bytes]]
pondsocket_common.subjects Subject[T] and BehaviorSubject[T] — synchronous reactive primitives mirroring the JS comnon impl
pondsocket_common.errors PondError, status constants (400/401/403/404/409/429/500/503/504), constructor helpers (bad_request, unauthorized, …), MultiError
pondsocket_common.ids uuid() — dashed v4 string

Wire format

Outbound client → server (ClientMessage):

{
  "action": "BROADCAST",
  "event": "message",
  "channelName": "/chat/42",
  "requestId": "<uuid>",
  "payload": {"text": "hi"}
}

Server → client (ServerMessage | PresenceMessage) discriminated on action:

{ "action": "SYSTEM",  "event": "ACKNOWLEDGE", "channelName": "/chat/42", "requestId": "...", "payload": {} }
{ "action": "PRESENCE", "event": "JOIN",       "channelName": "/chat/42", "requestId": "...", "payload": {"presence": [...], "changed": {...}} }

Field names on the wire are camelCase. The Python models use snake_case attributes (request_id, channel_name) with pydantic aliases. Use model_dump(by_alias=True) to serialize to wire form.

Parity with @eleven-am/pondsocket-common

  • Enums have identical string values.
  • Subject/BehaviorSubject mirror the JS classes 1:1 (synchronous fan-out, size property, close() semantics, BehaviorSubject initial-value replay on subscribe).
  • ValidationError(message, path?) formats as "path: message" to match.
  • uuid() returns a dashed lowercase hex string (matches crypto.randomUUID()).

The pydantic models are the canonical schema definitions on the Python side; the JS package uses hand-rolled validators with the same field-name shape.

License

GPL-3.0-or-later.

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

pondsocket_common-0.0.3.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

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

pondsocket_common-0.0.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file pondsocket_common-0.0.3.tar.gz.

File metadata

  • Download URL: pondsocket_common-0.0.3.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pondsocket_common-0.0.3.tar.gz
Algorithm Hash digest
SHA256 0dbb69a7dc00e6c83e4acc9f08eb1296a420193af83395d7690aac76a3ce1801
MD5 6bbeaf4f5665d3194af2fece53974ef5
BLAKE2b-256 351def908b802207842e7dfa5a6299082170aeefbd90af448933dd4c05fdf987

See more details on using hashes here.

File details

Details for the file pondsocket_common-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: pondsocket_common-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.0 {"installer":{"name":"uv","version":"0.10.0","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pondsocket_common-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9b67d67e6ef7a794ef6c49f3fba52798206ec955981eb47aeebd8e5af288116f
MD5 3793d298b991d5680d9397361b36a8d4
BLAKE2b-256 4fc81a804be8fe3a84f1df6a6fdb222a74f5ea4b0bec62be6fc321a47025daa2

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