Skip to content

Commit 5872399

Browse files
committed
✨ Add type definitions of import data
1 parent 5918f7a commit 5872399

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

api/response.ts

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,48 @@ export interface ExportPage<hasMetadata extends true | false = false> {
144144
lines: hasMetadata extends true ? Omit<Line, "id" | "userId">[]
145145
: string[];
146146
}
147+
147148
export interface ExportData<hasMetadata extends true | false = false> {
148149
/** project's name */ name: string;
149150
/** project's display name */ displayName: string;
150151
/** このデータを生成した日時 (UNIX時刻) */ exported: number;
151152
/** exported pages */ pages: ExportPage<hasMetadata>[];
152153
}
154+
155+
/** メタデータ無しインポート用ページデータ */
156+
export interface ImportedLightPage {
157+
/** page's title
158+
*
159+
* `title` should be equal to `lines[0]`
160+
*/
161+
title: string;
162+
/** page's text
163+
*
164+
* `lines[0]` should be equal to `title`
165+
*/
166+
lines: string[];
167+
}
168+
/** インポート用メタデータ付き行データ */
169+
export interface ImportedLine {
170+
/** line text */ text: string;
171+
/** 行の最終更新日時 (UNIX時刻) */ updated?: number;
172+
/** 行の最終作成日時 (UNIX時刻) */ created?: number;
173+
}
174+
/** メタデータ付きインポート用ページデータ */
175+
export interface ImportedPage {
176+
/** page's title
177+
*
178+
* `title` should be equal to `lines[0].text`
179+
*/
180+
title: string;
181+
/** page's line data
182+
*
183+
* `lines[0].text` should be equal to `title`
184+
*/
185+
lines: ImportedLine[];
186+
}
187+
/** JSON data for importing by https://scrapbox.io/api/page-data/import/:projectname.json */
188+
export interface ImportedData<hasMetadata extends true | false = false> {
189+
/** pages importing to a project */
190+
pages: hasMetadata extends true ? ImportedPage[] : ImportedLightPage;
191+
}

0 commit comments

Comments
 (0)