From 8f1da130a992c8960f6b0f2faf05bb3d12a87fec Mon Sep 17 00:00:00 2001 From: Rafael Marques Date: Fri, 15 Sep 2023 11:52:24 -0300 Subject: [PATCH 1/5] Add event trigger to deleteUser resolver --- CHANGELOG.md | 6 ++++++ manifest.json | 3 +++ node/package.json | 5 +++-- node/resolvers/Mutations/Users.ts | 5 +++-- node/yarn.lock | 10 +++++++--- 5 files changed, 22 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17345b66..ca73c59f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +## [0.36.1] - 2023-09-15 + +### Added + +- Added event trigger on delete a user + ## [0.36.0] - 2023-08-11 ### Added diff --git a/manifest.json b/manifest.json index fb7cb28a..599c3062 100644 --- a/manifest.json +++ b/manifest.json @@ -17,6 +17,9 @@ "vtex.storefront-permissions": "1.x" }, "policies": [ + { + "name": "colossus-fire-event" + }, { "name": "update-app-settings" }, diff --git a/node/package.json b/node/package.json index 51f3615c..a841c925 100644 --- a/node/package.json +++ b/node/package.json @@ -29,10 +29,11 @@ "tslint-config-prettier": "^1.18.0", "tslint-config-vtex": "^2.1.0", "typescript": "3.9.7", - "vtex.storefront-permissions": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.storefront-permissions@1.35.3/public/@types/vtex.storefront-permissions" + "vtex.b2b-organizations-graphql": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.b2b-organizations-graphql@0.36.0/public/@types/vtex.b2b-organizations-graphql", + "vtex.storefront-permissions": "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.storefront-permissions@1.36.0/public/@types/vtex.storefront-permissions" }, "scripts": { "lint": "tsc --noEmit && tslint -c tslint.json './**/*.ts'", "test": "jest" } -} +} \ No newline at end of file diff --git a/node/resolvers/Mutations/Users.ts b/node/resolvers/Mutations/Users.ts index 4333e12c..bceaab2f 100644 --- a/node/resolvers/Mutations/Users.ts +++ b/node/resolvers/Mutations/Users.ts @@ -379,7 +379,7 @@ const Users = { ctx: Context ) => { const { - clients: { storefrontPermissions: storefrontPermissionsClient }, + clients: { events, storefrontPermissions: storefrontPermissionsClient }, vtex: { adminUserAuthToken, logger, sessionData, storefrontPermissions }, } = ctx as Context | any @@ -412,7 +412,8 @@ const Users = { id, userId, }) - .then((result: any) => { + .then(async (result: any) => { + await new Promise(events.sendEvent('', 'b2b-organizations-graphql.removeUser', { id, email })) return result.data.deleteUser }) .catch((error: any) => { diff --git a/node/yarn.lock b/node/yarn.lock index 3b952b42..662cde3d 100644 --- a/node/yarn.lock +++ b/node/yarn.lock @@ -3909,9 +3909,13 @@ vary@^1.1.2: resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== -"vtex.storefront-permissions@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.storefront-permissions@1.35.3/public/@types/vtex.storefront-permissions": - version "1.35.3" - resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.storefront-permissions@1.35.3/public/@types/vtex.storefront-permissions#58d27d180d75da71e43c6d6059f7191002c5f06b" +"vtex.b2b-organizations-graphql@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.b2b-organizations-graphql@0.36.0/public/@types/vtex.b2b-organizations-graphql": + version "0.36.0" + resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.b2b-organizations-graphql@0.36.0/public/@types/vtex.b2b-organizations-graphql#14adc111841e871d38f888cb1c90ae4dacf1914e" + +"vtex.storefront-permissions@http://vtex.vtexassets.com/_v/public/typings/v1/vtex.storefront-permissions@1.36.0/public/@types/vtex.storefront-permissions": + version "1.36.0" + resolved "http://vtex.vtexassets.com/_v/public/typings/v1/vtex.storefront-permissions@1.36.0/public/@types/vtex.storefront-permissions#9b6eca8b176bd2b4a349932a598b6b8691bd6fe9" w3c-hr-time@^1.0.2: version "1.0.2" From a61055899ca34572e0c9eac30889dc7ee31f09a4 Mon Sep 17 00:00:00 2001 From: Rafael Marques Date: Fri, 15 Sep 2023 12:25:53 -0300 Subject: [PATCH 2/5] Remove date/version manually added to changelog --- CHANGELOG.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca73c59f..4d935afc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] -## [0.36.1] - 2023-09-15 - ### Added - Added event trigger on delete a user From bb10e0fe11cf937c0d963854b4da1b11d4791874 Mon Sep 17 00:00:00 2001 From: Rafael Marques Date: Mon, 18 Sep 2023 17:14:00 -0300 Subject: [PATCH 3/5] Change the method to trigger the delete user event to use the native solution --- node/resolvers/Mutations/Users.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/node/resolvers/Mutations/Users.ts b/node/resolvers/Mutations/Users.ts index bceaab2f..aedaea15 100644 --- a/node/resolvers/Mutations/Users.ts +++ b/node/resolvers/Mutations/Users.ts @@ -413,7 +413,7 @@ const Users = { userId, }) .then(async (result: any) => { - await new Promise(events.sendEvent('', 'b2b-organizations-graphql.removeUser', { id, email })) + await events.sendEvent('', 'b2b-organizations-graphql.removeUser', { id, email }) return result.data.deleteUser }) .catch((error: any) => { From 4d95fecacf2c2c5551fd5e5e96b476093978267b Mon Sep 17 00:00:00 2001 From: Rafael Marques Date: Tue, 19 Sep 2023 10:17:50 -0300 Subject: [PATCH 4/5] Fix @vtex/prettier-config indent error --- node/resolvers/Mutations/Users.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/node/resolvers/Mutations/Users.ts b/node/resolvers/Mutations/Users.ts index aedaea15..f0952204 100644 --- a/node/resolvers/Mutations/Users.ts +++ b/node/resolvers/Mutations/Users.ts @@ -413,7 +413,11 @@ const Users = { userId, }) .then(async (result: any) => { - await events.sendEvent('', 'b2b-organizations-graphql.removeUser', { id, email }) + await events.sendEvent('', 'b2b-organizations-graphql.removeUser', { + id, + email, + }) + return result.data.deleteUser }) .catch((error: any) => { From f95cdca55c620b2170917d36d62c938c85bf8a21 Mon Sep 17 00:00:00 2001 From: Rafael Marques Date: Tue, 19 Sep 2023 14:04:30 -0300 Subject: [PATCH 5/5] Remove async/await from deleteUser event trigger --- node/resolvers/Mutations/Users.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/node/resolvers/Mutations/Users.ts b/node/resolvers/Mutations/Users.ts index f0952204..c8963777 100644 --- a/node/resolvers/Mutations/Users.ts +++ b/node/resolvers/Mutations/Users.ts @@ -412,8 +412,8 @@ const Users = { id, userId, }) - .then(async (result: any) => { - await events.sendEvent('', 'b2b-organizations-graphql.removeUser', { + .then((result: any) => { + events.sendEvent('', 'b2b-organizations-graphql.removeUser', { id, email, })