Commit a26226c
authored
Add bm users/whoami/access-key commands + CLI table flag consistency (#408)
* Add bm users/whoami/access-key commands + table flag consistency
Adds full Business Manager Data API user administration to the CLI:
- bm users list/get/search/update/delete (OCAPI /users, /user_search)
- bm whoami (OCAPI /users/this — defaults to user-auth)
- bm access-key get/create/set/delete (OCAPI /users/{login}/access_key/{scope};
optional [LOGIN] defaults to whoami; --scope is an enum with
WEBDAV_AND_STUDIO as the default)
A new SDK module @salesforce/b2c-tooling-sdk/operations/bm-users wraps
the underlying endpoints. Endpoints whose OCAPI documentation states
"a valid user is required" (whoami + access-key) extend a shared
BmUserAuthCommand base which defaults the auth-method priority to
['implicit'] so a fresh shell triggers browser login rather than
failing the API call with UserNotAvailableException.
Also reworks tabular output across the CLI for consistency:
- New SDK helpers columnFlagsFor() / selectColumns() replace 22 copies
of an identical getSelectedColumns() helper. printFieldsBlock() does
the same for *Get-style label/value detail blocks (5 commands).
- Adds --columns / --extended to ~30 list and search commands that
previously had no column-customization (bm roles list, webdav ls,
cap list, code list, content list, docs search, job search, logs list,
sites list, slas client list, every mrt/* list command, plus several
setup and scaffold commands). webdav ls --extended now exposes the
previously-hidden modified and contentType columns.
- Renames --confirm to --force on the new bm/users delete commands to
match the dominant codebase convention.
Skills + docs: new b2c-cli:b2c-bm-users-roles skill and a rewritten
docs/cli/bm.md page cover the four bm command groups and the user-auth
defaulting. The b2c-am skill now defers to the new BM skill.
* Migrate bm delete commands to canonical ux/confirm helper
Switches bm/users/delete and bm/access-key/delete from @inquirer/prompts
to the SDK's @salesforce/b2c-tooling-sdk/ux confirm() introduced in main.
Drops the @inquirer/prompts dependency from these two files.
* Audit pass: hoist scope enum, extend helpers to MRT, migrate confirms
Acts on findings from a post-merge audit covering both this branch and
recently-merged main work:
SDK:
- Export ACCESS_KEY_SCOPES + AccessKeyScope from operations/bm-users so
the 4 access-key CLI commands no longer redeclare the same tuple.
- Refresh stale doc comment on getBmUserAccessKey (referenced removed
example values 'WEBDAV', 'OCAPI', 'SCAPI').
- printFieldsBlock now accepts null in addition to undefined and
skips both, matching the common shape of optional OpenAPI fields.
New DetailValue type alias exported.
CLI — apply our helpers to MRT commands main introduced in PR #407:
- mrt/org/cert/list and mrt/org/member/list now use TableRenderer +
columnFlagsFor + selectColumns instead of inline createTable.
- mrt/org/cert/get and mrt/org/member/get now use printFieldsBlock
instead of inline cliui label/value rendering.
CLI — finish the @inquirer/prompts -> SDK ux migration begun in main:
- setup, setup/instance/remove, sandbox/reset, sandbox/alias/delete,
and mrt/env/var/push now use confirm() from
@salesforce/b2c-tooling-sdk/ux. The two remaining @inquirer/prompts
importers (setup/skills, setup/instance/create) need more than just
confirm so they stay as-is for now.
* Add tests for bm whoami, bm users, and bm access-key commands
10 new test files following the bm/roles test patterns. Each covers:
JSON-mode return shape, non-JSON output (where applicable),
flag/arg behavior, and OCAPI error paths via the expectError helper.
- whoami.test.ts (3 cases)
- users/{list,get,delete}.test.ts (3 cases each)
- users/search.test.ts (5 cases — covers convenience flags, raw --query
passthrough, and invalid JSON rejection)
- users/update.test.ts (4 cases — covers the field→snake_case mapping
and "no fields" guard)
- access-key/{get,delete}.test.ts cover both the explicit-login and
whoami-fallback branches via two-call OCAPI stubs
- access-key/{create,set}.test.ts cover scope flag and PATCH body shape
CLI tests now: 1218 passing (was 1184). SDK tests unchanged at 1722.
* Strengthen authentication coverage in bm CLI docs
bm.md:
- Lead the Authentication section with the two flows (client-credentials
vs user-auth) and explicit setup before the "defaults" table.
- Document --user-auth, --auth-methods, and SFCC_AUTH_METHODS overrides
with concrete examples.
- Annotate the OCAPI permissions table with which command uses each
resource so readers know what to grant.
- Add a dedicated subsection on the Manage_Users_Access_Keys BM
functional permission required for access-key writes.
- Add Configuration Examples block.
authentication.md:
- Add "BM administration" entry under "Minimal Configuration by Feature"
with the importable JSON snippet covering /roles, /users, /users/this,
/users/*/access_key/*, and /user_search.
- Add a tip box explaining the user-identity requirement on whoami /
access-key endpoints and cross-link back to /cli/bm#authentication.
Both pages now properly cross-link to each other.1 parent f1a4ac0 commit a26226c
116 files changed
Lines changed: 4085 additions & 1751 deletions
File tree
- .changeset
- docs
- .vitepress
- cli
- guide
- packages
- b2c-cli
- src
- commands
- am
- clients
- orgs
- roles
- users
- bm
- access-key
- roles
- users
- cap
- code
- content
- docs
- ecdn
- certificates
- logpush/jobs
- mtls
- page-shield
- notifications
- policies
- scripts
- waf
- groups
- managed-rules
- rulesets
- rules
- zones
- job
- logs
- mrt
- bundle
- env
- access-control
- redirect
- var
- org
- cert
- member
- project
- member
- notification
- user
- sandbox
- alias
- clone
- operations
- scaffold
- scapi
- custom
- replications
- schemas
- setup
- instance
- sites
- slas/client
- webdav
- utils
- am
- bm
- test/commands
- am
- roles
- users
- bm
- access-key
- users
- ecdn
- certificates
- logpush/jobs
- mtls
- page-shield
- notifications
- policies
- scripts
- zones
- sandbox
- scapi/replications
- b2c-tooling-sdk
- src
- cli
- operations/bm-users
- skills/b2c-cli/skills
- b2c-am
- b2c-bm-users-roles
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
| 105 | + | |
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
| |||
This file was deleted.
0 commit comments