@@ -9,6 +9,9 @@ import type {paths, components} from './granular-replications.generated.js';
99import { createAuthMiddleware , createLoggingMiddleware , createRateLimitMiddleware } from './middleware.js' ;
1010import { globalMiddlewareRegistry , type MiddlewareRegistry } from './middleware-registry.js' ;
1111import { OAuthStrategy } from '../auth/oauth.js' ;
12+ import { buildTenantScope , toOrganizationId , normalizeTenantId } from './custom-apis.js' ;
13+
14+ export { toOrganizationId , normalizeTenantId , buildTenantScope } ;
1215
1316export type { paths , components } ;
1417export type GranularReplicationsClient = Client < paths > ;
@@ -26,7 +29,7 @@ export type PublishIdResponse = components['schemas']['PublishIdResponse'];
2629
2730export interface GranularReplicationsClientConfig {
2831 shortCode : string ;
29- organizationId : string ;
32+ tenantId : string ;
3033 scopes ?: string [ ] ;
3134 middlewareRegistry ?: MiddlewareRegistry ;
3235}
@@ -37,7 +40,7 @@ export interface GranularReplicationsClientConfig {
3740 * The Granular Replications API enables programmatic publishing of individual items
3841 * (products, price tables, content assets) from staging to production environments.
3942 *
40- * @param config - Client configuration with shortCode and organizationId
43+ * @param config - Client configuration with shortCode and tenantId
4144 * @param auth - OAuth authentication strategy
4245 * @returns Typed Granular Replications API client
4346 *
@@ -53,7 +56,7 @@ export interface GranularReplicationsClientConfig {
5356 *
5457 * const client = createGranularReplicationsClient({
5558 * shortCode: 'kv7kzm78',
56- * organizationId : 'f_ecom_zzxy_prd '
59+ * tenantId : 'zzxy_prd '
5760 * }, auth);
5861 *
5962 * // Queue a product for publishing
@@ -83,8 +86,8 @@ export function createGranularReplicationsClient(
8386 baseUrl : `https://${ config . shortCode } .api.commercecloud.salesforce.com/operation/replications/v1` ,
8487 } ) ;
8588
86- // OAuth scope handling
87- const requiredScopes = config . scopes ?? [ 'sfcc.granular-replications.rw' ] ;
89+ // Build required scopes: domain scope + tenant-specific scope
90+ const requiredScopes = config . scopes ?? [ 'sfcc.granular-replications.rw' , buildTenantScope ( config . tenantId ) ] ;
8891 const scopedAuth = auth instanceof OAuthStrategy ? auth . withAdditionalScopes ( requiredScopes ) : auth ;
8992
9093 client . use ( createAuthMiddleware ( scopedAuth ) ) ;
0 commit comments