mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-05 20:34:18 +01:00
section 16: Phase 16: Documentation, container ports and full repository checks
This commit is contained in:
1 parent
81a9f0c8ef
commit
a383e57bc5
55 files changed
+4095
-59
No files matched your search
@@ -0,0 +1,38 @@
|
||||
import { useQuery } from '@tanstack/react-query'
|
||||
import type { CreatePreviewSessionResponse, PreviewPortsResponse } from '@opencode-manager/shared/types'
|
||||
import { API_BASE_URL } from '@/config'
|
||||
import { fetchWrapper } from './fetchWrapper'
|
||||
|
||||
function directoryQuery(directory: string | undefined): string {
|
||||
return directory ? `?${new URLSearchParams({ directory }).toString()}` : ''
|
||||
}
|
||||
|
||||
export function previewPortsQueryKey(directory: string | undefined) {
|
||||
return ['previewPorts', directory ?? null] as const
|
||||
}
|
||||
|
||||
export function listPreviewPorts(directory?: string): Promise<PreviewPortsResponse> {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/preview/ports${directoryQuery(directory)}`)
|
||||
}
|
||||
|
||||
export function createPreviewSession(port: number): Promise<CreatePreviewSessionResponse> {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/preview/sessions`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ port }),
|
||||
})
|
||||
}
|
||||
|
||||
export interface UsePreviewPortsOptions {
|
||||
enabled: boolean
|
||||
refetchInterval?: number | false
|
||||
}
|
||||
|
||||
export function usePreviewPorts(directory: string | undefined, options: UsePreviewPortsOptions) {
|
||||
return useQuery({
|
||||
queryKey: previewPortsQueryKey(directory),
|
||||
queryFn: () => listPreviewPorts(directory),
|
||||
enabled: options.enabled,
|
||||
refetchInterval: options.refetchInterval,
|
||||
})
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import type { Repo } from './types'
|
||||
import { FetchError, fetchWrapper, fetchWrapperVoid, fetchWrapperBlob } from './fetchWrapper'
|
||||
import { API_BASE_URL } from '@/config'
|
||||
import { saveFile } from '@/lib/download'
|
||||
import type { DiscoverReposResponse, AssistantModeStatus, AssistantModeInitRequest } from '@opencode-manager/shared/types'
|
||||
import type { DiscoverReposResponse, AssistantModeStatus, AssistantModeInitRequest, WorktreeSetupResult } from '@opencode-manager/shared/types'
|
||||
|
||||
export interface CreateRepoOptions {
|
||||
repoUrl?: string
|
||||
@@ -63,7 +63,7 @@ export async function deleteRepoWorkspace(repoId: number, directory: string): Pr
|
||||
})
|
||||
}
|
||||
|
||||
export async function createRepoWorkspace(repoId: number): Promise<RepoWorktree> {
|
||||
export async function createRepoWorkspace(repoId: number): Promise<RepoWorktree & { worktreeSetup?: WorktreeSetupResult }> {
|
||||
return fetchWrapper(`${API_BASE_URL}/api/repos/${repoId}/workspaces`, {
|
||||
method: 'POST',
|
||||
})
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import type { SessionInfo } from '@opencode-manager/shared/opencode'
|
||||
import type { WorktreeSetupResult } from '@opencode-manager/shared/types'
|
||||
|
||||
export interface Repo {
|
||||
id: number
|
||||
name?: string
|
||||
@@ -15,10 +18,9 @@ export interface Repo {
|
||||
gitCredentialId?: string
|
||||
isWorktree?: boolean
|
||||
isLocal?: boolean
|
||||
worktreeSetup?: WorktreeSetupResult
|
||||
}
|
||||
|
||||
import type { SessionInfo } from '@opencode-manager/shared/opencode'
|
||||
|
||||
export type Session = SessionInfo
|
||||
export type PermissionResponse = 'once' | 'always' | 'reject'
|
||||
|
||||
|
||||
Reference in new issue
Block a user