@gusto/create-baerly-storage 0.6.0 → 0.7.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 (37) hide show
  1. package/dist/THIRD-PARTY-LICENSES.txt +204 -0
  2. package/dist/index.js +1537 -145
  3. package/dist/index.js.map +1 -1
  4. package/dist/templates/addons/docker/Dockerfile +13 -11
  5. package/dist/templates/minimal-cloudflare/AGENTS.md +77 -399
  6. package/dist/templates/minimal-cloudflare/README.md +33 -97
  7. package/dist/templates/minimal-cloudflare/package.json +12 -9
  8. package/dist/templates/minimal-cloudflare/pnpm-workspace.yaml +13 -7
  9. package/dist/templates/minimal-cloudflare/tsconfig.app.json +2 -3
  10. package/dist/templates/minimal-cloudflare/tsconfig.worker.json +2 -3
  11. package/dist/templates/minimal-cloudflare/vitest.config.ts +1 -1
  12. package/dist/templates/minimal-cloudflare/wrangler.jsonc +4 -2
  13. package/dist/templates/minimal-node/AGENTS.md +80 -380
  14. package/dist/templates/minimal-node/README.md +37 -135
  15. package/dist/templates/minimal-node/package.json +11 -9
  16. package/dist/templates/minimal-node/pnpm-workspace.yaml +14 -9
  17. package/dist/templates/minimal-node/tsconfig.app.json +2 -3
  18. package/dist/templates/minimal-node/tsconfig.server.json +2 -3
  19. package/dist/templates/react-cloudflare/AGENTS.md +101 -444
  20. package/dist/templates/react-cloudflare/README.md +14 -54
  21. package/dist/templates/react-cloudflare/package.json +18 -15
  22. package/dist/templates/react-cloudflare/pnpm-workspace.yaml +13 -7
  23. package/dist/templates/react-cloudflare/tsconfig.app.json +2 -3
  24. package/dist/templates/react-cloudflare/tsconfig.worker.json +2 -3
  25. package/dist/templates/react-cloudflare/vitest.config.ts +1 -1
  26. package/dist/templates/react-cloudflare/wrangler.jsonc +4 -2
  27. package/dist/templates/react-node/AGENTS.md +108 -474
  28. package/dist/templates/react-node/README.md +35 -125
  29. package/dist/templates/react-node/package.json +16 -14
  30. package/dist/templates/react-node/pnpm-workspace.yaml +14 -9
  31. package/dist/templates/react-node/tsconfig.app.json +2 -3
  32. package/dist/templates/react-node/tsconfig.server.json +2 -3
  33. package/package.json +7 -7
  34. package/dist/templates/minimal-cloudflare/uint8array-base64.d.ts +0 -16
  35. package/dist/templates/minimal-node/uint8array-base64.d.ts +0 -16
  36. package/dist/templates/react-cloudflare/uint8array-base64.d.ts +0 -16
  37. package/dist/templates/react-node/uint8array-base64.d.ts +0 -16
@@ -1,21 +1,12 @@
1
1
  # react-cloudflare
2
2
 
3
- A baerly-storage app scaffolded with `@gusto/create-baerly-storage` for
4
- the **Cloudflare Workers** target, with a React + Vite SPA.
5
- Single-bucket R2-backed deployment via
6
- `@gusto/baerly-storage/cloudflare`. Ships `auth: "none"` so the day-1
7
- happy path works with zero env vars, plus a one-collection `notes`
8
- schema you extend; flip to Cloudflare Access or a shared secret before
9
- deploy — see "Production auth" below.
10
-
11
- **The R2 bucket is the durable state.** The Worker is trusted app code
12
- with an R2 binding; it applies the baerly-storage protocol, but it is
13
- not a database server. No daemon, lock table, scheduler, or idle
14
- database bill; maintenance is automatic and write-triggered.
3
+ A baerly-storage app scaffolded with `@gusto/create-baerly-storage` for the **Cloudflare Workers** target, with a React + Vite SPA. Single-bucket R2-backed deployment via `@gusto/baerly-storage/cloudflare`. Ships `auth: "none"` so the day-1 happy path works with zero env vars, plus a one-collection `notes` schema you extend; flip to Cloudflare Access or a shared secret before deploy — see "Production auth" below.
4
+
5
+ **The R2 bucket is the durable state.** The Worker is trusted app code with an R2 binding; it applies the baerly-storage protocol, but it is not a database server. No daemon, lock table, scheduler, or idle database bill; maintenance is automatic and write-triggered.
15
6
 
16
7
  ## What you got
17
8
 
18
- ```
9
+ ```text
19
10
  react-cloudflare/
20
11
  ├── package.json # one package, all deps
21
12
  ├── tsconfig.json # project-references stub
@@ -45,18 +36,11 @@ pnpm install
45
36
  pnpm dev
46
37
  ```
47
38
 
48
- `pnpm dev` runs Vite. `@cloudflare/vite-plugin` runs the Worker
49
- inside `workerd` next to the SPA dev server, so the SPA and `/v1/*`
50
- share an origin (`http://localhost:5173`). First run downloads the
51
- `workerd` binary.
39
+ `pnpm dev` runs Vite. `@cloudflare/vite-plugin` runs the Worker inside `workerd` next to the SPA dev server, so the SPA and `/v1/*` share an origin (`http://localhost:5173`). First run downloads the `workerd` binary.
52
40
 
53
- Open <http://localhost:5173>. Type a note, hit "Add note." Open a
54
- second tab — inserts, edits, and deletes in one tab appear in the
55
- other over the `/v1/since?collection=notes&cursor=...` long-poll.
41
+ Open <http://localhost:5173>. Type a note, hit "Add note." Open a second tab — inserts, edits, and deletes in one tab appear in the other over the `/v1/since?collection=notes&cursor=...` long-poll.
56
42
 
57
- `pnpm build` runs `tsc -b && vite build`; the SPA lands in
58
- `dist/client/` for the `assets:` binding in `wrangler.jsonc` to
59
- serve on deploy.
43
+ `pnpm build` runs `tsc -b && vite build`; the SPA lands in `dist/client/` for the `assets:` binding in `wrangler.jsonc` to serve on deploy.
60
44
 
61
45
  ## Deploy
62
46
 
@@ -65,15 +49,11 @@ baerly deploy # reads baerly.config.ts:target, runs wran
65
49
  baerly doctor --target=cloudflare # verify bindings, secrets, optional triggers
66
50
  ```
67
51
 
68
- `baerly doctor --target=cloudflare` warns on `auth: "none"` for
69
- deploy targets — see "Production auth" below to flip the posture
70
- before shipping.
52
+ `baerly doctor --target=cloudflare` warns on `auth: "none"` for deploy targets — see "Production auth" below to flip the posture before shipping.
71
53
 
72
54
  ## Extend the schema
73
55
 
74
- Edit `baerly.config.ts`. The `Note` row type is inferred from
75
- `NoteSchema` in the same file — adding a field to the schema
76
- propagates to the UI through `import type { Note }`.
56
+ Edit `baerly.config.ts`. The `Note` row type is inferred from `NoteSchema` in the same file — adding a field to the schema propagates to the UI through `import type { Note }`.
77
57
 
78
58
  ```typescript
79
59
  export const NoteSchema = z.object({
@@ -86,34 +66,14 @@ export const NoteSchema = z.object({
86
66
 
87
67
  ## Production auth
88
68
 
89
- The scaffold ships `auth: "none"` so the day-1 happy path works
90
- with zero env vars; every request resolves to `config.tenant` and
91
- the `NoteSchema` still validates writes server-side. Before deploy,
92
- follow `AGENTS.md` → "Going to production":
93
-
94
- - **Pattern A — CF Access (recommended).** Same artifact in dev and
95
- prod; the factory `verifier:` override engages when
96
- `CF_ACCESS_TEAM_DOMAIN` + `CF_ACCESS_AUDIENCE_TAG` are present in
97
- `wrangler.jsonc:vars`. The `cloudflareAccess()` preset
98
- (re-exported from `@gusto/baerly-storage/auth`) reads the JWT off
99
- `Cf-Access-Jwt-Assertion`, validates it against your team's JWKS,
100
- and pins `tenantPrefix` to `config.tenant` unless you pass an
101
- explicit tenant claim.
102
- - **Pattern B — `auth: "shared-secret"`.** Single-tenant
103
- server-to-server callers. Flip `auth` in `baerly.config.ts`, set
104
- `SHARED_SECRET` via `wrangler secret put`, and re-enable
105
- `baerlyDevAuth` in `vite.config.ts` for browser bearer injection
106
- (the SPA never owns the secret — Vite injects it server-side).
69
+ The scaffold ships `auth: "none"` so the day-1 happy path works with zero env vars; every request resolves to `config.tenant` and the `NoteSchema` still validates writes server-side. Before deploy, follow `AGENTS.md` → "Going to production":
70
+
71
+ - **Pattern A — CF Access (recommended).** Same artifact in dev and prod; the factory `verifier:` override engages when `CF_ACCESS_TEAM_DOMAIN` + `CF_ACCESS_AUDIENCE_TAG` are present in `wrangler.jsonc:vars`. The `cloudflareAccess()` preset (re-exported from `@gusto/baerly-storage/auth`) reads the JWT off `Cf-Access-Jwt-Assertion`, validates it against your team's JWKS, and pins `tenantPrefix` to `config.tenant` unless you pass an explicit tenant claim.
72
+ - **Pattern B — `auth: "shared-secret"`.** Single-tenant server-to-server callers. Flip `auth` in `baerly.config.ts`, set `SHARED_SECRET` via `wrangler secret put`, and re-enable `baerlyDevAuth` in `vite.config.ts` for browser bearer injection (the SPA never owns the secret — Vite injects it server-side).
107
73
 
108
74
  ## When to graduate
109
75
 
110
- baerly-storage is sized for the small-to-medium operating point. Past
111
- ~30 writes/min/collection (throughput estimate), the R2 free-tier
112
- storage cost line (>10 GB/tenant), or the soft fan-out guideline
113
- (~100 collections/tenant — linear cost, nothing enforces it),
114
- graduate to D1 or Postgres via `baerly export --target=postgres`.
115
- Your data was already in your bucket; the export is a mechanical
116
- translator, not a vendor migration.
76
+ baerly-storage is sized for the small-to-medium operating point. Past the per-collection write line (throughput estimate), the R2 free-tier storage cost line, or the soft collections-per-tenant guideline (linear cost, nothing enforces it) — figures in docs/spec/scale-ceilings.md § "The published envelope" in the baerly-storage repo — graduate to D1 or Postgres via `baerly export --target=postgres`. Your data was already in your bucket; the export is a mechanical translator, not a vendor migration.
117
77
 
118
78
  ## Pointers
119
79
 
@@ -13,22 +13,25 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@gusto/baerly-storage": "workspace:*",
16
- "react": "^19.2.7",
17
- "react-dom": "^19.2.7",
18
- "zod": "^4.4.3"
16
+ "react": "^19.3.1",
17
+ "react-dom": "^19.3.1",
18
+ "zod": "^4.6.7"
19
19
  },
20
20
  "devDependencies": {
21
- "@cloudflare/vite-plugin": "^1.42.4",
22
- "@cloudflare/workers-types": "^4.20260630.1",
23
- "@types/node": "^26.0.1",
24
- "@types/react": "^19.2.17",
25
- "@types/react-dom": "^19.2.3",
26
- "@vitejs/plugin-react": "^6.0.3",
27
- "happy-dom": "^20.10.6",
28
- "typescript": "^6.0.3",
29
- "vite": "^8.1.2",
30
- "vitest": "^4.1.9",
31
- "wrangler": "^4.106.0"
21
+ "@cloudflare/vite-plugin": "^1.69.1",
22
+ "@cloudflare/workers-types": "^5.20261116.1",
23
+ "@types/node": "^26.6.6",
24
+ "@types/react": "^19.3.0",
25
+ "@types/react-dom": "^19.3.0",
26
+ "@vitejs/plugin-react": "^6.3.0",
27
+ "happy-dom": "^21.0.4",
28
+ "typescript": "^7.0.2",
29
+ "vite": "^8.3.8",
30
+ "vitest": "^5.1.0",
31
+ "wrangler": "^4.163.0"
32
32
  },
33
- "packageManager": "pnpm@11.1.2"
33
+ "engines": {
34
+ "node": ">=26"
35
+ },
36
+ "packageManager": "pnpm@12.22.0"
34
37
  }
@@ -3,13 +3,19 @@
3
3
  # map, `pnpm install` exits with `ERR_PNPM_IGNORED_BUILDS` for the
4
4
  # Cloudflare-stack deps below.
5
5
  #
6
- # - `esbuild` / `workerd` ship working install scripts we want to run.
7
- # - `sharp` is a transitive miniflare dep whose install script falls
8
- # back to a node-gyp build on Node 24 (no prebuilt for our
9
- # platform/runtime combo). Set to `false` to suppress cleanly —
10
- # sharp still loads from its prebuilt binary at require time, and
11
- # nothing in a scaffolded baerly app exercises its code path.
6
+ # `esbuild` and `workerd` ship working install scripts we want to run.
7
+ # Any other package that gains an install script fails the install
8
+ # until it is listed here.
12
9
  allowBuilds:
13
10
  esbuild: true
14
11
  workerd: true
15
- sharp: false
12
+
13
+ # Supply-chain guardrails, strict by default — loosen one deliberately:
14
+ # - minimumReleaseAge: don't resolve a version until it has been on
15
+ # the registry a day, closing the publish-then-yank window.
16
+ # - trustPolicy: fail if a package's publishing trust (provenance,
17
+ # trusted publisher) drops below what earlier versions had.
18
+ # - blockExoticSubdeps: only direct deps may come from git or tarballs.
19
+ minimumReleaseAge: 1440
20
+ trustPolicy: no-downgrade
21
+ blockExoticSubdeps: true
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES2024",
4
- "lib": ["ES2024", "DOM", "DOM.Iterable"],
4
+ "lib": ["ES2024", "ESNext.TypedArrays", "ESNext.Collection", "DOM"],
5
5
  "module": "ESNext",
6
6
  "moduleResolution": "bundler",
7
7
  "allowImportingTsExtensions": true,
@@ -19,11 +19,10 @@
19
19
  "isolatedModules": true,
20
20
  "erasableSyntaxOnly": true,
21
21
 
22
- "esModuleInterop": true,
23
22
  "skipLibCheck": true,
24
23
  "jsx": "react-jsx",
25
24
  "types": ["vite/client"],
26
25
  "composite": true
27
26
  },
28
- "include": ["src/web/**/*", "uint8array-base64.d.ts", "baerly.config.ts"]
27
+ "include": ["src/web/**/*", "baerly.config.ts"]
29
28
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES2024",
4
- "lib": ["ES2024", "DOM", "DOM.Iterable"],
4
+ "lib": ["ES2024", "ESNext.TypedArrays", "ESNext.Collection", "DOM"],
5
5
  "module": "ESNext",
6
6
  "moduleResolution": "bundler",
7
7
  "allowImportingTsExtensions": true,
@@ -19,10 +19,9 @@
19
19
  "isolatedModules": true,
20
20
  "erasableSyntaxOnly": true,
21
21
 
22
- "esModuleInterop": true,
23
22
  "skipLibCheck": true,
24
23
  "types": ["@cloudflare/workers-types", "node"],
25
24
  "composite": true
26
25
  },
27
- "include": ["src/server/**/*", "uint8array-base64.d.ts", "baerly.config.ts"]
26
+ "include": ["src/server/**/*", "baerly.config.ts"]
28
27
  }
@@ -1,7 +1,7 @@
1
1
  import { defineConfig } from "vitest/config";
2
2
 
3
3
  // Standalone — `vite.config.ts` loads `@cloudflare/vite-plugin`, which
4
- // rejects vitest's pool/environment combo. Add `@cloudflare/vitest-pool-workers`
4
+ // rejects vitest's pool/environment combo. Add `@cloudflare/vitest-plugin`
5
5
  // here if you want Worker-side integration tests.
6
6
  export default defineConfig({
7
7
  test: {
@@ -5,8 +5,10 @@
5
5
  "$schema": "node_modules/wrangler/config-schema.json",
6
6
  "name": "react-cloudflare",
7
7
  "main": "./src/server/index.ts",
8
- "compatibility_date": "2026-05-01",
9
- "compatibility_flags": ["nodejs_compat"],
8
+ "compatibility_date": "2026-10-23",
9
+ // `enable_request_signal` lets `/v1/since` see client disconnects. It is the
10
+ // default from compatibility_date 2026-11-17; drop it when the date moves past that.
11
+ "compatibility_flags": ["nodejs_compat", "enable_request_signal"],
10
12
 
11
13
  "r2_buckets": [
12
14
  {