litestar-vite 0.2.2__tar.gz → 0.2.4__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.
Potentially problematic release.
This version of litestar-vite might be problematic. Click here for more details.
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/PKG-INFO +1 -1
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/inertia/__init__.py +3 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/inertia/config.py +4 -2
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/inertia/exception_handler.py +22 -16
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/inertia/response.py +29 -15
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/plugin.py +1 -1
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/pyproject.toml +1 -1
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_inertia/test_inertia_request.py +1 -1
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_inertia/test_inertia_response.py +4 -4
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/.github/CODEOWNERS +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/.github/dependabot.yaml +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/.github/workflows/cd.yaml +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/.github/workflows/ci.yaml +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/.github/workflows/docs-preview.yaml +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/.github/workflows/docs.yaml +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/.github/workflows/pr-title.yaml +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/.github/workflows/publish.yaml +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/.gitignore +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/.pre-commit-config.yaml +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/.python-version +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/CONTRIBUTING.rst +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/LICENSE +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/Makefile +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/README.md +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/docs/Makefile +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/docs/conf.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/docs/contribution-guide.rst +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/docs/fix_missing_references.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/docs/index.rst +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/docs/reference/config.rst +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/docs/reference/plugin.rst +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/docs/usage/index.rst +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/docs/usage/placeholder.rst +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/__init__.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/basic/app.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/basic/package-lock.json +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/basic/package.json +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/basic/public/assets/main-l0sNRNKZ.js +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/basic/public/assets/styles-l0sNRNKZ.js +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/basic/public/manifest.json +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/basic/resources/main.ts +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/basic/resources/styles.css +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/basic/templates/index.html.j2 +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/basic/tsconfig.json +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/basic/vite.config.ts +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/flash/app.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/flash/package-lock.json +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/flash/package.json +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/flash/public/assets/main-l0sNRNKZ.js +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/flash/public/assets/styles-l0sNRNKZ.js +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/flash/public/manifest.json +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/flash/resources/main.ts +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/flash/resources/styles.css +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/flash/templates/index.html.j2 +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/flash/tsconfig.json +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/flash/vite.config.ts +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/app.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/package-lock.json +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/package.json +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/postcss.config.cjs +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/public/assets/main-BIhkjqcE.js +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/public/assets/styles-B8hX6ha2.css +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/public/manifest.json +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/resources/Layout.vue +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/resources/main.js +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/resources/pages/Dashboard.vue +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/resources/pages/Home.vue +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/resources/styles.css +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/resources/templates/index.html +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/resources/vite-env.d.ts +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/tailwind.config.cjs +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/tsconfig.json +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/vite.config.ts +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/__init__.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/__metadata__.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/cli.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/commands.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/config.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/inertia/_utils.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/inertia/middleware.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/inertia/plugin.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/inertia/request.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/inertia/routes.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/inertia/types.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/loader.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/py.typed +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/template_engine.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/templates/__init__.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/templates/index.html.j2 +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/templates/main.ts.j2 +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/templates/package.json.j2 +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/templates/styles.css.j2 +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/templates/tsconfig.json.j2 +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/litestar_vite/templates/vite.config.ts.j2 +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/pdm.lock +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/__init__.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/conftest.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/templates/__init__.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/templates/index.html.j2 +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_app/__init__.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_app/app.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_app/web/__init__.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_app/web/public/.gitkeep +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_app/web/public/assets/main-l0sNRNKZ.js +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_app/web/public/assets/styles-l0sNRNKZ.js +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_app/web/public/manifest.json +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_app/web/resources/.gitkeep +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_app/web/resources/main.ts +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_app/web/resources/styles.css +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_app/web/templates/.gitkeep +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_app/web/templates/index.html +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_cli/__init__.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_cli/conftest.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_cli/test_init.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_commands.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_config.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_inertia/__init__.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_inertia/conftest.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_inertia/templates/index.html.j2 +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_inertia/test_routes.py +0 -0
- {litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_template_engine.py +0 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from .config import InertiaConfig
|
|
2
|
+
from .exception_handler import create_inertia_exception_response, exception_to_http_response
|
|
2
3
|
from .middleware import InertiaMiddleware
|
|
3
4
|
from .plugin import InertiaPlugin
|
|
4
5
|
from .request import InertiaDetails, InertiaHeaders, InertiaRequest
|
|
@@ -28,4 +29,6 @@ __all__ = (
|
|
|
28
29
|
"InertiaRedirect",
|
|
29
30
|
"generate_js_routes",
|
|
30
31
|
"InertiaMiddleware",
|
|
32
|
+
"exception_to_http_response",
|
|
33
|
+
"create_inertia_exception_response",
|
|
31
34
|
)
|
|
@@ -21,5 +21,7 @@ class InertiaConfig:
|
|
|
21
21
|
"""An identifier to use on routes to exclude a route from the generated routes typescript file."""
|
|
22
22
|
redirect_unauthorized_to: str | None = None
|
|
23
23
|
"""Optionally supply a path where unauthorized requests should redirect."""
|
|
24
|
-
|
|
25
|
-
"""A dictionary of values to automatically add in to page props on every
|
|
24
|
+
extra_static_page_props: dict[str, Any] = field(default_factory=dict)
|
|
25
|
+
"""A dictionary of values to automatically add in to page props on every response."""
|
|
26
|
+
extra_session_page_props: set[str] = field(default_factory=set)
|
|
27
|
+
"""A set of session keys for which the value automatically be added (if it exists) to the response."""
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import contextlib
|
|
2
1
|
import re
|
|
3
2
|
from typing import TYPE_CHECKING, Any, cast
|
|
4
3
|
|
|
@@ -44,7 +43,7 @@ class _HTTPConflictException(HTTPException):
|
|
|
44
43
|
status_code = HTTP_409_CONFLICT
|
|
45
44
|
|
|
46
45
|
|
|
47
|
-
def exception_to_http_response(request: Request[UserT, AuthT, StateT], exc: Exception) -> Response[Any]:
|
|
46
|
+
def exception_to_http_response(request: Request[UserT, AuthT, StateT], exc: Exception) -> Response[Any]:
|
|
48
47
|
"""Handler for all exceptions subclassed from HTTPException."""
|
|
49
48
|
inertia_enabled = getattr(request, "inertia_enabled", False) or getattr(request, "is_inertia", False)
|
|
50
49
|
if isinstance(exc, NotFoundError):
|
|
@@ -57,17 +56,25 @@ def exception_to_http_response(request: Request[UserT, AuthT, StateT], exc: Exce
|
|
|
57
56
|
if request.app.debug and http_exc not in (PermissionDeniedException, NotFoundError):
|
|
58
57
|
return cast("Response[Any]", create_debug_response(request, exc))
|
|
59
58
|
return cast("Response[Any]", create_exception_response(request, http_exc(detail=str(exc.__cause__))))
|
|
59
|
+
return create_inertia_exception_response(request, exc)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def create_inertia_exception_response(request: Request[UserT, AuthT, StateT], exc: Exception) -> Response[Any]:
|
|
63
|
+
"""Create the inertia exception response"""
|
|
60
64
|
is_inertia = getattr(request, "is_inertia", False)
|
|
61
65
|
status_code = getattr(exc, "status_code", HTTP_500_INTERNAL_SERVER_ERROR)
|
|
62
|
-
preferred_type = MediaType.HTML if
|
|
66
|
+
preferred_type = MediaType.HTML if not is_inertia else MediaType.JSON
|
|
63
67
|
detail = getattr(exc, "detail", "") # litestar exceptions
|
|
64
68
|
extras = getattr(exc, "extra", "") # msgspec exceptions
|
|
65
69
|
content = {"status_code": status_code, "message": getattr(exc, "detail", "")}
|
|
66
70
|
inertia_plugin = cast("InertiaPlugin", request.app.plugins.get("InertiaPlugin"))
|
|
67
71
|
if extras:
|
|
68
72
|
content.update({"extra": extras})
|
|
69
|
-
|
|
73
|
+
try:
|
|
70
74
|
flash(request, detail, category="error")
|
|
75
|
+
except AttributeError:
|
|
76
|
+
msg = "Unable to set `flash` session state. A valid session was not found for this request."
|
|
77
|
+
request.logger.warning(msg)
|
|
71
78
|
if extras and len(extras) >= 1:
|
|
72
79
|
message = extras[0]
|
|
73
80
|
default_field = f"root.{message.get('key')}" if message.get("key", None) is not None else "root" # type: ignore
|
|
@@ -75,8 +82,7 @@ def exception_to_http_response(request: Request[UserT, AuthT, StateT], exc: Exce
|
|
|
75
82
|
match = FIELD_ERR_RE.search(error_detail)
|
|
76
83
|
field = match.group(1) if match else default_field
|
|
77
84
|
if isinstance(message, dict):
|
|
78
|
-
|
|
79
|
-
error(request, field, error_detail)
|
|
85
|
+
error(request, field, error_detail)
|
|
80
86
|
if status_code in {HTTP_422_UNPROCESSABLE_ENTITY, HTTP_400_BAD_REQUEST} or isinstance(
|
|
81
87
|
exc,
|
|
82
88
|
PermissionDeniedException,
|
|
@@ -85,15 +91,15 @@ def exception_to_http_response(request: Request[UserT, AuthT, StateT], exc: Exce
|
|
|
85
91
|
if isinstance(exc, PermissionDeniedException):
|
|
86
92
|
return InertiaBack(request)
|
|
87
93
|
if status_code == HTTP_401_UNAUTHORIZED or isinstance(exc, NotAuthorizedException):
|
|
88
|
-
|
|
94
|
+
if (
|
|
89
95
|
inertia_plugin.config.redirect_unauthorized_to is not None
|
|
90
96
|
and str(request.url) != inertia_plugin.config.redirect_unauthorized_to
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
)
|
|
97
|
+
):
|
|
98
|
+
return InertiaRedirect(request, redirect_to=inertia_plugin.config.redirect_unauthorized_to)
|
|
99
|
+
if str(request.url) != inertia_plugin.config.redirect_unauthorized_to:
|
|
100
|
+
return InertiaResponse[Any](
|
|
101
|
+
media_type=preferred_type,
|
|
102
|
+
content=content,
|
|
103
|
+
status_code=status_code,
|
|
104
|
+
)
|
|
105
|
+
return InertiaBack(request)
|
|
@@ -16,7 +16,6 @@ from litestar.response import Redirect
|
|
|
16
16
|
from litestar.response.base import ASGIResponse
|
|
17
17
|
from litestar.serialization import get_serializer
|
|
18
18
|
from litestar.status_codes import HTTP_200_OK, HTTP_303_SEE_OTHER, HTTP_307_TEMPORARY_REDIRECT, HTTP_409_CONFLICT
|
|
19
|
-
from litestar.types import Empty
|
|
20
19
|
from litestar.utils.deprecation import warn_deprecation
|
|
21
20
|
from litestar.utils.empty import value_or_default
|
|
22
21
|
from litestar.utils.helpers import get_enum_string_value
|
|
@@ -47,7 +46,11 @@ def share(
|
|
|
47
46
|
key: str,
|
|
48
47
|
value: Any,
|
|
49
48
|
) -> None:
|
|
50
|
-
|
|
49
|
+
try:
|
|
50
|
+
connection.session.setdefault("_shared", {}).update({key: value})
|
|
51
|
+
except AttributeError:
|
|
52
|
+
msg = "Unable to set `share` session state. A valid session was not found for this request."
|
|
53
|
+
connection.logger.warning(msg)
|
|
51
54
|
|
|
52
55
|
|
|
53
56
|
def error(
|
|
@@ -55,7 +58,11 @@ def error(
|
|
|
55
58
|
key: str,
|
|
56
59
|
message: str,
|
|
57
60
|
) -> None:
|
|
58
|
-
|
|
61
|
+
try:
|
|
62
|
+
connection.session.setdefault("_errors", {}).update({key: message})
|
|
63
|
+
except AttributeError:
|
|
64
|
+
msg = "Unable to set `error` session state. A valid session was not found for this request."
|
|
65
|
+
connection.logger.warning(msg)
|
|
59
66
|
|
|
60
67
|
|
|
61
68
|
def get_shared_props(request: ASGIConnection[Any, Any, Any, Any]) -> Dict[str, Any]: # noqa: UP006
|
|
@@ -64,19 +71,26 @@ def get_shared_props(request: ASGIConnection[Any, Any, Any, Any]) -> Dict[str, A
|
|
|
64
71
|
|
|
65
72
|
Be sure to call this before `self.create_template_context` if you would like to include the `flash` message details.
|
|
66
73
|
"""
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
74
|
+
props: dict[str, Any] = {}
|
|
75
|
+
try:
|
|
76
|
+
error_bag = request.headers.get("X-Inertia-Error-Bag", None)
|
|
77
|
+
errors: dict[str, Any] = request.session.pop("_errors", {})
|
|
78
|
+
props.update(cast("Dict[str,Any]", request.session.pop("_shared", {})))
|
|
79
|
+
flash: dict[str, list[str]] = defaultdict(list)
|
|
80
|
+
for message in cast("List[Dict[str,Any]]", request.session.pop("_messages", [])):
|
|
81
|
+
flash[message["category"]].append(message["message"])
|
|
82
|
+
|
|
83
|
+
inertia_plugin = cast("InertiaPlugin", request.app.plugins.get("InertiaPlugin"))
|
|
84
|
+
props.update(inertia_plugin.config.extra_static_page_props)
|
|
85
|
+
for session_prop in inertia_plugin.config.extra_session_page_props:
|
|
86
|
+
if session_prop not in props and session_prop in request.session:
|
|
87
|
+
props[session_prop] = request.session.get(session_prop)
|
|
88
|
+
props["flash"] = flash
|
|
89
|
+
props["errors"] = {error_bag: errors} if error_bag is not None else errors
|
|
90
|
+
except AttributeError:
|
|
91
|
+
msg = "Unable to generate all shared props. A valid session was not found for this request."
|
|
92
|
+
request.logger.warning(msg)
|
|
77
93
|
props["csrf_token"] = value_or_default(ScopeState.from_scope(request.scope).csrf_token, "")
|
|
78
|
-
props["flash"] = flash
|
|
79
|
-
props["errors"] = {error_bag: errors} if error_bag is not None else errors
|
|
80
94
|
return props
|
|
81
95
|
|
|
82
96
|
|
|
@@ -28,7 +28,7 @@ def set_environment(config: ViteConfig) -> None:
|
|
|
28
28
|
os.environ.setdefault("VITE_PORT", str(config.port))
|
|
29
29
|
os.environ.setdefault("VITE_HOST", config.host)
|
|
30
30
|
os.environ.setdefault("VITE_PROTOCOL", config.protocol)
|
|
31
|
-
os.environ.setdefault("APP_URL", "http://localhost:8000")
|
|
31
|
+
os.environ.setdefault("APP_URL", f"http://localhost:{os.environ.get('LITESTAR_PORT',8000)}")
|
|
32
32
|
if config.dev_mode:
|
|
33
33
|
os.environ.setdefault("VITE_DEV_MODE", str(config.dev_mode))
|
|
34
34
|
|
|
@@ -73,7 +73,7 @@ async def test_is_inertia_true(inertia_plugin: InertiaPlugin, vite_plugin: ViteP
|
|
|
73
73
|
response = client.get("/", headers={InertiaHeaders.ENABLED.value: "true"})
|
|
74
74
|
assert (
|
|
75
75
|
response.text
|
|
76
|
-
== '{"component":null,"url":"/","version":"1.0","props":{"content":true,"
|
|
76
|
+
== '{"component":null,"url":"/","version":"1.0","props":{"content":true,"flash":{},"errors":{},"csrf_token":""}}'
|
|
77
77
|
)
|
|
78
78
|
|
|
79
79
|
|
|
@@ -49,7 +49,7 @@ async def test_component_inertia_header_enabled(inertia_plugin: InertiaPlugin, v
|
|
|
49
49
|
response = client.get("/", headers={InertiaHeaders.ENABLED.value: "true"})
|
|
50
50
|
assert (
|
|
51
51
|
response.content
|
|
52
|
-
== b'{"component":"Home","url":"/","version":"1.0","props":{"content":{"thing":"value"},"
|
|
52
|
+
== b'{"component":"Home","url":"/","version":"1.0","props":{"content":{"thing":"value"},"flash":{},"errors":{},"csrf_token":""}}'
|
|
53
53
|
)
|
|
54
54
|
|
|
55
55
|
|
|
@@ -72,7 +72,7 @@ async def test_component_inertia_flash_header_enabled(inertia_plugin: InertiaPlu
|
|
|
72
72
|
response = client.get("/", headers={InertiaHeaders.ENABLED.value: "true"})
|
|
73
73
|
assert (
|
|
74
74
|
response.content
|
|
75
|
-
== b'{"component":"Home","url":"/","version":"1.0","props":{"content":{"thing":"value"},"
|
|
75
|
+
== b'{"component":"Home","url":"/","version":"1.0","props":{"content":{"thing":"value"},"flash":{"info":["a flash message"]},"errors":{},"csrf_token":""}}'
|
|
76
76
|
)
|
|
77
77
|
|
|
78
78
|
|
|
@@ -99,7 +99,7 @@ async def test_component_inertia_shared_flash_header_enabled(
|
|
|
99
99
|
response = client.get("/", headers={InertiaHeaders.ENABLED.value: "true"})
|
|
100
100
|
assert (
|
|
101
101
|
response.content
|
|
102
|
-
== b'{"component":"Home","url":"/","version":"1.0","props":{"content":{"thing":"value"},"auth":{"user":"nobody"},"
|
|
102
|
+
== b'{"component":"Home","url":"/","version":"1.0","props":{"content":{"thing":"value"},"auth":{"user":"nobody"},"flash":{"info":["a flash message"]},"errors":{},"csrf_token":""}}'
|
|
103
103
|
)
|
|
104
104
|
|
|
105
105
|
|
|
@@ -135,5 +135,5 @@ async def test_component_inertia_version_redirect(inertia_plugin: InertiaPlugin,
|
|
|
135
135
|
)
|
|
136
136
|
assert (
|
|
137
137
|
response.content
|
|
138
|
-
== b'{"component":"Home","url":"/","version":"1.0","props":{"content":{"thing":"value"},"
|
|
138
|
+
== b'{"component":"Home","url":"/","version":"1.0","props":{"content":{"thing":"value"},"flash":{},"errors":{},"csrf_token":""}}'
|
|
139
139
|
)
|
|
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
|
|
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
|
{litestar_vite-0.2.2 → litestar_vite-0.2.4}/examples/inertia/public/assets/styles-B8hX6ha2.css
RENAMED
|
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
|
|
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
|
{litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_app/web/public/assets/main-l0sNRNKZ.js
RENAMED
|
File without changes
|
{litestar_vite-0.2.2 → litestar_vite-0.2.4}/tests/test_app/web/public/assets/styles-l0sNRNKZ.js
RENAMED
|
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
|