import { AuthorKeypair } from "../crypto/crypto-types.ts";import { AuthorAddress, Base32String, DocBase, DocInputBase, FormatName, ShareAddress, Timestamp,} from "../util/doc-types.ts";import { ValidationError } from "../util/errors.ts";import { DocEs5, FormatEs5 } from "./format_es5.ts";
export interface FormatterGenerateOpts< FormatType extends string, DocInput extends DocInputBase<FormatType>, DocType extends DocBase<FormatType>, ConfigType,> { keypair: AuthorKeypair; config: ConfigType; input: DocInput; share: ShareAddress; timestamp: Timestamp; prevLatestDoc?: DocType;}
export interface IFormat< FormatType extends FormatName, DocInputType extends DocInputBase<FormatType>, DocType extends DocBase<FormatType>, ConfigType extends Record<string, unknown> | undefined,> { id: FormatType;
hashDocument(doc: DocType): Promise<Base32String | ValidationError>;
generateDocument( opts: FormatterGenerateOpts< FormatType, DocInputType, DocType, ConfigType >, ): Promise< | { doc: DocType; attachment?: ReadableStream<Uint8Array> | Uint8Array } | ValidationError >;
signDocument( keypair: AuthorKeypair, doc: DocType, config: ConfigType, ): Promise<DocType | ValidationError>;
wipeDocument( keypair: AuthorKeypair, docToWipe: DocType, config: ConfigType, ): Promise<DocType | ValidationError>;
removeExtraFields( doc: DocType, ): { doc: DocType; extras: Record<string, unknown> } | ValidationError;
checkDocumentIsValid( doc: DocType, now?: number, ): Promise<true | ValidationError>;
getAttachmentInfo(doc: DocType): { size: number; hash: string; } | ValidationError;
updateAttachmentFields( keypair: AuthorKeypair, doc: DocType, size: number, hash: string, config: ConfigType, ): Promise<DocType | ValidationError>;}
export type FormatInputType<FormatterType> = FormatterType extends IFormat< infer _FormatType, infer DocInputType, infer _DocType, infer _ConfigType> ? DocInputType : never;
export type FormatDocType<FormatterType> = FormatterType extends IFormat< infer _FormatType, infer _DocInputType, infer DocType, infer _ConfigType> ? DocType : FormatterType extends IFormat< infer _FormatType, infer _DocInputType, infer DocType, infer _ConfigType >[] ? DocType : never;
export type FormatNameType<FormatterType> = FormatterType extends IFormat< infer FormatType, infer _DocType, infer _DocInputType, infer _ConfigType> ? FormatType : never;
export type FormatConfigType<FormatterType> = FormatterType extends IFormat< infer _FormatType, infer _DocInputType, infer _DocType, infer ConfigType> ? ConfigType : FormatterType extends IFormat< infer _FormatType, infer _DocInputType, infer _DocType, infer ConfigType >[] ? ConfigType : never;
export type FormatsConfigRecord<FormatterType> = [FormatterType] extends [IFormat< infer _F, infer _I, infer _D, infer _C >[]] ? { [NameType in FormatterType[number]["id"]]: FormatConfigType< Extract< FormatterType[number], { id: NameType } > >; } : undefined;
export type FormatsArg<Init> = Init extends Array<IFormat<infer _N, infer _I, infer _O, infer _C>> ? Init : never;
export type FormatArg<Init> = Init extends IFormat<infer _N, infer _I, infer _O, infer _C> ? Init : never;
export type DefaultFormat = typeof FormatEs5;export type DefaultFormats = [DefaultFormat];export type DefaultDoc = DocEs5;