Skip to content

Commit 378b463

Browse files
committed
💥 Pageに使うinterfaceの名前を変えた
- s/Page/BasePage - PageSummaryをBasePageに統合した - 統合しても特に問題はなさそうだった
1 parent 0b64bb5 commit 378b463

File tree

3 files changed

+47
-25
lines changed

3 files changed

+47
-25
lines changed

base.ts

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,54 @@ export interface Line {
88
}
99

1010
/** basic information about a page */
11-
export interface Page {
12-
/** the id of a page */ id: PageId;
13-
/** the title of a page */ title: string;
11+
export interface BasePage {
12+
id: PageId;
13+
14+
/** 最新の編集コミットid */
15+
commitId: CommitId;
16+
17+
/** the title of a page */
18+
title: string;
19+
1420
/** the thumbnail URL of a page if exists
1521
*
1622
* set to `null` if not exists
1723
*/
1824
image: string | null;
25+
1926
/** the thumbnail text of a page.
27+
*
2028
* the maximum number of lines is 5.
2129
*/
2230
descriptions: string[];
23-
/** ページの最終更新日時 */ updated: UnixTime;
24-
/** Date last visitedに使われる最終アクセス日時 */ accessed: UnixTime;
31+
32+
/** ピン留めの状態を表す数値
33+
*
34+
* - 0: ピンされてない
35+
* - 0以外: ピンされている
36+
*/
37+
pin: number;
38+
39+
/** ページの作成日時 */
40+
created: UnixTime;
41+
42+
/** ページの最終更新日時 */
43+
updated: UnixTime;
44+
45+
/** Date last visitedに使われる最終アクセス日時 */
46+
accessed: UnixTime;
47+
48+
/** Page historyの最終生成日時 */
49+
snapshotCreated: UnixTime | null;
50+
51+
/** ページの閲覧回数 */
52+
views: number;
53+
54+
/** 被リンク数 */
55+
linked: number;
56+
57+
/** page rank */
58+
pageRank: number;
2559
}
2660

2761
/** the user id */

response.ts

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
2-
CommitId,
2+
BasePage,
33
Line,
4-
Page as PageBase,
54
PageId,
65
ProjectId,
76
StringLc,
@@ -10,7 +9,7 @@ import {
109
} from "./base.ts";
1110

1211
/** 関連ページのメタデータ */
13-
export interface RelatedPage extends PageBase {
12+
export interface RelatedPage extends BasePage {
1413
/** ページ内のリンク */ linksLc: StringLc[];
1514
/** おそらく被リンク数 */ linked: number;
1615
}
@@ -32,19 +31,8 @@ export interface UserInfo extends User {
3231
/** accountの更新日時 */ updated: UnixTime;
3332
}
3433

35-
/** summary of page information */
36-
export interface PageSummary extends PageBase {
37-
/** ピン留めされていたら1, されていなかったら0 */ pin: 0 | 1;
38-
/** ページの閲覧回数 */ views: number;
39-
/** おそらく被リンク数 */ linked: number;
40-
/** 最新の編集コミットid */ commitId: CommitId;
41-
/** ページの作成日時 */ created: UnixTime;
42-
/** page rank */ pageRank: number;
43-
/** Page historyの最終生成日時 */ snapshotCreated: UnixTime | null;
44-
}
45-
4634
/** page information */
47-
export interface Page extends PageSummary {
35+
export interface Page extends BasePage {
4836
/** APIを叩いたuserの最終アクセス日時。
4937
*
5038
* おそらくこの値を元にテロメアの未読/既読の判別をしている
@@ -74,7 +62,7 @@ export interface PageList {
7462
/** parameterに渡したskipと同じ */ skip: number;
7563
/** parameterに渡したlimitと同じ */ limit: number;
7664
/** projectの全ページ数 (中身のないページを除く) */ count: number;
77-
/** 取得できたページ情報 */ pages: PageSummary[];
65+
/** 取得できたページ情報 */ pages: BasePage[];
7866
}
7967

8068
/** project information which isn't joined */
@@ -128,7 +116,7 @@ export type UserResponse = GuestUser | MemberUser;
128116

129117
/** the response type of https://scrapbox.io/api/pages/:projectname/search/titles */
130118
export interface SearchedTitle
131-
extends Pick<PageBase, "id" | "title" | "updated"> {
119+
extends Pick<BasePage, "id" | "title" | "updated"> {
132120
/** 画像が存在するかどうか */ hasIcon: boolean;
133121
/** ページ内のリンク */ links: string[];
134122
}

scrapbox.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/// <reference lib="deno.ns" />
55

66
import type { Line } from "./blocks.ts";
7-
import type { Page as PageBase, StringLc } from "./base.ts";
7+
import type { BasePage, StringLc } from "./base.ts";
88
import type { PartialLayout } from "./layout.ts";
99
import type { AddMenuInit, Item, PageMenu } from "./pageMenu.ts";
1010
import type { EventEmitter } from "./deps/events.ts";
@@ -57,7 +57,7 @@ export type Scrapbox =
5757
/** get the current project name */
5858
get name(): string;
5959
/** get the dictionary used for comupletion */
60-
get pages(): Page[];
60+
get pages(): Candidate[];
6161
};
6262
}
6363
& (
@@ -84,7 +84,7 @@ export type Scrapbox =
8484
);
8585

8686
/** 入力補完に使われる辞書 */
87-
export interface Page extends Pick<PageBase, "id" | "title" | "updated"> {
87+
export interface Candidate extends Pick<BasePage, "id" | "title" | "updated"> {
8888
/** true when the page has contents */ exists: boolean;
8989
/** whether the page contains any image */ hasIcon?: boolean;
9090
/** lower case style of the page title */ titleLc: StringLc;

0 commit comments

Comments
 (0)