sharedkernel 2.8.0__tar.gz → 2.9.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.
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/PKG-INFO +4 -1
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/README.md +2 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/setup.py +2 -1
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/config.py +0 -1
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/database/cache/redis_generic_cache.py +1 -1
- sharedkernel-2.9.0/sharedkernel/enum/__init__.py +7 -0
- sharedkernel-2.9.0/sharedkernel/enum/error_code.py +21 -0
- sharedkernel-2.9.0/sharedkernel/enum/feature_display_type.py +5 -0
- sharedkernel-2.9.0/sharedkernel/enum/feature_key.py +11 -0
- sharedkernel-2.9.0/sharedkernel/enum/order_type.py +5 -0
- sharedkernel-2.9.0/sharedkernel/enum/plan_interval.py +7 -0
- sharedkernel-2.9.0/sharedkernel/enum/plan_type.py +7 -0
- sharedkernel-2.9.0/sharedkernel/objects/subscription.py +33 -0
- sharedkernel-2.9.0/sharedkernel/toolbox_service.py +70 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel.egg-info/PKG-INFO +4 -1
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel.egg-info/SOURCES.txt +7 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel.egg-info/requires.txt +1 -0
- sharedkernel-2.8.0/sharedkernel/enum/__init__.py +0 -2
- sharedkernel-2.8.0/sharedkernel/enum/error_code.py +0 -11
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/setup.cfg +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/chunker/chunk_rule.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/chunker/text_chunker.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/common.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/data_format_converter.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/database/__init__.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/database/audit_model.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/database/cache/__init__.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/database/cache/cache_repository.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/database/distributed_cache.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/database/mongo_generic_audit_repository.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/database/mongo_generic_repository.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/database/mongo_health_checker.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/database/pagination_response_dto.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/date_converter.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/diff_utils.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/enum/redis_mode_enum.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/enum/sort_order.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/exception/__init__.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/exception/exception.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/exception/exception_handlers.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/file_validation.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/ip_session_service.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/jwt_service.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/logger/log_decorator.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/logger/log_dto.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/logger/log_enums.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/logger/log_info.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/logger/log_middlewares.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/logger/logger_service.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/multipart_upload.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/normalizer/__init__.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/normalizer/number_normalizer.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/normalizer/phone_number_normalizer.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/normalizer/string_normalizer.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/objects/__init__.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/objects/base_document.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/objects/json_string_model.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/objects/jwt_model.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/objects/result.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/objects/user_info.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/regex_masking.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/s3_uploader.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/string_extentions.py +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel.egg-info/dependency_links.txt +0 -0
- {sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sharedkernel
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.9.0
|
|
4
4
|
Summary: sharekernel is a shared package between all python projects
|
|
5
5
|
Author: Smilinno
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -21,6 +21,7 @@ Requires-Dist: beautifulsoup4
|
|
|
21
21
|
Requires-Dist: deepdiff
|
|
22
22
|
Requires-Dist: kombu
|
|
23
23
|
Requires-Dist: redis==8.0.0
|
|
24
|
+
Requires-Dist: aiohttp
|
|
24
25
|
Dynamic: author
|
|
25
26
|
Dynamic: description
|
|
26
27
|
Dynamic: description-content-type
|
|
@@ -31,6 +32,8 @@ Dynamic: summary
|
|
|
31
32
|
this is a shared kernel package
|
|
32
33
|
|
|
33
34
|
# Change Log
|
|
35
|
+
### Version 2.9.0
|
|
36
|
+
- Add toolbox_service
|
|
34
37
|
### Version 2.8.0
|
|
35
38
|
- Add chunker for tts
|
|
36
39
|
### Version 2.7.0
|
|
@@ -41,9 +41,10 @@ setup(
|
|
|
41
41
|
"deepdiff",
|
|
42
42
|
"kombu",
|
|
43
43
|
"redis==8.0.0",
|
|
44
|
+
"aiohttp",
|
|
44
45
|
],
|
|
45
46
|
# *strongly* suggested for sharing
|
|
46
|
-
version="2.
|
|
47
|
+
version="2.9.0",
|
|
47
48
|
description="sharekernel is a shared package between all python projects",
|
|
48
49
|
long_description=long_description,
|
|
49
50
|
long_description_content_type="text/markdown",
|
|
@@ -26,7 +26,6 @@ IP_SESSION_CACHE_DATABASE_NUMBER = os.getenv("IP_SESSION_CACHE_DATABASE_NUMBER")
|
|
|
26
26
|
REDIS_URL = os.getenv("REDIS_URL")
|
|
27
27
|
REDIS_PASSWORD = os.getenv("REDIS_PASSWORD")
|
|
28
28
|
REDIS_USER = os.getenv("REDIS_USER")
|
|
29
|
-
REDIS_CONNECTION_STRING = os.getenv("REDIS_CONNECTION_STRING")
|
|
30
29
|
CACHE_DATABASE_NUMBER = os.getenv("CACHE_DATABASE_NUMBER")
|
|
31
30
|
REDIS_CONNECTION_STRING = os.getenv(
|
|
32
31
|
"REDIS_CONNECTION_STRING", f"redis://{REDIS_USER}:{REDIS_PASSWORD}@{REDIS_URL}"
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
from .error_code import ErrorCode
|
|
2
|
+
from .redis_mode_enum import RedisMode
|
|
3
|
+
from .feature_key import FeatureKey
|
|
4
|
+
from .plan_type import PlanType
|
|
5
|
+
from .plan_interval import PlanInterval
|
|
6
|
+
from .order_type import OrderType
|
|
7
|
+
from .feature_display_type import FeatureDisplayType
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
from enum import Enum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class ErrorCode(str, Enum):
|
|
5
|
+
Item_NotFound = "یافت نشد"
|
|
6
|
+
Internal_Server = "خطایی در سیستم رخ داده است"
|
|
7
|
+
UnAuthorized = "توکن دسترسی معتبر نمی باشد"
|
|
8
|
+
Success = "با موفقیت انجام شد"
|
|
9
|
+
Intents_Count_Should_Equal_One = "فقط یک اینتنت میتوانید وارد نمایید"
|
|
10
|
+
Unsupported_Date_Type = "تاریخ داده شده پیشتیبانی نمیشود."
|
|
11
|
+
Unsupported_IP = "آی پی داده شده معتبر نمی باشد"
|
|
12
|
+
Subscription_Not_Found = "اشتراک فعالی برای شما یافت نشد"
|
|
13
|
+
Subscription_Insufficient_Bot_Feature = "اعتبار شما برای ساخت بات کافی نیست"
|
|
14
|
+
Subscription_Insufficient_Message_Feature = "اعتبار شما برای ارسال پیام کافی نیست"
|
|
15
|
+
Subscription_Insufficient_URL_FEATURE = "اعتبار تعداد پردازش آدرس شما به اتمام رسیده"
|
|
16
|
+
Subscription_Insufficient_TEXT_FEATURE = "اعتبار تعداد پردازش متن شما به اتمام رسیده"
|
|
17
|
+
Subscription_Insufficient_FILE_FEATURE = "اعتبار تعداد پردازش فایل شما به اتمام رسیده"
|
|
18
|
+
Subscription_Insufficient_OCR_FEATURE = "اعتبار تعداد پردازش صفحات تصویر به متن شما به اتمام رسیده"
|
|
19
|
+
Subscription_Insufficient_TTS_FEATURE = "اعتبار تعداد پردازش متن به گفتار شما به اتمام رسیده"
|
|
20
|
+
Subscription_Insufficient_ASR_FEATURE = "اعتبار تعداد پردازش گفتار به متن شما به اتمام رسیده"
|
|
21
|
+
Subscription_Expired = "اشتراک شما منقضی شده است"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
from datetime import datetime
|
|
2
|
+
from typing import List, Optional
|
|
3
|
+
from pydantic import BaseModel
|
|
4
|
+
from sharedkernel.objects.base_document import BaseDocument
|
|
5
|
+
from sharedkernel.enum import PlanInterval, OrderType, PlanType, FeatureKey, FeatureDisplayType
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class SubscriptionFeature(BaseModel):
|
|
9
|
+
feature_key: FeatureKey
|
|
10
|
+
feature_unit: Optional[str] = None
|
|
11
|
+
remaining: int
|
|
12
|
+
original: int
|
|
13
|
+
title: str
|
|
14
|
+
description: Optional[str] = None
|
|
15
|
+
display_type: FeatureDisplayType = FeatureDisplayType.CIRCULAR
|
|
16
|
+
|
|
17
|
+
class Subscription(BaseDocument):
|
|
18
|
+
order_id: str
|
|
19
|
+
plan_id: str
|
|
20
|
+
plan_title: str
|
|
21
|
+
user_id: str
|
|
22
|
+
workspace_id: str
|
|
23
|
+
interval: PlanInterval
|
|
24
|
+
interval_count: int
|
|
25
|
+
type: OrderType
|
|
26
|
+
plan_type: PlanType | None = PlanType.FREE
|
|
27
|
+
features: List[SubscriptionFeature] | None = []
|
|
28
|
+
paid_at: datetime | None = None
|
|
29
|
+
from_date: datetime | None = None
|
|
30
|
+
to_date: datetime | None = None
|
|
31
|
+
is_active: bool
|
|
32
|
+
sum_messages: int | None = 0
|
|
33
|
+
avg_messages: float | None = 0
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
from typing import Type
|
|
2
|
+
from pydantic import BaseModel
|
|
3
|
+
import aiohttp
|
|
4
|
+
|
|
5
|
+
from sharedkernel.objects.result import Result
|
|
6
|
+
from sharedkernel.enum import FeatureKey, PlanType
|
|
7
|
+
from sharedkernel.enum import ErrorCode
|
|
8
|
+
from sharedkernel.objects.subscription import Subscription
|
|
9
|
+
from sharedkernel.exception.exception import BusinessException
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ToolboxService:
|
|
13
|
+
def __init__(self, cache):
|
|
14
|
+
self.cache = cache
|
|
15
|
+
|
|
16
|
+
async def send_request(
|
|
17
|
+
self,
|
|
18
|
+
method: str,
|
|
19
|
+
endpoint: str,
|
|
20
|
+
payload: dict = None,
|
|
21
|
+
params: dict | None = None,
|
|
22
|
+
headers: dict | None = None,
|
|
23
|
+
model: Type[BaseModel] | None = None,
|
|
24
|
+
) -> Result:
|
|
25
|
+
|
|
26
|
+
async with aiohttp.ClientSession() as session:
|
|
27
|
+
async with session.request(
|
|
28
|
+
method=method.upper(),
|
|
29
|
+
url=endpoint,
|
|
30
|
+
json=payload,
|
|
31
|
+
params=params,
|
|
32
|
+
headers=headers,
|
|
33
|
+
) as response:
|
|
34
|
+
|
|
35
|
+
response_data = await response.json()
|
|
36
|
+
return Result(
|
|
37
|
+
**response_data,
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def check_user_subscription(
|
|
43
|
+
self,
|
|
44
|
+
user_subscription: Subscription,
|
|
45
|
+
feature: FeatureKey,
|
|
46
|
+
quantity: int = 1
|
|
47
|
+
):
|
|
48
|
+
|
|
49
|
+
feature_errors = {
|
|
50
|
+
FeatureKey.MESSAGES: ErrorCode.Subscription_Insufficient_Message_Feature,
|
|
51
|
+
FeatureKey.BOTS: ErrorCode.Subscription_Insufficient_Bot_Feature,
|
|
52
|
+
FeatureKey.URLS: ErrorCode.Subscription_Insufficient_URL_FEATURE,
|
|
53
|
+
FeatureKey.TEXTS: ErrorCode.Subscription_Insufficient_TEXT_FEATURE,
|
|
54
|
+
FeatureKey.FILES: ErrorCode.Subscription_Insufficient_FILE_FEATURE,
|
|
55
|
+
FeatureKey.OCR: ErrorCode.Subscription_Insufficient_OCR_FEATURE,
|
|
56
|
+
FeatureKey.TTS: ErrorCode.Subscription_Insufficient_TTS_FEATURE,
|
|
57
|
+
FeatureKey.ASR: ErrorCode.Subscription_Insufficient_ASR_FEATURE,
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if not user_subscription:
|
|
61
|
+
raise BusinessException(error_code=ErrorCode.Subscription_Not_Found)
|
|
62
|
+
|
|
63
|
+
if user_subscription.plan_type == PlanType.UNLIMITED:
|
|
64
|
+
return
|
|
65
|
+
|
|
66
|
+
for _feature in user_subscription.features:
|
|
67
|
+
if _feature.feature_key == feature:
|
|
68
|
+
if _feature.remaining - quantity < 0:
|
|
69
|
+
raise BusinessException(error_code=feature_errors[feature])
|
|
70
|
+
break
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sharedkernel
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.9.0
|
|
4
4
|
Summary: sharekernel is a shared package between all python projects
|
|
5
5
|
Author: Smilinno
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -21,6 +21,7 @@ Requires-Dist: beautifulsoup4
|
|
|
21
21
|
Requires-Dist: deepdiff
|
|
22
22
|
Requires-Dist: kombu
|
|
23
23
|
Requires-Dist: redis==8.0.0
|
|
24
|
+
Requires-Dist: aiohttp
|
|
24
25
|
Dynamic: author
|
|
25
26
|
Dynamic: description
|
|
26
27
|
Dynamic: description-content-type
|
|
@@ -31,6 +32,8 @@ Dynamic: summary
|
|
|
31
32
|
this is a shared kernel package
|
|
32
33
|
|
|
33
34
|
# Change Log
|
|
35
|
+
### Version 2.9.0
|
|
36
|
+
- Add toolbox_service
|
|
34
37
|
### Version 2.8.0
|
|
35
38
|
- Add chunker for tts
|
|
36
39
|
### Version 2.7.0
|
|
@@ -12,6 +12,7 @@ sharedkernel/multipart_upload.py
|
|
|
12
12
|
sharedkernel/regex_masking.py
|
|
13
13
|
sharedkernel/s3_uploader.py
|
|
14
14
|
sharedkernel/string_extentions.py
|
|
15
|
+
sharedkernel/toolbox_service.py
|
|
15
16
|
sharedkernel.egg-info/PKG-INFO
|
|
16
17
|
sharedkernel.egg-info/SOURCES.txt
|
|
17
18
|
sharedkernel.egg-info/dependency_links.txt
|
|
@@ -31,6 +32,11 @@ sharedkernel/database/cache/cache_repository.py
|
|
|
31
32
|
sharedkernel/database/cache/redis_generic_cache.py
|
|
32
33
|
sharedkernel/enum/__init__.py
|
|
33
34
|
sharedkernel/enum/error_code.py
|
|
35
|
+
sharedkernel/enum/feature_display_type.py
|
|
36
|
+
sharedkernel/enum/feature_key.py
|
|
37
|
+
sharedkernel/enum/order_type.py
|
|
38
|
+
sharedkernel/enum/plan_interval.py
|
|
39
|
+
sharedkernel/enum/plan_type.py
|
|
34
40
|
sharedkernel/enum/redis_mode_enum.py
|
|
35
41
|
sharedkernel/enum/sort_order.py
|
|
36
42
|
sharedkernel/exception/__init__.py
|
|
@@ -51,4 +57,5 @@ sharedkernel/objects/base_document.py
|
|
|
51
57
|
sharedkernel/objects/json_string_model.py
|
|
52
58
|
sharedkernel/objects/jwt_model.py
|
|
53
59
|
sharedkernel/objects/result.py
|
|
60
|
+
sharedkernel/objects/subscription.py
|
|
54
61
|
sharedkernel/objects/user_info.py
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
from enum import Enum
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class ErrorCode(str, Enum):
|
|
5
|
-
Item_NotFound = "یافت نشد"
|
|
6
|
-
Internal_Server = "خطایی در سیستم رخ داده است"
|
|
7
|
-
UnAuthorized = "توکن دسترسی معتبر نمی باشد"
|
|
8
|
-
Success = "با موفقیت انجام شد"
|
|
9
|
-
Intents_Count_Should_Equal_One = "فقط یک اینتنت میتوانید وارد نمایید"
|
|
10
|
-
Unsupported_Date_Type = "تاریخ داده شده پیشتیبانی نمیشود."
|
|
11
|
-
Unsupported_IP = "آی پی داده شده معتبر نمی باشد"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/database/mongo_generic_audit_repository.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{sharedkernel-2.8.0 → sharedkernel-2.9.0}/sharedkernel/normalizer/phone_number_normalizer.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|