The value read back from the product-detail cache
Type predicate indicating the value is a Partial<T> record
const cached = await this.cache.getCachedProductData(key);
if (isCachedProductData<Product>(cached)) {
product.setData(cached); // cached is Partial<Product>
}
export function isCachedProductData<T extends Product = Product>(
value: unknown,
): value is Partial<T> {
return typeof value === 'object' && value !== null && !Array.isArray(value);
}
Type guard for a cached product-data record — the plain object produced by
ProductBuilder.dump()and round-tripped through the product-detail cache. Narrows anunknown(orRecord<string, unknown>) cache read toPartial<T>so it can be handed toProductBuilder.setDatawithout an assertion.The check is intentionally structural (a non-null, non-array object) rather than a full-schema validation:
setDataalready routes every key through its own validating setter and silently drops any field that fails, so validating individual fields here would only risk rejecting an otherwise-usable product.