/** * Workspace file storage settings: the one S3-compatible configuration that * Settings, onboarding, and templates such as Clips all read and write. * * Values live as workspace-scoped secrets under the `S3_*` names that every * S3 upload provider resolves. `R2_*` names are legacy aliases the providers * still read, so clearing removes them too; otherwise "cleared" storage would * keep uploading to the old bucket. */ import { type ActionRunContext } from "../action.js"; import { type PrivateStorageReadinessStatus } from "./storage-readiness.js"; export declare const FILE_STORAGE_SECRET_KEYS: { readonly endpoint: "S3_ENDPOINT"; readonly bucket: "S3_BUCKET"; readonly accessKeyId: "S3_ACCESS_KEY_ID"; readonly secretAccessKey: "S3_SECRET_ACCESS_KEY"; readonly region: "S3_REGION"; readonly publicBaseUrl: "S3_PUBLIC_BASE_URL"; }; export type FileStorageField = keyof typeof FILE_STORAGE_SECRET_KEYS; export declare const FILE_STORAGE_SECRET_DESCRIPTION = "S3-compatible object storage for file uploads"; export declare const FILE_STORAGE_PROVIDERS: readonly ["aws-s3", "cloudflare-r2", "supabase", "other"]; export type FileStorageProviderId = (typeof FILE_STORAGE_PROVIDERS)[number]; export declare const FILE_STORAGE_MANAGE_DENIED = "Only organization owners and admins can change file storage."; export interface FileStorageStatus { /** Owners and admins (or the only user of a solo workspace) can change storage. */ canManage: boolean; /** The saved workspace values form a complete configuration. */ configured: boolean; /** True when unreadable saved values prevented a complete status check. */ configurationUnavailable: boolean; /** Saved fields that exist but cannot be decrypted; values are never returned. */ unreadableFields: FileStorageField[]; /** Preset inferred from the endpoint; null when nothing is saved. */ provider: FileStorageProviderId | null; /** Non-secret saved values. Null for members and for unsaved fields. */ endpoint: string | null; bucket: string | null; region: string | null; publicBaseUrl: string | null; /** Which fields have a saved workspace value. Always false for members. */ saved: Record; /** * False when the registered `s3` provider can serve files without a public * base URL (Clips reads objects through signed requests). */ publicUrlRequired: boolean; /** The provider new uploads go to for this request. */ activeProvider: { id: string; name: string; } | null; /** True when saved credential errors prevented the active provider check. */ activeProviderUnavailable: boolean; /** Whether Builder.io storage would take uploads after a clear; null when the check failed. */ builderUploadConfigured: boolean | null; /** Private-blob readiness in the caller's strict selected-storage context. */ privateStorageReadiness: PrivateStorageReadinessStatus; } export interface SaveFileStorageInput { endpoint?: string; bucket?: string; accessKeyId?: string; secretAccessKey?: string; /** Empty string removes the saved value. */ region?: string; /** Empty string removes the saved value when the provider allows it. */ publicBaseUrl?: string; } interface FileStorageAccess { scopeId: string; canManage: boolean; } export declare function resolveFileStorageAccess(ctx: ActionRunContext | undefined): Promise; export declare function inferFileStorageProvider(endpoint: string | null | undefined): FileStorageProviderId | null; export declare function isFileStoragePublicUrlRequired(): boolean; export declare function getFileStorageStatus(ctx: ActionRunContext | undefined): Promise; /** * Save workspace storage values. Omitted and blank key fields keep their * saved value, so editing the bucket doesn't ask for the keys again. If an * existing value is unreadable, a partial save must replace it first. */ export declare function saveFileStorage(ctx: ActionRunContext | undefined, input: SaveFileStorageInput): Promise; /** Delete every workspace storage key. Files already uploaded stay in the bucket. */ export declare function clearFileStorage(ctx: ActionRunContext | undefined): Promise<{ removedKeys: string[]; status: FileStorageStatus; }>; export {};