mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-28 14:04:43 -04:00
fix: Move content into to frontend directory
Doing this BEFORE the merge prevents a lot of merge conflicts. Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
4e18ce38f3
commit
762a0a850e
1051 changed files with 0 additions and 35 deletions
45
frontend/src/api/revisions/index.ts
Normal file
45
frontend/src/api/revisions/index.ts
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
import type { RevisionDetails, RevisionMetadata } from './types'
|
||||
import { GetApiRequestBuilder } from '../common/api-request-builder/get-api-request-builder'
|
||||
import { DeleteApiRequestBuilder } from '../common/api-request-builder/delete-api-request-builder'
|
||||
|
||||
/**
|
||||
* Retrieves a note revision while using a cache for often retrieved revisions.
|
||||
*
|
||||
* @param noteId The id of the note for which to fetch the revision.
|
||||
* @param revisionId The id of the revision to fetch.
|
||||
* @return The revision.
|
||||
* @throws {Error} when the api request wasn't successful.
|
||||
*/
|
||||
export const getRevision = async (noteId: string, revisionId: number): Promise<RevisionDetails> => {
|
||||
const response = await new GetApiRequestBuilder<RevisionDetails>(
|
||||
`notes/${noteId}/revisions/${revisionId}`
|
||||
).sendRequest()
|
||||
return response.asParsedJsonObject()
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a list of all revisions stored for a given note.
|
||||
*
|
||||
* @param noteId The id of the note for which to look up the stored revisions.
|
||||
* @return A list of revision ids.
|
||||
* @throws {Error} when the api request wasn't successful.
|
||||
*/
|
||||
export const getAllRevisions = async (noteId: string): Promise<RevisionMetadata[]> => {
|
||||
const response = await new GetApiRequestBuilder<RevisionMetadata[]>(`notes/${noteId}/revisions`).sendRequest()
|
||||
return response.asParsedJsonObject()
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes all revisions for a note.
|
||||
*
|
||||
* @param noteIdOrAlias The id or alias of the note to delete all revisions for.
|
||||
* @throws {Error} when the api request wasn't successful.
|
||||
*/
|
||||
export const deleteRevisionsForNote = async (noteIdOrAlias: string): Promise<void> => {
|
||||
await new DeleteApiRequestBuilder(`notes/${noteIdOrAlias}/revisions`).sendRequest()
|
||||
}
|
21
frontend/src/api/revisions/types.ts
Normal file
21
frontend/src/api/revisions/types.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { NoteEdit } from '../notes/types'
|
||||
|
||||
export interface RevisionDetails extends RevisionMetadata {
|
||||
content: string
|
||||
patch: string
|
||||
edits: NoteEdit[]
|
||||
}
|
||||
|
||||
export interface RevisionMetadata {
|
||||
id: number
|
||||
createdAt: string
|
||||
length: number
|
||||
authorUsernames: string[]
|
||||
anonymousAuthorCount: number
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue