Skip to content

Conversation

@softmarshmallow
Copy link
Member

@softmarshmallow softmarshmallow commented Jan 11, 2026

regular, non breaking local type sync (prep PR)

supabase gen types

Summary by CodeRabbit

  • Chores
    • Internal database schema type definitions and structure updated for consistency. Various type references and function signatures optimized for improved developer experience and maintainability.

✏️ Tip: You can customize this high-level summary in your review settings.

@vercel
Copy link

vercel bot commented Jan 11, 2026

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

Project Deployment Review Updated (UTC)
docs Ready Ready Preview, Comment Jan 11, 2026 7:38am
grida Ready Ready Preview, Comment Jan 11, 2026 7:38am
5 Skipped Deployments
Project Deployment Review Updated (UTC)
code Ignored Ignored Jan 11, 2026 7:38am
legacy Ignored Ignored Jan 11, 2026 7:38am
backgrounds Skipped Skipped Jan 11, 2026 7:38am
blog Skipped Skipped Jan 11, 2026 7:38am
viewer Skipped Skipped Jan 11, 2026 7:38am

@softmarshmallow softmarshmallow changed the title supabase gen types chore: supabase gen types Jan 11, 2026
@coderabbitai
Copy link

coderabbitai bot commented Jan 11, 2026

Walkthrough

The generated TypeScript types file was updated to introduce a DatabaseWithoutInternals type (omitting internal Supabase properties), refactored all type utilities to reference this new type instead of the full Database type, reordered function argument fields across multiple schemas, added SetofOptions blocks to various set-returning functions, and adjusted field sets in return type shapes.

Changes

Cohort / File(s) Summary
Type reshaping and schema refactoring
database/database-generated.types.ts
Added DatabaseWithoutInternals type using Omit to exclude __InternalSupabase. Replaced all Database references with DatabaseWithoutInternals in DefaultSchema and generic utilities (Tables, TablesInsert, TablesUpdate, Enums, CompositeTypes). Updated TableName and schema resolution patterns accordingly.
Function signature restructuring
database/database-generated.types.ts
Reordered function argument fields across multiple functions (e.g., generate_combinations, inventory functions) to realign property positions. Consolidated multi-line function signature forms into compact single-line definitions (e.g., rls_form, rpc_check_max_responses).
SetofOptions additions and return shape modifications
database/database-generated.types.ts
Added SetofOptions blocks to numerous functions specifying set-returning relationships and cardinality semantics (targeting invitation, project, organization sets, etc.). Adjusted return object structures with new fields in inventory functions and workspace-related entities. Modified field presence and positioning in Insert/Update schemas and adjusted search_tsv field type consistency across tables.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A hop through types, so cleanly done,
Database reshaped, internals spun,
SetofOptions bloom like garden rows,
And schemas dance where struct flow grows! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'chore: supabase gen types' accurately describes the main change - regenerated Supabase database type definitions from an automated tool.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch canary

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@softmarshmallow softmarshmallow merged commit 984df25 into main Jan 11, 2026
9 of 10 checks passed
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
database/database-generated.types.ts (1)

2047-2126: Fix visitor.ip nullability mismatch: column is nullable but typed as non-null.

The visitor.ip column is nullable in the database ("ip" "inet" without NOT NULL constraint) but currently typed as unknown (non-optional) in the Row type at line 4215. This will cause consumers to miss required null checks when accessing this field.

Note: search_tsv fields are tsvector GENERATED ALWAYS AS (...) STORED with coalesce() fallbacks, so they are never NULL—the Row typing is correct. However, both visitor.ip and search_tsv are typed as unknown when they should have more specific types (e.g., string for ip/search_tsv).

Also applies to: 2214–2229, 2262–2277, 3764–3813, 4215–4232, 4266–4267

🤖 Fix all issues with AI agents
In @database/database-generated.types.ts:
- Around line 504-535: The RPC return types for
get_inventory_items_with_committed and get_inventory_with_committed are
incorrect: update the Returns object for both functions in
database-generated.types.ts so product_id and cost are nullable (product_id:
number | null and cost: number | null) to match the underlying inventory_item
column types; locate the Returns blocks for get_inventory_items_with_committed
and get_inventory_with_committed and change those two field types accordingly.
- Around line 4343-4366: The workspace_documents return type incorrectly marks
LEFT JOINable fields as required; update the Returns object for
workspace_documents so that form_id, organization_id, is_public, and
max_responses are optional (e.g., turn their types into possibly undefined or
add ?), leaving other fields unchanged; keep p_document_id in
workspace_mark_access as optional since it already matches the SQL DEFAULT NULL.
🧹 Nitpick comments (2)
database/database-generated.types.ts (2)

3254-3254: Args: never can be awkward with common rpc(fn, args) wrappers.

If your Supabase client wrapper expects an args object parameter, Args: never often forces casts. Consider generating Args: Record<string, never> (or {}) instead—if compatible with your calling conventions.

Also applies to: 4308-4310


4398-4513: DatabaseWithoutInternals wiring looks good; consider exporting + minor key extraction cleanup.

The shift to DatabaseWithoutInternals in the public generic helpers is a nice way to hide internal Supabase keys. Two small polish items:

  • Consider export type DatabaseWithoutInternals = ... / export type DefaultSchema = ... if you want consumers to reference them explicitly.
  • DefaultSchema can use Extract<keyof DatabaseWithoutInternals, "public"> for consistency.
Proposed diff
-type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase">
+export type DatabaseWithoutInternals = Omit<Database, "__InternalSupabase">

-type DefaultSchema = DatabaseWithoutInternals[Extract<keyof Database, "public">]
+export type DefaultSchema =
+  DatabaseWithoutInternals[Extract<keyof DatabaseWithoutInternals, "public">]
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between cf6711e and 5a9111a.

📒 Files selected for processing (1)
  • database/database-generated.types.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: test
🔇 Additional comments (3)
database/database-generated.types.ts (3)

1562-1566: RPC arg reordering / inline formatting: OK (no semantic change in TS).

Object-property order changes for Args don’t affect assignability; the one-line signature style is fine as long as this file is fully generator-owned.

Also applies to: 1697-1699, 3586-3592


2223-2228: No action required. SetofOptions is structurally safe for all downstream uses. Searches found zero instances of keyof Database[...]["Functions"] or explicit key enumeration patterns that would break from the added field. TypeScript's structural typing and inference patterns already in use (like extends { Args: infer A; Returns: infer R }) handle the new key automatically without issues.


4310-4319: Union-typed RPC generate_combinations confirmed—no wrapper issues found.

The Database["public"]["Functions"]["generate_combinations"] is correctly typed as a union of two { Args; Returns } shapes. The codebase uses the standard Supabase client (@supabase/ssr), which handles union-typed RPCs natively via RPC name discrimination rather than type inference, so no inference degradation occurs with the current implementation.

Comment on lines 504 to 535
generate_combinations: {
Args: { options: Json; index: number; current: Json }
Args: { current: Json; index: number; options: Json }
Returns: Json
}
get_inventory_items_with_committed: {
Args: { p_store_id: number }
Returns: {
id: number
available: number
committed: number
cost: number
created_at: string
id: number
product_id: number
sku: string
store_id: number
product_id: number
variant_id: number
cost: number
available: number
committed: number
}[]
}
get_inventory_with_committed: {
Args: { p_store_id: number; p_sku: string }
Args: { p_sku: string; p_store_id: number }
Returns: {
id: number
available: number
committed: number
cost: number
created_at: string
id: number
product_id: number
sku: string
store_id: number
product_id: number
variant_id: number
cost: number
available: number
committed: number
}[]
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cd /tmp && find . -type f \( -name "*.sql" -o -name "*migration*" \) 2>/dev/null | head -20

Repository: gridaco/grida

Length of output: 39


🏁 Script executed:

rg -tl sql 'get_inventory_items_with_committed|get_inventory_with_committed' --max-count=20

Repository: gridaco/grida

Length of output: 82


🏁 Script executed:

rg 'create\s+(or\s+replace\s+)?function.*get_inventory.*with_committed' -A 30 -i

Repository: gridaco/grida

Length of output: 5734


🏁 Script executed:

rg 'create\s+table.*inventory_item|CREATE\s+TABLE.*inventory_item' -A 50 -i

Repository: gridaco/grida

Length of output: 4550


Fix nullability mismatch in inventory RPC return types.

Both get_inventory_items_with_committed and get_inventory_with_committed return product_id and cost as non-null (number), but the SQL functions select these directly from inventory_item table columns that are nullable (product_id bigint and cost double precision without NOT NULL constraints). The generated TypeScript types must reflect that these fields can be null: product_id: number | null and cost: number | null.

🤖 Prompt for AI Agents
In @database/database-generated.types.ts around lines 504 - 535, The RPC return
types for get_inventory_items_with_committed and get_inventory_with_committed
are incorrect: update the Returns object for both functions in
database-generated.types.ts so product_id and cost are nullable (product_id:
number | null and cost: number | null) to match the underlying inventory_item
column types; locate the Returns blocks for get_inventory_items_with_committed
and get_inventory_with_committed and change those two field types accordingly.

Comment on lines 4343 to 4366
Args: { p_organization_id: number }
Returns: {
id: string
created_at: string
updated_at: string
doctype: Database["public"]["Enums"]["doctype"]
project_id: number
title: string
form_id: string
organization_id: number
has_connection_supabase: boolean
responses: number
max_responses: number
id: string
is_public: boolean
max_responses: number
organization_id: number
project_id: number
responses: number
title: string
updated_at: string
}[]
}
workspace_mark_access: {
Args: {
p_document_id?: string
p_organization_name: string
p_project_name: string
p_document_id?: string
}
Returns: undefined
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# Search for SQL function definitions
rg -A 50 'create\s+or\s+replace\s+function\s+workspace_documents\s*\(' -S --multiline

Repository: gridaco/grida

Length of output: 5189


🏁 Script executed:

# Search for SQL function definitions
rg -A 50 'create\s+or\s+replace\s+function\s+workspace_mark_access\s*\(' -S --multiline

Repository: gridaco/grida

Length of output: 39


🏁 Script executed:

rg -A 30 'create\s+or\s+replace\s+function\s+workspace_mark_access' -S

Repository: gridaco/grida

Length of output: 39


🏁 Script executed:

rg 'workspace_mark_access' -S

Repository: gridaco/grida

Length of output: 420


🏁 Script executed:

rg -A 20 'CREATE OR REPLACE FUNCTION public.workspace_mark_access' supabase/schemas/project.sql

Repository: gridaco/grida

Length of output: 649


🏁 Script executed:

rg -A 20 'CREATE OR REPLACE FUNCTION public.workspace_mark_access' supabase/migrations/20250418155207_user_project_access_state.sql

Repository: gridaco/grida

Length of output: 649


workspace_documents return fields from LEFT JOINs should be optional in TypeScript.

Fields that can return NULL due to LEFT JOINs (form_id, organization_id, is_public, max_responses) are typed as required. Update to mark these as optional.

workspace_mark_access.p_document_id is correctly optional in TypeScript and matches the SQL definition (DEFAULT NULL).

🤖 Prompt for AI Agents
In @database/database-generated.types.ts around lines 4343 - 4366, The
workspace_documents return type incorrectly marks LEFT JOINable fields as
required; update the Returns object for workspace_documents so that form_id,
organization_id, is_public, and max_responses are optional (e.g., turn their
types into possibly undefined or add ?), leaving other fields unchanged; keep
p_document_id in workspace_mark_access as optional since it already matches the
SQL DEFAULT NULL.

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.

1 participant