UNPKG

@memory-bank/mcp

Version:

Memory-enabled Co-Pilot (MCP) server for managing project documentation and context

188 lines 5.82 kB
import { DocumentId } from './DocumentId.js'; import { DocumentPath } from './DocumentPath.js'; import { Tag } from './Tag.js'; import { DocumentVersionInfo } from './DocumentVersionInfo.js'; import { IDocumentValidator } from '../validation/IDocumentValidator.js'; export declare const SCHEMA_VERSION = "memory_document_v2"; export interface BaseJsonDocumentV2 { schema: string; metadata: DocumentMetadataV2; content: Record<string, unknown>; } export interface DocumentMetadataV2 { id: string; title: string; path: string; tags: string[]; lastModified: string | Date; createdAt: string | Date; version: number; [key: string]: unknown; } /** * Type discriminator for document types */ export type DocumentType = 'branch_context' | 'active_context' | 'progress' | 'system_patterns' | 'generic'; /** * JsonDocument entity represents a structured document stored in JSON format * It uses the v2 schema with typed content based on document type */ export declare class JsonDocument<T extends Record<string, unknown> = Record<string, unknown>> { private readonly _id; private readonly _path; private readonly _title; private readonly _documentType; private readonly _tags; private readonly _content; private readonly _branch?; private readonly _versionInfo; private static validator; /** * Set the document validator to use for validation * This is injected from outside to avoid domain depending on infrastructure * @param validator Document validator to use */ static setValidator(validator: IDocumentValidator): void; /** * Get the current validator (throws if not set) */ private static getValidator; private constructor(); /** * Parse a JSON string into a JsonDocument * @param jsonString Raw JSON string * @param path Document path * @returns JsonDocument instance * @throws DomainError if parsing fails or validation fails */ static fromString(jsonString: string, path: DocumentPath): JsonDocument; /** * Create a JsonDocument from a parsed JSON object * @param jsonData Parsed JSON object * @param path Document path * @returns JsonDocument instance * @throws DomainError if validation fails */ static fromObject(jsonData: unknown, path: DocumentPath): JsonDocument; /** * Create a new JsonDocument with given values * @param params Document creation parameters * @returns JsonDocument instance */ static create<T extends Record<string, unknown> = Record<string, unknown>>({ id, path, title, documentType, tags, content, branch, versionInfo, }: { id?: DocumentId; path: DocumentPath; title: string; documentType: DocumentType; tags?: Tag[]; content: T; branch?: string; versionInfo?: DocumentVersionInfo; }): JsonDocument<T>; /** * Get the document ID */ get id(): DocumentId; /** * Get the document path */ get path(): DocumentPath; /** * Get the document title */ get title(): string; /** * Get the document type */ get documentType(): DocumentType; /** * Set the document type (internal use only for testing) */ set documentType(type: DocumentType); /** * Get the document tags */ get tags(): Tag[]; /** * Get the document content */ get content(): T; /** * Get the branch name */ get branch(): string | undefined; /** * Get the version info */ get versionInfo(): DocumentVersionInfo; /** * Get the last modified date */ get lastModified(): Date; /** * Get the document version */ get version(): number; /** * Check if document has a specific tag * @param tag Tag to check * @returns boolean indicating if document has tag */ hasTag(tag: Tag): boolean; /** * Create a new document with updated path * @param path New path * @returns New JsonDocument instance */ updatePath(path: DocumentPath): JsonDocument<T>; /** * Create a new document with updated title * @param title New title * @returns New JsonDocument instance */ updateTitle(title: string): JsonDocument<T>; /** * Create a new document with updated content * @param content New content * @returns New JsonDocument instance */ updateContent<U extends Record<string, unknown>>(content: U): JsonDocument<U>; /** * Create a new document with added tag * @param tag Tag to add * @returns New JsonDocument instance */ addTag(tag: Tag): JsonDocument<T>; /** * Create a new document with removed tag * @param tag Tag to remove * @returns New JsonDocument instance */ removeTag(tag: Tag): JsonDocument<T>; /** * Create a new document with updated tags * @param tags New tags * @returns New JsonDocument instance */ updateTags(tags: Tag[]): JsonDocument<T>; /** * Converts the document to a serializable object (BaseJsonDocumentV2) * @returns Document as a serializable object */ toObject(): BaseJsonDocumentV2 & { documentType: DocumentType; }; /** * Converts the document to a JSON string * @param pretty Whether to pretty-print the JSON (default: false) * @returns JSON string representation */ toString(pretty?: boolean): string; /** * Checks if two JsonDocument instances are equal (have the same ID) * @param other Another JsonDocument instance * @returns boolean indicating equality */ equals(other: JsonDocument): boolean; } //# sourceMappingURL=JsonDocument.d.ts.map