From c84a9abe0c1b002d785bca4840fc950c98b1045c Mon Sep 17 00:00:00 2001 From: adrien2p Date: Wed, 13 Sep 2023 17:24:15 +0200 Subject: [PATCH 01/13] feat: admin list product with product isolated module --- .../routes/admin/products/list-products.ts | 245 +++++++++++++++++- 1 file changed, 240 insertions(+), 5 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/products/list-products.ts b/packages/medusa/src/api/routes/admin/products/list-products.ts index 4640a87e33ff2..3ef37334bcae8 100644 --- a/packages/medusa/src/api/routes/admin/products/list-products.ts +++ b/packages/medusa/src/api/routes/admin/products/list-products.ts @@ -1,5 +1,6 @@ import { IsNumber, IsOptional, IsString } from "class-validator" import { + PriceListService, PricingService, ProductService, ProductVariantInventoryService, @@ -11,6 +12,8 @@ import { IInventoryService } from "@medusajs/types" import { PricedProduct } from "../../../../types/pricing" import { Product } from "../../../../models" import { Type } from "class-transformer" +import { defaultStoreProductsFields } from "../../store/products" +import IsolateProductDomainFeatureFlag from "../../../../loaders/feature-flags/isolate-product-domain" /** * @oas [get] /admin/products @@ -235,16 +238,30 @@ export default async (req, res) => { const salesChannelService: SalesChannelService = req.scope.resolve( "salesChannelService" ) + const featureFlagRouter = req.scope.resolve("featureFlagRouter") const pricingService: PricingService = req.scope.resolve("pricingService") const { skip, take, relations } = req.listConfig - const manager = req.scope.resolve("manager") + let rawProducts + let count - const [rawProducts, count] = await productService.listAndCount( - req.filterableFields, - req.listConfig - ) + if (featureFlagRouter.isFeatureEnabled(IsolateProductDomainFeatureFlag.key)) { + const [products, count_] = + await listAndCountProductWithIsolatedProductModule( + req, + req.filterableFields, + req.listConfig + ) + } else { + const [products, count_] = await productService.listAndCount( + req.filterableFields, + req.listConfig + ) + + rawProducts = products + count = count_ + } let products: (Product | PricedProduct)[] = rawProducts @@ -280,6 +297,224 @@ export default async (req, res) => { }) } +async function listAndCountProductWithIsolatedProductModule( + req, + filterableFields, + listConfig +) { + // TODO: Add support for fields/expands + + const remoteQuery = req.scope.resolve("remoteQuery") + + const productIdsFilter: Set = new Set() + const variantIdsFilter: Set = new Set() + + const promises: Promise[] = [] + + // This is not the best way of handling cross filtering but for now I would say it is fine + const salesChannelIdFilter = filterableFields.sales_channel_id + delete filterableFields.sales_channel_id + + if (salesChannelIdFilter) { + const salesChannelService = req.scope.resolve( + "salesChannelService" + ) as SalesChannelService + + promises.push( + salesChannelService + .listProductIdsBySalesChannelIds(salesChannelIdFilter) + .then((productIdsInSalesChannel) => { + let filteredProductIds = + productIdsInSalesChannel[salesChannelIdFilter] + + if (filterableFields.id) { + filterableFields.id = Array.isArray(filterableFields.id) + ? filterableFields.id + : [filterableFields.id] + + const salesChannelProductIdsSet = new Set(filteredProductIds) + + filteredProductIds = filterableFields.id.filter((productId) => + salesChannelProductIdsSet.has(productId) + ) + } + + filteredProductIds.map((id) => productIdsFilter.add(id)) + }) + ) + } + + const priceListId = filterableFields.price_list_id + delete filterableFields.price_list_id + + if (priceListId) { + const priceListService = req.scope.resolve( + "priceListService" + ) as PriceListService + promises.push( + priceListService + .retrieve(priceListId, { + relations: ["prices"], + }) + .then((priceList) => { + // TODO: need some more refactoring, maybe a link between price list and product to attach the variant and use the + // remote query here to retrieve [money_amount, product] couple such as what we have for the shipping profile + priceList.prices.map((ma) => variantIdsFilter.add(ma.variant_id)) + }) + ) + } + + const discountConditionId = filterableFields.discount_condition_id + delete filterableFields.discount_condition_id + + if (discountConditionId) { + // TODO Add support through another link such as we have for the shipping_profile + } + + await Promise.all(promises) + + if (productIdsFilter.size > 0) { + filterableFields.id = Array.from(productIdsFilter) + } + + if (variantIdsFilter.size > 0) { + filterableFields.variants = { id: Array.from(variantIdsFilter) } + } + + const variables = { + filters: filterableFields, + order: listConfig.order, + skip: listConfig.skip, + take: listConfig.take, + } + + // prettier-ignore + const args = ` + filters: $filters, + order: $order, + skip: $skip, + take: $take + ` + + const query = ` + query ($filters: any, $order: any, $skip: Int, $take: Int) { + product (${args}) { + ${defaultStoreProductsFields.join("\n")} + + images { + id + created_at + updated_at + deleted_at + url + metadata + } + + tags { + id + created_at + updated_at + deleted_at + value + } + + type { + id + created_at + updated_at + deleted_at + value + } + + collection { + title + handle + id + created_at + updated_at + deleted_at + } + + options { + id + created_at + updated_at + deleted_at + title + product_id + metadata + values { + id + created_at + updated_at + deleted_at + value + option_id + variant_id + metadata + } + } + + variants { + id + created_at + updated_at + deleted_at + title + product_id + sku + barcode + ean + upc + variant_rank + inventory_quantity + allow_backorder + manage_inventory + hs_code + origin_country + mid_code + material + weight + length + height + width + metadata + options { + id + created_at + updated_at + deleted_at + value + option_id + variant_id + metadata + } + } + + profile { + id + created_at + updated_at + deleted_at + name + type + } + } + } + ` + + const { + rows: products, + metadata: { count }, + } = await remoteQuery(query, variables) + + products.forEach((product) => { + product.profile_id = product.profile?.id + }) + + return [products, count] +} + export class AdminGetProductsParams extends FilterableProductProps { @IsNumber() @IsOptional() From 1bef4c6470989e992f21906fb395530d7469b6e6 Mon Sep 17 00:00:00 2001 From: adrien2p Date: Wed, 13 Sep 2023 17:26:06 +0200 Subject: [PATCH 02/13] WIP --- .../medusa/src/api/routes/admin/products/list-products.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/products/list-products.ts b/packages/medusa/src/api/routes/admin/products/list-products.ts index 3ef37334bcae8..d8a8d4e4acc98 100644 --- a/packages/medusa/src/api/routes/admin/products/list-products.ts +++ b/packages/medusa/src/api/routes/admin/products/list-products.ts @@ -12,8 +12,8 @@ import { IInventoryService } from "@medusajs/types" import { PricedProduct } from "../../../../types/pricing" import { Product } from "../../../../models" import { Type } from "class-transformer" -import { defaultStoreProductsFields } from "../../store/products" import IsolateProductDomainFeatureFlag from "../../../../loaders/feature-flags/isolate-product-domain" +import { defaultAdminProductFields } from "./index" /** * @oas [get] /admin/products @@ -399,7 +399,7 @@ async function listAndCountProductWithIsolatedProductModule( const query = ` query ($filters: any, $order: any, $skip: Int, $take: Int) { product (${args}) { - ${defaultStoreProductsFields.join("\n")} + ${defaultAdminProductFields.join("\n")} images { id From ba7fcc1161175e9f3e01c26d3ce4041f2b0ebfcb Mon Sep 17 00:00:00 2001 From: adrien2p Date: Wed, 13 Sep 2023 17:41:35 +0200 Subject: [PATCH 03/13] list variant ids by price list --- .../routes/admin/products/list-products.ts | 12 +++---- .../medusa/src/repositories/price-list.ts | 21 +++++++++++- packages/medusa/src/services/price-list.ts | 33 ++++++++++++++++++- 3 files changed, 57 insertions(+), 9 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/products/list-products.ts b/packages/medusa/src/api/routes/admin/products/list-products.ts index d8a8d4e4acc98..5f1adf41fd71f 100644 --- a/packages/medusa/src/api/routes/admin/products/list-products.ts +++ b/packages/medusa/src/api/routes/admin/products/list-products.ts @@ -353,13 +353,11 @@ async function listAndCountProductWithIsolatedProductModule( ) as PriceListService promises.push( priceListService - .retrieve(priceListId, { - relations: ["prices"], - }) - .then((priceList) => { - // TODO: need some more refactoring, maybe a link between price list and product to attach the variant and use the - // remote query here to retrieve [money_amount, product] couple such as what we have for the shipping profile - priceList.prices.map((ma) => variantIdsFilter.add(ma.variant_id)) + .listPriceListsVariantIdsMap(priceListId) + .then((priceListVariantIdsMap) => { + priceListVariantIdsMap[priceListId].map((variantId) => + variantIdsFilter.add(variantId) + ) }) ) } diff --git a/packages/medusa/src/repositories/price-list.ts b/packages/medusa/src/repositories/price-list.ts index 27e1914bbd01e..764e4bf5f47be 100644 --- a/packages/medusa/src/repositories/price-list.ts +++ b/packages/medusa/src/repositories/price-list.ts @@ -1,5 +1,5 @@ import { FindOperator, FindOptionsWhere, ILike, In } from "typeorm" -import { PriceList } from "../models" +import { PriceList, ProductVariantMoneyAmount } from "../models" import { ExtendedFindConfig } from "../types/common" import { dataSource } from "../loaders/database" @@ -54,6 +54,25 @@ export const PriceListRepository = dataSource.getRepository(PriceList).extend({ return await Promise.all([this.find(query_), this.count(query_)]) }, + + async listPriceListsVariantIdsMap( + priceListId: string + ): Promise<{ [priceListId: string]: string[] }> { + const data = await this.createQueryBuilder("pl") + .innerJoin("pl.prices", "prices") + .innerJoinAndSelect( + ProductVariantMoneyAmount, + "pvma", + "pvma.id = prices.id" + ) + .where("pl.id = :id", { id: priceListId }) + .execute() + + return data.reduce((acc, curr) => { + acc[curr["pvma_variant_id"]] = curr["pvma_id"] + return acc + }, {}) + }, }) export default PriceListRepository diff --git a/packages/medusa/src/services/price-list.ts b/packages/medusa/src/services/price-list.ts index b70946d69f998..35eb6ee90ea45 100644 --- a/packages/medusa/src/services/price-list.ts +++ b/packages/medusa/src/services/price-list.ts @@ -8,7 +8,7 @@ import { import { CustomerGroup, PriceList, Product, ProductVariant } from "../models" import { DeepPartial, EntityManager } from "typeorm" import { FindConfig, Selector } from "../types/common" -import { MedusaError, isDefined } from "medusa-core-utils" +import { isDefined, MedusaError } from "medusa-core-utils" import { CustomerGroupService } from "." import { FilterableProductProps } from "../types/product" @@ -106,6 +106,37 @@ class PriceListService extends TransactionBaseService { return priceList } + async listPriceListsVariantIdsMap( + priceListIds: string | string[] + ): Promise<{ [priceListId: string]: string[] }> { + priceListIds = Array.isArray(priceListIds) ? priceListIds : [priceListIds] + + if (!priceListIds.length) { + throw new MedusaError( + MedusaError.Types.NOT_FOUND, + `"priceListId" must be defined` + ) + } + + const priceListRepo = this.activeManager_.withRepository( + this.priceListRepo_ + ) + + const priceListsVariantIdsMap = + await priceListRepo.listPriceListsVariantIdsMap(priceListIds) + + if (!Object.keys(priceListsVariantIdsMap)?.length) { + throw new MedusaError( + MedusaError.Types.NOT_FOUND, + `No PriceList found for priceListIds with id: ${priceListIds.join( + ", " + )}` + ) + } + + return priceListsVariantIdsMap + } + /** * Creates a Price List * @param priceListObject - the Price List to create From fd27e560131dddfbe7301a7872461e973819cedb Mon Sep 17 00:00:00 2001 From: adrien2p Date: Wed, 13 Sep 2023 17:43:39 +0200 Subject: [PATCH 04/13] TODO --- packages/medusa/src/api/routes/admin/products/list-products.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/medusa/src/api/routes/admin/products/list-products.ts b/packages/medusa/src/api/routes/admin/products/list-products.ts index 5f1adf41fd71f..f62ffb282500c 100644 --- a/packages/medusa/src/api/routes/admin/products/list-products.ts +++ b/packages/medusa/src/api/routes/admin/products/list-products.ts @@ -366,7 +366,7 @@ async function listAndCountProductWithIsolatedProductModule( delete filterableFields.discount_condition_id if (discountConditionId) { - // TODO Add support through another link such as we have for the shipping_profile + // TODO } await Promise.all(promises) From 2d1d71786e603f05e1100f18739d123255d2b432 Mon Sep 17 00:00:00 2001 From: adrien2p Date: Wed, 13 Sep 2023 17:54:18 +0200 Subject: [PATCH 05/13] Fix repo --- packages/medusa/src/repositories/price-list.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/medusa/src/repositories/price-list.ts b/packages/medusa/src/repositories/price-list.ts index 764e4bf5f47be..d7bb0423a2ea1 100644 --- a/packages/medusa/src/repositories/price-list.ts +++ b/packages/medusa/src/repositories/price-list.ts @@ -56,8 +56,10 @@ export const PriceListRepository = dataSource.getRepository(PriceList).extend({ }, async listPriceListsVariantIdsMap( - priceListId: string + priceListIds: string | string[] ): Promise<{ [priceListId: string]: string[] }> { + priceListIds = Array.isArray(priceListIds) ? priceListIds : [priceListIds] + const data = await this.createQueryBuilder("pl") .innerJoin("pl.prices", "prices") .innerJoinAndSelect( @@ -65,7 +67,7 @@ export const PriceListRepository = dataSource.getRepository(PriceList).extend({ "pvma", "pvma.id = prices.id" ) - .where("pl.id = :id", { id: priceListId }) + .where("pl.id IN (:...ids)", { ids: priceListIds }) .execute() return data.reduce((acc, curr) => { From dfb8baf2b01bf183fbe60360f5a2254f9158d8e1 Mon Sep 17 00:00:00 2001 From: adrien2p Date: Thu, 14 Sep 2023 11:29:39 +0200 Subject: [PATCH 06/13] finalise first iteration --- .../src/api/routes/admin/products/list-products.ts | 9 ++++++++- packages/medusa/src/repositories/price-list.ts | 6 ++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/products/list-products.ts b/packages/medusa/src/api/routes/admin/products/list-products.ts index f62ffb282500c..4c4488388de85 100644 --- a/packages/medusa/src/api/routes/admin/products/list-products.ts +++ b/packages/medusa/src/api/routes/admin/products/list-products.ts @@ -253,6 +253,9 @@ export default async (req, res) => { req.filterableFields, req.listConfig ) + + rawProducts = products + count = count_ } else { const [products, count_] = await productService.listAndCount( req.filterableFields, @@ -348,6 +351,10 @@ async function listAndCountProductWithIsolatedProductModule( delete filterableFields.price_list_id if (priceListId) { + // TODO: it is working but validate the behaviour. + // e.g pricing context properly set. + // At the moment filtering by price list but not having any customer id or + // include discount forces the query to filter with price list id is null const priceListService = req.scope.resolve( "priceListService" ) as PriceListService @@ -366,7 +373,7 @@ async function listAndCountProductWithIsolatedProductModule( delete filterableFields.discount_condition_id if (discountConditionId) { - // TODO + // TODO implement later } await Promise.all(promises) diff --git a/packages/medusa/src/repositories/price-list.ts b/packages/medusa/src/repositories/price-list.ts index d7bb0423a2ea1..66b93749edcbb 100644 --- a/packages/medusa/src/repositories/price-list.ts +++ b/packages/medusa/src/repositories/price-list.ts @@ -65,13 +65,15 @@ export const PriceListRepository = dataSource.getRepository(PriceList).extend({ .innerJoinAndSelect( ProductVariantMoneyAmount, "pvma", - "pvma.id = prices.id" + "pvma.money_amount_id = prices.id" ) .where("pl.id IN (:...ids)", { ids: priceListIds }) .execute() return data.reduce((acc, curr) => { - acc[curr["pvma_variant_id"]] = curr["pvma_id"] + acc[curr["pl_id"]] ??= [] + acc[curr["pl_id"]].push(curr["pvma_variant_id"]) + acc[curr["pl_id"]] = [...new Set(acc[curr["pl_id"]])] return acc }, {}) }, From 8533969d56298f294e0e7e487bd2e7ac2dfae86e Mon Sep 17 00:00:00 2001 From: Adrien de Peretti Date: Thu, 14 Sep 2023 12:18:43 +0200 Subject: [PATCH 07/13] Create gentle-guests-brush.md --- .changeset/gentle-guests-brush.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/gentle-guests-brush.md diff --git a/.changeset/gentle-guests-brush.md b/.changeset/gentle-guests-brush.md new file mode 100644 index 0000000000000..67727eae153ca --- /dev/null +++ b/.changeset/gentle-guests-brush.md @@ -0,0 +1,5 @@ +--- +"@medusajs/medusa": patch +--- + +feat(medusa): admin list product with product isolated module From 793e55ba608b4e1faea2a2b50935f9ac1c2b2480 Mon Sep 17 00:00:00 2001 From: adrien2p Date: Tue, 19 Sep 2023 11:00:25 +0200 Subject: [PATCH 08/13] use object instead of string --- .../src/api/routes/admin/products/index.ts | 89 +++++++++++++ .../routes/admin/products/list-products.ts | 122 +----------------- 2 files changed, 96 insertions(+), 115 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/products/index.ts b/packages/medusa/src/api/routes/admin/products/index.ts index 8b40526ab00a4..a814c8ec2435e 100644 --- a/packages/medusa/src/api/routes/admin/products/index.ts +++ b/packages/medusa/src/api/routes/admin/products/index.ts @@ -138,6 +138,95 @@ export const defaultAdminProductFields: (keyof Product)[] = [ export const defaultAdminGetProductsVariantsFields = ["id", "product_id"] +/** + * This is temporary. + */ +export const defaultAdminRemoteQueryFields = { + fields: defaultAdminProductFields, + images: { + fields: ["id", "created_at", "updated_at", "deleted_at", "url", "metadata"], + }, + tags: { + fields: ["id", "created_at", "updated_at", "deleted_at", "value"], + }, + + type: { + fields: ["id", "created_at", "updated_at", "deleted_at", "value"], + }, + + collection: { + fields: ["title", "handle", "id", "created_at", "updated_at", "deleted_at"], + }, + + options: { + fields: [ + "id", + "created_at", + "updated_at", + "deleted_at", + "title", + "product_id", + "metadata", + ], + values: { + fields: [ + "id", + "created_at", + "updated_at", + "deleted_at", + "value", + "option_id", + "variant_id", + "metadata", + ], + }, + }, + + variants: { + fields: [ + "id", + "created_at", + "updated_at", + "deleted_at", + "title", + "product_id", + "sku", + "barcode", + "ean", + "upc", + "variant_rank", + "inventory_quantity", + "allow_backorder", + "manage_inventory", + "hs_code", + "origin_country", + "mid_code", + "material", + "weight", + "length", + "height", + "width", + "metadata", + ], + + options: { + fields: [ + "id", + "created_at", + "updated_at", + "deleted_at", + "value", + "option_id", + "variant_id", + "metadata", + ], + }, + }, + profile: { + fields: ["id", "created_at", "updated_at", "deleted_at", "name", "type"], + }, +} + /** * @schema AdminProductsDeleteOptionRes * type: object diff --git a/packages/medusa/src/api/routes/admin/products/list-products.ts b/packages/medusa/src/api/routes/admin/products/list-products.ts index 4c4488388de85..1e9d2dffcdd7d 100644 --- a/packages/medusa/src/api/routes/admin/products/list-products.ts +++ b/packages/medusa/src/api/routes/admin/products/list-products.ts @@ -13,7 +13,7 @@ import { PricedProduct } from "../../../../types/pricing" import { Product } from "../../../../models" import { Type } from "class-transformer" import IsolateProductDomainFeatureFlag from "../../../../loaders/feature-flags/isolate-product-domain" -import { defaultAdminProductFields } from "./index" +import { defaultAdminRemoteQueryFields } from "./index" /** * @oas [get] /admin/products @@ -393,120 +393,12 @@ async function listAndCountProductWithIsolatedProductModule( take: listConfig.take, } - // prettier-ignore - const args = ` - filters: $filters, - order: $order, - skip: $skip, - take: $take - ` - - const query = ` - query ($filters: any, $order: any, $skip: Int, $take: Int) { - product (${args}) { - ${defaultAdminProductFields.join("\n")} - - images { - id - created_at - updated_at - deleted_at - url - metadata - } - - tags { - id - created_at - updated_at - deleted_at - value - } - - type { - id - created_at - updated_at - deleted_at - value - } - - collection { - title - handle - id - created_at - updated_at - deleted_at - } - - options { - id - created_at - updated_at - deleted_at - title - product_id - metadata - values { - id - created_at - updated_at - deleted_at - value - option_id - variant_id - metadata - } - } - - variants { - id - created_at - updated_at - deleted_at - title - product_id - sku - barcode - ean - upc - variant_rank - inventory_quantity - allow_backorder - manage_inventory - hs_code - origin_country - mid_code - material - weight - length - height - width - metadata - options { - id - created_at - updated_at - deleted_at - value - option_id - variant_id - metadata - } - } - - profile { - id - created_at - updated_at - deleted_at - name - type - } - } - } - ` + const query = { + product: { + __args: variables, + ...defaultAdminRemoteQueryFields, + }, + } const { rows: products, From c689034d3fde128860e7c585c4c25d1eced84b18 Mon Sep 17 00:00:00 2001 From: adrien2p Date: Tue, 19 Sep 2023 11:01:21 +0200 Subject: [PATCH 09/13] feedback --- packages/medusa/src/services/price-list.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/packages/medusa/src/services/price-list.ts b/packages/medusa/src/services/price-list.ts index 35eb6ee90ea45..aa3d11ff5cc80 100644 --- a/packages/medusa/src/services/price-list.ts +++ b/packages/medusa/src/services/price-list.ts @@ -114,7 +114,7 @@ class PriceListService extends TransactionBaseService { if (!priceListIds.length) { throw new MedusaError( MedusaError.Types.NOT_FOUND, - `"priceListId" must be defined` + `"priceListIds" must be defined` ) } @@ -128,9 +128,7 @@ class PriceListService extends TransactionBaseService { if (!Object.keys(priceListsVariantIdsMap)?.length) { throw new MedusaError( MedusaError.Types.NOT_FOUND, - `No PriceList found for priceListIds with id: ${priceListIds.join( - ", " - )}` + `No PriceLists found with ids: ${priceListIds.join(", ")}` ) } From 0310dbad27df51729dd0c4d7c6fadab692874e69 Mon Sep 17 00:00:00 2001 From: adrien2p Date: Tue, 19 Sep 2023 11:04:13 +0200 Subject: [PATCH 10/13] rm variables arg --- packages/medusa/src/api/routes/admin/products/list-products.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/medusa/src/api/routes/admin/products/list-products.ts b/packages/medusa/src/api/routes/admin/products/list-products.ts index 1e9d2dffcdd7d..cc98ae8fd5f5f 100644 --- a/packages/medusa/src/api/routes/admin/products/list-products.ts +++ b/packages/medusa/src/api/routes/admin/products/list-products.ts @@ -403,7 +403,7 @@ async function listAndCountProductWithIsolatedProductModule( const { rows: products, metadata: { count }, - } = await remoteQuery(query, variables) + } = await remoteQuery(query) products.forEach((product) => { product.profile_id = product.profile?.id From 8ed6ad7d13f5ee41d4519d70930aa91881667c02 Mon Sep 17 00:00:00 2001 From: adrien2p Date: Fri, 22 Sep 2023 09:30:50 +0200 Subject: [PATCH 11/13] fix merge --- packages/medusa/src/api/routes/store/products/index.ts | 2 +- .../medusa/src/api/routes/store/products/list-products.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/medusa/src/api/routes/store/products/index.ts b/packages/medusa/src/api/routes/store/products/index.ts index aa61cdd1223c9..7f0fa7c62d38e 100644 --- a/packages/medusa/src/api/routes/store/products/index.ts +++ b/packages/medusa/src/api/routes/store/products/index.ts @@ -114,7 +114,7 @@ export const allowedStoreProductsRelations = [ /** * This is temporary. */ -export const defaultStoreRemoteQueryFields = { +export const defaultStoreProductRemoteQueryObject = { fields: defaultStoreProductsFields, images: { fields: ["id", "created_at", "updated_at", "deleted_at", "url", "metadata"], diff --git a/packages/medusa/src/api/routes/store/products/list-products.ts b/packages/medusa/src/api/routes/store/products/list-products.ts index 87b76d7fbf5fa..8b0ac2b51464e 100644 --- a/packages/medusa/src/api/routes/store/products/list-products.ts +++ b/packages/medusa/src/api/routes/store/products/list-products.ts @@ -24,7 +24,7 @@ import { cleanResponseData } from "../../../../utils/clean-response-data" import { defaultStoreCategoryScope } from "../product-categories" import { optionalBooleanMapper } from "../../../../utils/validators/is-boolean" import IsolateProductDomain from "../../../../loaders/feature-flags/isolate-product-domain" -import { defaultStoreRemoteQueryFields } from "./index" +import { defaultStoreProductRemoteQueryObject } from "./index" /** * @oas [get] /store/products @@ -397,7 +397,7 @@ async function listAndCountProductWithIsolatedProductModule( const query = { product: { __args: variables, - ...defaultStoreRemoteQueryFields, + ...defaultStoreProductRemoteQueryObject, }, } From dfc326095387b94e14ef00a97a083ed60abf3d1f Mon Sep 17 00:00:00 2001 From: adrien2p Date: Fri, 22 Sep 2023 11:41:33 +0200 Subject: [PATCH 12/13] fix --- .../medusa/src/api/routes/admin/products/list-products.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/medusa/src/api/routes/admin/products/list-products.ts b/packages/medusa/src/api/routes/admin/products/list-products.ts index cc98ae8fd5f5f..62225e0ad3198 100644 --- a/packages/medusa/src/api/routes/admin/products/list-products.ts +++ b/packages/medusa/src/api/routes/admin/products/list-products.ts @@ -13,7 +13,7 @@ import { PricedProduct } from "../../../../types/pricing" import { Product } from "../../../../models" import { Type } from "class-transformer" import IsolateProductDomainFeatureFlag from "../../../../loaders/feature-flags/isolate-product-domain" -import { defaultAdminRemoteQueryFields } from "./index" +import { defaultAdminProductRemoteQueryObject } from "./index" /** * @oas [get] /admin/products @@ -396,7 +396,7 @@ async function listAndCountProductWithIsolatedProductModule( const query = { product: { __args: variables, - ...defaultAdminRemoteQueryFields, + ...defaultAdminProductRemoteQueryObject, }, } From 15c6d20fe4251fe4edd95f79ad09ae254102785e Mon Sep 17 00:00:00 2001 From: adrien2p Date: Fri, 22 Sep 2023 12:06:12 +0200 Subject: [PATCH 13/13] fix --- packages/medusa/src/api/routes/store/products/get-product.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/medusa/src/api/routes/store/products/get-product.ts b/packages/medusa/src/api/routes/store/products/get-product.ts index 35a0b10763d3c..2f79a62eceda2 100644 --- a/packages/medusa/src/api/routes/store/products/get-product.ts +++ b/packages/medusa/src/api/routes/store/products/get-product.ts @@ -10,7 +10,7 @@ import { IsOptional, IsString } from "class-validator" import { PriceSelectionParams } from "../../../../types/price-selection" import { cleanResponseData } from "../../../../utils" import IsolateProductDomain from "../../../../loaders/feature-flags/isolate-product-domain" -import { defaultStoreRemoteQueryFields } from "./index" +import { defaultStoreProductRemoteQueryObject } from "./index" /** * @oas [get] /store/products/{id} @@ -170,7 +170,7 @@ async function getProductWithIsolatedProductModule(req, id: string) { const query = { product: { __args: variables, - ...defaultStoreRemoteQueryFields, + ...defaultStoreProductRemoteQueryObject, }, }