apexdevkit 2.0.2__tar.gz → 2.1.2__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.
Files changed (53) hide show
  1. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/PKG-INFO +2 -1
  2. apexdevkit-2.1.2/apexdevkit/__init__.py +7 -0
  3. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/fastapi/builder.py +51 -11
  4. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/sql/connector.py +2 -18
  5. apexdevkit-2.1.2/apexdevkit/repository/sql/sqlite/__init__.py +8 -0
  6. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/pyproject.toml +2 -2
  7. apexdevkit-2.0.2/apexdevkit/__init__.py +0 -0
  8. apexdevkit-2.0.2/apexdevkit/repository/sql/sqlite/__init__.py +0 -7
  9. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/LICENSE +0 -0
  10. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/README.md +0 -0
  11. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/annotation/__init__.py +0 -0
  12. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/annotation/deprecate.py +0 -0
  13. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/date.py +0 -0
  14. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/error.py +0 -0
  15. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/fastapi/__init__.py +0 -0
  16. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/fastapi/dependable.py +0 -0
  17. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/fastapi/docs.py +0 -0
  18. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/fastapi/name.py +0 -0
  19. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/fastapi/resource.py +0 -0
  20. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/fastapi/response.py +0 -0
  21. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/fastapi/router.py +0 -0
  22. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/fastapi/schema.py +0 -0
  23. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/fastapi/service.py +0 -0
  24. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/formatter.py +0 -0
  25. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/key_fn.py +0 -0
  26. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/py.typed +0 -0
  27. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/query/__init__.py +0 -0
  28. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/query/generator.py +0 -0
  29. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/query/query.py +0 -0
  30. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/__init__.py +0 -0
  31. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/core/__init__.py +0 -0
  32. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/core/database.py +0 -0
  33. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/core/decorator.py +0 -0
  34. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/core/interface.py +0 -0
  35. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/core/mixin.py +0 -0
  36. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/in_memory/__init__.py +0 -0
  37. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/in_memory/mixin.py +0 -0
  38. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/in_memory/repository.py +0 -0
  39. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/in_memory/store.py +0 -0
  40. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/sql/__init__.py +0 -0
  41. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/sql/field.py +0 -0
  42. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/sql/mssql/__init__.py +0 -0
  43. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/sql/mssql/repository.py +0 -0
  44. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/sql/mssql/table.py +0 -0
  45. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/sql/sqlite/repository.py +0 -0
  46. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/repository/sql/sqlite/table.py +0 -0
  47. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/server.py +0 -0
  48. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/sync/__init__.py +0 -0
  49. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/sync/observer.py +0 -0
  50. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/sync/source.py +0 -0
  51. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/sync/sync.py +0 -0
  52. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/sync/target.py +0 -0
  53. {apexdevkit-2.0.2 → apexdevkit-2.1.2}/apexdevkit/testing.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: apexdevkit
3
- Version: 2.0.2
3
+ Version: 2.1.2
4
4
  Summary: Apex Development Tools for python.
5
5
  License-File: LICENSE
6
6
  Author: Apex Dev
@@ -10,6 +10,7 @@ Classifier: Programming Language :: Python :: 3
10
10
  Classifier: Programming Language :: Python :: 3.12
11
11
  Classifier: Programming Language :: Python :: 3.13
12
12
  Classifier: Programming Language :: Python :: 3.14
13
+ Classifier: Programming Language :: Python :: 3.15
13
14
  Requires-Dist: fastapi
14
15
  Requires-Dist: pydantic
15
16
  Requires-Dist: pymssql (==2.*)
@@ -0,0 +1,7 @@
1
+ from dotenv import load_dotenv
2
+ from fastapi import FastAPI
3
+
4
+ __all__ = [
5
+ "FastAPI",
6
+ "load_dotenv",
7
+ ]
@@ -1,14 +1,15 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  from abc import ABC, abstractmethod
4
- from collections.abc import Mapping
4
+ from collections.abc import Mapping, MutableSet
5
5
  from dataclasses import dataclass, field
6
- from typing import Any, Self
6
+ from typing import Any, Protocol, Self
7
7
 
8
8
  from fastapi import APIRouter, FastAPI
9
9
  from fastapi.middleware.cors import CORSMiddleware
10
10
  from fastapi.responses import JSONResponse
11
11
 
12
+ from apexdevkit.annotation import deprecated
12
13
  from apexdevkit.error import ApiError
13
14
  from apexdevkit.fastapi.dependable import DependableBuilder
14
15
  from apexdevkit.fastapi.service import RestfulService
@@ -65,22 +66,61 @@ class FastApiBuilder:
65
66
 
66
67
  return self
67
68
 
69
+ @deprecated(
70
+ warning="""
71
+ .with_frontend is deprecated
72
+ use .apply(CORSApplicator()) instead
73
+ """
74
+ )
68
75
  def with_frontend(self, origin: str) -> Self: # pragma: no cover
69
- self.app.add_middleware(
70
- CORSMiddleware,
71
- allow_origins=[origin],
72
- allow_credentials=True,
73
- allow_methods=["*"],
74
- allow_headers=["*"],
75
- )
76
-
77
- return self
76
+ return self.apply(CORSApplicator().with_origin(origin))
78
77
 
79
78
  def with_swagger(self, **config: Any) -> Self: # pragma: no cover
80
79
  self.app.swagger_ui_parameters = config
81
80
 
82
81
  return self
83
82
 
83
+ def apply(self, applicator: Applicator) -> Self:
84
+ applicator.apply_to(self.app)
85
+
86
+ return self
87
+
88
+
89
+ class Applicator(Protocol):
90
+ def apply_to(self, app: FastAPI) -> None:
91
+ pass
92
+
93
+
94
+ @dataclass(frozen=True)
95
+ class CORSApplicator:
96
+ origins: MutableSet[str] = field(default_factory=set)
97
+
98
+ def and_origin(self, origin: str) -> Self:
99
+ return self.with_origin(origin)
100
+
101
+ def with_origin(self, origin: str) -> Self:
102
+ self.origins.add(origin)
103
+
104
+ return self
105
+
106
+ def and_localhost(self, port: int) -> Self:
107
+ return self.with_localhost(port)
108
+
109
+ def with_localhost(self, port: int) -> Self:
110
+ self.origins.add(f"http://localhost:{port}")
111
+ self.origins.add(f"http://127.0.0.1:{port}")
112
+
113
+ return self
114
+
115
+ def apply_to(self, app: FastAPI) -> None:
116
+ app.add_middleware(
117
+ CORSMiddleware,
118
+ allow_origins=list(self.origins),
119
+ allow_credentials=True,
120
+ allow_methods=["*"],
121
+ allow_headers=["*"],
122
+ )
123
+
84
124
 
85
125
  @dataclass
86
126
  class RestfulServiceBuilder(ABC):
@@ -3,7 +3,6 @@ from __future__ import annotations
3
3
  import sqlite3
4
4
  from contextlib import AbstractContextManager
5
5
  from dataclasses import dataclass
6
- from functools import cached_property
7
6
  from typing import Any
8
7
 
9
8
  import pymssql
@@ -18,25 +17,10 @@ class SqliteFileConnector:
18
17
  dsn: str = Environment().inject(variable="DSN")
19
18
 
20
19
  def connect(self) -> AbstractContextManager[Connection]:
21
- connection = sqlite3.connect(self.dsn)
20
+ connection = sqlite3.connect(self.dsn, autocommit=True)
22
21
  connection.row_factory = sqlite3.Row
23
22
 
24
- return connection
25
-
26
-
27
- @dataclass(frozen=True)
28
- class SqliteInMemoryConnector:
29
- dsn: str = ":memory:"
30
-
31
- def connect(self) -> AbstractContextManager[Connection]:
32
- return self._connection
33
-
34
- @cached_property
35
- def _connection(self) -> AbstractContextManager[Connection]:
36
- connection = sqlite3.connect(self.dsn, check_same_thread=False)
37
- connection.row_factory = sqlite3.Row
38
-
39
- return connection
23
+ return ConnectionContextManager(connection)
40
24
 
41
25
 
42
26
  @dataclass(frozen=True)
@@ -0,0 +1,8 @@
1
+ from .repository import SqliteRepository
2
+ from .table import SqliteTableBuilder, SqlTable
3
+
4
+ __all__ = [
5
+ "SqliteRepository",
6
+ "SqliteTableBuilder",
7
+ "SqlTable",
8
+ ]
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "apexdevkit"
3
- version = "2.0.2"
3
+ version = "2.1.2"
4
4
  description = "Apex Development Tools for python."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -79,5 +79,5 @@ show_missing = true
79
79
 
80
80
  [tool.pytest]
81
81
  env = [
82
- "ECHO_SERVER=http://localhost:8080"
82
+ "ECHO_SERVER=http://localhost:8080",
83
83
  ]
File without changes
@@ -1,7 +0,0 @@
1
- from apexdevkit.repository.sql.sqlite.repository import SqliteRepository
2
- from apexdevkit.repository.sql.sqlite.table import SqliteTableBuilder
3
-
4
- __all__ = [
5
- "SqliteRepository",
6
- "SqliteTableBuilder",
7
- ]
File without changes
File without changes