# --------------------------------------------------------------------------
# CD Report Generator - Environment Variables
# Copy this file to ".env" and fill in real values.
# NEVER commit the real ".env" file (with real keys) to version control.
# --------------------------------------------------------------------------

# AWS credentials used by boto3 to upload the generated zip to S3.
# (Not needed if you're running on an EC2/ECS instance with an attached
# IAM role that already has S3 access — in that case leave these blank
# and boto3 will pick up the role automatically.)

API_KEY=sk_live_03XMnzZ1Ab0beRQZitWjdW1GCEbamAA1TG-a8E2HiuI

#AWS_SECRET_ACCESS_KEY=GLoDCXCL1ajIg2orJAnpMlPhGaOPx/KTGdcM3p4t
#AWS_ACCESS_KEY_ID=AKIAVPKZLJQC42GN5CVW

AWS_SECRET_ACCESS_KEY=VT+C8/IpECe2IjOiuU0tr83nNjxo4HSKWWjmlmdY
AWS_ACCESS_KEY_ID=AKIAVPKZLJQCTBHCGFCP

# AWS region your S3 bucket lives in
AWS_REGION=eu-west-2

# S3 bucket name that backs the pharm.amazonaws.com domain
# (i.e. the actual bucket, not the custom domain)
S3_BUCKET=pharmsmart-pharmacy

# Optional: public base URL used to build the returned zip link.
# If your bucket/domain is public (e.g. served via CloudFront or a
# custom domain like pharm.amazonaws.com), set this so the API returns
# a clean public URL instead of a temporary presigned URL.
S3_PUBLIC_BASE_URL=https://pharmsmart-pharmacy.s3.eu-west-2.amazonaws.com/
PRESIGNED_URL_EXPIRY_SECONDS=7200

ALLOWED_ORIGINS=https://pharmsmart-pharmacy.s3.eu-west-2.amazonaws.com,http://157.245.44.140:8002,http://127.0.0.1:8000,https://csv2pdf.pharmsmart.co.uk
#http://localhost:3000,https://your-domain.com#,http://127.0.0.1:8000//

# Template used to auto-build the zip's destination S3 key when zip_key
# is NOT passed in the request. Placeholders are parsed straight out of
# csv_url, assuming a path shaped like:
#   .../<pharmacy_id>/report_files/<report_stem>.csv
#
# {pharmacy_id}  - the folder segment right before "report_files"
# {report_stem}  - the CSV filename without the ".csv" extension
#
# Example: given
#   csv_url = https://pharmsmart-pharmacy.s3.eu-west-2.amazonaws.com/local/pharmacies/aXUvTHlvWmVDMkIxL3EzQTk3Sm1kUT09/report_files/2906266-cd-entries.csv
# the default template below produces:
#   local/pharmacies/aXUvTHlvWmVDMkIxL3EzQTk3Sm1kUT09/report_files/2906266-cd-entries.zip
#
# If your real zip destination folder uses a DIFFERENT id than the source
# CSV folder, that mapping can't be derived from csv_url alone — adjust
# this template to match your actual folder-naming rule, or pass zip_key
# explicitly per request to override auto-derivation.
ZIP_KEY_TEMPLATE={receive_form}/pharmacies/{pharmacy_id}/report_files/{report_stem}.zip

# --------------------------------------------------------------------------
# LOCAL TESTING (no AWS needed)
# --------------------------------------------------------------------------
# Set STORAGE_BACKEND=local to test /generate-report on your machine with
# ZERO AWS setup — no account, no credentials, no bucket. The zip gets saved
# to LOCAL_OUTPUT_DIR on disk instead of uploaded to S3, and the API returns
# a local file path instead of a URL.
#
# For production, just set STORAGE_BACKEND=s3 (or remove this line) — no
# code changes needed, only this .env value.

STORAGE_BACKEND=s3
LOCAL_OUTPUT_DIR=/home/user/Downloads
#LOCAL_OUTPUT_DIR=./local_zip_output

# Base URL used to build the downloadable link returned in zip_url when
# STORAGE_BACKEND=local. Files are served by this same FastAPI app at
# {LOCAL_PUBLIC_BASE_URL}/files/{zip_key} — set this to wherever the server
# is actually reachable from (e.g. http://localhost:8000 for local dev, or
# https://your-domain.com if running this permanently without S3).
LOCAL_PUBLIC_BASE_URL=https://pharmsmart-pharmacy.s3.eu-west-2.amazonaws.com

# --------------------------------------------------------------------------
# Laravel API settings
# --------------------------------------------------------------------------
STAGE_LARAVEL_URL=https://devstage.pharmsmart.co.uk/api/ext/v2/pharmacy/aws-csv-pdf-converter/index.php
LIVE_LARAVEL_URL=https://pharmsmart.co.uk/api/ext/v2/pharmacy/aws-csv-pdf-converter/index.php
CALLBACK_TIMEOUT_SECONDS=30
LARAVEL_SECRET_KEY=c2fbe9b19b67817381401c489f28e06d83954f327a97018357d1fa12b97fd2a8

# --------------------------------------------------------------------------
# Logging settings
# --------------------------------------------------------------------------
LOG_FILE_PATH=logs/api.log
LOG_LEVEL=INFO
LOG_MAX_BYTES=5242880
LOG_BACKUP_COUNT=5

# --------------------------------------------------------------------------
# Memory and row limits
# --------------------------------------------------------------------------

MAX_MEMORY_MB=300
MAX_ROWS_PER_PDF=1000
MAX_REGISTER_GROUPS=500
