mirror of
https://github.com/supabase/supabase.git
synced 2026-10-07 02:15:05 +03:00
## Problem Studio still called the legacy `/workers` Management API routes and used the old `project_worker` response contract, so Compute instances could not be listed or retrieved after the API rename. The production API type check also detected drift in the v1 and platform declarations. ## Fix - Regenerate the v1, v2, and platform API declarations from the deployed schemas. - Update Studio list and detail queries to `/compute`. - Align typed fixtures with the Compute response schemas and `project_compute_instance` resource type. - Update platform response type references to the generated `_Output` schema names. ## How to test - Run `pnpm api:verify-types`. - Run `pnpm --filter api-types test`. - Run `pnpm --filter studio test data/compute/compute.utils.test.ts "tests/pages/project/[ref]/compute/index.test.tsx"`. - Run `pnpm --filter studio typecheck`. - Run `pnpm --filter common typecheck`. - Run `pnpm --filter studio lint:ratchet`. Expected result: production API declarations are synchronized, and Studio requests the `/compute` list and detail endpoints and renders `project_compute_instance` responses successfully. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Improvements** * Updated API response handling across profiles, backups, notifications, integrations, warehouses, access tokens, payments, and other Studio workflows for more accurate serialized data. * Compute instance pages and queries now use the compute-specific API endpoints and response data. * Improved feature-flag type handling when disabled feature data is unavailable. * **Tests** * Updated automated coverage and fixtures to reflect current compute and API response formats. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
73 lines
2.1 KiB
TypeScript
73 lines
2.1 KiB
TypeScript
import * as Sentry from '@sentry/nextjs'
|
|
import type { components } from 'api-types'
|
|
|
|
import { post } from '@/data/fetchers'
|
|
|
|
export type AiSupportStatus = 'bot_active' | 'escalated' | 'user_resolved' | 'bot_resolved'
|
|
|
|
export type SyncConversationMessagesVariables =
|
|
components['schemas']['SyncConversationMessagesBody']
|
|
|
|
type SyncConversationMessagesResponse =
|
|
components['schemas']['SyncConversationMessagesResponse_Output']
|
|
|
|
type EscalateConversationVariables = components['schemas']['EscalateConversationBody']
|
|
|
|
type ResolveConversationVariables = components['schemas']['ResolveConversationBody']
|
|
|
|
type UpdateConversationLifecycleResponse =
|
|
components['schemas']['UpdateConversationLifecycleResponse_Output']
|
|
|
|
/**
|
|
* Sync AI support chat messages to Front via the Platform API.
|
|
*
|
|
* These are fire-and-forget helpers: failures are reported to Sentry and return
|
|
* `null` so a Front outage never breaks the user's chat. The caller leaves its
|
|
* sync bookkeeping untouched on `null` and retries the same delta on the next
|
|
* turn (the server de-dupes by external_id).
|
|
*/
|
|
export async function syncConversationMessagesToFront(
|
|
variables: SyncConversationMessagesVariables
|
|
): Promise<SyncConversationMessagesResponse | null> {
|
|
const { data, error } = await post('/platform/feedback/conversations/messages', {
|
|
body: variables,
|
|
})
|
|
|
|
if (error) {
|
|
Sentry.captureException(error)
|
|
return null
|
|
}
|
|
|
|
return data
|
|
}
|
|
|
|
export async function escalateConversationInFront(
|
|
variables: EscalateConversationVariables
|
|
): Promise<UpdateConversationLifecycleResponse | null> {
|
|
const { data, error } = await post('/platform/feedback/conversations/escalation', {
|
|
body: variables,
|
|
})
|
|
|
|
if (error) {
|
|
Sentry.captureException(error)
|
|
return null
|
|
}
|
|
|
|
return data
|
|
}
|
|
|
|
export async function resolveConversationInFront(
|
|
variables: ResolveConversationVariables
|
|
): Promise<UpdateConversationLifecycleResponse | null> {
|
|
const { data, error } = await post('/platform/feedback/conversations/resolve', {
|
|
body: variables,
|
|
})
|
|
|
|
if (error) {
|
|
Sentry.captureException(error)
|
|
return null
|
|
}
|
|
|
|
return data
|
|
}
|