git-goose
Version:
a mongoose plugin that enables git like change tracking
41 lines (40 loc) • 1.94 kB
TypeScript
import { Require_id } from 'mongoose';
import { ContextualGitConfig } from '../config';
import { CommitRef, CommittableDocument, Patch, PatcherName } from '../types';
import { GitWithContext } from './context';
/**
* Git manager with a reference to a document, enabling contextual aware operations
*
* @template TargetDocType - The type of the {@link doc}
* @template TPatcherName - The inferred name of the patcher to use (used for type hinting patches)
*/
export declare class GitFromDocument<TargetDocType, TPatcherName extends PatcherName> extends GitWithContext<TargetDocType, TPatcherName> {
protected readonly doc: CommittableDocument<TargetDocType>;
constructor(doc: CommittableDocument<TargetDocType>, conf?: Partial<ContextualGitConfig<TPatcherName>>);
protected objectifyDoc(): import('../types').Nullable<Require_id<TargetDocType>>;
protected get refId(): Require_id<TargetDocType>["_id"];
checkout(commit: CommitRef): Promise<import('mongoose').IfAny<TargetDocType, any, import('mongoose').Document<unknown, {}, TargetDocType> & Require_id<TargetDocType>>>;
/**
* Fetch the current state of the active working reference document
*/
getActiveDoc(): Promise<import('../types').Nullable<Require_id<TargetDocType>>>;
getHeadDoc(): Promise<Require_id<TargetDocType> | null>;
/**
* Fetch the diff for the active document and the current HEAD commit
*
* Effectively an alias for {@link status}
*/
diff(): Promise<Patch<TPatcherName>>;
/**
* Return the difference between the active document and another commit
*
* @param commit - A commit identifier
*/
diff(commit: CommitRef): Promise<Patch<TPatcherName>>;
/**
* @param commitA - A commit identifier
* @param commitB - A commit identifier
*/
diff(commitA?: CommitRef, commitB?: CommitRef): Promise<Patch<TPatcherName>>;
protected commit(): Promise<void>;
}