Skip to content

Commit 92d9797

Browse files
authored
Merge pull request #21 from takker99/add-search
👍 /api/pages/:prjectname/search/query のresponseとerrorの型定義を入れた
2 parents 288564f + f979ec2 commit 92d9797

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

api/error.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,3 +52,11 @@ export interface InvalidURLError extends ErrorLike {
5252
export interface BadRequestError extends ErrorLike {
5353
name: "BadRequestError";
5454
}
55+
56+
/** 検索文字列を渡さないと出てくるエラー
57+
*
58+
* 実際のresponseではmessageしか返ってこないことに注意
59+
*/
60+
export interface NoQueryError extends ErrorLike {
61+
name: "NoQueryError";
62+
}

api/response.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,37 @@ export interface TweetInfo {
201201
/** Tweetに添付された画像 */
202202
images: string[];
203203
}
204+
205+
/** the response type of /api/pages/:projectname/search/titles */
206+
export interface SearchResult {
207+
/** 検索したprojectの名前 */
208+
projectName: string;
209+
/** 検索文字列 */
210+
searchQuery: string;
211+
/** 検索語句 */
212+
query: SearchQuery;
213+
/** 検索件数の上限 */
214+
limit: number;
215+
/** 検索件数 */
216+
count: number;
217+
/** 検索文字列と完全一致するタイトルが見つかったら`true` */
218+
existsExactTitleMatch: boolean;
219+
/** 全文検索エンジンの名前 */
220+
backend: string;
221+
/** 見つかったページ */
222+
pages: {
223+
id: string;
224+
title: string;
225+
image: string; // 無いときは''になる
226+
words: string[];
227+
lines: string[]; //検索語句に一致した行。 タイトル行のみが一致した場合は、検索語句の有無にかかわらずその次の行のみが入る
228+
}[];
229+
}
230+
231+
/** 検索クエリ */
232+
export interface SearchQuery {
233+
/** AND検索に使う語句 */
234+
words: string[];
235+
/** NOT検索に使う語句 */
236+
excludes: string[];
237+
}

0 commit comments

Comments
 (0)