diff --git a/api/response.ts b/api/response.ts index 06e02ab..26bb1e5 100644 --- a/api/response.ts +++ b/api/response.ts @@ -130,27 +130,62 @@ export interface SearchedTitle { /** ページ内のリンク */ links: string[]; } -export interface ProjectBackup { - name: string; - displayName: string; - exported: number; - pages: { - id: PageId; - title: string; - created: number; - updated: number; - lines: string[]; - }; +/** exportもしくはbackupをとったときのページデータ */ +export interface ExportedPage { + /** page's title */ title: string; + /** ページの最終更新日時 (UNIX時刻) */ updated: number; + /** ページの最終作成日時 (UNIX時刻) */ created: number; + /** page ID */ id: string; + /** ページ本文 + * + * `hasMetadata === true`のときは行のmetadataが入る + * それ以外の場合は行のテキストが入る + */ + lines: hasMetadata extends true ? Omit[] + : string[]; } -export interface ProjectBackupWithMetadata { - name: string; - displayName: string; - exported: number; - pages: { - id: PageId; - title: string; - created: number; - updated: number; - lines: Omit[]; - }; + +export interface ExportedData { + /** project's name */ name: string; + /** project's display name */ displayName: string; + /** このデータを生成した日時 (UNIX時刻) */ exported: number; + /** exported pages */ pages: ExportedPage[]; +} + +/** メタデータ無しインポート用ページデータ */ +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?: number; + /** 行の最終作成日時 (UNIX時刻) */ created?: number; +} +/** メタデータ付きインポート用ページデータ */ +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[]; +} +/** JSON data for importing by https://scrapbox.io/api/page-data/import/:projectname.json */ +export interface ImportedData { + /** pages importing to a project */ + pages: hasMetadata extends true ? ImportedPage[] : ImportedLightPage; }