feat: Region Module (basic CRUD) (#6315)
This commit is contained in:
@@ -12,9 +12,10 @@ export * as ModulesSdkTypes from "./modules-sdk"
|
||||
export * as PricingTypes from "./pricing"
|
||||
export * as ProductTypes from "./product"
|
||||
export * as PromotionTypes from "./promotion"
|
||||
export * as RegionTypes from "./region"
|
||||
export * as RegionTypes from "./region__legacy"
|
||||
export * as SalesChannelTypes from "./sales-channel"
|
||||
export * as SearchTypes from "./search"
|
||||
export * as StockLocationTypes from "./stock-location"
|
||||
export * as TransactionBaseTypes from "./transaction-base"
|
||||
export * as WorkflowTypes from "./workflow"
|
||||
|
||||
|
||||
@@ -20,9 +20,11 @@ export * from "./product"
|
||||
export * from "./product-category"
|
||||
export * from "./promotion"
|
||||
export * from "./region"
|
||||
export * from "./region__legacy"
|
||||
export * from "./sales-channel"
|
||||
export * from "./search"
|
||||
export * from "./shared-context"
|
||||
export * from "./stock-location"
|
||||
export * from "./transaction-base"
|
||||
export * from "./workflow"
|
||||
|
||||
|
||||
@@ -1,11 +1,60 @@
|
||||
export type RegionDTO = {
|
||||
import { BaseFilterable } from "../dal"
|
||||
|
||||
export interface RegionDTO {
|
||||
id: string
|
||||
name: string
|
||||
currency_code: string
|
||||
tax_rate?: number
|
||||
tax_code?: string | null
|
||||
gift_cards_taxable?: boolean
|
||||
automatic_taxes?: boolean
|
||||
tax_provider_id?: string | null
|
||||
metadata?: Record<string, unknown>
|
||||
includes_tax?: boolean
|
||||
currency: RegionCurrencyDTO
|
||||
countries: CountryDTO[]
|
||||
}
|
||||
|
||||
export interface CountryDTO {
|
||||
id: string
|
||||
iso_2: string
|
||||
iso_3: string
|
||||
num_code: number
|
||||
name: string
|
||||
display_name: string
|
||||
}
|
||||
|
||||
export interface FilterableRegionProps
|
||||
extends BaseFilterable<FilterableRegionProps> {
|
||||
id?: string[]
|
||||
name?: string[]
|
||||
}
|
||||
|
||||
export interface RegionCountryDTO {
|
||||
id: string
|
||||
iso_2: string
|
||||
iso_3: string
|
||||
num_code: number
|
||||
name: string
|
||||
display_name: string
|
||||
}
|
||||
|
||||
export interface RegionCurrencyDTO {
|
||||
id: string
|
||||
code: string
|
||||
symbol: string
|
||||
name: string
|
||||
symbol_native: string
|
||||
}
|
||||
|
||||
export interface FilterableRegionCurrencyProps
|
||||
extends BaseFilterable<FilterableRegionCurrencyProps> {
|
||||
id?: string[] | string
|
||||
code?: string[] | string
|
||||
symbol?: string[] | string
|
||||
name?: string[] | string
|
||||
symbol_native?: string[] | string
|
||||
}
|
||||
|
||||
export interface FilterableRegionCountryProps
|
||||
extends BaseFilterable<FilterableRegionCountryProps> {
|
||||
id?: string[] | string
|
||||
iso_2?: string[] | string
|
||||
iso_3?: string[] | string
|
||||
num_code?: number[] | string
|
||||
name?: string[] | string
|
||||
display_name?: string[] | string
|
||||
}
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
export * from "./common"
|
||||
export * from "./mutations"
|
||||
export * from "./service"
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { RegionCurrencyDTO } from "./common"
|
||||
|
||||
export interface CreateRegionDTO {
|
||||
name: string
|
||||
currency_code: string
|
||||
currency?: RegionCurrencyDTO
|
||||
tax_code?: string
|
||||
tax_rate?: number
|
||||
tax_provider_id?: string
|
||||
}
|
||||
|
||||
export interface UpdateRegionDTO {
|
||||
id: string
|
||||
currency_code?: string
|
||||
currency?: RegionCurrencyDTO
|
||||
name?: string
|
||||
tax_code?: string
|
||||
tax_rate?: number
|
||||
tax_provider_id?: string
|
||||
}
|
||||
|
||||
export interface AddCountryToRegionDTO {
|
||||
region_id: string
|
||||
country_id: string
|
||||
}
|
||||
|
||||
export interface RemoveCountryFromRegionDTO extends AddCountryToRegionDTO {}
|
||||
@@ -0,0 +1,92 @@
|
||||
import { FindConfig } from "../common"
|
||||
import { RestoreReturn, SoftDeleteReturn } from "../dal"
|
||||
import { IModuleService } from "../modules-sdk"
|
||||
import { Context } from "../shared-context"
|
||||
import {
|
||||
FilterableRegionCountryProps,
|
||||
FilterableRegionCurrencyProps,
|
||||
FilterableRegionProps,
|
||||
RegionCountryDTO,
|
||||
RegionCurrencyDTO,
|
||||
RegionDTO,
|
||||
} from "./common"
|
||||
import { CreateRegionDTO, UpdateRegionDTO } from "./mutations"
|
||||
|
||||
export interface IRegionModuleService extends IModuleService {
|
||||
create(data: CreateRegionDTO[], sharedContext?: Context): Promise<RegionDTO[]>
|
||||
create(data: CreateRegionDTO, sharedContext?: Context): Promise<RegionDTO>
|
||||
|
||||
update(data: UpdateRegionDTO[], sharedContext?: Context): Promise<RegionDTO[]>
|
||||
update(data: UpdateRegionDTO, sharedContext?: Context): Promise<RegionDTO>
|
||||
|
||||
delete(ids: string[], sharedContext?: Context): Promise<void>
|
||||
delete(id: string, sharedContext?: Context): Promise<void>
|
||||
|
||||
retrieve(
|
||||
id: string,
|
||||
config?: FindConfig<RegionDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<RegionDTO>
|
||||
|
||||
list(
|
||||
filters?: FilterableRegionProps,
|
||||
config?: FindConfig<RegionDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<RegionDTO[]>
|
||||
|
||||
listAndCount(
|
||||
filters?: FilterableRegionProps,
|
||||
config?: FindConfig<RegionDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<[RegionDTO[], number]>
|
||||
|
||||
retrieveCountry(
|
||||
countryId: string,
|
||||
config?: FindConfig<RegionCountryDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<RegionCountryDTO>
|
||||
|
||||
listCountries(
|
||||
filters?: FilterableRegionCountryProps,
|
||||
config?: FindConfig<RegionCountryDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<RegionCountryDTO[]>
|
||||
|
||||
retrieveCurrency(
|
||||
currencyId: string,
|
||||
config?: FindConfig<RegionCountryDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<RegionCurrencyDTO>
|
||||
|
||||
listAndCountCountries(
|
||||
filters?: FilterableRegionCountryProps,
|
||||
config?: FindConfig<RegionCountryDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<[RegionCountryDTO[], number]>
|
||||
|
||||
listCurrencies(
|
||||
filters?: FilterableRegionCurrencyProps,
|
||||
config?: FindConfig<RegionCurrencyDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<RegionCurrencyDTO[]>
|
||||
|
||||
listAndCountCurrencies(
|
||||
filters?: FilterableRegionCurrencyProps,
|
||||
config?: FindConfig<RegionCurrencyDTO>,
|
||||
sharedContext?: Context
|
||||
): Promise<[RegionCurrencyDTO[], number]>
|
||||
|
||||
softDelete<TReturnableLinkableKeys extends string = string>(
|
||||
regionIds: string[],
|
||||
config?: SoftDeleteReturn<TReturnableLinkableKeys>,
|
||||
sharedContext?: Context
|
||||
): Promise<Record<string, string[]> | void>
|
||||
|
||||
restore<TReturnableLinkableKeys extends string = string>(
|
||||
regionIds: string[],
|
||||
config?: RestoreReturn<TReturnableLinkableKeys>,
|
||||
sharedContext?: Context
|
||||
): Promise<Record<string, string[]> | void>
|
||||
|
||||
createDefaultCountriesAndCurrencies(sharedContext?: Context): Promise<void>
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
export type RegionDTO__legacy = {
|
||||
name: string
|
||||
currency_code: string
|
||||
tax_rate?: number
|
||||
tax_code?: string | null
|
||||
gift_cards_taxable?: boolean
|
||||
automatic_taxes?: boolean
|
||||
tax_provider_id?: string | null
|
||||
metadata?: Record<string, unknown>
|
||||
includes_tax?: boolean
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export * from "./common"
|
||||
Reference in New Issue
Block a user