From f979ec257f30b43f6db52fe7a5f61c8fcbeddafb Mon Sep 17 00:00:00 2001 From: takker99 <37929109+takker99@users.noreply.github.com> Date: Fri, 25 Mar 2022 18:49:50 +0900 Subject: [PATCH] =?UTF-8?q?:+1:=20/api/pages/:prjectname/search/query=20?= =?UTF-8?q?=E3=81=AEresponse=E3=81=A8error=E3=81=AE=E5=9E=8B=E5=AE=9A?= =?UTF-8?q?=E7=BE=A9=E3=82=92=E5=85=A5=E3=82=8C=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/error.ts | 8 ++++++++ api/response.ts | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/api/error.ts b/api/error.ts index 4cb045a..06ffa92 100644 --- a/api/error.ts +++ b/api/error.ts @@ -52,3 +52,11 @@ export interface InvalidURLError extends ErrorLike { export interface BadRequestError extends ErrorLike { name: "BadRequestError"; } + +/** 検索文字列を渡さないと出てくるエラー + * + * 実際のresponseではmessageしか返ってこないことに注意 + */ +export interface NoQueryError extends ErrorLike { + name: "NoQueryError"; +} diff --git a/api/response.ts b/api/response.ts index f7c9951..57a04aa 100644 --- a/api/response.ts +++ b/api/response.ts @@ -201,3 +201,37 @@ export interface TweetInfo { /** Tweetに添付された画像 */ images: string[]; } + +/** the response type of /api/pages/:projectname/search/titles */ +export interface SearchResult { + /** 検索したprojectの名前 */ + projectName: string; + /** 検索文字列 */ + searchQuery: string; + /** 検索語句 */ + query: SearchQuery; + /** 検索件数の上限 */ + limit: number; + /** 検索件数 */ + count: number; + /** 検索文字列と完全一致するタイトルが見つかったら`true` */ + existsExactTitleMatch: boolean; + /** 全文検索エンジンの名前 */ + backend: string; + /** 見つかったページ */ + pages: { + id: string; + title: string; + image: string; // 無いときは''になる + words: string[]; + lines: string[]; //検索語句に一致した行。 タイトル行のみが一致した場合は、検索語句の有無にかかわらずその次の行のみが入る + }[]; +} + +/** 検索クエリ */ +export interface SearchQuery { + /** AND検索に使う語句 */ + words: string[]; + /** NOT検索に使う語句 */ + excludes: string[]; +}