refactor: add typed helpers for Supabase join queries (#1047)#1051
Merged
sw-factory-automations merged 1 commit intoMay 12, 2026
Conversation
Co-authored-by: Ona <no-reply@ona.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Collaborator
Author
|
✅ Post-merge verification skipped — |
Collaborator
Author
|
✅ UI verification passed — no visual changes detected. This PR modifies Skipping Storybook visual regression, live site screenshots, and design spec compliance checks — not applicable for a pure type-safety refactor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1047
What
Adds
src/lib/supabase/typed-queries.tswith typed query builders and result casters for the 3 recurring Supabase join patterns. Replaces all 11 inlineas unknown ascasts across 10 files with calls to these centralized helpers.How
Each join pattern is defined once with four co-located pieces:
.select()argument as a constant.from().select()and returns the chainable queryas unknown ascast in one placeCall sites import the query builder (chain
.eq(),.limit(), etc.) and the result caster (get typed rows back). The cast is centralized so a schema change only needs updating in one file.Helpers added
membersWithProfilesasMemberProfileRowsmembersWithProfileEmailasMemberProfileEmailRowsmembersWithWorkspaceasMemberWorkspaceFullRowsmembersWithWorkspaceSlugasMemberWorkspaceSlugRowmembersWithWorkspaceSlugPersonalasMemberWorkspaceSlugPersonalRowspageVisitsWithPagesasPageVisitRowsFiles changed (11 cast sites across 10 files)
src/lib/database.ts— 1 castsrc/app/(app)/[workspaceSlug]/[pageId]/page.tsx— 1 castsrc/app/(app)/[workspaceSlug]/page.tsx— 1 castsrc/app/(auth)/sign-in/sign-in-form.tsx— 1 castsrc/app/(auth)/sign-up/sign-up-form.tsx— 1 castsrc/app/auth/callback/route.ts— 1 castsrc/components/delete-workspace-section.tsx— 2 castssrc/components/members/invite-form.tsx— 1 castsrc/components/sidebar/workspace-switcher.tsx— 1 castsrc/components/database/property-types/person.tsx— 1 castKnowledge base updates
.agents/architecture.md— addedtyped-queries.tsto the Component Map.agents/conventions.md— added "Typed join queries" pattern with usage exampleTesting
pnpm lint— 0 errors ✅pnpm typecheck— passes ✅pnpm test— 139 files, 1877 tests pass ✅Notes
Three additional Supabase join casts exist outside the issue's scope (
settings/members/page.tsx× 2,page-backlinks.tsx× 1). These use different join patterns (members with*+ profiles, workspace_invites with profiles, page_links with pages) and could be addressed in a follow-up.