Skip to content

Add SCAPI backend + get/update to mrt env redirect (W-24145907) - #729

Merged
vvemireddy-sf merged 3 commits into
mainfrom
W-24145907-redirect-scapi
Oct 2, 2026
Merged

vvemireddy-sf merged 3 commits into
mainfrom
W-24145907-redirect-scapi

Conversation

@vvemireddy-sf

@vvemireddy-sf vvemireddy-sf commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Makes the mrt env redirect command family backend-aware between the legacy MRT Cloud API and the SCAPI Storefront Environments API, and adds two new subcommands (get, update) so all six redirect operations — list / create / get / update / delete / clone — are reachable over SCAPI. Each command honors --mrt-backend and, over SCAPI, uses scopes sfcc.storefront.environments for reads and sfcc.storefront.environments.rw for writes. Under auto, SCAPI is used when configured with a safe fallback to legacy; explicit --mrt-backend scapi fails loud rather than silently downgrading. This follows the same pattern as the merged access-control SCAPI migration (#722).

The two backends identify a redirect differently — legacy keys on the source path (from_path), SCAPI keys on a redirect ID (UUID) — so get / update / delete take a neutral identifier positional. update is a partial update (only supplied fields change; the source path cannot be changed) and clone rejects a same-source clone.

Work item: W-24145907.

Changes

  • SDK (b2c-tooling-sdk): added the redirect paths/ops and schemas to specs/storefront-environments-v1.yaml, regenerated storefront-environments.generated.ts, exported the new types, and added the 6 *Scapi operations + normalizers and the 6 backend-aware *WithBackend wrappers (routing via runMrtWithFallback). Updated mrt-command.ts for the new supported family.
  • CLI (b2c-cli): rewrote list / create / delete / clone backend-aware; added get / update (delete gated by assertDestructiveOperationAllowed; clone rejects same-source before touching the backend). --json returns the serving backend's native response verbatim.
  • Docs / bookkeeping: updated docs/cli/mrt.md, the b2c-mrt skill (SKILL.md, ENVIRONMENT-COMMANDS.md), regenerated the tooling-index, and added a minor/minor changeset.

Testing

  • pnpm --filter @salesforce/b2c-tooling-sdk exec mocha on test/operations/mrt/redirect.test.ts — 34 passing (MSW: legacy ops, 6 SCAPI ops incl. the empty-201 clone + errors, and the scapi/legacy/auto-fallback/explicit-fail-loud routing matrix).
  • pnpm --filter @salesforce/b2c-cli exec mocha on test/commands/mrt/env/redirect/*.test.ts — 30 passing (sinon: arg/flag validation, backend-context forwarding, --json raw passthrough, non-JSON detail render, partial-update guard, same-source clone rejection, destructive-mode guard).
  • Repo-wide pnpm run lint:agent — clean.
  • SDK typecheck (typecheck:agent) and CLI test typecheck (tsc --noEmit -p test) — clean; both packages build cleanly.

Did not run the full test suite; validation was targeted to the changed SDK operations and CLI commands plus lint/typecheck.

Screenshot 2026-10-01 at 2 23 53 PM Screenshot 2026-10-01 at 2 24 23 PM Screenshot 2026-10-01 at 2 24 48 PM

Here are the commands for testing(Below project and target are in zymb_006):

`

1. LIST — baseline

./bin/dev.js mrt env redirect list -p teststorefron-715281 -e teststoref-8094fde3 --mrt-backend legacy --cloud-origin https://cloud-soak.mrt-soak.com

2. CREATE — permanent 301 (default)

./bin/dev.js mrt env redirect create -p teststorefron-715281 -e teststoref-8094fde3 --from "/old-page" --to "/new-page" --mrt-backend legacy --cloud-origin https://cloud-soak.mrt-soak.com

2b. CREATE — temporary 302 with query-string + wildcard forwarding

./bin/dev.js mrt env redirect create -p teststorefron-715281 -e teststoref-8094fde3 --from "/legacy/*" --to "/modern/$1" --status 302 --forward-querystring --forward-wildcard --mrt-backend legacy --cloud-origin https://cloud-soak.mrt-soak.com

3. GET — identify by SOURCE PATH on legacy

./bin/dev.js mrt env redirect get "/old-page" -p teststorefron-715281 -e teststoref-8094fde3 --mrt-backend legacy --cloud-origin https://cloud-soak.mrt-soak.com

4. UPDATE — partial: change only the destination (identify by source path)

./bin/dev.js mrt env redirect update "/old-page" -p teststorefron-715281 -e teststoref-8094fde3 --to "/newest-page" --mrt-backend legacy --cloud-origin https://cloud-soak.mrt-soak.com

4b. UPDATE — change status and disable query-string forwarding (verifies --no- flags)

./bin/dev.js mrt env redirect update "/legacy/*" -p teststorefron-715281 -e teststoref-8094fde3 --status 301 --no-forward-querystring --mrt-backend legacy --cloud-origin https://cloud-soak.mrt-soak.com

5. DELETE — by source path (--force skips the confirm prompt)

./bin/dev.js mrt env redirect delete "/old-page" -p teststorefron-715281 -e teststoref-8094fde3 --force --mrt-backend legacy --cloud-origin https://cloud-soak.mrt-soak.com

Clone needs a second, distinct environment in the same project:

6. CLONE — copies all redirects from --from into --to (must differ)

./bin/dev.js mrt env redirect clone -p teststorefron-715281 --from teststoref-8094fde3 --to teststoref-c3c38423 --force --mrt-backend legacy --cloud-origin https://cloud-soak.mrt-soak.com

6b. CLONE same-source rejection — should error "must differ" before touching the backend

./bin/dev.js mrt env redirect clone -p teststorefron-715281 --from teststoref-8094fde3 --to teststoref-8094fde3 --force --mrt-backend legacy --cloud-origin https://cloud-soak.mrt-soak.com

--mrt-backend legacy --cloud-origin https://cloud-soak.mrt-soak.com

3. GET — identify by SOURCE PATH on legacy

./bin/dev.js mrt env redirect get "/old-page" -p teststorefron-715281 -e teststoref-8094fde3 --mrt-backend legacy --cloud-origin https://cloud-soak.mrt-soak.com

4. UPDATE — partial: change only the destination (identify by source path)

./bin/dev.js mrt env redirect update "/old-page" -p teststorefron-715281 -e teststoref-8094fde3 --to "/newest-page" --mrt-backend legacy --cloud-origin https://cloud-soak.mrt-soak.com

4b. UPDATE — change status and disable query-string forwarding (verifies --no- flags)

./bin/dev.js mrt env redirect update "/legacy/*" -p teststorefron-715281 -e teststoref-8094fde3 --status 301 --no-forward-querystring --mrt-backend legacy --cloud-origin https://cloud-soak.mrt-soak.com

5. DELETE — by source path (--force skips the confirm prompt)

./bin/dev.js mrt env redirect delete "/old-page" -p teststorefron-715281 -e teststoref-8094fde3 --force --mrt-backend legacy --cloud-origin https://cloud-soak.mrt-soak.com

Clone needs a second, distinct environment in the same project:

6. CLONE — copies all redirects from --from into --to (must differ)

./bin/dev.js mrt env redirect clone -p teststorefron-715281 --from teststoref-8094fde3 --to teststoref-c3c38423 --force --mrt-backend legacy --cloud-origin https://cloud-soak.mrt-soak.com

6b. CLONE same-source rejection — should error "must differ" before touching the backend

./bin/dev.js mrt env redirect clone -p teststorefron-715281 --from teststoref-8094fde3 --to teststoref-8094fde3 --force --mrt-backend legacy --cloud-origin https://cloud-soak.mrt-soak.com`

Make the `mrt env redirect` command family backend-aware between the legacy
MRT Cloud API and the SCAPI Storefront Environments API, and add two new
subcommands (`get`, `update`) so all six redirect operations are reachable
over SCAPI.

- SDK: add the redirect paths/schemas to the storefront environments spec,
  regenerate the client types, export the new types, and add the 6 *Scapi
  operations + normalizers and the 6 backend-aware *WithBackend wrappers
  (auto fallback, fail-loud on explicit scapi). Update mrt-command.ts for the
  new supported family.
- CLI: rewrite list/create/delete/clone backend-aware; add get/update. The
  neutral `identifier` positional maps to the source path on legacy and the
  redirect ID (UUID) on SCAPI. update is a partial update; clone rejects a
  same-source clone.
- Tests: SDK (MSW) + CLI (sinon) covering legacy, SCAPI, and the backend
  routing matrix.
- Docs, tooling-index, and changeset updated.
Comment on lines 31 to 38
from: Flags.string({
description: 'Source path to redirect from',
required: true,
}),
to: Flags.string({
description: 'Destination URL to redirect to',
required: true,
}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Since the SCAPI api accept source and destination instead of fromPath and toUrl, can we add source and destination as aliases here?

@kieran-sf
kieran-sf marked this pull request as ready for review October 2, 2026 17:10
@kieran-sf
kieran-sf requested a review from clavery as a code owner October 2, 2026 17:10
@kieran-sf
kieran-sf deployed to b2c-docs-preview October 2, 2026 17:10 — with GitHub Actions Active
@github-actions

github-actions Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

📘 Docs preview

🧹 The preview for this PR has been removed (PR closed).

@vvemireddy-sf
vvemireddy-sf merged commit 515c206 into main Oct 2, 2026
15 checks passed
@vvemireddy-sf
vvemireddy-sf deleted the W-24145907-redirect-scapi branch October 2, 2026 17:57
@vvemireddy-sf
vvemireddy-sf deployed to b2c-docs-preview October 2, 2026 17:57 — with GitHub Actions Active
vvemireddy-sf added a commit that referenced this pull request Oct 2, 2026
vvemireddy-sf added a commit that referenced this pull request Oct 2, 2026
* Add SCAPI backend + get/update to mrt env redirect (W-24145907)

Make the `mrt env redirect` command family backend-aware between the legacy
MRT Cloud API and the SCAPI Storefront Environments API, and add two new
subcommands (`get`, `update`) so all six redirect operations are reachable
over SCAPI.

- SDK: add the redirect paths/schemas to the storefront environments spec,
  regenerate the client types, export the new types, and add the 6 *Scapi
  operations + normalizers and the 6 backend-aware *WithBackend wrappers
  (auto fallback, fail-loud on explicit scapi). Update mrt-command.ts for the
  new supported family.
- CLI: rewrite list/create/delete/clone backend-aware; add get/update. The
  neutral `identifier` positional maps to the source path on legacy and the
  redirect ID (UUID) on SCAPI. update is a partial update; clone rejects a
  same-source clone.
- Tests: SDK (MSW) + CLI (sinon) covering legacy, SCAPI, and the backend
  routing matrix.
- Docs, tooling-index, and changeset updated.

* docs: add redirect and access-control families to the SCAPI-supported commands list

* Add --source/--destination aliases for redirect create --from/--to (W-24145907)
vvemireddy-sf added a commit that referenced this pull request Oct 2, 2026
…722) (#735)

* Revert "Add SCAPI backend + get/update to mrt env redirect (W-24145907) (#729)"

This reverts commit 515c206.

* Revert "Add SCAPI backend + full CRUD to mrt env access-control (W-24145908) (#722)"

This reverts commit aa1c66f.
vvemireddy-sf added a commit that referenced this pull request Oct 2, 2026
…irect (W-24145907) (#736)

* Add SCAPI backend + full CRUD to mrt env access-control (W-24145908) (#722)

Expand the `mrt env access-control` command family from list-only to full
CRUD (list/create/get/delete), making each command backend-aware between the
legacy MRT Cloud API and the SCAPI Storefront Environments API.

- SDK: add the 4 access-control-header paths/schemas to the storefront
  environments spec, regenerate the client types, add the 4 *Scapi ops and
  their normalizers, and add backend-aware *WithBackend wrappers (auto
  fallback, fail-loud on explicit scapi).
- CLI: rewrite list backend-aware; add create/get/delete commands.
- Tests: SDK (MSW) + CLI (sinon) covering legacy, SCAPI, and the backend
  routing matrix.
- Docs, tooling-index, and changeset updated.

* Add SCAPI backend + get/update to mrt env redirect (W-24145907) (#729)

* Add SCAPI backend + get/update to mrt env redirect (W-24145907)

Make the `mrt env redirect` command family backend-aware between the legacy
MRT Cloud API and the SCAPI Storefront Environments API, and add two new
subcommands (`get`, `update`) so all six redirect operations are reachable
over SCAPI.

- SDK: add the redirect paths/schemas to the storefront environments spec,
  regenerate the client types, export the new types, and add the 6 *Scapi
  operations + normalizers and the 6 backend-aware *WithBackend wrappers
  (auto fallback, fail-loud on explicit scapi). Update mrt-command.ts for the
  new supported family.
- CLI: rewrite list/create/delete/clone backend-aware; add get/update. The
  neutral `identifier` positional maps to the source path on legacy and the
  redirect ID (UUID) on SCAPI. update is a partial update; clone rejects a
  same-source clone.
- Tests: SDK (MSW) + CLI (sinon) covering legacy, SCAPI, and the backend
  routing matrix.
- Docs, tooling-index, and changeset updated.

* docs: add redirect and access-control families to the SCAPI-supported commands list

* Add --source/--destination aliases for redirect create --from/--to (W-24145907)

This branch was successfully deployed

1 active deployment
b2c-docs-preview — 62e800fd Deployed Oct 2, 2026 by vvemireddy-sf via Remove preview on close #821
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants