@@ -130,27 +130,62 @@ export interface SearchedTitle {
130130 /** ページ内のリンク */ links : string [ ] ;
131131}
132132
133- export interface ProjectBackup {
134- name : string ;
135- displayName : string ;
136- exported : number ;
137- pages : {
138- id : PageId ;
139- title : string ;
140- created : number ;
141- updated : number ;
142- lines : string [ ] ;
143- } ;
133+ /** exportもしくはbackupをとったときのページデータ */
134+ export interface ExportedPage < hasMetadata extends true | false = false > {
135+ /** page's title */ title : string ;
136+ /** ページの最終更新日時 (UNIX時刻) */ updated : number ;
137+ /** ページの最終作成日時 (UNIX時刻) */ created : number ;
138+ /** page ID */ id : string ;
139+ /** ページ本文
140+ *
141+ * `hasMetadata === true`のときは行のmetadataが入る
142+ * それ以外の場合は行のテキストが入る
143+ */
144+ lines : hasMetadata extends true ? Omit < Line , "id" | "userId" > [ ]
145+ : string [ ] ;
144146}
145- export interface ProjectBackupWithMetadata {
146- name : string ;
147- displayName : string ;
148- exported : number ;
149- pages : {
150- id : PageId ;
151- title : string ;
152- created : number ;
153- updated : number ;
154- lines : Omit < Line , "id" | "userId" > [ ] ;
155- } ;
147+
148+ export interface ExportedData < hasMetadata extends true | false = false > {
149+ /** project's name */ name : string ;
150+ /** project's display name */ displayName : string ;
151+ /** このデータを生成した日時 (UNIX時刻) */ exported : number ;
152+ /** exported pages */ pages : ExportedPage < hasMetadata > [ ] ;
153+ }
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 ;
156191}
0 commit comments