|
| 1 | +/* |
| 2 | + * *** MIT LICENSE *** |
| 3 | + * ------------------------------------------------------------------------- |
| 4 | + * This code may be modified and distributed under the MIT license. |
| 5 | + * See the LICENSE file for details. |
| 6 | + * ------------------------------------------------------------------------- |
| 7 | + * |
| 8 | + * @summary Collection of collection related types |
| 9 | + * |
| 10 | + * @author Alvis HT Tang <alvis@hilbert.space> |
| 11 | + * @license MIT |
| 12 | + * @copyright Copyright (c) 2021 - All Rights Reserved. |
| 13 | + * ------------------------------------------------------------------------- |
| 14 | + */ |
| 15 | + |
| 16 | +/* eslint-disable @typescript-eslint/naming-convention */ |
| 17 | + |
| 18 | +import type { Block, FullBlock } from './block'; |
| 19 | +import type { RichText } from './format'; |
| 20 | +import type { PropertyMetaMap, PropertyValueMap } from './property'; |
| 21 | +import type { User } from './user'; |
| 22 | + |
| 23 | +/* |
| 24 | + * Parent |
| 25 | + */ |
| 26 | + |
| 27 | +interface ParentDatabase { |
| 28 | + type: 'database_id'; |
| 29 | + database_id: string; |
| 30 | +} |
| 31 | + |
| 32 | +interface ParentPage { |
| 33 | + type: 'page_id'; |
| 34 | + page_id: string; |
| 35 | +} |
| 36 | + |
| 37 | +interface ParentWorkspace { |
| 38 | + type: 'workspace'; |
| 39 | +} |
| 40 | + |
| 41 | +/* |
| 42 | + * Page |
| 43 | + */ |
| 44 | + |
| 45 | +export interface Page { |
| 46 | + object: 'page'; |
| 47 | + id: string; |
| 48 | + parent: ParentDatabase | ParentPage | ParentWorkspace; |
| 49 | + created_time: string; |
| 50 | + last_edited_time: string; |
| 51 | + archived: boolean; |
| 52 | + properties: PropertyValueMap; |
| 53 | + url: string; |
| 54 | +} |
| 55 | + |
| 56 | +export interface FullPage extends Page { |
| 57 | + blocks: FullBlock[]; |
| 58 | + markdown: string; |
| 59 | + title: string; |
| 60 | +} |
| 61 | + |
| 62 | +/* |
| 63 | + * Database |
| 64 | + */ |
| 65 | + |
| 66 | +export interface Database { |
| 67 | + object: 'database'; |
| 68 | + id: string; |
| 69 | + parent: ParentPage | ParentWorkspace; |
| 70 | + created_time: string; |
| 71 | + last_edited_time: string; |
| 72 | + title: RichText[]; |
| 73 | + properties: PropertyMetaMap; |
| 74 | +} |
| 75 | + |
| 76 | +export interface FullDatabase extends Omit<Database, 'title'> { |
| 77 | + pages: FullPage[]; |
| 78 | + title: string; |
| 79 | +} |
| 80 | + |
| 81 | +/* |
| 82 | + * List |
| 83 | + */ |
| 84 | + |
| 85 | +export type Entity = Block | Database | Page | User; |
| 86 | + |
| 87 | +export interface List<E extends Entity = Entity> { |
| 88 | + object: 'list'; |
| 89 | + results: E[]; |
| 90 | + has_more: boolean; |
| 91 | + next_cursor: string | null; |
| 92 | +} |
| 93 | + |
| 94 | +/* eslint-enable */ |
0 commit comments