apexdevkit 1.20.6__tar.gz → 1.21.1__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.
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/PKG-INFO +1 -1
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/fastapi/service.py +9 -6
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/repository/decorator.py +3 -4
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/repository/in_memory.py +2 -37
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/value.py +1 -1
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/pyproject.toml +1 -1
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/LICENSE +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/README.md +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/environment.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/error.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/fastapi/builder.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/fastapi/dependable.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/fastapi/name.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/fastapi/request.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/fastapi/resource.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/fastapi/router.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/fastapi/schema.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/fluent.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/formatter.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/http/httpx/__init__.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/http/httpx/client.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/http/httpx/hooks.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/id.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/key_fn.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/query/__init__.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/query/generator.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/query/query.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/repository/base.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/repository/interface.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/repository/mssql.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/repository/sql.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/repository/sqlite.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/server.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/synchronization.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/testing/fake.py +0 -0
- {apexdevkit-1.20.6 → apexdevkit-1.21.1}/apexdevkit/testing/rest.py +0 -0
|
@@ -2,11 +2,12 @@ from __future__ import annotations
|
|
|
2
2
|
|
|
3
3
|
from abc import ABC
|
|
4
4
|
from dataclasses import dataclass
|
|
5
|
+
from functools import cached_property
|
|
5
6
|
from typing import Any, Dict, Generic, Iterable, Mapping, TypeVar
|
|
6
7
|
|
|
7
8
|
from apexdevkit.formatter import Formatter
|
|
8
9
|
from apexdevkit.query.query import FooterOptions, QueryOptions, Summary
|
|
9
|
-
from apexdevkit.repository.decorator import
|
|
10
|
+
from apexdevkit.repository.decorator import BruteForceBatch
|
|
10
11
|
from apexdevkit.repository.interface import Repository
|
|
11
12
|
|
|
12
13
|
RawItem = Mapping[str, Any]
|
|
@@ -68,13 +69,17 @@ class RestfulRepository(RestfulService, Generic[ItemT]):
|
|
|
68
69
|
|
|
69
70
|
formatter: Formatter[Mapping[str, Any], ItemT]
|
|
70
71
|
|
|
72
|
+
@cached_property
|
|
73
|
+
def _batch(self) -> BruteForceBatch[ItemT]:
|
|
74
|
+
return BruteForceBatch(self.repository)
|
|
75
|
+
|
|
71
76
|
def create_one(self, item: RawItem) -> RawItem:
|
|
72
77
|
return self.formatter.dump(self.repository.create(self.formatter.load(item)))
|
|
73
78
|
|
|
74
79
|
def create_many(self, items: RawCollection) -> RawCollection:
|
|
75
80
|
return [
|
|
76
81
|
self.formatter.dump(item)
|
|
77
|
-
for item in
|
|
82
|
+
for item in self._batch.create_many(
|
|
78
83
|
[self.formatter.load(fields) for fields in items]
|
|
79
84
|
)
|
|
80
85
|
]
|
|
@@ -101,7 +106,7 @@ class RestfulRepository(RestfulService, Generic[ItemT]):
|
|
|
101
106
|
|
|
102
107
|
updates.append(self.formatter.load(data))
|
|
103
108
|
|
|
104
|
-
|
|
109
|
+
self._batch.update_many(updates)
|
|
105
110
|
|
|
106
111
|
return [self.formatter.dump(item) for item in updates]
|
|
107
112
|
|
|
@@ -111,9 +116,7 @@ class RestfulRepository(RestfulService, Generic[ItemT]):
|
|
|
111
116
|
return item
|
|
112
117
|
|
|
113
118
|
def replace_many(self, items: RawCollection) -> RawCollection:
|
|
114
|
-
|
|
115
|
-
[self.formatter.load(item) for item in items]
|
|
116
|
-
)
|
|
119
|
+
self._batch.update_many([self.formatter.load(item) for item in items])
|
|
117
120
|
|
|
118
121
|
return items
|
|
119
122
|
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
|
-
from typing import Any, Iterable, Iterator
|
|
2
|
+
from typing import Any, Generic, Iterable, Iterator
|
|
3
3
|
|
|
4
|
-
from apexdevkit.repository.base import RepositoryBase
|
|
5
4
|
from apexdevkit.repository.interface import ItemT, Repository
|
|
6
5
|
|
|
7
6
|
|
|
8
7
|
@dataclass
|
|
9
|
-
class RepositoryDecorator(
|
|
8
|
+
class RepositoryDecorator(Generic[ItemT]): # pragma: no cover
|
|
10
9
|
inner: Repository[ItemT]
|
|
11
10
|
|
|
12
11
|
def create(self, item: ItemT) -> ItemT:
|
|
@@ -31,7 +30,7 @@ class RepositoryDecorator(RepositoryBase[ItemT]):
|
|
|
31
30
|
return self.inner.__len__()
|
|
32
31
|
|
|
33
32
|
|
|
34
|
-
class
|
|
33
|
+
class BruteForceBatch(RepositoryDecorator[ItemT]):
|
|
35
34
|
def create_many(self, items: Iterable[ItemT]) -> Iterable[ItemT]:
|
|
36
35
|
return [self.inner.create(item) for item in items]
|
|
37
36
|
|
|
@@ -19,25 +19,14 @@ class InMemoryRepository(Generic[ItemT]):
|
|
|
19
19
|
keys: list[_KeyFunction[ItemT]] = field(default_factory=list)
|
|
20
20
|
seeds: frozenset[ItemT] = field(default_factory=frozenset)
|
|
21
21
|
|
|
22
|
-
def with_namespace(self, value: str) -> InMemoryRepository[ItemT]:
|
|
23
|
-
return InMemoryRepository[ItemT](
|
|
24
|
-
store=StoreNamespace(value, self.store),
|
|
25
|
-
keys=self.keys,
|
|
26
|
-
seeds=self.seeds,
|
|
27
|
-
)
|
|
28
|
-
|
|
29
22
|
def with_store(self, value: KeyValueStore[ItemT]) -> InMemoryRepository[ItemT]:
|
|
30
|
-
return InMemoryRepository
|
|
31
|
-
store=value,
|
|
32
|
-
keys=self.keys,
|
|
33
|
-
seeds=self.seeds,
|
|
34
|
-
)
|
|
23
|
+
return InMemoryRepository(store=value, keys=self.keys, seeds=self.seeds)
|
|
35
24
|
|
|
36
25
|
def and_key(self, function: _KeyFunction[ItemT]) -> InMemoryRepository[ItemT]:
|
|
37
26
|
return self.with_key(function)
|
|
38
27
|
|
|
39
28
|
def with_key(self, function: _KeyFunction[ItemT]) -> InMemoryRepository[ItemT]:
|
|
40
|
-
return InMemoryRepository
|
|
29
|
+
return InMemoryRepository(
|
|
41
30
|
store=self.store,
|
|
42
31
|
keys=[*self.keys, function],
|
|
43
32
|
seeds=self.seeds,
|
|
@@ -113,30 +102,6 @@ class InMemoryByteStore(Generic[ItemT]):
|
|
|
113
102
|
yield self.formatter.load(raw)
|
|
114
103
|
|
|
115
104
|
|
|
116
|
-
@dataclass
|
|
117
|
-
class StoreNamespace(Generic[ItemT]):
|
|
118
|
-
name: str
|
|
119
|
-
inner: KeyValueStore[ItemT]
|
|
120
|
-
|
|
121
|
-
def count(self) -> int:
|
|
122
|
-
return self.inner.count()
|
|
123
|
-
|
|
124
|
-
def values(self) -> Iterable[ItemT]:
|
|
125
|
-
return self.inner.values()
|
|
126
|
-
|
|
127
|
-
def set(self, key: str, value: ItemT) -> None:
|
|
128
|
-
self.inner.set(self._expand(key), value)
|
|
129
|
-
|
|
130
|
-
def get(self, key: str) -> ItemT:
|
|
131
|
-
return self.inner.get(self._expand(key))
|
|
132
|
-
|
|
133
|
-
def drop(self, key: str) -> None:
|
|
134
|
-
self.inner.drop(self._expand(key))
|
|
135
|
-
|
|
136
|
-
def _expand(self, key: str) -> str:
|
|
137
|
-
return "-".join([self.name, key])
|
|
138
|
-
|
|
139
|
-
|
|
140
105
|
@dataclass
|
|
141
106
|
class _SingleKeyRepository(RepositoryBase[ItemT]):
|
|
142
107
|
store: KeyValueStore[ItemT]
|
|
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
|