import {type UndefinableOptional} from "../interface"; import {type IWithIdentity} from "./interface"; export interface IMutationSource< TCreate extends Record, TEntity extends Record, > { /** * Creates a new entity by the given request. */ create(create: TCreate): Promise; /** * Patches the given entity. */ patch(patch: UndefinableOptional & IWithIdentity): Promise; /** * Delete given entities by the list of given ids. */ remove(ids: string[]): Promise; /** * Remove all the data from this source and all dependant sources. * * The original use case for this method is an ability to restore data (thus clean * sources used for restoring and importing fresh data). */ truncate(): Promise; } export namespace MutationSourceInfer { export type Create = T extends IMutationSource ? U : T; export type Entity = T extends IMutationSource ? U : T; }