caspian-utils 0.0.20__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.
- caspian_utils-0.0.20/PKG-INFO +214 -0
- caspian_utils-0.0.20/README.md +180 -0
- caspian_utils-0.0.20/casp/__init__.py +0 -0
- caspian_utils-0.0.20/casp/auth.py +537 -0
- caspian_utils-0.0.20/casp/cache_handler.py +178 -0
- caspian_utils-0.0.20/casp/caspian_config.py +455 -0
- caspian_utils-0.0.20/casp/component_decorator.py +181 -0
- caspian_utils-0.0.20/casp/components_compiler.py +334 -0
- caspian_utils-0.0.20/casp/html_attrs.py +95 -0
- caspian_utils-0.0.20/casp/layout.py +561 -0
- caspian_utils-0.0.20/casp/loading.py +25 -0
- caspian_utils-0.0.20/casp/rpc.py +236 -0
- caspian_utils-0.0.20/casp/scripts_type.py +21 -0
- caspian_utils-0.0.20/casp/state_manager.py +134 -0
- caspian_utils-0.0.20/casp/string_helpers.py +18 -0
- caspian_utils-0.0.20/casp/syntax_compiler.py +314 -0
- caspian_utils-0.0.20/casp/tw.py +31 -0
- caspian_utils-0.0.20/casp/validate.py +747 -0
- caspian_utils-0.0.20/caspian_utils.egg-info/PKG-INFO +214 -0
- caspian_utils-0.0.20/caspian_utils.egg-info/SOURCES.txt +23 -0
- caspian_utils-0.0.20/caspian_utils.egg-info/dependency_links.txt +1 -0
- caspian_utils-0.0.20/caspian_utils.egg-info/requires.txt +14 -0
- caspian_utils-0.0.20/caspian_utils.egg-info/top_level.txt +1 -0
- caspian_utils-0.0.20/setup.cfg +4 -0
- caspian_utils-0.0.20/setup.py +37 -0
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: caspian-utils
|
|
3
|
+
Version: 0.0.20
|
|
4
|
+
Summary: A utility package for Caspian projects
|
|
5
|
+
Home-page: https://github.com/TheSteelNinjaCode/caspian_utils
|
|
6
|
+
Author: Jefferson Abraham
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Requires-Python: >=3.11
|
|
11
|
+
Description-Content-Type: text/markdown
|
|
12
|
+
Requires-Dist: fastapi~=0.110
|
|
13
|
+
Requires-Dist: uvicorn~=0.27
|
|
14
|
+
Requires-Dist: python-dotenv~=1.0
|
|
15
|
+
Requires-Dist: jinja2~=3.1
|
|
16
|
+
Requires-Dist: beautifulsoup4~=4.12
|
|
17
|
+
Requires-Dist: tailwind-merge~=0.1
|
|
18
|
+
Requires-Dist: slowapi~=0.1
|
|
19
|
+
Requires-Dist: python-multipart~=0.0.9
|
|
20
|
+
Requires-Dist: starsessions~=1.3
|
|
21
|
+
Requires-Dist: httpx~=0.27
|
|
22
|
+
Requires-Dist: werkzeug~=3.0
|
|
23
|
+
Requires-Dist: cuid2~=2.0
|
|
24
|
+
Requires-Dist: nanoid~=2.0
|
|
25
|
+
Requires-Dist: python-ulid~=2.7
|
|
26
|
+
Dynamic: author
|
|
27
|
+
Dynamic: classifier
|
|
28
|
+
Dynamic: description
|
|
29
|
+
Dynamic: description-content-type
|
|
30
|
+
Dynamic: home-page
|
|
31
|
+
Dynamic: requires-dist
|
|
32
|
+
Dynamic: requires-python
|
|
33
|
+
Dynamic: summary
|
|
34
|
+
|
|
35
|
+
# Caspian Utils (`casp`)
|
|
36
|
+
|
|
37
|
+
Python is finally reactive.
|
|
38
|
+
|
|
39
|
+
**Caspian Utils** is the core utility package behind the Caspian framework ecosystem. It provides the building blocks used by Caspian projects: FastAPI-first plumbing, HTML/template processing, reactive integration patterns, RPC helpers, and common DX utilities.
|
|
40
|
+
|
|
41
|
+
- **PyPI package name:** `casp`
|
|
42
|
+
- **Framework/brand name:** Caspian (Caspian Utils is the shared library)
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## Why Caspian Utils?
|
|
47
|
+
|
|
48
|
+
Modern web stacks often require a separate Node backend, bundlers, and a growing set of conventions. Caspian projects remove that complexity while keeping the power:
|
|
49
|
+
|
|
50
|
+
- Keep the **DOM as the source of truth**
|
|
51
|
+
- Write **async Python** for server logic
|
|
52
|
+
- Call server functions directly from the UI via **RPC**
|
|
53
|
+
- Ship without a bundler or build pipeline
|
|
54
|
+
|
|
55
|
+
Caspian Utils exists to make those patterns reusable across apps and tooling.
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
## Key Capabilities
|
|
60
|
+
|
|
61
|
+
### FastAPI engine (native async)
|
|
62
|
+
|
|
63
|
+
Run application logic in **async Python** and leverage the FastAPI ecosystem (middleware, dependency injection, validation, Starlette sessions, etc.).
|
|
64
|
+
|
|
65
|
+
### Reactive DOM (no build step)
|
|
66
|
+
|
|
67
|
+
Modify HTML and see changes instantly. No Webpack/Vite required. The DOM is the runtime surface.
|
|
68
|
+
|
|
69
|
+
### File-system routing
|
|
70
|
+
|
|
71
|
+
Create pages like:
|
|
72
|
+
|
|
73
|
+
```text
|
|
74
|
+
app/users/index.py
|
|
75
|
+
app/users/index.html
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Caspian projects mount routes automatically based on your folder structure.
|
|
79
|
+
|
|
80
|
+
### Type-safe RPC (no API routes)
|
|
81
|
+
|
|
82
|
+
Call Python functions directly from the frontend without manually creating REST endpoints.
|
|
83
|
+
|
|
84
|
+
### Prisma ORM integration (optional)
|
|
85
|
+
|
|
86
|
+
Define your schema once and use an auto-generated, type-safe client in Python (no SQL boilerplate).
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Installation
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
pip install caspian-utils
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**Python:** `>=3.11`
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Quick Start (Conceptual)
|
|
101
|
+
|
|
102
|
+
A typical Caspian-style app is split into:
|
|
103
|
+
|
|
104
|
+
- `app/**/index.html` for UI
|
|
105
|
+
- `app/**/index.py` (or actions modules) for backend logic / RPC
|
|
106
|
+
- optional `app/**/layout.html` for nested layouts
|
|
107
|
+
|
|
108
|
+
### 1) Reactive UI in HTML
|
|
109
|
+
|
|
110
|
+
```html
|
|
111
|
+
<!-- app/todos/index.html -->
|
|
112
|
+
|
|
113
|
+
<!-- 1. Import Python Components -->
|
|
114
|
+
<!-- @import { Badge } from ../components/ui -->
|
|
115
|
+
|
|
116
|
+
<div class="flex gap-2 mb-4">
|
|
117
|
+
<Badge variant="default">Tasks: {todos.length}</Badge>
|
|
118
|
+
</div>
|
|
119
|
+
|
|
120
|
+
<!-- 2. Reactive loop -->
|
|
121
|
+
<ul>
|
|
122
|
+
<template pp-for="todo in todos">
|
|
123
|
+
<li key="{todo.id}" class="p-2 border-b">{todo.title}</li>
|
|
124
|
+
</template>
|
|
125
|
+
</ul>
|
|
126
|
+
|
|
127
|
+
<script>
|
|
128
|
+
// 3. State initialized by Python backend automatically
|
|
129
|
+
const [todos, setTodos] = pp.state([[todos]]);
|
|
130
|
+
</script>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### 2) Direct async RPC in Python
|
|
134
|
+
|
|
135
|
+
```py
|
|
136
|
+
# actions.py
|
|
137
|
+
|
|
138
|
+
from casp.rpc import rpc
|
|
139
|
+
from src.lib.prisma.db import prisma
|
|
140
|
+
|
|
141
|
+
@rpc(require_auth=True)
|
|
142
|
+
async def like_post(post_id: str):
|
|
143
|
+
# 1. Direct DB access (async)
|
|
144
|
+
post = await prisma.post.update(
|
|
145
|
+
where={"id": post_id},
|
|
146
|
+
data={"likes": {"increment": 1}},
|
|
147
|
+
)
|
|
148
|
+
# 2. Return data directly to frontend
|
|
149
|
+
return post.likes
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### 3) Call RPC from the frontend
|
|
153
|
+
|
|
154
|
+
```html
|
|
155
|
+
<button onclick="likePost()">Like Post</button>
|
|
156
|
+
|
|
157
|
+
<script>
|
|
158
|
+
async function likePost() {
|
|
159
|
+
const newCount = await pp.rpc("like_post", { post_id: "123" });
|
|
160
|
+
setLikes(newCount);
|
|
161
|
+
}
|
|
162
|
+
</script>
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
---
|
|
166
|
+
|
|
167
|
+
## What’s Included
|
|
168
|
+
|
|
169
|
+
Caspian Utils ships with integrations commonly used in Caspian projects:
|
|
170
|
+
|
|
171
|
+
- `fastapi`, `uvicorn`
|
|
172
|
+
- `jinja2` (templating)
|
|
173
|
+
- `beautifulsoup4` (HTML processing)
|
|
174
|
+
- `python-dotenv` (env loading)
|
|
175
|
+
- `slowapi` (rate limiting)
|
|
176
|
+
- `starsessions` (session management)
|
|
177
|
+
- `python-multipart` (uploads)
|
|
178
|
+
- `httpx` (HTTP client)
|
|
179
|
+
- `tailwind-merge` (class merging utility)
|
|
180
|
+
- `werkzeug` (helpers; used in some tooling)
|
|
181
|
+
- ID utilities: `cuid2`, `nanoid`, `python-ulid`
|
|
182
|
+
|
|
183
|
+
(Exact dependencies may vary by version; see `setup.py` in the repository.)
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Packaging Notes
|
|
188
|
+
|
|
189
|
+
If you are publishing to PyPI under `caspian-utils`, ensure your `setup.py` matches:
|
|
190
|
+
|
|
191
|
+
```py
|
|
192
|
+
setup(
|
|
193
|
+
name="caspian-utils",
|
|
194
|
+
# ...
|
|
195
|
+
)
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## Repository
|
|
201
|
+
|
|
202
|
+
[Repository](https://github.com/TheSteelNinjaCode/casp)
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## License
|
|
207
|
+
|
|
208
|
+
MIT
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Author
|
|
213
|
+
|
|
214
|
+
Jefferson Abraham
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# Caspian Utils (`casp`)
|
|
2
|
+
|
|
3
|
+
Python is finally reactive.
|
|
4
|
+
|
|
5
|
+
**Caspian Utils** is the core utility package behind the Caspian framework ecosystem. It provides the building blocks used by Caspian projects: FastAPI-first plumbing, HTML/template processing, reactive integration patterns, RPC helpers, and common DX utilities.
|
|
6
|
+
|
|
7
|
+
- **PyPI package name:** `casp`
|
|
8
|
+
- **Framework/brand name:** Caspian (Caspian Utils is the shared library)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Why Caspian Utils?
|
|
13
|
+
|
|
14
|
+
Modern web stacks often require a separate Node backend, bundlers, and a growing set of conventions. Caspian projects remove that complexity while keeping the power:
|
|
15
|
+
|
|
16
|
+
- Keep the **DOM as the source of truth**
|
|
17
|
+
- Write **async Python** for server logic
|
|
18
|
+
- Call server functions directly from the UI via **RPC**
|
|
19
|
+
- Ship without a bundler or build pipeline
|
|
20
|
+
|
|
21
|
+
Caspian Utils exists to make those patterns reusable across apps and tooling.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
## Key Capabilities
|
|
26
|
+
|
|
27
|
+
### FastAPI engine (native async)
|
|
28
|
+
|
|
29
|
+
Run application logic in **async Python** and leverage the FastAPI ecosystem (middleware, dependency injection, validation, Starlette sessions, etc.).
|
|
30
|
+
|
|
31
|
+
### Reactive DOM (no build step)
|
|
32
|
+
|
|
33
|
+
Modify HTML and see changes instantly. No Webpack/Vite required. The DOM is the runtime surface.
|
|
34
|
+
|
|
35
|
+
### File-system routing
|
|
36
|
+
|
|
37
|
+
Create pages like:
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
app/users/index.py
|
|
41
|
+
app/users/index.html
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Caspian projects mount routes automatically based on your folder structure.
|
|
45
|
+
|
|
46
|
+
### Type-safe RPC (no API routes)
|
|
47
|
+
|
|
48
|
+
Call Python functions directly from the frontend without manually creating REST endpoints.
|
|
49
|
+
|
|
50
|
+
### Prisma ORM integration (optional)
|
|
51
|
+
|
|
52
|
+
Define your schema once and use an auto-generated, type-safe client in Python (no SQL boilerplate).
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install caspian-utils
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Python:** `>=3.11`
|
|
63
|
+
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
## Quick Start (Conceptual)
|
|
67
|
+
|
|
68
|
+
A typical Caspian-style app is split into:
|
|
69
|
+
|
|
70
|
+
- `app/**/index.html` for UI
|
|
71
|
+
- `app/**/index.py` (or actions modules) for backend logic / RPC
|
|
72
|
+
- optional `app/**/layout.html` for nested layouts
|
|
73
|
+
|
|
74
|
+
### 1) Reactive UI in HTML
|
|
75
|
+
|
|
76
|
+
```html
|
|
77
|
+
<!-- app/todos/index.html -->
|
|
78
|
+
|
|
79
|
+
<!-- 1. Import Python Components -->
|
|
80
|
+
<!-- @import { Badge } from ../components/ui -->
|
|
81
|
+
|
|
82
|
+
<div class="flex gap-2 mb-4">
|
|
83
|
+
<Badge variant="default">Tasks: {todos.length}</Badge>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<!-- 2. Reactive loop -->
|
|
87
|
+
<ul>
|
|
88
|
+
<template pp-for="todo in todos">
|
|
89
|
+
<li key="{todo.id}" class="p-2 border-b">{todo.title}</li>
|
|
90
|
+
</template>
|
|
91
|
+
</ul>
|
|
92
|
+
|
|
93
|
+
<script>
|
|
94
|
+
// 3. State initialized by Python backend automatically
|
|
95
|
+
const [todos, setTodos] = pp.state([[todos]]);
|
|
96
|
+
</script>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### 2) Direct async RPC in Python
|
|
100
|
+
|
|
101
|
+
```py
|
|
102
|
+
# actions.py
|
|
103
|
+
|
|
104
|
+
from casp.rpc import rpc
|
|
105
|
+
from src.lib.prisma.db import prisma
|
|
106
|
+
|
|
107
|
+
@rpc(require_auth=True)
|
|
108
|
+
async def like_post(post_id: str):
|
|
109
|
+
# 1. Direct DB access (async)
|
|
110
|
+
post = await prisma.post.update(
|
|
111
|
+
where={"id": post_id},
|
|
112
|
+
data={"likes": {"increment": 1}},
|
|
113
|
+
)
|
|
114
|
+
# 2. Return data directly to frontend
|
|
115
|
+
return post.likes
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### 3) Call RPC from the frontend
|
|
119
|
+
|
|
120
|
+
```html
|
|
121
|
+
<button onclick="likePost()">Like Post</button>
|
|
122
|
+
|
|
123
|
+
<script>
|
|
124
|
+
async function likePost() {
|
|
125
|
+
const newCount = await pp.rpc("like_post", { post_id: "123" });
|
|
126
|
+
setLikes(newCount);
|
|
127
|
+
}
|
|
128
|
+
</script>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## What’s Included
|
|
134
|
+
|
|
135
|
+
Caspian Utils ships with integrations commonly used in Caspian projects:
|
|
136
|
+
|
|
137
|
+
- `fastapi`, `uvicorn`
|
|
138
|
+
- `jinja2` (templating)
|
|
139
|
+
- `beautifulsoup4` (HTML processing)
|
|
140
|
+
- `python-dotenv` (env loading)
|
|
141
|
+
- `slowapi` (rate limiting)
|
|
142
|
+
- `starsessions` (session management)
|
|
143
|
+
- `python-multipart` (uploads)
|
|
144
|
+
- `httpx` (HTTP client)
|
|
145
|
+
- `tailwind-merge` (class merging utility)
|
|
146
|
+
- `werkzeug` (helpers; used in some tooling)
|
|
147
|
+
- ID utilities: `cuid2`, `nanoid`, `python-ulid`
|
|
148
|
+
|
|
149
|
+
(Exact dependencies may vary by version; see `setup.py` in the repository.)
|
|
150
|
+
|
|
151
|
+
---
|
|
152
|
+
|
|
153
|
+
## Packaging Notes
|
|
154
|
+
|
|
155
|
+
If you are publishing to PyPI under `caspian-utils`, ensure your `setup.py` matches:
|
|
156
|
+
|
|
157
|
+
```py
|
|
158
|
+
setup(
|
|
159
|
+
name="caspian-utils",
|
|
160
|
+
# ...
|
|
161
|
+
)
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
---
|
|
165
|
+
|
|
166
|
+
## Repository
|
|
167
|
+
|
|
168
|
+
[Repository](https://github.com/TheSteelNinjaCode/casp)
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## License
|
|
173
|
+
|
|
174
|
+
MIT
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Author
|
|
179
|
+
|
|
180
|
+
Jefferson Abraham
|
|
File without changes
|