Print claim URL after provisioning, expose in status#13
Merged
Conversation
After ADR-0004 (revised) the site UUID is the credential for claiming. The connector now prints the claim URL once the server provisions a new site, and the status command re-displays it on demand. The URL is constructed from the API endpoint's origin plus `/claim?site=<uuid>`. Using the endpoint origin (rather than a hard-coded https://app.patchstack.com) means the connector produces the right URL whether it is talking to production, a staging deploy, an ngrok tunnel, or a local mock server. - New buildClaimUrl(endpoint, siteUuid) helper in client.ts, also exported from the public API. - runScan prints the URL right after the manifest-stored message, but only on the provisioning path (first scan of a fresh project). - runStatus shows a Claim URL line whenever a UUID is configured. - 6 new tests cover origin extraction, staging hosts, trailing slashes, scheme preservation, and URL encoding. Suite is 51 green. No state added to .patchstackrc.json — the claim URL is reconstructible from siteUuid + endpoint and is never persisted. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
mariojgt
approved these changes
May 13, 2026
ejntaylor
added a commit
that referenced
this pull request
May 13, 2026
…PS (#14) Two minor URL corrections that should have landed together in #13: - Claim URL: the SaaS claim page is at /monitor/claim alongside the other Pulse portal routes, not at /claim on the root. - Default endpoint: was http://api.patchstack.com (HTTP). Browsers will redirect to HTTPS at the server, but printing an http:// link in the build log is sloppy. Tests updated; help text and README brought in line. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Implements the connector-side half of the claim flow agreed in ADR-0004.
npx @patchstack/connect statusre-displays the claim URL whenever a UUID is configured./claim?site=<uuid>— works for production, staging, ngrok and local mock servers without code changes.Why
ADR-0004 (revised in saas#508) decides:
This PR is the connector half of that decision. The matching SaaS work — adding the
GET /claim?site=<uuid>page and the authenticatedPOST /claimroute — lands separately on the SaaS side. Until that ships, clicking the URL will 404; the connector printing it does no harm and makes the connector ready as soon as the SaaS endpoint goes live.What's in it
src/client.ts— newbuildClaimUrl(endpoint, siteUuid)helper alongsidebuildEndpointUrl. Usesnew URL(endpoint).originto extract the host part, so changing the API path doesn't break the claim URL.src/cli.ts—runScanprints the URL after the manifest-stored message, only on the provisioning path (first scan of a fresh project).runStatusshows aClaim URL:line whenever a UUID is configured.src/index.ts— exportsbuildClaimUrlfor programmatic consumers.tests/client.test.ts— 6 new tests cover origin extraction, ngrok-style hosts, trailing slashes, scheme preservation (http vs https), URL encoding of the UUID, and dropping deep paths from the endpoint. Suite is 51 green.README.md— adds the claim step to the "Quick start (zero configuration)" walkthrough.What's deliberately not in it
.patchstackrc.json. The claim URL is reconstructible fromsiteUuid+endpointand is never persisted. ADR-0004 explicitly avoids storing claim state in source control.claimed: true, connector suppresses the link). For MVP the URL is informational; the/claimpage tells a user "already claimed" if they reach it after the site is taken.GET/POST /claimseparately. The connector PR is independent and harmless until then.Output sample
Test plan
npx vitest run— 51/51 passingnpx tsc --noEmit— cleanscanandstatus/claimroute lands, click the URL from a real provisioning scan and confirm the round-trip🤖 Generated with Claude Code