epps
Version:
Enhances Pinia stores with advanced features such as persistence, encryption, and store extension. Simplifies state management and ensures data security for Vue.js and Nuxt applications.
29 lines (28 loc) • 1.9 kB
TypeScript
import type { CollectionStoreMethods } from "../types";
import type { Comparison } from "../types/comparison";
export interface IError {
id: string;
level?: number;
message: string;
}
export interface ErrorsState<TError extends IError = IError> {
errors: TError[];
}
type omitActions = 'clear' | 'getItem' | 'getItems' | 'removeItem' | 'setItems';
export interface ErrorsStore<TError extends IError = IError> extends Omit<CollectionStoreMethods, omitActions> {
addError: (error: TError) => void;
clearErrors: () => void;
getError: (errorId: {
id: string;
}) => TError | undefined;
getErrors: (findBy?: Partial<TError>, comparisonMode?: Comparison) => TError[] | undefined;
getErrorById: (id: string) => TError | undefined;
getErrorsByLevel: (value: number, comparisonMode?: Comparison) => TError[] | undefined;
hasError: (level?: number) => boolean;
removeError: (criteria: Partial<TError>) => void;
setErrors: (errors: TError[]) => void;
}
export declare const useErrorsStore: <TError extends IError = IError>(id: string) => ErrorsStore<IError> & ErrorsState<TError> & import("pinia")._StoreWithState<string, {}, {}, {}> & {} & {} & import("pinia").PiniaCustomProperties<string, {}, {}, {}> & import("pinia").PiniaCustomStateProperties<{}> & import("pinia").PiniaCustomProperties<string, import("pinia").StateTree, import("pinia")._GettersTree<import("pinia").StateTree>, import("pinia")._ActionsTree> & {
mutationCallback?: ((mutation: import("pinia").SubscriptionCallbackMutationPatchFunction | import("pinia").SubscriptionCallbackMutationPatchObject<ErrorsState<TError>>) => void) | undefined;
} & import("../types").PersistedStore & import("pinia").StoreDefinition<string, import("../types").AnyObject & ErrorsState<TError>, import("../types").AnyObject, ErrorsStore<IError> & import("../types").PersistedStore>;
export {};