Skip to content
Open
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: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ node/node_modules
react/package-lock.json
node/package-lock.json
node/node_modules
.vscode/
.vscode/
.cursor
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Scoped Master Data schema sync hash storage per app major version (`settings-v{N}` VBase key) to prevent infinite sync loops when multiple app majors coexist in the same account
- Bumped quotes Master Data schema version to align with app major 4 (`SCHEMA_VERSION` → `v4.3`)

## [4.0.6] - 2026-03-10

### Fixed
Expand Down
14 changes: 12 additions & 2 deletions node/constants.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const APP_NAME = 'b2b-quotes-graphql'
export const SCHEMA_VERSION = 'v1.3'
export const SCHEMA_VERSION = 'v4.3'
export const QUOTE_DATA_ENTITY = 'quotes'
export const B2B_USER_SCHEMA_VERSION = 'v0.1.2'
export const B2B_USER_SCHEMA_VERSION = 'v3.1.2'
export const B2B_USER_DATA_ENTITY = 'b2b_users'
export const CRON_EXPRESSION = '0 */12 * * *'

Expand Down Expand Up @@ -75,6 +75,16 @@ export const getAppId = (): string => {
return process.env.VTEX_APP_ID ?? ''
}

export const getAppMajorVersion = (): string => {
const appId = getAppId()
const version = appId.split('@')[1] ?? ''

return version.split('.')[0] || '0'
}

export const getSettingsVBaseKey = (): string =>
`settings-v${getAppMajorVersion()}`

export const schema = {
properties: {
costCenter: {
Expand Down
2 changes: 1 addition & 1 deletion node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"ramda": "^0.25.0",
"atob": "^2.1.2",
"axios": "0.27.2",
"@vtex/api": "6.50.1"
"@vtex/api": "6.51.0"
},
"devDependencies": {
"@types/atob": "^2.1.2",
Expand Down
5 changes: 3 additions & 2 deletions node/resolvers/mutations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { map, groupBy, values } from 'ramda'

import {
APP_NAME,
getSettingsVBaseKey,
QUOTE_DATA_ENTITY,
QUOTE_FIELDS,
routes,
Expand Down Expand Up @@ -657,7 +658,7 @@ export const Mutation = {
try {
settings = await vbase.getJSON<Settings | null>(
APP_NAME,
'settings',
getSettingsVBaseKey(),
true
)
} catch (error) {
Expand All @@ -684,7 +685,7 @@ export const Mutation = {
}

try {
await vbase.saveJSON(APP_NAME, 'settings', newSettings)
await vbase.saveJSON(APP_NAME, getSettingsVBaseKey(), newSettings)
} catch (error) {
logger.error({
error,
Expand Down
3 changes: 2 additions & 1 deletion node/resolvers/queries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
APP_NAME,
B2B_USER_DATA_ENTITY,
B2B_USER_SCHEMA_VERSION,
getSettingsVBaseKey,
QUOTE_DATA_ENTITY,
QUOTE_FIELDS,
SCHEMA_VERSION,
Expand Down Expand Up @@ -358,7 +359,7 @@ export const Query = {
try {
settings = await vbase.getJSON<Settings | null>(
APP_NAME,
'settings',
getSettingsVBaseKey(),
true
)
} catch (error) {
Expand Down
9 changes: 7 additions & 2 deletions node/resolvers/utils/checkConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { toHash } from '../../utils'
import {
APP_NAME,
CRON_EXPRESSION,
getSettingsVBaseKey,
QUOTE_DATA_ENTITY,
SCHEMA_VERSION,
routes,
Expand Down Expand Up @@ -348,7 +349,11 @@ export const checkConfig = async (ctx: Context) => {
const currTemplateHash = toHash(templates)

try {
settings = await vbase.getJSON<Settings | null>(APP_NAME, 'settings', true)
settings = await vbase.getJSON<Settings | null>(
APP_NAME,
getSettingsVBaseKey(),
true
)
} catch (error) {
logger.error({
error,
Expand Down Expand Up @@ -377,7 +382,7 @@ export const checkConfig = async (ctx: Context) => {
changed = initializationResult.changed

if (changed) {
await vbase.saveJSON(APP_NAME, 'settings', settings)
await vbase.saveJSON(APP_NAME, getSettingsVBaseKey(), settings)
}

await checkAndCreateQuotesConfig(ctx)
Expand Down
10 changes: 5 additions & 5 deletions node/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -591,10 +591,10 @@
resolved "https://registry.yarnpkg.com/@types/shimmer/-/shimmer-1.2.0.tgz#9b706af96fa06416828842397a70dfbbf1c14ded"
integrity sha512-UE7oxhQLLd9gub6JKIAhDq06T0F6FnztwMNRvYgjeQSBeMc1ZG/tA47EwfduvkuQS8apbkM/lpLpWsaCeYsXVg==

"@vtex/api@6.50.1":
version "6.50.1"
resolved "https://registry.yarnpkg.com/@vtex/api/-/api-6.50.1.tgz#a86578982a7aac7c7a8df2b9ec3df18bc43f01f2"
integrity sha512-4IlmYwCXKpkdpN2KN6NkPuRwnjet3ilSoET3PBOTTdZqE/mnuvIxRZRaQy+Yp7Gxu0XKAVdp/8SQJhsJaa6Unw==
"@vtex/api@6.51.0":
version "6.51.0"
resolved "https://registry.yarnpkg.com/@vtex/api/-/api-6.51.0.tgz#97aeb306619ff49fd890595b90568883eaf77d83"
integrity sha512-vRWKB4G1FPPt67rwWx+xGLanuP5y+M9SVmbKu3PzlTrqgq/aW/mINSUGa/Nhm64UBqIQCkVic7/smZ7kKFq52w==
dependencies:
"@types/koa" "^2.11.0"
"@types/koa-compose" "^3.2.3"
Expand Down Expand Up @@ -2254,7 +2254,7 @@ sprintf-js@~1.0.2:
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=

stats-lite@vtex/node-stats-lite#dist:
"stats-lite@github:vtex/node-stats-lite#dist":
version "2.2.1"
resolved "https://codeload.github.com/vtex/node-stats-lite/tar.gz/a0b5ee91861f31b6ec845146b4906faf5172c430"
dependencies:
Expand Down