@caretcms/cloudflare 0.1.1 → 0.2.0

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 +34 -0
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -30,3 +30,37 @@ export default defineConfig({
30
30
  - `r2UploadsProvider()`
31
31
  - `R2UploadHandler`
32
32
  - `getCloudflareRuntimeEnv()`
33
+
34
+ ## Worker environment / bindings
35
+
36
+ On Cloudflare, values are read from the Worker `env` (via
37
+ `context.locals.runtime.env`), not just `process.env`. Provide these as Worker
38
+ bindings/secrets (`wrangler secret put …` or `[vars]` in `wrangler.toml`):
39
+
40
+ | Binding | Purpose |
41
+ | --- | --- |
42
+ | `CMS_KV` | KV namespace for content storage (name configurable via `binding`). |
43
+ | `CMS_R2` | R2 bucket for uploads (name configurable via `binding`). |
44
+ | `CARET_EDIT_PASSWORD` | Editor login password. Without it the editor stays locked. |
45
+ | `CARET_SESSION_SECRET` | HMAC secret for session cookies. **Required** in production — generate with `openssl rand -base64 32`. |
46
+ | `CARET_DEMO_MODE` | `"true"` to enable the per-visitor demo sandbox. |
47
+
48
+ The auth layer reads `CARET_EDIT_PASSWORD` / `CARET_SESSION_SECRET` from the Worker
49
+ env when they aren't in `process.env`, so a binding-only deployment works.
50
+
51
+ ## Concurrency: single-writer only
52
+
53
+ > **Important.** The KV adapter provides best-effort optimistic concurrency, but
54
+ > it **cannot guarantee** conflict detection across concurrent writers.
55
+
56
+ CaretCMS serializes writes with an in-process lock and detects conflicts with a
57
+ revision counter. On Workers that lock is per-isolate (isolates are numerous and
58
+ ephemeral), and KV has no compare-and-swap and is eventually consistent. So two
59
+ editors saving the same entry — or two saves to different entries in the same
60
+ collection — can read the same revision/index, both pass the check, and the
61
+ later write silently wins (a lost update). A durable fix would require Durable
62
+ Objects (a compare-and-swap coordinator), which this adapter does not use.
63
+
64
+ **Guidance:** treat KV-backed deployments as **single-writer** (one editor at a
65
+ time, or the demo/preview overlay which is per-session and isolated). Don't run
66
+ multi-editor concurrent editorial workflows against the shared KV store.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caretcms/cloudflare",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "type": "module",
5
5
  "description": "Cloudflare-native storage (KV) and uploads (R2) adapters for CaretCMS.",
6
6
  "license": "MIT",
@@ -52,7 +52,7 @@
52
52
  "access": "public"
53
53
  },
54
54
  "peerDependencies": {
55
- "@caretcms/core": "^0.1.1"
55
+ "@caretcms/core": "^0.2.0"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@types/node": "25.6.0",