Files
noteflow/scripts/regenerate_proto.sh
Travis Vasceannie 58ad140f48 Complete Sprint 0: Proto & Schema Foundation
Sprint 0 consolidates all proto schema changes and database migrations
for Sprints 1-6 into a coordinated release.

Infrastructure:
- Add named_entities table migration with updated_at trigger
- Add webhook_configs and webhook_deliveries migrations
- Add httpx dependency for webhooks
- Multi-stage Docker build with NER support (with-ner target)
- Enable depends_on for db service in compose.yaml

Proto schema:
- Add SummarizationOptions message (Sprint 1)
- Add EXPORT_FORMAT_PDF enum value (Sprint 3)
- Add ExtractEntities RPC and messages (Sprint 4)
- Add Calendar RPCs and messages (Sprint 5)
- Proto regeneration script at scripts/regenerate_proto.sh

Tests:
- Add proto compilation tests verifying Sprint 0 messages
- Add feature flag tests with env var parsing
- Add migration structure and trigger tests

Documentation:
- Fix PROTO_CHANGELOG.md CalendarProvider field names
- Update COMPLETION_PLAN.md status to 100%

Client submodule updated with Sprint 0 TypeScript types.
2025-12-26 00:35:14 +00:00

63 lines
2.0 KiB
Bash
Executable File

#!/usr/bin/env bash
# Proto regeneration script for NoteFlow
# Regenerates Python, Rust, and provides guidance for TypeScript sync
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
PROTO_DIR="$PROJECT_ROOT/src/noteflow/grpc/proto"
PROTO_FILE="$PROTO_DIR/noteflow.proto"
echo "=== NoteFlow Proto Regeneration ==="
echo ""
# Verify proto file exists
if [[ ! -f "$PROTO_FILE" ]]; then
echo "ERROR: Proto file not found: $PROTO_FILE"
exit 1
fi
# Python stubs
echo "[1/3] Regenerating Python stubs..."
python -m grpc_tools.protoc \
-I "$PROTO_DIR" \
--python_out="$PROTO_DIR" \
--grpc_python_out="$PROTO_DIR" \
--pyi_out="$PROTO_DIR" \
"$PROTO_FILE"
# Fix imports for Python 3.12+ (relative imports in grpc stub)
echo "[2/3] Fixing Python imports..."
GRPC_FILE="$PROTO_DIR/noteflow_pb2_grpc.py"
if [[ "$OSTYPE" == "darwin"* ]]; then
sed -i '' 's/^import noteflow_pb2/from . import noteflow_pb2/' "$GRPC_FILE"
else
sed -i 's/^import noteflow_pb2/from . import noteflow_pb2/' "$GRPC_FILE"
fi
# Rust stubs (via cargo build)
echo "[3/3] Regenerating Rust stubs..."
if command -v cargo &> /dev/null && [[ -d "$PROJECT_ROOT/client/src-tauri" ]]; then
(cd "$PROJECT_ROOT/client" && cargo build --package noteflow-tauri 2>&1) || {
echo " Rust build failed or skipped (run 'cd client && cargo build' manually)"
}
else
echo " Rust toolchain not found or client directory missing, skipping"
fi
echo ""
echo "=== Proto regeneration complete ==="
echo ""
echo "Files updated:"
echo " - $PROTO_DIR/noteflow_pb2.py"
echo " - $PROTO_DIR/noteflow_pb2_grpc.py"
echo " - $PROTO_DIR/noteflow_pb2.pyi"
if [[ -d "$PROJECT_ROOT/client/src-tauri/src/grpc" ]]; then
echo " - client/src-tauri/src/grpc/noteflow.rs"
fi
echo ""
echo "Next steps:"
echo " 1. Update TypeScript types in client/src/api/types.ts (if proto changed)"
echo " 2. Run tests: pytest tests/grpc/"
echo " 3. Commit all generated files together"