1 export enum DocsApiErrorCode {
2 CommitIdOutOfSync = 250_000,
5 export const getDocumentMeta = (volumeId: string, linkId: string) => ({
7 url: `docs/volumes/${volumeId}/documents/${linkId}/meta`,
11 export const getDocumentMetaByToken = (linkId: string, token: string, headers: { [key: string]: string }) => ({
13 url: `docs/urls/${token}/documents/${linkId}/meta`,
18 export const getCommitData = (volumeId: string, linkId: string, commitId: string) => ({
20 url: `docs/volumes/${volumeId}/documents/${linkId}/commits/${commitId}`,
25 export const getCommitDataByToken = (
29 headers: { [key: string]: string }
32 url: `docs/urls/${token}/documents/${linkId}/commits/${commitId}`,
38 export const seedInitialCommit = (volumeId: string, linkId: string, data: Uint8Array) => ({
40 url: `docs/volumes/${volumeId}/documents/${linkId}/seed-initial-commit`,
45 export const lockDocument = (volumeId: string, linkId: string, fetchCommitId?: string) => ({
47 url: `docs/volumes/${volumeId}/documents/${linkId}/lock`,
49 FetchCommitID: fetchCommitId,
55 export const squashCommit = (volumeId: string, linkId: string, commitId: string, data: Uint8Array) => ({
57 url: `docs/volumes/${volumeId}/documents/${linkId}/commits/${commitId}/squash`,
62 export const createDocument = (volumeId: string, linkId: string) => ({
64 url: `docs/volumes/${volumeId}/documents/${linkId}`,
69 export const getAllCommentThreadsInDocument = (volumeId: string, linkId: string) => ({
71 url: `docs/volumes/${volumeId}/documents/${linkId}/threads`,
74 export const getCommentThreadInDocument = (volumeId: string, linkId: string, threadId: string) => ({
76 url: `docs/volumes/${volumeId}/documents/${linkId}/threads/${threadId}`,
79 type CommentType = 1 | 2;
81 type CommonCommentData = {
86 type CreateCommentData = CommonCommentData & {
88 DocumentName: string | null;
91 type CommentThreadType = 1 | 2;
93 export const createThreadInDocument = (
98 Comment: CreateCommentData;
99 Type: CommentThreadType;
103 url: `docs/volumes/${volumeId}/documents/${linkId}/threads`,
107 export const deleteThreadInDocument = (volumeId: string, linkId: string, threadId: string) => ({
109 url: `docs/volumes/${volumeId}/documents/${linkId}/threads/${threadId}`,
112 export const resolveThreadInDocument = (volumeId: string, linkId: string, threadId: string) => ({
114 url: `docs/volumes/${volumeId}/documents/${linkId}/threads/${threadId}/resolve`,
117 export const unresolveThreadInDocument = (volumeId: string, linkId: string, threadId: string) => ({
119 url: `docs/volumes/${volumeId}/documents/${linkId}/threads/${threadId}/unresolve`,
122 export const changeSuggestionThreadState = (
126 action: 'accept' | 'reject' | 'reopen'
129 url: `docs/volumes/${volumeId}/documents/${linkId}/threads/${threadId}/suggestion/${action}`,
132 export const addCommentToThreadInDocument = (
136 data: CreateCommentData & { ParentCommentId: string | null }
139 url: `docs/volumes/${volumeId}/documents/${linkId}/threads/${threadId}`,
143 export const editCommentInThreadInDocument = (
148 data: CommonCommentData
151 url: `docs/volumes/${volumeId}/documents/${linkId}/threads/${threadId}/comments/${commentId}`,
155 export const deleteCommentInThreadInDocument = (
162 url: `docs/volumes/${volumeId}/documents/${linkId}/threads/${threadId}/comments/${commentId}`,
165 export const createRealtimeValetToken = (volumeId: string, linkId: string, commitId?: string) => ({
167 url: `docs/volumes/${volumeId}/documents/${linkId}/tokens`,
170 LastCommitID: commitId ?? null,
174 export const fetchRecentDocuments = () => ({