-
Notifications
You must be signed in to change notification settings - Fork 0
Integrate external services for data management #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Integrate external services for data management #4
Conversation
Co-authored-by: info <info@reeseastor.com>
|
Cursor Agent can help with this pull request. Just |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces comprehensive cloud integrations for the workspace application, adding real-time database sync with Supabase, collaborative documentation with Notion, and cloud file storage with Google Drive.
Key changes include:
- Cloud Service Integration: Added Supabase, Notion, and Google Drive services with full authentication and data sync capabilities
- Frontend Integration UI: New "Integrations" tab with status indicators, sync controls, and configuration options
- Backend API Extensions: New endpoints for authentication, data syncing, and file management across all integrated services
Reviewed Changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| setup.js | Interactive setup wizard for configuring cloud integrations |
| services/supabase.js | Supabase service with database operations and real-time sync |
| services/notion.js | Notion service for creating pages and syncing content |
| services/googleDrive.js | Google Drive service for document and spreadsheet management |
| server.js | Extended server with integration endpoints and middleware |
| public/styles.css | Added CSS styling for integration status indicators and controls |
| public/script.js | Extended frontend with integration functions and UI handling |
| public/index.html | Added Integrations tab with status displays and sync controls |
| package.json | Updated dependencies and added setup script |
| README.md | Comprehensive rewrite with integration setup and usage instructions |
| .env.example | Environment variable template for all integrations |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| { responseType: 'stream' } | ||
| ); | ||
|
|
||
| const dest = fs.createWriteStream(destPath); |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The fs import at the top of the file imports the promises version (require('fs').promises), but this line uses the synchronous fs module. This will cause a runtime error since createWriteStream doesn't exist on the promises object. Import the regular fs module separately or use require('fs').createWriteStream(destPath).
| // Check Notion status (simplified check) | ||
| updateIntegrationStatus('notion', process.env.NOTION_API_KEY ? 'connected' : 'disconnected'); | ||
|
|
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Environment variables are not available in client-side JavaScript. process.env.NOTION_API_KEY will always be undefined in the browser, causing the Notion status to always show as disconnected. This check should be moved to the server-side or replaced with an API call to check the actual connection status.
| // Check Notion status (simplified check) | |
| updateIntegrationStatus('notion', process.env.NOTION_API_KEY ? 'connected' : 'disconnected'); | |
| // Check Notion status via API | |
| updateIntegrationStatus('notion', 'checking'); | |
| try { | |
| const response = await fetch('/api/sync/notion/status'); | |
| if (response.ok) { | |
| const data = await response.json(); | |
| updateIntegrationStatus('notion', data.connected ? 'connected' : 'disconnected'); | |
| } else { | |
| updateIntegrationStatus('notion', 'disconnected'); | |
| } | |
| } catch { | |
| updateIntegrationStatus('notion', 'disconnected'); | |
| } |
| } | ||
|
|
||
| // Create documents for novel chapters | ||
| const chaptersResponse = await fetch(`/api/novels/${currentNovelId}/chapters`); |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable currentNovelId is referenced but not defined in the visible scope. This will cause a ReferenceError when the syncToGoogleDrive function is called. The variable should be defined or retrieved from the current application state.
| async createTables() { | ||
| if (!this.supabase) return; | ||
|
|
||
| // Note: These tables should ideally be created through Supabase dashboard | ||
| // This is just for reference of the schema | ||
| const tables = { |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The createTables method defines table schemas but doesn't actually create them, making the method name misleading. Consider renaming to getTableSchemas or getSchemaReference to better reflect its purpose as a schema reference.
|
|
||
| // Initialize Google Drive tokens on startup | ||
| (async () => { | ||
| await googleDriveService.loadTokens(); |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The immediately invoked async function expression (IIFE) for loading Google Drive tokens lacks error handling. If loadTokens() throws an error, it will be an unhandled promise rejection. Wrap the call in a try-catch block to handle potential errors gracefully.
| await googleDriveService.loadTokens(); | |
| try { | |
| await googleDriveService.loadTokens(); | |
| } catch (error) { | |
| console.error('Failed to load Google Drive tokens:', error); | |
| } |
| showSuccess('Sync settings saved!'); | ||
| } | ||
|
|
||
| function showMessage(message, type) { |
Copilot
AI
Sep 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The showMessage function is duplicated - there's already an existing showMessage function in the codebase with different behavior. This creates a naming conflict and inconsistent behavior. Consider using the existing function or renaming this one to avoid confusion.
| function showMessage(message, type) { | |
| function displayMessage(message, type) { |
| if (settings.autoSyncNotion) syncToNotion(); | ||
| if (settings.autoSyncDrive) syncToGoogleDrive(); | ||
| }, intervalMinutes * 60 * 1000); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| data: company | ||
| }) | ||
| }); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
| // Check Notion status (simplified check) | ||
| updateIntegrationStatus('notion', process.env.NOTION_API_KEY ? 'connected' : 'disconnected'); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Don’t reference Node env vars in browser status check
checkIntegrationStatus reads process.env.NOTION_API_KEY to decide the Notion status. In the browser there is no process object, so this line throws a ReferenceError as soon as the integrations tab initializes and the rest of the status checks never run. The UI will always break unless this is replaced with a server-side check or some other client-safe flag.
Useful? React with 👍 / 👎.
| async function syncToNotion() { | ||
| showMessage('Syncing to Notion...', 'info'); | ||
|
|
||
| try { | ||
| // Get all credit memos | ||
| const memoResponse = await fetch('/api/credit-memos'); | ||
| const memos = await memoResponse.json(); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P1] Notion sync always fails because credit memo endpoint is missing
syncToNotion fetches /api/credit-memos to read existing memos before pushing to Notion, but the server defines only a POST handler for that path. The GET returns a 404 HTML page, memoResponse.json() throws, and no data is synced. Add a GET route (or use the existing POST results) so the Notion sync has data to work with.
Useful? React with 👍 / 👎.
Integrate Supabase, Notion, and Google Drive to add real-time database sync, collaborative documentation, and cloud file storage capabilities.
This PR introduces:
npm run setupfor easy configuration.Note
Adds Supabase, Notion, and Google Drive integrations with new UI tab, backend services/endpoints, env/setup, and dependency updates.
public/index.htmlsection with status indicators and sync controls; corresponding logic inpublic/script.jsto auth/sync with services and manage auto-sync; styles added inpublic/styles.css.services/supabase.js,services/notion.js,services/googleDrive.jsclients and helpers (OAuth for Google, Notion page creation, Supabase CRUD/realtime helpers).server.jsfor Supabase sync (/api/sync/supabase/*), Notion sync (/api/sync/notion/*), Google auth/callback and Drive ops (/api/drive/*), and a combined sync endpoint (/api/sync/all); enabled CORS and dotenv.setup.jsandnpm run setupto generate.env..env.example; expanded.gitignore.package.json/lock.Written by Cursor Bugbot for commit 2ebf3c7. This will update automatically on new commits. Configure here.