devcoffee-integration-event 1.0.0__tar.gz

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,11 @@
1
+ Metadata-Version: 2.1
2
+ Name: devcoffee-integration-event
3
+ Version: 1.0.0
4
+ Summary: DevCoffee events data
5
+ Author-Email: Hieu Nguyen <hieu.nguyen@devcoffee.tech>
6
+ License: MIT
7
+ Requires-Python: >=3.12
8
+ Requires-Dist: pydantic>=2.12.5
9
+ Description-Content-Type: text/markdown
10
+
11
+ # devcoffee-integration-event
@@ -0,0 +1 @@
1
+ # devcoffee-integration-event
@@ -0,0 +1,24 @@
1
+ [project]
2
+ name = "devcoffee-integration-event"
3
+ version = "1.0.0"
4
+ description = "DevCoffee events data"
5
+ authors = [
6
+ { name = "Hieu Nguyen", email = "hieu.nguyen@devcoffee.tech" },
7
+ ]
8
+ requires-python = ">=3.12"
9
+ readme = "README.md"
10
+ dependencies = [
11
+ "pydantic>=2.12.5",
12
+ ]
13
+
14
+ [project.license]
15
+ text = "MIT"
16
+
17
+ [tool.pdm]
18
+ distribution = true
19
+
20
+ [build-system]
21
+ requires = [
22
+ "pdm-backend",
23
+ ]
24
+ build-backend = "pdm.backend"
File without changes
@@ -0,0 +1 @@
1
+ from .base import BaseEvent
@@ -0,0 +1,23 @@
1
+ from datetime import datetime
2
+ from typing import Any
3
+ from uuid import UUID
4
+
5
+ from pydantic import BaseModel, Field
6
+
7
+ __all__=[
8
+ "BaseEvent"
9
+ ]
10
+
11
+ class BaseEvent(BaseModel):
12
+ event_id: UUID = Field(..., description="Unique identifier of the event (uuid)")
13
+ trace_id: UUID | None = Field(default=None, description="Trace identifier for distributed tracing (uuid)")
14
+ event_time: datetime = Field(..., description="When the token was issued")
15
+ event_name: str = Field(default="token.issued", description="The name of the event")
16
+ producer: str = Field(..., description="Service that produced the event")
17
+ data: dict[str, Any] = Field(..., description="Event payload data")
18
+
19
+ def __str__(self) -> str:
20
+ return f"{self.event_name} ({self.event_id})"
21
+
22
+ def __repr__(self):
23
+ return f"<{self.__class__.__name__} {self.event_name} {self.event_id}>"
@@ -0,0 +1,49 @@
1
+ from uuid import UUID
2
+
3
+ from pydantic import BaseModel, ConfigDict, Field
4
+
5
+ from .base import BaseEvent
6
+
7
+ __all__ = [
8
+ "IssuedTokenData",
9
+ "RevokedTokenData",
10
+ "TokenIssuedEvent",
11
+ "TokenRevokedEvent",
12
+ ]
13
+
14
+
15
+ class IssuedTokenData(BaseModel):
16
+ token: str = Field(..., description="The issued token string.")
17
+
18
+ token_type: str = Field(
19
+ ..., alias="tokenType", description="The type of the token issued (access_token, id_token)."
20
+ )
21
+ email: str = Field(..., description="The email of the user for whom the token was issued.")
22
+ user_id: UUID = Field(..., alias="userId", description="The unique identifier of the user.")
23
+ client_id: str = Field(
24
+ ..., alias="clientId", description="The client identifier of the application that requested the token."
25
+ )
26
+
27
+ model_config = ConfigDict(populate_by_name=True)
28
+
29
+
30
+ class RevokedTokenData(BaseModel):
31
+ token: str = Field(..., description="The revoked token string.")
32
+ token_type: str = Field(
33
+ ..., alias="tokenType", description="The type of the token revoked (access_token, id_token)."
34
+ )
35
+ email: str = Field(..., description="The email of the user for whom the token was revoked.")
36
+ user_id: UUID = Field(..., alias="userId", description="The unique identifier of the user.")
37
+ client_id: str = Field(
38
+ ..., alias="clientId", description="The client identifier of the application that requested the token."
39
+ )
40
+
41
+ model_config = ConfigDict(populate_by_name=True)
42
+
43
+
44
+ class TokenIssuedEvent(BaseEvent):
45
+ data: IssuedTokenData
46
+
47
+
48
+ class TokenRevokedEvent(BaseEvent):
49
+ data: RevokedTokenData
@@ -0,0 +1,58 @@
1
+ from datetime import datetime
2
+ from enum import StrEnum
3
+ from uuid import UUID
4
+
5
+ from pydantic import BaseModel, ConfigDict, Field
6
+
7
+ from .base import BaseEvent
8
+
9
+ __all__ = [
10
+ "User",
11
+ "AuthenticationMethod",
12
+ "Authentication",
13
+ "Client",
14
+ "AuthenticationPayload",
15
+ "UserAuthenticationSucceededEvent",
16
+ ]
17
+
18
+
19
+ class User(BaseModel):
20
+ id: UUID = Field(..., description="User's unique identifier (uuid)")
21
+ email: str = Field(..., description="User's email")
22
+ first_name: str = Field(..., alias="firstName", description="User's first name")
23
+ last_name: str = Field(..., alias="lastName", description="User's last name")
24
+ language: str | None = Field(default=None, description="User's language")
25
+ timezone: str | None = Field(default=None, description="User's timezone")
26
+ date_joined: datetime | None = Field(default=None, alias="dateJoined", description="User's joined date.")
27
+
28
+ model_config = ConfigDict(populate_by_name=True)
29
+
30
+
31
+ class AuthenticationMethod(StrEnum):
32
+ PASSWORD = "PASSWORD"
33
+ OIDC = "OIDC"
34
+ REMEMBER_TOKEN = "REMEMBER_TOKEN"
35
+ API_KEY = "API_KEY"
36
+
37
+
38
+ class Authentication(BaseModel):
39
+ method: AuthenticationMethod
40
+ provider: str | None = Field(
41
+ default=None, description="OIDC provider that authenticated the user. e.g. google, github"
42
+ )
43
+
44
+
45
+ class Client(BaseModel):
46
+ ip: str | None = Field(default=None, description="IP address of the client")
47
+ user_agent: str | None = Field(default=None, description="User agent of the client")
48
+ device: str | None = Field(default=None, description="Device identifier of the client")
49
+
50
+
51
+ class AuthenticationPayload(BaseModel):
52
+ user: User
53
+ authentication: Authentication
54
+ client: Client
55
+
56
+
57
+ class UserAuthenticationSucceededEvent(BaseEvent):
58
+ data: AuthenticationPayload
File without changes