@vibesdotdev/infra-cloudflare 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 (3) hide show
  1. package/README.md +12 -97
  2. package/package.json +11 -12
  3. package/SPEC.md +0 -166
package/README.md CHANGED
@@ -1,107 +1,22 @@
1
1
  # @vibesdotdev/infra-cloudflare
2
2
 
3
- Cloudflare slice of the vibes deployment toolkit. Generates wrangler-shaped
4
- config fragments for Cloudflare Workers, Queues, R2, and KV, and registers a
5
- write-only `secrets/store` backend that pushes secrets to Cloudflare via the
6
- v4 REST API.
3
+ Cloudflare infrastructure adapter for Vibes deployment manifests, workers, routes, and bindings.
7
4
 
8
- See [`SPEC.md`](./SPEC.md) for the contract and
9
- [`PROD-CHECKLIST.md`](./PROD-CHECKLIST.md) for verification status.
5
+ This package is part of the public Vibes framework package set. The source repository is private while the public repository split is being prepared, so package documentation is published on the Vibes docs site.
10
6
 
11
- ## What's in here
7
+ ## Install
12
8
 
13
- - `src/cloudflare.plugin.ts` — `cloudflarePlugin` registers loaders against
14
- `infra/worker`, `infra/queue`, `infra/object-storage`, `infra/cache`, and
15
- `secrets/store` kinds owned by [`infra-core`](../infra-core/SPEC.md) and
16
- [`secrets`](../secrets/SPEC.md).
17
- - `src/implementations/workers.impl.ts` —
18
- `generateCloudflareWorkerConfig` plus the cloud Flow job-consumer
19
- convention (`generateJobConsumerWorkerConfig`,
20
- `JOB_RESULT_STORE_BINDING` / `_CLASS` / `_INITIAL_MIGRATION_TAG`).
21
- - `src/implementations/queues.impl.ts` — Cloudflare Queues producer
22
- bindings.
23
- - `src/implementations/r2.impl.ts` — R2 bucket bindings (preview buckets,
24
- jurisdiction).
25
- - `src/implementations/kv.impl.ts` — KV namespace bindings (preview ids).
26
- - `src/secrets/` — `cloudflareApiDescriptor` + `createCloudflareApiStore`
27
- (push-only `secrets/store`) and the raw v4 client helpers.
28
-
29
- ## Common usage
30
-
31
- Register the plugin alongside `infraPlugin` during runtime bootstrap:
32
-
33
- ```ts
34
- import { createVibesRuntime } from '@vibesdotdev/runtime';
35
- import infraPlugin from '@vibesdotdev/infra-core/plugin';
36
- import cloudflarePlugin from '@vibesdotdev/infra-cloudflare/plugin';
37
-
38
- const runtime = createVibesRuntime({
39
- plugins: [infraPlugin, cloudflarePlugin]
40
- });
9
+ ```sh
10
+ bun add @vibesdotdev/infra-cloudflare
11
+ # or
12
+ npm install @vibesdotdev/infra-cloudflare
41
13
  ```
42
14
 
43
- Generate a worker config from a descriptor:
44
-
45
- ```ts
46
- import { generateCloudflareWorkerConfig } from '@vibesdotdev/infra-cloudflare/implementations/workers';
47
-
48
- const config = generateCloudflareWorkerConfig({
49
- kind: 'infra/worker',
50
- id: 'billing',
51
- name: 'Billing Worker',
52
- adapter: 'cloudflare-workers',
53
- workerName: 'vibes-billing-worker',
54
- main: 'src/worker.ts',
55
- consumers: [{ queue: 'billing-jobs' }],
56
- kvNamespaces: [{ binding: 'CACHE', id: 'abc123' }]
57
- });
58
- ```
59
-
60
- Generate a cloud Flow job-consumer worker (auto-injects the
61
- `JOB_RESULT_STORE` Durable Object binding + initial SQLite migration the
62
- [`workers`](../workers/SPEC.md) rendezvous protocol expects):
63
-
64
- ```ts
65
- import { generateJobConsumerWorkerConfig } from '@vibesdotdev/infra-cloudflare/implementations/workers';
15
+ ## Documentation
66
16
 
67
- const config = generateJobConsumerWorkerConfig({
68
- kind: 'infra/worker',
69
- id: 'flow-consumer',
70
- name: 'Flow Consumer',
71
- adapter: 'cloudflare-workers',
72
- workerName: 'vibes-flow-consumer',
73
- main: 'src/worker.ts',
74
- consumers: [{ queue: 'flow-jobs' }]
75
- });
76
- ```
77
-
78
- Push secrets via the Cloudflare API backend (requires
79
- `CLOUDFLARE_API_TOKEN` and `CLOUDFLARE_ACCOUNT_ID` in the environment):
80
-
81
- ```ts
82
- import { createCloudflareApiStore } from '@vibesdotdev/infra-cloudflare';
83
-
84
- const store = createCloudflareApiStore();
85
- await store.impl.setAll('production', {
86
- STRIPE_SECRET_KEY: '...',
87
- RESEND_API_KEY: '...'
88
- });
89
- ```
90
-
91
- ## Verification
92
-
93
- ```bash
94
- cd packages/infra-cloudflare
95
- bun test
96
- bun --bun tsc -p tsconfig.json --noEmit
97
- ```
17
+ - Package guide: https://docs.vibes.dev/packages/infra-cloudflare
18
+ - Vibes docs: https://docs.vibes.dev
98
19
 
99
- ## Links
20
+ ## License
100
21
 
101
- - [SPEC.md](./SPEC.md)
102
- - [PROD-CHECKLIST.md](./PROD-CHECKLIST.md)
103
- - [`infra-core`](../infra-core/SPEC.md)
104
- - [`infra-doks`](../infra-doks/SPEC.md)
105
- - [`secrets`](../secrets/SPEC.md)
106
- - [`workers`](../workers/SPEC.md)
107
- - [`deploy`](../deploy/SPEC.md)
22
+ MIT
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibesdotdev/infra-cloudflare",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -104,17 +104,12 @@
104
104
  "registry": "https://registry.npmjs.org",
105
105
  "access": "public"
106
106
  },
107
- "repository": {
108
- "type": "git",
109
- "url": "git+https://github.com/vibesdotdev/monorepo.git",
110
- "directory": "packages/infra-cloudflare"
111
- },
112
107
  "dependencies": {
113
- "@vibesdotdev/config": "0.0.1",
114
- "@vibesdotdev/infra-core": "0.0.1",
115
- "@vibesdotdev/runtime": "0.0.1",
116
- "@vibesdotdev/secrets": "0.0.1",
117
- "@vibesdotdev/connector-cloudflare": "0.0.1",
108
+ "@vibesdotdev/config": "0.0.2",
109
+ "@vibesdotdev/infra-core": "0.0.2",
110
+ "@vibesdotdev/runtime": "0.0.2",
111
+ "@vibesdotdev/secrets": "0.0.2",
112
+ "@vibesdotdev/connector-cloudflare": "0.0.2",
118
113
  "zod": "^4.3.6"
119
114
  },
120
115
  "scripts": {
@@ -128,7 +123,6 @@
128
123
  "src",
129
124
  "bin",
130
125
  "README.md",
131
- "SPEC.md",
132
126
  "LICENSE",
133
127
  "!src/**/__tests__/**",
134
128
  "!src/**/__stubs__/**",
@@ -149,5 +143,10 @@
149
143
  ],
150
144
  "vibes": {
151
145
  "visibility": "public-framework"
146
+ },
147
+ "description": "Cloudflare infrastructure adapter for Vibes deployment manifests, workers, routes, and bindings.",
148
+ "homepage": "https://docs.vibes.dev/packages/infra-cloudflare",
149
+ "bugs": {
150
+ "url": "https://docs.vibes.dev/packages/infra-cloudflare#support"
152
151
  }
153
152
  }
package/SPEC.md DELETED
@@ -1,166 +0,0 @@
1
- # @vibesdotdev/infra-cloudflare
2
-
3
- Cloudflare adapter for [`infra-core`](../infra-core/SPEC.md) kinds. Provides the
4
- Cloudflare slice of the vibes deployment toolkit: generates wrangler-shaped
5
- config fragments for Cloudflare Workers, Queues, R2, and KV, and registers a
6
- write-only `secrets/store` backend that pushes secrets to Cloudflare Pages
7
- projects and Workers scripts via the v4 REST API. Consumed by per-app
8
- `deployment.config.ts` files (and `infra/manifest.ts` / `infra/generate.ts`)
9
- inside this monorepo, and intended to be consumed by end-user vibes projects
10
- that target Cloudflare. Pairs with [`infra-doks`](../infra-doks/SPEC.md) on the
11
- DigitalOcean side.
12
-
13
- ## Owns
14
-
15
- - **Plugin descriptors registered by the plugin:** `cloudflarePlugin`
16
- (id `infra-cloudflare`, depends on `infra`) registers loaders for:
17
- - `infra/worker` → `cloudflare-workers`
18
- - `infra/queue` → `cloudflare-queues`
19
- - `infra/object-storage` → `cloudflare-r2`
20
- - `infra/cache` → `cloudflare-kv`
21
- - `secrets/store` → `cloudflare-api` (priority 20)
22
- - **Worker config generator** (`./implementations/workers`):
23
- `generateCloudflareWorkerConfig` plus the cloud Flow job-consumer
24
- convention (`generateJobConsumerWorkerConfig`,
25
- `JOB_RESULT_STORE_BINDING` / `_CLASS` / `_INITIAL_MIGRATION_TAG`). Emits a
26
- wrangler-shaped object: `name`, `main`, compatibility, `vars`, `queues`,
27
- `kv_namespaces`, `r2_buckets`, `durable_objects`, `migrations`, optional
28
- smart placement.
29
- - **Web-app wrangler.jsonc generator** (`./implementations/web-app`):
30
- `createCloudflareWebAppDeployment({ ... }).generateWranglerConfig()` is the
31
- authoritative emitter for SvelteKit/SSR apps. Supports every wrangler key
32
- currently in use across the repo: `name`, `main`, `compatibility_date`,
33
- `compatibility_flags`, `assets`, `routes`, `vars`, `secrets_store_secrets`,
34
- `secrets.required`, `d1_databases`, `r2_buckets`, `services`,
35
- `observability`, `triggers`, `queues`, `durable_objects`, `migrations`,
36
- `send_email`, `workers_dev`, `preview_urls`. `apps/<name>/wrangler.jsonc`
37
- is a build artifact regenerated from `deployment.config.ts` by
38
- `vibes infra deploy regenerate` (the sole supported path).
39
- CI drift is enforced via the CLI `--check`. To adopt: express the surface in
40
- `deployment.config.ts`, run `vibes infra deploy regenerate --adopt --path <dir>`.
41
- - **Queue producer config generator** (`./implementations/queues`):
42
- `generateCloudflareQueueConfig` for `infra/queue` when
43
- `engine === 'cloudflare-queues'`.
44
- - **R2 bucket config generator** (`./implementations/r2`):
45
- `generateCloudflareR2Config` for `infra/object-storage` when
46
- `adapter === 'cloudflare-r2'`. Supports preview buckets and jurisdiction.
47
- - **KV namespace config generator** (`./implementations/kv`):
48
- `generateCloudflareKVConfig` for `infra/cache` when
49
- `engine === 'cloudflare-kv'`. Supports preview namespaces.
50
- - **Cloudflare API secrets backend** (`./src/secrets/`):
51
- `cloudflareApiDescriptor` + `createCloudflareApiStore` register a
52
- push-only `secrets/store` against CF Pages project `env_vars` and Worker
53
- script `secrets`, plus the raw client helpers (`listPagesSecrets`,
54
- `setPagesSecrets`, `listWorkerSecrets`, `setWorkerSecrets`).
55
-
56
- ## Does not own
57
-
58
- - The kind contracts themselves (descriptor schema shapes for `infra/*` and
59
- `secrets/store`) → [`infra-core`](../infra-core/SPEC.md) and
60
- [`secrets`](../secrets/SPEC.md). This package only registers
61
- implementations against those kinds.
62
- - DigitalOcean / DOKS / Spaces / Managed DB equivalents →
63
- [`infra-doks`](../infra-doks/SPEC.md).
64
- - Deployment orchestration, manifest generation, env materialization →
65
- [`deploy`](../deploy/SPEC.md). Per-app `deployment.config.ts` lives in
66
- the consuming app.
67
- - Local / encrypted / env-file secret backends →
68
- [`secrets`](../secrets/SPEC.md).
69
-
70
- ## Hard rules
71
-
72
- - This package implements adapters; it never declares new runtime kinds.
73
- New kinds belong in [`infra-core`](../infra-core/SPEC.md).
74
- - Pure TypeScript and global `fetch`. No Node-only APIs, no filesystem, no
75
- `wrangler` CLI dependency. Generators return plain objects callers can
76
- serialize to wrangler.jsonc.
77
- - The `cloudflare-api` secrets store is push-only. `get` / `getAll` always
78
- return empty/undefined and `unset` is a no-op (Cloudflare does not return
79
- secret values or expose per-key delete). Callers that round-trip through
80
- `get` are broken; reads must come from a different backend.
81
- - `cloudflareApiDescriptor.tiers` is `['staging', 'production']` and
82
- `priority` is `20`. Local backends in
83
- [`secrets`](../secrets/SPEC.md) must out-prioritize this for `local` /
84
- `dev` tiers, or local development will attempt to push to Cloudflare.
85
- - `getClientConfig` throws when `CLOUDFLARE_API_TOKEN` or
86
- `CLOUDFLARE_ACCOUNT_ID` (or the descriptor-overridden env var names) are
87
- unset. Bootstrapping a CF push without those env vars is a hard failure,
88
- not a silent skip.
89
- - `JOB_RESULT_STORE_BINDING` / `JOB_RESULT_STORE_CLASS` /
90
- `JOB_RESULT_STORE_INITIAL_MIGRATION_TAG` are the contract for cloud Flow
91
- job-consumer workers. Consumers must use
92
- `generateJobConsumerWorkerConfig` (or replicate the binding name and
93
- initial-migration tag verbatim) — the [`workers`](../workers/SPEC.md)
94
- cloud rendezvous protocol expects this exact shape.
95
- - New CF Durable Object classes must register via `newSqliteClasses` in
96
- their initial migration. Plain `newClasses` is the legacy non-SQLite form
97
- and is rejected by Cloudflare for accounts created after 2024-04-01.
98
-
99
- ## Migration debt (completed)
100
-
101
- - [x] **Pages surface is missing.** 19 consumers (15
102
- `apps/*/deployment.config.ts`, plus `infra/manifest.ts` and
103
- `infra/generate.ts`) import `createCloudflarePagesDeployment` and
104
- `renderWranglerJson` from `@vibesdotdev/infra-cloudflare/pages`. ~~The
105
- `./pages` subpath is not declared in `package.json#exports`, no
106
- `src/pages.ts` / `src/implementations/pages.impl.ts` files exist, and
107
- there is no Pages-typed loader registered by the plugin. Restore the
108
- Pages module (`pages` helpers, `implementations/pages.impl.ts`, plugin
109
- registration for whichever kind it targets) and re-add the
110
- `./pages` + `./implementations/pages` exports.~~
111
- **Resolution:** Created `src/implementations/pages.impl.ts` with
112
- `createCloudflarePagesDeployment`, `renderWranglerJson`, and
113
- `generateCloudflarePagesDescriptor`. Created `src/pages.ts` as public
114
- entrypoint. Added `./pages` and `./implementations/pages` to
115
- `package.json#exports`. Registered `cloudflare-pages` loader for
116
- `infra/web-app` kind in plugin.
117
- - [x] `src/secrets/cloudflare-api.impl.ts` uses
118
- `require('@vibesdotdev/runtime')` inside `getCFProjectNames()` to dodge
119
- a circular dependency. ~~Replace with a constructor-injected runtime
120
- handle or a registered query callback so the file is ESM-clean.~~
121
- **Resolution:** Replaced `require()` hack with a
122
- `CFProjectNamesResolver` function type injected via constructor.
123
- Plugin passes a resolver that queries `runtime.assets('infra/web-app')`
124
- through the runtime handle. The implementation is now ESM-clean with
125
- no dynamic requires.
126
- - [x] `getCFProjectNames()` derives Cloudflare project names from
127
- `infra/web-app` descriptors using a hardcoded `vibes-{appId}` pattern.
128
- ~~Move project-name resolution onto the descriptor (e.g. an explicit
129
- `cfProjectName` field on `infra/web-app`) or codify the convention in
130
- `infra-core`.~~ **Resolution:** Added optional `cfProjectName` field to
131
- `WebAppDescriptorSchema` in `infra-core/src/kinds/web-app.kind.ts`.
132
- The secrets backend now prefers `descriptor.cfProjectName` when
133
- available, falling back to the `vibes-{appId}` convention for
134
- backward compatibility.
135
- - [x] `cloudflareApiDescriptor` lives in `./src/secrets/` but is reachable
136
- only via the package root. ~~Add a `./secrets` subpath in
137
- `package.json#exports` so end users can import the descriptor + helper
138
- client without pulling everything.~~ **Resolution:** Added
139
- `"./secrets": "./src/secrets/index.ts"` to `package.json#exports`.
140
-
141
- ## Public entrypoints
142
-
143
- `.`, `./pages`, `./implementations/workers`, `./implementations/queues`,
144
- `./implementations/r2`, `./implementations/kv`, `./implementations/pages`,
145
- `./plugin`, `./secrets`.
146
-
147
- The root export re-exports every `implementations/*` module plus
148
- `./secrets/index` and `cloudflarePlugin`.
149
-
150
- ## Verification
151
-
152
- `bun test` from `packages/infra-cloudflare`. Covers descriptor parse +
153
- generated-config shape for workers, queues, r2, kv
154
- (`__tests__/{workers,queues,r2,kv}.test.ts`) plus plugin metadata and
155
- per-impl creation (`__tests__/plugin.test.ts`, 6 cases). Does not cover
156
- the `cloudflare-api` secrets backend — there is no
157
- `__tests__/secrets.test.ts`, and the v4 REST calls are not exercised in
158
- CI. `bun --bun tsc -p tsconfig.json --noEmit` is the type gate.
159
-
160
- ## Links
161
-
162
- - [infra-core/SPEC.md](../infra-core/SPEC.md)
163
- - [infra-doks/SPEC.md](../infra-doks/SPEC.md)
164
- - [deploy/SPEC.md](../deploy/SPEC.md)
165
- - [secrets/SPEC.md](../secrets/SPEC.md)
166
- - [workers/SPEC.md](../workers/SPEC.md)