UNPKG

@directus/api

Version:

Directus is a real-time API and App dashboard for managing SQL database content

95 lines (94 loc) 4.02 kB
import type { Credentials, Deployment, Details, Log, Options, Project, TriggerResult } from '@directus/types'; import type { AxiosRequestConfig, AxiosResponse } from 'axios'; export type DeploymentRequestOptions = Pick<AxiosRequestConfig<string>, 'method' | 'headers'> & { body?: string | null; params?: Record<string, string>; }; export declare abstract class DeploymentDriver<TCredentials extends Credentials = Credentials, TOptions extends Options = Options> { credentials: TCredentials; options: TOptions; constructor(credentials: TCredentials, options?: TOptions); protected axiosRequest<T>(apiUrl: string, endpoint: string, options?: DeploymentRequestOptions): Promise<AxiosResponse<T>>; /** * Test connection with provider using credentials * * @throws {InvalidCredentialsError} When API credentials are invalid */ abstract testConnection(): Promise<void>; /** * List all available projects from provider * * @returns Array of external projects * @throws {InvalidCredentialsError} When API credentials are invalid * @throws {HitRateLimitError} When rate limit is exceeded * @throws {ServiceUnavailableError} When provider API fails */ abstract listProjects(): Promise<Project[]>; /** * Get project details by ID * * @param projectId External project ID * @returns Project details * @throws {InvalidCredentialsError} When API credentials are invalid * @throws {HitRateLimitError} When rate limit is exceeded * @throws {ServiceUnavailableError} When provider API fails */ abstract getProject(projectId: string): Promise<Project>; /** * List deployments for a project * * @param projectId External project ID * @param limit Number of deployments to return * @returns Array of deployments * @throws {InvalidCredentialsError} When API credentials are invalid * @throws {HitRateLimitError} When rate limit is exceeded * @throws {ServiceUnavailableError} When provider API fails */ abstract listDeployments(projectId: string, limit?: number): Promise<Deployment[]>; /** * Get deployment details including logs * * @param deploymentId External deployment ID * @returns Deployment details with logs * @throws {InvalidCredentialsError} When API credentials are invalid * @throws {HitRateLimitError} When rate limit is exceeded * @throws {ServiceUnavailableError} When provider API fails */ abstract getDeployment(deploymentId: string): Promise<Details>; /** * Trigger a new deployment * * @param projectId External project ID * @param options Deployment options * @returns Deployment result * @throws {InvalidCredentialsError} When API credentials are invalid * @throws {HitRateLimitError} When rate limit is exceeded * @throws {ServiceUnavailableError} When provider API fails */ abstract triggerDeployment(projectId: string, options?: { preview?: boolean; clearCache?: boolean; }): Promise<TriggerResult>; /** * Cancel a running deployment * * @param deploymentId External deployment ID * @throws {InvalidCredentialsError} When API credentials are invalid * @throws {HitRateLimitError} When rate limit is exceeded * @throws {ServiceUnavailableError} When provider API fails */ abstract cancelDeployment(deploymentId: string): Promise<void>; /** * Get deployment build logs * * @param deploymentId External deployment ID * @param options.since Only return logs after this timestamp * @returns Array of log entries * @throws {InvalidCredentialsError} When API credentials are invalid * @throws {HitRateLimitError} When rate limit is exceeded * @throws {ServiceUnavailableError} When provider API fails */ abstract getDeploymentLogs(deploymentId: string, options?: { since?: Date; }): Promise<Log[]>; }