The complete open source platform to run your entire marketplace. Storefront, vendor panel, admin console, and integrations in one enterprise-grade platform you own.
TypeScript b2b-marketplacecomposable-commerceecommerceenterpriseheadless-commercemarketplacemedusamedusajsmulti-vendortypescript
fix(core): return supported currencies from GET /vendor/stores (#1543)
Viktor Holik27e34a73277e
diff --git a/integration-tests/http/store-info/vendor/stores.spec.ts b/integration-tests/http/store-info/vendor/stores.spec.tsindex d07e97248..7ab08a263 100644--- a/integration-tests/http/store-info/vendor/stores.spec.ts+++ b/integration-tests/http/store-info/vendor/stores.spec.ts@@ -1,5 +1,6 @@import { medusaIntegrationTestRunner } from "@medusajs/test-utils"import { MedusaContainer } from "@medusajs/framework/types"+import { Modules } from "@medusajs/framework/utils"import { createSellerDefaultsWorkflow } from "@mercurjs/core/workflows"import { createSellerUser } from "../../../helpers/create-seller-user"@@ -40,6 +41,28 @@ medusaIntegrationTestRunner({expect(Array.isArray(response.data.stores)).toBe(true)})+ it("returns the store's supported currencies by default", async () => {+ const storeModule = appContainer.resolve(Modules.STORE)+ const [store] = await storeModule.listStores()+ await storeModule.updateStores(store.id, {+ supported_currencies: [+ { currency_code: "usd", is_default: true },+ { currency_code: "eur" },+ ],+ })++ const response = await api.get("/vendor/stores", headers)++ expect(response.status).toBe(200)+ const codes = response.data.stores[0].supported_currencies.map(+ (c: { currency_code: string }) => c.currency_code+ )+ expect(codes).toEqual(expect.arrayContaining(["usd", "eur"]))+ expect(+ response.data.stores[0].supported_currencies[0].currency+ ).toBeDefined()+ })+it("returns stores for a member without a seller", async () => {const registerResponse = await api.post("/auth/member/emailpass/register",diff --git a/packages/core/src/api/vendor/stores/query-config.ts b/packages/core/src/api/vendor/stores/query-config.tsindex 69e124825..8332caf1b 100644--- a/packages/core/src/api/vendor/stores/query-config.ts+++ b/packages/core/src/api/vendor/stores/query-config.ts@@ -14,18 +14,24 @@ export const vendorStoreFields = [// Both lists are stripped unconditionally. `allowed` used to depend on the// `rbac_filter_fields` feature flag; since Medusa 2.20 a requested field outside// it is always dropped, silently, before the query runs.+// AllowedFieldFilter compares de-starred relation paths, so `*relation`+// entries in `allowed` never match and the relation is dropped.+export const vendorStoreAllowedFields = vendorStoreFields.map((field) =>+ field.startsWith("*") ? field.slice(1) : field+)+export const vendorStoreDisallowedFields = ["members"]export const vendorStoreQueryConfig = {list: {defaults: vendorStoreFields,- allowed: vendorStoreFields,+ allowed: vendorStoreAllowedFields,disallowed: vendorStoreDisallowedFields,isList: true,},retrieve: {defaults: vendorStoreFields,- allowed: vendorStoreFields,+ allowed: vendorStoreAllowedFields,disallowed: vendorStoreDisallowedFields,isList: false,},