[WEB-5845] chore: changing description field to description json (#8230)
* chore: migrating description to description json * chore: replace description with description_json * chore: updated migration file * chore: updated the migration file * chore: added description key in external endpoint * chore: updated the migration file * chore: updated the typo --------- Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com>
This commit is contained in:
parent
6c8779c8d3
commit
2a29ab8d4a
26 changed files with 85 additions and 54 deletions
|
|
@ -27,14 +27,14 @@ export class DocumentController {
|
|||
const { description_html, variant } = validatedData;
|
||||
|
||||
// Process document conversion
|
||||
const { description, description_binary } = convertHTMLDocumentToAllFormats({
|
||||
const { description_json, description_binary } = convertHTMLDocumentToAllFormats({
|
||||
document_html: description_html,
|
||||
variant,
|
||||
});
|
||||
|
||||
// Return successful response
|
||||
res.status(200).json({
|
||||
description,
|
||||
description_json,
|
||||
description_binary,
|
||||
});
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import { Database as HocuspocusDatabase } from "@hocuspocus/extension-database";
|
||||
// utils
|
||||
// plane imports
|
||||
import {
|
||||
getAllDocumentFormatsFromDocumentEditorBinaryData,
|
||||
getBinaryDataFromDocumentEditorHTMLString,
|
||||
} from "@plane/editor";
|
||||
// logger
|
||||
import type { TDocumentPayload } from "@plane/types";
|
||||
import { logger } from "@plane/logger";
|
||||
// lib
|
||||
import { AppError } from "@/lib/errors";
|
||||
// services
|
||||
import { getPageService } from "@/services/page/handler";
|
||||
|
|
@ -36,10 +37,10 @@ const fetchDocument = async ({ context, documentName: pageId, instance }: FetchP
|
|||
convertedBinaryData,
|
||||
true
|
||||
);
|
||||
const payload = {
|
||||
const payload: TDocumentPayload = {
|
||||
description_binary: contentBinaryEncoded,
|
||||
description_html: contentHTML,
|
||||
description: contentJSON,
|
||||
description_json: contentJSON,
|
||||
};
|
||||
await service.updateDescriptionBinary(pageId, payload);
|
||||
} catch (e) {
|
||||
|
|
@ -76,10 +77,10 @@ const storeDocument = async ({
|
|||
true
|
||||
);
|
||||
// create payload
|
||||
const payload = {
|
||||
const payload: TDocumentPayload = {
|
||||
description_binary: contentBinaryEncoded,
|
||||
description_html: contentHTML,
|
||||
description: contentJSON,
|
||||
description_json: contentJSON,
|
||||
};
|
||||
await service.updateDescriptionBinary(pageId, payload);
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -1,15 +1,9 @@
|
|||
import { logger } from "@plane/logger";
|
||||
import type { TPage } from "@plane/types";
|
||||
import type { TDocumentPayload, TPage } from "@plane/types";
|
||||
// services
|
||||
import { AppError } from "@/lib/errors";
|
||||
import { APIService } from "../api.service";
|
||||
|
||||
export type TPageDescriptionPayload = {
|
||||
description_binary: string;
|
||||
description_html: string;
|
||||
description: object;
|
||||
};
|
||||
|
||||
export abstract class PageCoreService extends APIService {
|
||||
protected abstract basePath: string;
|
||||
|
||||
|
|
@ -103,7 +97,7 @@ export abstract class PageCoreService extends APIService {
|
|||
}
|
||||
}
|
||||
|
||||
async updateDescriptionBinary(pageId: string, data: TPageDescriptionPayload): Promise<any> {
|
||||
async updateDescriptionBinary(pageId: string, data: TDocumentPayload): Promise<any> {
|
||||
return this.patch(`${this.basePath}/pages/${pageId}/description/`, data, {
|
||||
headers: this.getHeader(),
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue