rn-forge-web 0.3.3__tar.gz → 0.4.0__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.
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/PKG-INFO +2 -2
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/pyproject.toml +2 -2
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/pyproject.toml.orig +2 -2
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/__init__.py +6 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/exceptions.py +15 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/problem.py +7 -3
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/transfer.py +28 -24
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/LICENSE +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/README.md +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/asgi.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/auth.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/concurrency.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/__init__.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/_pagination.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/_platform.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/_problem.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/_shared.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/_transfer.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/_writes.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/cases.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/conformance/types.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/deprecation.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/health.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/idempotency.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/merge_patch.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/models.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/openapi.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/operations.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/pagination.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/py.typed +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/read_mask.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/security.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/soft_delete.py +0 -0
- {rn_forge_web-0.3.3 → rn_forge_web-0.4.0}/src/rn_forge/web/tracing.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: rn-forge-web
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Framework-agnostic HTTP/API primitives built on rn-forge-commons
|
|
5
5
|
Author: Rohit Narayanan
|
|
6
6
|
Author-email: Rohit Narayanan <rohit.nn@gmail.com>
|
|
@@ -15,7 +15,7 @@ Classifier: Programming Language :: Python :: 3.14
|
|
|
15
15
|
Classifier: Typing :: Typed
|
|
16
16
|
Requires-Dist: rn-forge-commons[pydantic]>=0.8.0,<0.11
|
|
17
17
|
Requires-Dist: opentelemetry-api>=1.44
|
|
18
|
-
Requires-Dist: secure>=2.0.
|
|
18
|
+
Requires-Dist: secure>=2.0.2 ; extra == 'security'
|
|
19
19
|
Requires-Dist: assertpy>=2.36.0 ; extra == 'testing'
|
|
20
20
|
Requires-Dist: pytest>=9.1.1 ; extra == 'testing'
|
|
21
21
|
Requires-Python: >=3.14
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "rn-forge-web"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.0"
|
|
4
4
|
description = "Framework-agnostic HTTP/API primitives built on rn-forge-commons"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -29,7 +29,7 @@ testing = [
|
|
|
29
29
|
"assertpy>=2.36.0",
|
|
30
30
|
"pytest>=9.1.1",
|
|
31
31
|
]
|
|
32
|
-
security = ["secure>=2.0.
|
|
32
|
+
security = ["secure>=2.0.2"]
|
|
33
33
|
|
|
34
34
|
[project.urls]
|
|
35
35
|
Documentation = "https://rn-forge.github.io/pykit/packages/rn-forge-web/latest/"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "rn-forge-web"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.4.0"
|
|
4
4
|
description = "Framework-agnostic HTTP/API primitives built on rn-forge-commons"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [{ name = "Rohit Narayanan", email = "rohit.nn@gmail.com" }]
|
|
@@ -31,7 +31,7 @@ testing = ["assertpy>=2.36.0", "pytest>=9.1.1"]
|
|
|
31
31
|
# `rn_forge.web.security` only. `secure` is framework-agnostic (no dependencies
|
|
32
32
|
# of its own) and emits the OWASP header preset directly, so it is wrapped
|
|
33
33
|
# rather than hand-rolled.
|
|
34
|
-
security = ["secure>=2.0.
|
|
34
|
+
security = ["secure>=2.0.2"]
|
|
35
35
|
|
|
36
36
|
[project.urls]
|
|
37
37
|
Documentation = "https://rn-forge.github.io/pykit/packages/rn-forge-web/latest/"
|
|
@@ -43,6 +43,7 @@ from rn_forge.web.deprecation import (
|
|
|
43
43
|
)
|
|
44
44
|
from rn_forge.web.exceptions import (
|
|
45
45
|
AuthenticationFailed,
|
|
46
|
+
BadRequest,
|
|
46
47
|
ContentTooLarge,
|
|
47
48
|
CsrfFailed,
|
|
48
49
|
DomainConflict,
|
|
@@ -56,6 +57,7 @@ from rn_forge.web.exceptions import (
|
|
|
56
57
|
InvalidReadMask,
|
|
57
58
|
ItemsDenied,
|
|
58
59
|
MalformedPrecondition,
|
|
60
|
+
NotFound,
|
|
59
61
|
PermissionDenied,
|
|
60
62
|
PreconditionRequired,
|
|
61
63
|
RemoteProblem,
|
|
@@ -66,6 +68,7 @@ from rn_forge.web.exceptions import (
|
|
|
66
68
|
SessionRequired,
|
|
67
69
|
TooManyRequests,
|
|
68
70
|
UnsupportedMediaType,
|
|
71
|
+
ValidationFailed,
|
|
69
72
|
VersionConflict,
|
|
70
73
|
WebError,
|
|
71
74
|
)
|
|
@@ -249,6 +252,7 @@ __all__ = [
|
|
|
249
252
|
"ASGIApp",
|
|
250
253
|
"AsyncIdempotencyStore",
|
|
251
254
|
"AuthenticationFailed",
|
|
255
|
+
"BadRequest",
|
|
252
256
|
"BatchUpdateItem",
|
|
253
257
|
"BearerErrorCode",
|
|
254
258
|
"BodySizeLimitMiddleware",
|
|
@@ -285,6 +289,7 @@ __all__ = [
|
|
|
285
289
|
"JsonValue",
|
|
286
290
|
"MalformedPrecondition",
|
|
287
291
|
"Message",
|
|
292
|
+
"NotFound",
|
|
288
293
|
"Operation",
|
|
289
294
|
"OrderField",
|
|
290
295
|
"Page",
|
|
@@ -311,6 +316,7 @@ __all__ = [
|
|
|
311
316
|
"TabularFormat",
|
|
312
317
|
"TooManyRequests",
|
|
313
318
|
"UnsupportedMediaType",
|
|
319
|
+
"ValidationFailed",
|
|
314
320
|
"VersionConflict",
|
|
315
321
|
"VersionETagCodec",
|
|
316
322
|
"WebError",
|
|
@@ -13,6 +13,7 @@ if TYPE_CHECKING:
|
|
|
13
13
|
|
|
14
14
|
__all__ = [
|
|
15
15
|
"AuthenticationFailed",
|
|
16
|
+
"BadRequest",
|
|
16
17
|
"ContentTooLarge",
|
|
17
18
|
"CsrfFailed",
|
|
18
19
|
"DomainConflict",
|
|
@@ -26,6 +27,7 @@ __all__ = [
|
|
|
26
27
|
"InvalidReadMask",
|
|
27
28
|
"ItemsDenied",
|
|
28
29
|
"MalformedPrecondition",
|
|
30
|
+
"NotFound",
|
|
29
31
|
"PermissionDenied",
|
|
30
32
|
"PreconditionRequired",
|
|
31
33
|
"RemoteProblem",
|
|
@@ -36,6 +38,7 @@ __all__ = [
|
|
|
36
38
|
"SessionRequired",
|
|
37
39
|
"TooManyRequests",
|
|
38
40
|
"UnsupportedMediaType",
|
|
41
|
+
"ValidationFailed",
|
|
39
42
|
"VersionConflict",
|
|
40
43
|
"WebError",
|
|
41
44
|
]
|
|
@@ -118,6 +121,18 @@ class MalformedPrecondition(_PointedError):
|
|
|
118
121
|
"""The precondition header was present but could not be parsed (400)."""
|
|
119
122
|
|
|
120
123
|
|
|
124
|
+
class BadRequest(_PointedError):
|
|
125
|
+
"""The request cannot be read as sent (400)."""
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
class NotFound(WebError):
|
|
129
|
+
"""The addressed resource does not exist, or its existence is hidden (404)."""
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class ValidationFailed(_PointedError):
|
|
133
|
+
"""The request is well formed but breaks a rule (422)."""
|
|
134
|
+
|
|
135
|
+
|
|
121
136
|
class InvalidCursor(WebError):
|
|
122
137
|
"""The pagination token was absent from, or malformed in, the request (400)."""
|
|
123
138
|
|
|
@@ -18,6 +18,7 @@ from pydantic import ConfigDict, model_validator
|
|
|
18
18
|
from rn_forge.web.auth import AUTH_FAILED_DETAIL, CSRF_FAILED_DETAIL, challenge_header
|
|
19
19
|
from rn_forge.web.exceptions import (
|
|
20
20
|
AuthenticationFailed,
|
|
21
|
+
BadRequest,
|
|
21
22
|
ContentTooLarge,
|
|
22
23
|
CsrfFailed,
|
|
23
24
|
DomainConflict,
|
|
@@ -31,6 +32,7 @@ from rn_forge.web.exceptions import (
|
|
|
31
32
|
InvalidReadMask,
|
|
32
33
|
ItemsDenied,
|
|
33
34
|
MalformedPrecondition,
|
|
35
|
+
NotFound,
|
|
34
36
|
PermissionDenied,
|
|
35
37
|
PreconditionRequired,
|
|
36
38
|
RemoteProblem,
|
|
@@ -38,6 +40,7 @@ from rn_forge.web.exceptions import (
|
|
|
38
40
|
ServiceUnavailable,
|
|
39
41
|
TooManyRequests,
|
|
40
42
|
UnsupportedMediaType,
|
|
43
|
+
ValidationFailed,
|
|
41
44
|
VersionConflict,
|
|
42
45
|
)
|
|
43
46
|
from rn_forge.web.models import WireModel
|
|
@@ -302,7 +305,7 @@ class ProblemRegistry:
|
|
|
302
305
|
|
|
303
306
|
A framework raises HTTP errors no application registered — a routing
|
|
304
307
|
404, a 405. The row is the **first registered row with that status**, so
|
|
305
|
-
a framework 404 and a ``
|
|
308
|
+
a framework 404 and a ``NotFound`` produce the same body. With no such
|
|
306
309
|
row it is derived from the IANA reason phrase (405 →
|
|
307
310
|
``method-not-allowed`` / ``Method Not Allowed``); a status with no
|
|
308
311
|
reason phrase resolves to the fallback.
|
|
@@ -543,8 +546,9 @@ def default_registry(*, type_base: str = "") -> ProblemRegistry:
|
|
|
543
546
|
.register(InvalidMergePatch, VALIDATION_ERROR)
|
|
544
547
|
.register(RowsInvalid, VALIDATION_ERROR)
|
|
545
548
|
.register(ServiceUnavailable, SERVICE_UNAVAILABLE)
|
|
546
|
-
.register(
|
|
547
|
-
.register(
|
|
549
|
+
.register(BadRequest, BAD_REQUEST)
|
|
550
|
+
.register(NotFound, NOT_FOUND)
|
|
551
|
+
.register(ValidationFailed, VALIDATION_ERROR)
|
|
548
552
|
)
|
|
549
553
|
|
|
550
554
|
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from collections.abc import Iterable, Mapping
|
|
5
|
+
from collections.abc import Iterable, Mapping, Sequence
|
|
6
6
|
from dataclasses import dataclass
|
|
7
7
|
from typing import Any, Final, Literal, cast
|
|
8
8
|
from urllib.parse import quote
|
|
9
9
|
|
|
10
|
-
from rn_forge.web.exceptions import InvalidBatchGet, RowsInvalid
|
|
10
|
+
from rn_forge.web.exceptions import InvalidBatchGet, RowsInvalid, ValidationFailed
|
|
11
11
|
from rn_forge.web.merge_patch import JsonValue
|
|
12
12
|
from rn_forge.web.problem import (
|
|
13
13
|
REQUIRED_FIELD_DETAIL,
|
|
@@ -208,7 +208,7 @@ def row_errors_problem(
|
|
|
208
208
|
]
|
|
209
209
|
return render_problem(
|
|
210
210
|
registry or default_registry(),
|
|
211
|
-
|
|
211
|
+
ValidationFailed(_VALIDATION_ERROR),
|
|
212
212
|
instance=instance,
|
|
213
213
|
problem=VALIDATION_ERROR,
|
|
214
214
|
detail="One or more rows are invalid.",
|
|
@@ -222,7 +222,7 @@ def export_cap_problem(
|
|
|
222
222
|
"""Render "the export exceeds *cap* rows" as a 422 problem naming the cap."""
|
|
223
223
|
return render_problem(
|
|
224
224
|
registry or default_registry(),
|
|
225
|
-
|
|
225
|
+
ValidationFailed(_VALIDATION_ERROR),
|
|
226
226
|
instance=instance,
|
|
227
227
|
problem=VALIDATION_ERROR,
|
|
228
228
|
detail=f"The export exceeds the limit of {cap} rows; narrow the filter.",
|
|
@@ -246,7 +246,7 @@ def row_cap_problem(
|
|
|
246
246
|
"""
|
|
247
247
|
return render_problem(
|
|
248
248
|
registry or default_registry(),
|
|
249
|
-
|
|
249
|
+
ValidationFailed(_VALIDATION_ERROR),
|
|
250
250
|
instance=instance,
|
|
251
251
|
problem=VALIDATION_ERROR,
|
|
252
252
|
detail=_cap_detail(kind, cap),
|
|
@@ -319,6 +319,27 @@ def _parse_batch_item(
|
|
|
319
319
|
)
|
|
320
320
|
|
|
321
321
|
|
|
322
|
+
def _parse_batch_items(entries: Sequence[object]) -> list[BatchUpdateItem]:
|
|
323
|
+
"""The items of a batch, in request order."""
|
|
324
|
+
items: list[BatchUpdateItem] = []
|
|
325
|
+
errors: list[RowError] = []
|
|
326
|
+
for index, entry in enumerate(entries):
|
|
327
|
+
item = _parse_batch_item(index, entry, errors)
|
|
328
|
+
if item is not None:
|
|
329
|
+
items.append(item)
|
|
330
|
+
if errors:
|
|
331
|
+
raise RowsInvalid(errors, root="requests")
|
|
332
|
+
|
|
333
|
+
seen: set[str] = set()
|
|
334
|
+
for item in items:
|
|
335
|
+
if item.id in seen:
|
|
336
|
+
errors.append(RowError(item.index, "id", DUPLICATE_ID_DETAIL))
|
|
337
|
+
seen.add(item.id)
|
|
338
|
+
if errors:
|
|
339
|
+
raise RowsInvalid(errors, root="requests")
|
|
340
|
+
return items
|
|
341
|
+
|
|
342
|
+
|
|
322
343
|
def parse_batch_update(
|
|
323
344
|
body: object,
|
|
324
345
|
*,
|
|
@@ -353,7 +374,7 @@ def parse_batch_update(
|
|
|
353
374
|
)
|
|
354
375
|
return render_problem(
|
|
355
376
|
registry or default_registry(),
|
|
356
|
-
|
|
377
|
+
ValidationFailed(_VALIDATION_ERROR),
|
|
357
378
|
instance=instance,
|
|
358
379
|
problem=VALIDATION_ERROR,
|
|
359
380
|
detail=_VALIDATION_ERROR,
|
|
@@ -362,24 +383,7 @@ def parse_batch_update(
|
|
|
362
383
|
entries = cast("list[object]", raw)
|
|
363
384
|
if cap is not None and len(entries) > cap:
|
|
364
385
|
return row_cap_problem("batch", cap, instance=instance, registry=registry)
|
|
365
|
-
|
|
366
|
-
items: list[BatchUpdateItem] = []
|
|
367
|
-
errors: list[RowError] = []
|
|
368
|
-
for index, entry in enumerate(entries):
|
|
369
|
-
item = _parse_batch_item(index, entry, errors)
|
|
370
|
-
if item is not None:
|
|
371
|
-
items.append(item)
|
|
372
|
-
if errors:
|
|
373
|
-
raise RowsInvalid(errors, root="requests")
|
|
374
|
-
|
|
375
|
-
seen: set[str] = set()
|
|
376
|
-
for item in items:
|
|
377
|
-
if item.id in seen:
|
|
378
|
-
errors.append(RowError(item.index, "id", DUPLICATE_ID_DETAIL))
|
|
379
|
-
seen.add(item.id)
|
|
380
|
-
if errors:
|
|
381
|
-
raise RowsInvalid(errors, root="requests")
|
|
382
|
-
return items
|
|
386
|
+
return _parse_batch_items(entries)
|
|
383
387
|
|
|
384
388
|
|
|
385
389
|
@dataclass(frozen=True)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|