gatsby-source-notion-churnotion 1.1.29 → 1.1.31

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.
package/README.md CHANGED
@@ -6,6 +6,28 @@ This plugin recursively collects categories from a single Notion database, which
6
6
 
7
7
  If you're considering Notion as your CMS for Gatsby, this plugin could be a great choice as it supports recursive category collection.
8
8
 
9
+ ## What's New in v1.1.31
10
+
11
+ - **Fixed ES Module compatibility issues**:
12
+ - Removed dependency on external p-limit library
13
+ - Implemented custom parallel processing queue
14
+ - Fixed Gatsby build errors related to ESM imports
15
+ - Improved CommonJS compatibility
16
+
17
+ ## What's New in v1.1.30
18
+
19
+ - **Added support for more Notion block types**:
20
+ - bookmark, breadcrumb, callout, code, column, column_list, divider, embed, equation, file, link_preview, pdf, table, table_of_contents, toggle, to_do, video, audio
21
+ - **Improved performance**:
22
+ - Added parallel processing for Notion API requests with concurrency limits
23
+ - Implemented caching to reduce duplicate API calls
24
+ - Added batch processing for large datasets
25
+ - Added timeout handling for long-running operations
26
+ - **Code refactoring**:
27
+ - Modular block processor architecture
28
+ - Better error handling
29
+ - Improved type safety
30
+
9
31
  ## Install
10
32
 
11
33
  ```shell
@@ -64,7 +86,7 @@ When the development server is running, `gatsby-source-notion-churnotion` will f
64
86
 
65
87
  ### Explore in GraphQL
66
88
 
67
- Once the data is fetched, go to http://localhost:8000/__graphql, where youll find new nodes such as `Churnotion`, `NBook`, `NCategory`, and `NTag` as shown below:
89
+ Once the data is fetched, go to http://localhost:8000/__graphql, where you'll find new nodes such as `Churnotion`, `NBook`, `NCategory`, and `NTag` as shown below:
68
90
 
69
91
  ![alt text](readme2.png)
70
92
 
@@ -40,15 +40,22 @@ const getPages = async ({ databaseId, reporter, getCache, actions, createNode, c
40
40
  reporter.info(`[SUCCESS] total pages > ${result.results.length}`);
41
41
  // 페이지 ID 목록 수집
42
42
  const pageIds = result.results.map((page) => page.id);
43
- // 페이지 블록들을 병렬로 가져오기
44
- const pagesBlocks = await notionService.getMultiplePagesBlocks(pageIds);
45
- // 페이지 데이터와 블록 결합
46
- for (const page of result.results) {
47
- const pageData = {
48
- page,
49
- blocks: pagesBlocks[page.id] || [],
50
- };
51
- pagesToProcess.push(pageData);
43
+ // 페이지 블록들을 병렬로 가져오기 - 최대 50개씩 배치 처리
44
+ for (let i = 0; i < pageIds.length; i += 50) {
45
+ const batch = pageIds.slice(i, i + 50);
46
+ reporter.info(`[BATCH] Processing pages ${i + 1} to ${i + batch.length} of ${pageIds.length}`);
47
+ const batchBlocks = await notionService.getMultiplePagesBlocks(batch);
48
+ // 페이지 데이터와 블록 결합
49
+ for (const pageId of batch) {
50
+ const page = result.results.find((p) => p.id === pageId);
51
+ if (page) {
52
+ const pageData = {
53
+ page,
54
+ blocks: batchBlocks[pageId] || [],
55
+ };
56
+ pagesToProcess.push(pageData);
57
+ }
58
+ }
52
59
  }
53
60
  }
54
61
  }
@@ -1,11 +1,52 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.NotionService = void 0;
7
4
  const fetchData_1 = require("../../util/fetchData");
8
- const p_limit_1 = __importDefault(require("p-limit"));
5
+ /**
6
+ * 간단한 병렬 제한 큐
7
+ */
8
+ class ParallelLimiter {
9
+ running = 0;
10
+ queue = [];
11
+ limit;
12
+ constructor(limit) {
13
+ this.limit = limit;
14
+ }
15
+ async add(fn) {
16
+ return new Promise((resolve, reject) => {
17
+ const run = () => {
18
+ this.running++;
19
+ fn()
20
+ .then(resolve)
21
+ .catch(reject)
22
+ .finally(() => {
23
+ this.running--;
24
+ this.next();
25
+ });
26
+ };
27
+ if (this.running < this.limit) {
28
+ run();
29
+ }
30
+ else {
31
+ this.queue.push(run);
32
+ }
33
+ });
34
+ }
35
+ next() {
36
+ if (this.queue.length > 0 && this.running < this.limit) {
37
+ const run = this.queue.shift();
38
+ if (run)
39
+ run();
40
+ }
41
+ }
42
+ setLimit(limit) {
43
+ this.limit = limit;
44
+ // 새 제한 설정 후 큐에서 가능한 작업 실행
45
+ while (this.running < this.limit && this.queue.length > 0) {
46
+ this.next();
47
+ }
48
+ }
49
+ }
9
50
  class NotionService {
10
51
  reporter;
11
52
  parallelLimit;
@@ -17,7 +58,7 @@ class NotionService {
17
58
  this.parallelLimit = options.parallelLimit || 5; // 기본 동시 요청 수
18
59
  this.enableCaching = options.enableCaching !== false; // 기본값은 캐싱 활성화
19
60
  this.cache = new Map();
20
- this.limiter = (0, p_limit_1.default)(this.parallelLimit);
61
+ this.limiter = new ParallelLimiter(this.parallelLimit);
21
62
  }
22
63
  /**
23
64
  * 데이터베이스 쿼리
@@ -70,7 +111,7 @@ class NotionService {
70
111
  */
71
112
  async getMultiplePagesBlocks(pageIds) {
72
113
  this.reporter.info(`[NOTION] Fetching blocks for ${pageIds.length} pages in parallel (limit: ${this.parallelLimit})`);
73
- const tasks = pageIds.map((pageId) => this.limiter(async () => {
114
+ const tasks = pageIds.map((pageId) => this.limiter.add(async () => {
74
115
  try {
75
116
  const blocks = await this.getPageBlocks(pageId);
76
117
  return { pageId, blocks };
@@ -97,9 +138,9 @@ class NotionService {
97
138
  * 병렬 처리 제한 설정
98
139
  */
99
140
  setParallelLimit(limit) {
100
- this.parallelLimit = limit;
101
- this.limiter = (0, p_limit_1.default)(limit);
102
141
  this.reporter.info(`[NOTION] Updated parallel request limit to ${limit}`);
142
+ this.parallelLimit = limit;
143
+ this.limiter.setLimit(limit);
103
144
  }
104
145
  }
105
146
  exports.NotionService = NotionService;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "gatsby-source-notion-churnotion",
3
3
  "description": "Gatsby plugin that can connect with One Notion Database RECURSIVELY using official API",
4
- "version": "1.1.29",
4
+ "version": "1.1.31",
5
5
  "skipLibCheck": true,
6
6
  "license": "0BSD",
7
7
  "main": "./dist/gatsby-node.js",
@@ -51,7 +51,6 @@
51
51
  "natural": "^8.0.1",
52
52
  "notion-to-md": "^3.1.1",
53
53
  "notion-types": "^7.1.5",
54
- "p-limit": "^6.2.0",
55
54
  "typescript": "^5.7.2"
56
55
  },
57
56
  "devDependencies": {