feat: Sales Channels API routes + workflows (#6722)
**What** - Admin sales channels API routes - Workflows for creating, updating, and deleting sales channels - Align `ISalesChannelModuleService` interface with update + upsert conventions - Integrate v2 tests into v1 sales channels integration test suite - Add metadata to sales channel entity Sales channel <> Product management will come in a follow-up PR. On the integration tests, creating, updating, and deleting are passing with the V2 flag enabled. You'll have to take my word for it (or run them yourself), as they are not included in the CI.
This commit is contained in:
@@ -63,12 +63,12 @@ export interface FilterableSalesChannelProps
|
||||
/**
|
||||
* The IDs to filter the sales channel by.
|
||||
*/
|
||||
id?: string[]
|
||||
id?: string | string[]
|
||||
|
||||
/**
|
||||
* Filter sales channels by their names.
|
||||
*/
|
||||
name?: string[]
|
||||
name?: string | string[]
|
||||
|
||||
/**
|
||||
* Filter sales channels by whether they're disabled.
|
||||
|
||||
@@ -22,11 +22,6 @@ export interface CreateSalesChannelDTO {
|
||||
* The attributes to update in the sales channel.
|
||||
*/
|
||||
export interface UpdateSalesChannelDTO {
|
||||
/**
|
||||
* The ID of the sales channel.
|
||||
*/
|
||||
id: string
|
||||
|
||||
/**
|
||||
* The name of the sales channel.
|
||||
*/
|
||||
@@ -41,4 +36,34 @@ export interface UpdateSalesChannelDTO {
|
||||
* Whether the sales channel is disabled.
|
||||
*/
|
||||
is_disabled?: boolean
|
||||
/**
|
||||
* Holds custom data in key-value pairs.
|
||||
*/
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface UpsertSalesChannelDTO {
|
||||
/**
|
||||
* The ID of the sales channel.
|
||||
*/
|
||||
id?: string
|
||||
|
||||
/**
|
||||
* The name of the sales channel.
|
||||
*/
|
||||
name?: string
|
||||
|
||||
/**
|
||||
* The description of the sales channel.
|
||||
*/
|
||||
description?: string | null
|
||||
|
||||
/**
|
||||
* Whether the sales channel is disabled.
|
||||
*/
|
||||
is_disabled?: boolean
|
||||
/**
|
||||
* Holds custom data in key-value pairs.
|
||||
*/
|
||||
metadata?: Record<string, unknown> | null
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { IModuleService } from "../modules-sdk"
|
||||
import { FilterableSalesChannelProps, SalesChannelDTO } from "./common"
|
||||
import { FindConfig } from "../common"
|
||||
import { Context } from "../shared-context"
|
||||
import { RestoreReturn, SoftDeleteReturn } from "../dal"
|
||||
import { CreateSalesChannelDTO, UpdateSalesChannelDTO } from "./mutations"
|
||||
import { IModuleService } from "../modules-sdk"
|
||||
import { Context } from "../shared-context"
|
||||
import { FilterableSalesChannelProps, SalesChannelDTO } from "./common"
|
||||
import { CreateSalesChannelDTO, UpdateSalesChannelDTO, UpsertSalesChannelDTO } from "./mutations"
|
||||
|
||||
/**
|
||||
* The main service interface for the sales channel module.
|
||||
@@ -39,35 +39,25 @@ export interface ISalesChannelModuleService extends IModuleService {
|
||||
sharedContext?: Context
|
||||
): Promise<SalesChannelDTO>
|
||||
|
||||
/**
|
||||
* This method updates existing sales channels.
|
||||
*
|
||||
* @param {UpdateSalesChannelDTO[]} data - The attributes to update in each sales channel.
|
||||
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
||||
* @returns {Promise<SalesChannelDTO[]>} The updated sales channels.
|
||||
*
|
||||
* @example
|
||||
* {example-code}
|
||||
*/
|
||||
update(
|
||||
data: UpdateSalesChannelDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<SalesChannelDTO[]>
|
||||
|
||||
/**
|
||||
* This method updates an existing sales channel.
|
||||
*
|
||||
* @param {UpdateSalesChannelDTO} data - The attributes to update in the sales channel.
|
||||
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
|
||||
* @returns {Promise<SalesChannelDTO>} The updated sales channel.
|
||||
*
|
||||
* @example
|
||||
* {example-code}
|
||||
*/
|
||||
update(
|
||||
channelId: string,
|
||||
data: UpdateSalesChannelDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<SalesChannelDTO>
|
||||
update(
|
||||
selector: FilterableSalesChannelProps,
|
||||
data: UpdateSalesChannelDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<SalesChannelDTO[]>
|
||||
|
||||
upsert(
|
||||
data: UpsertSalesChannelDTO,
|
||||
sharedContext?: Context
|
||||
): Promise<SalesChannelDTO>
|
||||
upsert(
|
||||
data: UpsertSalesChannelDTO[],
|
||||
sharedContext?: Context
|
||||
): Promise<SalesChannelDTO[]>
|
||||
|
||||
/**
|
||||
* This method deletes sales channels by their IDs.
|
||||
|
||||
Reference in New Issue
Block a user