gatsby-source-notion-churnotion 1.1.29 → 1.1.30
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,21 @@ 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.29
|
10
|
+
|
11
|
+
- **Added support for more Notion block types**:
|
12
|
+
- bookmark, breadcrumb, callout, code, column, column_list, divider, embed, equation, file, link_preview, pdf, table, table_of_contents, toggle, to_do, video, audio
|
13
|
+
- **Improved performance**:
|
14
|
+
- Added parallel processing for Notion API requests with concurrency limits
|
15
|
+
- Implemented caching to reduce duplicate API calls
|
16
|
+
- Added batch processing for large datasets
|
17
|
+
- Added timeout handling for long-running operations
|
18
|
+
- **Code refactoring**:
|
19
|
+
- Modular block processor architecture
|
20
|
+
- Better error handling
|
21
|
+
- Improved type safety
|
22
|
+
- Fixed ES Module import issue with p-limit
|
23
|
+
|
9
24
|
## Install
|
10
25
|
|
11
26
|
```shell
|
@@ -64,7 +79,7 @@ When the development server is running, `gatsby-source-notion-churnotion` will f
|
|
64
79
|
|
65
80
|
### Explore in GraphQL
|
66
81
|
|
67
|
-
Once the data is fetched, go to http://localhost:8000/__graphql, where you
|
82
|
+
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
83
|
|
69
84
|

|
70
85
|
|
package/dist/api/getPages.js
CHANGED
@@ -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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
const
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
}
|
@@ -12,6 +12,8 @@ export declare class NotionService {
|
|
12
12
|
private cache;
|
13
13
|
private limiter;
|
14
14
|
constructor(options: NotionServiceOptions);
|
15
|
+
private initLimiter;
|
16
|
+
private createSimpleLimiter;
|
15
17
|
/**
|
16
18
|
* 데이터베이스 쿼리
|
17
19
|
*/
|
@@ -33,5 +35,5 @@ export declare class NotionService {
|
|
33
35
|
/**
|
34
36
|
* 병렬 처리 제한 설정
|
35
37
|
*/
|
36
|
-
setParallelLimit(limit: number): void
|
38
|
+
setParallelLimit(limit: number): Promise<void>;
|
37
39
|
}
|
@@ -1,11 +1,40 @@
|
|
1
1
|
"use strict";
|
2
|
-
var
|
3
|
-
|
4
|
-
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
5
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6
36
|
exports.NotionService = void 0;
|
7
37
|
const fetchData_1 = require("../../util/fetchData");
|
8
|
-
const p_limit_1 = __importDefault(require("p-limit"));
|
9
38
|
class NotionService {
|
10
39
|
reporter;
|
11
40
|
parallelLimit;
|
@@ -17,7 +46,44 @@ class NotionService {
|
|
17
46
|
this.parallelLimit = options.parallelLimit || 5; // 기본 동시 요청 수
|
18
47
|
this.enableCaching = options.enableCaching !== false; // 기본값은 캐싱 활성화
|
19
48
|
this.cache = new Map();
|
20
|
-
this.
|
49
|
+
this.initLimiter();
|
50
|
+
}
|
51
|
+
async initLimiter() {
|
52
|
+
try {
|
53
|
+
const pLimitModule = await Promise.resolve().then(() => __importStar(require("p-limit")));
|
54
|
+
const pLimit = pLimitModule.default;
|
55
|
+
this.limiter = pLimit(this.parallelLimit);
|
56
|
+
}
|
57
|
+
catch (error) {
|
58
|
+
this.reporter.error(`Failed to initialize p-limit: ${error}`);
|
59
|
+
this.limiter = this.createSimpleLimiter(this.parallelLimit);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
createSimpleLimiter(limit) {
|
63
|
+
let running = 0;
|
64
|
+
const queue = [];
|
65
|
+
const next = () => {
|
66
|
+
running--;
|
67
|
+
if (queue.length > 0) {
|
68
|
+
const run = queue.shift();
|
69
|
+
if (run)
|
70
|
+
run();
|
71
|
+
}
|
72
|
+
};
|
73
|
+
return (fn) => {
|
74
|
+
return new Promise((resolve, reject) => {
|
75
|
+
const run = () => {
|
76
|
+
running++;
|
77
|
+
fn().then(resolve).catch(reject).finally(next);
|
78
|
+
};
|
79
|
+
if (running < limit) {
|
80
|
+
run();
|
81
|
+
}
|
82
|
+
else {
|
83
|
+
queue.push(run);
|
84
|
+
}
|
85
|
+
});
|
86
|
+
};
|
21
87
|
}
|
22
88
|
/**
|
23
89
|
* 데이터베이스 쿼리
|
@@ -69,6 +135,9 @@ class NotionService {
|
|
69
135
|
* 여러 페이지의 블록 병렬 처리
|
70
136
|
*/
|
71
137
|
async getMultiplePagesBlocks(pageIds) {
|
138
|
+
if (!this.limiter) {
|
139
|
+
await this.initLimiter();
|
140
|
+
}
|
72
141
|
this.reporter.info(`[NOTION] Fetching blocks for ${pageIds.length} pages in parallel (limit: ${this.parallelLimit})`);
|
73
142
|
const tasks = pageIds.map((pageId) => this.limiter(async () => {
|
74
143
|
try {
|
@@ -96,9 +165,9 @@ class NotionService {
|
|
96
165
|
/**
|
97
166
|
* 병렬 처리 제한 설정
|
98
167
|
*/
|
99
|
-
setParallelLimit(limit) {
|
168
|
+
async setParallelLimit(limit) {
|
100
169
|
this.parallelLimit = limit;
|
101
|
-
this.
|
170
|
+
await this.initLimiter();
|
102
171
|
this.reporter.info(`[NOTION] Updated parallel request limit to ${limit}`);
|
103
172
|
}
|
104
173
|
}
|
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.
|
4
|
+
"version": "1.1.30",
|
5
5
|
"skipLibCheck": true,
|
6
6
|
"license": "0BSD",
|
7
7
|
"main": "./dist/gatsby-node.js",
|