Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions .github/workflows/regenerate-db-types.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: |
Expand Down Expand Up @@ -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: |
Expand Down
13 changes: 12 additions & 1 deletion apps/backend/lambdas/auth/db-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export interface BranchExpenditures {
entered_by: number | null;
expenditure_id: Generated<number>;
project_id: number;
receipt_url: string | null;
spent_on: Generated<Timestamp>;
status: Generated<string>;
}

export interface BranchProjectDonations {
Expand All @@ -52,20 +54,28 @@ export interface BranchProjectMemberships {
export interface BranchProjects {
created_at: Generated<Timestamp | null>;
currency: Generated<string | null>;
end_date: Timestamp | null;
description: string;
end_date: Timestamp | null;
name: string;
project_id: Generated<number>;
start_date: Timestamp | null;
total_budget: Numeric | null;
}

export interface BranchReports {
date_created: Generated<Timestamp>;
object_url: string;
project_id: number;
report_id: Generated<number>;
}

export interface BranchUsers {
cognito_sub: string | null;
created_at: Generated<Timestamp | null>;
email: string;
is_admin: Generated<boolean | null>;
name: string;
profile_image: string | null;
user_id: Generated<number>;
}

Expand All @@ -75,5 +85,6 @@ export interface DB {
"branch.project_donations": BranchProjectDonations;
"branch.project_memberships": BranchProjectMemberships;
"branch.projects": BranchProjects;
"branch.reports": BranchReports;
"branch.users": BranchUsers;
}
13 changes: 12 additions & 1 deletion apps/backend/lambdas/donors/db-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export interface BranchExpenditures {
entered_by: number | null;
expenditure_id: Generated<number>;
project_id: number;
receipt_url: string | null;
spent_on: Generated<Timestamp>;
status: Generated<string>;
}

export interface BranchProjectDonations {
Expand All @@ -52,20 +54,28 @@ export interface BranchProjectMemberships {
export interface BranchProjects {
created_at: Generated<Timestamp | null>;
currency: Generated<string | null>;
end_date: Timestamp | null;
description: string;
end_date: Timestamp | null;
name: string;
project_id: Generated<number>;
start_date: Timestamp | null;
total_budget: Numeric | null;
}

export interface BranchReports {
date_created: Generated<Timestamp>;
object_url: string;
project_id: number;
report_id: Generated<number>;
}

export interface BranchUsers {
cognito_sub: string | null;
created_at: Generated<Timestamp | null>;
email: string;
is_admin: Generated<boolean | null>;
name: string;
profile_image: string | null;
user_id: Generated<number>;
}

Expand All @@ -75,5 +85,6 @@ export interface DB {
"branch.project_donations": BranchProjectDonations;
"branch.project_memberships": BranchProjectMemberships;
"branch.projects": BranchProjects;
"branch.reports": BranchReports;
"branch.users": BranchUsers;
}
11 changes: 10 additions & 1 deletion apps/backend/lambdas/expenditures/db-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,28 @@ export interface BranchProjectMemberships {
export interface BranchProjects {
created_at: Generated<Timestamp | null>;
currency: Generated<string | null>;
end_date: Timestamp | null;
description: string;
end_date: Timestamp | null;
name: string;
project_id: Generated<number>;
start_date: Timestamp | null;
total_budget: Numeric | null;
}

export interface BranchReports {
date_created: Generated<Timestamp>;
object_url: string;
project_id: number;
report_id: Generated<number>;
}

export interface BranchUsers {
cognito_sub: string | null;
created_at: Generated<Timestamp | null>;
email: string;
is_admin: Generated<boolean | null>;
name: string;
profile_image: string | null;
user_id: Generated<number>;
}

Expand All @@ -77,5 +85,6 @@ export interface DB {
"branch.project_donations": BranchProjectDonations;
"branch.project_memberships": BranchProjectMemberships;
"branch.projects": BranchProjects;
"branch.reports": BranchReports;
"branch.users": BranchUsers;
}
14 changes: 13 additions & 1 deletion apps/backend/lambdas/projects/db-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export interface BranchExpenditures {
entered_by: number | null;
expenditure_id: Generated<number>;
project_id: number;
receipt_url: string | null;
spent_on: Generated<Timestamp>;
status: Generated<string>;
}

export interface BranchProjectDonations {
Expand All @@ -52,19 +54,28 @@ export interface BranchProjectMemberships {
export interface BranchProjects {
created_at: Generated<Timestamp | null>;
currency: Generated<string | null>;
end_date: Timestamp | null;
description: string;
end_date: Timestamp | null;
name: string;
project_id: Generated<number>;
start_date: Timestamp | null;
total_budget: Numeric | null;
}

export interface BranchReports {
date_created: Generated<Timestamp>;
object_url: string;
project_id: number;
report_id: Generated<number>;
}

export interface BranchUsers {
cognito_sub: string | null;
created_at: Generated<Timestamp | null>;
email: string;
is_admin: Generated<boolean | null>;
name: string;
profile_image: string | null;
user_id: Generated<number>;
}

Expand All @@ -74,5 +85,6 @@ export interface DB {
"branch.project_donations": BranchProjectDonations;
"branch.project_memberships": BranchProjectMemberships;
"branch.projects": BranchProjects;
"branch.reports": BranchReports;
"branch.users": BranchUsers;
}
5 changes: 4 additions & 1 deletion apps/backend/lambdas/reports/db-types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ export interface BranchExpenditures {
entered_by: number | null;
expenditure_id: Generated<number>;
project_id: number;
receipt_url: string | null;
spent_on: Generated<Timestamp>;
status: Generated<string>;
}

export interface BranchProjectDonations {
Expand All @@ -52,8 +54,8 @@ export interface BranchProjectMemberships {
export interface BranchProjects {
created_at: Generated<Timestamp | null>;
currency: Generated<string | null>;
end_date: Timestamp | null;
description: string;
end_date: Timestamp | null;
name: string;
project_id: Generated<number>;
start_date: Timestamp | null;
Expand All @@ -73,6 +75,7 @@ export interface BranchUsers {
email: string;
is_admin: Generated<boolean | null>;
name: string;
profile_image: string | null;
user_id: Generated<number>;
}

Expand Down
90 changes: 90 additions & 0 deletions apps/backend/lambdas/tools/db-types.d.ts
Original file line number Diff line number Diff line change
@@ -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> = T extends ColumnType<infer S, infer I, infer U>
? ColumnType<S, I | undefined, U>
: ColumnType<T, T | undefined, T>;

export type Numeric = ColumnType<string, number | string, number | string>;

export type Timestamp = ColumnType<Date, Date | string, Date | string>;

export interface BranchDonors {
contact_email: string | null;
contact_name: string | null;
created_at: Generated<Timestamp | null>;
donor_id: Generated<number>;
organization: string;
}

export interface BranchExpenditures {
amount: Numeric;
category: string | null;
created_at: Generated<Timestamp | null>;
description: string | null;
entered_by: number | null;
expenditure_id: Generated<number>;
project_id: number;
receipt_url: string | null;
spent_on: Generated<Timestamp>;
status: Generated<string>;
}

export interface BranchProjectDonations {
amount: Numeric;
donated_at: Generated<Timestamp | null>;
donation_id: Generated<number>;
donor_id: number;
project_id: number;
}

export interface BranchProjectMemberships {
hours: Numeric | null;
membership_id: Generated<number>;
project_id: number;
role: string;
start_date: Timestamp | null;
user_id: number;
}

export interface BranchProjects {
created_at: Generated<Timestamp | null>;
currency: Generated<string | null>;
description: string;
end_date: Timestamp | null;
name: string;
project_id: Generated<number>;
start_date: Timestamp | null;
total_budget: Numeric | null;
}

export interface BranchReports {
date_created: Generated<Timestamp>;
object_url: string;
project_id: number;
report_id: Generated<number>;
}

export interface BranchUsers {
cognito_sub: string | null;
created_at: Generated<Timestamp | null>;
email: string;
is_admin: Generated<boolean | null>;
name: string;
profile_image: string | null;
user_id: Generated<number>;
}

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;
}
Loading
Loading