gatsby-source-notion-churnotion 1.2.1 → 1.2.2

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
@@ -62,6 +62,15 @@ If you're considering Notion as your CMS for Gatsby, this plugin could be a grea
62
62
  - Better error handling
63
63
  - Improved type safety
64
64
 
65
+ ## Features
66
+
67
+ - **Recursive Database Fetching**: Connect with a Notion database and fetch all entries, including nested entries.
68
+ - **Type Safe**: All data types are converted to TypeScript types.
69
+ - **Powerful TypeScript Implementation**: Uses efficient, battle-tested TypeScript code for processing Notion API requests in parallel.
70
+ - **Customizable**: Allows for custom filtering and properties selection.
71
+
72
+ > **Note**: The plugin currently uses a pure TypeScript implementation for parallel processing of Notion API requests. A Rust-based implementation was initially planned for high-performance use cases but has been put on hold due to cross-platform compilation issues.
73
+
65
74
  ## Install
66
75
 
67
76
  ```shell
@@ -1,6 +1,6 @@
1
1
  /**
2
- * This file provides TypeScript bindings to the Rust implementation
3
- * of parallel Notion API processing.
2
+ * This file provides TypeScript bindings to the Notion API processing.
3
+ * Currently using the TypeScript implementation as the default.
4
4
  */
5
5
  import { Reporter } from "gatsby";
6
6
  /**
@@ -17,9 +17,8 @@ export interface RustNotionServiceOptions {
17
17
  enableCaching?: boolean;
18
18
  }
19
19
  /**
20
- * A wrapper class that provides access to the Rust implementation
21
- * of parallel processing for Notion API, with a fallback to the
22
- * TypeScript implementation if the Rust module is not available.
20
+ * A wrapper class that provides access to the TypeScript implementation
21
+ * for parallel processing of Notion API requests.
23
22
  */
24
23
  export declare class RustNotionService {
25
24
  private reporter;
@@ -27,14 +26,13 @@ export declare class RustNotionService {
27
26
  private parallelLimit;
28
27
  private enableCaching;
29
28
  private cache;
30
- private rustInstance;
31
29
  constructor(options: RustNotionServiceOptions);
32
30
  /**
33
31
  * Get blocks for a single page, with recursive fetching of child blocks
34
32
  */
35
33
  getPageBlocks(pageId: string): Promise<NotionBlock[]>;
36
34
  /**
37
- * Get blocks for multiple pages in parallel, using Rust implementation if available
35
+ * Get blocks for multiple pages in parallel
38
36
  */
39
37
  getMultiplePagesBlocks(pageIds: string[]): Promise<{
40
38
  [id: string]: NotionBlock[];
@@ -34,19 +34,9 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.RustNotionService = void 0;
37
- // Use dynamic import with try-catch to handle module loading
38
- let notionParallel = null;
39
- try {
40
- // When the compiled Rust library exists, load it
41
- notionParallel = require("../rust/notion-parallel/index.node");
42
- }
43
- catch (error) {
44
- console.warn("Rust bindings for notion-parallel not found. Using TypeScript fallback implementation.");
45
- }
46
37
  /**
47
- * A wrapper class that provides access to the Rust implementation
48
- * of parallel processing for Notion API, with a fallback to the
49
- * TypeScript implementation if the Rust module is not available.
38
+ * A wrapper class that provides access to the TypeScript implementation
39
+ * for parallel processing of Notion API requests.
50
40
  */
51
41
  class RustNotionService {
52
42
  reporter;
@@ -54,24 +44,13 @@ class RustNotionService {
54
44
  parallelLimit;
55
45
  enableCaching;
56
46
  cache;
57
- rustInstance = null;
58
47
  constructor(options) {
59
48
  this.reporter = options.reporter;
60
49
  this.notionApiKey = options.notionApiKey;
61
50
  this.parallelLimit = options.parallelLimit || 5;
62
51
  this.enableCaching = options.enableCaching !== false;
63
52
  this.cache = new Map();
64
- // Initialize Rust instance if available
65
- if (notionParallel) {
66
- try {
67
- this.rustInstance = new notionParallel.NotionParallel(this.notionApiKey, this.parallelLimit);
68
- this.reporter.info(`[RUST] Initialized Rust-based parallel processing with limit: ${this.parallelLimit}`);
69
- }
70
- catch (error) {
71
- this.reporter.warn(`[RUST] Failed to initialize Rust implementation: ${error}`);
72
- this.rustInstance = null;
73
- }
74
- }
53
+ this.reporter.info(`[NOTION] Initialized TypeScript-based parallel processing with limit: ${this.parallelLimit}`);
75
54
  }
76
55
  /**
77
56
  * Get blocks for a single page, with recursive fetching of child blocks
@@ -82,8 +61,6 @@ class RustNotionService {
82
61
  this.reporter.info(`[CACHE] Using cached page blocks for ${pageId}`);
83
62
  return this.cache.get(cacheKey);
84
63
  }
85
- // Currently we don't have a direct Rust counterpart for a single page
86
- // So we use the multiple pages method with a single ID
87
64
  const results = await this.getMultiplePagesBlocks([pageId]);
88
65
  const blocks = results[pageId] || [];
89
66
  if (this.enableCaching) {
@@ -92,24 +69,11 @@ class RustNotionService {
92
69
  return blocks;
93
70
  }
94
71
  /**
95
- * Get blocks for multiple pages in parallel, using Rust implementation if available
72
+ * Get blocks for multiple pages in parallel
96
73
  */
97
74
  async getMultiplePagesBlocks(pageIds) {
98
75
  this.reporter.info(`[NOTION] Fetching blocks for ${pageIds.length} pages in parallel (limit: ${this.parallelLimit})`);
99
- // If Rust implementation is available and initialized, use it
100
- if (this.rustInstance) {
101
- try {
102
- this.reporter.info(`[RUST] Using Rust implementation for parallel processing`);
103
- const results = await this.rustInstance.getMultiplePagesBlocks(pageIds);
104
- return results;
105
- }
106
- catch (error) {
107
- this.reporter.warn(`[RUST] Error using Rust implementation, falling back to TypeScript: ${error}`);
108
- // Fall back to TypeScript implementation
109
- }
110
- }
111
- // Fallback to TypeScript implementation
112
- // Import the TypeScript implementation dynamically
76
+ // Import the TypeScript implementation
113
77
  const { NotionService } = await Promise.resolve().then(() => __importStar(require("./api/service/notionService")));
114
78
  // Create a NotionService instance with the same configuration
115
79
  const tsService = new NotionService({
@@ -125,10 +89,6 @@ class RustNotionService {
125
89
  setParallelLimit(limit) {
126
90
  this.reporter.info(`[NOTION] Updated parallel request limit to ${limit}`);
127
91
  this.parallelLimit = limit;
128
- // Update the Rust instance if available
129
- if (this.rustInstance) {
130
- this.rustInstance.setParallelLimit(limit);
131
- }
132
92
  }
133
93
  }
134
94
  exports.RustNotionService = RustNotionService;
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.2.1",
4
+ "version": "1.2.2",
5
5
  "skipLibCheck": true,
6
6
  "license": "0BSD",
7
7
  "main": "./dist/gatsby-node.js",
@@ -11,8 +11,7 @@
11
11
  ],
12
12
  "scripts": {
13
13
  "clean": "del-cli dist",
14
- "build": "npm run build:rust && tsc",
15
- "build:rust": "cd rust/notion-parallel && (cargo build --release || cargo build --release --target x86_64-pc-windows-gnu || echo 'Rust build failed, using TypeScript fallback') && cd ../..",
14
+ "build": "tsc",
16
15
  "develop": "tsc --watch",
17
16
  "test": "jest",
18
17
  "prepare": "npm run clean && npm run build"