fraiseql_storage/config/mod.rs
1//! Bucket configuration and validation.
2
3use serde::{Deserialize, Serialize};
4
5/// Access control policy for a bucket.
6#[derive(Debug, Clone, Copy)]
7#[non_exhaustive]
8pub enum BucketAccess {
9 /// All operations require authentication.
10 Private,
11 /// Read operations are public; write operations require authentication.
12 PublicRead,
13}
14
15/// Image transform preset for predefined transformations.
16///
17/// Allows defining common image transformations (e.g., thumbnails, previews)
18/// that can be applied by name via the render endpoint.
19#[derive(Debug, Clone, Serialize, Deserialize)]
20pub struct TransformPreset {
21 /// Name of the preset (e.g., "thumbnail", "medium", "preview")
22 pub name: String,
23
24 /// Target width in pixels
25 pub width: Option<u32>,
26
27 /// Target height in pixels
28 pub height: Option<u32>,
29
30 /// Output format (e.g., "webp", "jpeg", "png")
31 pub format: Option<String>,
32
33 /// Quality for lossy formats (1-100)
34 pub quality: Option<u8>,
35}
36
37/// Bucket configuration.
38///
39/// Defines size limits, allowed MIME types, access policies, and transform presets for a bucket.
40#[derive(Debug, Clone)]
41pub struct BucketConfig {
42 /// Name of the bucket.
43 pub name: String,
44
45 /// Maximum object size in bytes (None = unlimited).
46 pub max_object_bytes: Option<u64>,
47
48 /// Allowed MIME types (None = any; Some([]) = none allowed).
49 pub allowed_mime_types: Option<Vec<String>>,
50
51 /// Access control policy.
52 pub access: BucketAccess,
53
54 /// Predefined image transform presets
55 pub transform_presets: Option<Vec<TransformPreset>>,
56}
57
58/// Storage configuration (from fraiseql-server config).
59///
60/// This struct represents the storage backend configuration that specifies
61/// which storage provider to use and its settings.
62#[derive(Debug, Clone, Serialize, Deserialize)]
63pub struct StorageConfig {
64 /// Storage backend type: "local", "s3", "gcs", "azure"
65 pub backend: String,
66
67 /// Path for local filesystem backend
68 pub path: Option<String>,
69
70 /// Bucket name for S3, GCS, and Azure backends
71 pub bucket: Option<String>,
72
73 /// AWS region for S3 backend
74 pub region: Option<String>,
75
76 /// Custom endpoint for S3-compatible services
77 pub endpoint: Option<String>,
78
79 /// GCP project ID for GCS backend
80 pub project_id: Option<String>,
81
82 /// Azure account name
83 pub account_name: Option<String>,
84}