caspian-utils 0.0.26 → 0.0.28
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.
- package/dist/docs/fetch-data.md +11 -9
- package/dist/docs/routing.md +18 -14
- package/package.json +1 -1
package/dist/docs/fetch-data.md
CHANGED
|
@@ -12,10 +12,10 @@ related:
|
|
|
12
12
|
- /docs/database
|
|
13
13
|
- /docs/file-uploads
|
|
14
14
|
- /docs/cache
|
|
15
|
-
- /docs/routing
|
|
16
|
-
- /docs/pulsepoint
|
|
17
|
-
- /docs/pulsepoint-runtime-map
|
|
18
|
-
- /docs/project-structure
|
|
15
|
+
- /docs/routing
|
|
16
|
+
- /docs/pulsepoint
|
|
17
|
+
- /docs/pulsepoint-runtime-map
|
|
18
|
+
- /docs/project-structure
|
|
19
19
|
- /docs/index
|
|
20
20
|
---
|
|
21
21
|
|
|
@@ -140,11 +140,11 @@ Validate incoming form and mutation payloads before persisting them. See [valida
|
|
|
140
140
|
|
|
141
141
|
If an RPC action needs transient request-scoped success or error state beyond its direct return payload, read [state.md](./state.md) and verify the current wire-request lifecycle before depending on persistence across navigations or full-page reloads.
|
|
142
142
|
|
|
143
|
-
Important:
|
|
144
|
-
|
|
145
|
-
- `pp.rpc()` posts to the current route RPC bridge.
|
|
146
|
-
- Older docs may refer to `pp.fetchFunction()`. In this repo's current runtime, the supported helper is `pp.rpc()`.
|
|
147
|
-
- Use [pulsepoint-runtime-map.md](./pulsepoint-runtime-map.md) when debugging browser-side RPC options such as streaming, upload progress, abort behavior, redirects, or SPA interaction.
|
|
143
|
+
Important:
|
|
144
|
+
|
|
145
|
+
- `pp.rpc()` posts to the current route RPC bridge.
|
|
146
|
+
- Older docs may refer to `pp.fetchFunction()`. In this repo's current runtime, the supported helper is `pp.rpc()`.
|
|
147
|
+
- Use [pulsepoint-runtime-map.md](./pulsepoint-runtime-map.md) when debugging browser-side RPC options such as streaming, upload progress, abort behavior, redirects, or SPA interaction.
|
|
148
148
|
|
|
149
149
|
## Streaming Responses
|
|
150
150
|
|
|
@@ -276,6 +276,8 @@ Use [auth.md](./auth.md) when the action should also participate in centralized
|
|
|
276
276
|
|
|
277
277
|
According to the upstream Caspian RPC docs, actions are private by default until decorated with `@rpc()`, and the framework includes CSRF protection plus origin validation for exposed actions.
|
|
278
278
|
|
|
279
|
+
For reverse-proxy deployments, RPC origin validation can also resolve the public app origin from `APP_BASE_URL`, `PUBLIC_BASE_URL`, or `SITE_URL`, and otherwise falls back to forwarded host and protocol headers when they are present.
|
|
280
|
+
|
|
279
281
|
## Serialization Rules
|
|
280
282
|
|
|
281
283
|
For RPC responses, Caspian can automatically serialize common Python return types such as:
|
package/dist/docs/routing.md
CHANGED
|
@@ -10,10 +10,10 @@ related:
|
|
|
10
10
|
- /docs/components
|
|
11
11
|
- /docs/cache
|
|
12
12
|
- /docs/file-uploads
|
|
13
|
-
- /docs/metadata
|
|
14
|
-
- /docs/pulsepoint
|
|
15
|
-
- /docs/pulsepoint-runtime-map
|
|
16
|
-
- /docs/index
|
|
13
|
+
- /docs/metadata
|
|
14
|
+
- /docs/pulsepoint
|
|
15
|
+
- /docs/pulsepoint-runtime-map
|
|
16
|
+
- /docs/index
|
|
17
17
|
---
|
|
18
18
|
|
|
19
19
|
Caspian follows the same mental model as the Next.js App Router: routes live under `src/app`, folders define URL segments, layouts nest automatically, and special folder names control grouping and dynamic matching.
|
|
@@ -228,7 +228,7 @@ Also bad:
|
|
|
228
228
|
</section>
|
|
229
229
|
```
|
|
230
230
|
|
|
231
|
-
Use [pulsepoint.md](./pulsepoint.md) when you need the full authored-vs-rendered example instead of this routing-focused reminder. Use [pulsepoint-runtime-map.md](./pulsepoint-runtime-map.md) when a route task names a specific PulsePoint directive or SPA behavior and you need the owning runtime file quickly.
|
|
231
|
+
Use [pulsepoint.md](./pulsepoint.md) when you need the full authored-vs-rendered example instead of this routing-focused reminder. Use [pulsepoint-runtime-map.md](./pulsepoint-runtime-map.md) when a route task names a specific PulsePoint directive or SPA behavior and you need the owning runtime file quickly.
|
|
232
232
|
|
|
233
233
|
### `index.py`
|
|
234
234
|
|
|
@@ -236,6 +236,8 @@ Use `index.py` as the backend companion when a route needs metadata or async ser
|
|
|
236
236
|
|
|
237
237
|
Use `index.py` by itself only for non-visual routes such as redirects or action-only handlers. Because Caspian runs on FastAPI, the page entry should be async when it performs async work.
|
|
238
238
|
|
|
239
|
+
When `page()` calls `render_page(__file__, ...)`, root-validation errors are attributed to the sibling `index.html` because that file is the authored template. If `page()` returns a raw HTML string directly, Caspian treats that value as a runtime fragment instead of an authored template and wraps it in a runtime host root when needed.
|
|
240
|
+
|
|
239
241
|
Example:
|
|
240
242
|
|
|
241
243
|
```python
|
|
@@ -391,20 +393,22 @@ Example root layout:
|
|
|
391
393
|
|
|
392
394
|
If a layout needs shared synchronous props or metadata, add a `layout.py` file next to the HTML layout. Treat it as the backend companion for the layout, not as the place to author visible wrapper markup.
|
|
393
395
|
|
|
396
|
+
When `layout()` calls `render_layout(__file__, ...)`, root-validation errors are attributed to the sibling `layout.html` because that file is the authored template. If `layout()` returns a raw HTML string directly, Caspian treats that value as a runtime fragment instead of an authored template and wraps it in a runtime host root when needed.
|
|
397
|
+
|
|
394
398
|
Example:
|
|
395
399
|
|
|
396
400
|
```python
|
|
397
401
|
from casp.auth import auth
|
|
398
402
|
|
|
399
|
-
def layout(context_data):
|
|
400
|
-
user = auth.get_payload()
|
|
401
|
-
|
|
402
|
-
return {
|
|
403
|
-
"user": user,
|
|
404
|
-
"dashboard_body_class": "w-screen h-screen overflow-hidden",
|
|
405
|
-
"theme": "dark",
|
|
406
|
-
}
|
|
407
|
-
```
|
|
403
|
+
def layout(context_data):
|
|
404
|
+
user = auth.get_payload()
|
|
405
|
+
|
|
406
|
+
return {
|
|
407
|
+
"user": user,
|
|
408
|
+
"dashboard_body_class": "w-screen h-screen overflow-hidden",
|
|
409
|
+
"theme": "dark",
|
|
410
|
+
}
|
|
411
|
+
```
|
|
408
412
|
|
|
409
413
|
`context_data` includes URL parameters such as dynamic route values.
|
|
410
414
|
|