UNPKG

@saleor/app-sdk

Version:
54 lines (51 loc) 1.78 kB
import { createClient } from 'redis'; import { APL, AuthData, AplReadyResult, AplConfiguredResult } from '../index.js'; type RedisClient = Pick<ReturnType<typeof createClient>, "connect" | "isOpen" | "hGet" | "hSet" | "hDel" | "hGetAll" | "ping">; /** * Configuration options for RedisAPL */ type RedisAPLConfig = { /** Redis client instance to use for storage */ client: RedisClient; /** Optional key to use for the hash collection. Defaults to "saleor_app_auth" */ hashCollectionKey?: string; }; /** * Redis implementation of the Auth Persistence Layer (APL). * This class provides Redis-based storage for Saleor App authentication data. * * @example * ```typescript * // Create and configure Redis client * const client = createClient({ * url: "redis://localhost:6379", * // Add any additional Redis configuration options * }); * * // Initialize RedisAPL with the client * const apl = new RedisAPL({ * client, * // Optional: customize the hash collection key * hashCollectionKey: "my_custom_auth_key" * }); * * // Use the APL in your app * await apl.set("saleorApiUrl", { token: "auth-token", saleorApiUrl: "https://saleor-api.com/graphql/", appId: "app-id" }); * const authData = await apl.get("saleorApiUrl"); * ``` */ declare class RedisAPL implements APL { private debug; private tracer; private client; private hashCollectionKey; constructor(config: RedisAPLConfig); private ensureConnection; get(saleorApiUrl: string): Promise<AuthData | undefined>; set(authData: AuthData): Promise<void>; delete(saleorApiUrl: string): Promise<void>; getAll(): Promise<AuthData[]>; isReady(): Promise<AplReadyResult>; isConfigured(): Promise<AplConfiguredResult>; } export { RedisAPL };