UNPKG

@xats-org/types

Version:

Shared TypeScript types for xats

48 lines 1.96 kB
/** * xats v0.5.0 Annotation System Types * * TypeScript type definitions for the peer review and annotation system * introduced in xats schema version 0.5.0 */ /** * Standard xats annotation type URIs */ export const ANNOTATION_TYPE_URIS = { /** Proposed change to content */ SUGGESTION: 'https://xats.org/vocabularies/annotations/suggestion', /** Need for more information */ CLARIFICATION_REQUEST: 'https://xats.org/vocabularies/annotations/clarification_request', /** Small fix required */ MINOR_REVISION_NEEDED: 'https://xats.org/vocabularies/annotations/minor_revision_needed', /** Significant change required */ MAJOR_REVISION_NEEDED: 'https://xats.org/vocabularies/annotations/major_revision_needed', /** Content approved */ APPROVAL: 'https://xats.org/vocabularies/annotations/approval', /** Content rejected */ REJECTION: 'https://xats.org/vocabularies/annotations/rejection', }; /** * Type guard to check if an object is an annotation */ export function isAnnotation(obj) { if (typeof obj !== 'object' || obj === null) return false; const annotation = obj; return (typeof annotation.id === 'string' && typeof annotation.language === 'string' && typeof annotation.annotationType === 'string' && typeof annotation.targetObjectId === 'string' && ['open', 'resolved', 'rejected', 'deferred'].includes(annotation.status) && ['low', 'medium', 'high', 'critical'].includes(annotation.priority) && typeof annotation.reviewer === 'string' && typeof annotation.content === 'object' && typeof annotation.createdAt === 'string'); } /** * Type guard to check if an annotation type URI is standard */ export function isStandardAnnotationType(uri) { return Object.values(ANNOTATION_TYPE_URIS).includes(uri); } // SemanticText is already exported from document.js in index.ts //# sourceMappingURL=annotations.js.map