@sheetwrite/coreclass
Transport/auth-neutral comment state with server-owned author and timestamp fields.
- Package
@sheetwrite/core- Source
packages/core/src/collaboration.ts#L458
Members 10
constructor
constructor(adapter: CommentAdapterinterface CommentAdapter {
listComments(
documentId: string,
signal?: AbortSignal,
): Promise<CommentListResult>;
mutateComment(
request: CommentMutationRequest,
): Promise<CommentMutationResponse>;
subscribeComments?(
documentId: string,
listener: (event: VersionedCommentEvent) => void,
signal?: AbortSignal,
): undefined | (() => void);
}interface CommentAdapter {
listComments(
documentId: string,
signal?: AbortSignal,
): Promise<CommentListResult>;
mutateComment(
request: CommentMutationRequest,
): Promise<CommentMutationResponse>;
subscribeComments?(
documentId: string,
listener: (event: VersionedCommentEvent) => void,
signal?: AbortSignal,
): undefined | (() => void);
}interface CommentAdapter {
listComments(
documentId: string,
signal?: AbortSignal,
): Promise<CommentListResult>;
mutateComment(
request: CommentMutationRequest,
): Promise<CommentMutationResponse>;
subscribeComments?(
documentId: string,
listener: (
event: VersionedCommentEvent,
) => void,
signal?: AbortSignal,
): undefined | (() => void);
}Host persistence contract for versioned comment threads.API reference →, options: CommentCoordinatorOptionsinterface CommentCoordinatorOptions {
documentId: string;
serverVersion?: number;
}interface CommentCoordinatorOptions {
documentId: string;
serverVersion?: number;
}interface CommentCoordinatorOptions {
documentId: string;
serverVersion?: number;
}Document identity and initial version for comment coordination.API reference →);commentThreads
commentThreads: () => readonly CommentThreadinterface CommentThread {
id: string;
documentId: string;
anchor: CommentAnchor;
version: number;
messages: readonly CommentMessage[];
resolved: boolean;
resolvedBy?: CommentAuthorRef;
resolvedAt?: string;
}interface CommentThread {
id: string;
documentId: string;
anchor: CommentAnchor;
version: number;
messages: readonly CommentMessage[];
resolved: boolean;
resolvedBy?: CommentAuthorRef;
resolvedAt?: string;
}interface CommentThread {
id: string;
documentId: string;
anchor: CommentAnchor;
version: number;
messages: readonly CommentMessage[];
resolved: boolean;
resolvedBy?: CommentAuthorRef;
resolvedAt?: string;
}Versioned discussion anchored to a document location.API reference →[];create
create: (threadId: string, messageId: string, anchor: CommentAnchortype CommentAnchor =
| {
kind: "cell";
address: { sheet: string; row: number; col: number };
}
| { kind: "range"; range: Range };type CommentAnchor =
| {
kind: "cell";
address: { sheet: string; row: number; col: number };
}
| { kind: "range"; range: Range };type CommentAnchor =
| {
kind: "cell";
address: {
sheet: string;
row: number;
col: number;
};
}
| {
kind: "range";
range: Range;
};Document location to which a comment thread is attached.API reference →, body: string, clientMutationId: string) => Promise<CommentMutationResponsetype CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| {
status: "conflict";
currentVersion: number;
};Applied, duplicate, or conflict acknowledgement for a comment mutation.API reference →>;destroy
destroy: () => void;load
load: () => Promise<readonly CommentThreadinterface CommentThread {
id: string;
documentId: string;
anchor: CommentAnchor;
version: number;
messages: readonly CommentMessage[];
resolved: boolean;
resolvedBy?: CommentAuthorRef;
resolvedAt?: string;
}interface CommentThread {
id: string;
documentId: string;
anchor: CommentAnchor;
version: number;
messages: readonly CommentMessage[];
resolved: boolean;
resolvedBy?: CommentAuthorRef;
resolvedAt?: string;
}interface CommentThread {
id: string;
documentId: string;
anchor: CommentAnchor;
version: number;
messages: readonly CommentMessage[];
resolved: boolean;
resolvedBy?: CommentAuthorRef;
resolvedAt?: string;
}Versioned discussion anchored to a document location.API reference →[]>;mutate
mutate: (mutation: CommentMutationtype CommentMutation =
| {
kind: "create";
threadId: string;
messageId: string;
anchor: CommentAnchor;
body: string;
}
| {
kind: "reply";
threadId: string;
messageId: string;
body: string;
}
| { kind: "resolve"; threadId: string; resolved: boolean };type CommentMutation =
| {
kind: "create";
threadId: string;
messageId: string;
anchor: CommentAnchor;
body: string;
}
| {
kind: "reply";
threadId: string;
messageId: string;
body: string;
}
| { kind: "resolve"; threadId: string; resolved: boolean };type CommentMutation =
| {
kind: "create";
threadId: string;
messageId: string;
anchor: CommentAnchor;
body: string;
}
| {
kind: "reply";
threadId: string;
messageId: string;
body: string;
}
| {
kind: "resolve";
threadId: string;
resolved: boolean;
};Serializable operation that creates or updates comment state.API reference →, clientMutationId: string) => Promise<CommentMutationResponsetype CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| {
status: "conflict";
currentVersion: number;
};Applied, duplicate, or conflict acknowledgement for a comment mutation.API reference →>;on
on: (listener: CommentListener) => () => void;reply
reply: (threadId: string, messageId: string, body: string, clientMutationId: string) => Promise<CommentMutationResponsetype CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| {
status: "conflict";
currentVersion: number;
};Applied, duplicate, or conflict acknowledgement for a comment mutation.API reference →>;resolve
resolve: (threadId: string, resolved: boolean, clientMutationId: string) => Promise<CommentMutationResponsetype CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| {
status: "conflict";
currentVersion: number;
};Applied, duplicate, or conflict acknowledgement for a comment mutation.API reference →>;serverVersion
serverVersion: numberDeclaration
View full TypeScript declaration
class CommentCoordinator { constructor(adapter: CommentAdapterinterface CommentAdapter {
listComments(
documentId: string,
signal?: AbortSignal,
): Promise<CommentListResult>;
mutateComment(
request: CommentMutationRequest,
): Promise<CommentMutationResponse>;
subscribeComments?(
documentId: string,
listener: (event: VersionedCommentEvent) => void,
signal?: AbortSignal,
): undefined | (() => void);
}interface CommentAdapter {
listComments(
documentId: string,
signal?: AbortSignal,
): Promise<CommentListResult>;
mutateComment(
request: CommentMutationRequest,
): Promise<CommentMutationResponse>;
subscribeComments?(
documentId: string,
listener: (event: VersionedCommentEvent) => void,
signal?: AbortSignal,
): undefined | (() => void);
}interface CommentAdapter {
listComments(
documentId: string,
signal?: AbortSignal,
): Promise<CommentListResult>;
mutateComment(
request: CommentMutationRequest,
): Promise<CommentMutationResponse>;
subscribeComments?(
documentId: string,
listener: (
event: VersionedCommentEvent,
) => void,
signal?: AbortSignal,
): undefined | (() => void);
}Host persistence contract for versioned comment threads.API reference →, options: CommentCoordinatorOptionsinterface CommentCoordinatorOptions {
documentId: string;
serverVersion?: number;
}interface CommentCoordinatorOptions {
documentId: string;
serverVersion?: number;
}interface CommentCoordinatorOptions {
documentId: string;
serverVersion?: number;
}Document identity and initial version for comment coordination.API reference →); commentThreads: () => readonly CommentThreadinterface CommentThread {
id: string;
documentId: string;
anchor: CommentAnchor;
version: number;
messages: readonly CommentMessage[];
resolved: boolean;
resolvedBy?: CommentAuthorRef;
resolvedAt?: string;
}interface CommentThread {
id: string;
documentId: string;
anchor: CommentAnchor;
version: number;
messages: readonly CommentMessage[];
resolved: boolean;
resolvedBy?: CommentAuthorRef;
resolvedAt?: string;
}interface CommentThread {
id: string;
documentId: string;
anchor: CommentAnchor;
version: number;
messages: readonly CommentMessage[];
resolved: boolean;
resolvedBy?: CommentAuthorRef;
resolvedAt?: string;
}Versioned discussion anchored to a document location.API reference →[]; create: ( threadId: string, messageId: string, anchor: CommentAnchortype CommentAnchor =
| {
kind: "cell";
address: { sheet: string; row: number; col: number };
}
| { kind: "range"; range: Range };type CommentAnchor =
| {
kind: "cell";
address: { sheet: string; row: number; col: number };
}
| { kind: "range"; range: Range };type CommentAnchor =
| {
kind: "cell";
address: {
sheet: string;
row: number;
col: number;
};
}
| {
kind: "range";
range: Range;
};Document location to which a comment thread is attached.API reference →, body: string, clientMutationId: string, ) => Promise<CommentMutationResponsetype CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| {
status: "conflict";
currentVersion: number;
};Applied, duplicate, or conflict acknowledgement for a comment mutation.API reference →>; destroy: () => void; load: () => Promise<readonly CommentThreadinterface CommentThread {
id: string;
documentId: string;
anchor: CommentAnchor;
version: number;
messages: readonly CommentMessage[];
resolved: boolean;
resolvedBy?: CommentAuthorRef;
resolvedAt?: string;
}interface CommentThread {
id: string;
documentId: string;
anchor: CommentAnchor;
version: number;
messages: readonly CommentMessage[];
resolved: boolean;
resolvedBy?: CommentAuthorRef;
resolvedAt?: string;
}interface CommentThread {
id: string;
documentId: string;
anchor: CommentAnchor;
version: number;
messages: readonly CommentMessage[];
resolved: boolean;
resolvedBy?: CommentAuthorRef;
resolvedAt?: string;
}Versioned discussion anchored to a document location.API reference →[]>; mutate: ( mutation: CommentMutationtype CommentMutation =
| {
kind: "create";
threadId: string;
messageId: string;
anchor: CommentAnchor;
body: string;
}
| {
kind: "reply";
threadId: string;
messageId: string;
body: string;
}
| { kind: "resolve"; threadId: string; resolved: boolean };type CommentMutation =
| {
kind: "create";
threadId: string;
messageId: string;
anchor: CommentAnchor;
body: string;
}
| {
kind: "reply";
threadId: string;
messageId: string;
body: string;
}
| { kind: "resolve"; threadId: string; resolved: boolean };type CommentMutation =
| {
kind: "create";
threadId: string;
messageId: string;
anchor: CommentAnchor;
body: string;
}
| {
kind: "reply";
threadId: string;
messageId: string;
body: string;
}
| {
kind: "resolve";
threadId: string;
resolved: boolean;
};Serializable operation that creates or updates comment state.API reference →, clientMutationId: string, ) => Promise<CommentMutationResponsetype CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| {
status: "conflict";
currentVersion: number;
};Applied, duplicate, or conflict acknowledgement for a comment mutation.API reference →>; on: (listener: CommentListener) => () => void; reply: ( threadId: string, messageId: string, body: string, clientMutationId: string, ) => Promise<CommentMutationResponsetype CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| {
status: "conflict";
currentVersion: number;
};Applied, duplicate, or conflict acknowledgement for a comment mutation.API reference →>; resolve: ( threadId: string, resolved: boolean, clientMutationId: string, ) => Promise<CommentMutationResponsetype CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| { status: "conflict"; currentVersion: number };type CommentMutationResponse =
| {
status: "applied";
version: number;
clientMutationId: string;
thread: CommentThread;
}
| {
status: "duplicate";
version: number;
clientMutationId: string;
}
| {
status: "conflict";
currentVersion: number;
};Applied, duplicate, or conflict acknowledgement for a comment mutation.API reference →>; serverVersion: number;}