apexdevkit 2.0.2__py3-none-any.whl → 2.1.2__py3-none-any.whl

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/__init__.py CHANGED
@@ -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)
@@ -1,7 +1,8 @@
1
- from apexdevkit.repository.sql.sqlite.repository import SqliteRepository
2
- from apexdevkit.repository.sql.sqlite.table import SqliteTableBuilder
1
+ from .repository import SqliteRepository
2
+ from .table import SqliteTableBuilder, SqlTable
3
3
 
4
4
  __all__ = [
5
5
  "SqliteRepository",
6
6
  "SqliteTableBuilder",
7
+ "SqlTable",
7
8
  ]
@@ -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.*)
@@ -1,10 +1,10 @@
1
- apexdevkit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
1
+ apexdevkit/__init__.py,sha256=BLEJbrXMCj3iUBH5PJtSGW-GP3ROiJFxoDiQfe9B4yE,115
2
2
  apexdevkit/annotation/__init__.py,sha256=pgFxbJ_Ip8MnsqwIc3A_aczneVMi_T4v1s0VQ4qX4b4,81
3
3
  apexdevkit/annotation/deprecate.py,sha256=tQId6WjSSGZ9w2SrmEFOuHV1TvEcx66IPBcZGb9pTJU,1538
4
4
  apexdevkit/date.py,sha256=mIuwErEMJOVcbgvUOagwHtyNTeQD2qoW9BXS81_ZbOE,2171
5
5
  apexdevkit/error.py,sha256=13Bl1JBWSREjaho_cL5lB_9eXorV72axXq2QFQE1GhM,1242
6
6
  apexdevkit/fastapi/__init__.py,sha256=LFmDbJ4wtjsW8QrwQOXYbVgaToG92DYf9cD-QHjEcM8,448
7
- apexdevkit/fastapi/builder.py,sha256=UqU_S80ZioE3NdLVIcmIG_jiJL9obgvO8yj00muUKJ4,3342
7
+ apexdevkit/fastapi/builder.py,sha256=J0UN_kzKnEAbD66QAVdpuNN28cgbu0PcKRoNWZIQpo0,4455
8
8
  apexdevkit/fastapi/dependable.py,sha256=qz-APhCj4l2LHJPilzk2d-6zgN5vmS7T1XnPTW73vtk,3701
9
9
  apexdevkit/fastapi/docs.py,sha256=ihx0pXDnepixSP9qDonBJ0wKZLNy6Ns6sdZjaC3T15I,215
10
10
  apexdevkit/fastapi/name.py,sha256=6nmN4V_20YadzzTPSEU2ZJQs9hUkWxzTTa2GQE8qj8M,801
@@ -30,12 +30,12 @@ apexdevkit/repository/in_memory/mixin.py,sha256=aFr5Cg0B_g_i5ZTZ1fzlunfG-7W3MV0_
30
30
  apexdevkit/repository/in_memory/repository.py,sha256=YYHF2rWxGKubb8UZke21Bfqkq61q1RbrsQs3Ag_-NDQ,2150
31
31
  apexdevkit/repository/in_memory/store.py,sha256=yjW3rlMCKYAUc86uD-JgCAGEHpgWuV2iYnfqmNKJ2U4,1220
32
32
  apexdevkit/repository/sql/__init__.py,sha256=Ja-NQCPyDu5RSP1DP1yxJqnXD0ORViEkN-ig6Nsm8MI,267
33
- apexdevkit/repository/sql/connector.py,sha256=Z5xeOS5fQyY3FEYLiEb6i0wTR7MyQCe5owltUYweHEI,2798
33
+ apexdevkit/repository/sql/connector.py,sha256=fTxKsQPRhc6yym0dl527w95NHddV7oEnCL2uOJXdwYk,2395
34
34
  apexdevkit/repository/sql/field.py,sha256=xmWGqG4je1xe5g_xZcReC_i0nVj3OVjaOojJr9j_UdU,9118
35
35
  apexdevkit/repository/sql/mssql/__init__.py,sha256=fKa2AHkRfyDGe80PGcxjcX77JBNZ2hQOCnpE1eB0GRQ,200
36
36
  apexdevkit/repository/sql/mssql/repository.py,sha256=icKY_iMzePb4p56c-1zfOVVQBplxhVzArVgCoqm7L-4,2487
37
37
  apexdevkit/repository/sql/mssql/table.py,sha256=ZUeCTcYNoEqQmO3UXn_C4ZP-awa2vbEa3CKK8wYqWJ8,9628
38
- apexdevkit/repository/sql/sqlite/__init__.py,sha256=TW4TJVOOw001zfcKUPNKNRxodnjxV4y7dUVqv5lPk-o,215
38
+ apexdevkit/repository/sql/sqlite/__init__.py,sha256=9dvXTRuH7n7nikljorlGTTnk0fzJ0vSnFITP2zfUKRM,178
39
39
  apexdevkit/repository/sql/sqlite/repository.py,sha256=2D05AldaecKdA4W4x2BwWhLmshyROJv83n3rCqgAkTM,2130
40
40
  apexdevkit/repository/sql/sqlite/table.py,sha256=tWzZi9Is4prMQ99ACVjw50WcJCNsD_CcF55wpx-vm2M,7494
41
41
  apexdevkit/server.py,sha256=reL8hiOgjyHeZw00UTzhYRuzRg2xK3Lt-IAtoSLaRVQ,4326
@@ -45,7 +45,7 @@ apexdevkit/sync/source.py,sha256=c2Yf47CDLjuxDcMllV7pibdocvHpU5p2LPP6Moqttsw,383
45
45
  apexdevkit/sync/sync.py,sha256=xh36xhwlubjUnLgTYnooOIw4EtpFWtK0nN68UK6vBjs,4723
46
46
  apexdevkit/sync/target.py,sha256=SVApnIrG_o9uf0s4iFiDOZl4ch8Kv9s3PQFM09ItttY,2653
47
47
  apexdevkit/testing.py,sha256=xaDJsipEB6a9PHFiP2PB86K-dcVZ_A7NJFSxRNAEt5k,4378
48
- apexdevkit-2.0.2.dist-info/METADATA,sha256=E4Vn4_08CcO0dhdR4qqXyaO7a4d1OUafTEltltrbegg,645
49
- apexdevkit-2.0.2.dist-info/WHEEL,sha256=EGEvSphFYqXKs23-kQBeyNoJP1nrT8ZJKQoi5p5DYL8,88
50
- apexdevkit-2.0.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
51
- apexdevkit-2.0.2.dist-info/RECORD,,
48
+ apexdevkit-2.1.2.dist-info/METADATA,sha256=bxRzDDQ2lj4ZdrqYNvMSOIAjvkjkaVoZ26KenVdYac4,696
49
+ apexdevkit-2.1.2.dist-info/WHEEL,sha256=L-WvLdSBvJWHXv5zrQxDvNRnIgoBzLUpcbuiw19KCuQ,88
50
+ apexdevkit-2.1.2.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
51
+ apexdevkit-2.1.2.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.4.0
2
+ Generator: poetry-core 2.5.0
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any