Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
159 changes: 126 additions & 33 deletions response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ import {
} from "./base.ts";
import { Commit } from "./commit.ts";

/** 関連ページのメタデータ */
export interface RelatedPage extends BasePage {
/** ページ内のリンク */ linksLc: StringLc[];
/** おそらく被リンク数 */ linked: number;
}

/** user information */
export interface User {
id: UserId;
Expand All @@ -39,31 +33,93 @@ export interface Page extends BasePage {
* おそらくこの値を元にテロメアの未読/既読の判別をしている
*/
lastAccessed: UnixTime | null;
/** 生成されたPage historyの数 */ snapshotCount: number;
/** 不明。削除されたページだとfalse? */ persistent: boolean;
/** ページの行情報 */ lines: BaseLine[];
/** ページ内のリンク */ links: string[];
/** ページ内のアイコン */ icons: string[];

/** 生成されたPage historyの数 */
snapshotCount: number;

/** 空リンクだと`false` */
persistent: boolean;

/** ページの行情報 */
lines: BaseLine[];

/** ページ内のリンク */
links: string[];

/** ページ内の外部プロジェクトリンク */
projectLinks: string[];

/** ページ内のアイコン */
icons: string[];

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

/** 関連ページリスト */
relatedPages: {
/** 1 hop links */ links1hop: RelatedPage[];
/** 2 hop links */ links2hop: RelatedPage[];
/** このページを参照しているページorアイコンがあればtrue */
hasBackLinksOrIcons: boolean;
};
/** 最後にページを更新したユーザー */ user: User;
/** ページを編集したユーザーのうち、`user`以外の人 */ collaborators: User[];
relatedPages: RelatedPages;

/** 最後にページを更新したユーザー */
user: User;

/** ページを編集したユーザーのうち、`user`以外の人 */
collaborators: User[];
}

export interface RelatedPages {
/** 1 hop links */
links1hop: RelatedPage[];

/** 2 hop links */
links2hop: RelatedPage[];

/** external links */
projectLinks1hop: ProjectRelatedPage[];

/** このページを参照しているページorアイコンがあればtrue */
hasBackLinksOrIcons: boolean;
}

/** 関連ページのメタデータ */
export interface RelatedPage extends
Pick<
BasePage,
| "id"
| "title"
| "image"
| "descriptions"
| "linked"
| "updated"
| "accessed"
> {
/** page title */
titleLc: StringLc;

/** ページ内のリンク */
linksLc: StringLc[];
}

/** 外部プロジェクトの関連ページ */
export interface ProjectRelatedPage extends Omit<RelatedPage, "linksLc"> {
/** project name */
projectName: string;
}

/** the response type of https://scrpabox.io/api/pages/:projectname */
export interface PageList {
/** data取得先のproject名 */ projectName: string;
/** parameterに渡したskipと同じ */ skip: number;
/** parameterに渡したlimitと同じ */ limit: number;
/** projectの全ページ数 (中身のないページを除く) */ count: number;
/** 取得できたページ情報 */ pages: BasePage[];
/** data取得先のproject名 */
projectName: string;

/** parameterに渡したskipと同じ */
skip: number;

/** parameterに渡したlimitと同じ */
limit: number;

/** projectの全ページ数 (中身のないページを除く) */
count: number;

/** 取得できたページ情報 */
pages: BasePage[];
}

/** project information which isn't joined */
Expand Down Expand Up @@ -118,8 +174,11 @@ export type UserResponse = GuestUser | MemberUser;
/** the response type of https://scrapbox.io/api/pages/:projectname/search/titles */
export interface SearchedTitle
extends Pick<BasePage, "id" | "title" | "updated"> {
/** 画像が存在するかどうか */ hasIcon: boolean;
/** ページ内のリンク */ links: string[];
/** 画像が存在するかどうか */
hasIcon: boolean;

/** ページ内のリンク */
links: string[];
}

/** exportもしくはbackupをとったときのページデータ */
Expand All @@ -135,10 +194,17 @@ export interface ExportedPage<hasMetadata extends true | false = false>
}

export interface ExportedData<hasMetadata extends true | false = false> {
/** project's name */ name: string;
/** project's display name */ displayName: string;
/** このデータを生成した日時 (UNIX時刻) */ exported: UnixTime;
/** exported pages */ pages: ExportedPage<hasMetadata>[];
/** project's name */
name: string;

/** project's display name */
displayName: string;

/** このデータを生成した日時 (UNIX時刻) */
exported: UnixTime;

/** exported pages */
pages: ExportedPage<hasMetadata>[];
}

/** メタデータ無しインポート用ページデータ */
Expand All @@ -148,6 +214,7 @@ export interface ImportedLightPage {
* `title` should be equal to `lines[0]`
*/
title: string;

/** page's text
*
* `lines[0]` should be equal to `title`
Expand All @@ -156,9 +223,14 @@ export interface ImportedLightPage {
}
/** インポート用メタデータ付き行データ */
export interface ImportedLine {
/** line text */ text: string;
/** 行の最終更新日時 (UNIX時刻) */ updated?: UnixTime;
/** 行の最終作成日時 (UNIX時刻) */ created?: UnixTime;
/** line text */
text: string;

/** 行の最終更新日時 (UNIX時刻) */
updated?: UnixTime;

/** 行の最終作成日時 (UNIX時刻) */
created?: UnixTime;
}
/** メタデータ付きインポート用ページデータ */
export interface ImportedPage {
Expand All @@ -167,6 +239,7 @@ export interface ImportedPage {
* `title` should be equal to `lines[0].text`
*/
title: string;

/** page's line data
*
* `lines[0].text` should be equal to `title`
Expand All @@ -183,10 +256,13 @@ export interface ImportedData<hasMetadata extends true | false = false> {
export interface TweetInfo {
/** Tweet本文 */
description: string;

/** Tweet投稿者のuser name*/
userName: string;

/** Tweet投稿者の表示名 */
screenName: string;

/** Tweetに添付された画像 */
images: string[];
}
Expand All @@ -195,30 +271,41 @@ export interface TweetInfo {
export interface SearchResult {
/** 検索したprojectの名前 */
projectName: string;

/** 検索文字列 */
searchQuery: string;

/** 検索語句 */
query: SearchQuery;

/** 検索件数の上限 */
limit: number;

/** 検索件数 */
count: number;

/** 検索文字列と完全一致するタイトルが見つかったら`true` */
existsExactTitleMatch: boolean;

/** 全文検索エンジンの名前 */
backend: string;

/** 見つかったページ */
pages: {
id: PageId;

/** page title */
title: string;

/** page thumbnail
*
* 無いときは空文字が入る
*/
image: string;

/** 検索語句の中で、このページに含まれている語句 */
words: string[];

/** 検索語句に一致した行
*
* タイトル行のみが一致した場合は、検索語句の有無にかかわらずその次の行のみが入る
Expand All @@ -231,15 +318,20 @@ export interface SearchResult {
export interface ProjectSearchResult {
/** 検索文字列 */
searchQuery: string;

/** 検索語句 */
query: SearchQuery;

/** 見つかったprojects */
projects: {
_id: ProjectId;

/** project name */
name: string;

/** projectの表示名 */
displayName: string;

/** project favicon
*
* 無いときは`null`が入るかproperty自体が存在しない
Expand All @@ -252,6 +344,7 @@ export interface ProjectSearchResult {
export interface SearchQuery {
/** AND検索に使う語句 */
words: string[];

/** NOT検索に使う語句 */
excludes: string[];
}
Expand Down