-
Notifications
You must be signed in to change notification settings - Fork 3
Squash of eng-294-create-supabase-insertupdate-route #176
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
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughThis update introduces a comprehensive Supabase-backed API layer for a Next.js application, implementing CRUD and batch operations for entities like Person, Account, Platform, Space, Content, Document, and Content Embeddings. It adds utility modules for Supabase integration, type-safe database access, validation, and batch processing. An OpenAI embedding API route is also included. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API_Route
participant Validator
participant SupabaseClient
participant DBUtils
Client->>API_Route: POST /api/supabase/content (JSON body)
API_Route->>Validator: Validate input
Validator-->>API_Route: Valid/Invalid
alt Valid
API_Route->>SupabaseClient: Create instance
API_Route->>DBUtils: getOrCreateEntity(input)
DBUtils-->>SupabaseClient: Upsert/fetch entity
SupabaseClient-->>DBUtils: Entity or error
DBUtils-->>API_Route: Result (entity, error, created)
API_Route-->>Client: JSON response (entity, status, error)
else Invalid
API_Route-->>Client: JSON error response (400)
end
sequenceDiagram
participant Client
participant API_Route
participant Validator
participant SupabaseClient
participant DBUtils
Client->>API_Route: POST /api/supabase/content-embedding/batch (JSON array)
API_Route->>Validator: Validate input array
Validator-->>API_Route: Valid/Invalid
alt Valid
API_Route->>DBUtils: Batch insert/process by model
DBUtils-->>SupabaseClient: Batch upsert per model
SupabaseClient-->>DBUtils: Results or errors
DBUtils-->>API_Route: Aggregated results, partial errors
API_Route-->>Client: JSON response (records, partial errors, status)
else Invalid
API_Route-->>Client: JSON error response (400)
end
Possibly related PRs
Suggested reviewers
Poem
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
9cd2b57 to
f5d1cb9
Compare
f5d1cb9 to
73538cf
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
mdroidian
left a comment
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.
A quick once over to remove comments, adhere to style guide, etc.
Once these comments are addressed, please re tag me for review.
26d1b11 to
7f47560
Compare
ec4ae5e to
4916281
Compare
2d9a054 to
351bed8
Compare
mdroidian
left a comment
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.
Mostly notes for myself later. I'm approving this now and will review/merge #177 into this. Do not push any more changes.
| /** | ||
| * Sends a standardized JSON response. | ||
| * @param request The original NextRequest. | ||
| * @param data The data payload for successful responses. | ||
| * @param error An error message string if the operation failed. | ||
| * @param details Optional detailed error information. | ||
| * @param status The HTTP status code for the response. | ||
| * @param created A boolean indicating if a resource was created (influences status code: 201 vs 200). | ||
| */ |
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 problem with JSDoc's is that they need to be kept up to date. If they are created at all, they should be after the review is passed and ready to be merged. As we can see, these are already out of date.
| * @param tableName The name of the table. | ||
| * @param insertData Data to upsert | ||
| * @param uniqueOn The expected uniqueOn key. | ||
| * @returns Promise<GetOrCreateEntityResult<T>> |
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.
.
| tableName: keyof Database["public"]["Tables"]; | ||
| items: TablesInsert<TableName>[]; | ||
| uniqueOn?: (keyof TablesInsert<TableName>)[]; // Uses pKey otherwise | ||
| inputValidator?: ItemValidator<TablesInsert<TableName>>; |
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.
.
| * Default GET handler for retrieving a resource by Id | ||
| */ | ||
| export const makeDefaultGetHandler = | ||
| (tableName: keyof Database["public"]["Tables"], pk: string = "id") => |
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.
.
Work by Sid: Hyde utility, embedding route, supabase insert routes
Marc-Antoine: introduce generated types, further work on insert routes
Summary by CodeRabbit
New Features
Enhancements
Chores
Documentation