@volter/twin-cloudflare 0.1.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 (58) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +223 -0
  3. package/dist/r2/src/endpoint.d.ts +14 -0
  4. package/dist/r2/src/endpoint.js +30 -0
  5. package/dist/r2/src/fetch.d.ts +7 -0
  6. package/dist/r2/src/fetch.js +230 -0
  7. package/dist/r2/src/generated/surface.gen.json +1 -0
  8. package/dist/r2/src/manifest.d.ts +22 -0
  9. package/dist/r2/src/manifest.js +69 -0
  10. package/dist/r2/src/semantics/buckets.d.ts +18 -0
  11. package/dist/r2/src/semantics/buckets.js +145 -0
  12. package/dist/r2/src/semantics/objects.d.ts +8 -0
  13. package/dist/r2/src/semantics/objects.js +252 -0
  14. package/dist/r2/src/wire.d.ts +54 -0
  15. package/dist/r2/src/wire.js +120 -0
  16. package/dist/src/cli.d.ts +2 -0
  17. package/dist/src/cli.js +26 -0
  18. package/dist/src/cloudflare-budget.d.ts +22 -0
  19. package/dist/src/cloudflare-budget.js +40 -0
  20. package/dist/src/cloudflare-capabilities.d.ts +6 -0
  21. package/dist/src/cloudflare-capabilities.js +1161 -0
  22. package/dist/src/cloudflare-common.d.ts +59 -0
  23. package/dist/src/cloudflare-common.js +142 -0
  24. package/dist/src/cloudflare-conformance.d.ts +6 -0
  25. package/dist/src/cloudflare-conformance.js +251 -0
  26. package/dist/src/cloudflare-connector.d.ts +53 -0
  27. package/dist/src/cloudflare-connector.js +418 -0
  28. package/dist/src/cloudflare-openapi-operations.d.ts +10 -0
  29. package/dist/src/cloudflare-openapi-operations.js +3336 -0
  30. package/dist/src/cloudflare-provisioning.d.ts +5 -0
  31. package/dist/src/cloudflare-provisioning.js +2097 -0
  32. package/dist/src/cloudflare-r2.d.ts +121 -0
  33. package/dist/src/cloudflare-r2.js +138 -0
  34. package/dist/src/cloudflare-server.d.ts +17 -0
  35. package/dist/src/cloudflare-server.js +101 -0
  36. package/dist/src/cloudflare-twin.d.ts +14 -0
  37. package/dist/src/cloudflare-twin.js +762 -0
  38. package/dist/src/cloudflare-worker-assets.d.ts +25 -0
  39. package/dist/src/cloudflare-worker-assets.js +192 -0
  40. package/dist/src/index.d.ts +9 -0
  41. package/dist/src/index.js +69 -0
  42. package/dist/src/screens/dashboard.d.ts +3 -0
  43. package/dist/src/screens/dashboard.js +265 -0
  44. package/package.json +56 -0
  45. package/src/cli.ts +25 -0
  46. package/src/cloudflare-budget.ts +61 -0
  47. package/src/cloudflare-capabilities.ts +1107 -0
  48. package/src/cloudflare-common.ts +183 -0
  49. package/src/cloudflare-conformance.ts +204 -0
  50. package/src/cloudflare-connector.ts +443 -0
  51. package/src/cloudflare-openapi-operations.ts +3344 -0
  52. package/src/cloudflare-provisioning.ts +1969 -0
  53. package/src/cloudflare-r2.ts +173 -0
  54. package/src/cloudflare-server.ts +109 -0
  55. package/src/cloudflare-twin.ts +714 -0
  56. package/src/cloudflare-worker-assets.ts +207 -0
  57. package/src/index.ts +112 -0
  58. package/src/screens/dashboard.tsx +297 -0
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,223 @@
1
+ # @volter/twin-cloudflare
2
+
3
+ Local, deterministic Cloudflare API v4 **control-plane** twin for generic account/zone discovery,
4
+ remotely managed Cloudflare Tunnel provisioning, tunnel configuration/token retrieval, a bounded
5
+ zone DNS-record control-plane slice, and the **Workers provisioning plane** a wrangler-shaped or
6
+ raw-API deploy script drives: Worker script upload (metadata + bindings recorded, content
7
+ fingerprinted, never executed), static-assets upload sessions (hashes and sizes recorded, bytes
8
+ never kept), versions and deployments, script settings, cron triggers, workers.dev subdomains,
9
+ zone routes, custom domains, Durable Object namespace records, R2 bucket control plane,
10
+ Hyperdrive configuration records, and Queues with consumers. An unmodified `wrangler deploy` —
11
+ first deploy and redeploy — completes against it. State is persisted through the shared `@volter/world-core` kernel.
12
+ The pack never opens a real tunnel, publishes DNS, executes a Worker, stores an object, dials an
13
+ origin, contacts Cloudflare, or embeds an application-specific workflow.
14
+
15
+ ```bash
16
+ bun packages/twin/cloudflare/src/cli.ts serve
17
+ ```
18
+
19
+ Point the official `cloudflare` TypeScript SDK at the printed loopback URL with any non-empty local
20
+ token and `maxRetries: 0`. The integration test uses the SDK unchanged; only its public `baseURL`
21
+ option is set.
22
+
23
+ ## Modeled surface
24
+
25
+ Cloudflare accounts and zones normally pre-exist the workflow under certification. Seed them using
26
+ the disclosed twin-only endpoint:
27
+
28
+ ```http
29
+ POST /twin/bootstrap
30
+ Authorization: Bearer local
31
+ Content-Type: application/json
32
+
33
+ {
34
+ "accounts": [{ "id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "name": "Acme" }],
35
+ "zones": [{ "id": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", "account_id": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "name": "example.test" }]
36
+ }
37
+ ```
38
+
39
+ The vendor-shaped endpoints are:
40
+
41
+ - accounts: list/get;
42
+ - zones: list/get, including `name` and `account.id` filters;
43
+ - `/accounts/{account_id}/cfd_tunnel`: list/create/get/edit/delete;
44
+ - tunnel configuration: get plus a locally useful put slice and tunnel token retrieval. The
45
+ official PUT includes broad nested `originRequest` schemas that are not fully validated here,
46
+ so that whole OpenAPI operation remains a manifest todo;
47
+ - `/zones/{zone_id}/dns_records`: list/get/delete plus locally useful create/put/patch support for
48
+ CNAME, address, text, and structured CAA-shaped certification records. Because Cloudflare's three
49
+ write operations are discriminated unions spanning many more record schemas, those whole OpenAPI
50
+ operations remain manifest todos; the pack does not claim complete union fidelity;
51
+ - **Workers scripts**: `/accounts/{account_id}/workers/scripts` list, script download, delete
52
+ (honoring the pinned OpenAPI `force` contract: without `force=true` a delete is stopped by
53
+ associated Durable Object namespaces or service bindings), plus the `PUT` module upload itself.
54
+ The upload accepts all three wire forms an unmodified client actually produces: raw
55
+ multipart/form-data with a JSON `metadata` part (wrangler / raw API), the official SDK's
56
+ FormData serialization (bracket-notation `metadata[...]` parts under the operation's
57
+ `application/javascript` content type — measured against `cloudflare@7.1.0`), and a raw
58
+ service-worker-syntax script body. Module content is recorded and SHA-256-fingerprinted into
59
+ the `etag`, never executed, parsed, or run. Because the full multipart metadata union (38
60
+ binding kinds, assets, placement, limits, observability) is far broader than the implemented
61
+ deploy slice, the whole `PUT` operation honestly remains a manifest todo (the same rule as the
62
+ DNS write unions) even though every worker-seeding verify drives it. The implemented binding
63
+ slice validates the closed binding-kind union and the deploy-critical kinds
64
+ (`plain_text`/`secret_text`/`json`/`kv_namespace`/`service`/`r2_bucket`/`queue`/`hyperdrive`/
65
+ `durable_object_namespace`), including referential checks against this twin's own R2 buckets,
66
+ queues, and Hyperdrive configs; other known kinds are recorded as configuration without deep
67
+ validation. Durable Object `migrations` (new/new_sqlite/deleted/renamed classes, old/new tag
68
+ matching, multi-step `steps`) materialize namespace records; `transferred_classes` fails loudly
69
+ as unmodeled;
70
+ - **what `wrangler deploy` drives around the upload**:
71
+ `GET /accounts/{account_id}/workers/services/{service_name}` — the Worker-as-service view
72
+ wrangler reads first (`default_environment.script.{tag,tags,migration_tag,last_deployed_from}`),
73
+ answering `10007` for a Worker that does not exist yet. That path is **not in the pinned
74
+ OpenAPI**, so it is served but carries no manifest capability; its shape is grounded in what
75
+ Cloudflare's own client (wrangler's deploy helpers) reads from it. `last_deployed_from` is
76
+ `wrangler` when the upload's User-Agent is wrangler's, `api` otherwise. A missing account
77
+ workers.dev subdomain answers `10007`, the code wrangler's register-or-fail branch keys on — so
78
+ a deploy that wants `workers.dev` needs the account subdomain registered first (`PUT
79
+ /accounts/{account_id}/workers/subdomain`), exactly as on a real account;
80
+ - **static assets**: `POST …/scripts/{script_name}/assets-upload-session` answers `{jwt, buckets}`
81
+ naming only the hashes the account does not already hold (at most 10 per bucket — a twin
82
+ convention; the spec does not pin the partition); `POST …/workers/assets/upload?base64=true`,
83
+ authenticated by that session token rather than the API token, checks each part's decoded
84
+ size against the manifest, records the asset's hash, size and content type — **never its
85
+ bytes**, since no vendor read endpoint returns them — and returns the completion token once
86
+ every hash is held. The manifest hash is wrangler's blake3 over base64 content plus extension;
87
+ the twin does not recompute blake3 and trusts the declared hash. The script upload redeems
88
+ `metadata.assets.jwt` (issued for this account and Worker, every hash uploaded), records the
89
+ manifest and the assets config (`run_worker_first`, `html_handling`, …) as configuration,
90
+ honours `keep_assets`, and refuses an `assets` binding with no assets. The single-file
91
+ Edge-KV upload path (`…/assets/upload/{hash}`) is not served: the twin's tokens never enable it;
92
+ - **versions and deployments**: every script `PUT` is a new version deployed at 100% and answers
93
+ `deployment_id` (the version id wrangler prints as "Current Version ID"). A redeploy with no
94
+ pending migration takes wrangler's versions path: `POST …/versions` uploads a version without
95
+ deploying it (Durable Object migrations refused — Cloudflare migrates only on deploy; `inherit`
96
+ bindings resolved from the deployed version, refused under `bindings_inherit=strict` when there
97
+ is nothing to inherit), `POST …/deployments` records a one- or two-version percentage split and
98
+ makes the larger share the live content (the split is recorded, never routed), and
99
+ `PATCH …/script-settings` records logpush, tags, tail consumers and observability. `GET
100
+ …/deployments`, `GET …/versions` and `…/versions/{version_id}`, `GET …/settings` (the deployed
101
+ bindings and runtime), `GET …/script-settings`, and `GET …/secrets` / `…/secrets/{secret_name}`
102
+ read it back; secret values are write-only and never echoed. `POST …/versions` carries the same
103
+ multipart metadata union as the script `PUT` and stays a manifest todo for the same reason;
104
+ `worker_loader` bindings are recorded as configuration like the other non-deploy-critical kinds;
105
+ - **cron triggers / subdomains / routes / domains**: script `schedules` get/put (5-field cron
106
+ validation), per-script workers.dev subdomain get/post/delete, the account-level Workers
107
+ subdomain get/put/delete (204), zone `workers/routes` CRUD, and `workers/domains`
108
+ attach/list/get/detach — domain attach resolves the hostname against this twin's zones and
109
+ requires the referenced Worker to exist, composing with the existing zone and DNS slices;
110
+ - **Durable Object namespaces**: `/accounts/{account_id}/workers/durable_objects/namespaces`
111
+ list, populated exclusively by script-upload migrations (Cloudflare has no direct
112
+ namespace-create endpoint);
113
+ - **R2 buckets** (control plane ONLY): create/list/get/delete with the vendor's documented name
114
+ pattern, `locationHint`/`storageClass` enums, and the `cf-r2-jurisdiction` header recorded.
115
+ The **object data plane is explicitly out of scope**: no object upload/get/list, no
116
+ presigned URLs, no CORS/lifecycle/sippy — a bucket here is a provisioning record, not storage;
117
+ - **Hyperdrive configs**: create/list/get/put/patch/delete over the three official origin shapes
118
+ (public database, Access-protected, Workers VPC). The origin connection is **recorded as
119
+ configuration and never dialed**; `password`/`access_client_secret` are writeOnly per the
120
+ vendor schema and are never echoed back;
121
+ - **Queues**: queue create/list/get/delete and consumer create/list/get/put/delete over the
122
+ official worker/http_pull consumer union with per-type settings validation. A queue's
123
+ `producers` list is computed from Worker uploads whose bindings declare `type:"queue"` —
124
+ producer bindings are configuration, not message flow. Queue messages, purge, metrics, and
125
+ subscriptions stay manifest todos (data plane).
126
+
127
+ Responses use Cloudflare's API v4 `{success, errors, messages, result, result_info?}` envelope.
128
+ Writes honor the kernel's read-only mode. Deletes are projected as tombstones, and deterministic ID
129
+ allocation scans tombstones so delete/recreate cannot resurrect stale state.
130
+
131
+ ## Control plane, not infrastructure
132
+
133
+ The tunnel object, ingress configuration, token, DNS record, Worker script record, bucket,
134
+ Hyperdrive config, and queue are local control-plane data. The twin does **not** run
135
+ `cloudflared`, connect to Cloudflare's edge, resolve DNS, propagate records, issue certificates,
136
+ provide a publicly reachable hostname, **execute a Worker, evaluate a cron trigger, serve a
137
+ route, store or serve an R2 object, dial a Hyperdrive origin, or move a queue message**. Those
138
+ are intentionally real-world certification steps and never manifest capabilities — a twin is a
139
+ deterministic, offline model of the API contract, and the tunnel/DNS infrastructure legs are what
140
+ the real root does. The provisioning slice's data planes (R2 objects, queue messages) are todos.
141
+
142
+ Cloudflare is API-first for this use case. Its dashboard is incidental administration UI, so this
143
+ pack has no mirror and no UI capability claims.
144
+
145
+ ## Connector and budget
146
+
147
+ All optional real I/O crosses the injected `CloudflareExecute` function. Pull walks every
148
+ `result_info.total_pages` page for accounts and zones, then every tunnel page per observed account,
149
+ one configuration read per remotely managed tunnel, and every DNS-record page per observed zone.
150
+ It validates required vendor fields before folding all five resource types through the kernel observation path,
151
+ tombstones previously vendor-observed resources absent from a later inventory only when pagination
152
+ metadata proves that inventory complete (metadata-free observations never delete state), rejects anything
153
+ other than a `success:true` envelope, and is idempotent for identical observations. Push translates
154
+ only the modeled local actions, preserves PUT-versus-PATCH replacement semantics and
155
+ Cloudflare-returned tunnel/DNS IDs across dependent
156
+ actions and retries, and confirms each only after a successful response with the required result
157
+ identity; unknown actions fail loudly.
158
+
159
+ The only live executor, `liveCloudflareExecute`, checks a persistent `CloudflareBudget` before every
160
+ fetch. Cloudflare documents a global 1,200 requests per five minutes per user/account token. This
161
+ pack deliberately uses a tighter fallback-sized ceiling of 60 weighted units per minute: reads cost
162
+ 2 (30/minute), mutations cost 3 (20/minute), and `429 Retry-After` establishes a persistent
163
+ cooldown. No live call is made by the tests or capability probes.
164
+
165
+ ## Error-code provenance for the provisioning slice
166
+
167
+ The pinned OpenAPI declares only a **generic 4XX error envelope** for the Workers/R2/Hyperdrive/
168
+ Queues operations, so specific numeric error codes are not pinned by it. This pack uses
169
+ Cloudflare's widely observed codes where they are well known — `10007` (script not found, and a
170
+ missing account workers.dev subdomain — the code wrangler branches on for both),
171
+ `10006` (R2 bucket does not exist), `10004` (R2 bucket already exists) — and the pack's generic
172
+ conventions (`1004` validation, `1001` not found, `1003` conflict) everywhere else. Statuses and
173
+ envelopes are spec-grounded; the numeric codes outside the three above are conventions, stated
174
+ here rather than dressed up as vendor facts.
175
+
176
+ ## Coverage denominator
177
+
178
+ The vendor denominator is the exact **3,334 HTTP operations across 2,077 paths** in the pinned
179
+ first-party OpenAPI document: one manifest entry per method + path, with no namespace sentinels or
180
+ mixed granularity. The committed census is mechanically generated by
181
+ `scripts/generate-operation-census.ts`; the manifest separately records fourteen connector
182
+ capabilities. The Workers provisioning slice proves 51
183
+ additional operations done (Workers scripts/schedules/subdomains/routes/domains, static-assets
184
+ upload session and upload, versions and deployments, script settings and secrets listing,
185
+ Durable Object namespace listing, R2 bucket control plane, Hyperdrive configs, Queues +
186
+ consumers), each with a
187
+ failable fresh-root verify asserting response values from a fresh root, and driving the negative
188
+ 4xx or not-found path its title implies wherever the operation has a reachable one. The official SDK's **121** top-level resource
189
+ namespaces remain a separately asserted cross-check, never a substitute for the operation
190
+ denominator. This intentionally produces about 1% initial coverage rather than letting the
191
+ implementation define its own denominator.
192
+
193
+ See `src/cloudflare-capabilities.ts` for the complete manifest and generated repository docs for
194
+ the measured counts.
195
+
196
+ ## Official grounding
197
+
198
+ Grounding was inspected on 2026-08-21 (provisioning slice re-read 2026-08-23 from the same
199
+ pinned commits) from only Cloudflare-maintained sources:
200
+
201
+ - `cloudflare/api-schemas`, OpenAPI 4.0.0 at commit
202
+ `2ac8369e9b63dccacee1a2284e95bb819f05b307`;
203
+ - `cloudflare/cloudflare-typescript` at commit
204
+ `faaaf89ed8064a9fb54de538ec3e89487f1302b0` and npm `cloudflare@7.1.0`;
205
+ - Cloudflare's official API rate-limit reference:
206
+ <https://developers.cloudflare.com/fundamentals/api/reference/limits/>.
207
+
208
+ The OpenAPI supplied the complete 3,334-operation census plus the account, zone, `cfd_tunnel`,
209
+ tunnel configuration/token, DNS-record, Workers, R2, Hyperdrive, Queues, and Durable Object
210
+ paths and request schemas (including the script-name and bucket-name patterns and the script
211
+ delete `force` contract). The official SDK supplied the namespace census, structured DNS unions
212
+ (including `data`-shaped CAA records), PUT-versus-PATCH semantics, tunnel filter/secret
213
+ contracts, the Workers binding-kind and queue-consumer unions, the response shapes for the
214
+ provisioning slice, the SDK's actual multipart serialization for script uploads (measured on the
215
+ wire during this build), and the unchanged loopback client contract. No third-party Cloudflare
216
+ wrappers or application code were used as behavioral truth.
217
+
218
+ **No live probe was possible for any slice of this pack — there is no Cloudflare account to
219
+ probe.** The pinned first-party OpenAPI document plus the pinned official SDK are the honest
220
+ grounding ceiling: paths, envelopes, request schemas, pagination, and closed enums/unions are
221
+ spec-grounded; behavior the spec leaves open (specific 4xx codes, uniqueness-conflict statuses,
222
+ cross-resource referential checks on bindings/domains/consumers) is a documented convention of
223
+ this twin, not a verified vendor observation.
@@ -0,0 +1,14 @@
1
+ /** The jurisdictions an endpoint may name (Data location, "Available jurisdictions": eu, fedramp, us). */
2
+ export declare const JURISDICTIONS: Set<string>;
3
+ /** The account, the jurisdiction and, for a virtual-hosted request, the bucket an S3 endpoint host names:
4
+ * `<ACCOUNT_ID>.r2.cloudflarestorage.com`, `<ACCOUNT_ID>.<JURISDICTION>.r2.cloudflarestorage.com` ("you must specify the
5
+ * jurisdiction in your S3 endpoint", https://developers.cloudflare.com/r2/reference/data-location/), each with a bucket in
6
+ * front for the virtual-hosted form R2's presigned-URL page shows its SDKs producing. */
7
+ export declare function endpointOf(host: string): {
8
+ account: string;
9
+ jurisdiction: string;
10
+ bucket?: string;
11
+ } | undefined;
12
+ /** A request URL in path-style form: a virtual-hosted one (`https://<bucket>.<ACCOUNT_ID>[.<JURISDICTION>].r2.cloudflarestorage.com/<key>`)
13
+ * becomes `https://<ACCOUNT_ID>[.<JURISDICTION>].r2.cloudflarestorage.com/<bucket>/<key>`; any other URL is unchanged. */
14
+ export declare function pathStyle(url: string): string;
@@ -0,0 +1,30 @@
1
+ // Where an S3 request to R2 is addressed: the account, the jurisdiction and, for a virtual-hosted request, the bucket its
2
+ // host names, and the same request in path-style form. The lane's router (fetch.ts) and the tools that read its answers
3
+ // (SHAPE, the example replay: manifest.ts exports pathStyle) share this one rule.
4
+ import { R2_ENDPOINT_SUFFIX } from "../../src/cloudflare-r2.js";
5
+ /** The jurisdictions an endpoint may name (Data location, "Available jurisdictions": eu, fedramp, us). */
6
+ export const JURISDICTIONS = new Set(['eu', 'fedramp', 'us']);
7
+ /** The account, the jurisdiction and, for a virtual-hosted request, the bucket an S3 endpoint host names:
8
+ * `<ACCOUNT_ID>.r2.cloudflarestorage.com`, `<ACCOUNT_ID>.<JURISDICTION>.r2.cloudflarestorage.com` ("you must specify the
9
+ * jurisdiction in your S3 endpoint", https://developers.cloudflare.com/r2/reference/data-location/), each with a bucket in
10
+ * front for the virtual-hosted form R2's presigned-URL page shows its SDKs producing. */
11
+ export function endpointOf(host) {
12
+ if (!host.endsWith(R2_ENDPOINT_SUFFIX))
13
+ return undefined;
14
+ const labels = host.slice(0, -R2_ENDPOINT_SUFFIX.length).split('.');
15
+ const jurisdiction = labels.length >= 2 && JURISDICTIONS.has(labels.at(-1)) ? labels.pop() : 'default';
16
+ const account = labels.at(-1);
17
+ if (!/^[0-9a-f]{32}$/.test(account))
18
+ return undefined;
19
+ return labels.length === 2 ? { account, jurisdiction, bucket: labels[0] } : labels.length === 1 ? { account, jurisdiction } : undefined;
20
+ }
21
+ /** A request URL in path-style form: a virtual-hosted one (`https://<bucket>.<ACCOUNT_ID>[.<JURISDICTION>].r2.cloudflarestorage.com/<key>`)
22
+ * becomes `https://<ACCOUNT_ID>[.<JURISDICTION>].r2.cloudflarestorage.com/<bucket>/<key>`; any other URL is unchanged. */
23
+ export function pathStyle(url) {
24
+ const u = new URL(url);
25
+ const endpoint = endpointOf(u.hostname.toLowerCase());
26
+ if (!endpoint?.bucket)
27
+ return url;
28
+ const host = `${endpoint.account}${endpoint.jurisdiction === 'default' ? '' : `.${endpoint.jurisdiction}`}${R2_ENDPOINT_SUFFIX}`;
29
+ return `${u.protocol}//${host}${u.port ? `:${u.port}` : ''}/${endpoint.bucket}${u.pathname === '/' ? '' : u.pathname}${u.search}`;
30
+ }
@@ -0,0 +1,7 @@
1
+ import { type DerivedFetch } from '@volter/world-core';
2
+ export type R2LaneOptions = {
3
+ root?: string;
4
+ readOnly?: boolean;
5
+ clock?: () => string;
6
+ };
7
+ export declare function createR2LaneFetch(options?: R2LaneOptions): DerivedFetch;