@scayle/storefront-core
Version:
Collection of essential utilities to work with the Storefront API
63 lines (62 loc) • 2.33 kB
TypeScript
import type { Log } from '..';
import { HashAlgorithm } from '../constants/hash';
/**
* Generates a key based on a template, shop ID, user ID, and optional hash algorithm.
*
* @param params The required asynchronous function parameters.
* @param params.keyName Deprecated and unused value to specify the name of a key.
* @param params.keyTemplate The template string for the key, which can include placeholders for `shopId` and `userId`.
* @param params.hashAlgorithm The hash algorithm to use (MD5, SHA256, or none). Defaults to SHA256.
* @param params.shopId The shop ID.
* @param params.userId The user ID.
* @param params.log Optional logger instance.
*
* @returns A Promise resolving to the generated key.
*/
export declare const generateKey: ({ keyTemplate, hashAlgorithm, shopId, userId, log, }: {
/** @deprecated */
keyName?: string;
keyTemplate: string;
hashAlgorithm: HashAlgorithm;
shopId: string;
userId: string;
log?: Log;
}) => Promise<string>;
/**
* Generates a wishlist key.
*
* @param params The required asynchronous function parameters.
* @param params.keyTemplate The template string for the key.
* @param params.hashAlgorithm The hash algorithm to use. Defaults to SHA256.
* @param params.shopId The shop ID.
* @param params.userId The user ID.
* @param params.log Optional logger instance.
*
* @returns A Promise resolving to the generated wishlist key.
*/
export declare const generateWishlistKey: ({ keyTemplate, hashAlgorithm, shopId, userId, log, }: {
keyTemplate: string;
hashAlgorithm: HashAlgorithm;
shopId: string;
userId: string;
log?: Log;
}) => Promise<string>;
/**
* Generates a basket key.
*
* @param params The required asynchronous function parameters.
* @param params.keyTemplate The template string for the key.
* @param params.hashAlgorithm The hash algorithm to use. Defaults to SHA256.
* @param params.shopId The shop ID.
* @param params.userId The user ID.
* @param params.log Optional logger instance.
*
* @returns A Promise resolving to the generated basket key.
*/
export declare const generateBasketKey: ({ keyTemplate, hashAlgorithm, shopId, userId, log, }: {
keyTemplate: string;
hashAlgorithm: HashAlgorithm;
shopId: string;
userId: string;
log?: Log;
}) => Promise<string>;