Skip to content

refactor(sets): share SET_TYPES across frontend and edge - #526

Open
chiptus wants to merge 4 commits into
mainfrom
fix/UPL-50/consolidate-set-types
Open

chiptus wants to merge 4 commits into
mainfrom
fix/UPL-50/consolidate-set-types

Conversation

@chiptus

@chiptus chiptus commented Oct 16, 2026

Copy link
Copy Markdown
Owner

UPL-50: collapses the two TS copies of SET_TYPES into supabase/functions/_shared/setTypes.ts (re-exported from src/api/sets/types.ts) and adds a unit test pinning sets_set_type_check to it, so drift fails a test.

Verification

  • Run pnpm exec vitest run src/lib/setTypeConstraint.test.ts; it passes.
  • Add a value to SET_TYPES without a migration; the test fails.
  • Create a set in the admin form with each set type; saves as before.
  • Run a schedule import with a set type column; imports as before.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CMhMAja3g8dwyMnAjVCLN2


Generated by Claude Code

Pin the sets_set_type_check constraint to SET_TYPES with a unit test.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CMhMAja3g8dwyMnAjVCLN2
Copilot AI balanced review requested due to automatic review settings October 16, 2026 05:09
@vercel

vercel Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
upline Ready Ready Preview Oct 23, 2026 5:08am UTC

@github-actions

github-actions Bot commented Oct 16, 2026 •

Copy link
Copy Markdown

Deploy → staging — workflow run
Last updated: 2026-10-23 05:08:56 UTC

  • ⏭️ DB migrations skipped (no changes)
  • ✅ Edge functions succeeded
  • ⏭️ Type generation skipped (no changes)

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused refactor preserves validation behavior, adds drift detection, and has no unresolved findings.

0 open findings

What changed in this PR

Centralizes set-type definitions shared by the frontend and edge functions, with a test to detect database constraint drift.

Changes:

  • Reuses shared constants, types, and validation through frontend exports.
  • Adds a migration-based constraint consistency test.
  • Updates documentation to describe the shared definition.
File Description
supabase/​functions/​_shared/​setTypes.ts Documents the shared definition and drift test.
src/​lib/​setTypeConstraint.test.ts Checks constraint values against SET_TYPES.
src/​api/​sets/​types.ts Replaces duplicate definitions with shared exports.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@chiptus

chiptus commented Oct 16, 2026

Copy link
Copy Markdown
Owner Author

test / run failed before any test ran: supabase start couldn't pull its Docker images (toomanyrequests: Data limit exceeded). That is a registry rate limit, not caused by this PR, which only touches SET_TYPES and a unit test. Unit tests, typecheck/lint and edge function tests are green. I'm re-running the failed job once.


Generated by Claude Code

@github-actions

Copy link
Copy Markdown

Playwright test results

passed  68 passed

Details

stats  68 tests across 22 suites
duration  1 minute, 21 seconds
commit  4dc341c

@@ -0,0 +1,28 @@
import { readFileSync, readdirSync } from "node:fs";

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

do we really need this test?

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Kept for now: UPL-50 explicitly asks to pin the DB constraint with a test so the TS/SQL copies can't drift silently (it's the only remaining sync point). It's ~25 lines and runs in unit tests without Supabase. If you'd rather drop it, say so and I'll remove it and the file.


Generated by Claude Code

Comment thread supabase/functions/_shared/setTypes.ts Outdated
@chiptus

chiptus commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

Run Edge Function Tests failed on de4490a before any test ran: supabase start couldn't pull its Docker images (toomanyrequests: Data limit exceeded / ECR timeouts). Same registry rate limit as the earlier test / run failure, which passed on re-run. It isn't caused by this PR's change, which only touches SET_TYPES and a unit test. I'm re-running the failed job once.


Generated by Claude Code

@chiptus

chiptus commented Oct 23, 2026

Copy link
Copy Markdown
Owner Author

The re-run of Run Edge Function Tests on de4490a hit the same Docker toomanyrequests: Data limit exceeded error while starting local Supabase, again before any test ran. Nothing in this PR can fix that, so I'm not re-running a third time. The test / run jobs got their one re-run and are pending. Once the registry limit clears, re-running the failed jobs should turn this green.


Generated by Claude Code

@chiptus

chiptus commented Oct 25, 2026

Copy link
Copy Markdown
Owner Author

CI is red on test / run, report / report and Run Edge Function Tests, but not because of this PR. The supabase start step failed pulling docker images with toomanyrequests: Data limit exceeded, which is a registry rate limit. Unit tests, typecheck and lint pass. No code fix exists for this, so I re-ran the failed jobs once. The open review thread ("do we really need this test?") is waiting on your call.


Generated by Claude Code

This branch was successfully deployed

2 active deployments
Preview — de4490ae Deployed Oct 23, 2026 by vercel[bot]
staging — de4490ae Deployed Oct 23, 2026 by chiptus via functions / Deploy edge functions (staging) #150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants