11import { Omit } from "../utils.ts" ;
2- import { Line } from "../base.ts" ;
2+ import {
3+ CommitId ,
4+ Line ,
5+ Page as PageBase ,
6+ PageId ,
7+ ProjectId ,
8+ UserId ,
9+ } from "../base.ts" ;
310import { NotFoundError , NotMemberError } from "./error.ts" ;
411
512/** 関連ページのメタデータ */
6- export interface RelatedPage {
7- /** ページのid */ id : string ;
8- /** ページのタイトル */ title : string ;
9- /** ページのタイトルを小文字にして、` `を`_`に変換したもの */ titleLc : string ;
10- /** ページのサムネイル画像 */ image : string ;
11- /** ページのサムネイル本文。最大5行 */ descriptions : string [ ] ;
13+ export interface RelatedPage extends PageBase {
1214 /** ページ内のリンク */ linksLc : string [ ] ;
1315 /** おそらく被リンク数 */ linked : number ;
14- /** ページの最終更新日時 */ updated : number ;
15- /** おそらくページの閲覧日時 */ accessed : number ;
1616}
1717
1818/** user information */
1919export interface User {
20- /** user id */ id : string ;
20+ id : UserId ;
2121 /** user name */ name : string ;
2222 /** user display name */ displayName : string ;
2323 /** profile image URL */ photo : string ;
@@ -33,21 +33,12 @@ export interface UserInfo extends User {
3333}
3434
3535/** summary of page information */
36- export interface PageSummary {
37- /** ページのid */ id : string ;
38- /** ページのタイトル */ title : string ;
39- /** ページのサムネイル画像
40- * 存在しなければ`null`
41- */
42- image : string | null ;
43- /** ページのサムネイル本文。最大5行 */ descriptions : string [ ] ;
36+ export interface PageSummary extends PageBase {
4437 /** ピン留めされていたら1, されていなかったら0 */ pin : 0 | 1 ;
4538 /** ページの閲覧回数 */ views : number ;
4639 /** おそらく被リンク数 */ linked : number ;
47- /** 最新の編集コミットid */ commitId : string ;
40+ /** 最新の編集コミットid */ commitId : CommitId ;
4841 /** ページの作成日時 */ created : number ;
49- /** ページの最終更新日時 */ updated : number ;
50- /** Date last visitedに使われる最終アクセス日時 */ accessed : number ;
5142 /** page rank */ pageRank : number ;
5243 /** Page historyの最終生成日時 */ snapshotCreated : number | null ;
5344}
@@ -74,20 +65,17 @@ export interface Page extends PageSummary {
7465}
7566
7667/** the response type of https://scrpabox.io/api/pages/:projectname */
77- export type PageListResponse =
78- | NotFoundError
79- | NotMemberError
80- | {
81- /** data取得先のproject名 */ projectName : string ;
82- /** parameterに渡したskipと同じ */ skip : number ;
83- /** parameterに渡したlimitと同じ */ limit : number ;
84- /** projectの全ページ数 (中身のないページを除く) */ count : number ;
85- /** 取得できたページ情報 */ pages : PageSummary [ ] ;
86- } ;
68+ export interface PageList {
69+ /** data取得先のproject名 */ projectName : string ;
70+ /** parameterに渡したskipと同じ */ skip : number ;
71+ /** parameterに渡したlimitと同じ */ limit : number ;
72+ /** projectの全ページ数 (中身のないページを除く) */ count : number ;
73+ /** 取得できたページ情報 */ pages : PageSummary [ ] ;
74+ }
8775
88- /** project basic information */
89- export interface Project {
90- id : string ;
76+ /** project information which isn't joined */
77+ export interface NotMemberProject {
78+ id : ProjectId ;
9179 name : string ;
9280 displayName : string ;
9381 publicVisible : boolean ;
@@ -98,31 +86,24 @@ export interface Project {
9886 image ?: string ;
9987 created : number ;
10088 updated : number ;
101- isMember : boolean ;
102- plan ?: string ;
89+ isMember : false ;
10390}
10491
105- /** the response type of https://scrpabox.io/api/projects/:projectname */
106- export type ProjectResponse =
107- | NotFoundError
108- | NotMemberError
109- | (
110- & Omit < Omit < Project , "isMember" > , "plan" >
111- & ( { isMember : false } | {
112- isMember : true ;
113- plan ?: string | null ;
114- users : UserInfo [ ] ;
115- admins : string [ ] ;
116- owner : string ;
117- trialing : boolean ;
118- trialMaxPages : number ;
119- skipPayment : boolean ;
120- uploadFileTo : "gcs" ;
121- uploadImaegTo : "gyazo" | "gcs" ;
122- emailAddressPatterns : string [ ] ;
123- backuped : number | null ;
124- } )
125- ) ;
92+ /** project information which is joined */
93+ export interface MemberProject extends Omit < NotMemberProject , "isMember" > {
94+ isMember : true ;
95+ plan ?: string | null ;
96+ users : UserInfo [ ] ;
97+ admins : UserId [ ] ;
98+ owner : UserId ;
99+ trialing : boolean ;
100+ trialMaxPages : number ;
101+ skipPayment : boolean ;
102+ uploadFileTo : "gcs" ;
103+ uploadImaegTo : "gyazo" | "gcs" ;
104+ emailAddressPatterns : string [ ] ;
105+ backuped : number | null ;
106+ }
126107
127108/** the response type of https://scrapbox.io/api/users/me */
128109export type UserResponse =
@@ -140,26 +121,20 @@ export type UserResponse =
140121 } & UserInfo ) ;
141122
142123/** the response type of https://scrapbox.io/api/pages/:projectname/search/titles */
143- export type LinksResponse =
144- | NotFoundError
145- | NotMemberError
146- | {
147- message : "Invalid pageId" ;
148- }
149- | {
150- /** page id */ id : string ;
151- /** page title */ title : string ;
152- /** 画像が存在するかどうか */ hasIcon : boolean ;
153- /** ページの更新日時 */ updated : number ;
154- /** ページ内のリンク */ links : string [ ] ;
155- } [ ] ;
124+ export interface SearchedTitle {
125+ id : PageId ;
126+ /** page title */ title : string ;
127+ /** 画像が存在するかどうか */ hasIcon : boolean ;
128+ /** ページの更新日時 */ updated : number ;
129+ /** ページ内のリンク */ links : string [ ] ;
130+ }
156131
157132export type ProjectBackup = {
158133 name : string ;
159134 displayName : string ;
160135 exported : number ;
161136 pages : {
162- id : string ;
137+ id : PageId ;
163138 title : string ;
164139 created : number ;
165140 updated : number ;
@@ -171,10 +146,10 @@ export type ProjectBackupWithMetadata = {
171146 displayName : string ;
172147 exported : number ;
173148 pages : {
174- id : string ;
149+ id : PageId ;
175150 title : string ;
176151 created : number ;
177152 updated : number ;
178- lines : { text : string ; updated : number ; created : number } [ ] ;
153+ lines : Omit < Line , "id" | "userId" > [ ] ;
179154 } ;
180155} ;
0 commit comments