Skip to content

Merge SCAPI MRT backend support into main (W-24461621) - #753

Merged
vvemireddy-sf merged 9 commits into
mainfrom
feature/scapi-mrt-env
Oct 13, 2026
Merged

vvemireddy-sf merged 9 commits into
mainfrom
feature/scapi-mrt-env

Conversation

@vvemireddy-sf

Copy link
Copy Markdown
Contributor

Summary

Merges the feature/scapi-mrt-env integration branch into main, landing the
SCAPI backend support for the Managed Runtime (mrt) CLI command family
(W-24461621). This brings the accumulated SCAPI MRT work — developed and
reviewed in a series of sub-PRs — onto main as a single integration.

Included changes:

All command families honor --mrt-backend auto|legacy|scapi with safe
auto fallback to the legacy MRT Cloud API.

Note for reviewers: feature/scapi-mrt-env is currently ~19 commits
behind main and this merge surfaces conflicts (see the Testing section).
The branch needs to be synced with main and conflicts resolved before this
is mergeable.

Testing

vvemireddy-sf and others added 5 commits October 2, 2026 12:58
…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)
…732)

* Add SCAPI backend to mrt project (storefronts) commands (W-24145902)

Make the `mrt project` family (list/create/get/update/delete) backend-aware
over `--mrt-backend`. A project maps to a SCAPI storefront: the storefront ID
is the project slug and the organization is fixed by --tenant-id.

- New SDK client for the Storefront Storefronts API
  (/storefront/storefronts/v1, scopes sfcc.storefront.storefronts[.rw]).
- Backend-aware project operations in operations/mrt/project.ts: 5 SCAPI
  primitives + 5 *WithBackend wrappers routing legacy <-> SCAPI with safe auto
  fallback and a normalized MrtProjectView.
- 5 CLI commands rewritten backend-aware; backend-specific flag validation
  (legacy create needs --organization; SCAPI create needs >=1 --site, --type
  defaults to storefront_next; SCAPI update cannot rename and --site fully
  replaces the assigned-sites set). SCAPI create/delete return 202 (async).
- mrt project member / notification stay legacy-only and reject
  --mrt-backend scapi.
- Unit + MSW tests for the legacy/SCAPI/routing matrix; docs and changeset.

* Address review feedback on MRT SCAPI backend commands (W-24145902)

- access-control delete: add confirmation prompt + --force/-f flag
- redirect list: keep fromPath/toUrl column aliases; warn when --search
  is combined with the SCAPI backend (gateway does not accept it yet)
- redirect delete --json: emit identifier + backward-compatible fromPath
- redirect clone --json: synthesize {from,to,count} on SCAPI's empty 201

* review changes

* Fix legacy redirect clone crash on empty response body (W-24145902)
* Add SCAPI backend to mrt env lifecycle commands (W-24145903)

* Address PR #743 review: drop redundant jsonEnabled guard, rename clone flags type

- invalidate.ts: remove the redundant if (!this.jsonEnabled()) guard around
  the success/note log calls; MrtCommand.log() already no-ops under --json.
- env.ts / index.ts: rename interface ScapiCloneEnvironmentFlags ->
  CloneEnvironmentFlagsScapi to match the Scapi-suffix convention for
  functions/types in operations/mrt.

* Address PR #743 review: SCAPI clone --wait, serialized error cause, SCAPI invalidate ack, preserve-proxy-user-agent

- clone: implement --wait on the SCAPI backend via waitForEnvironmentScapi
  (polls building -> ready/build_failed with injectable sleep/now); drop the
  "not supported yet" warning and the legacy-only note on the flag.
- base-command: serializeErrorCause() preserves object/Error causes in the
  --json error envelope instead of stringifying to "[object Object]".
- invalidate: SCAPI returns an empty 202 (raw === null), so emit a stable
  structured ack under --json; legacy response is returned verbatim (unchanged).
- env update: add --preserve-proxy-user-agent (legacy-only), wire SDK updateEnv
  + updateEnvironmentWithBackend, add preserve_proxy_user_agent to the legacy
  MRT spec and regenerate the client.
- Tests updated/added across SDK and CLI.
@vvemireddy-sf
vvemireddy-sf requested a review from a team October 8, 2026 21:23
@vvemireddy-sf
vvemireddy-sf requested a review from clavery as a code owner October 8, 2026 21:23
@github-actions github-actions Bot added the needs-3pl-review PR introduces net-new third-party dependencies and needs discussion label Oct 8, 2026
…onflicts (W-24461621)

main reverted the SCAPI redirect + access-control work (#735) that this branch
independently re-landed (#736). Resolution keeps the feature branch's re-landed
versions for every file the revert touched (commands, SDK operations, specs,
generated client, tests, docs, skills) — main contributed no other change to
those files. The two re-land changesets (mrt-access-control-scapi,
mrt-redirect-scapi) are restored; changesets consumed by main's release (#728)
stay deleted. data/tooling/index.json was regenerated from the merged tree to
retain main's entries alongside the re-landed MRT content.

Verified: both packages typecheck clean; 388 SDK + 140 CLI MRT tests pass; lint
clean (0 errors).
@github-actions github-actions Bot removed the needs-3pl-review PR introduces net-new third-party dependencies and needs discussion label Oct 8, 2026
@vvemireddy-sf
vvemireddy-sf deployed to b2c-docs-preview October 8, 2026 21:33 — with GitHub Actions Active
@github-actions

github-actions Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

📘 Docs preview

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

@clavery

clavery commented Oct 8, 2026

Copy link
Copy Markdown
Collaborator

Thanks @vvemireddy-sf . Lets wait till both me and Kieran approval this big one. I will do some e2e testing tomorrow with it and storefront next. If possible we can get it in in-time to merge into that project too

Comment on lines 33 to 40
fromPath: {
header: 'From',
get: (r) => r.from_path ?? '-',
get: (r) => r.source || '-',
},
toUrl: {
header: 'To',
get: (r) => r.to_url ?? '-',
get: (r) => r.destination || '-',
},

@clavery clavery Oct 9, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The fromPath/toUrl aliases are real column keys, so -x renders From/To twice and --columns help lists them separately. Map the aliases to source/destination before selectColumns() instead.

const {preference, scapiConnection, legacyAuth} = this.getMrtBackendContext();
// Whether the resolved preference + config will route this run to SCAPI, so
// required fields can be validated against the backend that actually runs.
const scapi = preference === 'scapi' || (preference === 'auto' && Boolean(scapiConnection));

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Under auto with SCAPI configured, this enforces SCAPI-only requirements before anything runs, which blocks the legacy fallback (e.g. env create staging now errors "requires --name"; same in clone.ts, update.ts, project/create.ts). Enforce them only for explicit scapi and let each backend branch validate its own inputs; a shared base-class helper would also remove the four copies of this expression.

Comment thread docs/cli/mrt.md
- `b2c mrt project update` — update a project (storefront)
- `b2c mrt project delete` — delete a project (storefront)

Every other MRT command runs on the legacy MRT Cloud API. On those, `--mrt-backend scapi` errors with an actionable message, and `--mrt-backend auto` warns (only when SCAPI is actually configured) before using legacy.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This list is missing the mrt env lifecycle commands (list/create/clone/get/update/delete/invalidate/set-primary), so this line is now wrong. set-primary also has no docs section (its withDocs anchor is dead) or skill entry; regenerate the tooling index after adding them.

Comment thread .changeset/mrt-env-lifecycle-scapi.md Outdated
'@salesforce/b2c-cli': minor
---

`mrt env` lifecycle commands (`list` / `create` / `clone` / `get` / `update` / `delete` / `invalidate`) are now backend-aware: each command honors `--mrt-backend` and can run over the SCAPI Storefront Environments API (scopes `sfcc.storefront.environments` for reads, `sfcc.storefront.environments.rw` for writes) or the legacy MRT Cloud API, with `auto` falling back to legacy when no SCAPI connection is configured. On SCAPI an environment is addressed by `{organizationId, storefrontId, environmentId}`; `create` and `clone` require `--name` (display name) and provision asynchronously, `update` changes the display name only, and `createCacheInvalidation` is fire-and-forget (`202`, empty body). A new `mrt env set-primary` command promotes a ready (or build-failed) environment to primary; it is idempotent and SCAPI-only. `mrt env b2c` remains legacy-only and is unchanged.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

These mrt-* changesets are too long for release notes (scopes, 202 semantics, SDK details). Trim each to a one-line user benefit, or combine them into one, e.g. "b2c mrt env, env redirect, env access-control, and project commands can now run over SCAPI with --mrt-backend scapi|auto." Fold mrt-redirect-ach-review-fixes.md in, since those features aren't on main yet.

@@ -304,7 +309,11 @@ export abstract class MrtCommand<T extends typeof Command> extends OAuthCommand<
if (!this.supportsScapiMrt() && this.mrtBackendPreference === 'scapi') {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

detectIgnoredLegacyFlags only covers the auth flags, so command flags marked "(legacy backend only)" are silently dropped on SCAPI (e.g. project update --name sends an empty PATCH and reports success). Could commands declare their backend-specific flags and have one consistent check run after the backend is resolved, erroring on explicit scapi and warning when auto lands on the other backend?

@clavery

clavery commented Oct 9, 2026

Copy link
Copy Markdown
Collaborator

Nice work keeping the default legacy path intact: --json payloads, --columns keys, flags/aliases, and existing SDK exports all match main, and the barrels are purely additive. Remaining notes are inline and mostly about SCAPI/auto behavior.

* Print a backend-neutral environment view in a formatted table.
*/
function printEnvDetails(env: MrtEnvironment, project: string): void {
export function printEnvView(env: MrtEnvironmentView, project: string): void {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

On legacy, this shared view drops fields the old per-command printers showed (Hostname, External Host/Domain, Allow Cookies, Source Maps, Log Level, Proxies), so env get/create/update/clone lose information. Could the view carry the legacy-only fields (normalizeLegacyEnv drops them) and print them when present?

- redirect list: remap fromPath/toUrl aliases to source/destination before
  selectColumns() instead of duplicate column defs
- env create/clone/update, project create: remove premature command-level
  SCAPI gates; each SDK backend branch validates its own inputs; add shared
  mrtBackendOnlyFlags() mechanism
- mrt-command: declare backend-specific flags per command; one consistent
  check after backend resolution (error on explicit, warn on auto)
- env get: printEnvView carries and prints legacy-only fields
- docs/cli/mrt.md: add mrt env lifecycle commands to SCAPI-supported list,
  add set-primary section, regenerate tooling index; add skill entries
- changesets: trim each to a one-line user benefit; fold redirect ACH
  review-fixes changeset into the redirect/access-control changesets
@vvemireddy-sf
vvemireddy-sf deployed to b2c-docs-preview October 9, 2026 20:29 — with GitHub Actions Active
@vvemireddy-sf
vvemireddy-sf deployed to b2c-docs-preview October 13, 2026 16:08 — with GitHub Actions Active
The merge of main regenerated the MRT OpenAPI client, tightening
project_type from a loose string to ProjectTypeEnum. The pre-existing
normalizeLegacyProject test used 'sfra', which no longer typechecks
under 'tsc --noEmit -p test' (CI pretest). Use 'SSR' instead.
@vvemireddy-sf
vvemireddy-sf deployed to b2c-docs-preview October 13, 2026 16:30 — with GitHub Actions Active
@vvemireddy-sf
vvemireddy-sf merged commit d6e0208 into main Oct 13, 2026
11 checks passed
@vvemireddy-sf
vvemireddy-sf deleted the feature/scapi-mrt-env branch October 13, 2026 22:38

This branch was successfully deployed

1 active deployment
b2c-docs-preview — 7daab4fd Deployed Oct 13, 2026 by vvemireddy-sf via Remove preview on close #985
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