mirror of
https://github.com/ruvnet/RuVector.git
synced 2026-05-25 06:36:37 +00:00
Major additions: - Complete Next.js studio application with 1600+ components - Docker support (Dockerfile.combined, docker-compose.yml) - GCP deployment documentation and benchmarks - SQL benchmark scripts for performance testing - Sentry integration for monitoring - Comprehensive test suite and mocks Studio features: - Dashboard and admin interfaces - Data visualization components - Authentication and user management - API integration with RuVector backend - Static data and public assets 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
73 lines
2.2 KiB
TypeScript
73 lines
2.2 KiB
TypeScript
import { useMutation, useQueryClient } from '@tanstack/react-query'
|
|
import { toast } from 'sonner'
|
|
|
|
import type { components } from 'data/api'
|
|
import { handleError, post } from 'data/fetchers'
|
|
import type { ResponseError, UseCustomMutationOptions } from 'types'
|
|
import type { Content } from './content-query'
|
|
import { contentKeys } from './keys'
|
|
|
|
export type InsertContentPayload = Omit<components['schemas']['CreateContentBody'], 'content'> & {
|
|
content: Content['content']
|
|
favorite?: boolean
|
|
}
|
|
|
|
export type InsertContentVariables = {
|
|
projectRef: string
|
|
payload: InsertContentPayload
|
|
}
|
|
|
|
export type InsertContentResponse = components['schemas']['UserContentObject']
|
|
|
|
export async function insertContent(
|
|
{ projectRef, payload }: InsertContentVariables,
|
|
signal?: AbortSignal
|
|
) {
|
|
const { data, error } = await post('/platform/projects/{ref}/content', {
|
|
params: { path: { ref: projectRef } },
|
|
body: {
|
|
id: payload.id,
|
|
name: payload.name,
|
|
description: payload.description,
|
|
owner_id: payload.owner_id,
|
|
type: payload.type,
|
|
visibility: payload.visibility,
|
|
content: payload.content as any,
|
|
folder_id: payload.folder_id,
|
|
favorite: payload.favorite,
|
|
},
|
|
signal,
|
|
})
|
|
if (error) handleError(error)
|
|
return data
|
|
}
|
|
|
|
export type InsertContentData = Awaited<ReturnType<typeof insertContent>>
|
|
|
|
export const useContentInsertMutation = ({
|
|
onError,
|
|
onSuccess,
|
|
...options
|
|
}: Omit<
|
|
UseCustomMutationOptions<InsertContentData, ResponseError, InsertContentVariables>,
|
|
'mutationFn'
|
|
> = {}) => {
|
|
const queryClient = useQueryClient()
|
|
|
|
return useMutation<InsertContentData, ResponseError, InsertContentVariables>({
|
|
mutationFn: (args) => insertContent(args),
|
|
async onSuccess(data, variables, context) {
|
|
const { projectRef } = variables
|
|
await queryClient.invalidateQueries({ queryKey: contentKeys.allContentLists(projectRef) })
|
|
await onSuccess?.(data, variables, context)
|
|
},
|
|
async onError(data, variables, context) {
|
|
if (onError === undefined) {
|
|
toast.error(`Failed to insert content: ${data.message}`)
|
|
} else {
|
|
onError(data, variables, context)
|
|
}
|
|
},
|
|
...options,
|
|
})
|
|
}
|