Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions docs/ja/reference/framework-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: <message>"}
```

### `DatabaseConnectionException`

DB 接続不能時に `DatabaseHealthCheck` やリポジトリ操作から raise されます。

---

## nene2.mcp
Expand Down Expand Up @@ -312,8 +349,25 @@ from nene2.mcp import HttpxMcpClient
client = HttpxMcpClient("bearer-token")
response = client.get("http://localhost:8080", "/notes")
response.is_successful() # True
response.body # str — 生のレスポンステキスト
response.status_code # int
response.request_id() # str | None — X-Request-ID ヘッダーの値
```

### `McpHttpResponse`

`HttpxMcpClient` メソッドの戻り値型。

フィールド: `status_code: int`、`headers: dict[str, str]`、`body: str`(生のレスポンステキスト)。

メソッド:
- `is_successful() -> bool`(`200 ≤ status_code < 300` のとき `True`)
- `request_id() -> str | None` — `X-Request-ID` レスポンスヘッダーの値を返す(なければ `None`)

### `McpHttpClientProtocol`

カスタム MCP HTTP クライアントの構造的契約。`get()`・`post()`・`put()`・`delete()` で `McpHttpResponse` を返し、`has_authentication() -> bool` を実装します。

---

## nene2.log
Expand Down
54 changes: 54 additions & 0 deletions docs/reference/framework-modules.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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: <message>"}
```

### `DatabaseConnectionException`

Raised by `DatabaseHealthCheck` or repository operations when the database is unreachable.

---

## nene2.mcp
Expand Down Expand Up @@ -357,8 +394,25 @@ from nene2.mcp import HttpxMcpClient
client = HttpxMcpClient("bearer-token")
response = client.get("http://localhost:8080", "/notes")
response.is_successful() # True
response.body # str — raw response text
response.status_code # int
response.request_id() # str | None — value of X-Request-ID header
```

### `McpHttpResponse`

Return type of `HttpxMcpClient` methods.

Fields: `status_code: int`, `headers: dict[str, str]`, `body: str` (raw response text).

Methods:
- `is_successful() -> bool` — `True` when `200 ≤ status_code < 300`
- `request_id() -> str | None` — returns the `X-Request-ID` response header value, or `None`

### `McpHttpClientProtocol`

Structural contract for custom MCP HTTP clients. Implement `get()`, `post()`, `put()`, `delete()` returning `McpHttpResponse`, and `has_authentication() -> bool`.

---

## nene2.log
Expand Down