feat(ai): MCP integration presets (#4398)
* init Signed-off-by: Innei <tukon479@gmail.com> * feat: mcp preset - Bumped the version of `@follow-app/client-sdk` from 0.3.48 to 0.3.50 in both `pnpm-lock.yaml` and `pnpm-workspace.yaml`. - Refactored button rendering logic in `ai-task-modal.tsx` for cleaner code. - Updated status color classes in `task-item.tsx` for improved styling consistency. - Simplified props in `MCPPresetCard.tsx` and removed loading state handling for a more straightforward UI. - Enhanced `MCPPresetSelectionModal.tsx` by removing unnecessary loading states and labels. - Cleaned up `MCPServiceModalContent.tsx` by removing loading state handling from buttons. - Improved `MCPServicesSection.tsx` by adjusting OAuth handling and refetch logic on window focus. - Added new quick setup options for GitHub and Linear in `types.ts`. These changes aim to enhance the user experience and maintainability of the codebase. Signed-off-by: Innei <tukon479@gmail.com> * refactor: implement query optimistic hook - Introduced a new optimistic mutation system to enhance the user experience by providing immediate feedback during create, update, and delete operations. - Added `createOptimisticConfig` for streamlined optimistic updates across various components. - Refactored existing mutations in `ai-task` and `MCPServicesSection` to utilize the new optimistic strategies, improving responsiveness and error handling. - Updated documentation in `CLAUDE.md` to clarify the usage of type checking and linting processes. These changes aim to improve the overall performance and user interaction within the application. Signed-off-by: Innei <tukon479@gmail.com> --------- Signed-off-by: Innei <tukon479@gmail.com>
This commit is contained in:
@@ -99,6 +99,12 @@ pnpm run typecheck
|
||||
pnpm run test
|
||||
```
|
||||
|
||||
You must first use `typecheck` to check if the code types are correct, and after making modifications, you need to use `typecheck` again until it passes.
|
||||
|
||||
After the `typecheck` passes, you can use `lint:fix` to check the code quality.
|
||||
|
||||
This project is a monorepo, and you can use the typecheck and `lint:fix` of sub-packages as needed, but please note that you must follow the above steps in order.
|
||||
|
||||
## Architecture Guidelines
|
||||
|
||||
### Multi-Platform Architecture
|
||||
|
||||
@@ -148,38 +148,46 @@ export const AITaskModal = ({ task, prompt, onSubmit }: AITaskModalProps) => {
|
||||
}
|
||||
|
||||
const handleSubmit = async (data: TaskFormData) => {
|
||||
try {
|
||||
// Process the form data to ensure proper datetime format
|
||||
const processedData = {
|
||||
...data,
|
||||
schedule: data.schedule,
|
||||
}
|
||||
// Process the form data to ensure proper datetime format
|
||||
const processedData = {
|
||||
...data,
|
||||
schedule: data.schedule,
|
||||
}
|
||||
|
||||
if (isEditing) {
|
||||
// Update existing task
|
||||
await updateAITaskMutation.mutateAsync({
|
||||
// The optimistic mutations handle success/error toasts and error cases automatically
|
||||
if (isEditing) {
|
||||
// Update existing task
|
||||
updateAITaskMutation.mutate(
|
||||
{
|
||||
id: task.id,
|
||||
name: processedData.title,
|
||||
prompt: processedData.prompt,
|
||||
schedule: processedData.schedule,
|
||||
})
|
||||
toast.success(t("tasks.toast.updated"))
|
||||
} else {
|
||||
// Create new task
|
||||
await createAITaskMutation.mutateAsync({
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
toast.success(t("tasks.toast.updated"))
|
||||
onSubmit?.(processedData)
|
||||
dismiss()
|
||||
},
|
||||
},
|
||||
)
|
||||
} else {
|
||||
// Create new task
|
||||
createAITaskMutation.mutate(
|
||||
{
|
||||
name: processedData.title,
|
||||
prompt: processedData.prompt,
|
||||
schedule: processedData.schedule,
|
||||
})
|
||||
toast.success(t("tasks.toast.created"))
|
||||
}
|
||||
|
||||
// Call the optional onSubmit callback
|
||||
onSubmit?.(processedData)
|
||||
dismiss()
|
||||
} catch (error) {
|
||||
console.error(`Failed to update/create AI task:`, error)
|
||||
toast.error(isEditing ? t("tasks.toast.update_error") : t("tasks.toast.create_error"))
|
||||
},
|
||||
{
|
||||
onSuccess: () => {
|
||||
toast.success(t("tasks.toast.created"))
|
||||
onSubmit?.(processedData)
|
||||
dismiss()
|
||||
},
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,19 +287,13 @@ export const AITaskModal = ({ task, prompt, onSubmit }: AITaskModalProps) => {
|
||||
{t("words.cancel", { ns: "common" })}
|
||||
</Button>
|
||||
<Button type="submit" size="sm" disabled={currentMutation.isPending}>
|
||||
{currentMutation.isPending ? (
|
||||
<>
|
||||
<i className="i-mgc-loading-3-cute-re mr-2 size-4 animate-spin" />
|
||||
{isEditing ? t("tasks.actions.updating") : t("tasks.actions.scheduling")}
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
<i
|
||||
className={`mr-2 size-4 ${isEditing ? "i-mgc-edit-cute-re" : "i-mgc-calendar-time-add-cute-re"}`}
|
||||
/>
|
||||
{isEditing ? t("tasks.actions.update") : t("tasks.actions.schedule")}
|
||||
</>
|
||||
)}
|
||||
{currentMutation.isPending
|
||||
? isEditing
|
||||
? t("tasks.actions.updating")
|
||||
: t("tasks.actions.scheduling")
|
||||
: isEditing
|
||||
? t("tasks.actions.update")
|
||||
: t("tasks.actions.schedule")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -62,16 +62,16 @@ const getTaskStatus = (task: AITask) => {
|
||||
const getStatusColor = (status: string) => {
|
||||
switch (status) {
|
||||
case "completed": {
|
||||
return "text-green-600 bg-green-50 border-green-200"
|
||||
return "text-green bg-green-50 dark:bg-green-950"
|
||||
}
|
||||
case "scheduled": {
|
||||
return "text-blue-600 bg-blue-50 border-blue-200"
|
||||
return "text-blue bg-blue-50 dark:bg-blue-950"
|
||||
}
|
||||
case "paused": {
|
||||
return "text-gray-600 bg-gray-50 border-gray-200"
|
||||
return "text-gray bg-gray-50 dark:bg-gray-950"
|
||||
}
|
||||
default: {
|
||||
return "text-gray-600 bg-gray-50 border-gray-200"
|
||||
return "text-gray bg-gray-50 dark:bg-gray-950"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,7 +112,7 @@ export const TaskItem = memo<TaskItemProps>(({ task, isDeleting, onDelete, onTog
|
||||
<h4 className="text-text text-sm font-medium">{task.name}</h4>
|
||||
<span
|
||||
className={cn(
|
||||
"inline-flex items-center rounded-full border px-2 py-1 text-xs font-medium",
|
||||
"inline-flex items-center rounded-full px-2 py-1 text-xs",
|
||||
statusColorClass,
|
||||
)}
|
||||
>
|
||||
|
||||
@@ -1,32 +1,35 @@
|
||||
import type { WithOptimistic } from "@follow/hooks"
|
||||
import { createOptimisticConfig, useOptimisticMutation } from "@follow/hooks"
|
||||
import type {
|
||||
AITask,
|
||||
CreateTaskRequest,
|
||||
TaskCreateResponse,
|
||||
TaskDeleteResponse,
|
||||
TaskUpdateResponse,
|
||||
UpdateTaskRequest,
|
||||
} from "@follow-app/client-sdk"
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
|
||||
import { followApi } from "~/lib/api-client"
|
||||
|
||||
const MAX_AI_TASKS = 10
|
||||
|
||||
// Use the generic optimistic wrapper type
|
||||
type OptimisticAITask = WithOptimistic<AITask>
|
||||
|
||||
const aiTaskKey = "ai-task"
|
||||
export const aiTaskKeys = {
|
||||
all: ["ai-task"] as const,
|
||||
lists: () => [...aiTaskKeys.all, "list"] as const,
|
||||
list: () => [...aiTaskKeys.lists()] as const,
|
||||
details: () => [...aiTaskKeys.all, "detail"] as const,
|
||||
detail: (id: string) => [...aiTaskKeys.details(), id] as const,
|
||||
list: [aiTaskKey, "list"] as const,
|
||||
details: [aiTaskKey, "detail"] as const,
|
||||
detail: (id: string) => [...aiTaskKeys.details, id] as const,
|
||||
}
|
||||
|
||||
// Queries
|
||||
|
||||
export const useAITaskListQuery = () => {
|
||||
const { data } = useQuery({
|
||||
queryKey: aiTaskKeys.list(),
|
||||
queryFn: () => followApi.aiTask.list(),
|
||||
queryKey: aiTaskKeys.list,
|
||||
queryFn: () => followApi.aiTask.list().then((res) => res.data),
|
||||
})
|
||||
return data?.data
|
||||
return data
|
||||
}
|
||||
|
||||
export const useCanCreateNewAITask = () => {
|
||||
@@ -37,7 +40,7 @@ export const useCanCreateNewAITask = () => {
|
||||
export const useAITaskQuery = (id: string | undefined, opts?: { enabled?: boolean }) => {
|
||||
const enabled = !!id && (opts?.enabled ?? true)
|
||||
const { data } = useQuery({
|
||||
queryKey: id ? aiTaskKeys.detail(id) : aiTaskKeys.details(),
|
||||
queryKey: id ? aiTaskKeys.detail(id) : aiTaskKeys.details,
|
||||
queryFn: () => followApi.aiTask.get({ id: id as string }),
|
||||
enabled,
|
||||
})
|
||||
@@ -47,38 +50,52 @@ export const useAITaskQuery = (id: string | undefined, opts?: { enabled?: boolea
|
||||
// Mutations
|
||||
|
||||
export const useCreateAITaskMutation = () => {
|
||||
const qc = useQueryClient()
|
||||
return useMutation<TaskCreateResponse, unknown, CreateTaskRequest>({
|
||||
mutationFn: (input) => followApi.aiTask.create(input),
|
||||
onSuccess: async () => {
|
||||
await qc.invalidateQueries({ queryKey: aiTaskKeys.lists() })
|
||||
},
|
||||
})
|
||||
return useOptimisticMutation(
|
||||
createOptimisticConfig.forCreate<OptimisticAITask, CreateTaskRequest, TaskCreateResponse>({
|
||||
mutationFn: (input) => followApi.aiTask.create(input),
|
||||
queryKey: aiTaskKeys.list,
|
||||
generateOptimistic: (variables) => ({
|
||||
name: variables.name,
|
||||
prompt: variables.prompt,
|
||||
isEnabled: variables.isEnabled ?? true,
|
||||
schedule: variables.schedule,
|
||||
userId: "temp-user",
|
||||
createdAt: new Date().toISOString(),
|
||||
updatedAt: new Date().toISOString(),
|
||||
lastRunAt: null,
|
||||
nextRunAt: null,
|
||||
runCount: 0,
|
||||
lastResult: null,
|
||||
lastError: null,
|
||||
}),
|
||||
|
||||
errorMessage: "Failed to create AI task",
|
||||
retryable: false,
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
export const useUpdateAITaskMutation = () => {
|
||||
const qc = useQueryClient()
|
||||
return useMutation<TaskUpdateResponse, unknown, UpdateTaskRequest>({
|
||||
mutationFn: (input) => followApi.aiTask.update(input),
|
||||
onSuccess: async (res) => {
|
||||
const id = res?.data?.id ?? undefined
|
||||
await Promise.all([
|
||||
qc.invalidateQueries({ queryKey: aiTaskKeys.lists() }),
|
||||
id ? qc.invalidateQueries({ queryKey: aiTaskKeys.detail(id) }) : Promise.resolve(),
|
||||
])
|
||||
},
|
||||
})
|
||||
return useOptimisticMutation(
|
||||
createOptimisticConfig.forUpdate<OptimisticAITask, UpdateTaskRequest>({
|
||||
mutationFn: (input) => followApi.aiTask.update(input),
|
||||
queryKey: aiTaskKeys.list,
|
||||
getId: (variables) => variables.id,
|
||||
errorMessage: "Failed to update AI task",
|
||||
retryable: false,
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
export const useDeleteAITaskMutation = () => {
|
||||
const qc = useQueryClient()
|
||||
return useMutation<TaskDeleteResponse, unknown, { id: string }>({
|
||||
mutationFn: ({ id }) => followApi.aiTask.delete({ id }),
|
||||
onSuccess: async (_res, vars) => {
|
||||
await Promise.all([
|
||||
qc.invalidateQueries({ queryKey: aiTaskKeys.lists() }),
|
||||
qc.invalidateQueries({ queryKey: aiTaskKeys.detail(vars.id) }),
|
||||
])
|
||||
},
|
||||
})
|
||||
return useOptimisticMutation(
|
||||
createOptimisticConfig.forDelete<OptimisticAITask, { id: string }>({
|
||||
mutationFn: ({ id }) => followApi.aiTask.delete({ id }),
|
||||
queryKey: aiTaskKeys.list,
|
||||
getId: (variables) => variables.id,
|
||||
|
||||
errorMessage: "Failed to delete AI task",
|
||||
retryable: false,
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
|
||||
import type { MCPPreset } from "./types"
|
||||
|
||||
interface MCPPresetCardProps {
|
||||
preset: MCPPreset
|
||||
onSelect: (preset: MCPPreset) => void
|
||||
}
|
||||
|
||||
export const MCPPresetCard = ({ preset, onSelect }: MCPPresetCardProps) => {
|
||||
return (
|
||||
<div className="border-fill-secondary bg-fill hover:border-accent hover:bg-fill-secondary group rounded-lg border p-4 transition-all hover:shadow-md">
|
||||
<div className="flex flex-col items-center space-y-3 text-center">
|
||||
{/* Icon */}
|
||||
<div className="flex size-12 items-center justify-center">
|
||||
<i className={`${preset.icon} text-text size-8`} />
|
||||
</div>
|
||||
|
||||
{/* Service Name */}
|
||||
<h3 className="text-text text-sm font-medium">{preset.displayName}</h3>
|
||||
|
||||
{/* Description */}
|
||||
<p className="text-text-secondary text-xs leading-relaxed">{preset.description}</p>
|
||||
|
||||
{/* Features */}
|
||||
<div className="w-full space-y-1">
|
||||
{preset.features.map((feature) => (
|
||||
<div key={feature} className="text-text flex items-center text-left text-xs">
|
||||
<span className="text-accent mr-2">•</span>
|
||||
<span>{feature}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Action Button */}
|
||||
<Button
|
||||
size="sm"
|
||||
buttonClassName="w-full bg-accent text-white hover:bg-accent/90"
|
||||
onClick={() => onSelect(preset)}
|
||||
>
|
||||
Quick Setup
|
||||
</Button>
|
||||
|
||||
{/* Auth Required Indicator */}
|
||||
{preset.authRequired && (
|
||||
<div className="text-text-secondary flex items-center text-xs">
|
||||
<i className="i-mgc-user-setting-cute-re mr-1 size-3" />
|
||||
<span>Authentication required</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
+79
@@ -0,0 +1,79 @@
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
|
||||
import { MCPPresetCard } from "./MCPPresetCard"
|
||||
import type { MCPPreset } from "./types"
|
||||
import { MCP_PRESETS } from "./types"
|
||||
|
||||
interface MCPPresetSelectionModalProps {
|
||||
onPresetSelected: (preset: MCPPreset) => void
|
||||
onManualConfig: () => void
|
||||
}
|
||||
|
||||
export const MCPPresetSelectionModal = ({
|
||||
onPresetSelected,
|
||||
onManualConfig,
|
||||
}: MCPPresetSelectionModalProps) => {
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="space-y-4">
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
{MCP_PRESETS.map((preset) => (
|
||||
<MCPPresetCard key={preset.id} preset={preset} onSelect={onPresetSelected} />
|
||||
))}
|
||||
|
||||
{/* Custom/Manual Configuration Card */}
|
||||
<div className="border-fill-secondary bg-fill hover:border-accent hover:bg-fill-secondary group rounded-lg border p-4 transition-all hover:shadow-md">
|
||||
<div className="flex flex-col items-center space-y-3 text-center">
|
||||
<div className="flex size-12 items-center justify-center">
|
||||
<i className="i-mgc-settings-7-cute-re text-text size-8" />
|
||||
</div>
|
||||
|
||||
<h3 className="text-text text-sm font-medium">Custom</h3>
|
||||
|
||||
<p className="text-text-secondary text-xs leading-relaxed">
|
||||
Manual configuration for other MCP services
|
||||
</p>
|
||||
|
||||
<div className="w-full space-y-1">
|
||||
<div className="text-text flex items-center text-left text-xs">
|
||||
<span className="text-accent mr-2">•</span>
|
||||
<span>Custom URL & settings</span>
|
||||
</div>
|
||||
<div className="text-text flex items-center text-left text-xs">
|
||||
<span className="text-accent mr-2">•</span>
|
||||
<span>Advanced configuration</span>
|
||||
</div>
|
||||
<div className="text-text flex items-center text-left text-xs">
|
||||
<span className="text-accent mr-2">•</span>
|
||||
<span>Full control</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
buttonClassName="w-full border-accent text-accent hover:bg-accent hover:text-white"
|
||||
onClick={onManualConfig}
|
||||
>
|
||||
Configure
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Future Services Hint */}
|
||||
<div className="bg-fill-secondary/50 rounded-lg p-4">
|
||||
<div className="flex items-start space-x-3">
|
||||
<i className="i-mgc-information-cute-re text-text-secondary mt-0.5 size-4" />
|
||||
<div className="space-y-1">
|
||||
<p className="text-text text-xs font-medium">More services coming soon</p>
|
||||
<p className="text-text-secondary text-xs">
|
||||
You can use the custom configuration option for any MCP-compatible service.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
+12
-15
@@ -16,6 +16,11 @@ import { toast } from "sonner"
|
||||
|
||||
interface MCPServiceModalContentProps {
|
||||
service?: MCPService | null
|
||||
initialValues?: {
|
||||
name: string
|
||||
transportType: "streamable-http" | "sse"
|
||||
url: string
|
||||
}
|
||||
onSave: (service: {
|
||||
name: string
|
||||
transportType: "streamable-http" | "sse"
|
||||
@@ -23,20 +28,19 @@ interface MCPServiceModalContentProps {
|
||||
headers?: Record<string, string>
|
||||
}) => void
|
||||
onCancel: () => void
|
||||
isLoading?: boolean
|
||||
}
|
||||
|
||||
export const MCPServiceModalContent = ({
|
||||
service,
|
||||
initialValues,
|
||||
onSave,
|
||||
onCancel,
|
||||
isLoading = false,
|
||||
}: MCPServiceModalContentProps) => {
|
||||
const { t } = useTranslation("ai")
|
||||
const [name, setName] = useState(service?.name || "")
|
||||
const [url, setUrl] = useState(service?.url || "")
|
||||
const [name, setName] = useState(service?.name || initialValues?.name || "")
|
||||
const [url, setUrl] = useState(service?.url || initialValues?.url || "")
|
||||
const [transportType, setTransportType] = useState<"streamable-http" | "sse">(
|
||||
service?.transportType || "streamable-http",
|
||||
service?.transportType || initialValues?.transportType || "streamable-http",
|
||||
)
|
||||
const [headers, setHeaders] = useState<Record<string, string>>(service?.headers || {})
|
||||
|
||||
@@ -122,18 +126,11 @@ export const MCPServiceModalContent = ({
|
||||
<div className="flex items-center justify-between">
|
||||
<div />
|
||||
<div className="flex gap-2">
|
||||
<Button variant="outline" size="sm" onClick={onCancel} disabled={isLoading}>
|
||||
<Button variant="outline" size="sm" onClick={onCancel}>
|
||||
Cancel
|
||||
</Button>
|
||||
<Button size="sm" onClick={handleSave} disabled={isLoading}>
|
||||
{isLoading ? (
|
||||
<>
|
||||
<i className="i-mgc-loading-3-cute-re mr-2 size-4 animate-spin" />
|
||||
Saving...
|
||||
</>
|
||||
) : (
|
||||
"Save"
|
||||
)}
|
||||
<Button size="sm" onClick={handleSave}>
|
||||
Save
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+203
-86
@@ -1,11 +1,14 @@
|
||||
import { Button } from "@follow/components/ui/button/index.js"
|
||||
import { Label } from "@follow/components/ui/label/index.jsx"
|
||||
import { Switch } from "@follow/components/ui/switch/index.jsx"
|
||||
import type { WithOptimistic } from "@follow/hooks"
|
||||
import { createOptimisticConfig, useOptimisticMutation } from "@follow/hooks"
|
||||
import type { MCPService } from "@follow/shared/settings/interface"
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"
|
||||
import * as React from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { toast } from "sonner"
|
||||
import { useEventListener } from "usehooks-ts"
|
||||
|
||||
import { setMCPEnabled, useMCPEnabled } from "~/atoms/settings/ai"
|
||||
import { useDialog, useModalStack } from "~/components/ui/modal/stacked/hooks"
|
||||
@@ -18,17 +21,23 @@ import {
|
||||
updateMCPConnection,
|
||||
} from "~/queries/mcp"
|
||||
|
||||
import { MCPPresetSelectionModal } from "./MCPPresetSelectionModal"
|
||||
import { MCPServiceItem } from "./MCPServiceItem"
|
||||
import { MCPServiceModalContent } from "./MCPServiceModalContent"
|
||||
|
||||
// Use the generic optimistic wrapper type
|
||||
type OptimisticMCPService = WithOptimistic<MCPService>
|
||||
|
||||
export const MCPServicesSection = () => {
|
||||
const { t } = useTranslation("ai")
|
||||
const mcpEnabled = useMCPEnabled()
|
||||
const queryClient = useQueryClient()
|
||||
const dialog = useDialog()
|
||||
|
||||
const shouldWindowFocusRefetchRef = React.useRef(false)
|
||||
|
||||
// Reusable OAuth authorization handler using dialog
|
||||
const handleOAuthAuthorization = async (authorizationUrl: string, connectionId?: string) => {
|
||||
const handleOAuthAuthorization = async (authorizationUrl: string, _connectionId?: string) => {
|
||||
const confirmed = await dialog.ask({
|
||||
title: t("integration.mcp.service.auth_required"),
|
||||
message: t("integration.mcp.service.auth_message"),
|
||||
@@ -41,22 +50,24 @@ export const MCPServicesSection = () => {
|
||||
const popup = window.open(
|
||||
authorizationUrl,
|
||||
"_blank",
|
||||
"width=600,height=700,scrollbars=yes,resizable=yes",
|
||||
"width=600,height=700,scrollbars=yes,resizable=yes,popup=yes",
|
||||
)
|
||||
|
||||
if (!popup) {
|
||||
toast.error(t("integration.mcp.service.popup_blocked"))
|
||||
} else {
|
||||
popup.onclose = () => {
|
||||
// FIXME
|
||||
setTimeout(() => {
|
||||
refreshToolsMutation.mutate(connectionId ? [connectionId] : undefined)
|
||||
}, 3000)
|
||||
}
|
||||
shouldWindowFocusRefetchRef.current = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
useEventListener("focus", () => {
|
||||
if (shouldWindowFocusRefetchRef.current) {
|
||||
shouldWindowFocusRefetchRef.current = false
|
||||
refetch()
|
||||
}
|
||||
})
|
||||
|
||||
// Query for MCP connections
|
||||
const {
|
||||
data: mcpServices = [],
|
||||
@@ -68,86 +79,160 @@ export const MCPServicesSection = () => {
|
||||
queryFn: fetchMCPConnections,
|
||||
enabled: mcpEnabled,
|
||||
refetchInterval: 30_000,
|
||||
refetchOnWindowFocus: true,
|
||||
retry: 2,
|
||||
})
|
||||
|
||||
// Mutation for creating MCP connection
|
||||
const createConnectionMutation = useMutation({
|
||||
mutationFn: createMCPConnection,
|
||||
onSuccess: async (result) => {
|
||||
queryClient.invalidateQueries({ queryKey: mcpQueryKeys.connections() })
|
||||
// Optimistic mutation for creating MCP connection
|
||||
const createConnectionMutation = useOptimisticMutation(
|
||||
createOptimisticConfig.custom<OptimisticMCPService, Parameters<typeof createMCPConnection>[0]>({
|
||||
mutationFn: createMCPConnection,
|
||||
queryKey: mcpQueryKeys.connections(),
|
||||
optimisticUpdater: (variables, previousData) => {
|
||||
const tempId = `temp-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
||||
const optimisticService: OptimisticMCPService = {
|
||||
id: tempId,
|
||||
name: variables.name || "New Service",
|
||||
transportType: variables.transportType,
|
||||
url: variables.url,
|
||||
headers: variables.headers,
|
||||
isConnected: false,
|
||||
enabled: true,
|
||||
status: "pending" as const,
|
||||
toolCount: 0,
|
||||
resourceCount: 0,
|
||||
promptCount: 0,
|
||||
createdAt: new Date().toISOString(),
|
||||
lastUsed: null,
|
||||
isOptimistic: true,
|
||||
}
|
||||
|
||||
// Handle OAuth authorization if needed
|
||||
if (result.authorizationUrl) {
|
||||
await handleOAuthAuthorization(result.authorizationUrl, result.connectionId)
|
||||
} else {
|
||||
toast.success(t("integration.mcp.service.added"))
|
||||
refreshToolsMutation.mutate([result.connectionId])
|
||||
return {
|
||||
newData: [optimisticService, ...previousData],
|
||||
rollbackData: previousData,
|
||||
tempId,
|
||||
}
|
||||
},
|
||||
successUpdater: (result: any, _variables, previousData, context: any) => {
|
||||
// Handle the API response structure
|
||||
return previousData.map((service) => {
|
||||
if (service.id === context?.tempId) {
|
||||
// Merge the response data with optimistic data
|
||||
return {
|
||||
...service,
|
||||
id: result.connectionId || result.id || service.id,
|
||||
isConnected: true,
|
||||
status: "connected" as const,
|
||||
isOptimistic: false,
|
||||
}
|
||||
}
|
||||
return service
|
||||
})
|
||||
},
|
||||
onSuccess: async (result: any) => {
|
||||
if (result.authorizationUrl) {
|
||||
await handleOAuthAuthorization(result.authorizationUrl, result.connectionId)
|
||||
} else {
|
||||
toast.success(t("integration.mcp.service.added"))
|
||||
refreshToolsMutation.mutate([result.connectionId])
|
||||
}
|
||||
},
|
||||
errorConfig: {
|
||||
showToast: true,
|
||||
customMessage: t("integration.mcp.service.discovery_failed"),
|
||||
retryable: false,
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
// Optimistic mutation for updating MCP connection
|
||||
const updateConnectionMutation = useOptimisticMutation(
|
||||
createOptimisticConfig.custom<
|
||||
OptimisticMCPService,
|
||||
{
|
||||
connectionId: string
|
||||
updateData: Parameters<typeof updateMCPConnection>[1]
|
||||
}
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error(t("integration.mcp.service.discovery_failed"))
|
||||
console.error("Failed to create MCP connection:", error)
|
||||
},
|
||||
})
|
||||
|
||||
// Mutation for updating MCP connection
|
||||
const updateConnectionMutation = useMutation({
|
||||
mutationFn: ({
|
||||
connectionId,
|
||||
updateData,
|
||||
}: {
|
||||
connectionId: string
|
||||
updateData: Parameters<typeof updateMCPConnection>[1]
|
||||
}) => updateMCPConnection(connectionId, updateData),
|
||||
onSuccess: async (result) => {
|
||||
queryClient.invalidateQueries({ queryKey: mcpQueryKeys.connections() })
|
||||
|
||||
// Handle OAuth authorization if needed
|
||||
if (result.authorizationUrl) {
|
||||
await handleOAuthAuthorization(result.authorizationUrl, result.connectionId)
|
||||
} else {
|
||||
toast.success(t("integration.mcp.service.updated"))
|
||||
refreshToolsMutation.mutate([result.connectionId])
|
||||
}
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error("Failed to update MCP connection")
|
||||
console.error("Failed to update MCP connection:", error)
|
||||
},
|
||||
})
|
||||
|
||||
const toggleConnectionMutation = useMutation({
|
||||
mutationFn: ({ connectionId, enabled }: { connectionId: string; enabled: boolean }) =>
|
||||
updateMCPConnection(connectionId, { enabled }),
|
||||
|
||||
onError: () => {
|
||||
toast.error("Failed to update MCP connection")
|
||||
},
|
||||
onMutate(variables) {
|
||||
queryClient.setQueryData(mcpQueryKeys.connections(), (old: MCPService[]) => {
|
||||
return old.map((service) =>
|
||||
>({
|
||||
mutationFn: (({ connectionId, updateData }) =>
|
||||
updateMCPConnection(connectionId, updateData)) as any,
|
||||
queryKey: mcpQueryKeys.connections(),
|
||||
optimisticUpdater: (variables, previousData) => {
|
||||
const newData = previousData.map((service) =>
|
||||
service.id === variables.connectionId
|
||||
? { ...service, enabled: variables.enabled }
|
||||
? {
|
||||
...service,
|
||||
...variables.updateData,
|
||||
status: "updating" as const,
|
||||
isOptimistic: true,
|
||||
updatedAt: new Date().toISOString(),
|
||||
}
|
||||
: service,
|
||||
)
|
||||
})
|
||||
},
|
||||
})
|
||||
|
||||
// Mutation for deleting MCP connection
|
||||
const deleteConnectionMutation = useMutation({
|
||||
mutationFn: deleteMCPConnection,
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: mcpQueryKeys.connections() })
|
||||
toast.success(t("integration.mcp.service.deleted"))
|
||||
},
|
||||
onError: (error) => {
|
||||
toast.error("Failed to delete MCP connection")
|
||||
console.error("Failed to delete MCP connection:", error)
|
||||
},
|
||||
})
|
||||
return {
|
||||
newData,
|
||||
rollbackData: previousData,
|
||||
targetId: variables.connectionId,
|
||||
}
|
||||
},
|
||||
successUpdater: (result: any, variables, previousData) => {
|
||||
return previousData.map((service) =>
|
||||
service.id === variables.connectionId
|
||||
? {
|
||||
...service,
|
||||
...result,
|
||||
id: variables.connectionId, // Keep the original ID
|
||||
status: "connected" as const,
|
||||
isOptimistic: false,
|
||||
}
|
||||
: service,
|
||||
)
|
||||
},
|
||||
onSuccess: async (result: any) => {
|
||||
if (result.authorizationUrl) {
|
||||
await handleOAuthAuthorization(result.authorizationUrl, result.connectionId)
|
||||
} else {
|
||||
toast.success(t("integration.mcp.service.updated"))
|
||||
refreshToolsMutation.mutate([result.connectionId])
|
||||
}
|
||||
},
|
||||
errorConfig: {
|
||||
showToast: true,
|
||||
customMessage: "Failed to update MCP connection",
|
||||
retryable: false,
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
// Optimistic mutation for toggling connection enabled status
|
||||
const toggleConnectionMutation = useOptimisticMutation(
|
||||
createOptimisticConfig.forToggle<
|
||||
OptimisticMCPService,
|
||||
{ connectionId: string; enabled: boolean },
|
||||
any // API response type
|
||||
>({
|
||||
mutationFn: ({ connectionId, enabled }) => updateMCPConnection(connectionId, { enabled }),
|
||||
queryKey: mcpQueryKeys.connections(),
|
||||
getId: (variables) => variables.connectionId,
|
||||
getToggleData: (variables) => ({ enabled: variables.enabled }),
|
||||
errorMessage: "Failed to toggle MCP connection",
|
||||
retryable: true,
|
||||
}),
|
||||
)
|
||||
|
||||
// Optimistic mutation for deleting MCP connection
|
||||
const deleteConnectionMutation = useOptimisticMutation(
|
||||
createOptimisticConfig.forDelete<OptimisticMCPService, string, void>({
|
||||
mutationFn: deleteMCPConnection,
|
||||
queryKey: mcpQueryKeys.connections(),
|
||||
getId: (connectionId) => connectionId,
|
||||
onSuccess: () => {
|
||||
toast.success(t("integration.mcp.service.deleted"))
|
||||
},
|
||||
errorMessage: "Failed to delete MCP connection",
|
||||
retryable: false,
|
||||
}),
|
||||
)
|
||||
|
||||
// Mutation for refreshing MCP tools
|
||||
const refreshToolsMutation = useMutation({
|
||||
@@ -169,14 +254,47 @@ export const MCPServicesSection = () => {
|
||||
present({
|
||||
title: "Add MCP Service",
|
||||
content: ({ dismiss }: { dismiss: () => void }) => (
|
||||
<MCPServiceModalContent
|
||||
service={null}
|
||||
onSave={(service) => {
|
||||
createConnectionMutation.mutate(service)
|
||||
<MCPPresetSelectionModal
|
||||
onPresetSelected={(preset) => {
|
||||
if (!preset.quickSetup) {
|
||||
// Show form with preset values pre-filled
|
||||
present({
|
||||
title: `Setup ${preset.displayName}`,
|
||||
content: ({ dismiss: dismissForm }) => (
|
||||
<MCPServiceModalContent
|
||||
service={null}
|
||||
initialValues={preset.configTemplate}
|
||||
onSave={(service) => {
|
||||
createConnectionMutation.mutate(service)
|
||||
dismissForm()
|
||||
}}
|
||||
onCancel={dismissForm}
|
||||
/>
|
||||
),
|
||||
})
|
||||
} else {
|
||||
// Direct submission for services
|
||||
createConnectionMutation.mutate(preset.configTemplate)
|
||||
}
|
||||
dismiss()
|
||||
}}
|
||||
onManualConfig={() => {
|
||||
// Show manual configuration form
|
||||
present({
|
||||
title: "Add MCP Service",
|
||||
content: ({ dismiss: dismissForm }) => (
|
||||
<MCPServiceModalContent
|
||||
service={null}
|
||||
onSave={(service) => {
|
||||
createConnectionMutation.mutate(service)
|
||||
dismissForm()
|
||||
}}
|
||||
onCancel={dismissForm}
|
||||
/>
|
||||
),
|
||||
})
|
||||
dismiss()
|
||||
}}
|
||||
onCancel={dismiss}
|
||||
isLoading={createConnectionMutation.isPending}
|
||||
/>
|
||||
),
|
||||
})
|
||||
@@ -196,7 +314,6 @@ export const MCPServicesSection = () => {
|
||||
dismiss()
|
||||
}}
|
||||
onCancel={dismiss}
|
||||
isLoading={updateConnectionMutation.isPending}
|
||||
/>
|
||||
),
|
||||
})
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
export interface MCPPreset {
|
||||
id: string
|
||||
name: string
|
||||
displayName: string
|
||||
icon: string // simple-icons class name
|
||||
description: string
|
||||
features: string[]
|
||||
|
||||
quickSetup: boolean
|
||||
authRequired: boolean
|
||||
configTemplate: {
|
||||
name: string
|
||||
transportType: "streamable-http" | "sse"
|
||||
url: string
|
||||
}
|
||||
}
|
||||
|
||||
export const MCP_PRESETS: MCPPreset[] = [
|
||||
{
|
||||
id: "notion",
|
||||
name: "notion",
|
||||
displayName: "Notion",
|
||||
icon: "i-simple-icons-notion",
|
||||
description: "Connect your Notion workspace",
|
||||
features: ["Read & search pages", "Create new content", "Update existing pages"],
|
||||
|
||||
quickSetup: true,
|
||||
authRequired: true,
|
||||
configTemplate: {
|
||||
name: "Notion",
|
||||
transportType: "streamable-http",
|
||||
url: "https://mcp.notion.com/mcp",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "linear",
|
||||
name: "linear",
|
||||
displayName: "Linear",
|
||||
icon: "i-simple-icons-linear",
|
||||
description: "Connect your Linear workspace",
|
||||
features: ["Read & search issues", "Create new issues", "Update existing issues"],
|
||||
|
||||
quickSetup: true,
|
||||
authRequired: true,
|
||||
configTemplate: {
|
||||
name: "Linear",
|
||||
transportType: "streamable-http",
|
||||
url: "https://mcp.linear.app/mcp",
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
id: "github",
|
||||
name: "github",
|
||||
displayName: "GitHub",
|
||||
icon: "i-simple-icons-github",
|
||||
description: "Connect your GitHub repository",
|
||||
features: ["Read & search issues", "Create new issues", "Update existing issues"],
|
||||
|
||||
quickSetup: false,
|
||||
authRequired: true,
|
||||
configTemplate: {
|
||||
name: "GitHub",
|
||||
transportType: "streamable-http",
|
||||
url: "https://api.githubcopilot.com/mcp",
|
||||
},
|
||||
},
|
||||
]
|
||||
@@ -1,4 +1,5 @@
|
||||
export type { HTMLMediaState } from "./factory/createHTMLMediaHook"
|
||||
export * from "./optimistic"
|
||||
export * from "./useAnyPointDown"
|
||||
export * from "./useControlled"
|
||||
export * from "./useCountDown"
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
import type { MutationFunction, QueryKey } from "@tanstack/react-query"
|
||||
|
||||
import { optimisticStrategies } from "./strategies"
|
||||
import type { OptimisticItem, OptimisticKey, OptimisticMutationConfig } from "./types"
|
||||
|
||||
/**
|
||||
* Configuration builders for common optimistic update patterns
|
||||
* These provide type-safe, pre-configured optimistic mutation setups
|
||||
*/
|
||||
export const createOptimisticConfig = {
|
||||
/**
|
||||
* Configuration for create operations
|
||||
* Adds new items to the beginning of the list
|
||||
*/
|
||||
forCreate: <TData extends OptimisticItem, TVariables, TResponse = any>(config: {
|
||||
mutationFn: MutationFunction<TResponse, TVariables>
|
||||
queryKey: QueryKey
|
||||
generateOptimistic: (variables: TVariables) => Omit<TData, "id" | OptimisticKey | "updatedAt">
|
||||
onSuccess?: (result: TResponse, variables: TVariables) => void | Promise<void>
|
||||
errorMessage?: string
|
||||
retryable?: boolean
|
||||
maxRetries?: number
|
||||
}): OptimisticMutationConfig<TData, TVariables, TResponse> => ({
|
||||
mutationFn: config.mutationFn,
|
||||
queryKey: config.queryKey,
|
||||
onSuccess: config.onSuccess,
|
||||
...optimisticStrategies.create<TData, TResponse>(
|
||||
(variables: TVariables) =>
|
||||
({
|
||||
...config.generateOptimistic(variables),
|
||||
createdAt: new Date().toISOString(),
|
||||
}) as Omit<TData, "id" | OptimisticKey>,
|
||||
),
|
||||
errorConfig: {
|
||||
showToast: true,
|
||||
customMessage: config.errorMessage || "Failed to create item",
|
||||
retryable: config.retryable ?? false,
|
||||
maxRetries: config.maxRetries ?? 0,
|
||||
},
|
||||
}),
|
||||
|
||||
/**
|
||||
* Configuration for update operations
|
||||
* Updates existing items in place
|
||||
*/
|
||||
forUpdate: <
|
||||
TData extends OptimisticItem,
|
||||
TVariables extends Record<string, any>,
|
||||
TResponse = any,
|
||||
>(config: {
|
||||
mutationFn: MutationFunction<TResponse, TVariables>
|
||||
queryKey: QueryKey
|
||||
getId: (variables: TVariables) => string
|
||||
onSuccess?: (result: TResponse, variables: TVariables) => void | Promise<void>
|
||||
errorMessage?: string
|
||||
retryable?: boolean
|
||||
maxRetries?: number
|
||||
}): OptimisticMutationConfig<TData, TVariables, TResponse> => ({
|
||||
mutationFn: config.mutationFn,
|
||||
queryKey: config.queryKey,
|
||||
onSuccess: config.onSuccess,
|
||||
...optimisticStrategies.update<TData, TResponse>(config.getId),
|
||||
errorConfig: {
|
||||
showToast: true,
|
||||
customMessage: config.errorMessage || "Failed to update item",
|
||||
retryable: config.retryable ?? false,
|
||||
maxRetries: config.maxRetries ?? 0,
|
||||
},
|
||||
}),
|
||||
|
||||
/**
|
||||
* Configuration for delete operations
|
||||
* Removes items from the list
|
||||
*/
|
||||
forDelete: <TData extends OptimisticItem, TVariables, TResponse = any>(config: {
|
||||
mutationFn: MutationFunction<TResponse, TVariables>
|
||||
queryKey: QueryKey
|
||||
getId: (variables: TVariables) => string
|
||||
onSuccess?: (result: TResponse, variables: TVariables) => void | Promise<void>
|
||||
errorMessage?: string
|
||||
retryable?: boolean
|
||||
}): OptimisticMutationConfig<TData, TVariables, TResponse> => ({
|
||||
mutationFn: config.mutationFn,
|
||||
queryKey: config.queryKey,
|
||||
onSuccess: config.onSuccess,
|
||||
...optimisticStrategies.delete<TData, TResponse>(config.getId),
|
||||
errorConfig: {
|
||||
showToast: true,
|
||||
customMessage: config.errorMessage || "Failed to delete item",
|
||||
retryable: config.retryable ?? false,
|
||||
maxRetries: 0, // Usually don't retry deletes
|
||||
},
|
||||
}),
|
||||
|
||||
/**
|
||||
* Configuration for toggle operations
|
||||
* Updates specific properties while preserving others
|
||||
*/
|
||||
forToggle: <TData extends OptimisticItem, TVariables, TResponse = any>(config: {
|
||||
mutationFn: MutationFunction<TResponse, TVariables>
|
||||
queryKey: QueryKey
|
||||
getId: (variables: TVariables) => string
|
||||
getToggleData: (variables: TVariables) => Partial<TData>
|
||||
onSuccess?: (result: TResponse, variables: TVariables) => void | Promise<void>
|
||||
errorMessage?: string
|
||||
retryable?: boolean
|
||||
}): OptimisticMutationConfig<TData, TVariables, TResponse> => ({
|
||||
mutationFn: config.mutationFn,
|
||||
queryKey: config.queryKey,
|
||||
onSuccess: config.onSuccess,
|
||||
...optimisticStrategies.toggle<TData, TResponse>(config.getId, config.getToggleData),
|
||||
errorConfig: {
|
||||
showToast: true,
|
||||
customMessage: config.errorMessage || "Failed to toggle item",
|
||||
retryable: config.retryable ?? true,
|
||||
maxRetries: 0,
|
||||
},
|
||||
}),
|
||||
|
||||
/**
|
||||
* Configuration for custom operations
|
||||
* Provides full control over optimistic update behavior
|
||||
*/
|
||||
custom: <TData extends OptimisticItem, TVariables, TResponse = any, TContext = unknown>(
|
||||
config: OptimisticMutationConfig<TData, TVariables, TResponse, TContext>,
|
||||
): OptimisticMutationConfig<TData, TVariables, TResponse, TContext> => ({
|
||||
errorConfig: {
|
||||
showToast: true,
|
||||
retryable: false,
|
||||
maxRetries: 0,
|
||||
},
|
||||
...config,
|
||||
}),
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
export { createOptimisticConfig } from "./config"
|
||||
export { optimisticStrategies } from "./strategies"
|
||||
export type {
|
||||
OptimisticContext,
|
||||
OptimisticItem,
|
||||
OptimisticMutationConfig,
|
||||
StrategyConfig,
|
||||
WithOptimistic,
|
||||
} from "./types"
|
||||
export { useOptimisticMutation } from "./useOptimisticMutation"
|
||||
@@ -0,0 +1,136 @@
|
||||
import type { OptimisticItem, OptimisticKey, StrategyConfig } from "./types"
|
||||
import { optimisticKey, optimisticStatusKey } from "./types"
|
||||
|
||||
/**
|
||||
* Predefined optimistic update strategies for common operations
|
||||
*/
|
||||
export const optimisticStrategies = {
|
||||
/**
|
||||
* Strategy for creating new items
|
||||
* Adds the new item to the beginning of the list with a temporary ID
|
||||
*/
|
||||
create: <T extends OptimisticItem, TResponse = T>(
|
||||
generateOptimisticItem: (variables: any) => Omit<T, "id" | OptimisticKey>,
|
||||
): StrategyConfig<T, TResponse> => ({
|
||||
optimisticUpdater: (variables: any, previousData: T[]) => {
|
||||
const tempId = `temp-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`
|
||||
const optimisticItem = {
|
||||
...generateOptimisticItem(variables),
|
||||
id: tempId,
|
||||
[optimisticKey]: true,
|
||||
[optimisticStatusKey]: "pending",
|
||||
updatedAt: new Date().toISOString(),
|
||||
} as T
|
||||
|
||||
return {
|
||||
newData: [optimisticItem, ...previousData],
|
||||
rollbackData: previousData,
|
||||
tempId,
|
||||
}
|
||||
},
|
||||
|
||||
successUpdater: (result: TResponse, variables: any, previousData: T[], context: any) => {
|
||||
return previousData.map((item) =>
|
||||
item.id === context?.tempId
|
||||
? { ...item, ...(result as any), [optimisticKey]: false }
|
||||
: item,
|
||||
)
|
||||
},
|
||||
}),
|
||||
|
||||
/**
|
||||
* Strategy for updating existing items
|
||||
* Updates the item in place and marks it as optimistic
|
||||
*/
|
||||
update: <T extends OptimisticItem, TResponse = T>(
|
||||
getTargetId: string | ((variables: any) => string),
|
||||
): StrategyConfig<T, TResponse> => ({
|
||||
optimisticUpdater: (variables: any, previousData: T[]) => {
|
||||
const targetId = typeof getTargetId === "function" ? getTargetId(variables) : getTargetId
|
||||
|
||||
const newData = previousData.map((item) =>
|
||||
item.id === targetId
|
||||
? {
|
||||
...item,
|
||||
...variables,
|
||||
[optimisticKey]: true,
|
||||
[optimisticStatusKey]: "updating",
|
||||
updatedAt: new Date().toISOString(),
|
||||
}
|
||||
: item,
|
||||
)
|
||||
|
||||
return {
|
||||
newData,
|
||||
rollbackData: previousData,
|
||||
targetId,
|
||||
}
|
||||
},
|
||||
|
||||
successUpdater: (result: TResponse, variables: any, previousData: T[]) => {
|
||||
const targetId = typeof getTargetId === "function" ? getTargetId(variables) : getTargetId
|
||||
return previousData.map((item) =>
|
||||
item.id === targetId ? { ...item, ...(result as any), [optimisticKey]: false } : item,
|
||||
)
|
||||
},
|
||||
}),
|
||||
|
||||
/**
|
||||
* Strategy for deleting items
|
||||
* Removes the item from the list immediately
|
||||
*/
|
||||
delete: <T extends OptimisticItem, TResponse = any>(
|
||||
getId: (variables: any) => string,
|
||||
): StrategyConfig<T, TResponse> => ({
|
||||
optimisticUpdater: (variables: any, previousData: T[]) => {
|
||||
const targetId = getId(variables)
|
||||
const newData = previousData.filter((item) => item.id !== targetId)
|
||||
|
||||
return {
|
||||
newData,
|
||||
rollbackData: previousData,
|
||||
targetId,
|
||||
}
|
||||
},
|
||||
}),
|
||||
|
||||
/**
|
||||
* Strategy for toggling item properties
|
||||
* Updates specific properties while keeping the rest unchanged
|
||||
*/
|
||||
toggle: <T extends OptimisticItem, TResponse = any>(
|
||||
getId: (variables: any) => string,
|
||||
getToggleData: (variables: any) => Partial<T>,
|
||||
): StrategyConfig<T, TResponse> => ({
|
||||
optimisticUpdater: (variables: any, previousData: T[]) => {
|
||||
const targetId = getId(variables)
|
||||
const toggleData = getToggleData(variables)
|
||||
|
||||
const newData = previousData.map((item) =>
|
||||
item.id === targetId
|
||||
? {
|
||||
...item,
|
||||
...toggleData,
|
||||
[optimisticKey]: true,
|
||||
[optimisticStatusKey]: "updating",
|
||||
|
||||
updatedAt: new Date().toISOString(),
|
||||
}
|
||||
: item,
|
||||
)
|
||||
|
||||
return {
|
||||
newData,
|
||||
rollbackData: previousData,
|
||||
targetId,
|
||||
}
|
||||
},
|
||||
|
||||
successUpdater: (result: TResponse, variables: any, previousData: T[]) => {
|
||||
const targetId = getId(variables)
|
||||
return previousData.map((item) =>
|
||||
item.id === targetId ? { ...item, ...(result as any), [optimisticKey]: false } : item,
|
||||
)
|
||||
},
|
||||
}),
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import type { MutationFunction, QueryKey } from "@tanstack/react-query"
|
||||
|
||||
export const optimisticKey = Symbol("optimistic")
|
||||
export const optimisticStatusKey = Symbol("optimisticStatus")
|
||||
|
||||
export type OptimisticKey = typeof optimisticKey
|
||||
export type OptimisticStatusKey = typeof optimisticStatusKey
|
||||
// Base interface for items that support optimistic updates
|
||||
export interface OptimisticItem {
|
||||
id: string
|
||||
// Use prefixed properties to minimize conflicts
|
||||
[optimisticKey]?: boolean
|
||||
[optimisticStatusKey]?: "pending" | "updating" | "error" | "connected"
|
||||
updatedAt?: string
|
||||
}
|
||||
|
||||
// Generic optimistic wrapper type
|
||||
export type WithOptimistic<T extends { id: string }> = T & {
|
||||
[optimisticKey]?: boolean
|
||||
[optimisticStatusKey]?: "pending" | "updating" | "error" | "connected"
|
||||
}
|
||||
|
||||
// Core optimistic update configuration
|
||||
export interface OptimisticMutationConfig<
|
||||
TData extends OptimisticItem,
|
||||
TVariables,
|
||||
TResponse = any,
|
||||
TContext = unknown,
|
||||
> {
|
||||
// Basic configuration - mutationFn can return any response type
|
||||
mutationFn: MutationFunction<TResponse, TVariables>
|
||||
queryKey: QueryKey
|
||||
|
||||
// Optimistic update strategy
|
||||
optimisticUpdater: (
|
||||
variables: TVariables,
|
||||
previousData: TData[],
|
||||
) => {
|
||||
newData: TData[]
|
||||
rollbackData: TData[]
|
||||
tempId?: string
|
||||
}
|
||||
|
||||
// Success data mapping - handles any response type
|
||||
successUpdater?: (
|
||||
result: TResponse,
|
||||
variables: TVariables,
|
||||
previousData: TData[],
|
||||
context?: TContext,
|
||||
) => TData[]
|
||||
|
||||
// Error handling configuration
|
||||
errorConfig?: {
|
||||
showToast?: boolean
|
||||
customMessage?: string
|
||||
retryable?: boolean
|
||||
maxRetries?: number
|
||||
}
|
||||
|
||||
// Success callback - receives the actual API response
|
||||
onSuccess?: (result: TResponse, variables: TVariables) => void | Promise<void>
|
||||
}
|
||||
|
||||
// Optimistic update context returned from onMutate
|
||||
export interface OptimisticContext {
|
||||
rollbackData: any[]
|
||||
tempId?: string
|
||||
previousData: any[]
|
||||
targetId?: string
|
||||
}
|
||||
|
||||
// Strategy configuration for different operation types
|
||||
export interface StrategyConfig<T extends OptimisticItem, TResponse = any> {
|
||||
optimisticUpdater: OptimisticMutationConfig<T, any, TResponse>["optimisticUpdater"]
|
||||
successUpdater?: OptimisticMutationConfig<T, any, TResponse>["successUpdater"]
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query"
|
||||
import { toast } from "sonner"
|
||||
|
||||
import type { OptimisticContext, OptimisticItem, OptimisticMutationConfig } from "./types"
|
||||
|
||||
/**
|
||||
* Generic optimistic update mutation hook
|
||||
* Provides automatic optimistic updates with error rollback for any mutation
|
||||
*/
|
||||
export function useOptimisticMutation<
|
||||
TData extends OptimisticItem,
|
||||
TVariables,
|
||||
TResponse = any,
|
||||
TContext = OptimisticContext,
|
||||
>(config: OptimisticMutationConfig<TData, TVariables, TResponse, TContext>) {
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
return useMutation({
|
||||
mutationFn: config.mutationFn,
|
||||
|
||||
onMutate: async (variables: TVariables) => {
|
||||
// Cancel any outgoing queries to prevent race conditions
|
||||
await queryClient.cancelQueries({ queryKey: config.queryKey })
|
||||
|
||||
// Get previous data for rollback
|
||||
const previousData = queryClient.getQueryData<TData[]>(config.queryKey) || []
|
||||
|
||||
// Execute optimistic update
|
||||
const { newData, rollbackData, tempId } = config.optimisticUpdater(variables, previousData)
|
||||
|
||||
// Update query cache with optimistic data
|
||||
queryClient.setQueryData(config.queryKey, newData)
|
||||
|
||||
return {
|
||||
rollbackData,
|
||||
tempId,
|
||||
previousData,
|
||||
variables,
|
||||
} as TContext
|
||||
},
|
||||
|
||||
onSuccess: async (result, variables, context) => {
|
||||
// Apply success updater if provided, otherwise invalidate queries
|
||||
if (config.successUpdater) {
|
||||
const currentData = queryClient.getQueryData<TData[]>(config.queryKey) || []
|
||||
const updatedData = config.successUpdater(result, variables, currentData, context)
|
||||
queryClient.setQueryData(config.queryKey, updatedData)
|
||||
}
|
||||
|
||||
// Execute custom success callback
|
||||
await config.onSuccess?.(result, variables)
|
||||
},
|
||||
|
||||
onError: (error, _variables, context: TContext | undefined) => {
|
||||
// Rollback to previous state
|
||||
const rollbackData = (context as any)?.rollbackData
|
||||
if (rollbackData) {
|
||||
queryClient.setQueryData(config.queryKey, rollbackData)
|
||||
}
|
||||
|
||||
// Show error toast if configured
|
||||
if (config.errorConfig?.showToast !== false) {
|
||||
const message = config.errorConfig?.customMessage || "Operation failed"
|
||||
toast.error(message)
|
||||
}
|
||||
|
||||
console.error("Optimistic mutation failed:", error)
|
||||
},
|
||||
|
||||
onSettled: () => {
|
||||
// Ensure eventual consistency by invalidating queries
|
||||
queryClient.invalidateQueries({ queryKey: config.queryKey })
|
||||
},
|
||||
|
||||
// Configure retry behavior
|
||||
retry: config.errorConfig?.retryable ? (config.errorConfig.maxRetries ?? 2) : false,
|
||||
|
||||
retryDelay: (attemptIndex) => Math.min(1000 * Math.pow(2, attemptIndex), 5000),
|
||||
})
|
||||
}
|
||||
Generated
+62
-62
@@ -7,8 +7,8 @@ settings:
|
||||
catalogs:
|
||||
default:
|
||||
'@follow-app/client-sdk':
|
||||
specifier: 0.3.48
|
||||
version: 0.3.48
|
||||
specifier: 0.3.50
|
||||
version: 0.3.50
|
||||
tailwindcss-uikit-colors:
|
||||
specifier: 1.0.0
|
||||
version: 1.0.0
|
||||
@@ -465,7 +465,7 @@ importers:
|
||||
version: 3.0.2(electron@37.2.0)
|
||||
'@follow-app/client-sdk':
|
||||
specifier: 'catalog:'
|
||||
version: 0.3.48(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)
|
||||
version: 0.3.50(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)
|
||||
'@follow/database':
|
||||
specifier: workspace:*
|
||||
version: link:../../../../packages/internal/database
|
||||
@@ -1673,7 +1673,7 @@ importers:
|
||||
dependencies:
|
||||
'@follow-app/client-sdk':
|
||||
specifier: 'catalog:'
|
||||
version: 0.3.48(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)
|
||||
version: 0.3.50(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)
|
||||
'@follow/configs':
|
||||
specifier: workspace:*
|
||||
version: link:../../configs
|
||||
@@ -1685,7 +1685,7 @@ importers:
|
||||
dependencies:
|
||||
'@follow-app/client-sdk':
|
||||
specifier: 'catalog:'
|
||||
version: 0.3.48(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)
|
||||
version: 0.3.50(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)
|
||||
'@follow/constants':
|
||||
specifier: workspace:*
|
||||
version: link:../constants
|
||||
@@ -1757,7 +1757,7 @@ importers:
|
||||
dependencies:
|
||||
'@follow-app/client-sdk':
|
||||
specifier: 'catalog:'
|
||||
version: 0.3.48(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)
|
||||
version: 0.3.50(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)
|
||||
'@follow/constants':
|
||||
specifier: workspace:*
|
||||
version: link:../constants
|
||||
@@ -1821,7 +1821,7 @@ importers:
|
||||
dependencies:
|
||||
'@follow-app/client-sdk':
|
||||
specifier: 'catalog:'
|
||||
version: 0.3.48(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)
|
||||
version: 0.3.50(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)
|
||||
'@follow/configs':
|
||||
specifier: workspace:*
|
||||
version: link:../../configs
|
||||
@@ -4051,26 +4051,26 @@ packages:
|
||||
'@floating-ui/utils@0.2.10':
|
||||
resolution: {integrity: sha512-aGTxbpbg8/b5JfU1HXSrbH3wXZuLPJcNEcZQFMxLs3oSzgtVu6nFPkbbGGUvBcUjKV2YyB9Wxxabo+HEH9tcRQ==}
|
||||
|
||||
'@follow-app/client-sdk@0.3.48':
|
||||
resolution: {integrity: sha512-nPRnKQwzTTvPaIMOfZierMi9+TUlxc2his1FrGmkXOUbyMe6VtnChMtxHWU03Kdb2mnCJrVmOzJa0CwW6NAvmQ==}
|
||||
'@follow-app/client-sdk@0.3.50':
|
||||
resolution: {integrity: sha512-qc8gI5li/v62h1oR8p0bkLh+tlNaEP8jogppoP92v10XktERtd0rrx5grvSQ1pw0mM3Fws4CknEJZeGH9leDaw==}
|
||||
|
||||
'@folo-services/ai-tools@0.2.31':
|
||||
resolution: {integrity: sha512-oqTVMBc6UCLOt/3M9GX4I+DJ8WT2U8Hlok1MN/Sruw8sQu0ZvtoDvkuiJEtssOQAGDifzHm7z8AVmOgNoGrKUg==}
|
||||
|
||||
'@folo-services/constants@0.1.27':
|
||||
resolution: {integrity: sha512-ZCTgPvLiNfKiOU3E7m0x6Y6w/8PIkEHVl7C5pH+Tt36DrM81vHZjy+zPnZISgjOd3DYTJFHTOCI2ReFRx8Ir3g==}
|
||||
|
||||
'@folo-services/drizzle@0.1.21':
|
||||
resolution: {integrity: sha512-yJAPJz05h2uio5wPOHYbzaeFhJNn5UU9S4HPLQa3L8DNE9IG9DMsNAJqFTEpXQPwEQOf2n3k8FCF8GP/SygA7w==}
|
||||
'@folo-services/constants@0.1.29':
|
||||
resolution: {integrity: sha512-7YH5UQyUoT0STsoAKXTJgdAlvW88RKe5L/yqq4nbovSf2UJm1yEfl+opOYMeYEKBzX3OnixIipPL/1oKQPeh0w==}
|
||||
|
||||
'@folo-services/drizzle@0.1.22':
|
||||
resolution: {integrity: sha512-n4L0bBA5AxqJn5K3k+BTzmtuZh90LAO7G6zALCo3H+BOsnMsQ1OCsQH/xFg7m6ICQ80LJVbHdUN6b4ZKUoQJ/g==}
|
||||
|
||||
'@folo-services/drizzle@0.1.23':
|
||||
resolution: {integrity: sha512-Y4oGzfcYtsh9jdaDZvMh0CMO2tD1c2VSt1gtaZbq9uF17sv45empMI72OdGfWEJBJse7h/P+YGydX7iK63aoIQ==}
|
||||
|
||||
'@folo-services/exceptions@0.1.16':
|
||||
resolution: {integrity: sha512-ThmLLe1Dv2CFsDIgcuY6kJhYJnjiQ7UEsewaqc25MkuImDabhzWnnad+3zRnJGLpveaMeEZ69uqUsTbKC+fR7g==}
|
||||
|
||||
'@folo-services/shared@0.0.16':
|
||||
resolution: {integrity: sha512-WWD9NEnzeJlRJ+6/d515ICITSPHRJjvbdqRwdQZM7J+KVyijZybl04VEf6TTJd62VAIEyRnF0PzFPeYQVCV+gQ==}
|
||||
'@folo-services/shared@0.0.18':
|
||||
resolution: {integrity: sha512-1uyoStgw1nE6pJqyrw3KaRQwLHGmz7AcbeYPFV3U7JRCLNz+TZTpYSBzSJ3ElRzc0EWnGs5ZztSH9b1N1uhSQA==}
|
||||
|
||||
'@fontsource/sn-pro@5.2.5':
|
||||
resolution: {integrity: sha512-rBdBv/0ygj6bkO7xDMMFpwobLdSrcQ2Jncb6DIwdeYGoAgeWkQRwVYhGDKasfLjEYCNYxrqr6wsXsM9+aU39RA==}
|
||||
@@ -18952,12 +18952,12 @@ snapshots:
|
||||
|
||||
'@floating-ui/utils@0.2.10': {}
|
||||
|
||||
'@follow-app/client-sdk@0.3.48(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)':
|
||||
'@follow-app/client-sdk@0.3.50(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)':
|
||||
dependencies:
|
||||
'@folo-services/constants': 0.1.27
|
||||
'@folo-services/drizzle': 0.1.21(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)
|
||||
'@folo-services/constants': 0.1.29
|
||||
'@folo-services/drizzle': 0.1.23(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)
|
||||
'@folo-services/exceptions': 0.1.16
|
||||
'@folo-services/shared': 0.0.16(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)
|
||||
'@folo-services/shared': 0.0.18(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)
|
||||
zod: 3.25.76
|
||||
transitivePeerDependencies:
|
||||
- '@aws-sdk/client-rds-data'
|
||||
@@ -19030,49 +19030,10 @@ snapshots:
|
||||
- sql.js
|
||||
- sqlite3
|
||||
|
||||
'@folo-services/constants@0.1.27':
|
||||
'@folo-services/constants@0.1.29':
|
||||
dependencies:
|
||||
zod: 3.25.76
|
||||
|
||||
'@folo-services/drizzle@0.1.21(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)':
|
||||
dependencies:
|
||||
'@folo-services/exceptions': 0.1.16
|
||||
drizzle-orm: 0.44.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)
|
||||
drizzle-zod: 0.7.1(drizzle-orm@0.44.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3))(zod@3.25.76)
|
||||
nanoid: 5.1.5
|
||||
pg: 8.16.3
|
||||
zod: 3.25.76
|
||||
transitivePeerDependencies:
|
||||
- '@aws-sdk/client-rds-data'
|
||||
- '@cloudflare/workers-types'
|
||||
- '@electric-sql/pglite'
|
||||
- '@libsql/client'
|
||||
- '@libsql/client-wasm'
|
||||
- '@neondatabase/serverless'
|
||||
- '@op-engineering/op-sqlite'
|
||||
- '@opentelemetry/api'
|
||||
- '@planetscale/database'
|
||||
- '@prisma/client'
|
||||
- '@tidbcloud/serverless'
|
||||
- '@types/better-sqlite3'
|
||||
- '@types/pg'
|
||||
- '@types/sql.js'
|
||||
- '@upstash/redis'
|
||||
- '@vercel/postgres'
|
||||
- '@xata.io/client'
|
||||
- better-sqlite3
|
||||
- bun-types
|
||||
- expo-sqlite
|
||||
- gel
|
||||
- knex
|
||||
- kysely
|
||||
- mysql2
|
||||
- pg-native
|
||||
- postgres
|
||||
- prisma
|
||||
- sql.js
|
||||
- sqlite3
|
||||
|
||||
'@folo-services/drizzle@0.1.22(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)':
|
||||
dependencies:
|
||||
'@folo-services/exceptions': 0.1.16
|
||||
@@ -19112,11 +19073,50 @@ snapshots:
|
||||
- sql.js
|
||||
- sqlite3
|
||||
|
||||
'@folo-services/drizzle@0.1.23(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)':
|
||||
dependencies:
|
||||
'@folo-services/exceptions': 0.1.16
|
||||
drizzle-orm: 0.44.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)
|
||||
drizzle-zod: 0.7.1(drizzle-orm@0.44.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3))(zod@3.25.76)
|
||||
nanoid: 5.1.5
|
||||
pg: 8.16.3
|
||||
zod: 3.25.76
|
||||
transitivePeerDependencies:
|
||||
- '@aws-sdk/client-rds-data'
|
||||
- '@cloudflare/workers-types'
|
||||
- '@electric-sql/pglite'
|
||||
- '@libsql/client'
|
||||
- '@libsql/client-wasm'
|
||||
- '@neondatabase/serverless'
|
||||
- '@op-engineering/op-sqlite'
|
||||
- '@opentelemetry/api'
|
||||
- '@planetscale/database'
|
||||
- '@prisma/client'
|
||||
- '@tidbcloud/serverless'
|
||||
- '@types/better-sqlite3'
|
||||
- '@types/pg'
|
||||
- '@types/sql.js'
|
||||
- '@upstash/redis'
|
||||
- '@vercel/postgres'
|
||||
- '@xata.io/client'
|
||||
- better-sqlite3
|
||||
- bun-types
|
||||
- expo-sqlite
|
||||
- gel
|
||||
- knex
|
||||
- kysely
|
||||
- mysql2
|
||||
- pg-native
|
||||
- postgres
|
||||
- prisma
|
||||
- sql.js
|
||||
- sqlite3
|
||||
|
||||
'@folo-services/exceptions@0.1.16': {}
|
||||
|
||||
'@folo-services/shared@0.0.16(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)':
|
||||
'@folo-services/shared@0.0.18(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)':
|
||||
dependencies:
|
||||
'@folo-services/drizzle': 0.1.21(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)
|
||||
'@folo-services/drizzle': 0.1.23(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)
|
||||
drizzle-orm: 0.44.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3)
|
||||
drizzle-zod: 0.7.1(drizzle-orm@0.44.3(@opentelemetry/api@1.9.0)(@types/pg@8.6.1)(expo-sqlite@15.2.12(expo@53.0.12(@babel/core@7.28.0)(@expo/metro-runtime@5.0.4(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0)))(bufferutil@4.0.9)(graphql@16.8.1)(react-native-webview@13.15.0(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(react-native@0.79.1(@babel/core@7.28.0)(@types/react@19.1.8)(bufferutil@4.0.9)(react@19.0.0))(react@19.0.0))(kysely@0.28.2)(pg@8.16.3))(zod@3.25.76)
|
||||
zod: 3.25.76
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ packages:
|
||||
|
||||
catalog:
|
||||
typescript: 5.8.3
|
||||
"@follow-app/client-sdk": 0.3.48
|
||||
"@follow-app/client-sdk": 0.3.50
|
||||
tailwindcss-uikit-colors: 1.0.0
|
||||
|
||||
onlyBuiltDependencies:
|
||||
|
||||
Reference in New Issue
Block a user