From a6864cd4c46e2fc9d9ca0928727eb872d3657d2e Mon Sep 17 00:00:00 2001 From: Armando Belardo <11140328+armandobelardo@users.noreply.github.com> Date: Thu, 19 Sep 2024 17:16:13 -0400 Subject: [PATCH] fix(fdr): attempt to fix git paths by adding `res.send` and removing any potential path conflicts (#1511) --- fern/apis/fdr/definition/git.yml | 12 ++++++------ .../generated/api/resources/git/client/Client.ts | 12 ++++++------ .../api/resources/git/service/GitService.js | 12 ++++++------ .../generators/getGeneratorsVersionsController.ts | 1 + servers/fdr/src/controllers/git/getGitController.ts | 12 ++++++++---- 5 files changed, 27 insertions(+), 22 deletions(-) diff --git a/fern/apis/fdr/definition/git.yml b/fern/apis/fdr/definition/git.yml index ed104c590f..0ca2720053 100644 --- a/fern/apis/fdr/definition/git.yml +++ b/fern/apis/fdr/definition/git.yml @@ -142,7 +142,7 @@ service: listRepositories: docs: Get all repositories. method: GET - path: "/repository" + path: "/repository/list" pagination: offset: $request.page results: $response.repositories @@ -171,13 +171,13 @@ service: upsertRepository: docs: Update or create the specified repository. method: PUT - path: /repository + path: /repository/upsert request: FernRepository deleteRepository: docs: Delete specified repository. method: DELETE - path: /repository/{repositoryOwner}/{repositoryName} + path: /repository/{repositoryOwner}/{repositoryName}/delete path-parameters: repositoryOwner: string repositoryName: string @@ -195,7 +195,7 @@ service: listPullRequests: docs: Get all pull requests. method: GET - path: "/pull-request" + path: "/pull-request/list" pagination: offset: $request.page results: $response.pullRequests @@ -224,13 +224,13 @@ service: upsertPullRequest: docs: Update or create the specified pull request. method: PUT - path: /pull-request + path: /pull-request/upsert request: PullRequest deletePullRequest: docs: Delete specified pull request. method: DELETE - path: /pull-request/{repositoryOwner}/{repositoryName}/{pullRequestNumber} + path: /pull-request/{repositoryOwner}/{repositoryName}/{pullRequestNumber}/delete path-parameters: repositoryOwner: string repositoryName: string diff --git a/packages/fdr-sdk/src/client/generated/api/resources/git/client/Client.ts b/packages/fdr-sdk/src/client/generated/api/resources/git/client/Client.ts index b142f87907..034c81073b 100644 --- a/packages/fdr-sdk/src/client/generated/api/resources/git/client/Client.ts +++ b/packages/fdr-sdk/src/client/generated/api/resources/git/client/Client.ts @@ -117,7 +117,7 @@ export class Git { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.FernRegistryEnvironment.Prod, - "/generators/github/repository" + "/generators/github/repository/list" ), method: "GET", headers: { @@ -188,7 +188,7 @@ export class Git { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.FernRegistryEnvironment.Prod, - "/generators/github/repository" + "/generators/github/repository/upsert" ), method: "PUT", headers: { @@ -236,7 +236,7 @@ export class Git { (await core.Supplier.get(this._options.environment)) ?? environments.FernRegistryEnvironment.Prod, `/generators/github/repository/${encodeURIComponent(repositoryOwner)}/${encodeURIComponent( repositoryName - )}` + )}/delete` ), method: "DELETE", headers: { @@ -356,7 +356,7 @@ export class Git { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.FernRegistryEnvironment.Prod, - "/generators/github/pull-request" + "/generators/github/pull-request/list" ), method: "GET", headers: { @@ -437,7 +437,7 @@ export class Git { const _response = await core.fetcher({ url: urlJoin( (await core.Supplier.get(this._options.environment)) ?? environments.FernRegistryEnvironment.Prod, - "/generators/github/pull-request" + "/generators/github/pull-request/upsert" ), method: "PUT", headers: { @@ -487,7 +487,7 @@ export class Git { (await core.Supplier.get(this._options.environment)) ?? environments.FernRegistryEnvironment.Prod, `/generators/github/pull-request/${encodeURIComponent(repositoryOwner)}/${encodeURIComponent( repositoryName - )}/${encodeURIComponent(pullRequestNumber)}` + )}/${encodeURIComponent(pullRequestNumber)}/delete` ), method: "DELETE", headers: { diff --git a/servers/fdr/src/api/generated/api/resources/git/service/GitService.js b/servers/fdr/src/api/generated/api/resources/git/service/GitService.js index c34eb0cbfd..ec03fe2555 100644 --- a/servers/fdr/src/api/generated/api/resources/git/service/GitService.js +++ b/servers/fdr/src/api/generated/api/resources/git/service/GitService.js @@ -51,7 +51,7 @@ export class GitService { next(error); } })); - this.router.get("/repository", (req, res, next) => __awaiter(this, void 0, void 0, function* () { + this.router.get("/repository/list", (req, res, next) => __awaiter(this, void 0, void 0, function* () { try { yield this.methods.listRepositories(req, { send: (responseBody) => __awaiter(this, void 0, void 0, function* () { @@ -75,7 +75,7 @@ export class GitService { next(error); } })); - this.router.put("/repository", (req, res, next) => __awaiter(this, void 0, void 0, function* () { + this.router.put("/repository/upsert", (req, res, next) => __awaiter(this, void 0, void 0, function* () { try { yield this.methods.upsertRepository(req, { send: () => __awaiter(this, void 0, void 0, function* () { @@ -99,7 +99,7 @@ export class GitService { next(error); } })); - this.router.delete("/repository/:repositoryOwner/:repositoryName", (req, res, next) => __awaiter(this, void 0, void 0, function* () { + this.router.delete("/repository/:repositoryOwner/:repositoryName/delete", (req, res, next) => __awaiter(this, void 0, void 0, function* () { try { yield this.methods.deleteRepository(req, { send: () => __awaiter(this, void 0, void 0, function* () { @@ -147,7 +147,7 @@ export class GitService { next(error); } })); - this.router.get("/pull-request", (req, res, next) => __awaiter(this, void 0, void 0, function* () { + this.router.get("/pull-request/list", (req, res, next) => __awaiter(this, void 0, void 0, function* () { try { yield this.methods.listPullRequests(req, { send: (responseBody) => __awaiter(this, void 0, void 0, function* () { @@ -171,7 +171,7 @@ export class GitService { next(error); } })); - this.router.put("/pull-request", (req, res, next) => __awaiter(this, void 0, void 0, function* () { + this.router.put("/pull-request/upsert", (req, res, next) => __awaiter(this, void 0, void 0, function* () { try { yield this.methods.upsertPullRequest(req, { send: () => __awaiter(this, void 0, void 0, function* () { @@ -195,7 +195,7 @@ export class GitService { next(error); } })); - this.router.delete("/pull-request/:repositoryOwner/:repositoryName/:pullRequestNumber", (req, res, next) => __awaiter(this, void 0, void 0, function* () { + this.router.delete("/pull-request/:repositoryOwner/:repositoryName/:pullRequestNumber/delete", (req, res, next) => __awaiter(this, void 0, void 0, function* () { try { yield this.methods.deletePullRequest(req, { send: () => __awaiter(this, void 0, void 0, function* () { diff --git a/servers/fdr/src/controllers/generators/getGeneratorsVersionsController.ts b/servers/fdr/src/controllers/generators/getGeneratorsVersionsController.ts index 669485ce44..0418217ca6 100644 --- a/servers/fdr/src/controllers/generators/getGeneratorsVersionsController.ts +++ b/servers/fdr/src/controllers/generators/getGeneratorsVersionsController.ts @@ -32,6 +32,7 @@ export function getGeneratorsVersionsController(app: FdrApplication): VersionsSe }); await app.dao.generatorVersions().upsertGeneratorRelease({ generatorRelease: req.body }); + return res.send(); }, getGeneratorRelease: async (req, res) => { const maybeRelease = await app.dao diff --git a/servers/fdr/src/controllers/git/getGitController.ts b/servers/fdr/src/controllers/git/getGitController.ts index 645bea073b..fd7626bb27 100644 --- a/servers/fdr/src/controllers/git/getGitController.ts +++ b/servers/fdr/src/controllers/git/getGitController.ts @@ -23,7 +23,7 @@ export function getGitController(app: FdrApplication): GitService { throw new RepositoryNotFoundError(nameAndOwner); } - res.send(maybeRepo); + return res.send(maybeRepo); }, listRepositories: async (req, res) => { await checkIsFernUser(req.headers.authorization); @@ -36,12 +36,13 @@ export function getGitController(app: FdrApplication): GitService { organizationId: req.query.organizationId, }); - res.send(repos); + return res.send(repos); }, upsertRepository: async (req, res) => { await checkIsFernUser(req.headers.authorization); await app.dao.git().upsertRepository({ repository: req.body }); + return res.send(); }, deleteRepository: async (req, res) => { await checkIsFernUser(req.headers.authorization); @@ -50,6 +51,7 @@ export function getGitController(app: FdrApplication): GitService { repositoryName: req.params.repositoryName, repositoryOwner: req.params.repositoryOwner, }); + return res.send(); }, getPullRequest: async (req, res) => { await checkIsFernUser(req.headers.authorization); @@ -64,7 +66,7 @@ export function getGitController(app: FdrApplication): GitService { throw new PullRequestNotFoundError(nameAndOwner); } - res.send(maybePull); + return res.send(maybePull); }, listPullRequests: async (req, res) => { await checkIsFernUser(req.headers.authorization); @@ -77,12 +79,13 @@ export function getGitController(app: FdrApplication): GitService { organizationId: req.query.organizationId, }); - res.send(repos); + return res.send(repos); }, upsertPullRequest: async (req, res) => { await checkIsFernUser(req.headers.authorization); await app.dao.git().upsertPullRequest({ pullRequest: req.body }); + return res.send(); }, deletePullRequest: async (req, res) => { await checkIsFernUser(req.headers.authorization); @@ -92,6 +95,7 @@ export function getGitController(app: FdrApplication): GitService { repositoryOwner: req.params.repositoryOwner, pullRequestNumber: req.params.pullRequestNumber, }); + return res.send(); }, }); }