UNPKG

git-goose

Version:

a mongoose plugin that enables git like change tracking

33 lines (32 loc) 1.39 kB
import { Connection } from 'mongoose'; import { mini_rfc6902, rfc6902 } from './patchers'; import { Patcher, PatcherName, PatchType } from './types'; export interface ModelOptions { /** Mongoose connection to use for queries */ connection?: Connection; /** Collection name to use for all commits */ collectionName?: string; } export interface GitConfig<TPatcherName extends PatcherName> extends ModelOptions { /** Suffix for the commit models collection (unless [collectionName]{@link ModelOptions#collectionName} is defined)*/ collectionSuffix: string; /** The method for creating patches when saving updates */ patcher: TPatcherName; } export interface ContextualGitConfig<TPatcherName extends PatcherName = PatcherName> extends GitConfig<TPatcherName> { /** How many commits to keep before aggregating them into a snapshot */ snapshotWindow: number; } export declare const GitGlobalConfig: ContextualGitConfig; export declare const RequiredConfig: (keyof ContextualGitConfig)[]; export declare const Patchers: { 'json-patch': Patcher<ReturnType<typeof rfc6902.create>>; 'mini-json-patch': Patcher<ReturnType<typeof mini_rfc6902.create>>; }; /** * Fetch the appropriate patcher for a given patcher name * * @param name * @private */ export declare function getPatcher<Name extends PatcherName>(name: Name): Patcher<PatchType<Name>>;