UNPKG

@memory-bank/mcp

Version:

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

56 lines 1.57 kB
import { v4 as uuidv4, validate as uuidValidate } from 'uuid'; import { DomainError, DomainErrorCodes } from '../../shared/errors/DomainError.js'; /** * Value object representing a document ID * Used to uniquely identify documents regardless of their path */ export class DocumentId { _value; constructor(_value) { this._value = _value; } /** * Factory method to create a new DocumentId * @param value UUID string * @returns DocumentId instance * @throws DomainError if UUID is invalid */ static create(value) { if (!value) { throw new DomainError(DomainErrorCodes.INVALID_DOCUMENT_ID, 'Document ID cannot be empty'); } if (!uuidValidate(value)) { throw new DomainError(DomainErrorCodes.INVALID_DOCUMENT_ID, 'Document ID must be a valid UUID'); } return new DocumentId(value); } /** * Generate a new DocumentId with a random UUID * @returns DocumentId instance */ static generate() { return new DocumentId(uuidv4()); } /** * Get the raw UUID value */ get value() { return this._value; } /** * Checks if two DocumentId instances are equal * @param other Another DocumentId instance * @returns boolean indicating equality */ equals(other) { return this._value === other._value; } /** * Convert to string * @returns Raw UUID value */ toString() { return this._value; } } //# sourceMappingURL=DocumentId.js.map