Repository navigation
Merge SCAPI MRT backend support into main (W-24461621) - #753
Conversation
…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.
…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).
📘 Docs preview🧹 The preview for this PR has been removed (PR closed). |
|
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 |
| fromPath: { | ||
| header: 'From', | ||
| get: (r) => r.from_path ?? '-', | ||
| get: (r) => r.source || '-', | ||
| }, | ||
| toUrl: { | ||
| header: 'To', | ||
| get: (r) => r.to_url ?? '-', | ||
| get: (r) => r.destination || '-', | ||
| }, |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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.
| - `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. |
There was a problem hiding this comment.
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.
| '@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. |
There was a problem hiding this comment.
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') { | |||
There was a problem hiding this comment.
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?
|
Nice work keeping the default legacy path intact: |
| * 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 { |
There was a problem hiding this comment.
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
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.
Summary
Merges the
feature/scapi-mrt-envintegration branch intomain, landing theSCAPI 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
mainas a single integration.Included changes:
create/get/update/delete/clone/invalidate, including SCAPI clone
--wait(
waitForEnvironmentScapi), theserializeErrorCausefix for--jsonerrorenvelopes, a backend-agnostic invalidate ack (legacy response preserved
verbatim), and the legacy-only
--preserve-proxy-user-agentflag onmrt env update.project (storefronts) commands.
re-landed SCAPI backend for access-control and redirect commands.
All command families honor
--mrt-backend auto|legacy|scapiwith safeautofallback to the legacy MRT Cloud API.Testing
(Add SCAPI backend to mrt env lifecycle commands (W-24145903) #743, Add SCAPI backend to mrt project (storefronts) commands (W-24145902) #732, Re-land SCAPI backend for mrt env access-control (W-24145908) and redirect (W-24145907) #736) against the integration branch.
b2c-tooling-sdktest/operations/mrt/env.test.ts,test/operations/mrt/project.test.ts,test/cli/base-command.test.ts; andb2c-clitest/commands/mrt/env/{update,clone,invalidate}.test.ts— allpassing. Typecheck and ESLint clean on changed files.
docs/cli/mrt.md,redirect/{clone,delete,list}.ts(+ tests),storefront-environments-v1.yaml,mrt-command.ts,storefront-environments.ts,operations/mrt/redirect.ts,skills/b2c-cli/skills/b2c-mrt/SKILL.md, and modify/delete conflicts onaccess-control/delete.ts(+ test) andoperations/mrt/redirect.test.ts(deleted on
main, modified on the branch).