fixyourdocs 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.
- fixyourdocs/__init__.py +56 -0
- fixyourdocs/_http.py +157 -0
- fixyourdocs/_results.py +26 -0
- fixyourdocs/client.py +126 -0
- fixyourdocs/errors.py +123 -0
- fixyourdocs/models.py +178 -0
- fixyourdocs/py.typed +0 -0
- fixyourdocs-0.1.0.dist-info/METADATA +128 -0
- fixyourdocs-0.1.0.dist-info/RECORD +11 -0
- fixyourdocs-0.1.0.dist-info/WHEEL +4 -0
- fixyourdocs-0.1.0.dist-info/licenses/LICENSE +202 -0
fixyourdocs/__init__.py
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""Reference Python SDK for the Docs Feedback Protocol v0.
|
|
2
|
+
|
|
3
|
+
See <https://github.com/fixyourdocs/protocol> for the wire-format spec.
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
__version__ = "0.1.0"
|
|
9
|
+
|
|
10
|
+
from fixyourdocs._results import SendResult
|
|
11
|
+
from fixyourdocs.client import AsyncClient, Client
|
|
12
|
+
from fixyourdocs.errors import (
|
|
13
|
+
AuthError,
|
|
14
|
+
FixYourDocsError,
|
|
15
|
+
NotFoundError,
|
|
16
|
+
OptedOutError,
|
|
17
|
+
PayloadTooLargeError,
|
|
18
|
+
PolicyRejectedError,
|
|
19
|
+
RateLimitedError,
|
|
20
|
+
ServerError,
|
|
21
|
+
UnsupportedMediaTypeError,
|
|
22
|
+
ValidationError,
|
|
23
|
+
)
|
|
24
|
+
from fixyourdocs.models import (
|
|
25
|
+
AgentInfo,
|
|
26
|
+
Evidence,
|
|
27
|
+
EvidenceKind,
|
|
28
|
+
Report,
|
|
29
|
+
ReportBody,
|
|
30
|
+
ReportKind,
|
|
31
|
+
TaskContext,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
__all__ = [
|
|
35
|
+
"__version__",
|
|
36
|
+
"AgentInfo",
|
|
37
|
+
"AsyncClient",
|
|
38
|
+
"AuthError",
|
|
39
|
+
"Client",
|
|
40
|
+
"Evidence",
|
|
41
|
+
"EvidenceKind",
|
|
42
|
+
"FixYourDocsError",
|
|
43
|
+
"NotFoundError",
|
|
44
|
+
"OptedOutError",
|
|
45
|
+
"PayloadTooLargeError",
|
|
46
|
+
"PolicyRejectedError",
|
|
47
|
+
"RateLimitedError",
|
|
48
|
+
"Report",
|
|
49
|
+
"ReportBody",
|
|
50
|
+
"ReportKind",
|
|
51
|
+
"SendResult",
|
|
52
|
+
"ServerError",
|
|
53
|
+
"TaskContext",
|
|
54
|
+
"UnsupportedMediaTypeError",
|
|
55
|
+
"ValidationError",
|
|
56
|
+
]
|
fixyourdocs/_http.py
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
"""Shared HTTP helpers used by both ``Client`` and ``AsyncClient``."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any, Optional
|
|
6
|
+
|
|
7
|
+
import httpx
|
|
8
|
+
|
|
9
|
+
from fixyourdocs._results import SendResult
|
|
10
|
+
from fixyourdocs.errors import (
|
|
11
|
+
AuthError,
|
|
12
|
+
FixYourDocsError,
|
|
13
|
+
NotFoundError,
|
|
14
|
+
OptedOutError,
|
|
15
|
+
PayloadTooLargeError,
|
|
16
|
+
PolicyRejectedError,
|
|
17
|
+
RateLimitedError,
|
|
18
|
+
ServerError,
|
|
19
|
+
UnsupportedMediaTypeError,
|
|
20
|
+
ValidationError,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
PROTOCOL_VERSION = "0"
|
|
24
|
+
PROTOCOL_VERSION_HEADER = "X-Docs-Feedback-Protocol-Version"
|
|
25
|
+
REPORTS_PATH = "/v1/reports"
|
|
26
|
+
RETRYABLE_STATUS_CODES = frozenset({502, 503, 504})
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def _sdk_user_agent() -> str:
|
|
30
|
+
# Import here to avoid an import cycle (``__init__`` re-exports from
|
|
31
|
+
# ``client.py``, which imports this module).
|
|
32
|
+
from fixyourdocs import __version__
|
|
33
|
+
|
|
34
|
+
return f"fixyourdocs-python/{__version__}"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _build_headers(
|
|
38
|
+
token: Optional[str],
|
|
39
|
+
idempotency_key: Optional[str],
|
|
40
|
+
) -> dict[str, str]:
|
|
41
|
+
"""Assemble the request headers for ``POST /v1/reports``."""
|
|
42
|
+
headers: dict[str, str] = {
|
|
43
|
+
"Content-Type": "application/json",
|
|
44
|
+
PROTOCOL_VERSION_HEADER: PROTOCOL_VERSION,
|
|
45
|
+
"User-Agent": _sdk_user_agent(),
|
|
46
|
+
"Accept": "application/json",
|
|
47
|
+
}
|
|
48
|
+
if token:
|
|
49
|
+
headers["Authorization"] = f"Bearer {token}"
|
|
50
|
+
if idempotency_key:
|
|
51
|
+
headers["Idempotency-Key"] = idempotency_key
|
|
52
|
+
return headers
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _safe_json(response: httpx.Response) -> dict[str, Any]:
|
|
56
|
+
"""Decode a response body as JSON, returning ``{}`` on failure."""
|
|
57
|
+
try:
|
|
58
|
+
data = response.json()
|
|
59
|
+
except Exception:
|
|
60
|
+
return {}
|
|
61
|
+
if isinstance(data, dict):
|
|
62
|
+
return data
|
|
63
|
+
return {}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _retry_after_seconds(response: httpx.Response) -> Optional[int]:
|
|
67
|
+
raw = response.headers.get("Retry-After")
|
|
68
|
+
if raw is None:
|
|
69
|
+
return None
|
|
70
|
+
try:
|
|
71
|
+
return int(raw.strip())
|
|
72
|
+
except ValueError:
|
|
73
|
+
return None
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def is_retryable_status(status_code: int) -> bool:
|
|
77
|
+
"""Return ``True`` if the SDK should retry once on this status."""
|
|
78
|
+
return status_code in RETRYABLE_STATUS_CODES
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def _raise_for_status(response: httpx.Response) -> None:
|
|
82
|
+
"""Translate a non-2xx response into the matching typed error."""
|
|
83
|
+
status = response.status_code
|
|
84
|
+
body = _safe_json(response)
|
|
85
|
+
error_message = str(body.get("error") or response.reason_phrase or f"HTTP {status}")
|
|
86
|
+
|
|
87
|
+
if status == 400:
|
|
88
|
+
raise ValidationError(
|
|
89
|
+
error_message,
|
|
90
|
+
status_code=status,
|
|
91
|
+
body=body,
|
|
92
|
+
details=list(body.get("details") or []),
|
|
93
|
+
)
|
|
94
|
+
if status == 401:
|
|
95
|
+
raise AuthError(error_message, status_code=status, body=body)
|
|
96
|
+
if status == 404:
|
|
97
|
+
raise NotFoundError(error_message, status_code=status, body=body)
|
|
98
|
+
if status == 410:
|
|
99
|
+
raise OptedOutError(
|
|
100
|
+
error_message,
|
|
101
|
+
status_code=status,
|
|
102
|
+
body=body,
|
|
103
|
+
since=body.get("since"),
|
|
104
|
+
)
|
|
105
|
+
if status == 413:
|
|
106
|
+
raw_max = body.get("max_bytes")
|
|
107
|
+
max_bytes: Optional[int]
|
|
108
|
+
try:
|
|
109
|
+
max_bytes = int(raw_max) if raw_max is not None else None
|
|
110
|
+
except (TypeError, ValueError):
|
|
111
|
+
max_bytes = None
|
|
112
|
+
raise PayloadTooLargeError(
|
|
113
|
+
error_message,
|
|
114
|
+
status_code=status,
|
|
115
|
+
body=body,
|
|
116
|
+
max_bytes=max_bytes,
|
|
117
|
+
)
|
|
118
|
+
if status == 415:
|
|
119
|
+
raise UnsupportedMediaTypeError(error_message, status_code=status, body=body)
|
|
120
|
+
if status == 422:
|
|
121
|
+
raise PolicyRejectedError(
|
|
122
|
+
error_message,
|
|
123
|
+
status_code=status,
|
|
124
|
+
body=body,
|
|
125
|
+
reason=body.get("reason"),
|
|
126
|
+
)
|
|
127
|
+
if status == 429:
|
|
128
|
+
raise RateLimitedError(
|
|
129
|
+
error_message,
|
|
130
|
+
status_code=status,
|
|
131
|
+
body=body,
|
|
132
|
+
retry_after=_retry_after_seconds(response),
|
|
133
|
+
)
|
|
134
|
+
if 500 <= status < 600:
|
|
135
|
+
raise ServerError(error_message, status_code=status, body=body)
|
|
136
|
+
|
|
137
|
+
# Any other 4xx the spec doesn't enumerate.
|
|
138
|
+
raise FixYourDocsError(error_message, status_code=status, body=body)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def parse_response(response: httpx.Response) -> SendResult:
|
|
142
|
+
"""Map a 2xx response to :class:`SendResult`; raise on non-2xx."""
|
|
143
|
+
if response.status_code in (200, 201):
|
|
144
|
+
body = _safe_json(response)
|
|
145
|
+
return SendResult(
|
|
146
|
+
id=str(body.get("id", "")),
|
|
147
|
+
received_at=body.get("received_at"), # type: ignore[arg-type]
|
|
148
|
+
protocol_version=str(body.get("protocol_version", PROTOCOL_VERSION)),
|
|
149
|
+
server_capabilities=list(body.get("server_capabilities") or []),
|
|
150
|
+
is_duplicate=(response.status_code == 200),
|
|
151
|
+
status_code=response.status_code,
|
|
152
|
+
)
|
|
153
|
+
_raise_for_status(response)
|
|
154
|
+
# Unreachable, but keeps mypy happy.
|
|
155
|
+
raise FixYourDocsError( # pragma: no cover
|
|
156
|
+
f"Unexpected status {response.status_code}", status_code=response.status_code
|
|
157
|
+
)
|
fixyourdocs/_results.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Result type returned by ``Client.send`` / ``AsyncClient.send``."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from datetime import datetime
|
|
6
|
+
from typing import Optional
|
|
7
|
+
|
|
8
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class SendResult(BaseModel):
|
|
12
|
+
"""Server acknowledgement parsed from a ``200``/``201`` response.
|
|
13
|
+
|
|
14
|
+
``is_duplicate`` is derived from the HTTP status code: ``201`` means
|
|
15
|
+
the server accepted a new submission, ``200`` means the idempotency
|
|
16
|
+
key matched an existing one.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
model_config = ConfigDict(extra="ignore")
|
|
20
|
+
|
|
21
|
+
id: str
|
|
22
|
+
received_at: datetime
|
|
23
|
+
protocol_version: str
|
|
24
|
+
server_capabilities: list[str] = Field(default_factory=list)
|
|
25
|
+
is_duplicate: bool = False
|
|
26
|
+
status_code: Optional[int] = None
|
fixyourdocs/client.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"""Sync and async HTTP clients for the Docs Feedback Protocol v0."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from types import TracebackType
|
|
6
|
+
from typing import Any, Optional, Union
|
|
7
|
+
|
|
8
|
+
import httpx
|
|
9
|
+
|
|
10
|
+
from fixyourdocs._http import (
|
|
11
|
+
REPORTS_PATH,
|
|
12
|
+
_build_headers,
|
|
13
|
+
is_retryable_status,
|
|
14
|
+
parse_response,
|
|
15
|
+
)
|
|
16
|
+
from fixyourdocs._results import SendResult
|
|
17
|
+
from fixyourdocs.models import Report
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _serialize(report: Report) -> dict[str, Any]:
|
|
21
|
+
"""Pydantic-dump a report into the wire-format JSON object."""
|
|
22
|
+
return report.model_dump(mode="json", exclude_none=True, by_alias=True)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def _reports_url(api_url: str) -> str:
|
|
26
|
+
return f"{api_url.rstrip('/')}{REPORTS_PATH}"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Client:
|
|
30
|
+
"""Synchronous client for ``POST /v1/reports``."""
|
|
31
|
+
|
|
32
|
+
def __init__(
|
|
33
|
+
self,
|
|
34
|
+
api_url: str,
|
|
35
|
+
*,
|
|
36
|
+
token: Optional[str] = None,
|
|
37
|
+
timeout: float = 10.0,
|
|
38
|
+
transport: Optional[httpx.BaseTransport] = None,
|
|
39
|
+
) -> None:
|
|
40
|
+
self._api_url = api_url
|
|
41
|
+
self._token = token
|
|
42
|
+
self._timeout = timeout
|
|
43
|
+
self._http = httpx.Client(timeout=timeout, transport=transport)
|
|
44
|
+
|
|
45
|
+
def __enter__(self) -> Client:
|
|
46
|
+
return self
|
|
47
|
+
|
|
48
|
+
def __exit__(
|
|
49
|
+
self,
|
|
50
|
+
exc_type: Optional[type[BaseException]],
|
|
51
|
+
exc: Optional[BaseException],
|
|
52
|
+
tb: Optional[TracebackType],
|
|
53
|
+
) -> None:
|
|
54
|
+
self.close()
|
|
55
|
+
|
|
56
|
+
def close(self) -> None:
|
|
57
|
+
self._http.close()
|
|
58
|
+
|
|
59
|
+
def send(
|
|
60
|
+
self,
|
|
61
|
+
report: Report,
|
|
62
|
+
*,
|
|
63
|
+
idempotency_key: Optional[str] = None,
|
|
64
|
+
) -> SendResult:
|
|
65
|
+
"""Submit ``report``. Returns :class:`SendResult` on 200/201; raises on errors."""
|
|
66
|
+
url = _reports_url(self._api_url)
|
|
67
|
+
body = _serialize(report)
|
|
68
|
+
headers = _build_headers(self._token, idempotency_key)
|
|
69
|
+
|
|
70
|
+
response = self._http.post(url, json=body, headers=headers)
|
|
71
|
+
if is_retryable_status(response.status_code):
|
|
72
|
+
response = self._http.post(url, json=body, headers=headers)
|
|
73
|
+
return parse_response(response)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class AsyncClient:
|
|
77
|
+
"""Asynchronous client for ``POST /v1/reports``."""
|
|
78
|
+
|
|
79
|
+
def __init__(
|
|
80
|
+
self,
|
|
81
|
+
api_url: str,
|
|
82
|
+
*,
|
|
83
|
+
token: Optional[str] = None,
|
|
84
|
+
timeout: float = 10.0,
|
|
85
|
+
transport: Optional[Union[httpx.AsyncBaseTransport, httpx.BaseTransport]] = None,
|
|
86
|
+
) -> None:
|
|
87
|
+
self._api_url = api_url
|
|
88
|
+
self._token = token
|
|
89
|
+
self._timeout = timeout
|
|
90
|
+
# ``httpx.MockTransport`` satisfies both sync and async transport
|
|
91
|
+
# protocols, which makes it convenient for tests; we just accept
|
|
92
|
+
# either here and pass it through.
|
|
93
|
+
self._http = httpx.AsyncClient(
|
|
94
|
+
timeout=timeout,
|
|
95
|
+
transport=transport, # type: ignore[arg-type]
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
async def __aenter__(self) -> AsyncClient:
|
|
99
|
+
return self
|
|
100
|
+
|
|
101
|
+
async def __aexit__(
|
|
102
|
+
self,
|
|
103
|
+
exc_type: Optional[type[BaseException]],
|
|
104
|
+
exc: Optional[BaseException],
|
|
105
|
+
tb: Optional[TracebackType],
|
|
106
|
+
) -> None:
|
|
107
|
+
await self.aclose()
|
|
108
|
+
|
|
109
|
+
async def aclose(self) -> None:
|
|
110
|
+
await self._http.aclose()
|
|
111
|
+
|
|
112
|
+
async def send(
|
|
113
|
+
self,
|
|
114
|
+
report: Report,
|
|
115
|
+
*,
|
|
116
|
+
idempotency_key: Optional[str] = None,
|
|
117
|
+
) -> SendResult:
|
|
118
|
+
"""Submit ``report``. Returns :class:`SendResult` on 200/201; raises on errors."""
|
|
119
|
+
url = _reports_url(self._api_url)
|
|
120
|
+
body = _serialize(report)
|
|
121
|
+
headers = _build_headers(self._token, idempotency_key)
|
|
122
|
+
|
|
123
|
+
response = await self._http.post(url, json=body, headers=headers)
|
|
124
|
+
if is_retryable_status(response.status_code):
|
|
125
|
+
response = await self._http.post(url, json=body, headers=headers)
|
|
126
|
+
return parse_response(response)
|
fixyourdocs/errors.py
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""Typed exceptions raised by the SDK on non-2xx HTTP responses.
|
|
2
|
+
|
|
3
|
+
These mirror the error table in §7.3 of the protocol spec. Each
|
|
4
|
+
exception captures whatever extra context the wire format carries for
|
|
5
|
+
its status code (e.g. ``retry_after`` for 429, ``since`` for 410), so
|
|
6
|
+
callers can branch on the type and read the structured fields instead
|
|
7
|
+
of re-parsing the response body.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from typing import Any, Optional
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class FixYourDocsError(Exception):
|
|
16
|
+
"""Base class for every typed SDK error.
|
|
17
|
+
|
|
18
|
+
All concrete subclasses carry the raw decoded JSON body (when one
|
|
19
|
+
was returned) on ``.body`` so callers can inspect server-specific
|
|
20
|
+
extensions that v0 does not standardise.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
def __init__(
|
|
24
|
+
self,
|
|
25
|
+
message: str,
|
|
26
|
+
*,
|
|
27
|
+
status_code: Optional[int] = None,
|
|
28
|
+
body: Optional[dict[str, Any]] = None,
|
|
29
|
+
) -> None:
|
|
30
|
+
super().__init__(message)
|
|
31
|
+
self.status_code = status_code
|
|
32
|
+
self.body = body or {}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class ValidationError(FixYourDocsError):
|
|
36
|
+
"""``400`` — body failed schema validation or version header mismatch."""
|
|
37
|
+
|
|
38
|
+
def __init__(
|
|
39
|
+
self,
|
|
40
|
+
message: str,
|
|
41
|
+
*,
|
|
42
|
+
status_code: Optional[int] = None,
|
|
43
|
+
body: Optional[dict[str, Any]] = None,
|
|
44
|
+
details: Optional[list[dict[str, Any]]] = None,
|
|
45
|
+
) -> None:
|
|
46
|
+
super().__init__(message, status_code=status_code, body=body)
|
|
47
|
+
self.details: list[dict[str, Any]] = details or []
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class AuthError(FixYourDocsError):
|
|
51
|
+
"""``401`` — auth required and missing/invalid."""
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
class NotFoundError(FixYourDocsError):
|
|
55
|
+
"""``404`` — endpoint does not map to a known receiving organisation."""
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class OptedOutError(FixYourDocsError):
|
|
59
|
+
"""``410`` — the receiving organisation has opted out."""
|
|
60
|
+
|
|
61
|
+
def __init__(
|
|
62
|
+
self,
|
|
63
|
+
message: str,
|
|
64
|
+
*,
|
|
65
|
+
status_code: Optional[int] = None,
|
|
66
|
+
body: Optional[dict[str, Any]] = None,
|
|
67
|
+
since: Optional[str] = None,
|
|
68
|
+
) -> None:
|
|
69
|
+
super().__init__(message, status_code=status_code, body=body)
|
|
70
|
+
self.since = since
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
class PayloadTooLargeError(FixYourDocsError):
|
|
74
|
+
"""``413`` — body exceeds the server's size limit."""
|
|
75
|
+
|
|
76
|
+
def __init__(
|
|
77
|
+
self,
|
|
78
|
+
message: str,
|
|
79
|
+
*,
|
|
80
|
+
status_code: Optional[int] = None,
|
|
81
|
+
body: Optional[dict[str, Any]] = None,
|
|
82
|
+
max_bytes: Optional[int] = None,
|
|
83
|
+
) -> None:
|
|
84
|
+
super().__init__(message, status_code=status_code, body=body)
|
|
85
|
+
self.max_bytes = max_bytes
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class UnsupportedMediaTypeError(FixYourDocsError):
|
|
89
|
+
"""``415`` — Content-Type was not JSON."""
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class PolicyRejectedError(FixYourDocsError):
|
|
93
|
+
"""``422`` — body validated but server rejected on policy grounds."""
|
|
94
|
+
|
|
95
|
+
def __init__(
|
|
96
|
+
self,
|
|
97
|
+
message: str,
|
|
98
|
+
*,
|
|
99
|
+
status_code: Optional[int] = None,
|
|
100
|
+
body: Optional[dict[str, Any]] = None,
|
|
101
|
+
reason: Optional[str] = None,
|
|
102
|
+
) -> None:
|
|
103
|
+
super().__init__(message, status_code=status_code, body=body)
|
|
104
|
+
self.reason = reason
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class RateLimitedError(FixYourDocsError):
|
|
108
|
+
"""``429`` — rate-limited; ``retry_after`` from the ``Retry-After`` header."""
|
|
109
|
+
|
|
110
|
+
def __init__(
|
|
111
|
+
self,
|
|
112
|
+
message: str,
|
|
113
|
+
*,
|
|
114
|
+
status_code: Optional[int] = None,
|
|
115
|
+
body: Optional[dict[str, Any]] = None,
|
|
116
|
+
retry_after: Optional[int] = None,
|
|
117
|
+
) -> None:
|
|
118
|
+
super().__init__(message, status_code=status_code, body=body)
|
|
119
|
+
self.retry_after = retry_after
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class ServerError(FixYourDocsError):
|
|
123
|
+
"""``5xx`` — server-side failure (after the one allowed retry)."""
|
fixyourdocs/models.py
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"""Pydantic v2 models mirroring ``schema/v0/report.schema.json``.
|
|
2
|
+
|
|
3
|
+
The models are deliberately a 1:1 translation of the JSON Schema so
|
|
4
|
+
serialised output round-trips byte-for-byte against the canonical
|
|
5
|
+
example fixtures. ``Report.create(...)`` is the ergonomic, flat
|
|
6
|
+
constructor most callers should reach for; the nested
|
|
7
|
+
``Report(agent=..., report=...)`` form is exposed for advanced use.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
from datetime import datetime
|
|
13
|
+
from enum import Enum
|
|
14
|
+
from typing import Any, Literal, Optional
|
|
15
|
+
|
|
16
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class EvidenceKind(str, Enum):
|
|
20
|
+
"""Enumerated kinds of evidence; see §4.4 of the spec."""
|
|
21
|
+
|
|
22
|
+
ERROR_MESSAGE = "error_message"
|
|
23
|
+
ATTEMPTED_ACTION = "attempted_action"
|
|
24
|
+
EXPECTED = "expected"
|
|
25
|
+
OBSERVED = "observed"
|
|
26
|
+
CODE_SNIPPET = "code_snippet"
|
|
27
|
+
QUOTE = "quote"
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class ReportKind(str, Enum):
|
|
31
|
+
"""Enumerated kinds of report; see §4.4 of the spec."""
|
|
32
|
+
|
|
33
|
+
BROKEN = "broken"
|
|
34
|
+
INCORRECT = "incorrect"
|
|
35
|
+
OUTDATED = "outdated"
|
|
36
|
+
MISSING = "missing"
|
|
37
|
+
UNCLEAR = "unclear"
|
|
38
|
+
OTHER = "other"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
class Evidence(BaseModel):
|
|
42
|
+
"""One evidence item attached to a report body."""
|
|
43
|
+
|
|
44
|
+
model_config = ConfigDict(extra="forbid", use_enum_values=True)
|
|
45
|
+
|
|
46
|
+
kind: EvidenceKind
|
|
47
|
+
text: str = Field(..., min_length=1, max_length=4000)
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
class AgentInfo(BaseModel):
|
|
51
|
+
"""Identification of the agent that produced the report."""
|
|
52
|
+
|
|
53
|
+
model_config = ConfigDict(extra="forbid")
|
|
54
|
+
|
|
55
|
+
name: str = Field(
|
|
56
|
+
...,
|
|
57
|
+
min_length=1,
|
|
58
|
+
max_length=64,
|
|
59
|
+
pattern=r"^[a-z0-9]([a-z0-9-]*[a-z0-9])?$",
|
|
60
|
+
)
|
|
61
|
+
version: Optional[str] = Field(default=None, max_length=64)
|
|
62
|
+
vendor: Optional[str] = Field(default=None, max_length=128)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
class ReportBody(BaseModel):
|
|
66
|
+
"""The substance of the feedback."""
|
|
67
|
+
|
|
68
|
+
model_config = ConfigDict(extra="forbid", use_enum_values=True)
|
|
69
|
+
|
|
70
|
+
kind: ReportKind
|
|
71
|
+
summary: str = Field(..., min_length=1, max_length=500)
|
|
72
|
+
details: Optional[str] = Field(default=None, max_length=8000)
|
|
73
|
+
evidence: Optional[list[Evidence]] = Field(default=None, max_length=20)
|
|
74
|
+
suggested_fix: Optional[str] = Field(default=None, max_length=4000)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
class TaskContext(BaseModel):
|
|
78
|
+
"""Optional context about the agent task that surfaced the issue."""
|
|
79
|
+
|
|
80
|
+
model_config = ConfigDict(extra="forbid")
|
|
81
|
+
|
|
82
|
+
task_summary: Optional[str] = Field(default=None, max_length=500)
|
|
83
|
+
transcript_excerpt: Optional[str] = Field(default=None, max_length=4000)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
class Report(BaseModel):
|
|
87
|
+
"""A single Docs Feedback Protocol v0 report.
|
|
88
|
+
|
|
89
|
+
Use :meth:`Report.create` for the ergonomic flat constructor. The
|
|
90
|
+
nested form (passing :class:`AgentInfo` / :class:`ReportBody`
|
|
91
|
+
explicitly) is also supported.
|
|
92
|
+
"""
|
|
93
|
+
|
|
94
|
+
model_config = ConfigDict(extra="forbid", populate_by_name=True)
|
|
95
|
+
|
|
96
|
+
protocol_version: Literal["0"] = "0"
|
|
97
|
+
doc_url: str = Field(..., max_length=2048)
|
|
98
|
+
agent: AgentInfo
|
|
99
|
+
report: ReportBody
|
|
100
|
+
task_context: Optional[TaskContext] = None
|
|
101
|
+
idempotency_key: Optional[str] = Field(
|
|
102
|
+
default=None,
|
|
103
|
+
min_length=1,
|
|
104
|
+
max_length=128,
|
|
105
|
+
pattern=r"^[\x21-\x7e]+$",
|
|
106
|
+
)
|
|
107
|
+
submitted_at: Optional[datetime] = None
|
|
108
|
+
locale: Optional[str] = Field(
|
|
109
|
+
default=None,
|
|
110
|
+
max_length=35,
|
|
111
|
+
pattern=r"^[A-Za-z]{1,8}(-[A-Za-z0-9]{1,8})*$",
|
|
112
|
+
)
|
|
113
|
+
client_capabilities: Optional[list[str]] = Field(default=None, max_length=32)
|
|
114
|
+
|
|
115
|
+
@classmethod
|
|
116
|
+
def create(
|
|
117
|
+
cls,
|
|
118
|
+
*,
|
|
119
|
+
doc_url: str,
|
|
120
|
+
summary: str,
|
|
121
|
+
kind: ReportKind | str,
|
|
122
|
+
agent_name: str,
|
|
123
|
+
agent_version: Optional[str] = None,
|
|
124
|
+
agent_vendor: Optional[str] = None,
|
|
125
|
+
details: Optional[str] = None,
|
|
126
|
+
evidence: Optional[list[Evidence | dict[str, Any]]] = None,
|
|
127
|
+
suggested_fix: Optional[str] = None,
|
|
128
|
+
task_summary: Optional[str] = None,
|
|
129
|
+
transcript_excerpt: Optional[str] = None,
|
|
130
|
+
idempotency_key: Optional[str] = None,
|
|
131
|
+
submitted_at: Optional[datetime] = None,
|
|
132
|
+
locale: Optional[str] = None,
|
|
133
|
+
client_capabilities: Optional[list[str]] = None,
|
|
134
|
+
) -> Report:
|
|
135
|
+
"""Build a :class:`Report` from a flat keyword-argument set.
|
|
136
|
+
|
|
137
|
+
This is the convenience constructor for the common case of
|
|
138
|
+
producing a one-shot report without manually instantiating the
|
|
139
|
+
nested ``AgentInfo``, ``ReportBody``, and ``TaskContext``
|
|
140
|
+
objects.
|
|
141
|
+
"""
|
|
142
|
+
agent = AgentInfo(name=agent_name, version=agent_version, vendor=agent_vendor)
|
|
143
|
+
|
|
144
|
+
ev_models: Optional[list[Evidence]]
|
|
145
|
+
if evidence is None:
|
|
146
|
+
ev_models = None
|
|
147
|
+
else:
|
|
148
|
+
ev_models = [
|
|
149
|
+
item if isinstance(item, Evidence) else Evidence(**item) for item in evidence
|
|
150
|
+
]
|
|
151
|
+
|
|
152
|
+
body = ReportBody(
|
|
153
|
+
kind=ReportKind(kind) if not isinstance(kind, ReportKind) else kind,
|
|
154
|
+
summary=summary,
|
|
155
|
+
details=details,
|
|
156
|
+
evidence=ev_models,
|
|
157
|
+
suggested_fix=suggested_fix,
|
|
158
|
+
)
|
|
159
|
+
|
|
160
|
+
task_context: Optional[TaskContext]
|
|
161
|
+
if task_summary is None and transcript_excerpt is None:
|
|
162
|
+
task_context = None
|
|
163
|
+
else:
|
|
164
|
+
task_context = TaskContext(
|
|
165
|
+
task_summary=task_summary,
|
|
166
|
+
transcript_excerpt=transcript_excerpt,
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
return cls(
|
|
170
|
+
doc_url=doc_url,
|
|
171
|
+
agent=agent,
|
|
172
|
+
report=body,
|
|
173
|
+
task_context=task_context,
|
|
174
|
+
idempotency_key=idempotency_key,
|
|
175
|
+
submitted_at=submitted_at,
|
|
176
|
+
locale=locale,
|
|
177
|
+
client_capabilities=client_capabilities,
|
|
178
|
+
)
|
fixyourdocs/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fixyourdocs
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Reference Python SDK for the Docs Feedback Protocol
|
|
5
|
+
Project-URL: Homepage, https://docsfeedback.org
|
|
6
|
+
Project-URL: Repository, https://github.com/fixyourdocs/sdk-python
|
|
7
|
+
Project-URL: Specification, https://github.com/fixyourdocs/protocol
|
|
8
|
+
Author-email: FixYourDocs <hello@fixyourdocs.org>
|
|
9
|
+
License-Expression: Apache-2.0
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: agents,ai,docs,documentation,feedback,protocol
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Documentation
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Requires-Dist: httpx<1,>=0.27
|
|
25
|
+
Requires-Dist: pydantic<3,>=2.6
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: mypy>=1.10; extra == 'dev'
|
|
28
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
29
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
30
|
+
Requires-Dist: respx>=0.21; extra == 'dev'
|
|
31
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
32
|
+
Description-Content-Type: text/markdown
|
|
33
|
+
|
|
34
|
+
# fixyourdocs (Python SDK)
|
|
35
|
+
|
|
36
|
+
Reference Python SDK for the [Docs Feedback Protocol](https://github.com/fixyourdocs/protocol)
|
|
37
|
+
v0. The protocol lets AI agents file structured reports against
|
|
38
|
+
documentation pages when the docs break agent task flows.
|
|
39
|
+
|
|
40
|
+
- Spec: <https://docsfeedback.org>.
|
|
41
|
+
- Why this exists: [the FixYourDocs manifesto](https://github.com/fixyourdocs/manifesto/blob/main/MANIFESTO.md).
|
|
42
|
+
|
|
43
|
+
## Install
|
|
44
|
+
|
|
45
|
+
```sh
|
|
46
|
+
pip install fixyourdocs
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Requires Python 3.9+.
|
|
50
|
+
|
|
51
|
+
## Usage (sync)
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from fixyourdocs import Client, Report
|
|
55
|
+
|
|
56
|
+
report = Report.create(
|
|
57
|
+
doc_url="https://docs.example.com/getting-started",
|
|
58
|
+
summary="The page does not document how to set the API_KEY env var.",
|
|
59
|
+
kind="missing",
|
|
60
|
+
agent_name="claude-code",
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
with Client(api_url="https://hub.fixyourdocs.io") as client:
|
|
64
|
+
result = client.send(report)
|
|
65
|
+
|
|
66
|
+
print(result.id, result.is_duplicate)
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Usage (async)
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
import asyncio
|
|
73
|
+
from fixyourdocs import AsyncClient, Report
|
|
74
|
+
|
|
75
|
+
async def main() -> None:
|
|
76
|
+
report = Report.create(
|
|
77
|
+
doc_url="https://docs.example.com/getting-started",
|
|
78
|
+
summary="The page does not document how to set the API_KEY env var.",
|
|
79
|
+
kind="missing",
|
|
80
|
+
agent_name="claude-code",
|
|
81
|
+
)
|
|
82
|
+
async with AsyncClient(api_url="https://hub.fixyourdocs.io") as client:
|
|
83
|
+
result = await client.send(report)
|
|
84
|
+
print(result.id, result.is_duplicate)
|
|
85
|
+
|
|
86
|
+
asyncio.run(main())
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## API shape
|
|
90
|
+
|
|
91
|
+
The wire format is a nested object (`agent`, `report`, `task_context`),
|
|
92
|
+
so the SDK exposes two ways to build a `Report`:
|
|
93
|
+
|
|
94
|
+
- **`Report.create(...)`** — ergonomic, flat keyword-argument
|
|
95
|
+
constructor for the common case. Internally builds the nested
|
|
96
|
+
wire-format structure.
|
|
97
|
+
- **`Report(agent=AgentInfo(...), report=ReportBody(...), ...)`** — the
|
|
98
|
+
typed nested form, useful when constructing reports programmatically
|
|
99
|
+
from already-typed sub-objects.
|
|
100
|
+
|
|
101
|
+
Both produce identical wire output.
|
|
102
|
+
|
|
103
|
+
## Errors
|
|
104
|
+
|
|
105
|
+
Non-2xx responses raise typed exceptions:
|
|
106
|
+
|
|
107
|
+
| Status | Exception |
|
|
108
|
+
|---|---|
|
|
109
|
+
| 400 | `ValidationError` (`.details`) |
|
|
110
|
+
| 401 | `AuthError` |
|
|
111
|
+
| 404 | `NotFoundError` |
|
|
112
|
+
| 410 | `OptedOutError` (`.since`) |
|
|
113
|
+
| 413 | `PayloadTooLargeError` (`.max_bytes`) |
|
|
114
|
+
| 415 | `UnsupportedMediaTypeError` |
|
|
115
|
+
| 422 | `PolicyRejectedError` (`.reason`) |
|
|
116
|
+
| 429 | `RateLimitedError` (`.retry_after`) |
|
|
117
|
+
| 5xx | `ServerError` (after one automatic retry on 502/503/504) |
|
|
118
|
+
|
|
119
|
+
All inherit from `FixYourDocsError`.
|
|
120
|
+
|
|
121
|
+
## Licence
|
|
122
|
+
|
|
123
|
+
Apache License 2.0 — see [LICENSE](LICENSE).
|
|
124
|
+
|
|
125
|
+
## Contributing
|
|
126
|
+
|
|
127
|
+
Contributions require a DCO sign-off and a signed Apache Individual
|
|
128
|
+
Contributor License Agreement — see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
fixyourdocs/__init__.py,sha256=4ZHLSmlpOEnk_6y8rZYYEz0kYIsoSYFBNy3YVrrr5es,1130
|
|
2
|
+
fixyourdocs/_http.py,sha256=ERBhMuUP-5MF18NjpNeZFvLCkxG0eF9B-ZTKXv0kDqg,4914
|
|
3
|
+
fixyourdocs/_results.py,sha256=fz7HKAqb2j1y0id3hZac2w3vX6sgXMp29epySpnWvMo,750
|
|
4
|
+
fixyourdocs/client.py,sha256=6DYcTGjgaJ4oAxUmIKnIKyYwZzSWa6YzRLhzM1H7uKU,3719
|
|
5
|
+
fixyourdocs/errors.py,sha256=2s7A_NJ7XRiJj0Iyt-nDHVHaYC7Y5cLeNjSM8f_6-hY,3624
|
|
6
|
+
fixyourdocs/models.py,sha256=9tD3UURwv6N111f0ev3thW6anKuK4VZgiQyDJCzpC9k,5613
|
|
7
|
+
fixyourdocs/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
fixyourdocs-0.1.0.dist-info/METADATA,sha256=NZl1Aqhub4Lc6vDftHCwfDvjxxLljBnTCE-5ab_K-4M,4007
|
|
9
|
+
fixyourdocs-0.1.0.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
10
|
+
fixyourdocs-0.1.0.dist-info/licenses/LICENSE,sha256=sD0F9MsULLCVKAXoaS8HbMkKPUtV5lh2_wEjYozVPoU,11357
|
|
11
|
+
fixyourdocs-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 FixYourDocs (Maciej Stopa)
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|