diff --git a/.github/workflows/regenerate-db-types.yaml b/.github/workflows/regenerate-db-types.yaml index 72e8ae7e..1ed9a4cb 100644 --- a/.github/workflows/regenerate-db-types.yaml +++ b/.github/workflows/regenerate-db-types.yaml @@ -53,14 +53,13 @@ jobs: echo "Installing project dependencies" npm ci --legacy-peer-deps - echo "Installing kysely-codegen globally" - npm install -g kysely-codegen - - echo "Verifying kysely-codegen installation" - kysely-codegen --version || { - echo "Error: kysely-codegen installation failed" - exit 1 - } + echo "Installing kysely-codegen, typescript, and pg globally" + npm install -g kysely-codegen typescript pg + + echo "Verifying installations" + which kysely-codegen || { echo "Error: kysely-codegen not found"; exit 1; } + tsc --version || { echo "Error: typescript not found"; exit 1; } + node -e "require('pg')" || { echo "Error: pg not found"; exit 1; } - name: Setup PostgreSQL uses: ikalnytskyi/action-setup-postgres@v6 @@ -151,14 +150,14 @@ jobs: cp "$SOURCE_FILE" "$dir/db-types.d.ts" if [ $? -eq 0 ]; then - ((SUCCESS_COUNT++)) + SUCCESS_COUNT=$((SUCCESS_COUNT + 1)) else echo "Failed to copy to $dir" - ((FAIL_COUNT++)) + FAIL_COUNT=$((FAIL_COUNT + 1)) fi else echo "Warning: Directory $dir does not exist" - ((FAIL_COUNT++)) + FAIL_COUNT=$((FAIL_COUNT + 1)) fi done @@ -219,14 +218,14 @@ jobs: if: steps.git-check.outputs.changes == 'true' id: pr-author run: | - # username PR_AUTHOR_NAME="${{ github.event.pull_request.user.login }}" - PR_AUTHOR_EMAIL="${{ github.event.pull_request.user.login }}@users.noreply.github.com" + PR_AUTHOR_EMAIL="${PR_AUTHOR_NAME}@users.noreply.github.com" - REAL_EMAIL=$(gh api /users/${{ github.event.pull_request.user.login }} --jq '.email' 2>/dev/null || echo "") - - if [ -n "$REAL_EMAIL" ] && [ "$REAL_EMAIL" != "null" ]; then - PR_AUTHOR_EMAIL="$REAL_EMAIL" + if [ -n "$PR_AUTHOR_NAME" ]; then + REAL_EMAIL=$(gh api /users/${PR_AUTHOR_NAME} --jq '.email' 2>/dev/null || echo "") + if [ -n "$REAL_EMAIL" ] && [ "$REAL_EMAIL" != "null" ]; then + PR_AUTHOR_EMAIL="$REAL_EMAIL" + fi fi echo "name=$PR_AUTHOR_NAME" >> $GITHUB_OUTPUT @@ -254,12 +253,12 @@ jobs: git commit -m "$COMMIT_MESSAGE" - git push origin HEAD:${{ github.head_ref }} + git push origin HEAD:${{ github.head_ref || github.ref_name }} echo "Changes committed + pushed successfully" - name: Comment on PR - if: steps.git-check.outputs.changes == 'true' + if: steps.git-check.outputs.changes == 'true' && github.event_name == 'pull_request' uses: actions/github-script@v7 with: script: | @@ -288,7 +287,7 @@ jobs: }); - name: Comment on PR if no changes - if: steps.git-check.outputs.changes != 'true' + if: steps.git-check.outputs.changes != 'true' && github.event_name == 'pull_request' uses: actions/github-script@v7 with: script: | diff --git a/apps/backend/lambdas/auth/db-types.d.ts b/apps/backend/lambdas/auth/db-types.d.ts index 5ca734e3..471a8a02 100644 --- a/apps/backend/lambdas/auth/db-types.d.ts +++ b/apps/backend/lambdas/auth/db-types.d.ts @@ -29,7 +29,9 @@ export interface BranchExpenditures { entered_by: number | null; expenditure_id: Generated; project_id: number; + receipt_url: string | null; spent_on: Generated; + status: Generated; } export interface BranchProjectDonations { @@ -52,20 +54,28 @@ export interface BranchProjectMemberships { export interface BranchProjects { created_at: Generated; currency: Generated; - end_date: Timestamp | null; description: string; + end_date: Timestamp | null; name: string; project_id: Generated; start_date: Timestamp | null; total_budget: Numeric | null; } +export interface BranchReports { + date_created: Generated; + object_url: string; + project_id: number; + report_id: Generated; +} + export interface BranchUsers { cognito_sub: string | null; created_at: Generated; email: string; is_admin: Generated; name: string; + profile_image: string | null; user_id: Generated; } @@ -75,5 +85,6 @@ export interface DB { "branch.project_donations": BranchProjectDonations; "branch.project_memberships": BranchProjectMemberships; "branch.projects": BranchProjects; + "branch.reports": BranchReports; "branch.users": BranchUsers; } diff --git a/apps/backend/lambdas/donors/db-types.d.ts b/apps/backend/lambdas/donors/db-types.d.ts index 5ca734e3..471a8a02 100644 --- a/apps/backend/lambdas/donors/db-types.d.ts +++ b/apps/backend/lambdas/donors/db-types.d.ts @@ -29,7 +29,9 @@ export interface BranchExpenditures { entered_by: number | null; expenditure_id: Generated; project_id: number; + receipt_url: string | null; spent_on: Generated; + status: Generated; } export interface BranchProjectDonations { @@ -52,20 +54,28 @@ export interface BranchProjectMemberships { export interface BranchProjects { created_at: Generated; currency: Generated; - end_date: Timestamp | null; description: string; + end_date: Timestamp | null; name: string; project_id: Generated; start_date: Timestamp | null; total_budget: Numeric | null; } +export interface BranchReports { + date_created: Generated; + object_url: string; + project_id: number; + report_id: Generated; +} + export interface BranchUsers { cognito_sub: string | null; created_at: Generated; email: string; is_admin: Generated; name: string; + profile_image: string | null; user_id: Generated; } @@ -75,5 +85,6 @@ export interface DB { "branch.project_donations": BranchProjectDonations; "branch.project_memberships": BranchProjectMemberships; "branch.projects": BranchProjects; + "branch.reports": BranchReports; "branch.users": BranchUsers; } diff --git a/apps/backend/lambdas/expenditures/db-types.d.ts b/apps/backend/lambdas/expenditures/db-types.d.ts index 18fcb702..471a8a02 100644 --- a/apps/backend/lambdas/expenditures/db-types.d.ts +++ b/apps/backend/lambdas/expenditures/db-types.d.ts @@ -54,20 +54,28 @@ export interface BranchProjectMemberships { export interface BranchProjects { created_at: Generated; currency: Generated; - end_date: Timestamp | null; description: string; + end_date: Timestamp | null; name: string; project_id: Generated; start_date: Timestamp | null; total_budget: Numeric | null; } +export interface BranchReports { + date_created: Generated; + object_url: string; + project_id: number; + report_id: Generated; +} + export interface BranchUsers { cognito_sub: string | null; created_at: Generated; email: string; is_admin: Generated; name: string; + profile_image: string | null; user_id: Generated; } @@ -77,5 +85,6 @@ export interface DB { "branch.project_donations": BranchProjectDonations; "branch.project_memberships": BranchProjectMemberships; "branch.projects": BranchProjects; + "branch.reports": BranchReports; "branch.users": BranchUsers; } diff --git a/apps/backend/lambdas/projects/db-types.d.ts b/apps/backend/lambdas/projects/db-types.d.ts index a44eaf8f..471a8a02 100644 --- a/apps/backend/lambdas/projects/db-types.d.ts +++ b/apps/backend/lambdas/projects/db-types.d.ts @@ -29,7 +29,9 @@ export interface BranchExpenditures { entered_by: number | null; expenditure_id: Generated; project_id: number; + receipt_url: string | null; spent_on: Generated; + status: Generated; } export interface BranchProjectDonations { @@ -52,19 +54,28 @@ export interface BranchProjectMemberships { export interface BranchProjects { created_at: Generated; currency: Generated; - end_date: Timestamp | null; description: string; + end_date: Timestamp | null; name: string; project_id: Generated; start_date: Timestamp | null; total_budget: Numeric | null; } +export interface BranchReports { + date_created: Generated; + object_url: string; + project_id: number; + report_id: Generated; +} + export interface BranchUsers { + cognito_sub: string | null; created_at: Generated; email: string; is_admin: Generated; name: string; + profile_image: string | null; user_id: Generated; } @@ -74,5 +85,6 @@ export interface DB { "branch.project_donations": BranchProjectDonations; "branch.project_memberships": BranchProjectMemberships; "branch.projects": BranchProjects; + "branch.reports": BranchReports; "branch.users": BranchUsers; } diff --git a/apps/backend/lambdas/reports/db-types.d.ts b/apps/backend/lambdas/reports/db-types.d.ts index f5ce7754..471a8a02 100644 --- a/apps/backend/lambdas/reports/db-types.d.ts +++ b/apps/backend/lambdas/reports/db-types.d.ts @@ -29,7 +29,9 @@ export interface BranchExpenditures { entered_by: number | null; expenditure_id: Generated; project_id: number; + receipt_url: string | null; spent_on: Generated; + status: Generated; } export interface BranchProjectDonations { @@ -52,8 +54,8 @@ export interface BranchProjectMemberships { export interface BranchProjects { created_at: Generated; currency: Generated; - end_date: Timestamp | null; description: string; + end_date: Timestamp | null; name: string; project_id: Generated; start_date: Timestamp | null; @@ -73,6 +75,7 @@ export interface BranchUsers { email: string; is_admin: Generated; name: string; + profile_image: string | null; user_id: Generated; } diff --git a/apps/backend/lambdas/tools/db-types.d.ts b/apps/backend/lambdas/tools/db-types.d.ts new file mode 100644 index 00000000..471a8a02 --- /dev/null +++ b/apps/backend/lambdas/tools/db-types.d.ts @@ -0,0 +1,90 @@ +/** + * This file was generated by kysely-codegen. + * Please do not edit it manually. + */ + +import type { ColumnType } from "kysely"; + +export type Generated = T extends ColumnType + ? ColumnType + : ColumnType; + +export type Numeric = ColumnType; + +export type Timestamp = ColumnType; + +export interface BranchDonors { + contact_email: string | null; + contact_name: string | null; + created_at: Generated; + donor_id: Generated; + organization: string; +} + +export interface BranchExpenditures { + amount: Numeric; + category: string | null; + created_at: Generated; + description: string | null; + entered_by: number | null; + expenditure_id: Generated; + project_id: number; + receipt_url: string | null; + spent_on: Generated; + status: Generated; +} + +export interface BranchProjectDonations { + amount: Numeric; + donated_at: Generated; + donation_id: Generated; + donor_id: number; + project_id: number; +} + +export interface BranchProjectMemberships { + hours: Numeric | null; + membership_id: Generated; + project_id: number; + role: string; + start_date: Timestamp | null; + user_id: number; +} + +export interface BranchProjects { + created_at: Generated; + currency: Generated; + description: string; + end_date: Timestamp | null; + name: string; + project_id: Generated; + start_date: Timestamp | null; + total_budget: Numeric | null; +} + +export interface BranchReports { + date_created: Generated; + object_url: string; + project_id: number; + report_id: Generated; +} + +export interface BranchUsers { + cognito_sub: string | null; + created_at: Generated; + email: string; + is_admin: Generated; + name: string; + profile_image: string | null; + user_id: Generated; +} + +export interface DB { + "branch.donors": BranchDonors; + "branch.expenditures": BranchExpenditures; + "branch.project_donations": BranchProjectDonations; + "branch.project_memberships": BranchProjectMemberships; + "branch.projects": BranchProjects; + "branch.reports": BranchReports; + "branch.users": BranchUsers; +} diff --git a/apps/backend/lambdas/users/db-types.d.ts b/apps/backend/lambdas/users/db-types.d.ts index f08f3c38..471a8a02 100644 --- a/apps/backend/lambdas/users/db-types.d.ts +++ b/apps/backend/lambdas/users/db-types.d.ts @@ -29,7 +29,9 @@ export interface BranchExpenditures { entered_by: number | null; expenditure_id: Generated; project_id: number; + receipt_url: string | null; spent_on: Generated; + status: Generated; } export interface BranchProjectDonations { @@ -52,22 +54,29 @@ export interface BranchProjectMemberships { export interface BranchProjects { created_at: Generated; currency: Generated; - end_date: Timestamp | null; description: string; + end_date: Timestamp | null; name: string; project_id: Generated; start_date: Timestamp | null; total_budget: Numeric | null; } +export interface BranchReports { + date_created: Generated; + object_url: string; + project_id: number; + report_id: Generated; +} + export interface BranchUsers { cognito_sub: string | null; created_at: Generated; email: string; is_admin: Generated; name: string; - user_id: Generated; profile_image: string | null; + user_id: Generated; } export interface DB { @@ -76,5 +85,6 @@ export interface DB { "branch.project_donations": BranchProjectDonations; "branch.project_memberships": BranchProjectMemberships; "branch.projects": BranchProjects; + "branch.reports": BranchReports; "branch.users": BranchUsers; }