@shopify/shopify-api
Version:
Shopify API Library for Node - accelerate development with support for authentication, graphql proxy, webhooks
52 lines • 2.13 kB
TypeScript
import { ConfigInterface } from '../base-types';
/**
* Applies configured domain transformations to a shop URL.
* Returns transformed domain or original if no transformation matches.
*
* @param shopUrl - The shop URL to transform
* @param config - Configuration object containing domain transformations
* @returns Transformed shop URL or original if no transformation matches
*
* @example
* const config = {
* domainTransformations: [{
* match: /^([a-zA-Z0-9-_]+)\.my\.shop\.dev$/,
* transform: '$1.dev-api.shop.dev'
* }]
* };
* applyDomainTransformations('shop1.my.shop.dev', config);
* // Returns: 'shop1.dev-api.shop.dev'
*/
export declare function applyDomainTransformations(shopUrl: string, config: ConfigInterface): string | null;
/**
* Extracts all domains (source and target) from transformations for validation.
* Uses heuristics to extract domain patterns from regex source.
*
* **Supported regex patterns:**
* - Simple literal domains with escaped dots: `\.example\.com`
* - Patterns with anchors: `^([a-zA-Z0-9-_]+)\.example\.com$`
* - Character classes in subdomains: `^[a-z0-9-]+\.example\.com$`
*
* **Unsupported regex patterns:**
* - Optional groups: `(\.staging)?\.example\.com$` - May not extract correctly
* - Character classes in domain part: `\.api[0-9]\.example\.com$` - May not extract correctly
* - Complex alternations: `\.(dev|staging)\.example\.com$` - May not extract correctly
* - Nested groups in domain part - May not extract correctly
*
* When using unsupported patterns, domain extraction will fail and be logged at debug level.
*
* @param config - Configuration object containing domain transformations
* @returns Array of domain regex patterns
*
* @example
* const config = {
* domainTransformations: [{
* match: /^([a-zA-Z0-9-_]+)\.my\.shop\.dev$/,
* transform: '$1.dev-api.shop.dev'
* }]
* };
* getTransformationDomains(config);
* // Returns: ['my\\.shop\\.dev', 'dev-api\\.shop\\.dev']
*/
export declare function getTransformationDomains(config: ConfigInterface): string[];
//# sourceMappingURL=domain-transformer.d.ts.map