Refactor Media Manager sync logic and fix duplication bugs
This major refactor addresses improper image matching and duplication: - Implemented strict ID-based matching in 'MediaService', removing the greedy filename matching fallback. - Redesigned synchronization pipeline to treat Google Drive as the Source of Truth, supporting orphan adoption (Shopify -> Drive) and secure uploads. - Implemented 'gallery_order' using Drive file properties (supporting both v2 and v3 APIs) for stable, drag-and-drop global ordering. - Added conditional file renaming using timestamps to enforce '_' naming convention without unnecessary renames. - Fixed runtime errors in 'MediaService' loops and updated 'ShopifyMediaService' GraphQL mutations to match correctly schema. - Rewrote 'MediaService.test.ts' with robust test cases for strict matching, adoption, sorting, and reordering.
This commit is contained in:
@ -7,4 +7,5 @@ export interface IDriveService {
|
||||
trashFile(fileId: string): void
|
||||
updateFileProperties(fileId: string, properties: {[key: string]: string}): void
|
||||
createFile(blob: GoogleAppsScript.Base.Blob): GoogleAppsScript.Drive.File
|
||||
getFileProperties(fileId: string): {[key: string]: string}
|
||||
}
|
||||
|
||||
@ -10,4 +10,5 @@ export interface IShop {
|
||||
SetInventoryItemDefaults(item: shopify.InventoryItem, config: Config): shopify.InventoryItem;
|
||||
SetInventoryItemWeight(item: shopify.InventoryItem, config: Config, weight: number, weight_unit: shopify.WeightUnit): shopify.InventoryItem;
|
||||
shopifyGraphQLAPI(payload: any): any;
|
||||
getShopDomain(): string;
|
||||
}
|
||||
|
||||
@ -4,4 +4,5 @@ export interface IShopifyMediaService {
|
||||
getProductMedia(productId: string): any[]
|
||||
productDeleteMedia(productId: string, mediaId: string): any
|
||||
productReorderMedia(productId: string, moves: any[]): any
|
||||
getShopDomain(): string
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user