import type { CamelCase } from "type-fest"; import type { GenericRecord } from "@webiny/api/types.js"; export type StorageKey = `${CamelCase}`; export interface IStoreValueSuccessResult { key: StorageKey; data: V | null | undefined; error?: undefined; } export interface IStoreValueErrorResult { key: StorageKey; data?: never; error: Error; } export type StoreValueResult = IStoreValueSuccessResult | IStoreValueErrorResult; export interface IStoreValuesSuccessResult> { keys: (keyof V)[]; data: V; error?: undefined; } export interface IStoreValuesErrorResult { keys: (keyof V)[]; data?: never; error: Error; } export type StoreValuesResult> = IStoreValuesSuccessResult | IStoreValuesErrorResult; export interface IGetValueSuccessResult { key: StorageKey; data: V | null | undefined; error?: undefined; } export interface IGetValueErrorResult { key: StorageKey; data?: never; error: Error; } export type GetValueResult = IGetValueSuccessResult | IGetValueErrorResult; export interface IGetValuesSuccessResult> { keys: (keyof V)[]; data: V; error?: undefined; } export interface IGetValuesErrorResult { keys: (keyof V)[]; data?: never; error: Error; } export type GetValuesResult> = IGetValuesSuccessResult | IGetValuesErrorResult; export interface IListValuesSuccessResult> { keys: (keyof V)[]; data: V; error?: undefined; } export interface IListValuesErrorResult { data?: never; error: Error; } export type ListValuesResult> = IListValuesSuccessResult | IListValuesErrorResult; export type IListValuesParams = { beginsWith: string; } | { eq: string; } | { gt: string; } | { gte: string; } | { lt: string; } | { lte: string; }; export type RemoveValueResult = StoreValueResult; export interface RemoveValuesResult> { keys: (keyof V)[]; error?: Error; } export interface IStore { storeValue(key: StorageKey, value: V): Promise>; storeValues>(values: V): Promise>; getValue(key: StorageKey): Promise>; getValues>(keys: (keyof V)[]): Promise>; listValues>(params?: IListValuesParams): Promise>; removeValue(key: StorageKey): Promise>; removeValues>(keys: (keyof V)[]): Promise>; }