55 */
66import { Command } from '@oclif/core' ;
77import { OAuthCommand } from '@salesforce/b2c-tooling-sdk/cli' ;
8- import {
9- createGranularReplicationsClient ,
10- type GranularReplicationsClient ,
11- toOrganizationId ,
12- } from '@salesforce/b2c-tooling-sdk' ;
8+ import { createGranularReplicationsClient , type GranularReplicationsClient } from '@salesforce/b2c-tooling-sdk' ;
139import { t } from '../../i18n/index.js' ;
1410
1511/**
@@ -24,17 +20,22 @@ export abstract class GranularReplicationsCommand<T extends typeof Command> exte
2420 * Gets or creates a Granular Replications API client.
2521 *
2622 * Requires:
27- * - shortCode configuration (via b2c config:set --short-code <code> )
23+ * - short code ( --short-code, SFCC_SHORTCODE, or dw.json )
2824 * - OAuth credentials
29- * - tenantId (from --tenant-id flag or config )
25+ * - tenant ID ( --tenant-id, SFCC_TENANT_ID, or dw.json )
3026 */
3127 protected get granularReplicationsClient ( ) : GranularReplicationsClient {
3228 if ( ! this . _granularReplicationsClient ) {
3329 const shortCode = this . resolvedConfig . values . shortCode ;
34- const tenantId = this . getTenantId ( ) ;
30+ const tenantId = this . requireTenantId ( ) ;
3531
3632 if ( ! shortCode ) {
37- this . error ( 'shortCode configuration is required. Run: b2c config:set --short-code <code>' ) ;
33+ this . error (
34+ t (
35+ 'error.shortCodeRequired' ,
36+ 'SCAPI short code required. Provide --short-code, set SFCC_SHORTCODE, or configure short-code in dw.json.' ,
37+ ) ,
38+ ) ;
3839 }
3940
4041 this . _granularReplicationsClient = createGranularReplicationsClient (
@@ -44,28 +45,4 @@ export abstract class GranularReplicationsCommand<T extends typeof Command> exte
4445 }
4546 return this . _granularReplicationsClient ;
4647 }
47-
48- /**
49- * Get the organization ID (with f_ecom_ prefix) for API path parameters.
50- */
51- protected getOrganizationId ( ) : string {
52- return toOrganizationId ( this . getTenantId ( ) ) ;
53- }
54-
55- /**
56- * Get the tenant ID from resolved config.
57- * @throws Error if tenant ID is not provided through any source
58- */
59- protected getTenantId ( ) : string {
60- const { tenantId} = this . resolvedConfig . values ;
61- if ( ! tenantId ) {
62- this . error (
63- t (
64- 'error.tenantIdRequired' ,
65- 'tenant-id is required. Provide via --tenant-id flag, SFCC_TENANT_ID env var, or tenant-id in dw.json.' ,
66- ) ,
67- ) ;
68- }
69- return tenantId ;
70- }
7148}
0 commit comments