Skip to content

Commit 281fa8f

Browse files
authored
Merge pull request #81 from takker99:infobox
fix: Update The respones type of `/api/pages/:project/:title`
2 parents a92fdfb + 43b9c39 commit 281fa8f

File tree

1 file changed

+37
-8
lines changed

1 file changed

+37
-8
lines changed

api/pages/project/title.ts

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,12 @@ export type TranslationLanguage =
132132
| "UK"
133133
| "ZH";
134134

135-
/** page information */
136-
export interface Page extends BasePage {
135+
/** page information
136+
*
137+
* @typeParam HasInfoboxDefinition Whether the page includes the infobox definition
138+
*/
139+
export interface Page<HasInfoboxDefinition extends boolean = false>
140+
extends BasePage {
137141
/** APIを叩いたuserの最終アクセス日時。
138142
*
139143
* おそらくこの値を元にテロメアの未読/既読の判別をしている
@@ -158,17 +162,19 @@ export interface Page extends BasePage {
158162
/** ページ内のアイコン */
159163
icons: string[];
160164

165+
helpfeels: string[];
166+
161167
/** ページ内に含まれる、scrapbox.ioにアップロードしたファイルのfile id */
162168
files: string[];
163169

164-
infoboxDefinition: string[];
170+
infoboxDefinition: HasInfoboxDefinition extends true ? [] : string[];
165171

166172
infoboxResult: InfoboxResult[];
167173

168174
infoboxDisableLinks: string[];
169175

170176
/** 関連ページリスト */
171-
relatedPages: RelatedPages;
177+
relatedPages: RelatedPages<HasInfoboxDefinition>;
172178

173179
/** ページを作成したユーザー */
174180
user: User;
@@ -178,26 +184,49 @@ export interface Page extends BasePage {
178184

179185
/** ページを編集したユーザーのうち、`user`以外の人 */
180186
collaborators: User[];
187+
188+
charsCount: number;
189+
190+
linesCount: number;
181191
}
182192

183-
export interface RelatedPages {
193+
/** A page with infobox definition */
194+
export type PageWithInfoboxDefinition = Page<true>;
195+
196+
/** A page without infobox definition */
197+
export type PageWithoutInfoboxDefinition = Page<false>;
198+
199+
export interface RelatedPages<HasInfoboxDefinition extends boolean = false> {
184200
/** 1 hop links */
185-
links1hop: RelatedPage[];
201+
links1hop:
202+
(HasInfoboxDefinition extends true ? Omit<RelatedPage, "descriptions">
203+
: RelatedPage)[];
186204

187205
/** 2 hop links */
188-
links2hop: RelatedPage[];
206+
links2hop:
207+
(HasInfoboxDefinition extends true ? Omit<RelatedPage, "descriptions">
208+
: RelatedPage)[];
189209

190210
/** external links */
191211
projectLinks1hop: ProjectRelatedPage[];
192212

193-
/** true if there are pages or icons that reference this page */
213+
/** `true` if there are pages or icons that reference this page */
194214
hasBackLinksOrIcons: boolean;
195215

216+
fatHeadwordsLc: string[];
217+
218+
hiddenHeadwordsLc: string[];
219+
196220
/** 2 hop searchのquery */
197221
search: string;
198222

199223
/** 全文検索エンジンの名前 */
200224
searchBackend: string;
225+
226+
charsCount: {
227+
links1hop: number;
228+
links2hop: number;
229+
};
201230
}
202231

203232
export interface InfoboxResult {

0 commit comments

Comments
 (0)