feat(vercel-deployments)!: resolve the deployment target per request - #200
Draft
jhb-dev wants to merge 3 commits into
Draft
feat(vercel-deployments)!: resolve the deployment target per request#200jhb-dev wants to merge 3 commits into
jhb-dev wants to merge 3 commits into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What
BREAKING: the Vercel project and the website URL move into a single required
deploymentTargetoption, which also accepts a function resolved against the current request. A multi-tenant admin panel can therefore report and deploy the Vercel project of the tenant currently selected.Migration is mechanical: move
vercel.projectIdandwidget.websiteUrlintodeploymentTarget. The option is required, so a config without a target no longer compiles.One option instead of three keeps the config honest —
vercelholds credentials and scope,deploymentTargetsays what to deploy,widgetstays presentational.websiteUrlis data about the target, not a widget setting.Behaviour when nothing resolves
A
projectIdofundefinedmeans the request has no deployment target:GETdeployments andPOSTtrigger-deployment answer400instead of querying Vercel for a missing projectA tenant that has not been deployed yet therefore needs no special casing.
Robustness and cost
500with the message, and the widget renders the error row instead of taking the dashboard down.GET ?id=<deploymentId>resolves no target at all — it addresses a deployment directly. This is the path the poller hits every 5s during a build.Tests
src/utilities/resolveTarget.test.ts— static targets, per-request resolution from a single lookup, and the no-project casesrc/endpoints/endpoints.test.ts— the resolved project reaches the Vercel request, the unresolved-target400s, the?id=path skipping resolution, and a throwing resolver answering500Dev app demonstration
dev/gains atenantscollection (withvercelProjectId/websiteUrl) plusposts, and wires@payloadcms/plugin-multi-tenantintodev/src/payload.config.ts. Two tenants are seeded:Acme(deployed) andNot deployed yet. Switching the tenant in the admin panel switches the deployments the widget shows; the deploy button disappears for the undeployed one. The resolver usesselect+depth: 0anddisableErrors: true, which is also the pattern the README documents.