feat: add public workspace page api (#1791)

This commit is contained in:
Himself65
2023-04-03 06:15:39 -05:00
committed by GitHub
parent 196b9f2dbb
commit 5dbbabae57
3 changed files with 133 additions and 16 deletions

View File

@@ -233,13 +233,16 @@ export function createWorkspaceApis(prefixUrl = '/') {
throw new RequestError(MessageCode.getMembersFailed, e);
});
},
createWorkspace: async (encodedYDoc: Blob): Promise<{ id: string }> => {
createWorkspace: async (
encodedYDoc: ArrayBuffer
): Promise<{ id: string }> => {
const auth = getLoginStorage();
assertExists(auth);
return fetch(prefixUrl + 'api/workspace', {
method: 'POST',
body: encodedYDoc,
headers: {
'Content-Type': 'application/octet-stream',
Authorization: auth.token,
},
})
@@ -382,6 +385,17 @@ export function createWorkspaceApis(prefixUrl = '/') {
throw new RequestError(MessageCode.leaveWorkspaceFailed, e);
});
},
downloadPublicWorkspacePage: async (
workspaceId: string,
pageId: string
): Promise<ArrayBuffer> => {
return fetch(
prefixUrl + `api/public/workspace/${workspaceId}/${pageId}`,
{
method: 'GET',
}
).then(r => r.arrayBuffer());
},
downloadWorkspace: async (
workspaceId: string,
published = false