feat: enforce SKU validity, use SKU as handle

This commit enforces proper SKU validation, uses the SKU as the Shopify handle, and implements ID-based product updates to allow renaming. It also extracts the IShop interface for TDD.
This commit is contained in:
Ben Miller
2025-12-25 04:54:55 -07:00
parent 2672d47203
commit 7cb469ccf9
8 changed files with 251 additions and 9 deletions

13
src/interfaces/IShop.ts Normal file
View File

@ -0,0 +1,13 @@
import * as shopify from "shopify-admin-api-typings";
import { Config } from "../config";
export interface IShop {
GetProductBySku(sku: string): any; // Return type is inferred as product node
GetProductById(id: string): any; // New method
GetInventoryItemBySku(sku: string): shopify.InventoryItem;
UpdateInventoryItemQuantity(item: shopify.InventoryItem, delta: number, config: Config): shopify.InventoryItem;
SetInventoryItemQuantity(item: shopify.InventoryItem, quantity: number, config: Config): any;
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;
}