Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove unnecessary b2b_users storage on vbase #161

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
30 changes: 6 additions & 24 deletions node/resolvers/Mutations/Users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -129,7 +129,7 @@ const createPermission = async ({ masterdata, vbase, params }: any) => {
id,
} = params

const { DocumentId } = await masterdata
await masterdata
.createOrUpdateEntireDocument({
dataEntity: config.name,
fields: {
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -221,7 +207,6 @@ export const addUser = async (_: any, params: any, ctx: Context) => {
...params,
clId: cId,
},
vbase,
})

return { status: 'success', message: '', id: cId }
Expand All @@ -237,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

Expand All @@ -251,7 +236,6 @@ export const updateUser = async (_: any, params: any, ctx: Context) => {
lm,
masterdata,
params,
vbase,
})

return { status: 'success', message: '', id: params.clId }
Expand Down Expand Up @@ -323,15 +307,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,
Expand Down
Loading