-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[wrangler] add artifacts binding support #13326
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dario-piotrowicz
merged 8 commits into
cloudflare:main
from
mattzcarey:feat/artifacts-binding
Apr 17, 2026
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
d3475c8
feat: add artifacts binding support to wrangler
mattzcarey 6fc33f8
update `removeRemoteConfigFieldFromBindings` accordingly
dario-piotrowicz 26372ae
add unit tests
dario-piotrowicz a2fe78f
ci: retry
mattzcarey 85145e4
Update .changeset/artifacts-binding-support.md
dario-piotrowicz 8f62e61
Merge branch 'main' into feat/artifacts-binding
mattzcarey f90f164
Merge branch 'main' into feat/artifacts-binding
mattzcarey 0a533dc
Merge branch 'main' into feat/artifacts-binding
dario-piotrowicz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| --- | ||
| "wrangler": minor | ||
| "miniflare": minor | ||
| "@cloudflare/workers-utils": minor | ||
| --- | ||
|
|
||
| Add Artifacts binding support to wrangler | ||
|
|
||
| You can now configure Artifacts bindings in your wrangler configuration: | ||
|
|
||
| ```jsonc | ||
| // wrangler.jsonc | ||
| { | ||
| "artifacts": [{ "binding": "MY_ARTIFACTS", "namespace": "default" }], | ||
| } | ||
| ``` | ||
|
|
||
| Type generation produces the correct `Artifacts` type reference from the workerd type definitions: | ||
|
|
||
| ```ts | ||
| interface Env { | ||
| MY_ARTIFACTS: Artifacts; | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { z } from "zod"; | ||
| import { | ||
| getUserBindingServiceName, | ||
| ProxyNodeBinding, | ||
| remoteProxyClientWorker, | ||
| } from "../shared"; | ||
| import type { Plugin, RemoteProxyConnectionString } from "../shared"; | ||
|
|
||
| const ArtifactsSchema = z.object({ | ||
| namespace: z.string(), | ||
| remoteProxyConnectionString: z | ||
| .custom<RemoteProxyConnectionString>() | ||
| .optional(), | ||
| }); | ||
|
|
||
| export const ArtifactsOptionsSchema = z.object({ | ||
| artifacts: z.record(ArtifactsSchema).optional(), | ||
| }); | ||
|
|
||
| export const ARTIFACTS_PLUGIN_NAME = "artifacts"; | ||
|
|
||
| export const ARTIFACTS_PLUGIN: Plugin<typeof ArtifactsOptionsSchema> = { | ||
| options: ArtifactsOptionsSchema, | ||
| async getBindings(options) { | ||
| if (!options.artifacts) { | ||
| return []; | ||
| } | ||
|
|
||
| return Object.entries(options.artifacts).map(([name, config]) => ({ | ||
| name, | ||
| service: { | ||
| name: getUserBindingServiceName( | ||
| ARTIFACTS_PLUGIN_NAME, | ||
| name, | ||
| config.remoteProxyConnectionString | ||
| ), | ||
| }, | ||
| })); | ||
| }, | ||
| getNodeBindings(options: z.infer<typeof ArtifactsOptionsSchema>) { | ||
| if (!options.artifacts) { | ||
| return {}; | ||
| } | ||
| return Object.fromEntries( | ||
| Object.keys(options.artifacts).map((name) => [ | ||
| name, | ||
| new ProxyNodeBinding(), | ||
| ]) | ||
| ); | ||
| }, | ||
| async getServices({ options }) { | ||
| if (!options.artifacts) { | ||
| return []; | ||
| } | ||
|
|
||
| return Object.entries(options.artifacts).map( | ||
| ([name, { remoteProxyConnectionString }]) => ({ | ||
| name: getUserBindingServiceName( | ||
| ARTIFACTS_PLUGIN_NAME, | ||
| name, | ||
| remoteProxyConnectionString | ||
| ), | ||
| worker: remoteProxyClientWorker(remoteProxyConnectionString, name), | ||
| }) | ||
| ); | ||
| }, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.