Skip to content
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

Support wrangler types for Pipelines #8528

Merged
merged 2 commits into from
Mar 20, 2025
Merged

Support wrangler types for Pipelines #8528

merged 2 commits into from
Mar 20, 2025

Conversation

cmackenzie1
Copy link
Contributor

Adds support for wrangler types command to generate the necessary types for Workers Pipelines.

Fixes https://jira.cfdata.org/browse/PIPE-181


  • Tests
    • TODO (before merge)
    • Tests included
    • Tests not necessary because:
  • Wrangler E2E Tests CI Job required? (Use "e2e" label or ask maintainer to run separately)
    • I don't know
    • Required
    • Not required because: type generation tests cover this
  • Public documentation
    • TODO (before merge)
    • Cloudflare docs PR(s):
    • Documentation not necessary because: covered by existing docs wrangler types -h

Sorry, something went wrong.

@cmackenzie1 cmackenzie1 requested a review from a team as a code owner March 17, 2025 17:35
Copy link

changeset-bot bot commented Mar 17, 2025

🦋 Changeset detected

Latest commit: 32ba1cc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
wrangler Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cmackenzie1 cmackenzie1 self-assigned this Mar 17, 2025
@cmackenzie1 cmackenzie1 requested review from oliy and hhoughgg March 17, 2025 17:36
@cmackenzie1
Copy link
Contributor Author

cmackenzie1 commented Mar 17, 2025

This type was recently moved into "cloudflare:pipelines". Does this change anything? I didn't see any examples of using a namespaced type in the file for mapping bindings to types.

cloudflare/workerd#3696

Copy link
Contributor

github-actions bot commented Mar 17, 2025

A wrangler prerelease is available for testing. You can install this latest build in your project with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13969709083/npm-package-wrangler-8528

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/8528/npm-package-wrangler-8528

Or you can use npx with this latest build directly:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13969709083/npm-package-wrangler-8528 dev path/to/script.js
Additional artifacts:

cloudflare-workers-bindings-extension:

wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13969709083/npm-package-cloudflare-workers-bindings-extension-8528 -O ./cloudflare-workers-bindings-extension.0.0.0-v7dcdd42d2.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-v7dcdd42d2.vsix

create-cloudflare:

npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13969709083/npm-package-create-cloudflare-8528 --no-auto-update

@cloudflare/kv-asset-handler:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13969709083/npm-package-cloudflare-kv-asset-handler-8528

miniflare:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13969709083/npm-package-miniflare-8528

@cloudflare/pages-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13969709083/npm-package-cloudflare-pages-shared-8528

@cloudflare/unenv-preset:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13969709083/npm-package-cloudflare-unenv-preset-8528

@cloudflare/vite-plugin:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13969709083/npm-package-cloudflare-vite-plugin-8528

@cloudflare/vitest-pool-workers:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13969709083/npm-package-cloudflare-vitest-pool-workers-8528

@cloudflare/workers-editor-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13969709083/npm-package-cloudflare-workers-editor-shared-8528

@cloudflare/workers-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13969709083/npm-package-cloudflare-workers-shared-8528

@cloudflare/workflows-shared:

npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/13969709083/npm-package-cloudflare-workflows-shared-8528

Note that these links will no longer work once the GitHub Actions artifact expires.


wrangler@4.2.0 includes the following runtime dependencies:

Package Constraint Resolved
miniflare workspace:* 4.20250317.1
workerd 1.20250319.0 1.20250319.0
workerd --version 1.20250319.0 2025-03-19

Please ensure constraints are pinned, and miniflare/workerd minor versions match.

@@ -511,6 +512,12 @@ export async function generateEnvTypes(
}
}

if (configToDTS.pipelines) {
for (const pipeline of configToDTS.pipelines) {
envTypeStructure.push([constructTypeKey(pipeline.binding), "Pipeline"]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't work, sine the Pipeline type isn't available globally anymore, as far as I know. This will need to be import("cloudflare:pipelines").Pipeline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated!

for (const pipeline of configToDTS.pipelines) {
envTypeStructure.push([
constructTypeKey(pipeline.binding),
`import("cloudflare:pipelines").Pipeline`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having tested this, this actually needs to be:

import("cloudflare:pipelines").Pipeline<
		import("cloudflare:pipelines").PipelineRecord
	>

because the Pipeline interface has no default for the generic. Is that intentional?

penalosa
penalosa previously approved these changes Mar 19, 2025
@penalosa
Copy link
Contributor

Pending internal discussion, this shouldn't be merged yet

@penalosa penalosa dismissed their stale review March 19, 2025 11:32

Pending internal discussion

cmackenzie1 and others added 2 commits March 20, 2025 12:49

Partially verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
Adds support for `wrangler types` command to generate the necessary types for Workers Pipelines.

Closes: https://jira.cfdata.org/browse/PIPE-181

Create swift-beers-battle.md
@penalosa penalosa added the skip-pr-description-validation Skip validation of the required PR description format label Mar 20, 2025
@penalosa penalosa merged commit 2a43cdc into main Mar 20, 2025
33 of 35 checks passed
@penalosa penalosa deleted the cole/pipelines branch March 20, 2025 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip-pr-description-validation Skip validation of the required PR description format skip-v3-pr Skip validation of presence of a v3 backport PR
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

3 participants