diff --git a/docs/ja/reference/framework-modules.md b/docs/ja/reference/framework-modules.md index 1c74843..737ce47 100644 --- a/docs/ja/reference/framework-modules.md +++ b/docs/ja/reference/framework-modules.md @@ -39,6 +39,25 @@ from nene2.http import problem_details_response return problem_details_response("not-found", "Not Found", 404, "Note 42 not found.") ``` +### `PaginationQuery` + +`PaginationQueryParser.parse()` が返すデータクラス。`limit: int` と `offset: int` を持ちます。 + +### `HealthCheckProtocol` / `HealthStatus` + +ヘルスチェックの契約と結果型。 + +```python +from nene2.http import HealthCheckProtocol, HealthStatus + +class MyHealthCheck: + def check(self) -> HealthStatus: + return HealthStatus(status="ok") +``` + +`HealthStatus` フィールド: `status: str`(`"ok"` または `"error"`)、`checks: dict[str, str]`。 +`is_healthy` プロパティは `status == "ok"` のとき `True`。 + --- ## nene2.use_case @@ -283,6 +302,24 @@ class TransferUseCase: 詳細なパターンと InMemory テスト実装は [sqlalchemy-repository.md](../how-to/sqlalchemy-repository.md) を参照してください。 +### `DatabaseHealthCheck` + +`HealthCheckProtocol` を実装し、DB 接続を確認して `HealthStatus` を返します。 + +```python +from nene2.database import DatabaseHealthCheck +from nene2.http import HealthStatus + +health = DatabaseHealthCheck(engine) +status: HealthStatus = health.check() +# status.status → "ok" または "error" +# status.checks → {"db": "ok"} または {"db": "error: "} +``` + +### `DatabaseConnectionException` + +DB 接続不能時に `DatabaseHealthCheck` やリポジトリ操作から raise されます。 + --- ## nene2.mcp @@ -312,8 +349,19 @@ from nene2.mcp import HttpxMcpClient client = HttpxMcpClient("bearer-token") response = client.get("http://localhost:8080", "/notes") response.is_successful() # True +response.body # dict | list — パース済み JSON +response.status_code # int ``` +### `McpHttpResponse` + +`HttpxMcpClient` メソッドの戻り値型。フィールド: `status_code: int`、`body: dict | list`。 +メソッド: `is_successful() -> bool`(`200 ≤ status_code < 300` のとき `True`)。 + +### `McpHttpClientProtocol` + +カスタム MCP HTTP クライアントの構造的契約。`get()`・`post()`・`put()`・`delete()` を実装して `McpHttpResponse` を返します。 + --- ## nene2.log diff --git a/docs/reference/framework-modules.md b/docs/reference/framework-modules.md index fd1b34f..7423ad9 100644 --- a/docs/reference/framework-modules.md +++ b/docs/reference/framework-modules.md @@ -39,6 +39,25 @@ from nene2.http import problem_details_response return problem_details_response("not-found", "Not Found", 404, "Note 42 not found.") ``` +### `PaginationQuery` + +Dataclass returned by `PaginationQueryParser.parse()`. Contains `limit: int` and `offset: int`. + +### `HealthCheckProtocol` / `HealthStatus` + +Contract and result type for application health checks. + +```python +from nene2.http import HealthCheckProtocol, HealthStatus + +class MyHealthCheck: + def check(self) -> HealthStatus: + return HealthStatus(status="ok") +``` + +`HealthStatus` fields: `status: str` (`"ok"` or `"error"`), `checks: dict[str, str]`. +`is_healthy` property returns `True` when `status == "ok"`. + --- ## nene2.use_case @@ -328,6 +347,24 @@ class TransferUseCase: **Testing with InMemory:** Implement `DatabaseTransactionManagerInterface` with a no-op executor that calls the callback directly. The `_in_tx` methods on the InMemory repository ignore the executor and operate on their in-memory store. +### `DatabaseHealthCheck` + +Implements `HealthCheckProtocol` — verifies the database connection and returns a `HealthStatus`. + +```python +from nene2.database import DatabaseHealthCheck +from nene2.http import HealthStatus + +health = DatabaseHealthCheck(engine) +status: HealthStatus = health.check() +# status.status → "ok" or "error" +# status.checks → {"db": "ok"} or {"db": "error: "} +``` + +### `DatabaseConnectionException` + +Raised by `DatabaseHealthCheck` or repository operations when the database is unreachable. + --- ## nene2.mcp @@ -357,8 +394,18 @@ from nene2.mcp import HttpxMcpClient client = HttpxMcpClient("bearer-token") response = client.get("http://localhost:8080", "/notes") response.is_successful() # True +response.body # dict | list — parsed JSON +response.status_code # int ``` +### `McpHttpResponse` + +Return type of `HttpxMcpClient` methods. Fields: `status_code: int`, `body: dict | list`. Method: `is_successful() -> bool` (`True` when `200 ≤ status_code < 300`). + +### `McpHttpClientProtocol` + +Structural contract for custom MCP HTTP clients. Implement `get()`, `post()`, `put()`, `delete()` returning `McpHttpResponse`. + --- ## nene2.log