import { Readable } from 'stream'; import type { PieceFrontmatter, PieceFrontmatterSchema, PieceFrontmatterSchemaField, PieceFrontMatterValue } from './utils/frontmatter.js'; import type LuzzleStorage from '../storage/abstract.js'; import type { PieceMarkdown } from './utils/markdown.js'; import type { LuzzleDatabase, LuzzleSelectable } from '../database/tables/index.js'; import compile from '../lib/ajv.js'; export interface InterfacePiece { new (directory: string, pieceName: string, schemaOverride?: PieceFrontmatterSchema): Piece; } export type PiecePruneResult = { action: 'pruned'; file: string; error?: false; } | { file: string; error: true; message: string; }; export type PieceSyncResult = { action: 'added' | 'updated' | 'skipped'; file: string; error?: false; } | { file: string; error: true; message: string; }; export type PieceDiffResult = { action: 'added'; file: string; markdown: PieceMarkdown; } | { action: 'updated'; file: string; markdown: PieceMarkdown; dbPiece: LuzzleSelectable<'pieces_items'>; } | { action: 'skipped'; file: string; }; declare class Piece { private _validator?; private _schema; private _storage; private _pieceName; private _fields?; constructor(pieceName: string, storage: LuzzleStorage, schema: PieceFrontmatterSchema); create(directory: string, name: string): Promise>; delete(file: string): Promise; get type(): string; get schema(): PieceFrontmatterSchema; protected get validator(): ReturnType>; get fields(): PieceFrontmatterSchemaField[]; isOutdated(file: string, db: LuzzleDatabase): Promise; validate(markdown: PieceMarkdown): { isValid: true; } | { isValid: false; errors: string[]; }; get(file: string): Promise>; write(markdown: PieceMarkdown): Promise; private findPrunable; diffPrune(db: LuzzleDatabase, files: string[]): Promise; prune(db: LuzzleDatabase, files: string[]): Promise>; private getChange; diffFile(db: LuzzleDatabase, file: string, options?: { force?: boolean; }): Promise>; diff(db: LuzzleDatabase, files: string[], options?: { force?: boolean; }): Promise>>; sync(db: LuzzleDatabase, files: string[], options?: { force?: boolean; }): Promise>; syncMarkdownAdd(db: LuzzleDatabase, markdown: PieceMarkdown, hash?: string): Promise; syncMarkdown(db: LuzzleDatabase, markdown: PieceMarkdown): Promise; syncMarkdownUpdate(db: LuzzleDatabase, markdown: PieceMarkdown, data: LuzzleSelectable<'pieces_items'>, hash?: string): Promise; toMarkdown(data: LuzzleSelectable<'pieces_items'>): PieceMarkdown; getField(markdown: PieceMarkdown, fieldPath: string): PieceFrontMatterValue | undefined; setFields(markdown: PieceMarkdown, fields: Record): Promise>; removeFields(markdown: PieceMarkdown, fields: string[]): Promise>>; setField(markdown: PieceMarkdown, fieldPath: string, value: unknown): Promise>; removeField(markdown: PieceMarkdown, fieldPath: string, value?: number | string | boolean): Promise>; } export default Piece;