From cd1fc5c4db361985746b5d0fd0c4588ccc13b9f9 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Thu, 17 Aug 2023 18:46:39 +0800 Subject: [PATCH] fix typo --- packages/api/src/elastic/highlights.ts | 8 ++++---- packages/api/src/elastic/labels.ts | 12 ++++++------ packages/api/src/elastic/pages.ts | 12 ++++++------ packages/api/src/elastic/recommendation.ts | 4 ++-- packages/api/src/elastic/types.ts | 2 +- packages/api/src/services/labels.ts | 6 +++--- packages/api/src/services/popular_reads.ts | 4 ++-- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/packages/api/src/elastic/highlights.ts b/packages/api/src/elastic/highlights.ts index c5b516118..3d0808c04 100644 --- a/packages/api/src/elastic/highlights.ts +++ b/packages/api/src/elastic/highlights.ts @@ -3,9 +3,9 @@ import { EntityType } from '../datalayer/pubsub' import { SortBy, SortOrder, SortParams } from '../utils/search' import { client, INDEX_ALIAS, logger } from './index' import { - Context, Highlight, Page, + PageContext, PageType, SearchItem, SearchResponse, @@ -14,7 +14,7 @@ import { export const addHighlightToPage = async ( id: string, highlight: Highlight, - ctx: Context + ctx: PageContext ): Promise => { try { const { body } = await client.update({ @@ -97,7 +97,7 @@ export const getHighlightById = async ( export const deleteHighlight = async ( highlightId: string, - ctx: Context + ctx: PageContext ): Promise => { try { const { body } = await client.updateByQuery({ @@ -256,7 +256,7 @@ export const searchHighlights = async ( export const updateHighlight = async ( highlight: Highlight, - ctx: Context + ctx: PageContext ): Promise => { try { const { body } = await client.updateByQuery({ diff --git a/packages/api/src/elastic/labels.ts b/packages/api/src/elastic/labels.ts index a6364ce6d..5864a0dff 100644 --- a/packages/api/src/elastic/labels.ts +++ b/packages/api/src/elastic/labels.ts @@ -1,12 +1,12 @@ import { errors } from '@elastic/elasticsearch' import { EntityType } from '../datalayer/pubsub' import { client, INDEX_ALIAS, logger } from './index' -import { Context, Label } from './types' +import { Label, PageContext } from './types' export const addLabelInPage = async ( pageId: string, label: Label, - ctx: Context + ctx: PageContext ): Promise => { try { const { body } = await client.update({ @@ -57,7 +57,7 @@ export const addLabelInPage = async ( export const updateLabelsInPage = async ( pageId: string, labels: Label[], - ctx: Context, + ctx: PageContext, labelsToAdd?: Label[] ): Promise => { try { @@ -105,7 +105,7 @@ export const updateLabelsInPage = async ( export const deleteLabel = async ( label: string, - ctx: Context + ctx: PageContext ): Promise => { try { const { body } = await client.updateByQuery({ @@ -181,7 +181,7 @@ export const deleteLabel = async ( export const updateLabel = async ( label: Label, - ctx: Context + ctx: PageContext ): Promise => { try { const { body } = await client.updateByQuery({ @@ -273,7 +273,7 @@ export const updateLabel = async ( export const setLabelsForHighlight = async ( highlightId: string, labels: Label[], - ctx: Context, + ctx: PageContext, labelsToAdd?: Label[] ): Promise => { try { diff --git a/packages/api/src/elastic/pages.ts b/packages/api/src/elastic/pages.ts index de10b4432..bd6b59e32 100644 --- a/packages/api/src/elastic/pages.ts +++ b/packages/api/src/elastic/pages.ts @@ -18,9 +18,9 @@ import { import { client, INDEX_ALIAS, logger } from './index' import { ArticleSavingRequestStatus, - Context, Label, Page, + PageContext, PageSearchArgs, PageType, ParamSet, @@ -404,7 +404,7 @@ const appendSiteNameFilter = ( export const createPage = async ( page: Page, - ctx: Context + ctx: PageContext ): Promise => { try { if (page.content.length > MAX_CONTENT_LENGTH) { @@ -446,7 +446,7 @@ export const createPage = async ( export const updatePage = async ( id: string, page: Partial, - ctx: Context + ctx: PageContext ): Promise => { try { if (page.content && page.content.length > MAX_CONTENT_LENGTH) { @@ -497,7 +497,7 @@ export const updatePage = async ( export const deletePage = async ( id: string, - ctx: Context + ctx: PageContext ): Promise => { try { const { body } = await client.delete({ @@ -760,7 +760,7 @@ export const countByCreatedAt = async ( export const deletePagesByParam = async ( param: Record, - ctx: Context + ctx: PageContext ): Promise => { try { const params = { @@ -857,7 +857,7 @@ export const searchAsYouType = async ( } export const updatePages = async ( - ctx: Context, + ctx: PageContext, action: BulkActionType, args: PageSearchArgs, maxDocs: number, diff --git a/packages/api/src/elastic/recommendation.ts b/packages/api/src/elastic/recommendation.ts index bb8a6c4c4..3caa544e6 100644 --- a/packages/api/src/elastic/recommendation.ts +++ b/packages/api/src/elastic/recommendation.ts @@ -2,13 +2,13 @@ import { logger } from '.' import { createPage, getPageByParam, updatePage } from './pages' import { ArticleSavingRequestStatus, - Context, Page, + PageContext, Recommendation, } from './types' export const addRecommendation = async ( - ctx: Context, + ctx: PageContext, page: Page, recommendation: Recommendation, highlightIds?: string[] diff --git a/packages/api/src/elastic/types.ts b/packages/api/src/elastic/types.ts index f3c32e87e..1dab0a69f 100644 --- a/packages/api/src/elastic/types.ts +++ b/packages/api/src/elastic/types.ts @@ -204,7 +204,7 @@ const keys = ['_id', 'url', 'slug', 'userId', 'uploadFileId', 'state'] as const export type ParamSet = PickTuple -export interface Context { +export interface PageContext { pubsub: PubsubClient refresh?: boolean uid: string diff --git a/packages/api/src/services/labels.ts b/packages/api/src/services/labels.ts index 5ed059029..5837ddf72 100644 --- a/packages/api/src/services/labels.ts +++ b/packages/api/src/services/labels.ts @@ -1,7 +1,7 @@ import DataLoader from 'dataloader' import { In } from 'typeorm' import { addLabelInPage } from '../elastic/labels' -import { Context } from '../elastic/types' +import { PageContext } from '../elastic/types' import { Label } from '../entity/label' import { Link } from '../entity/link' import { User } from '../entity/user' @@ -37,7 +37,7 @@ const batchGetLabelsFromLinkIds = async ( export const labelsLoader = new DataLoader(batchGetLabelsFromLinkIds) export const addLabelToPage = async ( - ctx: Context, + ctx: PageContext, pageId: string, label: { name: string @@ -114,7 +114,7 @@ export const createLabel = async ( } export const createLabels = async ( - ctx: Context, + ctx: PageContext, labels: CreateLabelInput[] ): Promise => { const user = await getRepository(User).findOneBy({ diff --git a/packages/api/src/services/popular_reads.ts b/packages/api/src/services/popular_reads.ts index a536a6848..7f79406d5 100644 --- a/packages/api/src/services/popular_reads.ts +++ b/packages/api/src/services/popular_reads.ts @@ -3,7 +3,7 @@ import { readFileSync } from 'fs' import path from 'path' import { createPubSubClient } from '../datalayer/pubsub' import { createPage } from '../elastic/pages' -import { ArticleSavingRequestStatus, Context, Page } from '../elastic/types' +import { ArticleSavingRequestStatus, Page, PageContext } from '../elastic/types' import { PageType } from '../generated/graphql' import { generateSlug, stringToHash } from '../utils/helpers' import { logger } from '../utils/logger' @@ -61,7 +61,7 @@ export const addPopularRead = async ( userId: string, name: string ): Promise => { - const ctx: Context = { + const ctx: PageContext = { pubsub: createPubSubClient(), refresh: true, uid: userId,