aiteamutils 0.2.78__tar.gz → 0.2.80__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aiteamutils
3
- Version: 0.2.78
3
+ Version: 0.2.80
4
4
  Summary: AI Team Utilities
5
5
  Project-URL: Homepage, https://github.com/yourusername/aiteamutils
6
6
  Project-URL: Issues, https://github.com/yourusername/aiteamutils/issues
@@ -79,13 +79,13 @@ class BaseRepository(Generic[ModelType]):
79
79
  async def delete(
80
80
  self,
81
81
  conditions: Dict[str, Any]
82
- ) -> None:
82
+ ) -> bool:
83
83
  await delete_entity(
84
84
  session=self.session,
85
85
  model=self.model,
86
86
  conditions=conditions
87
87
  )
88
-
88
+ return True
89
89
  #########################
90
90
  # 조회 및 검색 메서드 #
91
91
  #########################
@@ -93,7 +93,7 @@ class BaseRepository(Generic[ModelType]):
93
93
  self,
94
94
  skip: int = 0,
95
95
  limit: int = 100,
96
- filters: Optional[Dict[str, Any]] = None,
96
+ filters: Optional[List[Dict[str, Any]]] = None,
97
97
  explicit_joins: Optional[List[Any]] = None,
98
98
  loading_joins: Optional[List[Any]] = None
99
99
  ) -> List[ModelType]:
@@ -125,7 +125,7 @@ class BaseService(Generic[ModelType]):
125
125
  self,
126
126
  ulid: str | None = None,
127
127
  conditions: Dict[str, Any] | None = None
128
- ) -> None:
128
+ ) -> bool:
129
129
  try:
130
130
  if not ULID.from_str(ulid):
131
131
  raise CustomException(
@@ -168,29 +168,11 @@ class BaseService(Generic[ModelType]):
168
168
  skip: int = 0,
169
169
  limit: int = 100,
170
170
  filters: List[Dict[str, Any]] | None = None,
171
- model_name: str | None = None,
172
171
  response_model: Any = None,
173
172
  explicit_joins: Optional[List[Any]] = None,
174
173
  loading_joins: Optional[List[Any]] = None
175
174
  ) -> List[Dict[str, Any]]:
176
175
  try:
177
- # 모델 이름을 통한 동적 처리
178
- if model_name:
179
- if model_name not in self.additional_models:
180
- raise CustomException(
181
- ErrorCode.INVALID_REQUEST,
182
- detail=f"Model {model_name} not registered",
183
- source_function=f"{self.__class__.__name__}.list"
184
- )
185
- model = self.additional_models[model_name]
186
- entities = await self.repository.list(
187
- skip=skip,
188
- limit=limit,
189
- filters=filters,
190
- model=model
191
- )
192
- return [process_response(entity, response_model) for entity in entities]
193
-
194
176
  entities = await self.repository.list(
195
177
  skip=skip,
196
178
  limit=limit,
@@ -364,7 +364,7 @@ async def delete_entity(
364
364
  session: AsyncSession,
365
365
  model: Type[ModelType],
366
366
  conditions: Dict[str, Any]
367
- ) -> None:
367
+ ) -> bool:
368
368
  try:
369
369
  stmt = select(model)
370
370
  for key, value in conditions.items():
@@ -386,6 +386,7 @@ async def delete_entity(
386
386
  await session.flush()
387
387
  await session.refresh(entity)
388
388
 
389
+ return True
389
390
  except SQLAlchemyError as e:
390
391
  raise CustomException(
391
392
  ErrorCode.DB_DELETE_ERROR,
@@ -398,17 +399,18 @@ async def purge_entity(
398
399
  session: AsyncSession,
399
400
  model: Type[ModelType],
400
401
  entity: ModelType
401
- ) -> None:
402
+ ) -> bool:
402
403
  # 엔티티를 영구 삭제합니다.
403
404
  await session.delete(entity)
404
- await session.commit()
405
+
406
+ return True
405
407
 
406
408
  async def list_entities(
407
409
  session: AsyncSession,
408
410
  model: Type[ModelType],
409
411
  skip: int = 0,
410
412
  limit: int = 100,
411
- filters: Optional[Dict[str, Any]] = None,
413
+ filters: Optional[List[Dict[str, Any]]] = None,
412
414
  explicit_joins: Optional[List[Any]] = None,
413
415
  loading_joins: Optional[List[Any]] = None
414
416
  ) -> List[Dict[str, Any]]:
@@ -74,6 +74,8 @@ class ErrorCode(Enum):
74
74
  SERVICE_NOT_REGISTERED = ErrorResponse(5003, "GENERAL_SERVICE_UNAVAILABLE", 503, "서비스를 사용할 수 없습니다")
75
75
  LOGIN_ERROR = ErrorResponse(5004, "LOGIN_ERROR", 401, "로그인 오류")
76
76
  TOKEN_ERROR = ErrorResponse(5005, "TOKEN_ERROR", 401, "토큰 오류")
77
+ DELETE_ERROR = ErrorResponse(5006, "DELETE_ERROR", 400, "삭제 오류")
78
+
77
79
 
78
80
  class CustomException(Exception):
79
81
  """사용자 정의 예외 클래스"""
@@ -1,19 +1,17 @@
1
1
  """보안 관련 유틸리티."""
2
2
  from datetime import datetime, timedelta, timezone
3
- from typing import Dict, Any, Optional, Literal, Callable, TYPE_CHECKING, TypeVar, Type
3
+ from typing import Dict, Any, Optional, Literal, Callable, TYPE_CHECKING, TypeVar
4
4
  from fastapi import Request, HTTPException, status
5
5
  from functools import wraps
6
6
  from jose import jwt, JWTError
7
7
  from passlib.context import CryptContext
8
8
  import logging
9
9
  from sqlalchemy.ext.asyncio import AsyncSession
10
- from sqlalchemy.orm import DeclarativeBase
11
10
  from .exceptions import CustomException, ErrorCode
12
11
  from .enums import ActivityType
13
- from .database import log_create
14
12
 
15
13
  pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
16
- ModelType = TypeVar("ModelType", bound=DeclarativeBase)
14
+ ModelType = TypeVar("ModelType")
17
15
 
18
16
  # 전역 rate limit 상태 저장
19
17
  _rate_limits: Dict[str, Dict[str, Any]] = {}
@@ -134,7 +132,7 @@ def rate_limit(
134
132
  return decorator
135
133
 
136
134
  async def create_jwt_token(
137
- user_data: Type[ModelType],
135
+ user_data: Optional[ModelType],
138
136
  token_type: Literal["access", "refresh"],
139
137
  db_session: AsyncSession,
140
138
  token_settings: Dict[str, Any],
@@ -164,10 +162,10 @@ async def create_jwt_token(
164
162
  "token_type": token_type,
165
163
 
166
164
  # 조직 관련 클레임
167
- "organization_ulid": user_data.role.organization.ulid,
168
- "organization_id": user_data.role.organization.id,
169
- "organization_name": user_data.role.organization.name,
170
- "company_name": user_data.role.organization.company.name
165
+ "organization_ulid": user_data.role.team.organization.ulid,
166
+ "organization_id": user_data.role.team.organization.id,
167
+ "organization_name": user_data.role.team.organization.name,
168
+ "company_name": user_data.role.team.organization.company.name
171
169
  }
172
170
  else: # refresh token
173
171
  expires_at = datetime.now(timezone.utc) + timedelta(days=14)
@@ -0,0 +1,2 @@
1
+ """버전 정보"""
2
+ __version__ = "0.2.80"
@@ -1,2 +0,0 @@
1
- """버전 정보"""
2
- __version__ = "0.2.78"
File without changes
File without changes
File without changes
File without changes