evserver 0.3.0__tar.gz → 0.4.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.
- {evserver-0.3.0 → evserver-0.4.0}/PKG-INFO +1 -1
- {evserver-0.3.0 → evserver-0.4.0}/pyproject.toml +1 -1
- {evserver-0.3.0 → evserver-0.4.0}/pyproject.toml.orig +1 -1
- {evserver-0.3.0 → evserver-0.4.0}/src/evserver/__init__.py +24 -21
- {evserver-0.3.0 → evserver-0.4.0}/src/evserver/types.py +2 -2
- {evserver-0.3.0 → evserver-0.4.0}/README.md +0 -0
- {evserver-0.3.0 → evserver-0.4.0}/src/evserver/stores.py +0 -0
|
@@ -34,22 +34,25 @@ class State(TypedDict):
|
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
@asynccontextmanager
|
|
37
|
-
async def lifespan(
|
|
37
|
+
async def lifespan(application: FastAPI) -> AsyncGenerator[None]:
|
|
38
38
|
root_path = Path("data")
|
|
39
|
-
user_store = DirectoryStore[UserId, User](root_path / "users")
|
|
40
|
-
workspace_store = DirectoryStore[WorkspaceId, Workspace](
|
|
41
|
-
|
|
42
|
-
manifest_store = DirectoryStore[ManifestId, Manifest](root_path / "manifests")
|
|
43
|
-
reference_store = DirectoryStore[ReferenceId, Reference](root_path / "references")
|
|
44
|
-
content_store = DirectoryStore[ContentId, Content](root_path / "contents")
|
|
45
|
-
yield State(
|
|
46
|
-
user_store=user_store,
|
|
47
|
-
workspace_store=workspace_store,
|
|
48
|
-
snapshot_store=snapshot_store,
|
|
49
|
-
manifest_store=manifest_store,
|
|
50
|
-
reference_store=reference_store,
|
|
51
|
-
content_store=content_store,
|
|
39
|
+
application.state.user_store = DirectoryStore[UserId, User](root_path / "users")
|
|
40
|
+
application.state.workspace_store = DirectoryStore[WorkspaceId, Workspace](
|
|
41
|
+
root_path / "workspaces"
|
|
52
42
|
)
|
|
43
|
+
application.state.snapshot_store = DirectoryStore[SnapshotId, Snapshot](
|
|
44
|
+
root_path / "snapshots"
|
|
45
|
+
)
|
|
46
|
+
application.state.manifest_store = DirectoryStore[ManifestId, Manifest](
|
|
47
|
+
root_path / "manifests"
|
|
48
|
+
)
|
|
49
|
+
application.state.reference_store = DirectoryStore[ReferenceId, Reference](
|
|
50
|
+
root_path / "references"
|
|
51
|
+
)
|
|
52
|
+
application.state.content_store = DirectoryStore[ContentId, Content](
|
|
53
|
+
root_path / "contents"
|
|
54
|
+
)
|
|
55
|
+
yield
|
|
53
56
|
|
|
54
57
|
|
|
55
58
|
application = FastAPI(lifespan=lifespan)
|
|
@@ -128,7 +131,7 @@ async def put_user(
|
|
|
128
131
|
"/user/{user_id}",
|
|
129
132
|
)
|
|
130
133
|
async def delete_user(user_id: UserId, user_store: UserStoreDependency) -> None:
|
|
131
|
-
if user_store.contains(user_id):
|
|
134
|
+
if await user_store.contains(user_id):
|
|
132
135
|
await user_store.delete(user_id)
|
|
133
136
|
|
|
134
137
|
|
|
@@ -171,7 +174,7 @@ async def put_workspace(
|
|
|
171
174
|
async def delete_workspace(
|
|
172
175
|
workspace_id: WorkspaceId, workspace_store: WorkspaceStoreDependency
|
|
173
176
|
) -> None:
|
|
174
|
-
if workspace_store.contains(workspace_id):
|
|
177
|
+
if await workspace_store.contains(workspace_id):
|
|
175
178
|
await workspace_store.delete(workspace_id)
|
|
176
179
|
|
|
177
180
|
|
|
@@ -214,7 +217,7 @@ async def put_snapshot(
|
|
|
214
217
|
async def delete_snapshot(
|
|
215
218
|
snapshot_id: SnapshotId, snapshot_store: SnapshotDependency
|
|
216
219
|
) -> None:
|
|
217
|
-
if snapshot_store.contains(snapshot_id):
|
|
220
|
+
if await snapshot_store.contains(snapshot_id):
|
|
218
221
|
await snapshot_store.delete(snapshot_id)
|
|
219
222
|
|
|
220
223
|
|
|
@@ -257,7 +260,7 @@ async def put_manifest(
|
|
|
257
260
|
async def delete_manifest(
|
|
258
261
|
manifest_id: ManifestId, manifest_store: ManifestStoreDependency
|
|
259
262
|
) -> None:
|
|
260
|
-
if manifest_store.contains(manifest_id):
|
|
263
|
+
if await manifest_store.contains(manifest_id):
|
|
261
264
|
await manifest_store.delete(manifest_id)
|
|
262
265
|
|
|
263
266
|
|
|
@@ -300,7 +303,7 @@ async def put_reference(
|
|
|
300
303
|
async def delete_reference(
|
|
301
304
|
reference_id: ReferenceId, reference_store: ReferenceStoreDependency
|
|
302
305
|
) -> None:
|
|
303
|
-
if reference_store.contains(reference_id):
|
|
306
|
+
if await reference_store.contains(reference_id):
|
|
304
307
|
await reference_store.delete(reference_id)
|
|
305
308
|
|
|
306
309
|
|
|
@@ -343,9 +346,9 @@ async def put_content(
|
|
|
343
346
|
async def delete_content(
|
|
344
347
|
content_id: ContentId, content_store: ContentStoreDependency
|
|
345
348
|
) -> None:
|
|
346
|
-
if content_store.contains(content_id):
|
|
349
|
+
if await content_store.contains(content_id):
|
|
347
350
|
await content_store.delete(content_id)
|
|
348
351
|
|
|
349
352
|
|
|
350
353
|
def main() -> None:
|
|
351
|
-
uvicorn.run("evserver:application")
|
|
354
|
+
uvicorn.run("evserver:application", host="0.0.0.0", port=80) # noqa: S104
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
from hashlib import sha3_512
|
|
2
|
-
from pathlib import
|
|
2
|
+
from pathlib import PurePosixPath # noqa: TC003
|
|
3
3
|
|
|
4
4
|
from pydantic.dataclasses import dataclass
|
|
5
5
|
|
|
@@ -28,7 +28,7 @@ class Content:
|
|
|
28
28
|
|
|
29
29
|
@dataclass(slots=True)
|
|
30
30
|
class Reference:
|
|
31
|
-
file_path:
|
|
31
|
+
file_path: PurePosixPath
|
|
32
32
|
content_id: ContentId
|
|
33
33
|
|
|
34
34
|
@property
|
|
File without changes
|
|
File without changes
|