rotion 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/README.md +2 -1
  2. package/dist/exporter/api.d.ts +4 -0
  3. package/dist/exporter/api.js +22 -0
  4. package/dist/exporter/api.js.map +1 -1
  5. package/dist/exporter/blocks.js +30 -1
  6. package/dist/exporter/blocks.js.map +1 -1
  7. package/dist/exporter/files.d.ts +2 -1
  8. package/dist/exporter/files.js +18 -6
  9. package/dist/exporter/files.js.map +1 -1
  10. package/dist/exporter/github.d.ts +242 -0
  11. package/dist/exporter/github.js +44 -0
  12. package/dist/exporter/github.js.map +1 -0
  13. package/dist/exporter/types.d.ts +17 -1
  14. package/dist/exporter/types.js.map +1 -1
  15. package/dist/ui/cjs/index.css +1 -1
  16. package/dist/ui/cjs/index.js +1 -1
  17. package/dist/ui/cjs/index.js.map +1 -1
  18. package/dist/ui/cjs/types/exporter/api.d.ts +4 -0
  19. package/dist/ui/cjs/types/exporter/files.d.ts +2 -1
  20. package/dist/ui/cjs/types/exporter/github.d.ts +242 -0
  21. package/dist/ui/cjs/types/exporter/types.d.ts +17 -1
  22. package/dist/ui/cjs/types/ui/components/Icon/Icon.d.ts +1 -1
  23. package/dist/ui/cjs/types/ui/components/Page/LinkPreviewBlock/LinkPreviewBlock.types.d.ts +2 -2
  24. package/dist/ui/esm/index.css +1 -1
  25. package/dist/ui/esm/index.js +1 -1
  26. package/dist/ui/esm/index.js.map +1 -1
  27. package/dist/ui/esm/types/exporter/api.d.ts +4 -0
  28. package/dist/ui/esm/types/exporter/files.d.ts +2 -1
  29. package/dist/ui/esm/types/exporter/github.d.ts +242 -0
  30. package/dist/ui/esm/types/exporter/types.d.ts +17 -1
  31. package/dist/ui/esm/types/ui/components/Icon/Icon.d.ts +1 -1
  32. package/dist/ui/esm/types/ui/components/Page/LinkPreviewBlock/LinkPreviewBlock.types.d.ts +2 -2
  33. package/dist/ui/style-without-dark.css +1 -1
  34. package/dist/ui/types.d.ts +38 -4
  35. package/dist/ui/umd/index.css +1 -1
  36. package/dist/ui/umd/index.js +1 -1
  37. package/dist/ui/umd/index.js.map +1 -1
  38. package/dist/ui/umd/types/exporter/api.d.ts +4 -0
  39. package/dist/ui/umd/types/exporter/files.d.ts +2 -1
  40. package/dist/ui/umd/types/exporter/github.d.ts +242 -0
  41. package/dist/ui/umd/types/exporter/types.d.ts +17 -1
  42. package/dist/ui/umd/types/ui/components/Icon/Icon.d.ts +1 -1
  43. package/dist/ui/umd/types/ui/components/Page/LinkPreviewBlock/LinkPreviewBlock.types.d.ts +2 -2
  44. package/package.json +16 -21
@@ -13,3 +13,7 @@ export interface reqAPIWithBackoffAndCacheArgs {
13
13
  count: number;
14
14
  }
15
15
  export declare function reqAPIWithBackoffAndCache<T>({ name, func, args, count }: reqAPIWithBackoffAndCacheArgs): Promise<T>;
16
+ export interface FetchOptions extends RequestInit {
17
+ timeout?: number;
18
+ }
19
+ export declare function fetchWithTimeout(url: string | URL | Request, options?: FetchOptions): Promise<Response>;
@@ -6,7 +6,8 @@ export declare const atoh: (a: string) => string;
6
6
  export declare const createDirWhenNotfound: (dir: string) => Promise<void>;
7
7
  export declare function readCache<T>(f: string): Promise<T>;
8
8
  export declare function writeCache(f: string, data: unknown): Promise<void>;
9
- export declare function isAvailableCache(f: string): Promise<boolean>;
9
+ export declare function isAvailableCache(f: string, d?: number): Promise<boolean>;
10
+ export declare const sleep: (m: number) => Promise<unknown>;
10
11
  export declare function saveFile(fileUrl: string, prefix: string): Promise<{
11
12
  src: string;
12
13
  size: number;
@@ -0,0 +1,242 @@
1
+ interface FetchFunc<T> {
2
+ (input: RequestInfo, init?: RequestInit): Promise<T>;
3
+ }
4
+ export interface GithubRepoArgs {
5
+ owner: string;
6
+ repo: string;
7
+ }
8
+ export interface GithubRepoResponse {
9
+ id: number;
10
+ node_id: string;
11
+ name: string;
12
+ full_name: string;
13
+ private: boolean;
14
+ owner: {
15
+ login: string;
16
+ id: number;
17
+ node_id: string;
18
+ avatar_url: string;
19
+ gravatar_id: string;
20
+ url: string;
21
+ html_url: string;
22
+ followers_url: string;
23
+ following_url: string;
24
+ gists_url: string;
25
+ starred_url: string;
26
+ subscriptions_url: string;
27
+ organizations_url: string;
28
+ repos_url: string;
29
+ events_url: string;
30
+ received_events_url: string;
31
+ type: string;
32
+ site_admin: boolean;
33
+ };
34
+ html_url: string;
35
+ description: string;
36
+ fork: boolean;
37
+ url: string;
38
+ forks_url: string;
39
+ keys_url: string;
40
+ collaborators_url: string;
41
+ teams_url: string;
42
+ hooks_url: string;
43
+ issue_events_url: string;
44
+ events_url: string;
45
+ assignees_url: string;
46
+ branches_url: string;
47
+ tags_url: string;
48
+ blobs_url: string;
49
+ git_tags_url: string;
50
+ git_refs_url: string;
51
+ trees_url: string;
52
+ statuses_url: string;
53
+ languages_url: string;
54
+ stargazers_url: string;
55
+ contributors_url: string;
56
+ subscribers_url: string;
57
+ subscription_url: string;
58
+ commits_url: string;
59
+ git_commits_url: string;
60
+ comments_url: string;
61
+ issue_comment_url: string;
62
+ contents_url: string;
63
+ compare_url: string;
64
+ merges_url: string;
65
+ archive_url: string;
66
+ downloads_url: string;
67
+ issues_url: string;
68
+ pulls_url: string;
69
+ milestones_url: string;
70
+ notifications_url: string;
71
+ labels_url: string;
72
+ releases_url: string;
73
+ deployments_url: string;
74
+ created_at: string;
75
+ updated_at: string;
76
+ pushed_at: string;
77
+ git_url: string;
78
+ ssh_url: string;
79
+ clone_url: string;
80
+ svn_url: string;
81
+ homepage: string;
82
+ size: number;
83
+ stargazers_count: number;
84
+ watchers_count: number;
85
+ language: string;
86
+ has_issues: boolean;
87
+ has_projects: boolean;
88
+ has_downloads: boolean;
89
+ has_wiki: boolean;
90
+ has_pages: boolean;
91
+ has_discussions: boolean;
92
+ forks_count: number;
93
+ mirror_url: string;
94
+ archived: boolean;
95
+ disabled: boolean;
96
+ open_issues_count: number;
97
+ license: {
98
+ key: string;
99
+ name: string;
100
+ spdx_id: string;
101
+ url: string;
102
+ node_id: string;
103
+ };
104
+ allow_forking: boolean;
105
+ is_template: boolean;
106
+ web_commits_signoff_required: boolean;
107
+ topics: string[];
108
+ visibility: string;
109
+ forks: number;
110
+ open_issues: number;
111
+ watchers: number;
112
+ default_branch: string;
113
+ temp_clone_token: string;
114
+ network_count: number;
115
+ subscribers_count: number;
116
+ }
117
+ export declare function getRepo({ owner, repo }: GithubRepoArgs, func?: FetchFunc<GithubRepoResponse>): Promise<GithubRepoResponse>;
118
+ export interface LinkPreviewGithubRepo {
119
+ name: string;
120
+ login: string;
121
+ avatar_url: string;
122
+ avatar_src: string;
123
+ updated_at: string;
124
+ }
125
+ export declare function getRepoForLinkPreview({ owner, repo }: GithubRepoArgs, func?: FetchFunc<GithubRepoResponse>): Promise<LinkPreviewGithubRepo>;
126
+ export interface GithubIssueArgs {
127
+ owner: string;
128
+ repo: string;
129
+ number: string;
130
+ }
131
+ export interface GithubIssueResponse {
132
+ url: string;
133
+ repository_url: string;
134
+ labels_url: string;
135
+ comments_url: string;
136
+ events_url: string;
137
+ html_url: string;
138
+ id: number;
139
+ node_id: string;
140
+ number: number;
141
+ title: string;
142
+ user: {
143
+ login: string;
144
+ id: number;
145
+ node_id: string;
146
+ avatar_url: string;
147
+ glavatar_id: string;
148
+ url: string;
149
+ html_url: string;
150
+ followers_url: string;
151
+ following_url: string;
152
+ gist_url: string;
153
+ starred_url: string;
154
+ subscriptions_url: string;
155
+ organizations_url: string;
156
+ repos_url: string;
157
+ events_url: string;
158
+ received_events_url: string;
159
+ type: string;
160
+ site_admin: boolean;
161
+ };
162
+ labels: [
163
+ {
164
+ id: number;
165
+ node_id: string;
166
+ url: string;
167
+ name: string;
168
+ color: string;
169
+ default: boolean;
170
+ description: string;
171
+ }
172
+ ];
173
+ state: 'open' | 'closed';
174
+ locked: boolean;
175
+ assignee: string;
176
+ assignees: string[];
177
+ milestone: string;
178
+ comments: number;
179
+ created_at: string;
180
+ updated_at: string;
181
+ closed_at: string | null;
182
+ author_association: string;
183
+ active_lock_reason: string;
184
+ draft: boolean;
185
+ pull_request?: {
186
+ url: string;
187
+ html_url: string;
188
+ diff_url: string;
189
+ patch_url: string;
190
+ merged_at: string;
191
+ };
192
+ body: string;
193
+ closed_by: {
194
+ login: string;
195
+ id: number;
196
+ node_id: string;
197
+ avatar_url: string;
198
+ glavatar_id: string;
199
+ url: string;
200
+ html_url: string;
201
+ followers_url: string;
202
+ following_url: string;
203
+ gist_url: string;
204
+ starred_url: string;
205
+ subscriptions_url: string;
206
+ organizations_url: string;
207
+ repos_url: string;
208
+ events_url: string;
209
+ received_events_url: string;
210
+ type: string;
211
+ site_admin: boolean;
212
+ };
213
+ reactions: {
214
+ url: string;
215
+ total_count: number;
216
+ '+1': number;
217
+ '-1': number;
218
+ laugh: number;
219
+ hooray: number;
220
+ confused: number;
221
+ heart: number;
222
+ rocket: number;
223
+ eyes: number;
224
+ };
225
+ timeline_url: string;
226
+ performed_via_github_app: string;
227
+ state_reason: string;
228
+ }
229
+ export declare function getIssue({ owner, repo, number }: GithubIssueArgs, func?: FetchFunc<GithubIssueResponse>): Promise<GithubIssueResponse>;
230
+ export interface LinkPreviewGithubIssue {
231
+ title: string;
232
+ login: string;
233
+ avatar_url: string;
234
+ avatar_src: string;
235
+ created_at: string;
236
+ closed_at: string | null;
237
+ merged_at: string | null;
238
+ state: 'open' | 'closed' | 'merged';
239
+ number: number;
240
+ }
241
+ export declare function getIssueForLinkPreview({ owner, repo, number }: GithubIssueArgs, func?: FetchFunc<GithubIssueResponse>): Promise<LinkPreviewGithubIssue>;
242
+ export {};
@@ -1,4 +1,5 @@
1
1
  import type { QueryDatabaseResponse, ListBlockChildrenResponse, GetSelfResponse, ParagraphBlockObjectResponse, Heading1BlockObjectResponse, Heading2BlockObjectResponse, Heading3BlockObjectResponse, BulletedListItemBlockObjectResponse, NumberedListItemBlockObjectResponse, QuoteBlockObjectResponse, ToDoBlockObjectResponse, ToggleBlockObjectResponse, TemplateBlockObjectResponse, SyncedBlockBlockObjectResponse, ChildPageBlockObjectResponse, ChildDatabaseBlockObjectResponse, EquationBlockObjectResponse, CodeBlockObjectResponse, CalloutBlockObjectResponse, DividerBlockObjectResponse, BreadcrumbBlockObjectResponse, TableOfContentsBlockObjectResponse, ColumnListBlockObjectResponse, ColumnBlockObjectResponse, LinkToPageBlockObjectResponse, TableBlockObjectResponse, TableRowBlockObjectResponse, EmbedBlockObjectResponse, BookmarkBlockObjectResponse, ImageBlockObjectResponse, VideoBlockObjectResponse, PdfBlockObjectResponse, FileBlockObjectResponse, AudioBlockObjectResponse, LinkPreviewBlockObjectResponse, UnsupportedBlockObjectResponse, RichTextItemResponse, GetPagePropertyResponse, PageObjectResponse, PersonUserObjectResponse, DatabaseObjectResponse, MentionRichTextItemResponse, TextRichTextItemResponse, EquationRichTextItemResponse } from '@notionhq/client/build/src/api-endpoints.js';
2
+ import { LinkPreviewGithubRepo, LinkPreviewGithubIssue } from './github.js';
2
3
  export * from '@notionhq/client/build/src/api-endpoints.js';
3
4
  export type IdRequest = string | string;
4
5
  export type EmptyObject = Record<string, never>;
@@ -259,12 +260,27 @@ export type PdfBlockObjectResponseEx = PdfBlockObjectResponse & {
259
260
  export type SyncedBlockBlockObjectResponseEx = SyncedBlockBlockObjectResponse & {
260
261
  children?: ListBlockChildrenResponseEx;
261
262
  };
262
- export type BlockObjectResponse = ParagraphBlockObjectResponseEx | Heading1BlockObjectResponse | Heading2BlockObjectResponse | Heading3BlockObjectResponse | BulletedListItemBlockObjectResponseEx | NumberedListItemBlockObjectResponseEx | QuoteBlockObjectResponse | ToDoBlockObjectResponse | ToggleBlockObjectResponseEx | TemplateBlockObjectResponse | SyncedBlockBlockObjectResponseEx | ChildPageBlockObjectResponseEx | ChildDatabaseBlockObjectResponseEx | EquationBlockObjectResponse | CodeBlockObjectResponse | CalloutBlockObjectResponseEx | DividerBlockObjectResponse | BreadcrumbBlockObjectResponseEx | TableOfContentsBlockObjectResponse | ColumnListBlockObjectResponseEx | ColumnBlockObjectResponse | LinkToPageBlockObjectResponse | TableBlockObjectResponseEx | TableRowBlockObjectResponse | EmbedBlockObjectResponseEx | BookmarkBlockObjectResponseEx | ImageBlockObjectResponseEx | VideoBlockObjectResponseEx | PdfBlockObjectResponseEx | FileBlockObjectResponseEx | AudioBlockObjectResponse | LinkPreviewBlockObjectResponse | UnsupportedBlockObjectResponse;
263
+ export type BlockObjectResponse = ParagraphBlockObjectResponseEx | Heading1BlockObjectResponse | Heading2BlockObjectResponse | Heading3BlockObjectResponse | BulletedListItemBlockObjectResponseEx | NumberedListItemBlockObjectResponseEx | QuoteBlockObjectResponse | ToDoBlockObjectResponse | ToggleBlockObjectResponseEx | TemplateBlockObjectResponse | SyncedBlockBlockObjectResponseEx | ChildPageBlockObjectResponseEx | ChildDatabaseBlockObjectResponseEx | EquationBlockObjectResponse | CodeBlockObjectResponse | CalloutBlockObjectResponseEx | DividerBlockObjectResponse | BreadcrumbBlockObjectResponseEx | TableOfContentsBlockObjectResponse | ColumnListBlockObjectResponseEx | ColumnBlockObjectResponse | LinkToPageBlockObjectResponse | TableBlockObjectResponseEx | TableRowBlockObjectResponse | EmbedBlockObjectResponseEx | BookmarkBlockObjectResponseEx | ImageBlockObjectResponseEx | VideoBlockObjectResponseEx | PdfBlockObjectResponseEx | FileBlockObjectResponseEx | AudioBlockObjectResponse | LinkPreviewBlockObjectResponseEx | UnsupportedBlockObjectResponse;
263
264
  export type ListBlockChildrenResponseEx = ListBlockChildrenResponse & {
264
265
  results: Array<BlockObjectResponse>;
265
266
  children?: ListBlockChildrenResponse;
266
267
  last_edited_time?: string;
267
268
  };
269
+ export type LinkPreviewBlockObjectResponseEx = LinkPreviewBlockObjectResponse & {
270
+ link_preview: {
271
+ url: string;
272
+ github?: {
273
+ type: 'issue';
274
+ issue: LinkPreviewGithubIssue;
275
+ } | {
276
+ type: 'repo';
277
+ repo: LinkPreviewGithubRepo;
278
+ };
279
+ figma?: {
280
+ html: string;
281
+ };
282
+ };
283
+ };
268
284
  export type GetPageResponseEx = PageObjectResponse & {
269
285
  cover: {
270
286
  src: string;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import './Icon.css';
3
3
  export interface IconProps {
4
- name: 'figma' | 'slack' | 'github' | 'file' | 'link';
4
+ name: 'figma' | 'slack' | 'github' | 'file' | 'link' | 'codemerge' | 'circlecheck' | 'circledot';
5
5
  width?: string;
6
6
  height?: string;
7
7
  className?: string;
@@ -1,4 +1,4 @@
1
- import type { LinkPreviewBlockObjectResponse } from '../../../../exporter';
1
+ import type { LinkPreviewBlockObjectResponseEx } from '../../../../exporter';
2
2
  export type LinkPreviewBlockProps = {
3
- block: LinkPreviewBlockObjectResponse;
3
+ block: LinkPreviewBlockObjectResponseEx;
4
4
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rotion",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "license": "MIT",
5
5
  "repository": "linyows/rotion",
6
6
  "description": "This is react components that uses the notion API to display the notion's database and page.",
@@ -44,12 +44,11 @@
44
44
  "test": "npm run exporter:test",
45
45
  "exporter:build": "npm run exporter:clean && tsc -p tsconfig.exporter.json",
46
46
  "exporter:clean": "rm -rf dist/exporter/*",
47
- "exporter:test": "tsm node_modules/uvu/bin.js ./src/exporter",
47
+ "exporter:test": "tsx node_modules/uvu/bin.js ./src/exporter",
48
48
  "ui:build": "npm run ui:lint && npm run ui:typecheck && npm run ui:rollup",
49
49
  "ui:rollup": "rollup --config rollup.config.ts --configPlugin typescript",
50
50
  "ui:typecheck": "tsc -p src/ui/tsconfig.typecheck.json",
51
51
  "ui:lint": "eslint ./src/ui/components --ext .js,.jsx,.ts,.tsx -c ./src/ui/.eslintrc.json",
52
- "ui:test": "uvu -r tsm ./src/ui/components",
53
52
  "ui:fixtures": "jq '.' website/.cache/notion.databases.query-* | sed 's/?.*\",/\",/g' > src/ui/fixtures/fetch_database_response.json",
54
53
  "story": "storybook dev -p 6006 --ci",
55
54
  "build-story": "storybook build",
@@ -71,22 +70,22 @@
71
70
  "sharp": "^0.33.3"
72
71
  },
73
72
  "devDependencies": {
74
- "@chromatic-com/storybook": "^1.3.1",
73
+ "@chromatic-com/storybook": "^1.5.0",
75
74
  "@rollup/plugin-commonjs": "^25.0.7",
76
75
  "@rollup/plugin-json": "^6.1.0",
77
76
  "@rollup/plugin-node-resolve": "^15.2.3",
78
77
  "@rollup/plugin-terser": "^0.4.4",
79
78
  "@rollup/plugin-typescript": "^11.1.5",
80
- "@storybook/addon-essentials": "^8.0.6",
81
- "@storybook/addon-interactions": "^8.0.6",
82
- "@storybook/addon-links": "^8.0.6",
83
- "@storybook/addon-mdx-gfm": "^8.0.6",
84
- "@storybook/addon-onboarding": "^8.0.6",
85
- "@storybook/blocks": "^8.0.6",
86
- "@storybook/react": "^8.0.6",
87
- "@storybook/react-vite": "^8.0.6",
88
- "@storybook/test": "^8.0.6",
89
- "@storybook/theming": "^8.0.6",
79
+ "@storybook/addon-essentials": "^8.1.6",
80
+ "@storybook/addon-interactions": "^8.1.6",
81
+ "@storybook/addon-links": "^8.1.6",
82
+ "@storybook/addon-mdx-gfm": "^8.1.6",
83
+ "@storybook/addon-onboarding": "^8.1.6",
84
+ "@storybook/blocks": "^8.1.6",
85
+ "@storybook/react": "^8.1.6",
86
+ "@storybook/react-vite": "^8.1.6",
87
+ "@storybook/test": "^8.1.6",
88
+ "@storybook/theming": "^8.1.6",
90
89
  "@tsconfig/node-lts-strictest-esm": "^18.12.1",
91
90
  "@types/imagemin": "^8.0.5",
92
91
  "@types/imagemin-webp": "^7.0.3",
@@ -113,12 +112,11 @@
113
112
  "rollup-plugin-dts": "^6.1.0",
114
113
  "rollup-plugin-peer-deps-external": "^2.2.4",
115
114
  "rollup-plugin-postcss": "^4.0.2",
116
- "storybook": "^8.0.6",
115
+ "storybook": "^8.1.6",
117
116
  "storybook-dark-mode": "^4.0.1",
118
117
  "testdouble": "^3.20.1",
119
- "ts-node": "^10.9.2",
120
118
  "tslib": "^2.6.2",
121
- "tsm": "^2.3.0",
119
+ "tsx": "^4.13.2",
122
120
  "typescript": "^5.3.3",
123
121
  "uvu": "^0.5.6"
124
122
  },
@@ -127,8 +125,5 @@
127
125
  "http-cache-semantics": "4.1.1",
128
126
  "semver-regex": "3.1.4"
129
127
  },
130
- "extends": "@tsconfig/node-lts-strictest-esm",
131
- "ts-node": {
132
- "esm": true
133
- }
128
+ "extends": "@tsconfig/node-lts-strictest-esm"
134
129
  }