Skip to content

@W-21112167 adding replications api#215

Merged
charithaT07 merged 22 commits intomainfrom
W-21112167-Replications-API
Mar 24, 2026
Merged

@W-21112167 adding replications api#215
charithaT07 merged 22 commits intomainfrom
W-21112167-Replications-API

Conversation

@charithaT07
Copy link
Copy Markdown
Collaborator

@charithaT07 charithaT07 commented Feb 26, 2026

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

  • ✅ SDK Client - Type-safe createGranularReplicationsClient() with OAuth
  • ✅ 4 CLI Commands - list/get/publish/wait with table output
  • ✅ Complete Tests - 1,083 lines of unit tests with MSW mocking
  • ✅ Full Documentation - 380-line command reference guide
  • ✅ Entity Support - Products, price tables, and content assets

Implementation

SDK (packages/b2c-tooling-sdk):

  • OpenAPI spec + generated types (1,074 lines)
  • Granular Replications client with OAuth scopes
  • Test coverage with MSW API mocks

CLI (packages/b2c-cli):

  • Base command with tenant/org resolution
  • 4 commands with validation and formatted output
  • 785 lines of CLI test coverage

Testing

How was this tested?

Dependencies

  • No net-new third-party dependencies were added
  • If net-new third-party dependencies were added, rationale/discussion is included and 3pl-approved is set by a maintainer

  • Tests pass (pnpm test)
  • Code is formatted (pnpm run format)

@charithaT07 charithaT07 changed the title W 21112167 replications api @W 21112167 replications api Feb 26, 2026
@charithaT07 charithaT07 changed the title @W 21112167 replications api @W-21112167 replications api Feb 26, 2026
@charithaT07 charithaT07 changed the title @W-21112167 replications api @W-21112167 adding replications api Feb 26, 2026
@charithaT07 charithaT07 marked this pull request as ready for review March 6, 2026 12:31
Copy link
Copy Markdown
Collaborator

@clavery clavery left a comment

Choose a reason for hiding this comment

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

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-53
  • packages/b2c-cli/src/utils/scapi/schemas.ts:32-43
  • packages/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:set is 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.

@charithaT07
Copy link
Copy Markdown
Collaborator Author

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-53
  • packages/b2c-cli/src/utils/scapi/schemas.ts:32-43
  • packages/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:set is 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;

@charithaT07 charithaT07 requested a review from clavery March 20, 2026 14:59
@charithaT07 charithaT07 merged commit 368a1d8 into main Mar 24, 2026
5 checks passed
@charithaT07 charithaT07 deleted the W-21112167-Replications-API branch March 24, 2026 16:23
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