From bc1504f8676aba6e8473b44d59a5175afdc005f4 Mon Sep 17 00:00:00 2001 From: armandobelardo Date: Tue, 17 Sep 2024 17:53:29 -0400 Subject: [PATCH] chore(fdr): update git datamodel to reflect github api --- fern/apis/fdr/definition/git.yml | 6 +++--- .../client/generated/api/resources/git/types/GithubUser.ts | 4 ++-- .../client/generated/api/resources/git/types/PullRequest.ts | 2 +- .../20240917214830_make_pr_author_optional/migration.sql | 2 ++ servers/fdr/prisma/schema.prisma | 2 +- .../api/generated/api/resources/git/types/GithubUser.d.ts | 4 ++-- .../api/generated/api/resources/git/types/PullRequest.d.ts | 2 +- servers/fdr/src/db/git/GitDao.ts | 2 +- 8 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 servers/fdr/prisma/migrations/20240917214830_make_pr_author_optional/migration.sql diff --git a/fern/apis/fdr/definition/git.yml b/fern/apis/fdr/definition/git.yml index a5497dbaf9..ed104c590f 100644 --- a/fern/apis/fdr/definition/git.yml +++ b/fern/apis/fdr/definition/git.yml @@ -69,8 +69,8 @@ types: GithubUser: properties: - name: string - email: string + name: optional + email: optional username: string GithubTeam: @@ -95,7 +95,7 @@ types: pullRequestNumber: integer repositoryName: string repositoryOwner: string - author: GithubUser + author: optional reviewers: list title: string url: string diff --git a/packages/fdr-sdk/src/client/generated/api/resources/git/types/GithubUser.ts b/packages/fdr-sdk/src/client/generated/api/resources/git/types/GithubUser.ts index cce7e338cf..58f18ae130 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/git/types/GithubUser.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/git/types/GithubUser.ts @@ -3,7 +3,7 @@ */ export interface GithubUser { - name: string; - email: string; + name?: string; + email?: string; username: string; } diff --git a/packages/fdr-sdk/src/client/generated/api/resources/git/types/PullRequest.ts b/packages/fdr-sdk/src/client/generated/api/resources/git/types/PullRequest.ts index 61aceed9e1..431462843b 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/git/types/PullRequest.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/git/types/PullRequest.ts @@ -8,7 +8,7 @@ export interface PullRequest { pullRequestNumber: number; repositoryName: string; repositoryOwner: string; - author: FernRegistry.GithubUser; + author?: FernRegistry.GithubUser; reviewers: FernRegistry.PullRequestReviewer[]; title: string; url: string; diff --git a/servers/fdr/prisma/migrations/20240917214830_make_pr_author_optional/migration.sql b/servers/fdr/prisma/migrations/20240917214830_make_pr_author_optional/migration.sql new file mode 100644 index 0000000000..b4b30163e9 --- /dev/null +++ b/servers/fdr/prisma/migrations/20240917214830_make_pr_author_optional/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "PullRequest" ALTER COLUMN "author" DROP NOT NULL; diff --git a/servers/fdr/prisma/schema.prisma b/servers/fdr/prisma/schema.prisma index 1eb71f77f9..0fcf30766e 100644 --- a/servers/fdr/prisma/schema.prisma +++ b/servers/fdr/prisma/schema.prisma @@ -244,7 +244,7 @@ model PullRequest { repositoryName String repository Repository @relation(fields: [repositoryOwner, repositoryName], references: [owner, name], onDelete: Cascade) - author Bytes + author Bytes? reviewers Bytes checks Bytes diff --git a/servers/fdr/src/api/generated/api/resources/git/types/GithubUser.d.ts b/servers/fdr/src/api/generated/api/resources/git/types/GithubUser.d.ts index 847133d3f0..267b26eb49 100644 --- a/servers/fdr/src/api/generated/api/resources/git/types/GithubUser.d.ts +++ b/servers/fdr/src/api/generated/api/resources/git/types/GithubUser.d.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ export interface GithubUser { - name: string; - email: string; + name?: string; + email?: string; username: string; } diff --git a/servers/fdr/src/api/generated/api/resources/git/types/PullRequest.d.ts b/servers/fdr/src/api/generated/api/resources/git/types/PullRequest.d.ts index 09d895e3d3..2a8adcab98 100644 --- a/servers/fdr/src/api/generated/api/resources/git/types/PullRequest.d.ts +++ b/servers/fdr/src/api/generated/api/resources/git/types/PullRequest.d.ts @@ -6,7 +6,7 @@ export interface PullRequest { pullRequestNumber: number; repositoryName: string; repositoryOwner: string; - author: FernRegistry.GithubUser; + author?: FernRegistry.GithubUser; reviewers: FernRegistry.PullRequestReviewer[]; title: string; url: string; diff --git a/servers/fdr/src/db/git/GitDao.ts b/servers/fdr/src/db/git/GitDao.ts index 37a7612651..c0294581d4 100644 --- a/servers/fdr/src/db/git/GitDao.ts +++ b/servers/fdr/src/db/git/GitDao.ts @@ -321,7 +321,7 @@ function convertPrismaPullRequest(maybePR: prisma.PullRequest | null): PullReque pullRequestNumber: maybePR.pullRequestNumber, repositoryName: maybePR.repositoryName, repositoryOwner: maybePR.repositoryOwner, - author: readBuffer(maybePR.author) as GithubUser, + author: maybePR.author != null ? (readBuffer(maybePR.author) as GithubUser) : undefined, reviewers: readBuffer(maybePR.reviewers) as PullRequestReviewer[], checks: readBuffer(maybePR.checks) as CheckRun[], title: maybePR.title,