kiba-core 0.5.3.dev77__tar.gz → 0.5.3.dev79__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.
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/PKG-INFO +1 -1
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/locks/sql.py +2 -1
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/queues/sql.py +3 -2
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/store/database.py +11 -6
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/store/entity_repository.py +3 -2
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/store/retriever.py +22 -22
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/store/saver.py +5 -5
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/kiba_core.egg-info/PKG-INFO +1 -1
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/pyproject.toml +1 -1
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/.github/pull_request_template.md +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/.github/workflows/deploy.yml +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/.github/workflows/pull-request.yml +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/.github/workflows/release.yml +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/.gitignore +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/CHANGELOG.md +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/Dockerfile +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/README.md +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/api_request.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/api_response.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/authorizer.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/default_routes.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/health.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/json_route.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/middleware/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/middleware/database_connection_middleware.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/middleware/exception_handling_middleware.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/middleware/logging_middleware.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/middleware/origin_ip_middleware.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/middleware/server_headers_middleware.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/openapi.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/rate_limit.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/request_context.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/route.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/route_auth.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/route_metadata.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/streaming_json_route.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/aws_requester.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/caching/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/caching/cache.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/caching/dict_cache.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/caching/file_cache.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/cron/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/cron/api_request_cron_job_processor.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/cron/cron_executor.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/cron/cron_job_processor.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/cron/model.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/exceptions.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/http/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/http/basic_authentication.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/http/jwt.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/http/rest_method.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/locks/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/locks/lock.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/locks/model.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/logging.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/notifications/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/notifications/discord_client.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/notifications/notification_client.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/notifications/slack_client.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/py.typed +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/queues/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/queues/aqs.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/queues/cosmos.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/queues/message_queue.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/queues/message_queue_processor.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/queues/model.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/queues/sqs.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/requester/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/requester/requester.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/s3_manager.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/service_client.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/store/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/util/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/util/async_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/util/chain_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/util/date_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/util/dict_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/util/file_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/util/hashing_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/util/http_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/util/json_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/util/list_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/util/process_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/util/string_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/util/typing_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/util/url_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/util/value_holder.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/web3/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/web3/eth_client.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/web3/eth_client_registry.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/web3/multicall3.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/kiba_core.egg-info/SOURCES.txt +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/kiba_core.egg-info/dependency_links.txt +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/kiba_core.egg-info/requires.txt +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/kiba_core.egg-info/top_level.txt +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/makefile +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/setup.cfg +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/api/test_api_response.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/api/test_authorizer.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/api/test_exception_handling_middleware.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/api/test_json_route.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/api/test_openapi.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/api/test_origin_ip_middleware.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/api/test_rate_limit.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/api/test_request_context.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/api/test_route.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/api/test_streaming_json_route.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/caching/test_dict_cache.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/caching/test_file_cache.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/cron/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/cron/test_cron_executor.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/locks/test_sql_lock.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/queues/conftest.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/queues/test_aqs_queue.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/queues/test_cosmos_queue.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/queues/test_message_queue_processor.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/queues/test_sql_queue.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/queues/test_sqs_queue.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/requester/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/requester/test_requester.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/test_database.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/test_entity_repository.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/test_exceptions.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/test_logging.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/util/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/util/test_async_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/util/test_chain_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/util/test_date_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/util/test_dict_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/util/test_file_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/util/test_json_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/util/test_list_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/util/test_process_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/util/test_string_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/util/test_url_util.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/web3/__init__.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/web3/test_eth_client_registry.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/web3/test_rest_eth_client.py +0 -0
- {kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/uv.lock +0 -0
|
@@ -11,6 +11,7 @@ from core.exceptions import LockedException
|
|
|
11
11
|
from core.locks.lock import Lock
|
|
12
12
|
from core.locks.model import LockLease
|
|
13
13
|
from core.store.database import Database
|
|
14
|
+
from core.store.database import DatabaseTable
|
|
14
15
|
from core.util import date_util
|
|
15
16
|
from core.util import process_util
|
|
16
17
|
|
|
@@ -31,7 +32,7 @@ LocksTable = sqlalchemy.Table(
|
|
|
31
32
|
|
|
32
33
|
|
|
33
34
|
class SqlLock(Lock):
|
|
34
|
-
def __init__(self, database: Database, table:
|
|
35
|
+
def __init__(self, database: Database, table: DatabaseTable = LocksTable, pollIntervalSeconds: float = 1.0, owner: str | None = None) -> None:
|
|
35
36
|
self.database = database
|
|
36
37
|
self.table = table
|
|
37
38
|
self.pollIntervalSeconds = pollIntervalSeconds
|
|
@@ -16,6 +16,7 @@ from core.exceptions import InternalServerErrorException
|
|
|
16
16
|
from core.queues.message_queue import MessageQueue
|
|
17
17
|
from core.queues.model import Message
|
|
18
18
|
from core.store.database import Database
|
|
19
|
+
from core.store.database import DatabaseTable
|
|
19
20
|
from core.util import process_util
|
|
20
21
|
|
|
21
22
|
MESSAGE_STATUS_PENDING = 'pending'
|
|
@@ -61,7 +62,7 @@ class SqlMessage(Message):
|
|
|
61
62
|
lockToken: str
|
|
62
63
|
|
|
63
64
|
@classmethod
|
|
64
|
-
def from_row(cls, row: RowMapping, table:
|
|
65
|
+
def from_row(cls, row: RowMapping, table: DatabaseTable) -> SqlMessage:
|
|
65
66
|
return cls(
|
|
66
67
|
id=row[table.c.id],
|
|
67
68
|
command=row[table.c.command],
|
|
@@ -79,7 +80,7 @@ class SqlMessageQueue(MessageQueue[SqlMessage]):
|
|
|
79
80
|
self,
|
|
80
81
|
database: Database,
|
|
81
82
|
queueName: str,
|
|
82
|
-
table:
|
|
83
|
+
table: DatabaseTable = QueueMessagesTable,
|
|
83
84
|
pollIntervalSeconds: float = 1.0,
|
|
84
85
|
maxAttempts: int = 3,
|
|
85
86
|
failureRetryDelaySeconds: int = 60,
|
|
@@ -4,7 +4,7 @@ import datetime
|
|
|
4
4
|
import typing
|
|
5
5
|
import weakref
|
|
6
6
|
from collections.abc import AsyncIterator
|
|
7
|
-
from typing import
|
|
7
|
+
from typing import TypeVarTuple
|
|
8
8
|
|
|
9
9
|
import sqlalchemy
|
|
10
10
|
import sqlalchemy.exc
|
|
@@ -12,7 +12,9 @@ from sqlalchemy.engine import Result
|
|
|
12
12
|
from sqlalchemy.ext.asyncio import AsyncConnection
|
|
13
13
|
from sqlalchemy.ext.asyncio import AsyncEngine
|
|
14
14
|
from sqlalchemy.ext.asyncio import create_async_engine
|
|
15
|
+
from sqlalchemy.sql.base import ReadOnlyColumnCollection
|
|
15
16
|
from sqlalchemy.sql.dml import UpdateBase
|
|
17
|
+
from sqlalchemy.sql.elements import KeyedColumnElement
|
|
16
18
|
from sqlalchemy.sql.selectable import TypedReturnsRows
|
|
17
19
|
|
|
18
20
|
from core import logging
|
|
@@ -20,7 +22,10 @@ from core.exceptions import InternalServerErrorException
|
|
|
20
22
|
from core.util import json_util
|
|
21
23
|
|
|
22
24
|
DatabaseConnection = AsyncConnection
|
|
23
|
-
ResultType =
|
|
25
|
+
ResultType = TypeVarTuple('ResultType')
|
|
26
|
+
# NOTE(krishan711): these spell out sqlalchemy 2.1's default column collections. mypy's disallow_any_explicit rejects bare Table / FromClause annotations because the defaults contain Any, but not uses of these aliases
|
|
27
|
+
DatabaseTable = sqlalchemy.Table[ReadOnlyColumnCollection[str, sqlalchemy.Column[typing.Any]]] # type: ignore[explicit-any]
|
|
28
|
+
DatabaseFromClause = sqlalchemy.FromClause[ReadOnlyColumnCollection[str, KeyedColumnElement[typing.Any]]] # type: ignore[explicit-any]
|
|
24
29
|
|
|
25
30
|
|
|
26
31
|
class Database:
|
|
@@ -140,10 +145,10 @@ class Database:
|
|
|
140
145
|
self._connectionContext.reset(token)
|
|
141
146
|
|
|
142
147
|
@typing.overload
|
|
143
|
-
async def execute(self, query: TypedReturnsRows[ResultType], connection: DatabaseConnection | None = None) -> Result[ResultType]: ...
|
|
148
|
+
async def execute(self, query: TypedReturnsRows[*ResultType], connection: DatabaseConnection | None = None) -> Result[*ResultType]: ...
|
|
144
149
|
@typing.overload
|
|
145
|
-
async def execute(self, query: sqlalchemy.sql.Executable, connection: DatabaseConnection | None = None) -> Result[typing.Any]: ... # type: ignore[explicit-any]
|
|
146
|
-
async def execute(self, query: sqlalchemy.sql.Executable, connection: DatabaseConnection | None = None) -> Result[typing.Any]: # type: ignore[explicit-any]
|
|
150
|
+
async def execute(self, query: sqlalchemy.sql.Executable, connection: DatabaseConnection | None = None) -> Result[*tuple[typing.Any, ...]]: ... # type: ignore[explicit-any]
|
|
151
|
+
async def execute(self, query: sqlalchemy.sql.Executable, connection: DatabaseConnection | None = None) -> Result[*tuple[typing.Any, ...]]: # type: ignore[explicit-any]
|
|
147
152
|
if not self._engine:
|
|
148
153
|
raise InternalServerErrorException(message='Connection has not been established. Please called collect() first.')
|
|
149
154
|
if not connection:
|
|
@@ -152,4 +157,4 @@ class Database:
|
|
|
152
157
|
raise InternalServerErrorException(message='No connection found. Please provide a connection or call create_context_connection() for the context.')
|
|
153
158
|
if isinstance(query, UpdateBase):
|
|
154
159
|
self._connectionsWithWrites.add(connection)
|
|
155
|
-
return typing.cast(Result[typing.Any], await connection.execute(statement=query)) # type: ignore[explicit-any]
|
|
160
|
+
return typing.cast(Result[*tuple[typing.Any, ...]], await connection.execute(statement=query)) # type: ignore[explicit-any]
|
|
@@ -14,6 +14,7 @@ from core.exceptions import KibaException
|
|
|
14
14
|
from core.exceptions import NotFoundException
|
|
15
15
|
from core.store.database import Database
|
|
16
16
|
from core.store.database import DatabaseConnection
|
|
17
|
+
from core.store.database import DatabaseTable
|
|
17
18
|
from core.store.retriever import FieldFilter
|
|
18
19
|
from core.store.retriever import Order
|
|
19
20
|
from core.store.retriever import apply_field_filters
|
|
@@ -37,7 +38,7 @@ class EntityRepository(typing.Generic[EntityType]): # noqa: UP046
|
|
|
37
38
|
|
|
38
39
|
def __init__(
|
|
39
40
|
self,
|
|
40
|
-
table:
|
|
41
|
+
table: DatabaseTable,
|
|
41
42
|
modelClass: type[EntityType],
|
|
42
43
|
) -> None:
|
|
43
44
|
self.table = table
|
|
@@ -79,7 +80,7 @@ class EntityRepository(typing.Generic[EntityType]): # noqa: UP046
|
|
|
79
80
|
def from_row(self, row: RowMapping) -> EntityType:
|
|
80
81
|
return self.modelClass.model_validate(self._get_field_values(row=row))
|
|
81
82
|
|
|
82
|
-
def force_from_result(self, result: Result[typing.Any]) -> EntityType: # type: ignore[explicit-any]
|
|
83
|
+
def force_from_result(self, result: Result[*tuple[typing.Any, ...]]) -> EntityType: # type: ignore[explicit-any]
|
|
83
84
|
row = result.mappings().first()
|
|
84
85
|
if row is None:
|
|
85
86
|
raise NotFoundException
|
|
@@ -7,11 +7,11 @@ from enum import Enum
|
|
|
7
7
|
|
|
8
8
|
import sqlalchemy
|
|
9
9
|
import sqlalchemy.sql.functions
|
|
10
|
-
from sqlalchemy import Table
|
|
11
10
|
from sqlalchemy.sql import ColumnElement
|
|
12
11
|
from sqlalchemy.sql import Select
|
|
13
12
|
|
|
14
13
|
from core.store.database import Database
|
|
14
|
+
from core.store.database import DatabaseTable
|
|
15
15
|
from core.store.database import ResultType
|
|
16
16
|
from core.util import date_util
|
|
17
17
|
|
|
@@ -110,7 +110,7 @@ def datetime_to_column_value(column: sqlalchemy.ColumnElement[typing.Any], dt: d
|
|
|
110
110
|
return date_util.datetime_to_utc_naive_datetime(dt=dt)
|
|
111
111
|
|
|
112
112
|
|
|
113
|
-
def apply_order(query: Select[ResultType], table:
|
|
113
|
+
def apply_order(query: Select[*ResultType], table: DatabaseTable, order: Order) -> Select[*ResultType]:
|
|
114
114
|
if isinstance(order, RandomOrder):
|
|
115
115
|
query = query.order_by(sqlalchemy.sql.functions.random())
|
|
116
116
|
else:
|
|
@@ -119,13 +119,13 @@ def apply_order(query: Select[ResultType], table: Table, order: Order) -> Select
|
|
|
119
119
|
return query
|
|
120
120
|
|
|
121
121
|
|
|
122
|
-
def apply_orders(query: Select[ResultType], table:
|
|
122
|
+
def apply_orders(query: Select[*ResultType], table: DatabaseTable, orders: Sequence[Order]) -> Select[*ResultType]:
|
|
123
123
|
for order in orders:
|
|
124
124
|
query = apply_order(query=query, table=table, order=order)
|
|
125
125
|
return query
|
|
126
126
|
|
|
127
127
|
|
|
128
|
-
def get_string_field_filter_conditions(table:
|
|
128
|
+
def get_string_field_filter_conditions(table: DatabaseTable, fieldFilter: StringFieldFilter) -> list[ColumnElement[bool]]:
|
|
129
129
|
field = table.c[fieldFilter.fieldName]
|
|
130
130
|
conditions: list[ColumnElement[bool]] = []
|
|
131
131
|
if fieldFilter.eq is not None:
|
|
@@ -139,7 +139,7 @@ def get_string_field_filter_conditions(table: Table, fieldFilter: StringFieldFil
|
|
|
139
139
|
return conditions
|
|
140
140
|
|
|
141
141
|
|
|
142
|
-
def get_uuid_field_filter_conditions(table:
|
|
142
|
+
def get_uuid_field_filter_conditions(table: DatabaseTable, fieldFilter: UUIDFieldFilter) -> list[ColumnElement[bool]]:
|
|
143
143
|
field = table.c[fieldFilter.fieldName]
|
|
144
144
|
conditions: list[ColumnElement[bool]] = []
|
|
145
145
|
if fieldFilter.eq is not None:
|
|
@@ -153,7 +153,7 @@ def get_uuid_field_filter_conditions(table: Table, fieldFilter: UUIDFieldFilter)
|
|
|
153
153
|
return conditions
|
|
154
154
|
|
|
155
155
|
|
|
156
|
-
def get_date_field_filter_conditions(table:
|
|
156
|
+
def get_date_field_filter_conditions(table: DatabaseTable, fieldFilter: DateFieldFilter) -> list[ColumnElement[bool]]:
|
|
157
157
|
field = table.c[fieldFilter.fieldName]
|
|
158
158
|
conditions: list[ColumnElement[bool]] = []
|
|
159
159
|
if fieldFilter.eq is not None:
|
|
@@ -175,7 +175,7 @@ def get_date_field_filter_conditions(table: Table, fieldFilter: DateFieldFilter)
|
|
|
175
175
|
return conditions
|
|
176
176
|
|
|
177
177
|
|
|
178
|
-
def get_integer_field_filter_conditions(table:
|
|
178
|
+
def get_integer_field_filter_conditions(table: DatabaseTable, fieldFilter: IntegerFieldFilter) -> list[ColumnElement[bool]]:
|
|
179
179
|
# NOTE(krishan711): `field == value` / `field.in_(values)` let SQLAlchemy's `Numeric.coerce_compared_value`
|
|
180
180
|
# re-infer a bind param type from the compared Python `int` (typically `BigInteger`, i.e. int64) instead of
|
|
181
181
|
# keeping `field.type` (e.g. `Numeric(78, 0)` for uint256 columns). Binding explicitly with `type_=field.type`
|
|
@@ -201,7 +201,7 @@ def get_integer_field_filter_conditions(table: Table, fieldFilter: IntegerFieldF
|
|
|
201
201
|
return conditions
|
|
202
202
|
|
|
203
203
|
|
|
204
|
-
def get_float_field_filter_conditions(table:
|
|
204
|
+
def get_float_field_filter_conditions(table: DatabaseTable, fieldFilter: FloatFieldFilter) -> list[ColumnElement[bool]]:
|
|
205
205
|
field = table.c[fieldFilter.fieldName]
|
|
206
206
|
conditions: list[ColumnElement[bool]] = []
|
|
207
207
|
if fieldFilter.eq is not None:
|
|
@@ -223,7 +223,7 @@ def get_float_field_filter_conditions(table: Table, fieldFilter: FloatFieldFilte
|
|
|
223
223
|
return conditions
|
|
224
224
|
|
|
225
225
|
|
|
226
|
-
def get_boolean_field_filter_conditions(table:
|
|
226
|
+
def get_boolean_field_filter_conditions(table: DatabaseTable, fieldFilter: BooleanFieldFilter) -> list[ColumnElement[bool]]:
|
|
227
227
|
field = table.c[fieldFilter.fieldName]
|
|
228
228
|
conditions: list[ColumnElement[bool]] = []
|
|
229
229
|
if fieldFilter.eq is not None:
|
|
@@ -233,7 +233,7 @@ def get_boolean_field_filter_conditions(table: Table, fieldFilter: BooleanFieldF
|
|
|
233
233
|
return conditions
|
|
234
234
|
|
|
235
235
|
|
|
236
|
-
def get_field_filter_conditions(table:
|
|
236
|
+
def get_field_filter_conditions(table: DatabaseTable, fieldFilter: FieldFilter) -> list[ColumnElement[bool]]:
|
|
237
237
|
field = table.c[fieldFilter.fieldName]
|
|
238
238
|
conditions: list[ColumnElement[bool]] = []
|
|
239
239
|
if fieldFilter.isNull:
|
|
@@ -255,11 +255,11 @@ def get_field_filter_conditions(table: Table, fieldFilter: FieldFilter) -> list[
|
|
|
255
255
|
return conditions
|
|
256
256
|
|
|
257
257
|
|
|
258
|
-
def get_field_filters_conditions(table:
|
|
258
|
+
def get_field_filters_conditions(table: DatabaseTable, fieldFilters: Sequence[FieldFilter]) -> list[ColumnElement[bool]]:
|
|
259
259
|
return [condition for fieldFilter in fieldFilters for condition in get_field_filter_conditions(table=table, fieldFilter=fieldFilter)]
|
|
260
260
|
|
|
261
261
|
|
|
262
|
-
def apply_field_filters(query: Select[ResultType], table:
|
|
262
|
+
def apply_field_filters(query: Select[*ResultType], table: DatabaseTable, fieldFilters: Sequence[FieldFilter]) -> Select[*ResultType]:
|
|
263
263
|
return query.where(*get_field_filters_conditions(table=table, fieldFilters=fieldFilters))
|
|
264
264
|
|
|
265
265
|
|
|
@@ -267,32 +267,32 @@ class Retriever:
|
|
|
267
267
|
def __init__(self, database: Database) -> None:
|
|
268
268
|
self.database = database
|
|
269
269
|
|
|
270
|
-
def _apply_order(self, query: Select[ResultType], table:
|
|
270
|
+
def _apply_order(self, query: Select[*ResultType], table: DatabaseTable, order: Order) -> Select[*ResultType]:
|
|
271
271
|
return apply_order(query=query, table=table, order=order)
|
|
272
272
|
|
|
273
|
-
def _apply_orders(self, query: Select[ResultType], table:
|
|
273
|
+
def _apply_orders(self, query: Select[*ResultType], table: DatabaseTable, orders: Sequence[Order]) -> Select[*ResultType]:
|
|
274
274
|
return apply_orders(query=query, table=table, orders=orders)
|
|
275
275
|
|
|
276
|
-
def _apply_string_field_filter(self, query: Select[ResultType], table:
|
|
276
|
+
def _apply_string_field_filter(self, query: Select[*ResultType], table: DatabaseTable, fieldFilter: StringFieldFilter) -> Select[*ResultType]:
|
|
277
277
|
return query.where(*get_string_field_filter_conditions(table=table, fieldFilter=fieldFilter))
|
|
278
278
|
|
|
279
|
-
def _apply_uuid_field_filter(self, query: Select[ResultType], table:
|
|
279
|
+
def _apply_uuid_field_filter(self, query: Select[*ResultType], table: DatabaseTable, fieldFilter: UUIDFieldFilter) -> Select[*ResultType]:
|
|
280
280
|
return query.where(*get_uuid_field_filter_conditions(table=table, fieldFilter=fieldFilter))
|
|
281
281
|
|
|
282
|
-
def _apply_date_field_filter(self, query: Select[ResultType], table:
|
|
282
|
+
def _apply_date_field_filter(self, query: Select[*ResultType], table: DatabaseTable, fieldFilter: DateFieldFilter) -> Select[*ResultType]:
|
|
283
283
|
return query.where(*get_date_field_filter_conditions(table=table, fieldFilter=fieldFilter))
|
|
284
284
|
|
|
285
|
-
def _apply_integer_field_filter(self, query: Select[ResultType], table:
|
|
285
|
+
def _apply_integer_field_filter(self, query: Select[*ResultType], table: DatabaseTable, fieldFilter: IntegerFieldFilter) -> Select[*ResultType]:
|
|
286
286
|
return query.where(*get_integer_field_filter_conditions(table=table, fieldFilter=fieldFilter))
|
|
287
287
|
|
|
288
|
-
def _apply_float_field_filter(self, query: Select[ResultType], table:
|
|
288
|
+
def _apply_float_field_filter(self, query: Select[*ResultType], table: DatabaseTable, fieldFilter: FloatFieldFilter) -> Select[*ResultType]:
|
|
289
289
|
return query.where(*get_float_field_filter_conditions(table=table, fieldFilter=fieldFilter))
|
|
290
290
|
|
|
291
|
-
def _apply_boolean_field_filter(self, query: Select[ResultType], table:
|
|
291
|
+
def _apply_boolean_field_filter(self, query: Select[*ResultType], table: DatabaseTable, fieldFilter: BooleanFieldFilter) -> Select[*ResultType]:
|
|
292
292
|
return query.where(*get_boolean_field_filter_conditions(table=table, fieldFilter=fieldFilter))
|
|
293
293
|
|
|
294
|
-
def _apply_field_filter(self, query: Select[ResultType], table:
|
|
294
|
+
def _apply_field_filter(self, query: Select[*ResultType], table: DatabaseTable, fieldFilter: FieldFilter) -> Select[*ResultType]:
|
|
295
295
|
return query.where(*get_field_filter_conditions(table=table, fieldFilter=fieldFilter))
|
|
296
296
|
|
|
297
|
-
def _apply_field_filters(self, query: Select[ResultType], table:
|
|
297
|
+
def _apply_field_filters(self, query: Select[*ResultType], table: DatabaseTable, fieldFilters: Sequence[FieldFilter]) -> Select[*ResultType]:
|
|
298
298
|
return apply_field_filters(query=query, table=table, fieldFilters=fieldFilters)
|
|
@@ -3,13 +3,13 @@ from collections.abc import AsyncIterator
|
|
|
3
3
|
from typing import TYPE_CHECKING
|
|
4
4
|
from typing import Any
|
|
5
5
|
|
|
6
|
-
from sqlalchemy import Table
|
|
7
6
|
from sqlalchemy.engine import Result
|
|
8
7
|
from sqlalchemy.sql.selectable import TypedReturnsRows
|
|
9
8
|
|
|
10
9
|
from core.exceptions import InternalServerErrorException
|
|
11
10
|
from core.store.database import Database
|
|
12
11
|
from core.store.database import DatabaseConnection
|
|
12
|
+
from core.store.database import DatabaseTable
|
|
13
13
|
from core.store.database import ResultType
|
|
14
14
|
|
|
15
15
|
if TYPE_CHECKING:
|
|
@@ -39,7 +39,7 @@ class Saver:
|
|
|
39
39
|
async with self.database.create_transaction() as connection:
|
|
40
40
|
yield connection
|
|
41
41
|
|
|
42
|
-
async def _execute(self, query: TypedReturnsRows[ResultType], connection: DatabaseConnection | None = None) -> Result[ResultType]:
|
|
42
|
+
async def _execute(self, query: TypedReturnsRows[*ResultType], connection: DatabaseConnection | None = None) -> Result[*ResultType]:
|
|
43
43
|
try:
|
|
44
44
|
if connection:
|
|
45
45
|
return await self.database.execute(query=query, connection=connection)
|
|
@@ -49,19 +49,19 @@ class Saver:
|
|
|
49
49
|
except Exception as exception:
|
|
50
50
|
raise SavingException(message=f'Error running save operation: {exception!s}') from exception
|
|
51
51
|
|
|
52
|
-
async def _insert_record(self, table:
|
|
52
|
+
async def _insert_record(self, table: DatabaseTable, values: CreateRecordValuesDict, connection: DatabaseConnection | None = None) -> int:
|
|
53
53
|
query = table.insert().values(values).returning(table.c.id)
|
|
54
54
|
result = await self._execute(query=query, connection=connection)
|
|
55
55
|
rowId = int(result.scalar_one())
|
|
56
56
|
return rowId
|
|
57
57
|
|
|
58
|
-
async def _update_records(self, table:
|
|
58
|
+
async def _update_records(self, table: DatabaseTable, where: WhereClause, values: UpdateRecordValuesDict, connection: DatabaseConnection | None = None) -> list[int]:
|
|
59
59
|
query = table.update().where(where).values(values).returning(table.c.id)
|
|
60
60
|
result = await self._execute(query=query, connection=connection)
|
|
61
61
|
rowIds = [int(rowId) for rowId in result.scalars()]
|
|
62
62
|
return rowIds
|
|
63
63
|
|
|
64
|
-
async def _delete_records(self, table:
|
|
64
|
+
async def _delete_records(self, table: DatabaseTable, where: WhereClause, connection: DatabaseConnection | None = None) -> list[int]:
|
|
65
65
|
query = table.delete().where(where).returning(table.c.id)
|
|
66
66
|
result = await self._execute(query=query, connection=connection)
|
|
67
67
|
rowIds = [int(rowId) for rowId in result.scalars()]
|
|
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
|
{kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/middleware/exception_handling_middleware.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/core/api/middleware/server_headers_middleware.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
|
|
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
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/api/test_exception_handling_middleware.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
|
{kiba_core-0.5.3.dev77 → kiba_core-0.5.3.dev79}/tests/queues/test_message_queue_processor.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
|
|
File without changes
|