Commit e8f22b7
feat(project-engine-client): add GET /v1/url/resolve to the vendored client + mock (#1771)
<!-- mysticat-pr-skill -->
## 1. Abstract
Adds the Semrush Project Engine `GET /v1/url/resolve` endpoint to the
vendored `spacecat-shared-project-engine-client` — its generated types,
the spec overlay, and the stateful Counterfact mock. This is §1 of the
cross-repo brand-URL normalization spec.
## 2. Reasoning
When we add a brand URL to a Semrush AIO project we currently send the
raw URL verbatim (e.g. `https://www.lovesac.com`). Semrush stores brand
URLs in a canonical, scheme-less form (`lovesac.com`) and its own
frontend normalizes first by calling the Project Engine URL-resolve
endpoint before writing. Sending the raw URL produces a
duplicate/mismatched brand-URL entry that does not line up with the
canonical benchmark Semrush already holds. Fixing that requires the
endpoint to exist in the vendored typed client first — this PR is that
prerequisite. Reported by the Semrush team in the Elements-wrappers
review thread (2026-07-02/03); the live contract was captured directly
against prod.
## 3. High-level overview of the changes
Models a live endpoint that is absent from the vendored swagger,
following the established overlay + regenerate + mock pattern (precedent
CR1/CR8). No consumer-facing client code changes — the client is a thin
generic `openapi-fetch` wrapper, so once the path is in the generated
types a caller just does `client.GET('/v1/url/resolve', { params: {
query: { primary_url } } })`.
- **Spec overlay (CR16):** adds a `model.UrlResolveResponse` schema (`{
domain, primary_url, is_valid }`, all required) and the `GET
/v1/url/resolve` path (query param `primary_url` required,
`200`/`400`/`401` responses). Regenerating from the overlay updates
`src/generated/types.ts` and the pydantic models; the regen also catches
up a previously-stale pydantic artifact (a CR14 field that had only been
regenerated into the TS types).
- **Mock behaviour (before → after):** the endpoint did not exist → the
mock now canonicalizes `primary_url`. It strips the scheme and a leading
`www.` while preserving any other subdomain and the path
(`http://www.lovesac.com/products` → `lovesac.com/products`;
`blog.hubspot.com` stays `blog.hubspot.com`); `domain` is the
registrable apex (subdomain stripped too). Unresolvable/garbage input
returns `{ domain: '', primary_url: '', is_valid: false }` at HTTP `200`
— never an error — matching the live trap that consumers must check
`is_valid`.
- The canonicalization is a pure, unit-tested helper
(`mock/url-resolve.js`) exposed on the mock context like the existing
`tagId`/`parentIdField` helpers, rather than logic buried in the
coverage-excluded route handler.
- Endpoint inventory in `docs/mock-usage.md` updated to list the new
route.
Two intentional, documented mock simplifications: the apex is the last
two dot-labels (so a multi-part public suffix like `example.co.uk`
collapses to `co.uk`, unlike live's PSL), and an empty `primary_url=`
returns `200 is_valid:false` rather than `400` (Counterfact enforces the
`required` presence — a missing param still `400`s — but not the string
`minLength`).
## 4. Required information
- Spec: adobe/serenity-docs#25
- Other: brand-URL normalization tracked alongside the Serenity
mapping-table work adobe/serenity-docs#23
## 5. Affected / used mysticat-workspace projects
- `spacecat-api-service` — will consume this endpoint (§2 of the spec):
a new `resolveUrl` transport method + resolve-before-write on the
brand-URL CREATE/EDIT paths. Blocked on this package being released
(contract dependency).
- `mysticat-data-service` — the Serenity migration CLI (§3, on the
`feat/customer_onboarding` branch / #737) will add the same
`resolve_url` call. Also blocked on this release.
## 6. Additional information outside the code
- Booted the stateful Counterfact mock (`npm run test:e2e`) and drove
the new `/v1/url/resolve` route end-to-end through the real
`createSerenityProjectEngineApiClient` — verified the canonical case,
the subdomain/path-preserving case, the `is_valid:false` garbage case
(HTTP 200), and the missing-vs-empty `primary_url` request-validation
behaviour.
- The live contract behind the mock was captured directly against prod
Project Engine (`https://adobe-hackathon.semrush.com`) with a real IMS
bearer (serenity-docs#25 §0) — method, param, response shape, error
codes, and the `is_valid:false` empty-string trap are ground truth, not
assumptions.
## 7. Test plan
- (a) Local: unit suite plus the offline overlay freshness gate (asserts
CR16 both applies and is necessary against the vendored swagger), and
the `MOCK_E2E=1` end-to-end suite driving the booted mock through the
typed client — all exercised locally.
- (b) Per-env: this package ships no runtime service, so there is no
eph/dev/stage/prod deploy to verify. After merge, semantic-release
publishes a new npm version and the GHCR mock Docker image republishes
on the release tag; consumers verify by bumping
`@adobe/spacecat-shared-project-engine-client` and calling
`client.GET('/v1/url/resolve', { params: { query: { primary_url } } })`
against the published mock image in their integration tests.
## 8. Deployment & merge order
- This PR is the hard prerequisite for the rest of serenity-docs#25 — it
must merge and release (npm + GHCR mock image) first.
- After release: the api-service change (§2) bumps the dependency and
adds the resolve-before-write; the migration CLI change (§3) does the
same. Both are `related` and neither can build/test until this version
publishes.
Ordered sequence: merge + release this PR → api-service §2 + migration
§3 bump the dep and proceed in parallel.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 75e9204 commit e8f22b7
16 files changed
Lines changed: 471 additions & 4 deletions
File tree
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
| 138 | + | |
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
| |||
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| 50 | + | |
50 | 51 | | |
51 | 52 | | |
52 | 53 | | |
| |||
104 | 105 | | |
105 | 106 | | |
106 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
107 | 113 | | |
108 | 114 | | |
109 | 115 | | |
| |||
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
Lines changed: 16 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
41 | 41 | | |
42 | 42 | | |
43 | 43 | | |
| 44 | + | |
44 | 45 | | |
45 | 46 | | |
46 | 47 | | |
| |||
428 | 429 | | |
429 | 430 | | |
430 | 431 | | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
Lines changed: 79 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 69 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
81 | 81 | | |
82 | 82 | | |
83 | 83 | | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
84 | 93 | | |
85 | 94 | | |
86 | 95 | | |
| |||
415 | 424 | | |
416 | 425 | | |
417 | 426 | | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
0 commit comments