@vexcms/core 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.
Files changed (2) hide show
  1. package/README.md +155 -0
  2. package/package.json +3 -1
package/README.md ADDED
@@ -0,0 +1,155 @@
1
+ # @vexcms/core
2
+
3
+ The foundational package for [VEX CMS](https://github.com/vexcms) — a headless content management system built for [Convex](https://convex.dev).
4
+
5
+ `@vexcms/core` provides the configuration API, field type system, schema generation, type generation, and all core utilities that power the VEX CMS ecosystem. It has no direct Convex dependency — Convex is a peer dependency only.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pnpm add @vexcms/core
11
+ ```
12
+
13
+ ## Features
14
+
15
+ ### Configuration API
16
+
17
+ Define your CMS structure with a type-safe, declarative API:
18
+
19
+ ```typescript
20
+ import { defineConfig, defineCollection, text, richtext, select } from "@vexcms/core"
21
+
22
+ const posts = defineCollection({
23
+ slug: "posts",
24
+ labels: { singular: "Post", plural: "Posts" },
25
+ fields: {
26
+ title: text({ label: "Title", required: true }),
27
+ content: richtext({ label: "Content" }),
28
+ status: select({
29
+ label: "Status",
30
+ options: [
31
+ { label: "Draft", value: "draft" },
32
+ { label: "Published", value: "published" },
33
+ ],
34
+ defaultValue: "draft",
35
+ }),
36
+ },
37
+ })
38
+
39
+ export default defineConfig({
40
+ collections: [posts],
41
+ admin: { user: "user" },
42
+ basePath: "/admin",
43
+ })
44
+ ```
45
+
46
+ ### Field Types
47
+
48
+ 13 built-in field types with full TypeScript inference:
49
+
50
+ | Field | Description |
51
+ |-------|-------------|
52
+ | `text` | String with optional min/max length |
53
+ | `number` | Numeric with optional min/max/step |
54
+ | `checkbox` | Boolean toggle |
55
+ | `select` | Single or multi-value enum with options |
56
+ | `date` | Date stored as epoch milliseconds |
57
+ | `imageUrl` | URL string for images |
58
+ | `relationship` | Reference to another collection (single or hasMany) |
59
+ | `upload` | Reference to media collection documents (single or hasMany) |
60
+ | `json` | Arbitrary JSON data |
61
+ | `array` | Wraps any field type in an array |
62
+ | `richtext` | Plate/Slate JSON editor documents |
63
+ | `ui` | Non-persisted custom render components |
64
+ | `blocks` | Ordered array of block instances (discriminated union) |
65
+
66
+ ### Blocks System
67
+
68
+ Define reusable content blocks for flexible page building:
69
+
70
+ ```typescript
71
+ import { defineBlock, text, richtext } from "@vexcms/core"
72
+
73
+ const heroBlock = defineBlock({
74
+ slug: "hero",
75
+ label: "Hero Section",
76
+ fields: {
77
+ heading: text({ label: "Heading", required: true }),
78
+ body: richtext({ label: "Body" }),
79
+ },
80
+ })
81
+ ```
82
+
83
+ ### Collections, Globals & Media
84
+
85
+ - **Collections** — Content types with typed fields, versioning/draft workflow, database indexes, search indexes, and admin UI configuration
86
+ - **Globals** — Singleton settings (site config, navigation, etc.) with the same field system
87
+ - **Media Collections** — File storage with auto-injected fields (storageId, filename, mimeType, size, url, alt, width, height)
88
+
89
+ ### Schema & Type Generation
90
+
91
+ Generates Convex schema and TypeScript types from your config:
92
+
93
+ ```typescript
94
+ import { generateVexSchema, generateVexTypes } from "@vexcms/core"
95
+
96
+ const schemaSource = generateVexSchema(config) // → vex.schema.ts
97
+ const typesSource = generateVexTypes(config) // → vex.types.ts
98
+ ```
99
+
100
+ ### Versioning & Drafts
101
+
102
+ Per-collection draft/publish workflow with autosave:
103
+
104
+ ```typescript
105
+ defineCollection({
106
+ slug: "posts",
107
+ versions: {
108
+ drafts: true,
109
+ autosave: { interval: 2000 },
110
+ maxPerDoc: 100,
111
+ },
112
+ // ...
113
+ })
114
+ ```
115
+
116
+ ### Access Control (RBAC)
117
+
118
+ Field-level and collection-level permissions:
119
+
120
+ ```typescript
121
+ import { defineAccess } from "@vexcms/core"
122
+
123
+ const access = defineAccess({
124
+ posts: {
125
+ read: true,
126
+ update: { mode: "allow", fields: ["title", "content"] },
127
+ delete: false,
128
+ },
129
+ })
130
+ ```
131
+
132
+ ### Auto-Migration
133
+
134
+ Schema diffing and migration planning for safe schema changes:
135
+
136
+ ```typescript
137
+ import { diffSchema, planMigration } from "@vexcms/core"
138
+
139
+ const diff = diffSchema(oldSchema, newSchema)
140
+ const ops = planMigration(config, oldSchema, newSchema)
141
+ ```
142
+
143
+ ### Live Preview
144
+
145
+ Per-collection iframe preview with responsive breakpoints and snapshot system.
146
+
147
+ ### Convex Integration Utilities
148
+
149
+ Generic document CRUD operations, query helpers with draft support, and preview snapshot management — all framework-agnostic.
150
+
151
+ ## Peer Dependencies
152
+
153
+ - `convex` — Convex backend
154
+ - `react` — React 18+
155
+ - `@tanstack/react-table` — Table utilities for admin column generation
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vexcms/core",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -23,6 +23,8 @@
23
23
  },
24
24
  "devDependencies": {
25
25
  "@tanstack/react-table": "8.21.3",
26
+ "@types/node": "^20.19.33",
27
+ "@types/react": "^19.2.14",
26
28
  "@vitest/coverage-v8": "^4.0.18",
27
29
  "convex": "^1.31.5",
28
30
  "react": "^19.2.4",