@W-21112167 adding replications api#215
Conversation
clavery
left a comment
There was a problem hiding this comment.
Code Review — DRY Issues
Overall the PR is well-structured and follows established patterns. The SDK client, generated types, tests, and docs all look good. I found a few DRY issues that should be addressed:
1. getTenantId() duplicates inherited requireTenantId()
packages/b2c-cli/src/utils/scapi/replications.ts:59-70
GranularReplicationsCommand.getTenantId() is a near-exact copy of OAuthCommand.requireTenantId() (packages/b2c-tooling-sdk/src/cli/oauth-command.ts:215-227). Every other command family (SLAS, CIP, etc.) uses the inherited method.
Fix: Delete getTenantId() and use this.requireTenantId(). Update the internal call in the granularReplicationsClient getter.
2. getOrganizationId() duplicated across 3 base commands
All three of these do the same thing — validate tenantId then call toOrganizationId():
packages/b2c-cli/src/utils/scapi/replications.ts:51-53packages/b2c-cli/src/utils/scapi/schemas.ts:32-43packages/b2c-cli/src/utils/ecdn/base-command.ts:90-101
Fix: Promote getOrganizationId() to OAuthCommand in the SDK (it already has requireTenantId() and access to toOrganizationId). Remove all 3 copies.
3. getSelectedColumns() missing column validation
packages/b2c-cli/src/commands/scapi/replications/list.ts:114-130
The replications version doesn't call tableRenderer.validateColumnKeys() on user input, unlike every other list command (schemas list, ecdn zones list, custom status). Invalid column names silently pass through instead of warning the user.
Also: tableRenderer should be a module-level const rather than created inside run(), matching the established pattern in schemas/ecdn/custom list commands.
4. shortCode error message is inconsistent and incorrect
packages/b2c-cli/src/utils/scapi/replications.ts:37
The error is a hardcoded raw string: 'shortCode configuration is required. Run: b2c config:set --short-code <code>'
config:setis not a valid command- The ecdn and schemas base commands use
t('error.shortCodeRequired', ...)with correct guidance
Fix: Use t('error.shortCodeRequired', ...) for consistency and correctness.
Thanks for the review ! Replications now uses requireTenantId() and t('error.shortCodeRequired', …); getOrganizationId() lives on OAuthCommand with the three base copies removed; replications list uses a module-level TableRenderer and validateColumnKeys() on --columns like the other list commands; |
Summary
Brief description of what this PR does.
Summary
Adds support for the Granular Replications API to publish individual items (products, price tables, content assets) from staging to production, providing fine-grained control over replication instead of full-site replication.
Commands Added
Usage
Publish a product
b2c scapi replications publish --product-id PROD-123 --tenant-id zzxy_stg
List processes
b2c scapi replications list --tenant-id zzxy_stg
Wait for completion
b2c scapi replications wait --tenant-id zzxy_stg
What's Included
Implementation
SDK (packages/b2c-tooling-sdk):
CLI (packages/b2c-cli):
Testing
How was this tested?
Dependencies
3pl-approvedis set by a maintainerpnpm test)pnpm run format)