caspian-utils 0.0.21 → 0.0.22
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
CHANGED
|
@@ -236,9 +236,10 @@ Use this pattern for real file managers:
|
|
|
236
236
|
|
|
237
237
|
- Keep upload and delete actions in the owning route `index.py`, not in `main.py`.
|
|
238
238
|
- Use `page()` to render the initial manager payload.
|
|
239
|
-
- Store durable metadata in Prisma and store the browser-accessible blob separately under `public/
|
|
239
|
+
- Store durable metadata in Prisma and store the browser-accessible blob separately under a public upload directory such as `public/uploads/`.
|
|
240
|
+
- Create `public/uploads` on demand in the shared helper if the directory does not exist yet.
|
|
240
241
|
- Use `pp.state(...)` plus `pp-for` for the list UI instead of manual `innerHTML` writes.
|
|
241
|
-
- Add
|
|
242
|
+
- Add the public-root-relative directory name `uploads` to `PUBLIC_IGNORE_DIRS` in `settings/bs-config.ts` when `public/uploads/` is the active upload root so runtime uploads do not trigger BrowserSync reloads during `npm run dev`.
|
|
242
243
|
|
|
243
244
|
Read [file-uploads.md](./file-uploads.md) for the complete file-manager pattern.
|
|
244
245
|
|
|
@@ -23,7 +23,8 @@ Treat uploads as normal route behavior. Keep the owning browser UI in the route
|
|
|
23
23
|
- Keep first-render file manager data in `page()` so the initial HTML already contains the current asset list and storage summary.
|
|
24
24
|
- Keep upload and delete actions in the route's `index.py`; do not move ordinary upload flows into `main.py`.
|
|
25
25
|
- Keep reusable file-manager helpers in `src/lib/`.
|
|
26
|
-
- Store uploaded blobs under a project-owned public directory such as `public/
|
|
26
|
+
- Store uploaded blobs under a project-owned public directory such as `public/uploads/...` when the files should be browser-accessible.
|
|
27
|
+
- Create the upload directory on demand in the shared helper when it does not exist yet; do not assume the folder is committed.
|
|
27
28
|
- Store durable metadata in Prisma, not in JSON manifests or ad hoc metadata files.
|
|
28
29
|
- Use `pp.state(...)` plus `pp-for` to render and update the file list from returned server payloads.
|
|
29
30
|
- Use `onUploadProgress` only for progress UI; let the RPC return refreshed manager data for the authoritative post-upload state.
|
|
@@ -36,7 +37,7 @@ Treat uploads as normal route behavior. Keep the owning browser UI in the route
|
|
|
36
37
|
| Upload and delete `@rpc()` actions | `src/app/**/index.py` | Keep these route-local so they stay close to the owning page. |
|
|
37
38
|
| Shared storage, normalization, and persistence helpers | `src/lib/**` | Reuse helpers across routes without pushing route behavior into app bootstrap. |
|
|
38
39
|
| Upload metadata model | `prisma/schema.prisma` | Persist owner, file name, MIME type, path, size, collection, and timestamps in Prisma. |
|
|
39
|
-
| Browser-accessible uploaded blobs | `public/
|
|
40
|
+
| Browser-accessible uploaded blobs | `public/uploads/**` or another app-owned public directory | Keep the public path predictable and derived from stored metadata, and create the directory on demand if it may not exist yet. |
|
|
40
41
|
| BrowserSync upload ignore | `settings/bs-config.ts` | Keep the active public upload directory in `PUBLIC_IGNORE_DIRS`. |
|
|
41
42
|
|
|
42
43
|
## Route Flow
|
|
@@ -143,15 +144,17 @@ Typical metadata fields include:
|
|
|
143
144
|
|
|
144
145
|
## BrowserSync And Uploaded Public Files
|
|
145
146
|
|
|
146
|
-
If runtime uploads write into `public/
|
|
147
|
+
If runtime uploads write into `public/uploads/`, BrowserSync should ignore that directory during local development. Otherwise every upload can trigger a full browser reload.
|
|
147
148
|
|
|
148
|
-
|
|
149
|
+
The helper that stores uploaded files should create `public/uploads` before writing the first file when the directory is not present yet.
|
|
150
|
+
|
|
151
|
+
Use a public-root-relative ignore entry in `settings/bs-config.ts`:
|
|
149
152
|
|
|
150
153
|
```ts
|
|
151
|
-
const PUBLIC_IGNORE_DIRS = ["
|
|
154
|
+
const PUBLIC_IGNORE_DIRS = ["uploads"];
|
|
152
155
|
```
|
|
153
156
|
|
|
154
|
-
|
|
157
|
+
`settings/bs-config.ts` matches those entries against paths relative to the `public/` root, so nested uploads such as `uploads/user-1/media/example.png` are ignored too.
|
|
155
158
|
|
|
156
159
|
## What To Avoid
|
|
157
160
|
|
|
@@ -167,5 +170,5 @@ Match those entries against workspace-relative paths so nested uploads such as `
|
|
|
167
170
|
- Use `fetch-data.md` for the route-render versus RPC split.
|
|
168
171
|
- Use `database.md` when Prisma models or relations must change for upload metadata.
|
|
169
172
|
- Use `validation.md` for MIME, extension, and other boundary checks, then keep explicit size and auth checks in the owning RPC action.
|
|
170
|
-
- Use `project-structure.md` for placement rules, especially `src/app/` versus `src/lib/` and `public/
|
|
173
|
+
- Use `project-structure.md` for placement rules, especially `src/app/` versus `src/lib/` and `public/uploads/`.
|
|
171
174
|
- Use `commands.md` and `settings/bs-config.ts` when uploads should not trigger BrowserSync reloads during `npm run dev`.
|
|
@@ -172,7 +172,9 @@ This folder contains your database model definitions in `schema.prisma` and any
|
|
|
172
172
|
|
|
173
173
|
Store static assets here, including images, fonts, and generated frontend assets that should be served directly.
|
|
174
174
|
|
|
175
|
-
Runtime-uploaded public blobs can also live here. Confirm the actual upload path in the project code and keep that directory aligned with any BrowserSync ignore rules.
|
|
175
|
+
Runtime-uploaded public blobs can also live here. Confirm the actual upload path in the project code, commonly `public/uploads/`, and keep that directory aligned with any BrowserSync ignore rules.
|
|
176
|
+
|
|
177
|
+
If the upload directory is created only at runtime, create it on demand in the owning upload helper instead of assuming it is already committed.
|
|
176
178
|
|
|
177
179
|
If the local BrowserSync stack is running, keep that upload directory in `settings/bs-config.ts` `PUBLIC_IGNORE_DIRS` so new uploads do not force a full browser reload.
|
|
178
180
|
|
|
@@ -205,7 +207,9 @@ Read the actual values in `caspian.config.json` instead of inferring feature sta
|
|
|
205
207
|
|
|
206
208
|
The BrowserSync watcher configuration for the local stack lives here.
|
|
207
209
|
|
|
208
|
-
When runtime uploads write into `public/
|
|
210
|
+
When runtime uploads write into `public/uploads/`, keep the public-root-relative entry `uploads` in `PUBLIC_IGNORE_DIRS`.
|
|
211
|
+
|
|
212
|
+
`settings/bs-config.ts` matches ignore entries against paths relative to the `public/` root, so nested uploaded files do not trigger reloads.
|
|
209
213
|
|
|
210
214
|
### `src/lib/auth/auth_config.py`
|
|
211
215
|
|