swiftpy-framework 0.1.0__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.
- swiftpy/.gitignore +0 -0
- swiftpy/__init__.py +572 -0
- swiftpy/admin/__init__.py +50 -0
- swiftpy/admin/auth.py +522 -0
- swiftpy/admin/registry.py +567 -0
- swiftpy/admin/views.py +1583 -0
- swiftpy/ai/__init__.py +199 -0
- swiftpy/ai/_deterministic.py +40 -0
- swiftpy/ai/_fake.py +604 -0
- swiftpy/ai/agents/__init__.py +30 -0
- swiftpy/ai/agents/base_agent.py +506 -0
- swiftpy/ai/agents/memory.py +864 -0
- swiftpy/ai/client.py +1011 -0
- swiftpy/ai/conversation.py +171 -0
- swiftpy/ai/embeddings.py +321 -0
- swiftpy/ai/exceptions.py +75 -0
- swiftpy/ai/history_strategies.py +157 -0
- swiftpy/ai/middleware.py +918 -0
- swiftpy/ai/observability/__init__.py +28 -0
- swiftpy/ai/observability/drivers.py +763 -0
- swiftpy/ai/observability/observer.py +364 -0
- swiftpy/ai/pool.py +102 -0
- swiftpy/ai/pricing.py +101 -0
- swiftpy/ai/prompts/__init__.py +6 -0
- swiftpy/ai/prompts/loader.py +343 -0
- swiftpy/ai/providers/__init__.py +22 -0
- swiftpy/ai/providers/anthropic_provider.py +353 -0
- swiftpy/ai/providers/base.py +273 -0
- swiftpy/ai/providers/openai_provider.py +275 -0
- swiftpy/ai/rag/__init__.py +53 -0
- swiftpy/ai/rag/context_formatter.py +263 -0
- swiftpy/ai/rag/pipeline_builder.py +544 -0
- swiftpy/ai/rag/reranker.py +484 -0
- swiftpy/ai/rag/result.py +78 -0
- swiftpy/ai/rag/retriever.py +315 -0
- swiftpy/ai/redis_store.py +227 -0
- swiftpy/ai/streaming.py +115 -0
- swiftpy/ai/tools/__init__.py +22 -0
- swiftpy/ai/tools/base_tool.py +489 -0
- swiftpy/ai/tools/first_party.py +384 -0
- swiftpy/ai/tools/tool_loop.py +417 -0
- swiftpy/ai/vectorstore/__init__.py +46 -0
- swiftpy/ai/vectorstore/base.py +542 -0
- swiftpy/ai/vectorstore/chroma_adapter.py +435 -0
- swiftpy/ai/vectorstore/in_memory_adapter.py +321 -0
- swiftpy/ai/vectorstore/lancedb_adapter.py +370 -0
- swiftpy/ai/vectorstore/pgvector_adapter.py +496 -0
- swiftpy/ai/vectorstore/pinecone_adapter.py +445 -0
- swiftpy/ai/vectorstore/qdrant_adapter.py +418 -0
- swiftpy/auth/__init__.py +50 -0
- swiftpy/auth/api_key_guard.py +544 -0
- swiftpy/auth/auth_manager.py +259 -0
- swiftpy/auth/exceptions.py +71 -0
- swiftpy/auth/jwt_guard.py +230 -0
- swiftpy/auth/jwt_issuer.py +658 -0
- swiftpy/auth/token_blacklist.py +300 -0
- swiftpy/cache/__init__.py +14 -0
- swiftpy/cache/cache.py +251 -0
- swiftpy/cache/driver.py +216 -0
- swiftpy/cache/drivers/memory.py +199 -0
- swiftpy/cache/drivers/redis.py +421 -0
- swiftpy/console/__init__.py +0 -0
- swiftpy/console/cli.py +68 -0
- swiftpy/console/commands/__init__.py +0 -0
- swiftpy/console/commands/cache.py +164 -0
- swiftpy/console/commands/make.py +935 -0
- swiftpy/console/commands/migrate.py +280 -0
- swiftpy/console/commands/new.py +1806 -0
- swiftpy/console/commands/queue.py +306 -0
- swiftpy/console/commands/seed.py +252 -0
- swiftpy/console/commands/start.py +171 -0
- swiftpy/console/commands/storage.py +104 -0
- swiftpy/console/loader.py +21 -0
- swiftpy/console/stubs/__init__.py +26 -0
- swiftpy/console/stubs/controller.stub +14 -0
- swiftpy/console/stubs/event.stub +14 -0
- swiftpy/console/stubs/job.stub +22 -0
- swiftpy/console/stubs/listener.stub +14 -0
- swiftpy/console/stubs/mail.stub +20 -0
- swiftpy/console/stubs/middleware.stub +16 -0
- swiftpy/console/stubs/migration.alter.stub +17 -0
- swiftpy/console/stubs/migration.api_keys.stub +22 -0
- swiftpy/console/stubs/migration.blank.stub +11 -0
- swiftpy/console/stubs/migration.create.stub +15 -0
- swiftpy/console/stubs/migration.stub +11 -0
- swiftpy/console/stubs/migration.update.stub +17 -0
- swiftpy/console/stubs/model.stub +17 -0
- swiftpy/console/stubs/provider.stub +18 -0
- swiftpy/console/stubs/repository.stub +10 -0
- swiftpy/console/stubs/request.stub +16 -0
- swiftpy/console/stubs/resource.stub +21 -0
- swiftpy/console/stubs/schema.stub +12 -0
- swiftpy/console/stubs/seeder.stub +14 -0
- swiftpy/console/stubs/service.stub +10 -0
- swiftpy/core/__init__.py +0 -0
- swiftpy/core/application.py +1306 -0
- swiftpy/core/bootstrap.py +30 -0
- swiftpy/core/config.py +432 -0
- swiftpy/core/container.py +596 -0
- swiftpy/core/container_exceptions.py +18 -0
- swiftpy/core/context.py +148 -0
- swiftpy/core/exceptions.py +352 -0
- swiftpy/core/providers/base.py +35 -0
- swiftpy/database/__init__.py +41 -0
- swiftpy/database/exceptions.py +42 -0
- swiftpy/database/identifiers.py +105 -0
- swiftpy/database/migrations/__init__.py +36 -0
- swiftpy/database/migrations/blueprint.py +431 -0
- swiftpy/database/migrations/lock.py +104 -0
- swiftpy/database/migrations/migration.py +22 -0
- swiftpy/database/migrations/migrator.py +507 -0
- swiftpy/database/migrations/schema.py +435 -0
- swiftpy/database/orm/__init__.py +33 -0
- swiftpy/database/orm/fields.py +92 -0
- swiftpy/database/orm/model.py +2034 -0
- swiftpy/database/orm/registry.py +33 -0
- swiftpy/database/orm/relationships.py +836 -0
- swiftpy/database/pagination/__init__.py +16 -0
- swiftpy/database/pagination/contracts.py +60 -0
- swiftpy/database/pagination/paginator.py +112 -0
- swiftpy/database/pagination/simple_paginator.py +97 -0
- swiftpy/database/pool.py +218 -0
- swiftpy/database/query_builder.py +1803 -0
- swiftpy/database/seeder.py +39 -0
- swiftpy/database/transaction.py +276 -0
- swiftpy/events/__init__.py +10 -0
- swiftpy/events/dispatcher.py +308 -0
- swiftpy/events/redis_bus.py +552 -0
- swiftpy/filesystem/__init__.py +227 -0
- swiftpy/filesystem/disk.py +378 -0
- swiftpy/filesystem/drivers/__init__.py +11 -0
- swiftpy/filesystem/drivers/base.py +156 -0
- swiftpy/filesystem/drivers/local.py +559 -0
- swiftpy/filesystem/drivers/s3.py +655 -0
- swiftpy/filesystem/events.py +37 -0
- swiftpy/filesystem/exceptions.py +127 -0
- swiftpy/filesystem/manager.py +138 -0
- swiftpy/filesystem/metadata.py +22 -0
- swiftpy/filesystem/paths.py +99 -0
- swiftpy/filesystem/service_provider.py +17 -0
- swiftpy/filesystem/uploads/__init__.py +13 -0
- swiftpy/filesystem/uploads/handlers.py +362 -0
- swiftpy/filesystem/uploads/uploaded_file.py +222 -0
- swiftpy/filesystem/uploads/validators.py +186 -0
- swiftpy/filesystem/visibility.py +22 -0
- swiftpy/helpers/__init__.py +42 -0
- swiftpy/helpers/helper.py +180 -0
- swiftpy/http/exceptions.py +41 -0
- swiftpy/http/middleware.py +307 -0
- swiftpy/http/request.py +375 -0
- swiftpy/http/response.py +442 -0
- swiftpy/http/router.py +1050 -0
- swiftpy/mail/__init__.py +58 -0
- swiftpy/mail/attachments.py +255 -0
- swiftpy/mail/config.py +71 -0
- swiftpy/mail/envelope.py +183 -0
- swiftpy/mail/exceptions.py +90 -0
- swiftpy/mail/facade.py +312 -0
- swiftpy/mail/mailable.py +53 -0
- swiftpy/mail/manager.py +240 -0
- swiftpy/mail/message.py +186 -0
- swiftpy/mail/models.py +19 -0
- swiftpy/mail/queue/__init__.py +5 -0
- swiftpy/mail/queue/job.py +279 -0
- swiftpy/mail/service_provider.py +19 -0
- swiftpy/mail/templates/__init__.py +5 -0
- swiftpy/mail/templates/renderer.py +173 -0
- swiftpy/mail/transports/__init__.py +21 -0
- swiftpy/mail/transports/api/__init__.py +13 -0
- swiftpy/mail/transports/api/base.py +194 -0
- swiftpy/mail/transports/api/mailgun.py +158 -0
- swiftpy/mail/transports/api/resend.py +156 -0
- swiftpy/mail/transports/api/sendgrid.py +172 -0
- swiftpy/mail/transports/base.py +24 -0
- swiftpy/mail/transports/console.py +91 -0
- swiftpy/mail/transports/sendmail.py +128 -0
- swiftpy/mail/transports/smtp.py +466 -0
- swiftpy/queue/__init__.py +13 -0
- swiftpy/queue/dispatcher.py +813 -0
- swiftpy/queue/job.py +541 -0
- swiftpy/queue/worker.py +556 -0
- swiftpy/support/__init__.py +12 -0
- swiftpy/support/keys.py +108 -0
- swiftpy/support/redis_config.py +223 -0
- swiftpy/support/strings.py +114 -0
- swiftpy/testing/__init__.py +20 -0
- swiftpy/testing/fakes/__init__.py +11 -0
- swiftpy/testing/fakes/ai_fake.py +21 -0
- swiftpy/testing/fakes/vectorstore_fake.py +194 -0
- swiftpy/testing/fixtures.py +124 -0
- swiftpy/testing/http_client.py +730 -0
- swiftpy/testing/test_case.py +126 -0
- swiftpy/validation/__init__.py +97 -0
- swiftpy/validation/exceptions.py +26 -0
- swiftpy/validation/form_request.py +302 -0
- swiftpy/validation/protocols.py +33 -0
- swiftpy/validation/rules/__init__.py +89 -0
- swiftpy/validation/rules/builtin.py +391 -0
- swiftpy/validation/rules/exists.py +86 -0
- swiftpy/validation/rules/registry.py +290 -0
- swiftpy/validation/rules/required.py +55 -0
- swiftpy/validation/rules/unique.py +138 -0
- swiftpy/validation/validator.py +612 -0
- swiftpy/websockets/__init__.py +19 -0
- swiftpy/websockets/connection.py +317 -0
- swiftpy/websockets/manager.py +271 -0
- swiftpy_framework-0.1.0.dist-info/METADATA +603 -0
- swiftpy_framework-0.1.0.dist-info/RECORD +211 -0
- swiftpy_framework-0.1.0.dist-info/WHEEL +4 -0
- swiftpy_framework-0.1.0.dist-info/entry_points.txt +2 -0
- swiftpy_framework-0.1.0.dist-info/licenses/LICENSE +21 -0
swiftpy/.gitignore
ADDED
|
File without changes
|
swiftpy/__init__.py
ADDED
|
@@ -0,0 +1,572 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import importlib
|
|
4
|
+
from typing import TYPE_CHECKING, Any
|
|
5
|
+
|
|
6
|
+
if TYPE_CHECKING:
|
|
7
|
+
from swiftpy.admin import (
|
|
8
|
+
AdminSite,
|
|
9
|
+
ModelAdmin,
|
|
10
|
+
admin,
|
|
11
|
+
)
|
|
12
|
+
from swiftpy.ai.agents import (
|
|
13
|
+
Agent,
|
|
14
|
+
AgentMemory,
|
|
15
|
+
AgentResponse,
|
|
16
|
+
AgentTask,
|
|
17
|
+
BaseAgent,
|
|
18
|
+
)
|
|
19
|
+
from swiftpy.auth import (
|
|
20
|
+
ApiKeyGuard,
|
|
21
|
+
AuthManager,
|
|
22
|
+
CurrentUser,
|
|
23
|
+
JWTGuard,
|
|
24
|
+
JWTIssuer,
|
|
25
|
+
TokenBlacklist,
|
|
26
|
+
current_user,
|
|
27
|
+
hash_api_key,
|
|
28
|
+
require_api_key,
|
|
29
|
+
require_jwt,
|
|
30
|
+
verify_api_key_hash,
|
|
31
|
+
)
|
|
32
|
+
from swiftpy.cache import (
|
|
33
|
+
Cache,
|
|
34
|
+
CacheDriver,
|
|
35
|
+
CacheManager,
|
|
36
|
+
MemoryDriver,
|
|
37
|
+
RedisDriver,
|
|
38
|
+
)
|
|
39
|
+
from swiftpy.core.application import Application
|
|
40
|
+
from swiftpy.core.config import Config
|
|
41
|
+
from swiftpy.core.container import Container
|
|
42
|
+
from swiftpy.core.container_exceptions import CircularDependencyError
|
|
43
|
+
from swiftpy.core.exceptions import (
|
|
44
|
+
BadRequestError,
|
|
45
|
+
ClientDisconnect,
|
|
46
|
+
ExceptionHandler,
|
|
47
|
+
ForbiddenError,
|
|
48
|
+
HttpException,
|
|
49
|
+
InternalServerError,
|
|
50
|
+
MethodNotAllowedError,
|
|
51
|
+
NotFoundError,
|
|
52
|
+
PayloadTooLargeError,
|
|
53
|
+
UnauthorizedError,
|
|
54
|
+
ValidationError,
|
|
55
|
+
)
|
|
56
|
+
from swiftpy.core.providers.base import ServiceProvider
|
|
57
|
+
from swiftpy.database import (
|
|
58
|
+
DatabaseError,
|
|
59
|
+
ModelNotFoundError,
|
|
60
|
+
RecordNotFoundError,
|
|
61
|
+
Seeder,
|
|
62
|
+
)
|
|
63
|
+
from swiftpy.database.orm import (
|
|
64
|
+
BelongsTo,
|
|
65
|
+
BelongsToMany,
|
|
66
|
+
Field,
|
|
67
|
+
HasMany,
|
|
68
|
+
HasOne,
|
|
69
|
+
LazyLoadingDisabledError,
|
|
70
|
+
Model,
|
|
71
|
+
RelationNotLoadedError,
|
|
72
|
+
Vector,
|
|
73
|
+
)
|
|
74
|
+
from swiftpy.database.pagination import (
|
|
75
|
+
Paginator,
|
|
76
|
+
SimplePaginator,
|
|
77
|
+
)
|
|
78
|
+
from swiftpy.events import (
|
|
79
|
+
EventDispatcher,
|
|
80
|
+
EventHandler,
|
|
81
|
+
RedisEventBus,
|
|
82
|
+
)
|
|
83
|
+
from swiftpy.filesystem import (
|
|
84
|
+
FileMetadata,
|
|
85
|
+
FilesystemManager,
|
|
86
|
+
LocalStorageDriver,
|
|
87
|
+
PathNormalizer,
|
|
88
|
+
S3StorageDriver,
|
|
89
|
+
Storage,
|
|
90
|
+
StorageDisk,
|
|
91
|
+
StorageDriver,
|
|
92
|
+
UploadedFile,
|
|
93
|
+
Visibility,
|
|
94
|
+
)
|
|
95
|
+
from swiftpy.helpers.helper import (
|
|
96
|
+
app,
|
|
97
|
+
cache,
|
|
98
|
+
config,
|
|
99
|
+
container,
|
|
100
|
+
dispatch,
|
|
101
|
+
dispatcher,
|
|
102
|
+
env,
|
|
103
|
+
env_bool,
|
|
104
|
+
event,
|
|
105
|
+
mail,
|
|
106
|
+
pluralize,
|
|
107
|
+
queue,
|
|
108
|
+
resolve,
|
|
109
|
+
snake_case,
|
|
110
|
+
storage,
|
|
111
|
+
websocket_manager,
|
|
112
|
+
ws_manager,
|
|
113
|
+
)
|
|
114
|
+
from swiftpy.http.middleware import (
|
|
115
|
+
CORS,
|
|
116
|
+
CORSMiddleware,
|
|
117
|
+
Middleware,
|
|
118
|
+
RequestId,
|
|
119
|
+
RequestIdMiddleware,
|
|
120
|
+
SecurityHeaders,
|
|
121
|
+
SecurityHeadersMiddleware,
|
|
122
|
+
)
|
|
123
|
+
from swiftpy.http.request import Request
|
|
124
|
+
from swiftpy.http.response import (
|
|
125
|
+
Response,
|
|
126
|
+
forbidden,
|
|
127
|
+
json_response,
|
|
128
|
+
unauthorized,
|
|
129
|
+
)
|
|
130
|
+
from swiftpy.http.router import RouteGroup, Router
|
|
131
|
+
from swiftpy.mail import (
|
|
132
|
+
Attachment,
|
|
133
|
+
Mail,
|
|
134
|
+
Mailable,
|
|
135
|
+
MailFake,
|
|
136
|
+
MailManager,
|
|
137
|
+
MailMessage,
|
|
138
|
+
MailSendResult,
|
|
139
|
+
MailTransport,
|
|
140
|
+
)
|
|
141
|
+
from swiftpy.queue import (
|
|
142
|
+
Job,
|
|
143
|
+
JobSerializationError,
|
|
144
|
+
QueueDispatcher,
|
|
145
|
+
QueueWorker,
|
|
146
|
+
push,
|
|
147
|
+
)
|
|
148
|
+
from swiftpy.testing import (
|
|
149
|
+
TestCase,
|
|
150
|
+
TestClient,
|
|
151
|
+
TestResponse,
|
|
152
|
+
db_transaction,
|
|
153
|
+
transactional_test,
|
|
154
|
+
)
|
|
155
|
+
from swiftpy.validation import (
|
|
156
|
+
BetweenRule,
|
|
157
|
+
BoolRule,
|
|
158
|
+
EmailRule,
|
|
159
|
+
ExistsRule,
|
|
160
|
+
FloatRule,
|
|
161
|
+
FormRequest,
|
|
162
|
+
InRule,
|
|
163
|
+
IntRule,
|
|
164
|
+
MaxRule,
|
|
165
|
+
MinRule,
|
|
166
|
+
NotInRule,
|
|
167
|
+
NullableRule,
|
|
168
|
+
RegexRule,
|
|
169
|
+
RequiredRule,
|
|
170
|
+
StrRule,
|
|
171
|
+
UniqueRule,
|
|
172
|
+
UrlRule,
|
|
173
|
+
ValidationException,
|
|
174
|
+
ValidationResult,
|
|
175
|
+
Validator,
|
|
176
|
+
ValidatorRule,
|
|
177
|
+
between,
|
|
178
|
+
bool_,
|
|
179
|
+
email,
|
|
180
|
+
exists,
|
|
181
|
+
float_,
|
|
182
|
+
in_,
|
|
183
|
+
int_,
|
|
184
|
+
max_,
|
|
185
|
+
min_,
|
|
186
|
+
not_in,
|
|
187
|
+
nullable,
|
|
188
|
+
regex,
|
|
189
|
+
required,
|
|
190
|
+
str_,
|
|
191
|
+
unique,
|
|
192
|
+
url,
|
|
193
|
+
validate,
|
|
194
|
+
)
|
|
195
|
+
from swiftpy.websockets import (
|
|
196
|
+
WebSocket,
|
|
197
|
+
WebSocketConnection,
|
|
198
|
+
WebSocketDisconnect,
|
|
199
|
+
WebSocketException,
|
|
200
|
+
WebSocketManager,
|
|
201
|
+
WebSocketState,
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
_EXPORT_MAP: dict[str, tuple[str, str]] = {
|
|
205
|
+
'AdminSite': ('swiftpy.admin', 'AdminSite'),
|
|
206
|
+
'Agent': ('swiftpy.ai.agents', 'Agent'),
|
|
207
|
+
'AgentMemory': ('swiftpy.ai.agents', 'AgentMemory'),
|
|
208
|
+
'AgentResponse': ('swiftpy.ai.agents', 'AgentResponse'),
|
|
209
|
+
'AgentTask': ('swiftpy.ai.agents', 'AgentTask'),
|
|
210
|
+
'ApiKeyGuard': ('swiftpy.auth', 'ApiKeyGuard'),
|
|
211
|
+
'Application': ('swiftpy.core.application', 'Application'),
|
|
212
|
+
'Attachment': ('swiftpy.mail', 'Attachment'),
|
|
213
|
+
'AuthManager': ('swiftpy.auth', 'AuthManager'),
|
|
214
|
+
'BadRequestError': ('swiftpy.core.exceptions', 'BadRequestError'),
|
|
215
|
+
'BaseAgent': ('swiftpy.ai.agents', 'BaseAgent'),
|
|
216
|
+
'BelongsTo': ('swiftpy.database.orm', 'BelongsTo'),
|
|
217
|
+
'BelongsToMany': ('swiftpy.database.orm', 'BelongsToMany'),
|
|
218
|
+
'BetweenRule': ('swiftpy.validation', 'BetweenRule'),
|
|
219
|
+
'BoolRule': ('swiftpy.validation', 'BoolRule'),
|
|
220
|
+
'CORS': ('swiftpy.http.middleware', 'CORS'),
|
|
221
|
+
'CORSMiddleware': ('swiftpy.http.middleware', 'CORSMiddleware'),
|
|
222
|
+
'Cache': ('swiftpy.cache', 'Cache'),
|
|
223
|
+
'CacheDriver': ('swiftpy.cache', 'CacheDriver'),
|
|
224
|
+
'CacheManager': ('swiftpy.cache', 'CacheManager'),
|
|
225
|
+
'CircularDependencyError': ('swiftpy.core.container_exceptions', 'CircularDependencyError'),
|
|
226
|
+
'ClientDisconnect': ('swiftpy.core.exceptions', 'ClientDisconnect'),
|
|
227
|
+
'Config': ('swiftpy.core.config', 'Config'),
|
|
228
|
+
'Container': ('swiftpy.core.container', 'Container'),
|
|
229
|
+
'CurrentUser': ('swiftpy.auth', 'CurrentUser'),
|
|
230
|
+
'DatabaseError': ('swiftpy.database', 'DatabaseError'),
|
|
231
|
+
'EmailRule': ('swiftpy.validation', 'EmailRule'),
|
|
232
|
+
'EventDispatcher': ('swiftpy.events', 'EventDispatcher'),
|
|
233
|
+
'EventHandler': ('swiftpy.events', 'EventHandler'),
|
|
234
|
+
'ExceptionHandler': ('swiftpy.core.exceptions', 'ExceptionHandler'),
|
|
235
|
+
'ExistsRule': ('swiftpy.validation', 'ExistsRule'),
|
|
236
|
+
'Field': ('swiftpy.database.orm', 'Field'),
|
|
237
|
+
'FileMetadata': ('swiftpy.filesystem', 'FileMetadata'),
|
|
238
|
+
'FilesystemManager': ('swiftpy.filesystem', 'FilesystemManager'),
|
|
239
|
+
'FloatRule': ('swiftpy.validation', 'FloatRule'),
|
|
240
|
+
'ForbiddenError': ('swiftpy.core.exceptions', 'ForbiddenError'),
|
|
241
|
+
'FormRequest': ('swiftpy.validation', 'FormRequest'),
|
|
242
|
+
'HasMany': ('swiftpy.database.orm', 'HasMany'),
|
|
243
|
+
'HasOne': ('swiftpy.database.orm', 'HasOne'),
|
|
244
|
+
'HttpException': ('swiftpy.core.exceptions', 'HttpException'),
|
|
245
|
+
'InRule': ('swiftpy.validation', 'InRule'),
|
|
246
|
+
'IntRule': ('swiftpy.validation', 'IntRule'),
|
|
247
|
+
'InternalServerError': ('swiftpy.core.exceptions', 'InternalServerError'),
|
|
248
|
+
'JWTGuard': ('swiftpy.auth', 'JWTGuard'),
|
|
249
|
+
'JWTIssuer': ('swiftpy.auth', 'JWTIssuer'),
|
|
250
|
+
'Job': ('swiftpy.queue', 'Job'),
|
|
251
|
+
'JobSerializationError': ('swiftpy.queue', 'JobSerializationError'),
|
|
252
|
+
'LazyLoadingDisabledError': ('swiftpy.database.orm', 'LazyLoadingDisabledError'),
|
|
253
|
+
'LocalStorageDriver': ('swiftpy.filesystem', 'LocalStorageDriver'),
|
|
254
|
+
'Mail': ('swiftpy.mail', 'Mail'),
|
|
255
|
+
'MailFake': ('swiftpy.mail', 'MailFake'),
|
|
256
|
+
'MailManager': ('swiftpy.mail', 'MailManager'),
|
|
257
|
+
'MailMessage': ('swiftpy.mail', 'MailMessage'),
|
|
258
|
+
'MailSendResult': ('swiftpy.mail', 'MailSendResult'),
|
|
259
|
+
'MailTransport': ('swiftpy.mail', 'MailTransport'),
|
|
260
|
+
'Mailable': ('swiftpy.mail', 'Mailable'),
|
|
261
|
+
'MaxRule': ('swiftpy.validation', 'MaxRule'),
|
|
262
|
+
'MemoryDriver': ('swiftpy.cache', 'MemoryDriver'),
|
|
263
|
+
'MethodNotAllowedError': ('swiftpy.core.exceptions', 'MethodNotAllowedError'),
|
|
264
|
+
'Middleware': ('swiftpy.http.middleware', 'Middleware'),
|
|
265
|
+
'MinRule': ('swiftpy.validation', 'MinRule'),
|
|
266
|
+
'Model': ('swiftpy.database.orm', 'Model'),
|
|
267
|
+
'ModelAdmin': ('swiftpy.admin', 'ModelAdmin'),
|
|
268
|
+
'ModelNotFoundError': ('swiftpy.database', 'ModelNotFoundError'),
|
|
269
|
+
'NotFoundError': ('swiftpy.core.exceptions', 'NotFoundError'),
|
|
270
|
+
'NotInRule': ('swiftpy.validation', 'NotInRule'),
|
|
271
|
+
'NullableRule': ('swiftpy.validation', 'NullableRule'),
|
|
272
|
+
'Paginator': ('swiftpy.database.pagination', 'Paginator'),
|
|
273
|
+
'PathNormalizer': ('swiftpy.filesystem', 'PathNormalizer'),
|
|
274
|
+
'PayloadTooLargeError': ('swiftpy.core.exceptions', 'PayloadTooLargeError'),
|
|
275
|
+
'QueueDispatcher': ('swiftpy.queue', 'QueueDispatcher'),
|
|
276
|
+
'QueueWorker': ('swiftpy.queue', 'QueueWorker'),
|
|
277
|
+
'RecordNotFoundError': ('swiftpy.database', 'RecordNotFoundError'),
|
|
278
|
+
'RedisDriver': ('swiftpy.cache', 'RedisDriver'),
|
|
279
|
+
'RedisEventBus': ('swiftpy.events', 'RedisEventBus'),
|
|
280
|
+
'RegexRule': ('swiftpy.validation', 'RegexRule'),
|
|
281
|
+
'RelationNotLoadedError': ('swiftpy.database.orm', 'RelationNotLoadedError'),
|
|
282
|
+
'Request': ('swiftpy.http.request', 'Request'),
|
|
283
|
+
'RequestId': ('swiftpy.http.middleware', 'RequestId'),
|
|
284
|
+
'RequestIdMiddleware': ('swiftpy.http.middleware', 'RequestIdMiddleware'),
|
|
285
|
+
'RequiredRule': ('swiftpy.validation', 'RequiredRule'),
|
|
286
|
+
'Response': ('swiftpy.http.response', 'Response'),
|
|
287
|
+
'RouteGroup': ('swiftpy.http.router', 'RouteGroup'),
|
|
288
|
+
'Router': ('swiftpy.http.router', 'Router'),
|
|
289
|
+
'S3StorageDriver': ('swiftpy.filesystem', 'S3StorageDriver'),
|
|
290
|
+
'SecurityHeaders': ('swiftpy.http.middleware', 'SecurityHeaders'),
|
|
291
|
+
'SecurityHeadersMiddleware': ('swiftpy.http.middleware', 'SecurityHeadersMiddleware'),
|
|
292
|
+
'Seeder': ('swiftpy.database', 'Seeder'),
|
|
293
|
+
'ServiceProvider': ('swiftpy.core.providers.base', 'ServiceProvider'),
|
|
294
|
+
'SimplePaginator': ('swiftpy.database.pagination', 'SimplePaginator'),
|
|
295
|
+
'Storage': ('swiftpy.filesystem', 'Storage'),
|
|
296
|
+
'StorageDisk': ('swiftpy.filesystem', 'StorageDisk'),
|
|
297
|
+
'StorageDriver': ('swiftpy.filesystem', 'StorageDriver'),
|
|
298
|
+
'StrRule': ('swiftpy.validation', 'StrRule'),
|
|
299
|
+
'TestCase': ('swiftpy.testing', 'TestCase'),
|
|
300
|
+
'TestClient': ('swiftpy.testing', 'TestClient'),
|
|
301
|
+
'TestResponse': ('swiftpy.testing', 'TestResponse'),
|
|
302
|
+
'TokenBlacklist': ('swiftpy.auth', 'TokenBlacklist'),
|
|
303
|
+
'UnauthorizedError': ('swiftpy.core.exceptions', 'UnauthorizedError'),
|
|
304
|
+
'UniqueRule': ('swiftpy.validation', 'UniqueRule'),
|
|
305
|
+
'UploadedFile': ('swiftpy.filesystem', 'UploadedFile'),
|
|
306
|
+
'UrlRule': ('swiftpy.validation', 'UrlRule'),
|
|
307
|
+
'ValidationError': ('swiftpy.core.exceptions', 'ValidationError'),
|
|
308
|
+
'ValidationException': ('swiftpy.validation', 'ValidationException'),
|
|
309
|
+
'ValidationResult': ('swiftpy.validation', 'ValidationResult'),
|
|
310
|
+
'Validator': ('swiftpy.validation', 'Validator'),
|
|
311
|
+
'ValidatorRule': ('swiftpy.validation', 'ValidatorRule'),
|
|
312
|
+
'Vector': ('swiftpy.database.orm', 'Vector'),
|
|
313
|
+
'Visibility': ('swiftpy.filesystem', 'Visibility'),
|
|
314
|
+
'WebSocket': ('swiftpy.websockets', 'WebSocket'),
|
|
315
|
+
'WebSocketConnection': ('swiftpy.websockets', 'WebSocketConnection'),
|
|
316
|
+
'WebSocketDisconnect': ('swiftpy.websockets', 'WebSocketDisconnect'),
|
|
317
|
+
'WebSocketException': ('swiftpy.websockets', 'WebSocketException'),
|
|
318
|
+
'WebSocketManager': ('swiftpy.websockets', 'WebSocketManager'),
|
|
319
|
+
'WebSocketState': ('swiftpy.websockets', 'WebSocketState'),
|
|
320
|
+
'admin': ('swiftpy.admin', 'admin'),
|
|
321
|
+
'app': ('swiftpy.helpers.helper', 'app'),
|
|
322
|
+
'between': ('swiftpy.validation', 'between'),
|
|
323
|
+
'bool_': ('swiftpy.validation', 'bool_'),
|
|
324
|
+
'cache': ('swiftpy.helpers.helper', 'cache'),
|
|
325
|
+
'config': ('swiftpy.helpers.helper', 'config'),
|
|
326
|
+
'container': ('swiftpy.helpers.helper', 'container'),
|
|
327
|
+
'current_user': ('swiftpy.auth', 'current_user'),
|
|
328
|
+
'db_transaction': ('swiftpy.testing', 'db_transaction'),
|
|
329
|
+
'dispatch': ('swiftpy.helpers.helper', 'dispatch'),
|
|
330
|
+
'dispatcher': ('swiftpy.helpers.helper', 'dispatcher'),
|
|
331
|
+
'email': ('swiftpy.validation', 'email'),
|
|
332
|
+
'env': ('swiftpy.helpers.helper', 'env'),
|
|
333
|
+
'env_bool': ('swiftpy.helpers.helper', 'env_bool'),
|
|
334
|
+
'event': ('swiftpy.helpers.helper', 'event'),
|
|
335
|
+
'exists': ('swiftpy.validation', 'exists'),
|
|
336
|
+
'float_': ('swiftpy.validation', 'float_'),
|
|
337
|
+
'forbidden': ('swiftpy.http.response', 'forbidden'),
|
|
338
|
+
'hash_api_key': ('swiftpy.auth', 'hash_api_key'),
|
|
339
|
+
'in_': ('swiftpy.validation', 'in_'),
|
|
340
|
+
'int_': ('swiftpy.validation', 'int_'),
|
|
341
|
+
'json_response': ('swiftpy.http.response', 'json_response'),
|
|
342
|
+
'mail': ('swiftpy.helpers.helper', 'mail'),
|
|
343
|
+
'max_': ('swiftpy.validation', 'max_'),
|
|
344
|
+
'min_': ('swiftpy.validation', 'min_'),
|
|
345
|
+
'not_in': ('swiftpy.validation', 'not_in'),
|
|
346
|
+
'nullable': ('swiftpy.validation', 'nullable'),
|
|
347
|
+
'pluralize': ('swiftpy.helpers.helper', 'pluralize'),
|
|
348
|
+
'push': ('swiftpy.queue', 'push'),
|
|
349
|
+
'queue': ('swiftpy.helpers.helper', 'queue'),
|
|
350
|
+
'regex': ('swiftpy.validation', 'regex'),
|
|
351
|
+
'require_api_key': ('swiftpy.auth', 'require_api_key'),
|
|
352
|
+
'require_jwt': ('swiftpy.auth', 'require_jwt'),
|
|
353
|
+
'required': ('swiftpy.validation', 'required'),
|
|
354
|
+
'resolve': ('swiftpy.helpers.helper', 'resolve'),
|
|
355
|
+
'snake_case': ('swiftpy.helpers.helper', 'snake_case'),
|
|
356
|
+
'storage': ('swiftpy.helpers.helper', 'storage'),
|
|
357
|
+
'str_': ('swiftpy.validation', 'str_'),
|
|
358
|
+
'transactional_test': ('swiftpy.testing', 'transactional_test'),
|
|
359
|
+
'unauthorized': ('swiftpy.http.response', 'unauthorized'),
|
|
360
|
+
'unique': ('swiftpy.validation', 'unique'),
|
|
361
|
+
'url': ('swiftpy.validation', 'url'),
|
|
362
|
+
'validate': ('swiftpy.validation', 'validate'),
|
|
363
|
+
'verify_api_key_hash': ('swiftpy.auth', 'verify_api_key_hash'),
|
|
364
|
+
'websocket_manager': ('swiftpy.helpers.helper', 'websocket_manager'),
|
|
365
|
+
'ws_manager': ('swiftpy.helpers.helper', 'ws_manager'),
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
_SUBMODULE_EXPORTS: frozenset[str] = frozenset({
|
|
369
|
+
'admin',
|
|
370
|
+
'ai',
|
|
371
|
+
'auth',
|
|
372
|
+
'cache',
|
|
373
|
+
'cli',
|
|
374
|
+
'console',
|
|
375
|
+
'core',
|
|
376
|
+
'database',
|
|
377
|
+
'events',
|
|
378
|
+
'filesystem',
|
|
379
|
+
'helpers',
|
|
380
|
+
'http',
|
|
381
|
+
'mail',
|
|
382
|
+
'queue',
|
|
383
|
+
'support',
|
|
384
|
+
'testing',
|
|
385
|
+
'validation',
|
|
386
|
+
'websockets',
|
|
387
|
+
})
|
|
388
|
+
|
|
389
|
+
|
|
390
|
+
def __getattr__(name: str) -> Any:
|
|
391
|
+
"""Lazily resolve top-level SwiftPY exports without eager subsystem imports."""
|
|
392
|
+
target = _EXPORT_MAP.get(name)
|
|
393
|
+
if target is not None:
|
|
394
|
+
module_name, attr_name = target
|
|
395
|
+
module = importlib.import_module(module_name)
|
|
396
|
+
value = getattr(module, attr_name)
|
|
397
|
+
globals()[name] = value
|
|
398
|
+
return value
|
|
399
|
+
if name in _SUBMODULE_EXPORTS:
|
|
400
|
+
module = importlib.import_module(f"swiftpy.{name}")
|
|
401
|
+
globals()[name] = module
|
|
402
|
+
return module
|
|
403
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
404
|
+
|
|
405
|
+
|
|
406
|
+
def __dir__() -> list[str]:
|
|
407
|
+
return sorted(set(globals()) | set(__all__))
|
|
408
|
+
|
|
409
|
+
|
|
410
|
+
__all__ = [
|
|
411
|
+
'CORS',
|
|
412
|
+
'AdminSite',
|
|
413
|
+
'Agent',
|
|
414
|
+
'AgentMemory',
|
|
415
|
+
'AgentResponse',
|
|
416
|
+
'AgentTask',
|
|
417
|
+
'ApiKeyGuard',
|
|
418
|
+
'Application',
|
|
419
|
+
'Attachment',
|
|
420
|
+
'AuthManager',
|
|
421
|
+
'BadRequestError',
|
|
422
|
+
'BaseAgent',
|
|
423
|
+
'BelongsTo',
|
|
424
|
+
'BelongsToMany',
|
|
425
|
+
'BetweenRule',
|
|
426
|
+
'BoolRule',
|
|
427
|
+
'CORSMiddleware',
|
|
428
|
+
'Cache',
|
|
429
|
+
'CacheDriver',
|
|
430
|
+
'CacheManager',
|
|
431
|
+
'CircularDependencyError',
|
|
432
|
+
'ClientDisconnect',
|
|
433
|
+
'Config',
|
|
434
|
+
'Container',
|
|
435
|
+
'CurrentUser',
|
|
436
|
+
'DatabaseError',
|
|
437
|
+
'EmailRule',
|
|
438
|
+
'EventDispatcher',
|
|
439
|
+
'EventHandler',
|
|
440
|
+
'ExceptionHandler',
|
|
441
|
+
'ExistsRule',
|
|
442
|
+
'Field',
|
|
443
|
+
'FileMetadata',
|
|
444
|
+
'FilesystemManager',
|
|
445
|
+
'FloatRule',
|
|
446
|
+
'ForbiddenError',
|
|
447
|
+
'FormRequest',
|
|
448
|
+
'HasMany',
|
|
449
|
+
'HasOne',
|
|
450
|
+
'HttpException',
|
|
451
|
+
'InRule',
|
|
452
|
+
'IntRule',
|
|
453
|
+
'InternalServerError',
|
|
454
|
+
'JWTGuard',
|
|
455
|
+
'JWTIssuer',
|
|
456
|
+
'Job',
|
|
457
|
+
'JobSerializationError',
|
|
458
|
+
'LazyLoadingDisabledError',
|
|
459
|
+
'LocalStorageDriver',
|
|
460
|
+
'Mail',
|
|
461
|
+
'MailFake',
|
|
462
|
+
'MailManager',
|
|
463
|
+
'MailMessage',
|
|
464
|
+
'MailSendResult',
|
|
465
|
+
'MailTransport',
|
|
466
|
+
'Mailable',
|
|
467
|
+
'MaxRule',
|
|
468
|
+
'MemoryDriver',
|
|
469
|
+
'MethodNotAllowedError',
|
|
470
|
+
'Middleware',
|
|
471
|
+
'MinRule',
|
|
472
|
+
'Model',
|
|
473
|
+
'ModelAdmin',
|
|
474
|
+
'ModelNotFoundError',
|
|
475
|
+
'NotFoundError',
|
|
476
|
+
'NotInRule',
|
|
477
|
+
'NullableRule',
|
|
478
|
+
'Paginator',
|
|
479
|
+
'PathNormalizer',
|
|
480
|
+
'PayloadTooLargeError',
|
|
481
|
+
'QueueDispatcher',
|
|
482
|
+
'QueueWorker',
|
|
483
|
+
'RecordNotFoundError',
|
|
484
|
+
'RedisDriver',
|
|
485
|
+
'RedisEventBus',
|
|
486
|
+
'RegexRule',
|
|
487
|
+
'RelationNotLoadedError',
|
|
488
|
+
'Request',
|
|
489
|
+
'RequestId',
|
|
490
|
+
'RequestIdMiddleware',
|
|
491
|
+
'RequiredRule',
|
|
492
|
+
'Response',
|
|
493
|
+
'RouteGroup',
|
|
494
|
+
'Router',
|
|
495
|
+
'S3StorageDriver',
|
|
496
|
+
'SecurityHeaders',
|
|
497
|
+
'SecurityHeadersMiddleware',
|
|
498
|
+
'Seeder',
|
|
499
|
+
'ServiceProvider',
|
|
500
|
+
'SimplePaginator',
|
|
501
|
+
'Storage',
|
|
502
|
+
'StorageDisk',
|
|
503
|
+
'StorageDriver',
|
|
504
|
+
'StrRule',
|
|
505
|
+
'TestCase',
|
|
506
|
+
'TestClient',
|
|
507
|
+
'TestResponse',
|
|
508
|
+
'TokenBlacklist',
|
|
509
|
+
'UnauthorizedError',
|
|
510
|
+
'UniqueRule',
|
|
511
|
+
'UploadedFile',
|
|
512
|
+
'UrlRule',
|
|
513
|
+
'ValidationError',
|
|
514
|
+
'ValidationException',
|
|
515
|
+
'ValidationResult',
|
|
516
|
+
'Validator',
|
|
517
|
+
'ValidatorRule',
|
|
518
|
+
'Vector',
|
|
519
|
+
'Visibility',
|
|
520
|
+
'WebSocket',
|
|
521
|
+
'WebSocketConnection',
|
|
522
|
+
'WebSocketDisconnect',
|
|
523
|
+
'WebSocketException',
|
|
524
|
+
'WebSocketManager',
|
|
525
|
+
'WebSocketState',
|
|
526
|
+
'admin',
|
|
527
|
+
'app',
|
|
528
|
+
'between',
|
|
529
|
+
'bool_',
|
|
530
|
+
'cache',
|
|
531
|
+
'config',
|
|
532
|
+
'container',
|
|
533
|
+
'current_user',
|
|
534
|
+
'db_transaction',
|
|
535
|
+
'dispatch',
|
|
536
|
+
'dispatcher',
|
|
537
|
+
'email',
|
|
538
|
+
'env',
|
|
539
|
+
'env_bool',
|
|
540
|
+
'event',
|
|
541
|
+
'exists',
|
|
542
|
+
'float_',
|
|
543
|
+
'forbidden',
|
|
544
|
+
'hash_api_key',
|
|
545
|
+
'in_',
|
|
546
|
+
'int_',
|
|
547
|
+
'json_response',
|
|
548
|
+
'mail',
|
|
549
|
+
'max_',
|
|
550
|
+
'min_',
|
|
551
|
+
'not_in',
|
|
552
|
+
'nullable',
|
|
553
|
+
'pluralize',
|
|
554
|
+
'push',
|
|
555
|
+
'queue',
|
|
556
|
+
'regex',
|
|
557
|
+
'require_api_key',
|
|
558
|
+
'require_jwt',
|
|
559
|
+
'required',
|
|
560
|
+
'resolve',
|
|
561
|
+
'snake_case',
|
|
562
|
+
'storage',
|
|
563
|
+
'str_',
|
|
564
|
+
'transactional_test',
|
|
565
|
+
'unauthorized',
|
|
566
|
+
'unique',
|
|
567
|
+
'url',
|
|
568
|
+
'validate',
|
|
569
|
+
'verify_api_key_hash',
|
|
570
|
+
'websocket_manager',
|
|
571
|
+
'ws_manager',
|
|
572
|
+
]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from swiftpy.admin.auth import (
|
|
4
|
+
ADMIN_COOKIE_NAME,
|
|
5
|
+
AdminAuthenticator,
|
|
6
|
+
AdminSessionStore,
|
|
7
|
+
AdminUnauthorizedError,
|
|
8
|
+
AdminUser,
|
|
9
|
+
clear_admin_session,
|
|
10
|
+
create_admin_session,
|
|
11
|
+
current_admin,
|
|
12
|
+
get_admin_authenticator,
|
|
13
|
+
get_admin_session_store,
|
|
14
|
+
get_current_admin,
|
|
15
|
+
require_admin,
|
|
16
|
+
)
|
|
17
|
+
from swiftpy.admin.registry import (
|
|
18
|
+
AdminSite,
|
|
19
|
+
FieldMetadata,
|
|
20
|
+
ModelAdmin,
|
|
21
|
+
RelationshipMetadata,
|
|
22
|
+
admin,
|
|
23
|
+
)
|
|
24
|
+
from swiftpy.admin.views import (
|
|
25
|
+
compile_admin_routes,
|
|
26
|
+
create_admin_router,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
__all__ = [
|
|
30
|
+
"ADMIN_COOKIE_NAME",
|
|
31
|
+
"AdminAuthenticator",
|
|
32
|
+
"AdminSessionStore",
|
|
33
|
+
"AdminSite",
|
|
34
|
+
"AdminUnauthorizedError",
|
|
35
|
+
"AdminUser",
|
|
36
|
+
"FieldMetadata",
|
|
37
|
+
"ModelAdmin",
|
|
38
|
+
"RelationshipMetadata",
|
|
39
|
+
"admin",
|
|
40
|
+
"clear_admin_session",
|
|
41
|
+
"compile_admin_routes",
|
|
42
|
+
"create_admin_router",
|
|
43
|
+
"create_admin_session",
|
|
44
|
+
"current_admin",
|
|
45
|
+
"get_admin_authenticator",
|
|
46
|
+
"get_admin_session_store",
|
|
47
|
+
"get_current_admin",
|
|
48
|
+
"require_admin",
|
|
49
|
+
]
|
|
50
|
+
|