prismiq 0.1.0__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.
@@ -0,0 +1,76 @@
1
+ """SQLAlchemy Core table definitions for Prismiq metadata."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from sqlalchemy import (
6
+ Boolean,
7
+ Column,
8
+ ForeignKey,
9
+ Index,
10
+ MetaData,
11
+ String,
12
+ Table,
13
+ Text,
14
+ UniqueConstraint,
15
+ )
16
+ from sqlalchemy.dialects.postgresql import ARRAY, JSONB, TIMESTAMP, UUID
17
+
18
+ metadata = MetaData()
19
+
20
+ # Dashboards table
21
+ dashboards_table = Table(
22
+ "prismiq_dashboards",
23
+ metadata,
24
+ Column("id", UUID(as_uuid=True), primary_key=True),
25
+ Column("tenant_id", String(255), nullable=False),
26
+ Column("name", String(255), nullable=False),
27
+ Column("description", Text, nullable=True),
28
+ Column("layout", JSONB, nullable=False),
29
+ Column("filters", JSONB, nullable=False),
30
+ Column("owner_id", String(255), nullable=True),
31
+ Column("is_public", Boolean, nullable=False, default=False),
32
+ Column("allowed_viewers", ARRAY(Text), nullable=False),
33
+ Column("created_at", TIMESTAMP(timezone=True), nullable=False),
34
+ Column("updated_at", TIMESTAMP(timezone=True), nullable=False),
35
+ UniqueConstraint("tenant_id", "name", name="unique_dashboard_name_per_tenant"),
36
+ Index("idx_dashboards_tenant_id", "tenant_id"),
37
+ Index("idx_dashboards_owner_id", "tenant_id", "owner_id"),
38
+ )
39
+
40
+ # Widgets table
41
+ widgets_table = Table(
42
+ "prismiq_widgets",
43
+ metadata,
44
+ Column("id", UUID(as_uuid=True), primary_key=True),
45
+ Column(
46
+ "dashboard_id",
47
+ UUID(as_uuid=True),
48
+ ForeignKey("prismiq_dashboards.id", ondelete="CASCADE"),
49
+ nullable=False,
50
+ ),
51
+ Column("type", String(50), nullable=False),
52
+ Column("title", String(255), nullable=False),
53
+ Column("query", JSONB, nullable=True), # Null for text widgets
54
+ Column("position", JSONB, nullable=False),
55
+ Column("config", JSONB, nullable=False),
56
+ Column("created_at", TIMESTAMP(timezone=True), nullable=False),
57
+ Column("updated_at", TIMESTAMP(timezone=True), nullable=False),
58
+ Index("idx_widgets_dashboard_id", "dashboard_id"),
59
+ )
60
+
61
+ # Saved queries table
62
+ saved_queries_table = Table(
63
+ "prismiq_saved_queries",
64
+ metadata,
65
+ Column("id", UUID(as_uuid=True), primary_key=True),
66
+ Column("tenant_id", String(255), nullable=False),
67
+ Column("name", String(255), nullable=False),
68
+ Column("description", Text, nullable=True),
69
+ Column("query", JSONB, nullable=False),
70
+ Column("owner_id", String(255), nullable=True),
71
+ Column("is_shared", Boolean, nullable=False, default=False),
72
+ Column("created_at", TIMESTAMP(timezone=True), nullable=False),
73
+ Column("updated_at", TIMESTAMP(timezone=True), nullable=False),
74
+ UniqueConstraint("tenant_id", "name", name="unique_query_name_per_tenant"),
75
+ Index("idx_saved_queries_tenant", "tenant_id"),
76
+ )
prismiq/pins.py ADDED
@@ -0,0 +1,72 @@
1
+ """Pydantic models for dashboard pinning functionality.
2
+
3
+ Pins allow users to save dashboards to system-defined contexts
4
+ (e.g., "dashboard", "accounts", "home") for quick access in different
5
+ areas of the embedding application.
6
+ """
7
+
8
+ from __future__ import annotations
9
+
10
+ from datetime import datetime
11
+ from typing import Annotated
12
+
13
+ from pydantic import BaseModel, Field, StringConstraints
14
+
15
+ # Non-empty string type for dashboard IDs
16
+ NonEmptyStr = Annotated[str, StringConstraints(min_length=1)]
17
+
18
+
19
+ class PinnedDashboard(BaseModel):
20
+ """A pinned dashboard entry.
21
+
22
+ Attributes:
23
+ id: Unique identifier for this pin (non-empty).
24
+ dashboard_id: ID of the pinned dashboard (non-empty).
25
+ context: Context where the dashboard is pinned (e.g., "accounts").
26
+ position: Order position within the context (0-based, non-negative).
27
+ pinned_at: When the dashboard was pinned.
28
+ """
29
+
30
+ id: str = Field(..., min_length=1)
31
+ dashboard_id: str = Field(..., min_length=1)
32
+ context: str = Field(..., min_length=1, max_length=100)
33
+ position: int = Field(..., ge=0)
34
+ pinned_at: datetime
35
+
36
+
37
+ class PinRequest(BaseModel):
38
+ """Request to pin a dashboard to a context.
39
+
40
+ Attributes:
41
+ dashboard_id: ID of the dashboard to pin (non-empty).
42
+ context: Context to pin to (e.g., "accounts", "dashboard").
43
+ position: Optional position in the list (non-negative). If None, appends at end.
44
+ """
45
+
46
+ dashboard_id: str = Field(..., min_length=1)
47
+ context: str = Field(..., min_length=1, max_length=100)
48
+ position: int | None = Field(default=None, ge=0)
49
+
50
+
51
+ class UnpinRequest(BaseModel):
52
+ """Request to unpin a dashboard from a context.
53
+
54
+ Attributes:
55
+ dashboard_id: ID of the dashboard to unpin (non-empty).
56
+ context: Context to unpin from (1-100 characters).
57
+ """
58
+
59
+ dashboard_id: str = Field(..., min_length=1)
60
+ context: str = Field(..., min_length=1, max_length=100)
61
+
62
+
63
+ class ReorderPinsRequest(BaseModel):
64
+ """Request to reorder pinned dashboards in a context.
65
+
66
+ Attributes:
67
+ context: Context to reorder pins in.
68
+ dashboard_ids: Ordered list of dashboard IDs (new order). Each ID must be non-empty.
69
+ """
70
+
71
+ context: str = Field(..., min_length=1, max_length=100)
72
+ dashboard_ids: list[NonEmptyStr] = Field(..., min_length=1)
prismiq/py.typed ADDED
File without changes