artemis-model 0.1.87__py3-none-any.whl → 0.1.89__py3-none-any.whl

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.
artemis_model/__init__.py CHANGED
@@ -14,4 +14,3 @@ from artemis_model.track import * # noqa
14
14
  from artemis_model.user import * # noqa
15
15
  from artemis_model.zone import * # noqa
16
16
  from artemis_model.otp import * # noqa
17
- from artemis_model.device import * # noqa
@@ -0,0 +1,5 @@
1
+ """Redis models."""
2
+
3
+ from .zone_state import ZoneState, NowPlaying, SessionId, BucketId
4
+
5
+ __all__ = ["ZoneState", "NowPlaying", "SessionId", "BucketId"]
@@ -0,0 +1,61 @@
1
+ """Zone state schema."""
2
+
3
+
4
+ from dataclasses import Field
5
+ from typing import Annotated, Literal
6
+
7
+ from pydantic import BaseModel, field_validator
8
+
9
+
10
+ class NowPlaying(BaseModel):
11
+ """Now playing schema."""
12
+
13
+ name: str = Field(description="The name of the track", default="UNKNOWN")
14
+ artist_name: str = Field(description="The artist name of the track", default="UNKNOWN")
15
+ album_name: str = Field(description="The album name of the track", default="UNKNOWN")
16
+
17
+
18
+ SessionId = Annotated[
19
+ int,
20
+ Field(
21
+ description="The session id of the pushed playlist. It's generated as a timestamp value of the current time."
22
+ ),
23
+ ]
24
+ BucketId = Annotated[
25
+ int | None,
26
+ Field(
27
+ description="The bucket id of the pushed playlist. It's calculated in set_bucket_track as the timestamp value of the timeslot."
28
+ ),
29
+ ]
30
+
31
+
32
+
33
+ class ZoneState(BaseModel):
34
+ """Zone state schema."""
35
+
36
+ player_mode: Literal["scheduled", "pushplaylist"] = Field(
37
+ default="scheduled",
38
+ description="The mode of the player",
39
+ )
40
+ player_state: Literal["playing", "paused", "stopped", "ready"] = Field(
41
+ default="ready",
42
+ description="The state of the player",
43
+ )
44
+ now_playing: NowPlaying | None = Field(
45
+ default=None,
46
+ description="The currently playing track",
47
+ )
48
+ push_playlist_details: dict[SessionId, BucketId] | None = Field(
49
+ default_factory=dict,
50
+ description="The details of the pushed playlist",
51
+ )
52
+
53
+ @field_validator("push_playlist_details", mode="before")
54
+ @classmethod
55
+ def default_empty_dict_if_none(cls, v):
56
+ """Override none value to empty dict."""
57
+ return v or {}
58
+
59
+
60
+
61
+ __all__ = ["ZoneState", "NowPlaying", "SessionId", "BucketId"]
artemis_model/user.py CHANGED
@@ -28,14 +28,6 @@ class UserMixin(TimeStampMixin):
28
28
  cascade="all, delete-orphan",
29
29
  )
30
30
 
31
- @declared_attr
32
- def devices(cls) -> Mapped[list["Device"]]:
33
- return relationship(
34
- "Device",
35
- secondary="device_user_assoc", # Directly reference the association table
36
- back_populates="users",
37
- )
38
-
39
31
  @declared_attr
40
32
  def user_permission_associations(cls) -> Mapped[List["UserPermissionAssoc"]]:
41
33
  return relationship(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: artemis-model
3
- Version: 0.1.87
3
+ Version: 0.1.89
4
4
  Summary:
5
5
  Author: Jukeboxy
6
6
  Requires-Python: >=3.10.6,<4.0.0
@@ -1,10 +1,9 @@
1
- artemis_model/__init__.py,sha256=ppr3Y8tA0RIhszLWNEIL2eIXzj8ho833nbrejsXPuMk,735
1
+ artemis_model/__init__.py,sha256=VwCQjY-_A2WqI4wLdUwVKh8diUOE67qkGK_8KqL665k,692
2
2
  artemis_model/album.py,sha256=cnjrE0catTK24uWTrAoRcZUQB3CPt5l8s9PeM2sxLrc,2103
3
3
  artemis_model/artist.py,sha256=Mx2bnl7bxqm2ELjDIePGFfIkQU_DbnfOTc507dzh14g,1577
4
4
  artemis_model/auth.py,sha256=WVonoYbCE0uvRuPR2Fz1hZJ-xmbyTuBVt6H51X6OfEs,4087
5
5
  artemis_model/base.py,sha256=21Isonytb_iWfmde4u8LiU6a27h7mkgnwncTAKi9ezY,6768
6
6
  artemis_model/category.py,sha256=jhCZrK-LxPmc0pXmVifAZWdCENssBTzdTmC3nqqZc6s,1761
7
- artemis_model/device.py,sha256=b_TAh3v9JWGsKCjlWtyljLj8QVnruVWU6L7BEDNGIQQ,2110
8
7
  artemis_model/dj_set.py,sha256=-0rU2xOAJ4vecite8yKFmp9yFLPZurFrdFmYAjPHtso,3848
9
8
  artemis_model/genre.py,sha256=oMs1ZZfr0SZWmWzW9PEPuaNcatfeIx53nk5M3DPodrQ,1615
10
9
  artemis_model/location.py,sha256=T6TlUCXxGyicYtb39dw7XjbCSNECZnMPYahxtOtyEiE,4687
@@ -13,11 +12,13 @@ artemis_model/organization.py,sha256=hu9jKB2qu57BwN0sUUK13p3tC-Hqw9EghFMqjFP9Pr4
13
12
  artemis_model/otp.py,sha256=TjZ_EHeIedjsLIqyZTtzd0s6Uc-1dleMEV8DhzsW44o,1046
14
13
  artemis_model/permission.py,sha256=sEBRN-bQJl2TNtRJ5LRuySoEbW1lY4DCoyRk0nOM-kY,1503
15
14
  artemis_model/playlist.py,sha256=1mR1FbjeG5ZKzILLd7Mo_fuMplEwN3gPCO-jHvkE1WM,6550
15
+ artemis_model/redis/__init__.py,sha256=EHuVa0Bn3AJ9g__8hm39K8MklmBXBr7HKOMpgno1z8w,152
16
+ artemis_model/redis/zone_state.py,sha256=2Kyzco0SdiFmHrIOg8upeDgNe1M3wk1Nrh4uu4md7NY,1746
16
17
  artemis_model/schedule.py,sha256=pnoKDMlUh28o61I7kZddNYn6z-uqOt_ml1nbWxKVeRM,1722
17
18
  artemis_model/setting.py,sha256=McWbeDZP45km3VSSwP1BgAmmjO4qCL0pTnOmJVAz0WI,1265
18
19
  artemis_model/track.py,sha256=x8BHKDZl9uQmQH6DWpzH-SEsfecLghOBdBT7qXgN3d0,3865
19
- artemis_model/user.py,sha256=jGG3FpO6ddehXVl9XWqv4poQH6QQZut48saob3Cy8vU,2467
20
+ artemis_model/user.py,sha256=ZtZVwavSPoQmYM1_MarMULy-DJa2pH482G_G8su0b6c,2211
20
21
  artemis_model/zone.py,sha256=iGRUtzUwKh9LHT3MOfzzg1DnkPBts_ZBzZVTi2EmIgs,2282
21
- artemis_model-0.1.87.dist-info/METADATA,sha256=39Ls_EQEk3eZ_B6R4o1uRnQQ8PWoHzpOyJK_hZiiA_8,3402
22
- artemis_model-0.1.87.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
23
- artemis_model-0.1.87.dist-info/RECORD,,
22
+ artemis_model-0.1.89.dist-info/METADATA,sha256=mkzW6n0T0TuOW03pJc2mD6pQ8ZXNT72NOkHbpSosKQc,3402
23
+ artemis_model-0.1.89.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
24
+ artemis_model-0.1.89.dist-info/RECORD,,
artemis_model/device.py DELETED
@@ -1,69 +0,0 @@
1
- import enum
2
- import uuid
3
- from datetime import datetime
4
-
5
- from sqlalchemy import JSON, UUID, ForeignKey
6
- from sqlalchemy.orm import Mapped, mapped_column, relationship
7
- from sqlalchemy.ext.declarative import declared_attr
8
- from sqlalchemy.ext.associationproxy import association_proxy
9
-
10
- from artemis_model.base import CustomSyncBase, CustomBase, TimeStampMixin
11
-
12
-
13
- class DeviceMixin(TimeStampMixin):
14
- """
15
- Represents a Jukebox device that can be controlled by multiple users.
16
- """
17
- id: Mapped[uuid.UUID] = mapped_column(UUID(as_uuid=True), primary_key=True, default=uuid.uuid4)
18
- device_id: Mapped[str] = mapped_column(nullable=False, unique=True, index=True)
19
- name: Mapped[str] = mapped_column(nullable=False) # e.g., "Living Room Jukebox"
20
- fcm_token: Mapped[str | None] = mapped_column(nullable=True)
21
- device_specs: Mapped[dict] = mapped_column(JSON, nullable=True) # control_mode can be stored here
22
-
23
- @declared_attr
24
- def device_user_assoc(cls) -> Mapped[list["DeviceUserAssoc"]]:
25
- return relationship(cascade="all, delete-orphan")
26
-
27
- @declared_attr
28
- def user_ids(cls) -> Mapped[list["UserAccount"] | None]:
29
- return association_proxy(
30
- "device_user_assoc",
31
- "user",
32
- creator=lambda u: DeviceUserAssoc(user_id=u),
33
- )
34
-
35
- @declared_attr
36
- def users(cls) -> Mapped[list["User"]]:
37
- return relationship(
38
- secondary="device_user_assoc",
39
- viewonly=True
40
- )
41
-
42
-
43
- class DeviceSync(CustomSyncBase, DeviceMixin):
44
- pass
45
-
46
-
47
- class Device(CustomBase, DeviceMixin):
48
- pass
49
-
50
-
51
- class DeviceUserAssocMixin(TimeStampMixin):
52
- """
53
- Association table for many-to-many relationship between UserAccount and Device.
54
- """
55
-
56
- device_id: Mapped[uuid.UUID] = mapped_column(
57
- ForeignKey("device.id"), primary_key=True, nullable=False
58
- )
59
- user_id: Mapped[uuid.UUID] = mapped_column(
60
- ForeignKey("user.id"), primary_key=True, nullable=False
61
- )
62
-
63
-
64
- class DeviceUserAssocSync(CustomSyncBase, DeviceUserAssocMixin):
65
- pass
66
-
67
-
68
- class DeviceUserAssoc(CustomBase, DeviceUserAssocMixin):
69
- pass