From 6a23c938daccd499961d68a907410e5544da1493 Mon Sep 17 00:00:00 2001 From: Enzo Mercanti Date: Fri, 20 Sep 2024 16:56:31 -0300 Subject: [PATCH 1/3] fix: remove unnecessary b2b_users storage on vbase --- CHANGELOG.md | 3 +++ node/resolvers/Mutations/Users.ts | 29 ++++++----------------------- 2 files changed, 9 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6d09776..8c2c9ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fixed +- Remove unnecessary b2b_users storage on vbase + ## [1.44.6] - 2024-09-05 ### Fixed diff --git a/node/resolvers/Mutations/Users.ts b/node/resolvers/Mutations/Users.ts index 3115834..60921c6 100644 --- a/node/resolvers/Mutations/Users.ts +++ b/node/resolvers/Mutations/Users.ts @@ -116,7 +116,7 @@ const updateUserFields = async ({ masterdata, fields, id }: any) => { return DocumentId } -const createPermission = async ({ masterdata, vbase, params }: any) => { +const createPermission = async ({ masterdata, params }: any) => { const { roleId, canImpersonate, @@ -129,7 +129,7 @@ const createPermission = async ({ masterdata, vbase, params }: any) => { id, } = params - const { DocumentId } = await masterdata + await masterdata .createOrUpdateEntireDocument({ dataEntity: config.name, fields: { @@ -157,25 +157,11 @@ const createPermission = async ({ masterdata, vbase, params }: any) => { throw error }) - - if (DocumentId) { - await vbase.saveJSON('b2b_users', email, { - canImpersonate, - clId, - costId, - email, - id: DocumentId, - name, - orgId, - roleId, - userId, - }) - } } export const addUser = async (_: any, params: any, ctx: Context) => { const { - clients: { masterdata, lm, vbase }, + clients: { masterdata, lm }, vtex: { logger }, } = ctx @@ -220,8 +206,7 @@ export const addUser = async (_: any, params: any, ctx: Context) => { params: { ...params, clId: cId, - }, - vbase, + } }) return { status: 'success', message: '', id: cId } @@ -323,15 +308,13 @@ export const deleteUserProfile = async (_: any, params: any, ctx: Context) => { export const deleteUser = async (_: any, params: any, ctx: Context) => { const { - clients: { masterdata, vbase }, + clients: { masterdata }, vtex: { logger }, } = ctx - const { id, email } = params + const { id } = params try { - await vbase.deleteFile('b2b_users', email).catch(() => null) - await masterdata.deleteDocument({ dataEntity: config.name, id, From bca432cbe11ae5fb8e287adc6f61e05540a15c5e Mon Sep 17 00:00:00 2001 From: Enzo Mercanti Date: Fri, 20 Sep 2024 16:59:58 -0300 Subject: [PATCH 2/3] fix: remove vbase parameter from updateUser --- node/resolvers/Mutations/Users.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/node/resolvers/Mutations/Users.ts b/node/resolvers/Mutations/Users.ts index 60921c6..8a90d00 100644 --- a/node/resolvers/Mutations/Users.ts +++ b/node/resolvers/Mutations/Users.ts @@ -222,7 +222,7 @@ export const addUser = async (_: any, params: any, ctx: Context) => { export const updateUser = async (_: any, params: any, ctx: Context) => { const { - clients: { masterdata, lm, vbase }, + clients: { masterdata, lm }, vtex: { logger }, } = ctx @@ -235,8 +235,7 @@ export const updateUser = async (_: any, params: any, ctx: Context) => { await createPermission({ lm, masterdata, - params, - vbase, + params }) return { status: 'success', message: '', id: params.clId } From b06b47f0201f8c4d79886fe30e77b61774a0457c Mon Sep 17 00:00:00 2001 From: Enzo Mercanti Date: Mon, 23 Sep 2024 08:50:43 -0300 Subject: [PATCH 3/3] fix: lint --- 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 8a90d00..2323237 100644 --- a/node/resolvers/Mutations/Users.ts +++ b/node/resolvers/Mutations/Users.ts @@ -206,7 +206,7 @@ export const addUser = async (_: any, params: any, ctx: Context) => { params: { ...params, clId: cId, - } + }, }) return { status: 'success', message: '', id: cId } @@ -235,7 +235,7 @@ export const updateUser = async (_: any, params: any, ctx: Context) => { await createPermission({ lm, masterdata, - params + params, }) return { status: 'success', message: '', id: params.clId }