Skip to content

Commit 35c504c

Browse files
authored
Merge pull request #48 from takker99:refactor
Refactoring
2 parents 6ec9e72 + 7e74a33 commit 35c504c

File tree

1 file changed

+90
-42
lines changed

1 file changed

+90
-42
lines changed

response.ts

Lines changed: 90 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,33 @@ import { Commit } from "./commit.ts";
1212
/** user information */
1313
export interface User {
1414
id: UserId;
15-
/** user name */ name: string;
16-
/** user display name */ displayName: string;
17-
/** profile image URL */ photo: string;
15+
16+
/** user name */
17+
name: string;
18+
19+
/** user display name */
20+
displayName: string;
21+
22+
/** profile image URL */
23+
photo: string;
1824
}
1925

2026
/** user detailed information */
2127
export interface UserInfo extends User {
22-
/** user e-mail */ email: string;
23-
/** whether the user is a pro user or not */ pro: boolean;
24-
/** login provider */ provider: "google" | "microsoft" | "email";
25-
/** accountの作成日時 */ created: UnixTime;
26-
/** accountの更新日時 */ updated: UnixTime;
28+
/** user e-mail */
29+
email: string;
30+
31+
/** whether the user is a pro user or not */
32+
pro: boolean;
33+
34+
/** login provider */
35+
provider: "google" | "microsoft" | "email";
36+
37+
/** creation time of the account */
38+
created: UnixTime;
39+
40+
/** update time of the account */
41+
updated: UnixTime;
2742
}
2843

2944
/** page information */
@@ -52,7 +67,7 @@ export interface Page extends BasePage {
5267
/** ページ内のアイコン */
5368
icons: string[];
5469

55-
/** ページ内に含まれる、scrapbox.ioにアップロードしたファイルへのリンク */
70+
/** ページ内に含まれる、scrapbox.ioにアップロードしたファイルのfile id */
5671
files: string[];
5772

5873
/** 関連ページリスト */
@@ -129,22 +144,33 @@ export interface PageList {
129144
/** project information */
130145
export interface Project {
131146
id: ProjectId;
147+
132148
name: string;
149+
133150
displayName: string;
151+
134152
publicVisible: boolean;
153+
135154
loginStrategies: string[];
155+
136156
theme: string;
157+
137158
gyazoTeamsName: string | null;
159+
138160
googleAnalyticsCode: string | null;
161+
139162
/** planの種類
140163
*
141164
* public projectの場合は`null`になる
142165
*
143166
* 古いprojectだとpropertyが生えていない
144167
*/
145168
plan?: string | null;
169+
146170
created: UnixTime;
171+
147172
updated: UnixTime;
173+
148174
isMember: boolean;
149175
}
150176

@@ -156,35 +182,51 @@ export interface ProjectResponse {
156182
/** project information which isn't joined */
157183
export interface NotMemberProject extends Omit<Project, "isMember"> {
158184
image?: string;
185+
159186
isMember: false;
160187
}
161188

162189
/** project information which is joined */
163190
export interface MemberProject extends Omit<NotMemberProject, "isMember"> {
164191
isMember: true;
192+
165193
plan?: string | null;
194+
166195
users: UserInfo[];
196+
167197
admins: UserId[];
198+
168199
owner: UserId;
200+
169201
trialing: boolean;
202+
170203
trialMaxPages: number;
204+
171205
skipPayment: boolean;
206+
172207
uploadFileTo: "gcs";
208+
173209
uploadImaegTo: "gyazo" | "gcs";
210+
174211
emailAddressPatterns: string[];
212+
175213
backuped: UnixTime | null;
176214
}
177215

178216
export interface GuestUser {
179217
isGuest: true;
218+
180219
csrfToken: string;
181220
}
182221

183222
export interface MemberUser extends UserInfo {
184223
isGuest: false;
224+
185225
csrfToken: string;
226+
186227
config: {
187228
userScript: boolean;
229+
188230
emacsBinding: boolean;
189231
};
190232
}
@@ -334,27 +376,30 @@ export interface SearchResult {
334376
backend: string;
335377

336378
/** 見つかったページ */
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-
}[];
379+
pages: FoundPage[];
380+
}
381+
382+
/** /api/pages/:projectname/search/titles で見つかったページ */
383+
export interface FoundPage {
384+
id: PageId;
385+
386+
/** page title */
387+
title: string;
388+
389+
/** page thumbnail
390+
*
391+
* 無いときは空文字が入る
392+
*/
393+
image: string;
394+
395+
/** 検索語句の中で、このページに含まれている語句 */
396+
words: string[];
397+
398+
/** 検索語句に一致した行
399+
*
400+
* タイトル行のみが一致した場合は、検索語句の有無にかかわらずその次の行のみが入る
401+
*/
402+
lines: string[];
358403
}
359404

360405
/** the response type of /api/projects/search/query and /api/projects/search/watch-list */
@@ -366,21 +411,24 @@ export interface ProjectSearchResult {
366411
query: SearchQuery;
367412

368413
/** 見つかったprojects */
369-
projects: {
370-
_id: ProjectId;
414+
projects: FoundProject[];
415+
}
371416

372-
/** project name */
373-
name: string;
417+
/** /api/projects/search/query や /api/projects/search/watch-list で見つかったproject */
418+
export interface FoundProject {
419+
_id: ProjectId;
374420

375-
/** projectの表示名 */
376-
displayName: string;
421+
/** project name */
422+
name: string;
377423

378-
/** project favicon
379-
*
380-
* 無いときは`null`が入るかproperty自体が存在しない
381-
*/
382-
image?: string | null;
383-
}[];
424+
/** projectの表示名 */
425+
displayName: string;
426+
427+
/** project favicon
428+
*
429+
* 無いときは`null`が入るかproperty自体が存在しない
430+
*/
431+
image?: string | null;
384432
}
385433

386434
/** 検索クエリ */

0 commit comments

Comments
 (0)