Skip to content

Commit 4fc5c01

Browse files
committed
refactor: ネストした型定義の一部を分離した
1 parent 6ec9e72 commit 4fc5c01

File tree

1 file changed

+39
-33
lines changed

1 file changed

+39
-33
lines changed

response.ts

Lines changed: 39 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -334,27 +334,30 @@ export interface SearchResult {
334334
backend: string;
335335

336336
/** 見つかったページ */
337-
pages: {
338-
id: PageId;
339-
340-
/** page title */
341-
title: string;
342-
343-
/** page thumbnail
344-
*
345-
* 無いときは空文字が入る
346-
*/
347-
image: string;
348-
349-
/** 検索語句の中で、このページに含まれている語句 */
350-
words: string[];
351-
352-
/** 検索語句に一致した行
353-
*
354-
* タイトル行のみが一致した場合は、検索語句の有無にかかわらずその次の行のみが入る
355-
*/
356-
lines: string[];
357-
}[];
337+
pages: FoundPage[];
338+
}
339+
340+
/** /api/pages/:projectname/search/titles で見つかったページ */
341+
export interface FoundPage {
342+
id: PageId;
343+
344+
/** page title */
345+
title: string;
346+
347+
/** page thumbnail
348+
*
349+
* 無いときは空文字が入る
350+
*/
351+
image: string;
352+
353+
/** 検索語句の中で、このページに含まれている語句 */
354+
words: string[];
355+
356+
/** 検索語句に一致した行
357+
*
358+
* タイトル行のみが一致した場合は、検索語句の有無にかかわらずその次の行のみが入る
359+
*/
360+
lines: string[];
358361
}
359362

360363
/** the response type of /api/projects/search/query and /api/projects/search/watch-list */
@@ -366,21 +369,24 @@ export interface ProjectSearchResult {
366369
query: SearchQuery;
367370

368371
/** 見つかったprojects */
369-
projects: {
370-
_id: ProjectId;
372+
projects: FoundProject[];
373+
}
374+
375+
/** /api/projects/search/query や /api/projects/search/watch-list で見つかったproject */
376+
export interface FoundProject {
377+
_id: ProjectId;
371378

372-
/** project name */
373-
name: string;
379+
/** project name */
380+
name: string;
374381

375-
/** projectの表示名 */
376-
displayName: string;
382+
/** projectの表示名 */
383+
displayName: string;
377384

378-
/** project favicon
379-
*
380-
* 無いときは`null`が入るかproperty自体が存在しない
381-
*/
382-
image?: string | null;
383-
}[];
385+
/** project favicon
386+
*
387+
* 無いときは`null`が入るかproperty自体が存在しない
388+
*/
389+
image?: string | null;
384390
}
385391

386392
/** 検索クエリ */

0 commit comments

Comments
 (0)