servicekit 0.3.5__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 (41) hide show
  1. servicekit-0.3.5/PKG-INFO +184 -0
  2. servicekit-0.3.5/README.md +148 -0
  3. servicekit-0.3.5/pyproject.toml +161 -0
  4. servicekit-0.3.5/src/servicekit/.DS_Store +0 -0
  5. servicekit-0.3.5/src/servicekit/__init__.py +78 -0
  6. servicekit-0.3.5/src/servicekit/api/.DS_Store +0 -0
  7. servicekit-0.3.5/src/servicekit/api/__init__.py +72 -0
  8. servicekit-0.3.5/src/servicekit/api/app.py +225 -0
  9. servicekit-0.3.5/src/servicekit/api/apps/.DS_Store +0 -0
  10. servicekit-0.3.5/src/servicekit/api/apps/landing/index.html +146 -0
  11. servicekit-0.3.5/src/servicekit/api/apps/landing/manifest.json +8 -0
  12. servicekit-0.3.5/src/servicekit/api/auth.py +162 -0
  13. servicekit-0.3.5/src/servicekit/api/crud.py +368 -0
  14. servicekit-0.3.5/src/servicekit/api/dependencies.py +70 -0
  15. servicekit-0.3.5/src/servicekit/api/middleware.py +163 -0
  16. servicekit-0.3.5/src/servicekit/api/monitoring.py +100 -0
  17. servicekit-0.3.5/src/servicekit/api/pagination.py +27 -0
  18. servicekit-0.3.5/src/servicekit/api/registration.py +287 -0
  19. servicekit-0.3.5/src/servicekit/api/router.py +28 -0
  20. servicekit-0.3.5/src/servicekit/api/routers/__init__.py +18 -0
  21. servicekit-0.3.5/src/servicekit/api/routers/health.py +114 -0
  22. servicekit-0.3.5/src/servicekit/api/routers/job.py +126 -0
  23. servicekit-0.3.5/src/servicekit/api/routers/metrics.py +47 -0
  24. servicekit-0.3.5/src/servicekit/api/routers/system.py +77 -0
  25. servicekit-0.3.5/src/servicekit/api/service_builder.py +793 -0
  26. servicekit-0.3.5/src/servicekit/api/sse.py +23 -0
  27. servicekit-0.3.5/src/servicekit/api/utilities.py +80 -0
  28. servicekit-0.3.5/src/servicekit/data/README.md +185 -0
  29. servicekit-0.3.5/src/servicekit/data/__init__.py +22 -0
  30. servicekit-0.3.5/src/servicekit/data/dataframe.py +1104 -0
  31. servicekit-0.3.5/src/servicekit/database.py +252 -0
  32. servicekit-0.3.5/src/servicekit/exceptions.py +138 -0
  33. servicekit-0.3.5/src/servicekit/gunicorn.conf.py +109 -0
  34. servicekit-0.3.5/src/servicekit/logging.py +98 -0
  35. servicekit-0.3.5/src/servicekit/manager.py +311 -0
  36. servicekit-0.3.5/src/servicekit/models.py +26 -0
  37. servicekit-0.3.5/src/servicekit/py.typed +0 -0
  38. servicekit-0.3.5/src/servicekit/repository.py +173 -0
  39. servicekit-0.3.5/src/servicekit/scheduler.py +302 -0
  40. servicekit-0.3.5/src/servicekit/schemas.py +184 -0
  41. servicekit-0.3.5/src/servicekit/types.py +94 -0
@@ -0,0 +1,184 @@
1
+ Metadata-Version: 2.3
2
+ Name: servicekit
3
+ Version: 0.3.5
4
+ Summary: Async SQLAlchemy framework with FastAPI integration - reusable foundation for building data services
5
+ Keywords: fastapi,sqlalchemy,async,database,rest-api,crud,framework
6
+ Author: Morten Hansen
7
+ Author-email: Morten Hansen <morten@winterop.com>
8
+ License: AGPL-3.0-or-later
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Classifier: Framework :: FastAPI
15
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
16
+ Classifier: Topic :: Database
17
+ Requires-Dist: aiosqlite>=0.21.0
18
+ Requires-Dist: alembic>=1.17.0
19
+ Requires-Dist: fastapi[standard]>=0.119.1
20
+ Requires-Dist: gunicorn>=23.0.0
21
+ Requires-Dist: opentelemetry-api>=1.37.0
22
+ Requires-Dist: opentelemetry-exporter-prometheus>=0.58b0
23
+ Requires-Dist: opentelemetry-instrumentation-fastapi>=0.58b0
24
+ Requires-Dist: opentelemetry-instrumentation-sqlalchemy>=0.58b0
25
+ Requires-Dist: opentelemetry-sdk>=1.37.0
26
+ Requires-Dist: pydantic>=2.12.0
27
+ Requires-Dist: python-ulid>=3.1.0
28
+ Requires-Dist: sqlalchemy[asyncio]>=2.0.43
29
+ Requires-Dist: structlog>=24.4.0
30
+ Requires-Python: >=3.13, <3.14
31
+ Project-URL: Documentation, https://winterop-com.github.io/servicekit
32
+ Project-URL: Homepage, https://github.com/winterop-com/servicekit
33
+ Project-URL: Issues, https://github.com/winterop-com/servicekit/issues
34
+ Project-URL: Repository, https://github.com/winterop-com/servicekit
35
+ Description-Content-Type: text/markdown
36
+
37
+ # Servicekit
38
+
39
+ [![CI](https://github.com/winterop-com/servicekit/actions/workflows/ci.yml/badge.svg)](https://github.com/winterop-com/servicekit/actions/workflows/ci.yml)
40
+ [![codecov](https://codecov.io/gh/winterop-com/servicekit/branch/main/graph/badge.svg)](https://codecov.io/gh/winterop-com/servicekit)
41
+ [![Python 3.13+](https://img.shields.io/badge/python-3.13+-blue.svg)](https://www.python.org/downloads/)
42
+ [![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
43
+ [![Documentation](https://img.shields.io/badge/docs-mkdocs-blue.svg)](https://winterop-com.github.io/servicekit/)
44
+
45
+ > Async SQLAlchemy framework with FastAPI integration - reusable foundation for building data services
46
+
47
+ Servicekit is a framework-agnostic core library providing foundational infrastructure for building async Python services with FastAPI and SQLAlchemy.
48
+
49
+ ## Features
50
+
51
+ - **Database Layer**: Async SQLAlchemy with SQLite support, connection pooling, and automatic migrations
52
+ - **Repository Pattern**: Generic repository base classes for data access
53
+ - **Manager Pattern**: Business logic layer with lifecycle hooks
54
+ - **CRUD API**: Auto-generated REST endpoints with full CRUD operations
55
+ - **Authentication**: API key middleware with file and environment variable support
56
+ - **Job Scheduling**: Async job scheduler with concurrency control
57
+ - **App Hosting**: Mount static web applications alongside your API
58
+ - **Monitoring**: Prometheus metrics and OpenTelemetry integration
59
+ - **Health Checks**: Flexible health check system with SSE streaming support
60
+ - **Error Handling**: RFC 9457 Problem Details for HTTP APIs
61
+ - **Logging**: Structured logging with request context
62
+
63
+ ## Installation
64
+
65
+ ```bash
66
+ pip install servicekit
67
+ ```
68
+
69
+ ## Quick Start
70
+
71
+ ```python
72
+ from servicekit.api import BaseServiceBuilder, ServiceInfo
73
+
74
+ app = (
75
+ BaseServiceBuilder(info=ServiceInfo(display_name="My Service"))
76
+ .with_health()
77
+ .with_database("sqlite+aiosqlite:///./data.db")
78
+ .build()
79
+ )
80
+ ```
81
+
82
+ ## Architecture
83
+
84
+ ```
85
+ servicekit/
86
+ ├── database.py # Database, SqliteDatabase, SqliteDatabaseBuilder
87
+ ├── models.py # Base, Entity ORM classes
88
+ ├── repository.py # Repository, BaseRepository
89
+ ├── manager.py # Manager, BaseManager
90
+ ├── schemas.py # EntityIn, EntityOut, PaginatedResponse
91
+ ├── scheduler.py # JobScheduler, AIOJobScheduler
92
+ ├── exceptions.py # Error classes
93
+ ├── logging.py # Structured logging
94
+ ├── types.py # ULIDType, JsonSafe
95
+ └── api/ # FastAPI framework layer
96
+ ├── router.py # Router base class
97
+ ├── crud.py # CrudRouter, CrudPermissions
98
+ ├── auth.py # API key authentication
99
+ ├── app.py # Static app hosting
100
+ ├── middleware.py # Error handlers, logging
101
+ └── routers/ # Health, Jobs, System, Metrics
102
+ ```
103
+
104
+ ## Key Components
105
+
106
+ ### BaseServiceBuilder
107
+
108
+ ```python
109
+ from servicekit.api import BaseServiceBuilder, ServiceInfo
110
+
111
+ app = (
112
+ BaseServiceBuilder(info=ServiceInfo(display_name="My Service"))
113
+ .with_health() # Health check endpoint
114
+ .with_database(url) # Database configuration
115
+ .with_jobs(max_concurrency=10) # Job scheduler
116
+ .with_auth() # API key authentication
117
+ .with_monitoring() # Prometheus metrics
118
+ .with_app("./webapp") # Static web app
119
+ .include_router(custom_router) # Custom routes
120
+ .build()
121
+ )
122
+ ```
123
+
124
+ ### Repository Pattern
125
+
126
+ ```python
127
+ from servicekit import BaseRepository, Entity
128
+ from sqlalchemy.orm import Mapped, mapped_column
129
+
130
+ class User(Entity):
131
+ __tablename__ = "users"
132
+ name: Mapped[str] = mapped_column()
133
+ email: Mapped[str] = mapped_column()
134
+
135
+ class UserRepository(BaseRepository[User, ULID]):
136
+ def __init__(self, session: AsyncSession):
137
+ super().__init__(session, User)
138
+ ```
139
+
140
+ ### CRUD Router
141
+
142
+ ```python
143
+ from servicekit.api import CrudRouter, CrudPermissions
144
+
145
+ router = CrudRouter.create(
146
+ prefix="/api/v1/users",
147
+ tags=["Users"],
148
+ entity_in_type=UserIn,
149
+ entity_out_type=UserOut,
150
+ manager_factory=get_user_manager,
151
+ permissions=CrudPermissions(create=True, read=True, update=True, delete=False)
152
+ )
153
+ ```
154
+
155
+
156
+ ## Examples
157
+
158
+ See the `examples/` directory for complete working examples:
159
+
160
+ - `core_api.py` - Basic CRUD service
161
+ - `job_scheduler_api.py` - Background job execution
162
+ - `app_hosting_api.py` - Hosting static web apps
163
+ - `auth_basic.py` - API key authentication
164
+ - `monitoring_api.py` - Prometheus metrics
165
+
166
+ ## Documentation
167
+
168
+ See `docs/` for comprehensive guides and API reference.
169
+
170
+ ## Testing
171
+
172
+ ```bash
173
+ make test # Run tests
174
+ make lint # Run linter
175
+ make coverage # Test coverage
176
+ ```
177
+
178
+ ## License
179
+
180
+ AGPL-3.0-or-later
181
+
182
+ ## Related Projects
183
+
184
+ - **[chapkit](https://github.com/dhis2-chap/chapkit)** - Domain modules (artifacts, configs, tasks, ML workflows) built on servicekit ([docs](https://dhis2-chap.github.io/chapkit))
@@ -0,0 +1,148 @@
1
+ # Servicekit
2
+
3
+ [![CI](https://github.com/winterop-com/servicekit/actions/workflows/ci.yml/badge.svg)](https://github.com/winterop-com/servicekit/actions/workflows/ci.yml)
4
+ [![codecov](https://codecov.io/gh/winterop-com/servicekit/branch/main/graph/badge.svg)](https://codecov.io/gh/winterop-com/servicekit)
5
+ [![Python 3.13+](https://img.shields.io/badge/python-3.13+-blue.svg)](https://www.python.org/downloads/)
6
+ [![License: AGPL v3](https://img.shields.io/badge/License-AGPL_v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
7
+ [![Documentation](https://img.shields.io/badge/docs-mkdocs-blue.svg)](https://winterop-com.github.io/servicekit/)
8
+
9
+ > Async SQLAlchemy framework with FastAPI integration - reusable foundation for building data services
10
+
11
+ Servicekit is a framework-agnostic core library providing foundational infrastructure for building async Python services with FastAPI and SQLAlchemy.
12
+
13
+ ## Features
14
+
15
+ - **Database Layer**: Async SQLAlchemy with SQLite support, connection pooling, and automatic migrations
16
+ - **Repository Pattern**: Generic repository base classes for data access
17
+ - **Manager Pattern**: Business logic layer with lifecycle hooks
18
+ - **CRUD API**: Auto-generated REST endpoints with full CRUD operations
19
+ - **Authentication**: API key middleware with file and environment variable support
20
+ - **Job Scheduling**: Async job scheduler with concurrency control
21
+ - **App Hosting**: Mount static web applications alongside your API
22
+ - **Monitoring**: Prometheus metrics and OpenTelemetry integration
23
+ - **Health Checks**: Flexible health check system with SSE streaming support
24
+ - **Error Handling**: RFC 9457 Problem Details for HTTP APIs
25
+ - **Logging**: Structured logging with request context
26
+
27
+ ## Installation
28
+
29
+ ```bash
30
+ pip install servicekit
31
+ ```
32
+
33
+ ## Quick Start
34
+
35
+ ```python
36
+ from servicekit.api import BaseServiceBuilder, ServiceInfo
37
+
38
+ app = (
39
+ BaseServiceBuilder(info=ServiceInfo(display_name="My Service"))
40
+ .with_health()
41
+ .with_database("sqlite+aiosqlite:///./data.db")
42
+ .build()
43
+ )
44
+ ```
45
+
46
+ ## Architecture
47
+
48
+ ```
49
+ servicekit/
50
+ ├── database.py # Database, SqliteDatabase, SqliteDatabaseBuilder
51
+ ├── models.py # Base, Entity ORM classes
52
+ ├── repository.py # Repository, BaseRepository
53
+ ├── manager.py # Manager, BaseManager
54
+ ├── schemas.py # EntityIn, EntityOut, PaginatedResponse
55
+ ├── scheduler.py # JobScheduler, AIOJobScheduler
56
+ ├── exceptions.py # Error classes
57
+ ├── logging.py # Structured logging
58
+ ├── types.py # ULIDType, JsonSafe
59
+ └── api/ # FastAPI framework layer
60
+ ├── router.py # Router base class
61
+ ├── crud.py # CrudRouter, CrudPermissions
62
+ ├── auth.py # API key authentication
63
+ ├── app.py # Static app hosting
64
+ ├── middleware.py # Error handlers, logging
65
+ └── routers/ # Health, Jobs, System, Metrics
66
+ ```
67
+
68
+ ## Key Components
69
+
70
+ ### BaseServiceBuilder
71
+
72
+ ```python
73
+ from servicekit.api import BaseServiceBuilder, ServiceInfo
74
+
75
+ app = (
76
+ BaseServiceBuilder(info=ServiceInfo(display_name="My Service"))
77
+ .with_health() # Health check endpoint
78
+ .with_database(url) # Database configuration
79
+ .with_jobs(max_concurrency=10) # Job scheduler
80
+ .with_auth() # API key authentication
81
+ .with_monitoring() # Prometheus metrics
82
+ .with_app("./webapp") # Static web app
83
+ .include_router(custom_router) # Custom routes
84
+ .build()
85
+ )
86
+ ```
87
+
88
+ ### Repository Pattern
89
+
90
+ ```python
91
+ from servicekit import BaseRepository, Entity
92
+ from sqlalchemy.orm import Mapped, mapped_column
93
+
94
+ class User(Entity):
95
+ __tablename__ = "users"
96
+ name: Mapped[str] = mapped_column()
97
+ email: Mapped[str] = mapped_column()
98
+
99
+ class UserRepository(BaseRepository[User, ULID]):
100
+ def __init__(self, session: AsyncSession):
101
+ super().__init__(session, User)
102
+ ```
103
+
104
+ ### CRUD Router
105
+
106
+ ```python
107
+ from servicekit.api import CrudRouter, CrudPermissions
108
+
109
+ router = CrudRouter.create(
110
+ prefix="/api/v1/users",
111
+ tags=["Users"],
112
+ entity_in_type=UserIn,
113
+ entity_out_type=UserOut,
114
+ manager_factory=get_user_manager,
115
+ permissions=CrudPermissions(create=True, read=True, update=True, delete=False)
116
+ )
117
+ ```
118
+
119
+
120
+ ## Examples
121
+
122
+ See the `examples/` directory for complete working examples:
123
+
124
+ - `core_api.py` - Basic CRUD service
125
+ - `job_scheduler_api.py` - Background job execution
126
+ - `app_hosting_api.py` - Hosting static web apps
127
+ - `auth_basic.py` - API key authentication
128
+ - `monitoring_api.py` - Prometheus metrics
129
+
130
+ ## Documentation
131
+
132
+ See `docs/` for comprehensive guides and API reference.
133
+
134
+ ## Testing
135
+
136
+ ```bash
137
+ make test # Run tests
138
+ make lint # Run linter
139
+ make coverage # Test coverage
140
+ ```
141
+
142
+ ## License
143
+
144
+ AGPL-3.0-or-later
145
+
146
+ ## Related Projects
147
+
148
+ - **[chapkit](https://github.com/dhis2-chap/chapkit)** - Domain modules (artifacts, configs, tasks, ML workflows) built on servicekit ([docs](https://dhis2-chap.github.io/chapkit))
@@ -0,0 +1,161 @@
1
+ [project]
2
+ name = "servicekit"
3
+ version = "0.3.5"
4
+ description = "Async SQLAlchemy framework with FastAPI integration - reusable foundation for building data services"
5
+ readme = "README.md"
6
+ authors = [{ name = "Morten Hansen", email = "morten@winterop.com" }]
7
+ license = { text = "AGPL-3.0-or-later" }
8
+ requires-python = ">=3.13,<3.14"
9
+ keywords = [
10
+ "fastapi",
11
+ "sqlalchemy",
12
+ "async",
13
+ "database",
14
+ "rest-api",
15
+ "crud",
16
+ "framework",
17
+ ]
18
+ classifiers = [
19
+ "Development Status :: 3 - Alpha",
20
+ "Intended Audience :: Developers",
21
+ "License :: OSI Approved :: GNU Affero General Public License v3 or later (AGPLv3+)",
22
+ "Programming Language :: Python :: 3",
23
+ "Programming Language :: Python :: 3.13",
24
+ "Framework :: FastAPI",
25
+ "Topic :: Software Development :: Libraries :: Python Modules",
26
+ "Topic :: Database",
27
+ ]
28
+ dependencies = [
29
+ "aiosqlite>=0.21.0",
30
+ "alembic>=1.17.0",
31
+ "fastapi[standard]>=0.119.1",
32
+ "gunicorn>=23.0.0",
33
+ "opentelemetry-api>=1.37.0",
34
+ "opentelemetry-exporter-prometheus>=0.58b0",
35
+ "opentelemetry-instrumentation-fastapi>=0.58b0",
36
+ "opentelemetry-instrumentation-sqlalchemy>=0.58b0",
37
+ "opentelemetry-sdk>=1.37.0",
38
+ "pydantic>=2.12.0",
39
+ "python-ulid>=3.1.0",
40
+ "sqlalchemy[asyncio]>=2.0.43",
41
+ "structlog>=24.4.0",
42
+ ]
43
+
44
+ [project.optional-dependencies]
45
+
46
+ [project.urls]
47
+ Homepage = "https://github.com/winterop-com/servicekit"
48
+ Repository = "https://github.com/winterop-com/servicekit"
49
+ Issues = "https://github.com/winterop-com/servicekit/issues"
50
+ Documentation = "https://winterop-com.github.io/servicekit"
51
+
52
+ [dependency-groups]
53
+ dev = [
54
+ "coverage[toml]>=7.6.0",
55
+ "mypy>=1.18.2",
56
+ "pandas-stubs>=2.3.2.250926",
57
+ "pytest>=8.4.2",
58
+ "pytest-cov>=5.0.0",
59
+ "pytest-asyncio>=1.2.0",
60
+ "ruff>=0.14.0",
61
+ "pyright>=1.1.407",
62
+ "mkdocs>=1.6.0",
63
+ "mkdocs-material>=9.5.0",
64
+ "mkdocstrings[python]>=0.26.0",
65
+ "pandas>=2.3.3",
66
+ "polars>=1.34.0",
67
+ "xarray>=2025.10.1",
68
+ "numpy>=2.3.4",
69
+ ]
70
+
71
+ [build-system]
72
+ requires = ["uv_build>=0.9.0,<0.10.0"]
73
+ build-backend = "uv_build"
74
+
75
+ [tool.ruff]
76
+ target-version = "py313"
77
+ line-length = 120
78
+
79
+ [tool.ruff.lint]
80
+ fixable = ["ALL"]
81
+ select = ["E", "W", "F", "I", "D"]
82
+ ignore = ["D203", "D213"]
83
+
84
+ [tool.ruff.lint.pydocstyle]
85
+ convention = "google"
86
+
87
+ [tool.ruff.lint.per-file-ignores]
88
+ "tests/**/*.py" = ["D"]
89
+ "**/__init__.py" = ["D104"]
90
+ "src/**/*.py" = ["D102", "D105", "D107"]
91
+ "examples/**/*.py" = []
92
+
93
+ [tool.ruff.format]
94
+ quote-style = "double"
95
+ indent-style = "space"
96
+ skip-magic-trailing-comma = false
97
+ docstring-code-format = true
98
+ docstring-code-line-length = "dynamic"
99
+
100
+ [tool.pytest.ini_options]
101
+ asyncio_mode = "auto"
102
+ testpaths = ["tests"]
103
+ norecursedirs = ["examples", ".git", ".venv", "__pycache__"]
104
+
105
+ [tool.coverage.run]
106
+ branch = true
107
+ dynamic_context = "test_function"
108
+ relative_files = true
109
+ source = ["servicekit"]
110
+
111
+ [tool.coverage.report]
112
+ exclude_also = ["if TYPE_CHECKING:"]
113
+ precision = 2
114
+ show_missing = true
115
+ skip_covered = true
116
+
117
+ [tool.mypy]
118
+ python_version = "3.13"
119
+ warn_return_any = true
120
+ warn_unused_configs = true
121
+ disallow_untyped_defs = true
122
+ check_untyped_defs = true
123
+ disallow_any_unimported = true
124
+ no_implicit_optional = true
125
+ warn_unused_ignores = true
126
+ strict_equality = true
127
+ mypy_path = ["src", "typings"]
128
+
129
+ [[tool.mypy.overrides]]
130
+ module = "tests.*"
131
+ disallow_untyped_defs = false
132
+
133
+ [[tool.mypy.overrides]]
134
+ module = "polars.*"
135
+ ignore_missing_imports = true
136
+
137
+ [[tool.mypy.overrides]]
138
+ module = "xarray.*"
139
+ ignore_missing_imports = true
140
+
141
+ [[tool.mypy.overrides]]
142
+ module = "examples.*"
143
+ ignore_missing_imports = true
144
+ disallow_untyped_defs = false
145
+
146
+ [tool.pyright]
147
+ include = ["src", "tests", "examples"]
148
+ pythonVersion = "3.13"
149
+ typeCheckingMode = "strict"
150
+ useLibraryCodeForTypes = true
151
+ reportPrivateUsage = false
152
+ reportUnusedFunction = false
153
+ reportUnknownMemberType = false
154
+ reportUnknownArgumentType = false
155
+ reportUnknownLambdaType = false
156
+ reportUnknownParameterType = false
157
+ reportUnknownVariableType = false
158
+ reportMissingTypeArgument = false
159
+ reportMissingTypeStubs = false
160
+ reportMissingImports = "none"
161
+ reportMissingModuleSource = "none"
@@ -0,0 +1,78 @@
1
+ """Core framework components - generic interfaces and base classes."""
2
+
3
+ # ruff: noqa: F401
4
+
5
+ # Base infrastructure (framework-agnostic)
6
+ from .database import Database, SqliteDatabase, SqliteDatabaseBuilder
7
+ from .exceptions import (
8
+ BadRequestError,
9
+ ConflictError,
10
+ ErrorType,
11
+ ForbiddenError,
12
+ InvalidULIDError,
13
+ NotFoundError,
14
+ ServicekitException,
15
+ UnauthorizedError,
16
+ ValidationError,
17
+ )
18
+ from .logging import add_request_context, clear_request_context, configure_logging, get_logger, reset_request_context
19
+ from .manager import BaseManager, LifecycleHooks, Manager
20
+ from .models import Base, Entity
21
+ from .repository import BaseRepository, Repository
22
+ from .scheduler import AIOJobScheduler, JobScheduler
23
+ from .schemas import (
24
+ BulkOperationError,
25
+ BulkOperationResult,
26
+ EntityIn,
27
+ EntityOut,
28
+ JobRecord,
29
+ JobStatus,
30
+ PaginatedResponse,
31
+ ProblemDetail,
32
+ )
33
+ from .types import JsonSafe, ULIDType
34
+
35
+ __all__ = [
36
+ # Base infrastructure
37
+ "Database",
38
+ "SqliteDatabase",
39
+ "SqliteDatabaseBuilder",
40
+ "Repository",
41
+ "BaseRepository",
42
+ "Manager",
43
+ "LifecycleHooks",
44
+ "BaseManager",
45
+ # ORM and types
46
+ "Base",
47
+ "Entity",
48
+ "ULIDType",
49
+ "JsonSafe",
50
+ # Schemas
51
+ "EntityIn",
52
+ "EntityOut",
53
+ "PaginatedResponse",
54
+ "BulkOperationResult",
55
+ "BulkOperationError",
56
+ "ProblemDetail",
57
+ "JobRecord",
58
+ "JobStatus",
59
+ # Job scheduling
60
+ "JobScheduler",
61
+ "AIOJobScheduler",
62
+ # Exceptions
63
+ "ErrorType",
64
+ "ServicekitException",
65
+ "NotFoundError",
66
+ "ValidationError",
67
+ "ConflictError",
68
+ "InvalidULIDError",
69
+ "BadRequestError",
70
+ "UnauthorizedError",
71
+ "ForbiddenError",
72
+ # Logging
73
+ "configure_logging",
74
+ "get_logger",
75
+ "add_request_context",
76
+ "clear_request_context",
77
+ "reset_request_context",
78
+ ]
@@ -0,0 +1,72 @@
1
+ """FastAPI framework layer - routers, middleware, utilities."""
2
+
3
+ from .app import App, AppInfo, AppLoader, AppManager, AppManifest
4
+ from .auth import APIKeyMiddleware, load_api_keys_from_env, load_api_keys_from_file, validate_api_key_format
5
+ from .crud import CrudPermissions, CrudRouter
6
+ from .dependencies import (
7
+ get_app_manager,
8
+ get_database,
9
+ get_scheduler,
10
+ get_session,
11
+ set_app_manager,
12
+ set_database,
13
+ set_scheduler,
14
+ )
15
+ from .middleware import add_error_handlers, add_logging_middleware, database_error_handler, validation_error_handler
16
+ from .pagination import PaginationParams, create_paginated_response
17
+ from .router import Router
18
+ from .routers import HealthRouter, HealthState, HealthStatus, JobRouter, SystemInfo, SystemRouter
19
+ from .service_builder import BaseServiceBuilder, ServiceInfo
20
+ from .sse import SSE_HEADERS, format_sse_event, format_sse_model_event
21
+ from .utilities import build_location_url, run_app
22
+
23
+ __all__ = [
24
+ # Base router classes
25
+ "Router",
26
+ "CrudRouter",
27
+ "CrudPermissions",
28
+ # Service builder
29
+ "BaseServiceBuilder",
30
+ "ServiceInfo",
31
+ # App system
32
+ "App",
33
+ "AppInfo",
34
+ "AppLoader",
35
+ "AppManifest",
36
+ "AppManager",
37
+ # Authentication
38
+ "APIKeyMiddleware",
39
+ "load_api_keys_from_env",
40
+ "load_api_keys_from_file",
41
+ "validate_api_key_format",
42
+ # Dependencies
43
+ "get_app_manager",
44
+ "set_app_manager",
45
+ "get_database",
46
+ "set_database",
47
+ "get_session",
48
+ "get_scheduler",
49
+ "set_scheduler",
50
+ # Middleware
51
+ "add_error_handlers",
52
+ "add_logging_middleware",
53
+ "database_error_handler",
54
+ "validation_error_handler",
55
+ # Pagination
56
+ "PaginationParams",
57
+ "create_paginated_response",
58
+ # System routers
59
+ "HealthRouter",
60
+ "HealthState",
61
+ "HealthStatus",
62
+ "JobRouter",
63
+ "SystemRouter",
64
+ "SystemInfo",
65
+ # SSE utilities
66
+ "SSE_HEADERS",
67
+ "format_sse_event",
68
+ "format_sse_model_event",
69
+ # Utilities
70
+ "build_location_url",
71
+ "run_app",
72
+ ]