feat(types, product): added product module update (#4504)
* Feat: create product with product module * feat: create product wip * feat: create product wip * feat: update product relation and generate image migration * lint * conitnue implementation * continue implementation and add integration tests for produceService.create * Add integration tests for product creation at the module level for the complete flow * only use persist since write operations are always wrapped in a transaction which will be committed and flushed * simplify the transaction wrapper to make future changes easier * feat: move some utils to the utils package to simplify its usage * tests: fix unit tests * feat: create variants along side the product * Add more integration tests an update migrations * chore: Update actions workflow to include packages integration tests * small types and utils cleanup * chore: Add support for database debug option * chore: Add missing types in package.json from types and util, validate that all the models are sync with medusa * expose retrieve method * fix types issues * fix unit tests and move integration tests workflow with the plugins integration tests * chore: remove migration function export from the definition to prevent them to be ran by the medusa cli just in case * fix package.json script * chore: workflows * feat: start creating the create product workflow * feat: add empty step for prices and sales channel * tests: update scripts and action envs * fix imports * feat: Add proper soft deleted support + add product deletion service public api * chore: update migrations * chore: update migrations * chore: update todo * feat: Add product deletion to the create-product workflow as compensation * chore: cleanup product utils * feat: Add support for cascade soft-remove * feat: refactor repository to take into account withDeleted * fix integration tests * Add support for force delete -> delete, cleanup repositories and improvements * Add support for restoring a product and add integration tests * cleaup + tests * types * fix integration tests * remove unnecessary comments * move specific mikro orm usage to the DAL * Cleanup workflow functions * Make deleted_at optional at the property level and add url index for the images * address feedback + cleanup * fix export * merge migrations into one * feat(product, types): added missing product variant methods (#4475) * chore: added missing product variant methods * chore: address PR feedback * chore: catch undefined case for retrieve + specs for variant service * chore: align TEntity + add changeset * chore: revert changeset, TEntity to ProductVariant * chore: write tests for pagination, unskip the test * Create chilled-mice-deliver.md * update integration fixtuers * update pipeline node version * rename github action * fix pipeline * feat(medusa, types): added missing category tests and service methods (#4499) * chore: added missing category tests and service methods * chore: added type changes to module service * chore: address pr feedback * chore: added product module update * chore: use status enum type from common types * chore: remove flushing at repo level, pass in relation instead of ID * chore: update error message for missing id * update repositories manager usage and serialisation from the write public API * move serializisation to the DAL * rename template args * chore: address feedback * chore: wip * chore: added collection methods for module and collection service (#4505) * chore: added collection methods for module and collection service * Create fresh-islands-teach.md * chore: move retrieve entity to utils package * chore: make products optional in DTO type --------- Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com> * chore: added categories, collections and other relations to update * feat(product): Apply transaction decorators to the services (#4512) * chore: handle variant update, create and delete through products update * chore: cleanup types, self review * chore: remove relations that are not present in collection * chore: address reviews p1 * chore: add test for incorrect ID + remove extra check on variant id existance * chore: cleanup + add changeset * chore: wip * chore: add todos for getter method --------- Co-authored-by: adrien2p <adrien.deperetti@gmail.com> Co-authored-by: Oliver Windall Juhl <59018053+olivermrbl@users.noreply.github.com> Co-authored-by: Carlos R. L. Rodrigues <37986729+carlos-r-l-rodrigues@users.noreply.github.com>
This commit is contained in:
co-authored by
Oliver Windall Juhl
adrien2p
Carlos R. L. Rodrigues
parent
585ebf2454
commit
caea44ebfd
@@ -34,6 +34,9 @@ export interface RepositoryService<T = any> {
|
||||
|
||||
create(data: unknown[], context?: Context): Promise<T[]>
|
||||
|
||||
// TODO: remove optionality when all the other repositories have an update
|
||||
update?(data: unknown[], context?: Context): Promise<T[]>
|
||||
|
||||
delete(ids: string[], context?: Context): Promise<void>
|
||||
|
||||
softDelete(ids: string[], context?: Context): Promise<T[]>
|
||||
|
||||
@@ -58,6 +58,7 @@ export interface IInventoryService {
|
||||
context?: SharedContext
|
||||
): Promise<ReservationItemDTO>
|
||||
|
||||
// TODO make it bulk
|
||||
createReservationItems(
|
||||
input: CreateReservationItemInput[],
|
||||
context?: SharedContext
|
||||
|
||||
@@ -163,6 +163,7 @@ export interface FilterableProductVariantProps
|
||||
extends BaseFilterable<FilterableProductVariantProps> {
|
||||
id?: string | string[]
|
||||
sku?: string | string[]
|
||||
product_id?: string | string[]
|
||||
options?: { id?: string[] }
|
||||
}
|
||||
|
||||
@@ -219,6 +220,28 @@ export interface CreateProductVariantDTO {
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface UpdateProductVariantDTO {
|
||||
id: string
|
||||
title?: string
|
||||
sku?: string
|
||||
barcode?: string
|
||||
ean?: string
|
||||
upc?: string
|
||||
allow_backorder?: boolean
|
||||
inventory_quantity?: number
|
||||
manage_inventory?: boolean
|
||||
hs_code?: string
|
||||
origin_country?: string
|
||||
mid_code?: string
|
||||
material?: string
|
||||
weight?: number
|
||||
length?: number
|
||||
height?: number
|
||||
width?: number
|
||||
options?: CreateProductVariantOptionDTO[]
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface CreateProductDTO {
|
||||
title: string
|
||||
subtitle?: string
|
||||
@@ -233,7 +256,6 @@ export interface CreateProductDTO {
|
||||
type_id?: string
|
||||
collection_id?: string
|
||||
tags?: CreateProductTagDTO[]
|
||||
// sales_channel
|
||||
categories?: { id: string }[]
|
||||
options?: CreateProductOptionDTO[]
|
||||
variants?: CreateProductVariantDTO[]
|
||||
@@ -248,6 +270,35 @@ export interface CreateProductDTO {
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface UpdateProductDTO {
|
||||
id: string
|
||||
title?: string
|
||||
subtitle?: string
|
||||
description?: string
|
||||
is_giftcard?: boolean
|
||||
discountable?: boolean
|
||||
images?: string[] | { id?: string; url: string }[]
|
||||
thumbnail?: string
|
||||
handle?: string
|
||||
status?: ProductStatus
|
||||
type?: CreateProductTypeDTO
|
||||
type_id?: string | null
|
||||
collection_id?: string | null
|
||||
tags?: CreateProductTagDTO[]
|
||||
categories?: { id: string }[]
|
||||
options?: CreateProductOptionDTO[]
|
||||
variants?: (CreateProductVariantDTO | UpdateProductVariantDTO)[]
|
||||
width?: number
|
||||
height?: number
|
||||
length?: number
|
||||
weight?: number
|
||||
origin_country?: string
|
||||
hs_code?: string
|
||||
material?: string
|
||||
mid_code?: string
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface CreateProductOnlyDTO {
|
||||
title: string
|
||||
subtitle?: string
|
||||
@@ -294,6 +345,28 @@ export interface CreateProductVariantOnlyDTO {
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface UpdateProductVariantOnlyDTO {
|
||||
id: string,
|
||||
title?: string
|
||||
sku?: string
|
||||
barcode?: string
|
||||
ean?: string
|
||||
upc?: string
|
||||
allow_backorder?: boolean
|
||||
inventory_quantity?: number
|
||||
manage_inventory?: boolean
|
||||
hs_code?: string
|
||||
origin_country?: string
|
||||
mid_code?: string
|
||||
material?: string
|
||||
weight?: number
|
||||
length?: number
|
||||
height?: number
|
||||
width?: number
|
||||
options?: (CreateProductVariantOptionDTO & { option: any })[]
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface CreateProductOptionOnlyDTO {
|
||||
product: { id: string }
|
||||
title: string
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import {
|
||||
CreateProductDTO,
|
||||
UpdateProductDTO,
|
||||
FilterableProductCategoryProps,
|
||||
FilterableProductCollectionProps,
|
||||
FilterableProductProps,
|
||||
@@ -19,7 +20,11 @@ import { JoinerServiceConfig } from "../joiner"
|
||||
export interface IProductModuleService {
|
||||
__joinerConfig(): JoinerServiceConfig
|
||||
|
||||
retrieve(productId: string, sharedContext?: Context): Promise<ProductDTO>
|
||||
retrieve(
|
||||
productId: string,
|
||||
config?: FindConfig<ProductDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<ProductDTO>
|
||||
|
||||
list(
|
||||
filters?: FilterableProductProps,
|
||||
@@ -98,6 +103,11 @@ export interface IProductModuleService {
|
||||
sharedContext?: Context
|
||||
): Promise<ProductDTO[]>
|
||||
|
||||
update(
|
||||
data: UpdateProductDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<ProductDTO[]>
|
||||
|
||||
delete(productIds: string[], sharedContext?: Context): Promise<void>
|
||||
|
||||
softDelete(
|
||||
|
||||
Reference in New Issue
Block a user