feat: Update signature of region module to match latest spec (#6487)

This commit is contained in:
Stevche Radevski authored and GitHub committed 2024-02-23 15:56:16 +00:00
1 parent c86e27bd0d
commit 5b85c3103e
8 files changed
+174 -87

No files matched your search

+6 -12
View File
@@ -22,16 +22,13 @@ export interface CreateRegionDTO {
metadata?: Record<string, unknown>
}
/**
* The attributes to update in the region.
*/
export interface UpdateRegionDTO {
export interface UpsertRegionDTO {
/**
* The ID of the region.
* The id of the region in the case of an update
*/
id: string
id?: string
/**
* The name of the region.
* The target name of the region
*/
name?: string
/**
@@ -48,12 +45,9 @@ export interface UpdateRegionDTO {
metadata?: Record<string, unknown>
}
/**
* The updatable fields of a region.
*/
export interface UpdatableRegionFields {
export interface UpdateRegionDTO {
/**
* The name of the region.
* The target name of the region
*/
name?: string
/**
+32 -25
View File
@@ -10,11 +10,7 @@ import {
RegionCurrencyDTO,
RegionDTO,
} from "./common"
import {
CreateRegionDTO,
UpdatableRegionFields,
UpdateRegionDTO,
} from "./mutations"
import { CreateRegionDTO, UpsertRegionDTO, UpdateRegionDTO } from "./mutations"
/**
* The main service interface for the region module.
@@ -45,21 +41,46 @@ export interface IRegionModuleService extends IModuleService {
create(data: CreateRegionDTO, sharedContext?: Context): Promise<RegionDTO>
/**
* This method updates existing regions.
* This method updates existing regions, or creates new ones if they don't exist.
*
* @param {UpdateRegionDTO[]} data - The attributes to update in each region.
* @returns {Promise<RegionDTO[]>} The updated regions.
* @param {UpsertRegionDTO[]} data - The attributes to update or create in each region.
* @returns {Promise<RegionDTO[]>} The updated and created regions.
*
* @example
* {example-code}
*/
update(data: UpdateRegionDTO[]): Promise<RegionDTO[]>
upsert(data: UpsertRegionDTO[], sharedContext?: Context): Promise<RegionDTO[]>
/**
* This method updates an existing region, or creates a new one if it doesn't exist.
*
* @param {UpsertRegionDTO} data - The attributes to update or create for the region.
* @returns {Promise<RegionDTO>} The updated or created region.
*
* @example
* {example-code}
*/
upsert(data: UpsertRegionDTO, sharedContext?: Context): Promise<RegionDTO>
/**
* This method updates an existing region.
*
* @param {string} id - The region's ID.
* @param {UpdatableRegionFields} data - The details to update in the region.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<RegionDTO>} The updated region.
*/
update(
id: string,
data: UpdateRegionDTO,
sharedContext?: Context
): Promise<RegionDTO>
/**
* This method updates existing regions.
*
* @param {FilterableRegionProps} selector - The filters to specify which regions should be updated.
* @param {UpdatableRegionFields} data - The details to update in the regions.
* @param {UpdateRegionDTO} data - The details to update in the regions.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<RegionDTO[]>} The updated regions.
*
@@ -68,24 +89,10 @@ export interface IRegionModuleService extends IModuleService {
*/
update(
selector: FilterableRegionProps,
data: UpdatableRegionFields,
data: UpdateRegionDTO,
sharedContext?: Context
): Promise<RegionDTO[]>
/**
* This method updates an existing region.
*
* @param {string} regionId - The region's ID.
* @param {UpdatableRegionFields} data - The details to update in the regions.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<RegionDTO>} The updated region.
*/
update(
regionId: string,
data: UpdatableRegionFields,
sharedContext?: Context
): Promise<RegionDTO>
/**
* This method deletes regions by their IDs.
*