@vexcms/file-storage-convex 0.0.1 → 0.0.2
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/README.md +70 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# @vexcms/file-storage-convex
|
|
2
|
+
|
|
3
|
+
[Convex](https://convex.dev) file storage adapter for [VEX CMS](https://github.com/vexcms). Integrates Convex's built-in file storage system with VEX media collections.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @vexcms/file-storage-convex
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { defineConfig } from "@vexcms/core"
|
|
15
|
+
import { convexFileStorage } from "@vexcms/file-storage-convex"
|
|
16
|
+
|
|
17
|
+
export default defineConfig({
|
|
18
|
+
media: {
|
|
19
|
+
collections: [media],
|
|
20
|
+
storageAdapter: convexFileStorage(),
|
|
21
|
+
},
|
|
22
|
+
collections: [/* ... */],
|
|
23
|
+
})
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## What It Does
|
|
27
|
+
|
|
28
|
+
`convexFileStorage()` returns a `FileStorageAdapter` that tells VEX CMS to use Convex's native file storage. This affects:
|
|
29
|
+
|
|
30
|
+
- **Schema generation** — Media collection `storageId` fields use `v.id("_storage")` (Convex's typed storage reference) instead of plain strings
|
|
31
|
+
- **Upload flow** — Media uploads go through Convex's presigned URL system
|
|
32
|
+
- **File management** — Delete and URL resolution use Convex's storage APIs
|
|
33
|
+
|
|
34
|
+
## Media Collection Fields
|
|
35
|
+
|
|
36
|
+
When you use a storage adapter, every media collection automatically gets these fields:
|
|
37
|
+
|
|
38
|
+
| Field | Type | Notes |
|
|
39
|
+
|-------|------|-------|
|
|
40
|
+
| `storageId` | `v.id("_storage")` | Convex file storage reference (locked) |
|
|
41
|
+
| `filename` | `v.string()` | Original filename (locked, read-only) |
|
|
42
|
+
| `mimeType` | `v.string()` | MIME type, indexed (locked, read-only) |
|
|
43
|
+
| `size` | `v.number()` | File size in bytes (locked, read-only) |
|
|
44
|
+
| `url` | `v.string()` | Accessible URL (overridable) |
|
|
45
|
+
| `alt` | `v.optional(v.string())` | Alt text (overridable) |
|
|
46
|
+
| `width` | `v.optional(v.number())` | Image width (overridable) |
|
|
47
|
+
| `height` | `v.optional(v.number())` | Image height (overridable) |
|
|
48
|
+
|
|
49
|
+
You can add additional custom fields to media collections alongside these.
|
|
50
|
+
|
|
51
|
+
## Adapter Interface
|
|
52
|
+
|
|
53
|
+
The adapter implements `FileStorageAdapter` from `@vexcms/core`:
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
interface FileStorageAdapter {
|
|
57
|
+
name: string // "convex"
|
|
58
|
+
storageIdValueType: string // 'v.id("_storage")'
|
|
59
|
+
getUploadUrl(): Promise<string> // Presigned upload URL
|
|
60
|
+
getUrl(props: { storageId: string }): Promise<string | null> // Resolve to URL
|
|
61
|
+
deleteFile(props: { storageId: string }): Promise<void> // Delete file
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The runtime methods (`getUploadUrl`, `getUrl`, `deleteFile`) are wired to actual Convex functions by the admin panel at runtime.
|
|
66
|
+
|
|
67
|
+
## Peer Dependencies
|
|
68
|
+
|
|
69
|
+
- `@vexcms/core` — Core VEX CMS types
|
|
70
|
+
- `convex` — Convex backend
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vexcms/file-storage-convex",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
],
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"convex": "^1.31.5",
|
|
18
|
-
"@vexcms/core": "0.0.
|
|
18
|
+
"@vexcms/core": "0.0.2"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|
|
21
21
|
"convex": "^1.31.5",
|
|
22
22
|
"tsup": "^8.5.1",
|
|
23
23
|
"typescript": "^5.9.3",
|
|
24
24
|
"vitest": "^4.0.0",
|
|
25
|
-
"@vexcms/core": "0.0.
|
|
25
|
+
"@vexcms/core": "0.0.2",
|
|
26
26
|
"@vexcms/tsconfig": "0.0.0"
|
|
27
27
|
},
|
|
28
28
|
"publishConfig": {
|