mirror of
https://github.com/Sea-Haven-Industries/payments-dashboard.git
synced 2026-09-30 22:53:11 +00:00
Capture response headers, body, and transactionId on every check-issue API call; persist as boa_txn#<ts>#<action> records with 90-day TTL. Add "Recent BoA Submissions" section to App Home showing the last 10 with click-to-copy transactionId. Motivation: BoA support asked for a transactionId from a past successful call and we had no way to recover it from CloudWatch summary logs alone. Also adds simulate-csv.cjs (dry-run preview) and stampli-uploader.sh (launchd-invoked S3 uploader), and gitignores debug artifacts.
45 lines
1.4 KiB
Bash
Executable file
45 lines
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
DROP_DIR="$HOME/stampli-drop"
|
|
UPLOADED_DIR="$DROP_DIR/uploaded"
|
|
LOG_FILE="$DROP_DIR/.upload.log"
|
|
BUCKET="seahaven-payments-csv-328440206208"
|
|
|
|
mkdir -p "$UPLOADED_DIR"
|
|
exec >> "$LOG_FILE" 2>&1
|
|
|
|
LOCK_DIR="$DROP_DIR/.upload.lock"
|
|
if ! mkdir "$LOCK_DIR" 2>/dev/null; then
|
|
echo "$(date '+%Y-%m-%dT%H:%M:%S') skipping — another run holds the lock"
|
|
exit 0
|
|
fi
|
|
trap 'rmdir "$LOCK_DIR" 2>/dev/null || true' EXIT
|
|
|
|
sleep 2
|
|
|
|
shopt -s nullglob
|
|
uploaded_count=0
|
|
failed_count=0
|
|
|
|
for f in "$DROP_DIR"/*.csv; do
|
|
[ -f "$f" ] || continue
|
|
name=$(basename "$f")
|
|
ts=$(date '+%Y%m%d-%H%M%S')
|
|
|
|
echo "$(date '+%Y-%m-%dT%H:%M:%S') uploading $name"
|
|
if aws s3 cp "$f" "s3://$BUCKET/$name"; then
|
|
mv "$f" "$UPLOADED_DIR/$ts-$name"
|
|
echo "$(date '+%Y-%m-%dT%H:%M:%S') OK → uploaded/$ts-$name"
|
|
uploaded_count=$((uploaded_count + 1))
|
|
osascript -e "display notification \"Uploaded $name\" with title \"Stampli Uploader\"" 2>/dev/null || true
|
|
else
|
|
echo "$(date '+%Y-%m-%dT%H:%M:%S') FAIL $name"
|
|
failed_count=$((failed_count + 1))
|
|
osascript -e "display notification \"Failed to upload $name — see .upload.log\" with title \"Stampli Uploader\" sound name \"Basso\"" 2>/dev/null || true
|
|
fi
|
|
done
|
|
|
|
if [ $uploaded_count -eq 0 ] && [ $failed_count -eq 0 ]; then
|
|
echo "$(date '+%Y-%m-%dT%H:%M:%S') folder change triggered but no .csv files found"
|
|
fi
|