Skip to content
Merged
Show file tree
Hide file tree
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
114 changes: 114 additions & 0 deletions api/commits/project/pageId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
import type {
CommitId,
LineId,
PageId,
StringLc,
UnixTime,
UserId,
} from "../../../base.ts";
import type {
ChangeLine,
CharsCountChange,
DeleteChange,
DescriptionsChange,
FilesChange,
HelpFeelsChange,
ImageChange,
InfoboxDefinitionChange,
InsertChange,
LinesCountChange,
PinChange,
} from "../../../change.ts";

/** the response type of /api/commits/:projectname/:pageid */
export interface CommitsResponse {
/** 指定したページのcommits */
commits: Commit[];
}

/** Scrapboxのページの編集commit */
export interface Commit {
id: CommitId;

/** 一つ前のcommitのID
*
* 存在しないときは`null`になる
*/
parentId: CommitId | null;

pageId: PageId;

/** commitの作成者 */
userId: UserId;

/** commitの作成日時 */
created: UnixTime;

/** 変更内容 */
changes: Change[];

/** 詳細不明 */
kind: "page";
}
/** ページの変更内容 */
export type Change =
| InsertChange
| UpdateChange
| DeleteChange
| LinksChange
| ProjectLinksChange
| IconsChange
| DescriptionsChange
| ImageChange
| FilesChange
| HelpFeelsChange
| InfoboxDefinitionChange
| TitleChange
| LinesCountChange
| CharsCountChange
| PinChange;

/** 既存の行を書き換える変更 */
export interface UpdateChange {
/** 書き換える行のID */
_update: LineId;

/** 行の変更内容 */
lines: ChangeLine;
}

/** ページ中のリンクが変更されると発生する */
export interface LinksChange {
/** 新しいリンク */
links: string[];

/** 新しいリンク */
linksLc: StringLc[];
}

/** ページ中のproject linksが変更されると発生する */
export interface ProjectLinksChange {
/** 新しいリンク */
projectLinks: string[];

/** 新しいリンク */
projectLinksLc: StringLc[];
}

/** ページ中のiconsが変更されると発生する */
export interface IconsChange {
/** 新しいicons */
icons: string[];

/** 新しいicons */
iconsLc: StringLc[];
}

/** ページのタイトルが変更されると発生する */
export interface TitleChange {
/** 新しいタイトル */
title: string;

/** 新しいタイトル */
titleLc: StringLc;
}
11 changes: 11 additions & 0 deletions api/embed-text/twitter.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/** the response type of /api/embed-text/twitter */
export interface TweetInfo {
/** Tweet本文 */
description?: string;

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

/** Tweetに添付された画像 */
images: string[];
}
35 changes: 35 additions & 0 deletions api/page-data/export/project.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { BaseLine, UnixTime } from "../../../base.ts";
import type { Page, UserInfo } from "../../pages/project/title.ts";

/** exportしたときのページデータ */
export interface ExportedPage<hasMetadata extends true | false = false>
extends Pick<Page, "title" | "updated" | "created" | "id" | "views"> {
/** ページ本文
*
* `hasMetadata === true`のときは行のmetadataが入る
* それ以外の場合は行のテキストが入る
*/
lines: hasMetadata extends true ? Omit<BaseLine, "id">[] : string[];
}

/** JSON data exported from https://scrapbox.io/api/page-data/export/:projectname.json */
export interface ExportedData<hasMetadata extends true | false = false> {
/** project's name */
name: string;

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

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

/** project members */
users: UserForExport[];

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

/** user infomation included in exported data */
export interface UserForExport
extends Pick<UserInfo, "id" | "name" | "displayName" | "email"> {}
47 changes: 47 additions & 0 deletions api/page-data/import/project.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import type { UnixTime } from "../../../base.ts";

/** JSON data for importing by https://scrapbox.io/api/page-data/import/:projectname.json */
export interface ImportedData<hasMetadata extends true | false = false> {
/** pages importing to a project */
pages: hasMetadata extends true ? ImportedPage[] : ImportedLightPage[];
}

/** メタデータ無しインポート用ページデータ */
export interface ImportedLightPage {
/** page's title
*
* `title` should be equal to `lines[0]`
*/
title: string;

/** page's text
*
* `lines[0]` should be equal to `title`
*/
lines: string[];
}
/** インポート用メタデータ付き行データ */
export interface ImportedLine {
/** line text */
text: string;

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

/** 行の最終作成日時 (UNIX時刻) */
created?: UnixTime;
}
/** メタデータ付きインポート用ページデータ */
export interface ImportedPage {
/** page's title
*
* `title` should be equal to `lines[0].text`
*/
title: string;

/** page's line data
*
* `lines[0].text` should be equal to `title`
*/
lines: ImportedLine[];
}
14 changes: 14 additions & 0 deletions api/page-snapshots/project/pageId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import type { PageId, UnixTime } from "../../../base.ts";

/** the response type of /api/page-snapshots/:projectname/:pageid */
export interface PageSnapshotList {
pageId: PageId;

/** 作成されているsnapshotsのtimestamp idのリスト */
timestamps: SnapshotTimestamp[];
}

export interface SnapshotTimestamp {
id: string;
created: UnixTime;
}
26 changes: 26 additions & 0 deletions api/page-snapshots/project/pageId/timestampId.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import type { BaseLine, BasePage, UnixTime } from "../../../../base.ts";
import type { User } from "../../../pages/project/title.ts";

/** the response type of /api/page-snapshots/:projectname/:pageid/:timestampid */
export interface PageSnapshotResult {
page: PageWithSnapshot;

snapshot: Snapshot;
}

export interface PageWithSnapshot extends BasePage {
user: Pick<User, "id">;
lastupdateUser: Pick<User, "id"> | null;
}

/** a page snapshot */
export interface Snapshot {
/** snapshotを撮ったときのページタイトル */
title: string;

/** snapshotの作成日時 */
created: UnixTime;

/** snapshotしたページ本文 */
lines: BaseLine[];
}
19 changes: 19 additions & 0 deletions api/pages/project.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { BasePage } from "../../base.ts";

/** 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[];
}
13 changes: 13 additions & 0 deletions api/pages/project/search/files.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { FoundPage, SearchResult } from "./query.ts";

/** the response type of /api/pages/:projectname/search/files */
export interface FileSearchResult
extends Omit<SearchResult, "field" | "pages"> {
/** 見つかったページ */
pages: FoundPageByFile[];
}

/** /api/pages/:projectname/search/files で見つかったページ */
export interface FoundPageByFile extends FoundPage {
file: string;
}
62 changes: 62 additions & 0 deletions api/pages/project/search/query.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import type { PageId } from "../../../../base.ts";

/** the response type of /api/pages/:projectname/search/query */
export interface SearchResult {
/** 検索したprojectの名前 */
projectName: string;

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

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

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

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

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

field: "title" | "helpfeels" | "lines";

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

/** 見つかったページ */
pages: FoundPage[];
}

/** /api/pages/:projectname/search/query で見つかったページ */
export interface FoundPage {
id: PageId;

/** page title */
title: string;

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

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

/** 検索語句に一致した行
*
* タイトル行のみが一致した場合は、検索語句の有無にかかわらずその次の行のみが入る
*/
lines: string[];
}

/** 検索クエリ */
export interface SearchQuery {
/** AND検索に使う語句 */
words: string[];

/** NOT検索に使う語句 */
excludes: string[];
}
11 changes: 11 additions & 0 deletions api/pages/project/search/titles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { BasePage } from "../../../../base.ts";

/** the response type of https://scrapbox.io/api/pages/:projectname/search/titles */
export interface SearchedTitle
extends Pick<BasePage, "id" | "title" | "updated"> {
/** thumbnail URL */
image?: string;

/** ページ内のリンク */
links: string[];
}
31 changes: 31 additions & 0 deletions api/pages/project/search/watch-list.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { ProjectId } from "../../../../base.ts";
import type { SearchQuery } from "./query.ts";

/** the response type of /api/projects/search/query and /api/projects/search/watch-list */
export interface ProjectSearchResult {
/** 検索文字列 */
searchQuery: string;

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

/** 見つかったprojects */
projects: FoundProject[];
}

/** /api/projects/search/query や /api/projects/search/watch-list で見つかったproject */
export interface FoundProject {
_id: ProjectId;

/** project name */
name: string;

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

/** project favicon
*
* 無いときは`null`が入るかproperty自体が存在しない
*/
image?: string | null;
}
Loading