@webflow/cloud-app 0.1.0-beta.10
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.
- package/LICENSE +21 -0
- package/README.md +161 -0
- package/dist/bindings.d.ts +190 -0
- package/dist/bindings.d.ts.map +1 -0
- package/dist/bindings.js +126 -0
- package/dist/bindings.js.map +1 -0
- package/dist/compat-date.d.ts +68 -0
- package/dist/compat-date.d.ts.map +1 -0
- package/dist/compat-date.js +169 -0
- package/dist/compat-date.js.map +1 -0
- package/dist/config/package-json.d.ts +57 -0
- package/dist/config/package-json.d.ts.map +1 -0
- package/dist/config/package-json.js +94 -0
- package/dist/config/package-json.js.map +1 -0
- package/dist/config/webflow-json.d.ts +47 -0
- package/dist/config/webflow-json.d.ts.map +1 -0
- package/dist/config/webflow-json.js +72 -0
- package/dist/config/webflow-json.js.map +1 -0
- package/dist/create-webflow-json.d.ts +21 -0
- package/dist/create-webflow-json.d.ts.map +1 -0
- package/dist/create-webflow-json.js +168 -0
- package/dist/create-webflow-json.js.map +1 -0
- package/dist/diagnostics.d.ts +23 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +31 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +23 -0
- package/dist/errors.js.map +1 -0
- package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.d.ts +28 -0
- package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.d.ts.map +1 -0
- package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.js +148 -0
- package/dist/frameworks/astro/adapter-patches/assert-adapter-nested-under-mount.js.map +1 -0
- package/dist/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.d.ts +34 -0
- package/dist/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.d.ts.map +1 -0
- package/dist/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.js +89 -0
- package/dist/frameworks/astro/adapter-patches/ensure-compatible-cloudflare-adapter.js.map +1 -0
- package/dist/frameworks/astro/adapter-patches/resolve-cloudflare-adapter.d.ts +39 -0
- package/dist/frameworks/astro/adapter-patches/resolve-cloudflare-adapter.d.ts.map +1 -0
- package/dist/frameworks/astro/adapter-patches/resolve-cloudflare-adapter.js +93 -0
- package/dist/frameworks/astro/adapter-patches/resolve-cloudflare-adapter.js.map +1 -0
- package/dist/frameworks/astro/astro5.d.ts +28 -0
- package/dist/frameworks/astro/astro5.d.ts.map +1 -0
- package/dist/frameworks/astro/astro5.js +276 -0
- package/dist/frameworks/astro/astro5.js.map +1 -0
- package/dist/frameworks/astro/astro6.d.ts +28 -0
- package/dist/frameworks/astro/astro6.d.ts.map +1 -0
- package/dist/frameworks/astro/astro6.js +305 -0
- package/dist/frameworks/astro/astro6.js.map +1 -0
- package/dist/frameworks/astro/astro7.d.ts +28 -0
- package/dist/frameworks/astro/astro7.d.ts.map +1 -0
- package/dist/frameworks/astro/astro7.js +303 -0
- package/dist/frameworks/astro/astro7.js.map +1 -0
- package/dist/frameworks/astro/index.d.ts +10 -0
- package/dist/frameworks/astro/index.d.ts.map +1 -0
- package/dist/frameworks/astro/index.js +16 -0
- package/dist/frameworks/astro/index.js.map +1 -0
- package/dist/frameworks/astro/session-check.d.ts +24 -0
- package/dist/frameworks/astro/session-check.d.ts.map +1 -0
- package/dist/frameworks/astro/session-check.js +166 -0
- package/dist/frameworks/astro/session-check.js.map +1 -0
- package/dist/frameworks/astro/templates/astro.config.webflow.ts +61 -0
- package/dist/frameworks/astro/templates/v5/astro.config.mjs.template +25 -0
- package/dist/frameworks/astro/templates/v5/webflow-loader.ts +126 -0
- package/dist/frameworks/astro/templates/v5/wrangler.json +6 -0
- package/dist/frameworks/astro/templates/v6/astro.config.mjs.template +35 -0
- package/dist/frameworks/astro/templates/v6/webflow-loader.ts +126 -0
- package/dist/frameworks/astro/templates/v6/wrangler.json +9 -0
- package/dist/frameworks/astro/templates/v7/astro.config.mjs.template +34 -0
- package/dist/frameworks/astro/templates/v7/webflow-loader.ts +125 -0
- package/dist/frameworks/astro/templates/v7/wrangler.json +9 -0
- package/dist/frameworks/astro/templates/webflow-image-url.ts +140 -0
- package/dist/frameworks/base.d.ts +134 -0
- package/dist/frameworks/base.d.ts.map +1 -0
- package/dist/frameworks/base.js +175 -0
- package/dist/frameworks/base.js.map +1 -0
- package/dist/frameworks/errors.d.ts +72 -0
- package/dist/frameworks/errors.d.ts.map +1 -0
- package/dist/frameworks/errors.js +120 -0
- package/dist/frameworks/errors.js.map +1 -0
- package/dist/frameworks/nextjs/adapter-resolver.d.ts +72 -0
- package/dist/frameworks/nextjs/adapter-resolver.d.ts.map +1 -0
- package/dist/frameworks/nextjs/adapter-resolver.js +246 -0
- package/dist/frameworks/nextjs/adapter-resolver.js.map +1 -0
- package/dist/frameworks/nextjs/index.d.ts +38 -0
- package/dist/frameworks/nextjs/index.d.ts.map +1 -0
- package/dist/frameworks/nextjs/index.js +268 -0
- package/dist/frameworks/nextjs/index.js.map +1 -0
- package/dist/frameworks/nextjs/templates/next.config.ts.template +13 -0
- package/dist/frameworks/nextjs/templates/next.config.webflow.ts +46 -0
- package/dist/frameworks/nextjs/templates/open-next.config.ts +3 -0
- package/dist/frameworks/nextjs/templates/webflow-loader.ts +44 -0
- package/dist/frameworks/nextjs/templates/wrangler.json +6 -0
- package/dist/frameworks/registry.d.ts +127 -0
- package/dist/frameworks/registry.d.ts.map +1 -0
- package/dist/frameworks/registry.js +257 -0
- package/dist/frameworks/registry.js.map +1 -0
- package/dist/frameworks/static/index.d.ts +116 -0
- package/dist/frameworks/static/index.d.ts.map +1 -0
- package/dist/frameworks/static/index.js +394 -0
- package/dist/frameworks/static/index.js.map +1 -0
- package/dist/frameworks/static/templates/wrangler.json +8 -0
- package/dist/frameworks/types.d.ts +138 -0
- package/dist/frameworks/types.d.ts.map +1 -0
- package/dist/frameworks/types.js +3 -0
- package/dist/frameworks/types.js.map +1 -0
- package/dist/frameworks/vite/index.d.ts +46 -0
- package/dist/frameworks/vite/index.d.ts.map +1 -0
- package/dist/frameworks/vite/index.js +303 -0
- package/dist/frameworks/vite/index.js.map +1 -0
- package/dist/frameworks/vite/templates/vite.config.ts.template +14 -0
- package/dist/frameworks/vite/templates/vite.config.webflow.ts +52 -0
- package/dist/frameworks/vite/templates/wrangler.json +10 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +136 -0
- package/dist/index.js.map +1 -0
- package/dist/pipeline.d.ts +12 -0
- package/dist/pipeline.d.ts.map +1 -0
- package/dist/pipeline.js +293 -0
- package/dist/pipeline.js.map +1 -0
- package/dist/ports/command-runner.d.ts +59 -0
- package/dist/ports/command-runner.d.ts.map +1 -0
- package/dist/ports/command-runner.js +126 -0
- package/dist/ports/command-runner.js.map +1 -0
- package/dist/ports/filesystem.d.ts +19 -0
- package/dist/ports/filesystem.d.ts.map +1 -0
- package/dist/ports/filesystem.js +68 -0
- package/dist/ports/filesystem.js.map +1 -0
- package/dist/ports/index.d.ts +17 -0
- package/dist/ports/index.d.ts.map +1 -0
- package/dist/ports/index.js +14 -0
- package/dist/ports/index.js.map +1 -0
- package/dist/ports/logger.d.ts +22 -0
- package/dist/ports/logger.d.ts.map +1 -0
- package/dist/ports/logger.js +18 -0
- package/dist/ports/logger.js.map +1 -0
- package/dist/ports/telemetry.d.ts +23 -0
- package/dist/ports/telemetry.d.ts.map +1 -0
- package/dist/ports/telemetry.js +12 -0
- package/dist/ports/telemetry.js.map +1 -0
- package/dist/static-base-href.d.ts +31 -0
- package/dist/static-base-href.d.ts.map +1 -0
- package/dist/static-base-href.js +183 -0
- package/dist/static-base-href.js.map +1 -0
- package/dist/toolchain/errors.d.ts +32 -0
- package/dist/toolchain/errors.d.ts.map +1 -0
- package/dist/toolchain/errors.js +31 -0
- package/dist/toolchain/errors.js.map +1 -0
- package/dist/toolchain/resolver.d.ts +25 -0
- package/dist/toolchain/resolver.d.ts.map +1 -0
- package/dist/toolchain/resolver.js +200 -0
- package/dist/toolchain/resolver.js.map +1 -0
- package/dist/toolchain/types.d.ts +52 -0
- package/dist/toolchain/types.d.ts.map +1 -0
- package/dist/toolchain/types.js +10 -0
- package/dist/toolchain/types.js.map +1 -0
- package/dist/types.d.ts +71 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/fs.d.ts +29 -0
- package/dist/utils/fs.d.ts.map +1 -0
- package/dist/utils/fs.js +126 -0
- package/dist/utils/fs.js.map +1 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +27 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/node-version.d.ts +20 -0
- package/dist/utils/node-version.d.ts.map +1 -0
- package/dist/utils/node-version.js +113 -0
- package/dist/utils/node-version.js.map +1 -0
- package/dist/utils/process.d.ts +25 -0
- package/dist/utils/process.d.ts.map +1 -0
- package/dist/utils/process.js +40 -0
- package/dist/utils/process.js.map +1 -0
- package/dist/utils/reserved-env.d.ts +26 -0
- package/dist/utils/reserved-env.d.ts.map +1 -0
- package/dist/utils/reserved-env.js +51 -0
- package/dist/utils/reserved-env.js.map +1 -0
- package/dist/utils/template.d.ts +15 -0
- package/dist/utils/template.d.ts.map +1 -0
- package/dist/utils/template.js +75 -0
- package/dist/utils/template.js.map +1 -0
- package/dist/utils/version.d.ts +9 -0
- package/dist/utils/version.d.ts.map +1 -0
- package/dist/utils/version.js +52 -0
- package/dist/utils/version.js.map +1 -0
- package/dist/wrangler.d.ts +195 -0
- package/dist/wrangler.d.ts.map +1 -0
- package/dist/wrangler.js +372 -0
- package/dist/wrangler.js.map +1 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Webflow, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# @webflow/cloud-app
|
|
2
|
+
|
|
3
|
+
Build a JS framework app into a [Webflow Cloud](https://webflow.com) bundle that
|
|
4
|
+
runs on Cloudflare Workers — **without your app having to know anything about
|
|
5
|
+
Cloudflare.**
|
|
6
|
+
|
|
7
|
+
You declare what you need in `webflow.json`. `@webflow/cloud-app` figures out your
|
|
8
|
+
framework (Vite, Next.js, Astro), injects the right Cloudflare adapter and
|
|
9
|
+
config, runs the build, and produces a worker-ready output directory. No
|
|
10
|
+
`wrangler.json`, no adapter packages in your `package.json`, no generated config
|
|
11
|
+
files in your tree — all of that happens in an ephemeral build workspace.
|
|
12
|
+
|
|
13
|
+
This is the same engine the Webflow CLI and Webflow Cloud's server-side builder
|
|
14
|
+
use, so a build is identical wherever it runs.
|
|
15
|
+
|
|
16
|
+
> **Status:** early. The public API and the host port seam below are stable; the
|
|
17
|
+
> framework build pipeline is being extracted from the canonical
|
|
18
|
+
> (cosmic-builder) implementation. `buildApp` throws `NotImplementedError` until
|
|
19
|
+
> that lands.
|
|
20
|
+
|
|
21
|
+
## Install
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm install @webflow/cloud-app
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { buildApp, consoleLogger, nodeCommandRunner } from '@webflow/cloud-app';
|
|
31
|
+
|
|
32
|
+
const result = await buildApp({
|
|
33
|
+
projectDir: process.cwd(),
|
|
34
|
+
outputDir: './.webflow-output',
|
|
35
|
+
ports: {
|
|
36
|
+
logger: consoleLogger,
|
|
37
|
+
runCommand: nodeCommandRunner,
|
|
38
|
+
// telemetry + fs fall back to no-op / node defaults
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
console.log(result.framework, result.deploymentType, result.entrypointPath);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Ports — running the same engine anywhere
|
|
46
|
+
|
|
47
|
+
Everything environment-specific is injected, so the engine itself is pure build
|
|
48
|
+
logic and stays public-safe (no auth, upload, secrets, or vendor SDKs baked in).
|
|
49
|
+
|
|
50
|
+
| Port | Required | Default | Why a host overrides it |
|
|
51
|
+
| ------------ | -------- | ----------------------------------------- | ---------------------------------------------------------------------- |
|
|
52
|
+
| `logger` | yes | `consoleLogger` / `silentLogger` provided | route output into oclif spinners, ECS structured logs, etc. |
|
|
53
|
+
| `runCommand` | yes | `nodeCommandRunner` provided | control/sandbox how `npm`, the framework build, and `wrangler` execute |
|
|
54
|
+
| `telemetry` | no | `noopTelemetry` | wrap `dd-trace` so existing dashboards keep working |
|
|
55
|
+
| `fs` | no | `nodeFileSystem` | plug in a virtual filesystem (e.g. browser-based agents) |
|
|
56
|
+
|
|
57
|
+
## `webflow.json`
|
|
58
|
+
|
|
59
|
+
The only Webflow-owned file in your project. Framework is auto-detected (you can
|
|
60
|
+
pin it) and **bindings are declared here** rather than in `wrangler.json`:
|
|
61
|
+
|
|
62
|
+
```jsonc
|
|
63
|
+
{
|
|
64
|
+
"cloud": {
|
|
65
|
+
"framework": "nextjs",
|
|
66
|
+
"bindings": {
|
|
67
|
+
"kv": [{ "binding": "MY_KV" }],
|
|
68
|
+
"r2": [{ "binding": "MY_BUCKET", "bucket_name": "my-bucket" }],
|
|
69
|
+
"d1": [{ "binding": "DB", "database_name": "app-db", "migrations_dir": "./migrations" }],
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
You declare the binding name (and, for R2/D1, the resource name) — Webflow Cloud
|
|
76
|
+
provisions the resource and namespaces it per environment. KV ids / D1
|
|
77
|
+
`database_id`s are assigned for you; omit them. Limits: up to 5 of each type; R2
|
|
78
|
+
bucket names are lowercase alphanumeric + hyphens, ≤27 chars. (`vars` is not
|
|
79
|
+
supported yet — it needs deployer support to propagate.)
|
|
80
|
+
|
|
81
|
+
The deploy-contract fields (`contract_version`, `framework`, `deployment_type`,
|
|
82
|
+
`entrypoint_path`, `skip_no_bundle`) are filled in by the build and validated
|
|
83
|
+
against [`@webflow/cosmic-deploy-contract`](https://www.npmjs.com/package/@webflow/cosmic-deploy-contract)
|
|
84
|
+
before output is produced.
|
|
85
|
+
|
|
86
|
+
## Development
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
npm install # from the monorepo root
|
|
90
|
+
npm test # jest
|
|
91
|
+
npm run build # tsc → dist/
|
|
92
|
+
npm run type-check
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## How consumers resolve this package
|
|
96
|
+
|
|
97
|
+
Two consumers build with this engine: the Webflow CLI (`apps/webflow-cli`, same
|
|
98
|
+
monorepo) and the cosmic-builder image (`webflow/infrastructure`, a separate
|
|
99
|
+
repo). Which copy of `@webflow/cloud-app` they load is decided by **where
|
|
100
|
+
`npm install` ran**, not by how the code is bundled and not at runtime — a
|
|
101
|
+
`require("@webflow/cloud-app")` just reads whatever `npm` put in `node_modules`.
|
|
102
|
+
|
|
103
|
+
| Scenario | `node_modules/@webflow/cloud-app` is… | Source |
|
|
104
|
+
| ---------------------------------------------------------------------------- | ------------------------------------- | --------------------- |
|
|
105
|
+
| End user runs `npm i -g @webflow/webflow-cli` | the registry copy npm fetched | npm registry |
|
|
106
|
+
| Engineer working in the webflow-cli repo (`npm ci`, build, run local `dist`) | a symlink to `apps/webflow-cloud-app` | workspace (repo tree) |
|
|
107
|
+
| CI for webflow-cli (unit, regression, e2e) | a symlink to `apps/webflow-cloud-app` | workspace (repo tree) |
|
|
108
|
+
| cosmic-builder (separate repo) | the registry copy npm fetched | npm registry |
|
|
109
|
+
|
|
110
|
+
- **Inside this monorepo the CLI always uses the workspace copy.**
|
|
111
|
+
`apps/webflow-cloud-app` is a workspace member, so npm links it by name
|
|
112
|
+
while the declared version matches — `apps/webflow-cli`
|
|
113
|
+
depends on it at an exact pin equal to this package's version (enforced in CI
|
|
114
|
+
by `npm run check:cloud-app-pin`; a mismatched pin would make npm silently
|
|
115
|
+
install the registry copy instead). Edit the source here and it takes effect on
|
|
116
|
+
the next build.
|
|
117
|
+
- **The published CLI uses the registry copy.** The engine is kept external in
|
|
118
|
+
the CLI's tsup bundle (it is CJS, not inlined), so the shipped `dist` keeps
|
|
119
|
+
`require("@webflow/cloud-app")` and resolves it at the user's install time.
|
|
120
|
+
The CLI's `package.json` carries an exact pin (not a caret, since this is a
|
|
121
|
+
prerelease line the CLI is built and tested against), so released builds
|
|
122
|
+
resolve exactly that version from npm.
|
|
123
|
+
- **cosmic-builder is a different repo**, so it has no workspace copy and always
|
|
124
|
+
resolves from the registry. That is why publishing to npm (below) still
|
|
125
|
+
matters even though the CLI links the workspace in development.
|
|
126
|
+
|
|
127
|
+
## Publishing
|
|
128
|
+
|
|
129
|
+
Published **manually** from this folder — there is no GitHub Action. Its release
|
|
130
|
+
cadence follows the build engine, not the CLI. It is a regular changesets
|
|
131
|
+
workspace package, but `changeset publish` always publishes with `--tag latest`,
|
|
132
|
+
which would move `latest` onto a beta, so it must already be on npm before a CLI
|
|
133
|
+
release: `publish-packages.sh` refuses to run otherwise, and skips it once it is.
|
|
134
|
+
Don't add changesets for this package — changesets can't increment a prerelease
|
|
135
|
+
(it would turn `0.1.0-beta.7` into `0.1.0`); bump the version by hand. CI fails
|
|
136
|
+
(`npm run check:cloud-app-pin`) if a changeset names it.
|
|
137
|
+
|
|
138
|
+
This is a prerelease line (`0.1.0-beta.x`), so always pass an explicit
|
|
139
|
+
`--tag` — npm would otherwise move the `latest` tag onto a beta. The CLI pins
|
|
140
|
+
this exact version, so move the pin in the same PR (CI runs
|
|
141
|
+
`npm run check:cloud-app-pin`):
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
# from apps/webflow-cloud-app
|
|
145
|
+
npm version prerelease --preid beta --no-git-tag-version # 0.1.0-beta.7 → 0.1.0-beta.8
|
|
146
|
+
# set "@webflow/cloud-app" in apps/webflow-cli/package.json to the same version
|
|
147
|
+
# and run `npm install` from the repo root
|
|
148
|
+
npm publish --tag beta # installs via @webflow/cloud-app@beta
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
To test a build against the consumers (webflow-cli, cosmic-builder) before a
|
|
152
|
+
real release, publish the same version under a throwaway ticket-scoped tag so
|
|
153
|
+
it never touches `latest` or `beta`:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
npm publish --tag beta7-cloud888 # installs via @webflow/cloud-app@beta7-cloud888
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Consumers then pin that exact version (e.g. `"@webflow/cloud-app": "0.1.0-beta.8"`)
|
|
160
|
+
and CI resolves it from the registry. Remove a throwaway tag when done with
|
|
161
|
+
`npm dist-tag rm @webflow/cloud-app beta7-cloud888`.
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud resource bindings declared in `webflow.json`.
|
|
3
|
+
*
|
|
4
|
+
* NEW in @webflow/cloud-app: users declare KV / R2 / D1 bindings under
|
|
5
|
+
* `cloud.bindings` in webflow.json instead of hand-writing wrangler.json (which
|
|
6
|
+
* is now internal). The engine validates them and synthesizes a wrangler-shaped
|
|
7
|
+
* bridge (clouduser.wrangler.json) that the existing deployer consumes
|
|
8
|
+
* unchanged — the deployer namespaces resources as `<APP_NAME>-<name>` and
|
|
9
|
+
* fills in the real ids, so the placeholder ids below only need to satisfy the
|
|
10
|
+
* build-phase wrangler schema + dry-run.
|
|
11
|
+
*
|
|
12
|
+
* `vars` are intentionally NOT supported yet: the deployer's
|
|
13
|
+
* `processWranglerBindings` ships only d1/kv/r2 and drops everything else, so
|
|
14
|
+
* vars wouldn't survive to deploy without a deployer change.
|
|
15
|
+
*/
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
import type { WranglerJson } from './wrangler';
|
|
18
|
+
/** Max number of each binding type, matching the deployer's limits. */
|
|
19
|
+
export declare const MAX_BINDINGS_PER_TYPE = 5;
|
|
20
|
+
export declare const KvBindingSchema: z.ZodObject<{
|
|
21
|
+
binding: z.ZodString;
|
|
22
|
+
id: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
24
|
+
binding: z.ZodString;
|
|
25
|
+
id: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
27
|
+
binding: z.ZodString;
|
|
28
|
+
id: z.ZodOptional<z.ZodString>;
|
|
29
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
30
|
+
export declare const R2BindingSchema: z.ZodObject<{
|
|
31
|
+
binding: z.ZodString;
|
|
32
|
+
bucket_name: z.ZodString;
|
|
33
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
34
|
+
binding: z.ZodString;
|
|
35
|
+
bucket_name: z.ZodString;
|
|
36
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
37
|
+
binding: z.ZodString;
|
|
38
|
+
bucket_name: z.ZodString;
|
|
39
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
40
|
+
export declare const D1BindingSchema: z.ZodObject<{
|
|
41
|
+
binding: z.ZodString;
|
|
42
|
+
database_name: z.ZodString;
|
|
43
|
+
database_id: z.ZodOptional<z.ZodString>;
|
|
44
|
+
migrations_dir: z.ZodOptional<z.ZodString>;
|
|
45
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
46
|
+
binding: z.ZodString;
|
|
47
|
+
database_name: z.ZodString;
|
|
48
|
+
database_id: z.ZodOptional<z.ZodString>;
|
|
49
|
+
migrations_dir: z.ZodOptional<z.ZodString>;
|
|
50
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
51
|
+
binding: z.ZodString;
|
|
52
|
+
database_name: z.ZodString;
|
|
53
|
+
database_id: z.ZodOptional<z.ZodString>;
|
|
54
|
+
migrations_dir: z.ZodOptional<z.ZodString>;
|
|
55
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
56
|
+
export declare const BindingsSchema: z.ZodObject<{
|
|
57
|
+
kv: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
58
|
+
binding: z.ZodString;
|
|
59
|
+
id: z.ZodOptional<z.ZodString>;
|
|
60
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
61
|
+
binding: z.ZodString;
|
|
62
|
+
id: z.ZodOptional<z.ZodString>;
|
|
63
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
64
|
+
binding: z.ZodString;
|
|
65
|
+
id: z.ZodOptional<z.ZodString>;
|
|
66
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
67
|
+
r2: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
68
|
+
binding: z.ZodString;
|
|
69
|
+
bucket_name: z.ZodString;
|
|
70
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
71
|
+
binding: z.ZodString;
|
|
72
|
+
bucket_name: z.ZodString;
|
|
73
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
74
|
+
binding: z.ZodString;
|
|
75
|
+
bucket_name: z.ZodString;
|
|
76
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
77
|
+
d1: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
78
|
+
binding: z.ZodString;
|
|
79
|
+
database_name: z.ZodString;
|
|
80
|
+
database_id: z.ZodOptional<z.ZodString>;
|
|
81
|
+
migrations_dir: z.ZodOptional<z.ZodString>;
|
|
82
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
83
|
+
binding: z.ZodString;
|
|
84
|
+
database_name: z.ZodString;
|
|
85
|
+
database_id: z.ZodOptional<z.ZodString>;
|
|
86
|
+
migrations_dir: z.ZodOptional<z.ZodString>;
|
|
87
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
88
|
+
binding: z.ZodString;
|
|
89
|
+
database_name: z.ZodString;
|
|
90
|
+
database_id: z.ZodOptional<z.ZodString>;
|
|
91
|
+
migrations_dir: z.ZodOptional<z.ZodString>;
|
|
92
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
93
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
94
|
+
kv: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
95
|
+
binding: z.ZodString;
|
|
96
|
+
id: z.ZodOptional<z.ZodString>;
|
|
97
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
98
|
+
binding: z.ZodString;
|
|
99
|
+
id: z.ZodOptional<z.ZodString>;
|
|
100
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
101
|
+
binding: z.ZodString;
|
|
102
|
+
id: z.ZodOptional<z.ZodString>;
|
|
103
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
104
|
+
r2: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
105
|
+
binding: z.ZodString;
|
|
106
|
+
bucket_name: z.ZodString;
|
|
107
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
108
|
+
binding: z.ZodString;
|
|
109
|
+
bucket_name: z.ZodString;
|
|
110
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
111
|
+
binding: z.ZodString;
|
|
112
|
+
bucket_name: z.ZodString;
|
|
113
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
114
|
+
d1: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
115
|
+
binding: z.ZodString;
|
|
116
|
+
database_name: z.ZodString;
|
|
117
|
+
database_id: z.ZodOptional<z.ZodString>;
|
|
118
|
+
migrations_dir: z.ZodOptional<z.ZodString>;
|
|
119
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
120
|
+
binding: z.ZodString;
|
|
121
|
+
database_name: z.ZodString;
|
|
122
|
+
database_id: z.ZodOptional<z.ZodString>;
|
|
123
|
+
migrations_dir: z.ZodOptional<z.ZodString>;
|
|
124
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
125
|
+
binding: z.ZodString;
|
|
126
|
+
database_name: z.ZodString;
|
|
127
|
+
database_id: z.ZodOptional<z.ZodString>;
|
|
128
|
+
migrations_dir: z.ZodOptional<z.ZodString>;
|
|
129
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
130
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
131
|
+
kv: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
132
|
+
binding: z.ZodString;
|
|
133
|
+
id: z.ZodOptional<z.ZodString>;
|
|
134
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
135
|
+
binding: z.ZodString;
|
|
136
|
+
id: z.ZodOptional<z.ZodString>;
|
|
137
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
138
|
+
binding: z.ZodString;
|
|
139
|
+
id: z.ZodOptional<z.ZodString>;
|
|
140
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
141
|
+
r2: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
142
|
+
binding: z.ZodString;
|
|
143
|
+
bucket_name: z.ZodString;
|
|
144
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
145
|
+
binding: z.ZodString;
|
|
146
|
+
bucket_name: z.ZodString;
|
|
147
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
148
|
+
binding: z.ZodString;
|
|
149
|
+
bucket_name: z.ZodString;
|
|
150
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
151
|
+
d1: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
152
|
+
binding: z.ZodString;
|
|
153
|
+
database_name: z.ZodString;
|
|
154
|
+
database_id: z.ZodOptional<z.ZodString>;
|
|
155
|
+
migrations_dir: z.ZodOptional<z.ZodString>;
|
|
156
|
+
}, "passthrough", z.ZodTypeAny, z.objectOutputType<{
|
|
157
|
+
binding: z.ZodString;
|
|
158
|
+
database_name: z.ZodString;
|
|
159
|
+
database_id: z.ZodOptional<z.ZodString>;
|
|
160
|
+
migrations_dir: z.ZodOptional<z.ZodString>;
|
|
161
|
+
}, z.ZodTypeAny, "passthrough">, z.objectInputType<{
|
|
162
|
+
binding: z.ZodString;
|
|
163
|
+
database_name: z.ZodString;
|
|
164
|
+
database_id: z.ZodOptional<z.ZodString>;
|
|
165
|
+
migrations_dir: z.ZodOptional<z.ZodString>;
|
|
166
|
+
}, z.ZodTypeAny, "passthrough">>, "many">>;
|
|
167
|
+
}, z.ZodTypeAny, "passthrough">>;
|
|
168
|
+
export type WebflowBindings = z.infer<typeof BindingsSchema>;
|
|
169
|
+
/** Parse the raw `cloud.bindings` block. Returns undefined if it's absent/invalid-shaped. */
|
|
170
|
+
export declare function parseBindings(raw: unknown): WebflowBindings | undefined;
|
|
171
|
+
/** Whether the binding block declares at least one binding. */
|
|
172
|
+
export declare function hasAnyBindings(bindings: WebflowBindings | undefined): boolean;
|
|
173
|
+
/** Validate an R2 bucket name (rules from Cloudflare; 27-char cap leaves room for the app-name prefix). */
|
|
174
|
+
export declare function validateR2BucketName(name: string): void;
|
|
175
|
+
/** Enforce per-type count limits and R2 naming rules. Mirrors the deployer's checks. */
|
|
176
|
+
export declare function validateBindings(bindings: WebflowBindings): void;
|
|
177
|
+
/**
|
|
178
|
+
* `compatibility_date` written into the binding bridge. A schema placeholder the deployer
|
|
179
|
+
* ignores, not a date the user chose; the compat date policy never treats it as one.
|
|
180
|
+
*/
|
|
181
|
+
export declare const BINDINGS_BRIDGE_COMPAT_DATE = "2025-01-01";
|
|
182
|
+
/**
|
|
183
|
+
* Synthesize the wrangler-shaped binding bridge from webflow.json bindings.
|
|
184
|
+
*
|
|
185
|
+
* Produces the same shape the build pipeline would otherwise read from a user's
|
|
186
|
+
* wrangler.json: `name` + `compatibility_date` (placeholders the deployer
|
|
187
|
+
* ignores) plus the kv/r2/d1 arrays with placeholder ids.
|
|
188
|
+
*/
|
|
189
|
+
export declare function bindingsToWranglerJson(bindings: WebflowBindings, name?: string): WranglerJson;
|
|
190
|
+
//# sourceMappingURL=bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.d.ts","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,uEAAuE;AACvE,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAUvC,eAAO,MAAM,eAAe;;;;;;;;;gCAEZ,CAAC;AACjB,eAAO,MAAM,eAAe;;;;;;;;;gCAEZ,CAAC;AACjB,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;gCAOZ,CAAC;AAEjB,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gCAMX,CAAC;AAEjB,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE7D,6FAA6F;AAC7F,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,GAAG,SAAS,CAGvE;AAED,+DAA+D;AAC/D,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,GAAG,SAAS,GAAG,OAAO,CAG7E;AAED,2GAA2G;AAC3G,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAgBvD;AAED,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAmBhE;AAED;;;GAGG;AACH,eAAO,MAAM,2BAA2B,eAAe,CAAC;AAExD;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,IAAI,SAAgB,GACnB,YAAY,CAmBd"}
|
package/dist/bindings.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BINDINGS_BRIDGE_COMPAT_DATE = exports.BindingsSchema = exports.D1BindingSchema = exports.R2BindingSchema = exports.KvBindingSchema = exports.MAX_BINDINGS_PER_TYPE = void 0;
|
|
4
|
+
exports.parseBindings = parseBindings;
|
|
5
|
+
exports.hasAnyBindings = hasAnyBindings;
|
|
6
|
+
exports.validateR2BucketName = validateR2BucketName;
|
|
7
|
+
exports.validateBindings = validateBindings;
|
|
8
|
+
exports.bindingsToWranglerJson = bindingsToWranglerJson;
|
|
9
|
+
/**
|
|
10
|
+
* Cloud resource bindings declared in `webflow.json`.
|
|
11
|
+
*
|
|
12
|
+
* NEW in @webflow/cloud-app: users declare KV / R2 / D1 bindings under
|
|
13
|
+
* `cloud.bindings` in webflow.json instead of hand-writing wrangler.json (which
|
|
14
|
+
* is now internal). The engine validates them and synthesizes a wrangler-shaped
|
|
15
|
+
* bridge (clouduser.wrangler.json) that the existing deployer consumes
|
|
16
|
+
* unchanged — the deployer namespaces resources as `<APP_NAME>-<name>` and
|
|
17
|
+
* fills in the real ids, so the placeholder ids below only need to satisfy the
|
|
18
|
+
* build-phase wrangler schema + dry-run.
|
|
19
|
+
*
|
|
20
|
+
* `vars` are intentionally NOT supported yet: the deployer's
|
|
21
|
+
* `processWranglerBindings` ships only d1/kv/r2 and drops everything else, so
|
|
22
|
+
* vars wouldn't survive to deploy without a deployer change.
|
|
23
|
+
*/
|
|
24
|
+
const zod_1 = require("zod");
|
|
25
|
+
const errors_1 = require("./frameworks/errors");
|
|
26
|
+
/** Max number of each binding type, matching the deployer's limits. */
|
|
27
|
+
exports.MAX_BINDINGS_PER_TYPE = 5;
|
|
28
|
+
// Cloudflare assigns the real ids at deploy time. The user wrangler schema and
|
|
29
|
+
// `wrangler deploy --dry-run` accept bindings without ids; the placeholders keep
|
|
30
|
+
// the bridge valid against the strict `loadWranglerJson` schema.
|
|
31
|
+
const KV_ID_PLACEHOLDER = '0'.repeat(32);
|
|
32
|
+
const D1_ID_PLACEHOLDER = '00000000-0000-0000-0000-000000000000';
|
|
33
|
+
// `binding` is the JS binding name (e.g. `env.MY_KV`). `id` / `database_id` are
|
|
34
|
+
// optional — users normally omit them (the deployer assigns real ones).
|
|
35
|
+
exports.KvBindingSchema = zod_1.z
|
|
36
|
+
.object({ binding: zod_1.z.string(), id: zod_1.z.string().optional() })
|
|
37
|
+
.passthrough();
|
|
38
|
+
exports.R2BindingSchema = zod_1.z
|
|
39
|
+
.object({ binding: zod_1.z.string(), bucket_name: zod_1.z.string() })
|
|
40
|
+
.passthrough();
|
|
41
|
+
exports.D1BindingSchema = zod_1.z
|
|
42
|
+
.object({
|
|
43
|
+
binding: zod_1.z.string(),
|
|
44
|
+
database_name: zod_1.z.string(),
|
|
45
|
+
database_id: zod_1.z.string().optional(),
|
|
46
|
+
migrations_dir: zod_1.z.string().optional(),
|
|
47
|
+
})
|
|
48
|
+
.passthrough();
|
|
49
|
+
exports.BindingsSchema = zod_1.z
|
|
50
|
+
.object({
|
|
51
|
+
kv: zod_1.z.array(exports.KvBindingSchema).optional(),
|
|
52
|
+
r2: zod_1.z.array(exports.R2BindingSchema).optional(),
|
|
53
|
+
d1: zod_1.z.array(exports.D1BindingSchema).optional(),
|
|
54
|
+
})
|
|
55
|
+
.passthrough();
|
|
56
|
+
/** Parse the raw `cloud.bindings` block. Returns undefined if it's absent/invalid-shaped. */
|
|
57
|
+
function parseBindings(raw) {
|
|
58
|
+
const result = exports.BindingsSchema.safeParse(raw);
|
|
59
|
+
return result.success ? result.data : undefined;
|
|
60
|
+
}
|
|
61
|
+
/** Whether the binding block declares at least one binding. */
|
|
62
|
+
function hasAnyBindings(bindings) {
|
|
63
|
+
if (!bindings)
|
|
64
|
+
return false;
|
|
65
|
+
return Boolean(bindings.kv?.length || bindings.r2?.length || bindings.d1?.length);
|
|
66
|
+
}
|
|
67
|
+
/** Validate an R2 bucket name (rules from Cloudflare; 27-char cap leaves room for the app-name prefix). */
|
|
68
|
+
function validateR2BucketName(name) {
|
|
69
|
+
if (!/^[a-z0-9-]+$/.test(name)) {
|
|
70
|
+
throw new errors_1.FrameworkConfigError(`Invalid object storage bucket name ${JSON.stringify(name)}: Only lowercase letters, numbers, and hyphens are allowed.`);
|
|
71
|
+
}
|
|
72
|
+
if (name.startsWith('-') || name.endsWith('-')) {
|
|
73
|
+
throw new errors_1.FrameworkConfigError(`Invalid object storage bucket name "${name}": Cannot begin or end with a hyphen.`);
|
|
74
|
+
}
|
|
75
|
+
if (name.length > 27) {
|
|
76
|
+
throw new errors_1.FrameworkConfigError(`Invalid object storage bucket name "${name}": Must be 27 characters or fewer (currently ${name.length} characters).`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/** Enforce per-type count limits and R2 naming rules. Mirrors the deployer's checks. */
|
|
80
|
+
function validateBindings(bindings) {
|
|
81
|
+
if ((bindings.kv?.length ?? 0) > exports.MAX_BINDINGS_PER_TYPE) {
|
|
82
|
+
throw new errors_1.FrameworkConfigError(`Too many KV namespaces configured: ${bindings.kv.length}. Maximum allowed is ${exports.MAX_BINDINGS_PER_TYPE}.`);
|
|
83
|
+
}
|
|
84
|
+
if ((bindings.d1?.length ?? 0) > exports.MAX_BINDINGS_PER_TYPE) {
|
|
85
|
+
throw new errors_1.FrameworkConfigError(`Too many D1 databases configured: ${bindings.d1.length}. Maximum allowed is ${exports.MAX_BINDINGS_PER_TYPE}.`);
|
|
86
|
+
}
|
|
87
|
+
if ((bindings.r2?.length ?? 0) > exports.MAX_BINDINGS_PER_TYPE) {
|
|
88
|
+
throw new errors_1.FrameworkConfigError(`Too many R2 buckets configured: ${bindings.r2.length}. Maximum allowed is ${exports.MAX_BINDINGS_PER_TYPE}.`);
|
|
89
|
+
}
|
|
90
|
+
for (const bucket of bindings.r2 ?? []) {
|
|
91
|
+
validateR2BucketName(bucket.bucket_name);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* `compatibility_date` written into the binding bridge. A schema placeholder the deployer
|
|
96
|
+
* ignores, not a date the user chose; the compat date policy never treats it as one.
|
|
97
|
+
*/
|
|
98
|
+
exports.BINDINGS_BRIDGE_COMPAT_DATE = '2025-01-01';
|
|
99
|
+
/**
|
|
100
|
+
* Synthesize the wrangler-shaped binding bridge from webflow.json bindings.
|
|
101
|
+
*
|
|
102
|
+
* Produces the same shape the build pipeline would otherwise read from a user's
|
|
103
|
+
* wrangler.json: `name` + `compatibility_date` (placeholders the deployer
|
|
104
|
+
* ignores) plus the kv/r2/d1 arrays with placeholder ids.
|
|
105
|
+
*/
|
|
106
|
+
function bindingsToWranglerJson(bindings, name = 'webflow-app') {
|
|
107
|
+
return {
|
|
108
|
+
name,
|
|
109
|
+
compatibility_date: exports.BINDINGS_BRIDGE_COMPAT_DATE,
|
|
110
|
+
kv_namespaces: (bindings.kv ?? []).map((k) => ({
|
|
111
|
+
binding: k.binding,
|
|
112
|
+
id: k.id ?? KV_ID_PLACEHOLDER,
|
|
113
|
+
})),
|
|
114
|
+
r2_buckets: (bindings.r2 ?? []).map((r) => ({
|
|
115
|
+
binding: r.binding,
|
|
116
|
+
bucket_name: r.bucket_name,
|
|
117
|
+
})),
|
|
118
|
+
d1_databases: (bindings.d1 ?? []).map((d) => ({
|
|
119
|
+
binding: d.binding,
|
|
120
|
+
database_name: d.database_name,
|
|
121
|
+
database_id: d.database_id ?? D1_ID_PLACEHOLDER,
|
|
122
|
+
...(d.migrations_dir ? { migrations_dir: d.migrations_dir } : {}),
|
|
123
|
+
})),
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bindings.js","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":";;;AAyDA,sCAGC;AAGD,wCAGC;AAGD,oDAgBC;AAGD,4CAmBC;AAeD,wDAsBC;AAhJD;;;;;;;;;;;;;;GAcG;AACH,6BAAwB;AAExB,gDAA2D;AAG3D,uEAAuE;AAC1D,QAAA,qBAAqB,GAAG,CAAC,CAAC;AAEvC,+EAA+E;AAC/E,iFAAiF;AACjF,iEAAiE;AACjE,MAAM,iBAAiB,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACzC,MAAM,iBAAiB,GAAG,sCAAsC,CAAC;AAEjE,gFAAgF;AAChF,wEAAwE;AAC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;YAC/C,GAAG,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,cAAc,EAAE,CAAC,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAClE,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Logger } from './ports';
|
|
2
|
+
/**
|
|
3
|
+
* Lowest `compatibility_date` the platform runs a worker at once the policy is on.
|
|
4
|
+
* workerd only provides a working `node:http` / `node:https` client from this date.
|
|
5
|
+
*/
|
|
6
|
+
export declare const COMPAT_DATE_FLOOR = "2025-08-16";
|
|
7
|
+
/**
|
|
8
|
+
* Where the build records the date it settled on, next to `clouduser.wrangler.json`
|
|
9
|
+
* (which already travels from the build to the deploy). Keep in sync with the
|
|
10
|
+
* deployer.
|
|
11
|
+
*/
|
|
12
|
+
export declare const COMPAT_DATE_RECORD_FILE = "clouduser.compat-date.json";
|
|
13
|
+
export type CompatDateSource = 'template' | 'floor' | 'user';
|
|
14
|
+
export interface CompatDateInputs {
|
|
15
|
+
/** `compatibility_date` of the template the build's wrangler.json was copied from. */
|
|
16
|
+
templateDate: string;
|
|
17
|
+
/** `compatibility_date` from the user's own wrangler config, if any. */
|
|
18
|
+
userDate?: string;
|
|
19
|
+
/**
|
|
20
|
+
* When false the template date is used unchanged. When true, the result is always
|
|
21
|
+
* a valid date at or above COMPAT_DATE_FLOOR: the user's date when it qualifies,
|
|
22
|
+
* otherwise the template's date or the floor, whichever is later.
|
|
23
|
+
*/
|
|
24
|
+
policyEnabled: boolean;
|
|
25
|
+
/** Injected for tests. */
|
|
26
|
+
now?: Date;
|
|
27
|
+
}
|
|
28
|
+
export interface CompatDateResolution {
|
|
29
|
+
date: string;
|
|
30
|
+
source: CompatDateSource;
|
|
31
|
+
/** Present when the user's date was unusable. */
|
|
32
|
+
warning?: string;
|
|
33
|
+
}
|
|
34
|
+
/** What the build leaves for the deploy. */
|
|
35
|
+
export interface CompatDateRecord {
|
|
36
|
+
compatibilityDate: string;
|
|
37
|
+
source: CompatDateSource;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Pure resolution of the date a worker is built and deployed with.
|
|
41
|
+
*
|
|
42
|
+
* policy off -> template date, unchanged
|
|
43
|
+
* policy on, user date valid, <= today, >= floor -> user date
|
|
44
|
+
* policy on, otherwise -> default, plus a warning if a
|
|
45
|
+
* user date was given but unusable
|
|
46
|
+
*
|
|
47
|
+
* where default = the template date if it is a valid date at or above the floor,
|
|
48
|
+
* else the floor.
|
|
49
|
+
*/
|
|
50
|
+
export declare function resolveCompatDate(inputs: CompatDateInputs): CompatDateResolution;
|
|
51
|
+
/**
|
|
52
|
+
* Settles the date on `<cwd>/wrangler.json` (just copied from the framework
|
|
53
|
+
* template) and records it for the deploy.
|
|
54
|
+
*
|
|
55
|
+
* `userCompatDate` is the date from the user's own wrangler config, if any. The
|
|
56
|
+
* bindings-bridge placeholder is not a user choice and is ignored. With the policy
|
|
57
|
+
* off nothing changes and no record is written; a record already in the checkout is
|
|
58
|
+
* removed either way, because the deploy trusts that file and a repo must not be
|
|
59
|
+
* able to supply it.
|
|
60
|
+
*
|
|
61
|
+
* Never throws: an error keeps the template date and logs a warning, so this cannot
|
|
62
|
+
* fail a build.
|
|
63
|
+
*/
|
|
64
|
+
export declare function applyCompatDateAtBuild(log: Logger, cwd: string, userCompatDate: string | undefined, opts?: {
|
|
65
|
+
policyEnabled?: boolean;
|
|
66
|
+
now?: Date;
|
|
67
|
+
}): CompatDateResolution | undefined;
|
|
68
|
+
//# sourceMappingURL=compat-date.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compat-date.d.ts","sourceRoot":"","sources":["../src/compat-date.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAGtC;;;GAGG;AACH,eAAO,MAAM,iBAAiB,eAAe,CAAC;AAE9C;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,+BAA+B,CAAC;AAEpE,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,OAAO,GAAG,MAAM,CAAC;AAE7D,MAAM,WAAW,gBAAgB;IAC/B,sFAAsF;IACtF,YAAY,EAAE,MAAM,CAAC;IACrB,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,aAAa,EAAE,OAAO,CAAC;IACvB,0BAA0B;IAC1B,GAAG,CAAC,EAAE,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,gBAAgB,CAAC;IACzB,iDAAiD;IACjD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,4CAA4C;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAUD;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,gBAAgB,GAAG,oBAAoB,CAgChF;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,MAAM,GAAG,SAAS,EAClC,IAAI,GAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,GAAG,CAAC,EAAE,IAAI,CAAA;CAAO,GACjD,oBAAoB,GAAG,SAAS,CAwClC"}
|