Skip to content

Commit 2a034a6

Browse files
committed
Fix map to
1 parent dfd9f15 commit 2a034a6

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

.cursor/rules/sdk-port.mdc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ Turms config is in `graphql.config.yaml` at the package root.
4747
- Error classes extend `BaseError` (in `errors/base.py`), which mirrors the JS `BaseError extends Error`.
4848
- `from` is a Python keyword; the JS `errors/from.ts` is named `errors/from_error.py` with a `from_error()` function.
4949
- Use generated pydantic models and enums from `graphql/__generated__/schema.py` for typed error constructors, operations, and fragment types.
50+
- Avoid `Any` as much as possible: prefer generated fragment/operation types (e.g. `ConnectionInfoFull`, `ReplayEntryFull`) for convert function parameters and internal variables; use `object` or a protocol only when you must accept multiple unrelated types.
5051
- In `from_error()`, prefer dispatching on the GraphQL `typename` string (mirroring the JS `error.__typename` switch) instead of structural pattern matching on specific pydantic model classes. This keeps the function compatible with both fragment `...Full` models and operation-specific inline fragment models, as long as they expose the required attributes. For new error families, mirror the existing `from_error()` style and raise a `ValueError` on unknown `typename`.
5152
- Use `match`/`case` on enum values in error constructors (e.g., `CloudErrorReason.UNAVAILABLE`).
5253
- `PluginFunctionCallError` takes REST `Any` payloads (not GraphQL fragments) since it comes from the REST API.

packages/caido-sdk-client/src/caido_sdk_client/convert/network.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,15 @@
22

33
from __future__ import annotations
44

5-
from typing import Any
6-
5+
from caido_sdk_client.graphql.__generated__.schema import ConnectionInfoFull
76
from caido_sdk_client.types.network import ConnectionInfo
87

98

10-
def map_to_connection_info(node: Any) -> ConnectionInfo:
9+
def map_to_connection_info(node: ConnectionInfoFull) -> ConnectionInfo:
1110
"""Convert ConnectionInfoFull fragment to public ConnectionInfo type."""
1211
return ConnectionInfo(
1312
host=node.host,
1413
port=node.port,
15-
is_tls=node.isTls,
16-
sni=getattr(node, "SNI", None),
14+
is_tls=node.isTLS,
15+
sni=node.SNI,
1716
)

0 commit comments

Comments
 (0)