From 7908616df786bca9f5e279d87e0ba0533312d1b5 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Fri, 11 Mar 2022 16:25:13 +0800 Subject: [PATCH] refactor: parameters created and updated by journal Signed-off-by: Ryan Wang --- packages/admin-api/src/clients/JournalClient.ts | 12 +++--------- packages/admin-api/src/types/index.ts | 7 +++++++ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/admin-api/src/clients/JournalClient.ts b/packages/admin-api/src/clients/JournalClient.ts index 6a5b456..0d1f3ce 100644 --- a/packages/admin-api/src/clients/JournalClient.ts +++ b/packages/admin-api/src/clients/JournalClient.ts @@ -1,6 +1,6 @@ import { HttpClient } from '@halo-dev/rest-api-client' import { buildPath } from '../url' -import { Journal, JournalQuery, JournalType, JournalWithCmtCount, Page, Response } from '../types' +import { Journal, JournalParam, JournalQuery, JournalWithCmtCount, Page, Response } from '../types' export class JournalClient { private client: HttpClient @@ -41,7 +41,7 @@ export class JournalClient { * @param params parameter for creates * @returns A response of created journal. */ - public create(params: Journal): Promise> { + public create(params: JournalParam): Promise> { const path = buildPath({ endpointName: 'journals', }) @@ -55,13 +55,7 @@ export class JournalClient { * @param params parameter for updates * @returns A response of updated journal. */ - public update( - journalId: number, - params: { - sourceContent: string - type?: JournalType - }, - ): Promise> { + public update(journalId: number, params: JournalParam): Promise> { const path = buildPath({ endpointName: `journals/${journalId}`, }) diff --git a/packages/admin-api/src/types/index.ts b/packages/admin-api/src/types/index.ts index d31bf39..ab8e4d7 100644 --- a/packages/admin-api/src/types/index.ts +++ b/packages/admin-api/src/types/index.ts @@ -223,6 +223,13 @@ export type Journal = { type: JournalType } +export type JournalParam = { + sourceContent: string + content: string + type: JournalType + keepRaw?: boolean +} + export interface JournalCommentWithJournal extends BaseComment { journal: Journal }