Skip to content

Integrate Notion API syncing with analyze workflow#26

Open
stevenschling13 wants to merge 1 commit intomainfrom
codex/audit-codebase-and-fix-issues
Open

Integrate Notion API syncing with analyze workflow#26
stevenschling13 wants to merge 1 commit intomainfrom
codex/audit-codebase-and-fix-issues

Conversation

@stevenschling13
Copy link
Owner

Summary

  • add a Notion integration helper that normalizes property payloads and upserts history records
  • update the analyze route to patch photo pages and history entries using the new Notion service
  • extend tests to mock Notion calls and verify URL id extraction helpers

Testing

  • pnpm test -- --run
  • pnpm lint
  • pnpm typecheck

https://chatgpt.com/codex/tasks/task_e_690692b218ec832cb8b5cead05a642b4

Copilot AI review requested due to automatic review settings November 1, 2025 23:31
Copy link

Copilot AI left a 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 implements the Notion API integration for the grow operations photo analysis system. The changes activate previously placeholder functionality to write photo analysis results to Notion databases.

  • Adds complete Notion API client with proper property mapping and HMAC-verified requests
  • Implements upsert logic for history tracking with idempotency keys
  • Adds comprehensive test coverage for the new integration

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/integrations/notion.ts Adds NotionService class with updatePhoto and upsertHistory methods, including property mapping functions and URL ID extraction
src/routes/analyze.ts Activates Notion API calls by replacing placeholder code with actual updatePhoto and upsertHistory invocations
src/domain/mapping.ts Adds missing "Sev" (severity) property mapping to photo writebacks
test/notion.test.ts Adds unit tests for Notion URL ID extraction helper
test/mapping.test.ts Adds unit tests for writeback-to-photo and history property mapping functions
test/hmac.test.ts Extends HMAC test to mock Notion API calls and verify end-to-end integration

expect(body).toHaveProperty("results");
expect(body.results).toHaveLength(1);

fetchMock.mockRestore?.();
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The optional chaining on mockRestore will silently fail since vi.fn() doesn't provide a mockRestore method. Use fetchMock.mockClear() or wrap the mock/restore logic in afterEach/beforeEach hooks to properly clean up the test state.

Suggested change
fetchMock.mockRestore?.();

Copilot uses AI. Check for mistakes.
}
}

async function notionFetch(path: string, init: RequestInit & { token: string }): Promise<any> {
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The return type is Promise<any> which bypasses TypeScript's type safety. Consider defining specific return types for each Notion API response or use a generic NotionApiResponse type instead of any.

Suggested change
async function notionFetch(path: string, init: RequestInit & { token: string }): Promise<any> {
async function notionFetch<T = unknown>(path: string, init: RequestInit & { token: string }): Promise<T | null> {

Copilot uses AI. Check for mistakes.
text: async () => JSON.stringify(data),
});

const fetchMock = vi.fn(async (url: string, init: RequestInit) => {
Copy link

Copilot AI Nov 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fetch mock setup (lines 63-75) duplicates test infrastructure. Consider extracting this into a shared test helper function to improve maintainability and reusability across test files.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant