UNPKG

@magnetarjs/core

Version:
25 lines (24 loc) 1.63 kB
import type { ActionConfig, ActionName, DoOnFetch, DoOnFetchAggregate, EventNameFnsMap, FetchAggregateResponse, FetchResponse, OnAddedFn, PluginDeleteAction, PluginDeletePropAction, PluginFetchAction, PluginFetchAggregateAction, PluginFetchCountAction, PluginInsertAction, PluginModuleConfig, PluginWriteAction, SyncBatch } from '@magnetarjs/types'; /** * handleAction is responsible for executing (1) on.before (2) the action provided by the store plugin (3) on.error / on.success (4) optional: onNextStoresSuccess. * in any event/hook it's possible for the dev to modify the result & also abort the execution chain, which prevents calling handleAction on the next store as well * @returns unknown is returned in case of an error */ export declare function handleAction(args: { collectionPath: string; docId: string | undefined; modulePath: string; pluginModuleConfig: PluginModuleConfig; pluginAction: PluginFetchAction | PluginFetchCountAction | PluginFetchAggregateAction | PluginWriteAction | PluginDeletePropAction | PluginDeleteAction | PluginInsertAction; payload: undefined | { [key: string]: unknown; } | { [key: string]: unknown; }[] | string | string[]; actionConfig: ActionConfig; eventNameFnsMap: EventNameFnsMap; onError: 'revert' | 'continue' | 'stop'; actionName: Exclude<ActionName, 'stream'>; stopExecutionAfterAction: (arg?: boolean | 'revert') => void; storeName: string; }): Promise<undefined | string | FetchAggregateResponse | DoOnFetchAggregate | FetchResponse | DoOnFetch | OnAddedFn | SyncBatch | [string, SyncBatch] | unknown>;