UNPKG

graphile-settings

Version:
57 lines (56 loc) 2.49 kB
/** * Presigned URL resolver for the Constructive presigned URL plugin. * * Reads CDN/S3 configuration from the standard env system * (getEnvOptions → pgpmDefaults + config files + env vars) and lazily * initializes an S3Client on first use. * * Also provides a per-database bucket name resolver that derives the * S3 bucket name from the database UUID + a configurable prefix. * * Follows the same lazy-init pattern as upload-resolver.ts. */ import type { S3Config, BucketNameResolver, EnsureBucketProvisioned } from 'graphile-presigned-url-plugin'; /** * Lazily initialize and return the S3Config for the presigned URL plugin. * * Reads CDN config on first call via getEnvOptions() (which already merges * pgpmDefaults → config file → env vars), creates an S3Client, and caches * the result. Same CDN config as upload-resolver.ts. * * NOTE: The `bucket` field here is the global fallback bucket name * (from BUCKET_NAME env var). When `resolveBucketName` is provided, * per-database bucket names take precedence for all S3 operations. */ export declare function getPresignedUrlS3Config(): S3Config; /** * Create a per-(database, bucketKey) bucket name resolver. * * Uses the BUCKET_NAME env var as a prefix. For each (database, bucketKey) * pair, the S3 bucket name becomes `{prefix}-{bucketKey}-{databaseId}` * (e.g., "myapp-public-abc123def456"). * * This aligns with the bucket provisioner plugin which creates separate * S3 buckets per logical bucket key. */ export declare function createBucketNameResolver(): BucketNameResolver; /** * Resolve CORS allowed origins from the env/config system. * * Reads SERVER_ORIGIN from the standard env hierarchy * (pgpmDefaults → config file → env vars) and wraps it in an array. * Falls back to ['http://localhost:3000'] for local development. */ export declare function getAllowedOrigins(): string[]; /** * Create a lazy bucket provisioner callback for the presigned URL plugin. * * On the first upload to an S3 bucket that doesn't exist yet, this callback * uses the BucketProvisioner to create and fully configure the bucket * (Block Public Access, CORS, policies, lifecycle rules for temp buckets). * * Uses the same S3 connection config as the bucket provisioner plugin * (getBucketProvisionerConnection) and reads CORS origins from * SERVER_ORIGIN env var (falls back to localhost for local dev). */ export declare function createEnsureBucketProvisioned(): EnsureBucketProvisioned;