From 378b4637c159ab34ea116f3315746c8df9fcf427 Mon Sep 17 00:00:00 2001 From: takker99 <37929109+takker99@users.noreply.github.com> Date: Sat, 16 Apr 2022 10:35:54 +0900 Subject: [PATCH 1/4] =?UTF-8?q?:boom:=20Page=E3=81=AB=E4=BD=BF=E3=81=86int?= =?UTF-8?q?erface=E3=81=AE=E5=90=8D=E5=89=8D=E3=82=92=E5=A4=89=E3=81=88?= =?UTF-8?q?=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - s/Page/BasePage - PageSummaryをBasePageに統合した - 統合しても特に問題はなさそうだった --- base.ts | 44 +++++++++++++++++++++++++++++++++++++++----- response.ts | 22 +++++----------------- scrapbox.ts | 6 +++--- 3 files changed, 47 insertions(+), 25 deletions(-) diff --git a/base.ts b/base.ts index 92891d5..b932131 100644 --- a/base.ts +++ b/base.ts @@ -8,20 +8,54 @@ export interface Line { } /** basic information about a page */ -export interface Page { - /** the id of a page */ id: PageId; - /** the title of a page */ title: string; +export interface BasePage { + id: PageId; + + /** 最新の編集コミットid */ + commitId: CommitId; + + /** the title of a page */ + title: string; + /** the thumbnail URL of a page if exists * * set to `null` if not exists */ image: string | null; + /** the thumbnail text of a page. + * * the maximum number of lines is 5. */ descriptions: string[]; - /** ページの最終更新日時 */ updated: UnixTime; - /** Date last visitedに使われる最終アクセス日時 */ accessed: UnixTime; + + /** ピン留めの状態を表す数値 + * + * - 0: ピンされてない + * - 0以外: ピンされている + */ + pin: number; + + /** ページの作成日時 */ + created: UnixTime; + + /** ページの最終更新日時 */ + updated: UnixTime; + + /** Date last visitedに使われる最終アクセス日時 */ + accessed: UnixTime; + + /** Page historyの最終生成日時 */ + snapshotCreated: UnixTime | null; + + /** ページの閲覧回数 */ + views: number; + + /** 被リンク数 */ + linked: number; + + /** page rank */ + pageRank: number; } /** the user id */ diff --git a/response.ts b/response.ts index 7da921c..e046335 100644 --- a/response.ts +++ b/response.ts @@ -1,7 +1,6 @@ import { - CommitId, + BasePage, Line, - Page as PageBase, PageId, ProjectId, StringLc, @@ -10,7 +9,7 @@ import { } from "./base.ts"; /** 関連ページのメタデータ */ -export interface RelatedPage extends PageBase { +export interface RelatedPage extends BasePage { /** ページ内のリンク */ linksLc: StringLc[]; /** おそらく被リンク数 */ linked: number; } @@ -32,19 +31,8 @@ export interface UserInfo extends User { /** accountの更新日時 */ updated: UnixTime; } -/** summary of page information */ -export interface PageSummary extends PageBase { - /** ピン留めされていたら1, されていなかったら0 */ pin: 0 | 1; - /** ページの閲覧回数 */ views: number; - /** おそらく被リンク数 */ linked: number; - /** 最新の編集コミットid */ commitId: CommitId; - /** ページの作成日時 */ created: UnixTime; - /** page rank */ pageRank: number; - /** Page historyの最終生成日時 */ snapshotCreated: UnixTime | null; -} - /** page information */ -export interface Page extends PageSummary { +export interface Page extends BasePage { /** APIを叩いたuserの最終アクセス日時。 * * おそらくこの値を元にテロメアの未読/既読の判別をしている @@ -74,7 +62,7 @@ export interface PageList { /** parameterに渡したskipと同じ */ skip: number; /** parameterに渡したlimitと同じ */ limit: number; /** projectの全ページ数 (中身のないページを除く) */ count: number; - /** 取得できたページ情報 */ pages: PageSummary[]; + /** 取得できたページ情報 */ pages: BasePage[]; } /** project information which isn't joined */ @@ -128,7 +116,7 @@ export type UserResponse = GuestUser | MemberUser; /** the response type of https://scrapbox.io/api/pages/:projectname/search/titles */ export interface SearchedTitle - extends Pick { + extends Pick { /** 画像が存在するかどうか */ hasIcon: boolean; /** ページ内のリンク */ links: string[]; } diff --git a/scrapbox.ts b/scrapbox.ts index c662ccf..dbf972a 100644 --- a/scrapbox.ts +++ b/scrapbox.ts @@ -4,7 +4,7 @@ /// import type { Line } from "./blocks.ts"; -import type { Page as PageBase, StringLc } from "./base.ts"; +import type { BasePage, StringLc } from "./base.ts"; import type { PartialLayout } from "./layout.ts"; import type { AddMenuInit, Item, PageMenu } from "./pageMenu.ts"; import type { EventEmitter } from "./deps/events.ts"; @@ -57,7 +57,7 @@ export type Scrapbox = /** get the current project name */ get name(): string; /** get the dictionary used for comupletion */ - get pages(): Page[]; + get pages(): Candidate[]; }; } & ( @@ -84,7 +84,7 @@ export type Scrapbox = ); /** 入力補完に使われる辞書 */ -export interface Page extends Pick { +export interface Candidate extends Pick { /** true when the page has contents */ exists: boolean; /** whether the page contains any image */ hasIcon?: boolean; /** lower case style of the page title */ titleLc: StringLc; From abbbef7987fe5140e641b873ff24a990d235b00e Mon Sep 17 00:00:00 2001 From: takker99 <37929109+takker99@users.noreply.github.com> Date: Sat, 16 Apr 2022 10:38:13 +0900 Subject: [PATCH 2/4] :boom: s/Line/BaseLine --- base.ts | 2 +- blocks.ts | 4 ++-- response.ts | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/base.ts b/base.ts index b932131..b32b216 100644 --- a/base.ts +++ b/base.ts @@ -1,5 +1,5 @@ /** scrapboxの行のメタデータ */ -export interface Line { +export interface BaseLine { /** 行のid */ id: LineId; /** 行のテキスト */ text: string; /** 一番最後に行を編集した人のid */ userId: UserId; diff --git a/blocks.ts b/blocks.ts index 1a868fc..167328c 100644 --- a/blocks.ts +++ b/blocks.ts @@ -1,8 +1,8 @@ import type { Node, NodeWithoutIndent } from "./nodes.ts"; -import type { Line as LineBase } from "./base.ts"; +import type { BaseLine } from "./base.ts"; export type Line = - & LineBase + & BaseLine & { section: { /** section number */ diff --git a/response.ts b/response.ts index e046335..ba367de 100644 --- a/response.ts +++ b/response.ts @@ -1,6 +1,6 @@ import { + BaseLine, BasePage, - Line, PageId, ProjectId, StringLc, @@ -40,7 +40,7 @@ export interface Page extends BasePage { lastAccessed: UnixTime | null; /** 生成されたPage historyの数 */ snapshotCount: number; /** 不明。削除されたページだとfalse? */ persistent: boolean; - /** ページの行情報 */ lines: Line[]; + /** ページの行情報 */ lines: BaseLine[]; /** ページ内のリンク */ links: string[]; /** ページ内のアイコン */ icons: string[]; /** ページ内に含まれる、scrapbox.ioにアップロードしたファイルへのリンク */ @@ -129,7 +129,7 @@ export interface ExportedPage * `hasMetadata === true`のときは行のmetadataが入る * それ以外の場合は行のテキストが入る */ - lines: hasMetadata extends true ? Omit[] + lines: hasMetadata extends true ? Omit[] : string[]; } From e6e27586c594d1c777365284915b3ef199215df0 Mon Sep 17 00:00:00 2001 From: takker99 <37929109+takker99@users.noreply.github.com> Date: Sat, 16 Apr 2022 10:39:22 +0900 Subject: [PATCH 3/4] =?UTF-8?q?:boom:=20`mod.ts`=E3=82=92=E5=BB=83?= =?UTF-8?q?=E6=AD=A2=E3=81=97=E3=80=81REST=20API=E3=81=A8UserScript?= =?UTF-8?q?=E3=81=A8=E3=81=A7=E5=9E=8B=E3=82=92=E5=88=86=E3=81=91=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mod.ts | 6 ------ rest.ts | 5 +++++ userscript.ts | 3 +++ 3 files changed, 8 insertions(+), 6 deletions(-) delete mode 100644 mod.ts create mode 100644 rest.ts diff --git a/mod.ts b/mod.ts deleted file mode 100644 index cfe8878..0000000 --- a/mod.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from "./response.ts"; -export * from "./error.ts"; -export * from "./base.ts"; -export type { Scrapbox } from "./userscript.ts"; -import * as UserScript from "./userscript.ts"; -export { UserScript }; diff --git a/rest.ts b/rest.ts new file mode 100644 index 0000000..2d8b8ed --- /dev/null +++ b/rest.ts @@ -0,0 +1,5 @@ +/** @module types used at REST API */ + +export * from "./base.ts"; +export * from "./response.ts"; +export * from "./error.ts"; diff --git a/userscript.ts b/userscript.ts index 4303ea1..ec5a3c8 100644 --- a/userscript.ts +++ b/userscript.ts @@ -1,3 +1,6 @@ +/** @module types used at UserScript */ + +export * from "./base.ts"; export * from "./blocks.ts"; export * from "./nodes.ts"; export * from "./layout.ts"; From 0277511201157c61ab8997e4d12a59f50cff798a Mon Sep 17 00:00:00 2001 From: takker99 <37929109+takker99@users.noreply.github.com> Date: Sat, 16 Apr 2022 10:43:52 +0900 Subject: [PATCH 4/4] =?UTF-8?q?:construction=5Fworker:=20=E5=9E=8B?= =?UTF-8?q?=E3=83=81=E3=82=A7=E3=83=83=E3=82=AF=E3=81=99=E3=82=8B=E3=83=95?= =?UTF-8?q?=E3=82=A1=E3=82=A4=E3=83=AB=E3=82=92=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index de66c75..71ff822 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,4 +15,4 @@ jobs: - name: Run lint run: deno lint - name: Run type check - run: deno cache mod.ts + run: deno cache rest.ts userscript.ts