UNPKG

@akson/cortex-shopify-translations

Version:

Unified Shopify translations management client with product extraction, translation sync, and CLI tools

120 lines (117 loc) 3.64 kB
/** * Shopify Configuration Utilities */ interface ShopifyConfig { shop: string; accessToken: string; apiVersion: string; rateLimitDelay: number; sourceLanguage: string; targetLanguages: string[]; } declare const getShopifyConfig: () => ShopifyConfig; /** * Enhanced GraphQL Client for Shopify Admin API * Handles comprehensive translation resource discovery and management */ interface GraphQLResponse<T = any> { data?: T; errors?: Array<{ message: string; locations?: Array<{ line: number; column: number; }>; path?: string[]; }>; extensions?: { cost?: { requestedQueryCost: number; actualQueryCost: number; throttleStatus: { maximumAvailable: number; currentlyAvailable: number; restoreRate: number; }; }; }; } interface TranslatableResource { resourceId: string; translatableContent: Array<{ key: string; value: string; digest: string; locale: string; }>; translations: Array<{ key: string; value: string; locale: string; outdated?: boolean; }>; } interface PageInfo { hasNextPage: boolean; endCursor?: string; hasPreviousPage: boolean; startCursor?: string; } interface TranslatableResourceConnection { edges: Array<{ node: TranslatableResource; cursor: string; }>; pageInfo: PageInfo; } type TranslatableResourceType = 'PRODUCT' | 'COLLECTION' | 'ARTICLE' | 'BLOG' | 'PAGE' | 'ONLINE_STORE_THEME' | 'SHOP' | 'SHOP_POLICY' | 'PRODUCT_OPTION' | 'DELIVERY_METHOD_DEFINITION' | 'METAFIELD' | 'SELLING_PLAN' | 'SELLING_PLAN_GROUP' | 'FILTER' | 'EMAIL_TEMPLATE'; declare class ShopifyGraphQLClient { private config; private lastCallTime; private remainingCost; constructor(); get sourceLanguage(): string; get targetLanguages(): string[]; private rateLimitDelay; private get endpoint(); private get headers(); query<T = any>(query: string, variables?: Record<string, any>): Promise<GraphQLResponse<T>>; /** * Discover all available translatable resource types */ discoverTranslatableResourceTypes(): Promise<TranslatableResourceType[]>; /** * Get all translatable resources of a specific type with pagination */ getTranslatableResources(resourceType: TranslatableResourceType, first?: number, after?: string): Promise<TranslatableResourceConnection>; /** * Get all translatable resources for all types */ getAllTranslatableResources(): Promise<Record<TranslatableResourceType, TranslatableResource[]>>; /** * Register translations for multiple resources */ registerTranslations(translations: Array<{ resourceId: string; translations: Array<{ key: string; value: string; locale: string; translatableContentDigest: string; }>; }>): Promise<boolean>; /** * Fetch translations for a batch of resources efficiently */ private fetchTranslationsForResources; /** * Get current query cost status */ getRemainingCost(): number; /** * Check if we need to pause due to rate limiting */ needsRateLimit(): boolean; } declare const createGraphQLClient: () => ShopifyGraphQLClient; export { type PageInfo, ShopifyGraphQLClient, type TranslatableResource, type TranslatableResourceConnection, type TranslatableResourceType, createGraphQLClient, getShopifyConfig };