From 5da04f68fe828a801185a724a87e798725f7199e Mon Sep 17 00:00:00 2001 From: f1ames Date: Fri, 9 Feb 2024 09:54:51 +0100 Subject: [PATCH 1/4] fix: require suppression location to be passed --- packages/synchronizer/src/handlers/apiHandler.ts | 10 +++++----- packages/synchronizer/src/utils/projectSynchronizer.ts | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/synchronizer/src/handlers/apiHandler.ts b/packages/synchronizer/src/handlers/apiHandler.ts index 8f400d89..a428cacd 100644 --- a/packages/synchronizer/src/handlers/apiHandler.ts +++ b/packages/synchronizer/src/handlers/apiHandler.ts @@ -166,9 +166,9 @@ const getRepoIdQuery = ` `; const toggleSuppressionMutation = ` - mutation toggleSuppression($fingerprint: String!, $repoId: ID!, $description: String!) { + mutation toggleSuppression($fingerprint: String!, $repoId: ID!, $description: String!, $location: String) { toggleSuppression( - input: {fingerprint: $fingerprint, repository: $repoId, description: $description, skipReview: true} + input: {fingerprint: $fingerprint, repository: $repoId, description: $description, $location: location, skipReview: true} ) { id fingerprint @@ -243,7 +243,7 @@ export type ApiSuppression = { id: string; fingerprint: string; description: string; - locations: string; + location: string; status: SuppressionStatus; justification: string; expiresAt: string; @@ -402,8 +402,8 @@ export class ApiHandler { return this.queryApi(getRepoIdQuery, tokenInfo, {projectSlug, repoOwner, repoName}); } - async toggleSuppression(fingerprint: string, repoId: string, description: string, tokenInfo: TokenInfo) { - return this.queryApi(toggleSuppressionMutation, tokenInfo, {fingerprint, repoId, description}); + async toggleSuppression(fingerprint: string, repoId: string, description: string, location: string | undefined, tokenInfo: TokenInfo) { + return this.queryApi(toggleSuppressionMutation, tokenInfo, {fingerprint, repoId, description, location}); } generateDeepLink(path: string) { diff --git a/packages/synchronizer/src/utils/projectSynchronizer.ts b/packages/synchronizer/src/utils/projectSynchronizer.ts index 165e73d3..9bd71cfb 100644 --- a/packages/synchronizer/src/utils/projectSynchronizer.ts +++ b/packages/synchronizer/src/utils/projectSynchronizer.ts @@ -78,7 +78,7 @@ export class ProjectSynchronizer extends EventEmitter { return this._dataCache[this.getCacheId(rootPath, projectSlug)]?.suppressions ?? []; } - async toggleSuppression(tokenInfo: TokenInfo, fingerprint: string, description: string, rootPath: string, projectSlug?: string) { + async toggleSuppression(tokenInfo: TokenInfo, fingerprint: string, description: string, location: string, rootPath: string, projectSlug?: string) { if (!tokenInfo?.accessToken?.length) { throw new Error('Cannot use suppressions without access token.'); } @@ -105,7 +105,7 @@ export class ProjectSynchronizer extends EventEmitter { throw new Error('Cannot suppress due to missing repository id or project slug!'); } - const suppressionResult = await this._apiHandler.toggleSuppression(fingerprint, id, description, tokenInfo); + const suppressionResult = await this._apiHandler.toggleSuppression(fingerprint, id, description, location, tokenInfo); if (suppressionResult?.data?.getSuppressions?.data?.length) { const existingSuppressions = await this.readSuppressions(repoData); const allSuppressions = this.mergeSuppressions(existingSuppressions, suppressionResult.data.getSuppressions.data); From 94d4b024ece94a6595e89a7a2caaf321767b30f7 Mon Sep 17 00:00:00 2001 From: f1ames Date: Fri, 9 Feb 2024 09:55:49 +0100 Subject: [PATCH 2/4] Xchore: add changeset --- .changeset/blue-donkeys-sparkle.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/blue-donkeys-sparkle.md diff --git a/.changeset/blue-donkeys-sparkle.md b/.changeset/blue-donkeys-sparkle.md new file mode 100644 index 00000000..921cf6d7 --- /dev/null +++ b/.changeset/blue-donkeys-sparkle.md @@ -0,0 +1,5 @@ +--- +"@monokle/synchronizer": patch +--- + +Suppression location can now be passed 'toggleSuppression' API From 06f7fd311b2888f1d0a14d872423393c0dc65a1f Mon Sep 17 00:00:00 2001 From: f1ames Date: Fri, 9 Feb 2024 09:58:14 +0100 Subject: [PATCH 3/4] fix: make passing location always optional --- packages/synchronizer/src/utils/projectSynchronizer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/synchronizer/src/utils/projectSynchronizer.ts b/packages/synchronizer/src/utils/projectSynchronizer.ts index 9bd71cfb..7cb1a930 100644 --- a/packages/synchronizer/src/utils/projectSynchronizer.ts +++ b/packages/synchronizer/src/utils/projectSynchronizer.ts @@ -78,7 +78,7 @@ export class ProjectSynchronizer extends EventEmitter { return this._dataCache[this.getCacheId(rootPath, projectSlug)]?.suppressions ?? []; } - async toggleSuppression(tokenInfo: TokenInfo, fingerprint: string, description: string, location: string, rootPath: string, projectSlug?: string) { + async toggleSuppression(tokenInfo: TokenInfo, fingerprint: string, description: string, location: string | undefined, rootPath: string, projectSlug?: string) { if (!tokenInfo?.accessToken?.length) { throw new Error('Cannot use suppressions without access token.'); } From 90cbcd17a5233713eac1a8d3a4f874140ac5a276 Mon Sep 17 00:00:00 2001 From: f1ames Date: Fri, 9 Feb 2024 10:52:31 +0100 Subject: [PATCH 4/4] fix: fix typo --- packages/synchronizer/src/handlers/apiHandler.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/synchronizer/src/handlers/apiHandler.ts b/packages/synchronizer/src/handlers/apiHandler.ts index a428cacd..7e2dba7a 100644 --- a/packages/synchronizer/src/handlers/apiHandler.ts +++ b/packages/synchronizer/src/handlers/apiHandler.ts @@ -168,7 +168,7 @@ const getRepoIdQuery = ` const toggleSuppressionMutation = ` mutation toggleSuppression($fingerprint: String!, $repoId: ID!, $description: String!, $location: String) { toggleSuppression( - input: {fingerprint: $fingerprint, repository: $repoId, description: $description, $location: location, skipReview: true} + input: {fingerprint: $fingerprint, repository: $repoId, description: $description, location: $location, skipReview: true} ) { id fingerprint