import { ResolverActions, CommentResolverSaveEvent } from "../../utils/enums"; import { PartialAttachment } from "./attachment-resolver.data.model"; import { BaseMetadata } from "./base-metadata.data.model"; import { CommentAnnotation } from "./comment-annotation.data.model"; import { ResolverConfig, ResolverResponse } from "./resolver.data.model"; import { SuggestionData } from "./suggestion.data.model"; export interface CommentAnnotationDataProvider { get?: (request: GetCommentResolverRequest) => Promise>>; save?: (request: SaveCommentResolverRequest) => Promise>; delete?: (request: DeleteCommentResolverRequest) => Promise>; config?: ResolverConfig; } export interface GetCommentResolverRequest { organizationId: string; commentAnnotationIds?: string[]; documentIds?: string[]; folderId?: string; allDocuments?: boolean; } export interface DeleteCommentResolverRequest { commentAnnotationId: string; metadata?: BaseMetadata; event?: ResolverActions; } export interface SaveCommentResolverRequest { commentAnnotation: { [key: string]: PartialCommentAnnotation; }; /** * The save event. One of the 4 core PII events (`ResolverActions`) or, when the customer * opts in via `ResolverConfig.additionalSaveEvents`, a non-core annotation-level event * (`CommentResolverSaveEvent`). See specs/comment-resolver iteration-2. * * Exception (comment-resolver iteration-3): `comment_annotation.suggestion_reject` is sent WITHOUT * opt-in whenever the annotation carries a `suggestion` — it is the only suggestion transition that * carries new content (`rejectReason`). A backend must answer 2xx and upsert for ANY event value, * and an event name alone never means "apply the change": read `suggestion.status`. */ event?: ResolverActions | CommentResolverSaveEvent; metadata?: BaseMetadata; commentId?: string; /** * The comment the action occurred on, resolved from `commentId` against the * payload's `commentAnnotation[*].comments` map. Convenience field so the * customer backend does not have to re-derive the target comment from * `commentId`. Omitted when `commentId` is absent or no matching comment is found. */ targetComment?: PartialComment; } export interface PartialUser { userId: string; } export interface PartialTaggedUserContacts { userId: string; contact?: PartialUser; text?: string; } export interface PartialComment { commentId: string | number; commentHtml?: string; commentText?: string; attachments?: { [attachmentId: number]: PartialAttachment; }; from?: PartialUser; to?: PartialUser[]; taggedUserContacts?: PartialTaggedUserContacts[]; } export interface PartialCommentAnnotationResult { strippedData: { [annotationId: string]: PartialCommentAnnotation; } | null; originalData: CommentAnnotation | null; eventType?: ResolverActions | CommentResolverSaveEvent; /** * INTERNAL (SDK write path only, never sent to a resolver). True when `originalData` still * carries `context.textEditorConfig.text` on purpose: the row is a legacy one whose resolver * copy does not hold the anchor yet and this save is not a core event that hands it over. * `CommonDbUtilsService` forwards it to the Velt-DB filter as `keepContextText`. */ veltCopyKeepsContextText?: boolean; /** * INTERNAL (SDK write path only, never sent to a resolver). True when `originalData.suggestion` * still carries its content keys on purpose (comment-resolver AC-032): a legacy row whose resolver * copy does not hold them yet and this save is not a core hand-off. Forwarded by * `CommonDbUtilsService` to the Velt-DB filter as `keepSuggestionContent`. */ veltCopyKeepsSuggestionContent?: boolean; } export interface PartialTargetTextRange { text: string; } export interface PartialCommentAnnotation { annotationId: string; metadata?: BaseMetadata; comments: { [commentId: string]: PartialComment; }; from?: PartialUser; assignedTo?: PartialUser; /** * The TipTap anchor text (`context.textEditorConfig.text`) — the highlighted sentence a * text comment created through `@veltdev/tiptap-velt-comments` is attached to. Moved here * from the annotation's `context` blob (which is otherwise customer-owned and stays in * Velt) and merged back on read; the same PII class as `targetTextRange.text`. Present * only when the annotation carries it (PM-2026-09-29-self-hosting-pii-egress-side-channels). * When `context` itself is listed in `fieldsToRemove`, the WHOLE context object travels * here instead. */ context?: { textEditorConfig?: { text?: string; [key: string]: any; }; [key: string]: any; }; targetTextRange?: PartialTargetTextRange; resolvedByUserId?: string | null; /** * The suggestion (comment-resolver iteration-3) — present when the annotation carries one. Its * content keys (`oldValue`, `newValue`, `summary`, `rejectReason`, `metadata`, `textChange`) are PII: they live only here, * never in Velt. When sent it is always COMPLETE (the content your store already holds plus this * write), so a backend may replace the stored value wholesale. `resolvedBy` may be `{ userId }` * under a user resolver. On `get`, only the content keys are read back — Velt stays authoritative * for `status`, `resolvedBy` and `resolvedAt`. Backends must persist and return it. */ suggestion?: Partial; [key: string]: any; }