gatsby-source-notion-churnotion 1.1.27 → 1.1.28
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/dist/util/fetchData.js +0 -6
- package/package.json +1 -1
package/dist/util/fetchData.js
CHANGED
@@ -16,13 +16,10 @@ const fetchAllBlocks = async (pageId, startCursor = null) => {
|
|
16
16
|
let allResults = [];
|
17
17
|
while (hasMore) {
|
18
18
|
const pageUrl = `blocks/${pageId}/children?page_size=100${nextCursor ? `&start_cursor=${nextCursor}` : ""}`;
|
19
|
-
console.log(`[INFO] Fetching blocks from: ${pageUrl}`); // 디버깅용 로그
|
20
19
|
const result = await (0, exports.fetchGetWithRetry)(pageUrl);
|
21
20
|
if (result?.results?.length) {
|
22
21
|
allResults = [...allResults, ...result.results]; // 기존 데이터와 병합
|
23
22
|
}
|
24
|
-
console.log(`[INFO] Retrieved ${result.results.length} blocks`);
|
25
|
-
console.log(`[INFO] has_more: ${result.has_more}, next_cursor: ${result.next_cursor}`);
|
26
23
|
hasMore = result.has_more || false; // 다음 데이터가 있는지 확인
|
27
24
|
nextCursor = result.next_cursor || null; // 다음 페이지 커서 업데이트
|
28
25
|
// 만약 nextCursor가 계속 null이라면 루프 탈출
|
@@ -37,16 +34,13 @@ exports.fetchAllBlocks = fetchAllBlocks;
|
|
37
34
|
* Notion API에서 GET 요청을 수행하는 함수 (재시도 로직 포함)
|
38
35
|
*/
|
39
36
|
const fetchGetWithRetry = async (url, options = {}, tryCount = 0, maxRetries = 5) => {
|
40
|
-
console.log(`[GET] Request URL: ${url}`); // 디버깅용 로그
|
41
37
|
try {
|
42
38
|
const response = await connector_1.instance.get(url);
|
43
39
|
let results = response.data.results;
|
44
|
-
console.log(`[INFO] Initial results count: ${results.length}`);
|
45
40
|
// Notion API 응답에 has_more가 있으면 추가 블록을 가져와 병합
|
46
41
|
if (response.data.has_more) {
|
47
42
|
const pageId = url.match(/blocks\/([^\/]*)\/children/)?.[1]; // 정확한 pageId 추출
|
48
43
|
if (pageId) {
|
49
|
-
console.log(`[INFO] Fetching additional blocks for pageId: ${pageId} with next_cursor: ${response.data.next_cursor}`);
|
50
44
|
const additionalResults = await (0, exports.fetchAllBlocks)(pageId, response.data.next_cursor); // next_cursor도 함께 전달
|
51
45
|
results = [...results, ...additionalResults]; // 기존 results에 추가 데이터 병합
|
52
46
|
}
|
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.28",
|
5
5
|
"skipLibCheck": true,
|
6
6
|
"license": "0BSD",
|
7
7
|
"main": "./dist/gatsby-node.js",
|