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.
61 lines (44 loc) • 2.7 kB
TypeScript
import { PiniaPlugin, PiniaPluginContext, Store } from 'pinia';
import { EppsContructor } from '../plugins/epps';
import { EppsConstructorProps } from '../plugins/eppsPlugin';
import { CollectionState, CollectionStoreMethods, DefineEppsStore, EppsStore as EppsStoreInterface } from './store';
import { ErrorsState, ErrorsStore } from '../stores/errors'
import { Item } from '../models/item';
import type { ParentStoreInterface, ParentStore as ParentStoreType } from "../types/epps"
import { ResourceIdStore } from '../stores/resourceId'
import { WebUserState, WebUserStore } from '../stores/webuser'
export interface AnyObject {
[key: number | string | symbol]: any;
}
export interface SearchCollectionCriteria {
[key: number | string | symbol]: boolean | number | string;
}
export type { AugmentOptionApiStore, CollectionState, CollectionStoreMethods, DefineEppsStore, EppsStore, ExtendedStore, PersistedState, PersistedStore } from "./store";
export type { ErrorsState, ErrorsStore } from '../stores/errors';
export type { ResourceIdStore } from '../stores/resourceId';
export type { Item as ResourceIdState } from '../models/item';
export type { WebUserState, WebUserStore } from '../stores/webuser';
declare module 'epps' {
export function createPlugin(dbName: string, cryptKey?: string, debug?: boolean): PiniaPlugin;
export function createPluginMock(dbName: string, cryptKey?: string): PiniaPlugin;
export function defineEppsStore<TStore, TState>(id: string, storeDefinition: () => AnyObject, eppsOptions?: Epps): DefineEppsStore<TStore, TState>
export function defineStoreId(prefix: string, id: string): string
export class EppsPlugin {
constructor({ dbName, dbKeyPath, cryptKey }: EppsConstructorProps)
plugin(context: PiniaPluginContext): void
}
export class Epps {
constructor(options: EppsContructor)
getStore<TStore, TState>(idOrIndex: number | string, childId?: string): EppsStoreInterface<TStore, TState> | undefined
parentsStores(childId?: string): EppsStoreInterface<AnyObject, AnyObject>[]
}
export class ParentStore implements ParentStoreInterface {
get id(): string
constructor(id: string, store: ParentStoreType)
build(childId: string): EppsStoreInterface<AnyObject, AnyObject>
}
export function useCollectionStore<T>(id: string): Store & CollectionState<T> & CollectionStoreMethods;
export function useErrorsStore<T>(id: string): Store & ErrorsState & ErrorsStore;
export function useResourceIdStore<T>(id: string): Store & ResourceIdStore & Item;
export function useWebUserStore<T>(id: string): Store & WebUserState & WebUserStore;
}