Skip to content

Commit 5542638

Browse files
authored
Merge pull request #26 from takker99/layout
BREAKING CHANGES: deprecate `mod.ts`
2 parents 0b64bb5 + 0277511 commit 5542638

File tree

8 files changed

+62
-38
lines changed

8 files changed

+62
-38
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ jobs:
1515
- name: Run lint
1616
run: deno lint
1717
- name: Run type check
18-
run: deno cache mod.ts
18+
run: deno cache rest.ts userscript.ts

base.ts

Lines changed: 40 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/** scrapboxの行のメタデータ */
2-
export interface Line {
2+
export interface BaseLine {
33
/** 行のid */ id: LineId;
44
/** 行のテキスト */ text: string;
55
/** 一番最後に行を編集した人のid */ userId: UserId;
@@ -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 */

blocks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type { Node, NodeWithoutIndent } from "./nodes.ts";
2-
import type { Line as LineBase } from "./base.ts";
2+
import type { BaseLine } from "./base.ts";
33

44
export type Line =
5-
& LineBase
5+
& BaseLine
66
& {
77
section: {
88
/** section number */

mod.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

response.ts

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
2-
CommitId,
3-
Line,
4-
Page as PageBase,
2+
BaseLine,
3+
BasePage,
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,27 +31,16 @@ 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
* おそらくこの値を元にテロメアの未読/既読の判別をしている
5139
*/
5240
lastAccessed: UnixTime | null;
5341
/** 生成されたPage historyの数 */ snapshotCount: number;
5442
/** 不明。削除されたページだとfalse? */ persistent: boolean;
55-
/** ページの行情報 */ lines: Line[];
43+
/** ページの行情報 */ lines: BaseLine[];
5644
/** ページ内のリンク */ links: string[];
5745
/** ページ内のアイコン */ icons: string[];
5846
/** ページ内に含まれる、scrapbox.ioにアップロードしたファイルへのリンク */
@@ -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
}
@@ -141,7 +129,7 @@ export interface ExportedPage<hasMetadata extends true | false = false>
141129
* `hasMetadata === true`のときは行のmetadataが入る
142130
* それ以外の場合は行のテキストが入る
143131
*/
144-
lines: hasMetadata extends true ? Omit<Line, "id" | "userId">[]
132+
lines: hasMetadata extends true ? Omit<BaseLine, "id" | "userId">[]
145133
: string[];
146134
}
147135

rest.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/** @module types used at REST API */
2+
3+
export * from "./base.ts";
4+
export * from "./response.ts";
5+
export * from "./error.ts";

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;

userscript.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/** @module types used at UserScript */
2+
3+
export * from "./base.ts";
14
export * from "./blocks.ts";
25
export * from "./nodes.ts";
36
export * from "./layout.ts";

0 commit comments

Comments
 (0)