Spaces:
Sleeping
Sleeping
File size: 622 Bytes
7f81110 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | export class ShopifyTopicMapper {
/**
* Maps a Shopify webhook topic (e.g., 'products/update') to an internal event type (e.g., 'shopify.products.update').
* @param topic The Shopify topic from the webhook header
* @returns The internalized event type string
*/
public static toEventType(topic: string): string {
if (!topic) {
return "shopify.unknown";
}
// Shopify topics are typically in the format of 'group/action' (e.g., 'products/update')
// We map them to 'shopify.group.action'
return `shopify.${topic.replace(/\//g, ".")}`;
}
}
|