Skip to content

Commit ac961c0

Browse files
committed
feat: notion block type add
1 parent 5758350 commit ac961c0

File tree

7 files changed

+390
-0
lines changed

7 files changed

+390
-0
lines changed

packages/#types/package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "@repo/notion-types",
3+
"version": "0.0.0",
4+
"private": true,
5+
"license": "MIT",
6+
"devDependencies": {
7+
"typescript": "^5.6.3",
8+
"@repo/eslint-config": "workspace:*",
9+
"@repo/typescript-config": "workspace:*"
10+
}
11+
}

packages/#types/src/notion-block.ts

Lines changed: 341 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,341 @@
1+
import { User } from './notion-user';
2+
3+
export interface Block {
4+
object: 'block';
5+
id: string;
6+
parent?: BlockParent;
7+
type: BlockType;
8+
created_time?: string; // ISO 8601 문자열
9+
created_by?: User;
10+
last_edited_time?: string; // ISO 8601 문자열
11+
last_edited_by?: User;
12+
archived?: boolean;
13+
in_trash?: boolean;
14+
has_children?: boolean;
15+
}
16+
17+
export type BlockType =
18+
| 'bookmark'
19+
| 'breadcrumb'
20+
| 'bulleted_list_item'
21+
| 'callout'
22+
| 'child_database'
23+
| 'child_page'
24+
| 'column'
25+
| 'column_list'
26+
| 'divider'
27+
| 'embed'
28+
| 'equation'
29+
| 'file'
30+
| 'heading_1'
31+
| 'heading_2'
32+
| 'heading_3'
33+
| 'image'
34+
| 'link_preview'
35+
| 'link_to_page'
36+
| 'numbered_list_item'
37+
| 'paragraph'
38+
| 'pdf'
39+
| 'quote'
40+
| 'synced_block'
41+
| 'table'
42+
| 'table_of_contents'
43+
| 'table_row'
44+
| 'template'
45+
| 'to_do'
46+
| 'toggle'
47+
| 'unsupported'
48+
| 'video'
49+
| 'code';
50+
51+
export interface BlockParent {
52+
type: 'page_id' | 'database_id' | 'block_id' | 'workspace';
53+
page_id?: string;
54+
database_id?: string;
55+
block_id?: string;
56+
workspace?: boolean;
57+
}
58+
59+
export type RichTextType = 'text' | 'mention' | 'equation';
60+
61+
export type ColorType =
62+
| 'default'
63+
| 'gray'
64+
| 'brown'
65+
| 'orange'
66+
| 'yellow'
67+
| 'green'
68+
| 'blue'
69+
| 'purple'
70+
| 'pink'
71+
| 'red'
72+
| 'gray_background'
73+
| 'brown_background'
74+
| 'orange_background'
75+
| 'yellow_background'
76+
| 'green_background'
77+
| 'blue_background'
78+
| 'purple_background'
79+
| 'pink_background'
80+
| 'red_background';
81+
82+
export interface RichText {
83+
type: RichTextType;
84+
text?: {
85+
content: string;
86+
link?: {
87+
url: string;
88+
};
89+
};
90+
mention?: MentionType;
91+
equation?: {
92+
expression: string;
93+
};
94+
annotations: {
95+
bold: boolean;
96+
italic: boolean;
97+
strikethrough: boolean;
98+
underline: boolean;
99+
code: boolean;
100+
color: ColorType;
101+
};
102+
plain_text: string;
103+
href?: string;
104+
}
105+
106+
export type File = {
107+
type: 'file' | 'external';
108+
file?: {
109+
url: string; // Notion 내부 파일의 URL
110+
expiry_time: string; // 파일의 만료 시간 (ISO 8601 형식)
111+
};
112+
external?: {
113+
url: string; // 외부 파일의 URL
114+
};
115+
};
116+
117+
export type Emoji = {
118+
type: 'emoji';
119+
emoji: string;
120+
};
121+
122+
export interface BookmarkBlock extends Block {
123+
type: 'bookmark';
124+
bookmark: {
125+
caption: RichText[];
126+
url: string;
127+
};
128+
}
129+
130+
export interface BreadcrumbBlock extends Block {
131+
type: 'breadcrumb';
132+
}
133+
134+
export interface BulletedListItemBlock extends Block {
135+
type: 'bulleted_list_item';
136+
bulleted_list_item: {
137+
rich_text: RichText[];
138+
color: ColorType; // Notion 색상 옵션
139+
children?: Block[]; // 하위 블록
140+
};
141+
}
142+
143+
export interface CalloutBlock extends Block {
144+
type: 'callout';
145+
callout: {
146+
rich_text: RichText[];
147+
icon?: File | Emoji; // 아이콘 (예: 이모지, 파일 등)
148+
color: ColorType;
149+
};
150+
}
151+
152+
export interface ChildDatabaseBlock extends Block {
153+
type: 'child_database';
154+
child_database: {
155+
title: string;
156+
};
157+
}
158+
159+
export interface ChildPageBlock extends Block {
160+
type: 'child_page';
161+
child_page: {
162+
title: string;
163+
};
164+
}
165+
166+
export interface CodeBlock extends Block {
167+
type: 'code';
168+
code: {
169+
caption: RichText[];
170+
rich_text: RichText[];
171+
language: string;
172+
};
173+
}
174+
175+
export interface ColumnBlock extends Block {
176+
type: 'column';
177+
}
178+
179+
export interface ColumnListBlock extends Block {
180+
type: 'column_list';
181+
}
182+
183+
export interface DividerBlock extends Block {
184+
type: 'divider';
185+
}
186+
187+
export interface EmbedBlock extends Block {
188+
type: 'embed';
189+
embed: {
190+
url: string;
191+
};
192+
}
193+
194+
export interface EquationBlock extends Block {
195+
type: 'equation';
196+
equation: {
197+
expression: string;
198+
};
199+
}
200+
201+
export interface FileBlock extends Block {
202+
type: 'file';
203+
file: {
204+
caption: RichText[];
205+
name: string;
206+
} & File;
207+
}
208+
209+
export interface Heading1Block extends Block {
210+
type: 'heading_1';
211+
heading_1: {
212+
rich_text: RichText[];
213+
color: ColorType;
214+
is_toggleable: boolean;
215+
};
216+
}
217+
218+
export interface Heading2Block extends Block {
219+
type: 'heading_2';
220+
heading_2: {
221+
rich_text: RichText[];
222+
color: ColorType;
223+
is_toggleable: boolean;
224+
};
225+
}
226+
227+
export interface Heading3Block extends Block {
228+
type: 'heading_3';
229+
heading_3: {
230+
rich_text: RichText[];
231+
color: ColorType;
232+
is_toggleable: boolean;
233+
};
234+
}
235+
236+
export interface ImageBlock extends Block {
237+
type: 'image';
238+
image: File;
239+
}
240+
241+
export interface LinkPreviewBlock extends Block {
242+
type: 'link_preview';
243+
link_preview: {
244+
url: string;
245+
};
246+
}
247+
248+
export interface NumberedListItemBlock extends Block {
249+
type: 'numbered_list_item';
250+
numbered_list_item: {
251+
rich_text: RichText[];
252+
color: ColorType;
253+
children?: Block[];
254+
};
255+
}
256+
257+
export interface ParagraphBlock extends Block {
258+
type: 'paragraph';
259+
paragraph: {
260+
rich_text: RichText[];
261+
color: ColorType;
262+
children?: Block[];
263+
};
264+
}
265+
266+
export interface PDFBlock extends Block {
267+
type: 'pdf';
268+
pdf: {
269+
caption: RichText[];
270+
} & File;
271+
}
272+
273+
export interface QuoteBlock extends Block {
274+
type: 'quote';
275+
quote: {
276+
rich_text: RichText[];
277+
color: ColorType;
278+
children?: Block[];
279+
};
280+
}
281+
282+
export interface SyncedBlock extends Block {
283+
type: 'synced_block';
284+
synced_block: {
285+
synced_from: null | {
286+
block_id: string;
287+
};
288+
children?: Block[];
289+
};
290+
}
291+
292+
export interface TableBlock extends Block {
293+
type: 'table';
294+
table: {
295+
table_width: number;
296+
has_column_header: boolean;
297+
has_row_header: boolean;
298+
};
299+
}
300+
301+
export interface TableOfContentsBlock extends Block {
302+
type: 'table_of_contents';
303+
table_of_contents: {
304+
color: ColorType;
305+
};
306+
}
307+
308+
/**
309+
* !deprecated
310+
*/
311+
export interface TemplateBlock extends Block {
312+
type: 'template';
313+
template: {
314+
rich_text: RichText[];
315+
children?: Block[];
316+
};
317+
}
318+
319+
export interface ToDoBlock extends Block {
320+
type: 'to_do';
321+
to_do: {
322+
rich_text: RichText[];
323+
checked?: boolean;
324+
color: ColorType;
325+
children?: Block[];
326+
};
327+
}
328+
329+
export interface ToggleBlock extends Block {
330+
type: 'toggle';
331+
toggle: {
332+
rich_text: RichText[];
333+
color: ColorType;
334+
children?: Block[];
335+
};
336+
}
337+
338+
export interface VideoBlock extends Block {
339+
type: 'video';
340+
video: File;
341+
}

packages/#types/src/notion-user.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export interface User {
2+
object: 'user';
3+
id: string;
4+
type: 'person' | 'bot';
5+
name?: string;
6+
avatar_url?: string;
7+
}

packages/#types/tsconfig.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "@repo/typescript-config/react-library.json",
3+
"compilerOptions": {
4+
"outDir": "dist"
5+
},
6+
"include": ["src"],
7+
"exclude": ["node_modules", "dist"]
8+
}

packages/#types/tsconfig.lint.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": "@repo/typescript-config/react-library.json",
3+
"compilerOptions": {
4+
"outDir": "dist"
5+
},
6+
"include": ["src", "turbo"],
7+
"exclude": ["node_modules", "dist"]
8+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
let a = 1;
2+
3+
export { a };

0 commit comments

Comments
 (0)