feat: Add tax region + rates to SDK and types (#7635)
* feat: Add tax region + rates to SDK and types * replace client with sdk in loaders * Address PR feedback
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
AdminPostTaxRatesReq,
|
||||
AdminPostTaxRatesTaxRateReq,
|
||||
} from "@medusajs/medusa"
|
||||
import { AdminTaxRateListResponse, AdminTaxRateResponse } from "@medusajs/types"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
QueryKey,
|
||||
UseMutationOptions,
|
||||
@@ -10,10 +6,9 @@ import {
|
||||
useMutation,
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import { client } from "../../lib/client"
|
||||
import { sdk } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import { TaxRateDeleteRes } from "../../types/api-responses"
|
||||
|
||||
const TAX_RATES_QUERY_KEY = "tax_rates" as const
|
||||
export const taxRatesQueryKeys = queryKeysFactory(TAX_RATES_QUERY_KEY)
|
||||
@@ -23,9 +18,9 @@ export const useTaxRate = (
|
||||
query?: Record<string, any>,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
AdminTaxRateResponse,
|
||||
HttpTypes.AdminTaxRateResponse,
|
||||
Error,
|
||||
AdminTaxRateResponse,
|
||||
HttpTypes.AdminTaxRateResponse,
|
||||
QueryKey
|
||||
>,
|
||||
"queryFn" | "queryKey"
|
||||
@@ -33,7 +28,7 @@ export const useTaxRate = (
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryKey: taxRatesQueryKeys.detail(id),
|
||||
queryFn: async () => client.taxes.retrieveTaxRate(id, query),
|
||||
queryFn: async () => sdk.admin.taxRate.retrieve(id, query),
|
||||
...options,
|
||||
})
|
||||
|
||||
@@ -44,16 +39,16 @@ export const useTaxRates = (
|
||||
query?: Record<string, any>,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
AdminTaxRateListResponse,
|
||||
HttpTypes.AdminTaxRateListResponse,
|
||||
Error,
|
||||
AdminTaxRateListResponse,
|
||||
HttpTypes.AdminTaxRateListResponse,
|
||||
QueryKey
|
||||
>,
|
||||
"queryFn" | "queryKey"
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryFn: () => client.taxes.listTaxRates(query),
|
||||
queryFn: () => sdk.admin.taxRate.list(query),
|
||||
queryKey: taxRatesQueryKeys.list(query),
|
||||
...options,
|
||||
})
|
||||
@@ -64,13 +59,13 @@ export const useTaxRates = (
|
||||
export const useUpdateTaxRate = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<
|
||||
AdminTaxRateResponse,
|
||||
HttpTypes.AdminTaxRateResponse,
|
||||
Error,
|
||||
AdminPostTaxRatesTaxRateReq
|
||||
HttpTypes.AdminUpdateTaxRate
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload) => client.taxes.updateTaxRate(id, payload),
|
||||
mutationFn: (payload) => sdk.admin.taxRate.update(id, payload),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({ queryKey: taxRatesQueryKeys.lists() })
|
||||
queryClient.invalidateQueries({
|
||||
@@ -85,13 +80,13 @@ export const useUpdateTaxRate = (
|
||||
|
||||
export const useCreateTaxRate = (
|
||||
options?: UseMutationOptions<
|
||||
AdminTaxRateResponse,
|
||||
HttpTypes.AdminTaxRateResponse,
|
||||
Error,
|
||||
AdminPostTaxRatesReq
|
||||
HttpTypes.AdminCreateTaxRate
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload) => client.taxes.createTaxRate(payload),
|
||||
mutationFn: (payload) => sdk.admin.taxRate.create(payload),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({ queryKey: taxRatesQueryKeys.lists() })
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
@@ -102,10 +97,14 @@ export const useCreateTaxRate = (
|
||||
|
||||
export const useDeleteTaxRate = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<TaxRateDeleteRes, Error, void>
|
||||
options?: UseMutationOptions<
|
||||
HttpTypes.AdminTaxRateDeleteResponse,
|
||||
Error,
|
||||
void
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: () => client.taxes.deleteTaxRate(id),
|
||||
mutationFn: () => sdk.admin.taxRate.delete(id),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({ queryKey: taxRatesQueryKeys.lists() })
|
||||
queryClient.invalidateQueries({
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import { AdminCreateTaxRegion } from "@medusajs/medusa"
|
||||
import {
|
||||
AdminTaxRegionListResponse,
|
||||
AdminTaxRegionResponse,
|
||||
} from "@medusajs/types"
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import {
|
||||
QueryKey,
|
||||
UseMutationOptions,
|
||||
@@ -10,10 +6,9 @@ import {
|
||||
useMutation,
|
||||
useQuery,
|
||||
} from "@tanstack/react-query"
|
||||
import { client } from "../../lib/client"
|
||||
import { sdk } from "../../lib/client"
|
||||
import { queryClient } from "../../lib/query-client"
|
||||
import { queryKeysFactory } from "../../lib/query-key-factory"
|
||||
import { TaxRegionDeleteRes } from "../../types/api-responses"
|
||||
|
||||
const TAX_REGIONS_QUERY_KEY = "tax_regions" as const
|
||||
export const taxRegionsQueryKeys = queryKeysFactory(TAX_REGIONS_QUERY_KEY)
|
||||
@@ -23,9 +18,9 @@ export const useTaxRegion = (
|
||||
query?: Record<string, any>,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
AdminTaxRegionResponse,
|
||||
HttpTypes.AdminTaxRegionResponse,
|
||||
Error,
|
||||
AdminTaxRegionResponse,
|
||||
HttpTypes.AdminTaxRegionResponse,
|
||||
QueryKey
|
||||
>,
|
||||
"queryFn" | "queryKey"
|
||||
@@ -33,7 +28,7 @@ export const useTaxRegion = (
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryKey: taxRegionsQueryKeys.detail(id),
|
||||
queryFn: async () => client.taxes.retrieveTaxRegion(id, query),
|
||||
queryFn: async () => sdk.admin.taxRegion.retrieve(id, query),
|
||||
...options,
|
||||
})
|
||||
|
||||
@@ -44,16 +39,16 @@ export const useTaxRegions = (
|
||||
query?: Record<string, any>,
|
||||
options?: Omit<
|
||||
UseQueryOptions<
|
||||
AdminTaxRegionListResponse,
|
||||
HttpTypes.AdminTaxRegionListResponse,
|
||||
Error,
|
||||
AdminTaxRegionListResponse,
|
||||
HttpTypes.AdminTaxRegionListResponse,
|
||||
QueryKey
|
||||
>,
|
||||
"queryFn" | "queryKey"
|
||||
>
|
||||
) => {
|
||||
const { data, ...rest } = useQuery({
|
||||
queryFn: () => client.taxes.listTaxRegions(query),
|
||||
queryFn: () => sdk.admin.taxRegion.list(query),
|
||||
queryKey: taxRegionsQueryKeys.list(query),
|
||||
...options,
|
||||
})
|
||||
@@ -63,13 +58,13 @@ export const useTaxRegions = (
|
||||
|
||||
export const useCreateTaxRegion = (
|
||||
options?: UseMutationOptions<
|
||||
AdminTaxRegionResponse,
|
||||
HttpTypes.AdminTaxRegionResponse,
|
||||
Error,
|
||||
AdminCreateTaxRegion
|
||||
HttpTypes.AdminCreateTaxRegion
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: (payload) => client.taxes.createTaxRegion(payload),
|
||||
mutationFn: (payload) => sdk.admin.taxRegion.create(payload),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({ queryKey: taxRegionsQueryKeys.all })
|
||||
options?.onSuccess?.(data, variables, context)
|
||||
@@ -80,10 +75,14 @@ export const useCreateTaxRegion = (
|
||||
|
||||
export const useDeleteTaxRegion = (
|
||||
id: string,
|
||||
options?: UseMutationOptions<TaxRegionDeleteRes, Error, void>
|
||||
options?: UseMutationOptions<
|
||||
HttpTypes.AdminTaxRegionDeleteResponse,
|
||||
Error,
|
||||
void
|
||||
>
|
||||
) => {
|
||||
return useMutation({
|
||||
mutationFn: () => client.taxes.deleteTaxRegion(id),
|
||||
mutationFn: () => sdk.admin.taxRegion.delete(id),
|
||||
onSuccess: (data, variables, context) => {
|
||||
queryClient.invalidateQueries({ queryKey: taxRegionsQueryKeys.lists() })
|
||||
queryClient.invalidateQueries({
|
||||
|
||||
@@ -20,7 +20,6 @@ import { shippingProfiles } from "./shipping-profiles"
|
||||
import { stockLocations } from "./stock-locations"
|
||||
import { stores } from "./stores"
|
||||
import { tags } from "./tags"
|
||||
import { taxes } from "./taxes"
|
||||
import { users } from "./users"
|
||||
import { workflowExecutions } from "./workflow-executions"
|
||||
|
||||
@@ -40,7 +39,6 @@ export const client = {
|
||||
shippingProfiles: shippingProfiles,
|
||||
productTags: tags,
|
||||
users: users,
|
||||
taxes: taxes,
|
||||
invites: invites,
|
||||
inventoryItems: inventoryItems,
|
||||
reservations: reservations,
|
||||
|
||||
@@ -1,59 +0,0 @@
|
||||
import {
|
||||
AdminCreateTaxRegion,
|
||||
AdminPostTaxRatesTaxRateReq,
|
||||
} from "@medusajs/medusa"
|
||||
import {
|
||||
AdminTaxRateResponse,
|
||||
AdminTaxRegionListResponse,
|
||||
AdminTaxRegionResponse,
|
||||
} from "@medusajs/types"
|
||||
import { TaxRateDeleteRes, TaxRegionDeleteRes } from "../../types/api-responses"
|
||||
import { deleteRequest, getRequest, postRequest } from "./common"
|
||||
|
||||
async function retrieveTaxRegion(id: string, query?: Record<string, any>) {
|
||||
return getRequest<AdminTaxRegionResponse>(`/admin/tax-regions/${id}`, query)
|
||||
}
|
||||
|
||||
async function listTaxRegions(query?: Record<string, any>) {
|
||||
return getRequest<AdminTaxRegionListResponse>(`/admin/tax-regions`, query)
|
||||
}
|
||||
|
||||
async function createTaxRegion(payload: AdminCreateTaxRegion) {
|
||||
return postRequest<AdminTaxRegionResponse>(`/admin/tax-regions`, payload)
|
||||
}
|
||||
|
||||
async function deleteTaxRegion(id: string) {
|
||||
return deleteRequest<TaxRegionDeleteRes>(`/admin/tax-regions/${id}`)
|
||||
}
|
||||
|
||||
async function retrieveTaxRate(id: string, query?: Record<string, any>) {
|
||||
return getRequest<AdminTaxRegionResponse>(`/admin/tax-rates/${id}`, query)
|
||||
}
|
||||
|
||||
async function listTaxRates(query?: Record<string, any>) {
|
||||
return getRequest<AdminTaxRegionListResponse>(`/admin/tax-rates`, query)
|
||||
}
|
||||
|
||||
async function updateTaxRate(id: string, payload: AdminPostTaxRatesTaxRateReq) {
|
||||
return postRequest<AdminTaxRateResponse>(`/admin/tax-rates/${id}`, payload)
|
||||
}
|
||||
|
||||
async function createTaxRate(payload: AdminCreateTaxRate) {
|
||||
return postRequest<AdminTaxRateResponse>(`/admin/tax-rates`, payload)
|
||||
}
|
||||
|
||||
async function deleteTaxRate(id: string) {
|
||||
return deleteRequest<TaxRateDeleteRes>(`/admin/tax-rates/${id}`)
|
||||
}
|
||||
|
||||
export const taxes = {
|
||||
retrieveTaxRegion,
|
||||
listTaxRegions,
|
||||
retrieveTaxRate,
|
||||
listTaxRates,
|
||||
updateTaxRate,
|
||||
createTaxRegion,
|
||||
deleteTaxRegion,
|
||||
createTaxRate,
|
||||
deleteTaxRate,
|
||||
}
|
||||
@@ -1,13 +1,12 @@
|
||||
import { LoaderFunctionArgs } from "react-router-dom"
|
||||
|
||||
import { AdminTaxRateResponse } from "@medusajs/types"
|
||||
import { LoaderFunctionArgs } from "react-router-dom"
|
||||
import { taxRatesQueryKeys } from "../../../hooks/api/tax-rates"
|
||||
import { client } from "../../../lib/client"
|
||||
import { sdk } from "../../../lib/client"
|
||||
import { queryClient } from "../../../lib/query-client"
|
||||
|
||||
const taxRateDetailQuery = (id: string) => ({
|
||||
queryKey: taxRatesQueryKeys.detail(id),
|
||||
queryFn: async () => client.taxes.retrieveTaxRate(id),
|
||||
queryFn: async () => sdk.admin.taxRate.retrieve(id),
|
||||
})
|
||||
|
||||
export const taxRateLoader = async ({ params }: LoaderFunctionArgs) => {
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import { LoaderFunctionArgs } from "react-router-dom"
|
||||
|
||||
import { AdminTaxRegionResponse } from "@medusajs/types"
|
||||
import { LoaderFunctionArgs } from "react-router-dom"
|
||||
import { taxRegionsQueryKeys } from "../../../hooks/api/tax-regions"
|
||||
import { client } from "../../../lib/client"
|
||||
import { sdk } from "../../../lib/client"
|
||||
import { queryClient } from "../../../lib/query-client"
|
||||
|
||||
const taxRegionDetailQuery = (id: string) => ({
|
||||
queryKey: taxRegionsQueryKeys.detail(id),
|
||||
queryFn: async () => client.taxes.retrieveTaxRegion(id),
|
||||
queryFn: async () => sdk.admin.taxRegion.retrieve(id),
|
||||
})
|
||||
|
||||
export const taxRegionLoader = async ({ params }: LoaderFunctionArgs) => {
|
||||
|
||||
@@ -11,6 +11,8 @@ import { SalesChannel } from "./sales-channel"
|
||||
import { ShippingOption } from "./shipping-option"
|
||||
import { ShippingProfile } from "./shipping-profile"
|
||||
import { StockLocation } from "./stock-location"
|
||||
import { TaxRate } from "./tax-rate"
|
||||
import { TaxRegion } from "./tax-region"
|
||||
import { Upload } from "./upload"
|
||||
|
||||
export class Admin {
|
||||
@@ -27,6 +29,8 @@ export class Admin {
|
||||
public shippingOption: ShippingOption
|
||||
public shippingProfile: ShippingProfile
|
||||
public order: Order
|
||||
public taxRate: TaxRate
|
||||
public taxRegion: TaxRegion
|
||||
|
||||
constructor(client: Client) {
|
||||
this.invite = new Invite(client)
|
||||
@@ -42,5 +46,7 @@ export class Admin {
|
||||
this.shippingOption = new ShippingOption(client)
|
||||
this.shippingProfile = new ShippingProfile(client)
|
||||
this.order = new Order(client)
|
||||
this.taxRate = new TaxRate(client)
|
||||
this.taxRegion = new TaxRegion(client)
|
||||
}
|
||||
}
|
||||
|
||||
81
packages/core/js-sdk/src/admin/tax-rate.ts
Normal file
81
packages/core/js-sdk/src/admin/tax-rate.ts
Normal file
@@ -0,0 +1,81 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { Client } from "../client"
|
||||
import { ClientHeaders } from "../types"
|
||||
|
||||
const taxRateUrl = "/admin/tax-rates"
|
||||
|
||||
export class TaxRate {
|
||||
private client: Client
|
||||
constructor(client: Client) {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateTaxRate,
|
||||
query?: HttpTypes.SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminTaxRateResponse>(taxRateUrl, {
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
})
|
||||
}
|
||||
|
||||
async update(
|
||||
id: string,
|
||||
body: HttpTypes.AdminUpdateTaxRate,
|
||||
query?: HttpTypes.SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminTaxRateResponse>(
|
||||
`${taxRateUrl}/${id}`,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminTaxRateDeleteResponse>(
|
||||
`${taxRateUrl}/${id}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminTaxRateResponse>(
|
||||
`${taxRateUrl}/${id}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async list(
|
||||
query?: HttpTypes.AdminTaxRateListParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminTaxRateListResponse>(
|
||||
taxRateUrl,
|
||||
{
|
||||
method: "GET",
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
68
packages/core/js-sdk/src/admin/tax-region.ts
Normal file
68
packages/core/js-sdk/src/admin/tax-region.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
import { HttpTypes } from "@medusajs/types"
|
||||
import { Client } from "../client"
|
||||
import { ClientHeaders } from "../types"
|
||||
|
||||
const taxRegionUrl = "/admin/tax-regions"
|
||||
|
||||
// TODO: Add support for updating a tax region
|
||||
export class TaxRegion {
|
||||
private client: Client
|
||||
constructor(client: Client) {
|
||||
this.client = client
|
||||
}
|
||||
|
||||
async create(
|
||||
body: HttpTypes.AdminCreateTaxRegion,
|
||||
query?: HttpTypes.SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminTaxRegionResponse>(
|
||||
taxRegionUrl,
|
||||
{
|
||||
method: "POST",
|
||||
headers,
|
||||
body,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async delete(id: string, headers?: ClientHeaders) {
|
||||
return await this.client.fetch<HttpTypes.AdminTaxRegionDeleteResponse>(
|
||||
`${taxRegionUrl}/${id}`,
|
||||
{
|
||||
method: "DELETE",
|
||||
headers,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async retrieve(
|
||||
id: string,
|
||||
query?: HttpTypes.SelectParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminTaxRegionResponse>(
|
||||
`${taxRegionUrl}/${id}`,
|
||||
{
|
||||
method: "GET",
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async list(
|
||||
query?: HttpTypes.AdminTaxRegionListParams,
|
||||
headers?: ClientHeaders
|
||||
) {
|
||||
return await this.client.fetch<HttpTypes.AdminTaxRegionListResponse>(
|
||||
taxRegionUrl,
|
||||
{
|
||||
method: "GET",
|
||||
headers,
|
||||
query,
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -22,5 +22,7 @@ export * from "./sales-channel"
|
||||
export * from "./shipping-option"
|
||||
export * from "./shipping-profile"
|
||||
export * from "./stock-locations"
|
||||
export * from "./tax"
|
||||
export * from "./tax-rate"
|
||||
export * from "./tax-region"
|
||||
export * from "./user"
|
||||
|
||||
|
||||
23
packages/core/types/src/http/tax-rate/admin/entities.ts
Normal file
23
packages/core/types/src/http/tax-rate/admin/entities.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import { AdminTaxRegion } from "../../tax-region"
|
||||
|
||||
export interface AdminTaxRateRule {
|
||||
reference: string
|
||||
reference_id: string
|
||||
}
|
||||
|
||||
export interface AdminTaxRate {
|
||||
id: string
|
||||
rate: number | null
|
||||
code: string | null
|
||||
name: string
|
||||
metadata: Record<string, unknown> | null
|
||||
tax_region_id: string
|
||||
is_combinable: boolean
|
||||
is_default: boolean
|
||||
created_at: string
|
||||
updated_at: string
|
||||
deleted_at: null
|
||||
created_by: string | null
|
||||
tax_region: AdminTaxRegion
|
||||
rules: AdminTaxRateRule[]
|
||||
}
|
||||
4
packages/core/types/src/http/tax-rate/admin/index.ts
Normal file
4
packages/core/types/src/http/tax-rate/admin/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from "./entities"
|
||||
export * from "./payloads"
|
||||
export * from "./queries"
|
||||
export * from "./responses"
|
||||
25
packages/core/types/src/http/tax-rate/admin/payloads.ts
Normal file
25
packages/core/types/src/http/tax-rate/admin/payloads.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
interface AdminCreateTaxRateRule {
|
||||
reference: string
|
||||
reference_id: string
|
||||
}
|
||||
|
||||
export interface AdminCreateTaxRate {
|
||||
name: string
|
||||
tax_region_id: string
|
||||
rate?: number
|
||||
code?: string
|
||||
rules?: AdminCreateTaxRateRule[]
|
||||
is_default?: boolean
|
||||
is_combinable?: boolean
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
export interface AdminUpdateTaxRate {
|
||||
name?: string
|
||||
rate?: number
|
||||
code?: string
|
||||
rules?: AdminCreateTaxRateRule[]
|
||||
is_default?: boolean
|
||||
is_combinable?: boolean
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
16
packages/core/types/src/http/tax-rate/admin/queries.ts
Normal file
16
packages/core/types/src/http/tax-rate/admin/queries.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { OperatorMap } from "../../../dal"
|
||||
import { FindParams } from "../../common"
|
||||
|
||||
export interface AdminTaxRateListParams extends FindParams {
|
||||
id?: string | string[]
|
||||
q?: string
|
||||
tax_region_id?: string | string[] | OperatorMap<string | string[]>
|
||||
is_default?: string
|
||||
service_zone_id?: string
|
||||
shipping_profile_id?: string
|
||||
provider_id?: string
|
||||
shipping_option_type_id?: string
|
||||
created_at?: string | OperatorMap<string>
|
||||
updated_at?: string | OperatorMap<string>
|
||||
deleted_at?: string | OperatorMap<string>
|
||||
}
|
||||
13
packages/core/types/src/http/tax-rate/admin/responses.ts
Normal file
13
packages/core/types/src/http/tax-rate/admin/responses.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { DeleteResponse, PaginatedResponse } from "../../common"
|
||||
import { AdminTaxRate } from "./entities"
|
||||
|
||||
export interface AdminTaxRateResponse {
|
||||
tax_rate: AdminTaxRate
|
||||
}
|
||||
|
||||
export type AdminTaxRateListResponse = PaginatedResponse<{
|
||||
tax_rates: AdminTaxRate[]
|
||||
}>
|
||||
|
||||
export interface AdminTaxRateDeleteResponse
|
||||
extends DeleteResponse<"tax_rate"> {}
|
||||
21
packages/core/types/src/http/tax-region/admin/entities.ts
Normal file
21
packages/core/types/src/http/tax-region/admin/entities.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { AdminTaxRate } from "../../tax-rate"
|
||||
|
||||
export interface AdminTaxRegion {
|
||||
id: string
|
||||
rate: number | null
|
||||
code: string | null
|
||||
country_code: string | null
|
||||
province_code: string | null
|
||||
name: string
|
||||
metadata: Record<string, unknown> | null
|
||||
tax_region_id: string
|
||||
is_combinable: boolean
|
||||
is_default: boolean
|
||||
parent_id: string | null
|
||||
created_at: string
|
||||
updated_at: string
|
||||
deleted_at: string | null
|
||||
created_by: string | null
|
||||
tax_rates: AdminTaxRate[]
|
||||
parent: AdminTaxRegion
|
||||
}
|
||||
4
packages/core/types/src/http/tax-region/admin/index.ts
Normal file
4
packages/core/types/src/http/tax-region/admin/index.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export * from "./entities"
|
||||
export * from "./payloads"
|
||||
export * from "./queries"
|
||||
export * from "./responses"
|
||||
13
packages/core/types/src/http/tax-region/admin/payloads.ts
Normal file
13
packages/core/types/src/http/tax-region/admin/payloads.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export interface AdminCreateTaxRegion {
|
||||
country_code: string
|
||||
province_code?: string
|
||||
parent_id?: string
|
||||
default_tax_rate?: {
|
||||
rate?: number
|
||||
code?: string
|
||||
name: string
|
||||
is_combinable?: boolean
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
14
packages/core/types/src/http/tax-region/admin/queries.ts
Normal file
14
packages/core/types/src/http/tax-region/admin/queries.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { OperatorMap } from "../../../dal"
|
||||
import { FindParams } from "../../common"
|
||||
|
||||
export interface AdminTaxRegionListParams extends FindParams {
|
||||
id?: string | string[]
|
||||
q?: string
|
||||
parent_id?: string | string[] | OperatorMap<string | string[]>
|
||||
country_code?: string | string[] | OperatorMap<string | string[]>
|
||||
province_code?: string | string[] | OperatorMap<string | string[]>
|
||||
created_at?: string | OperatorMap<string>
|
||||
updated_at?: string | OperatorMap<string>
|
||||
deleted_at?: string | OperatorMap<string>
|
||||
created_by?: string | OperatorMap<string>
|
||||
}
|
||||
13
packages/core/types/src/http/tax-region/admin/responses.ts
Normal file
13
packages/core/types/src/http/tax-region/admin/responses.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { DeleteResponse, PaginatedResponse } from "../../common"
|
||||
import { AdminTaxRegion } from "./entities"
|
||||
|
||||
export interface AdminTaxRegionResponse {
|
||||
tax_region: AdminTaxRegion
|
||||
}
|
||||
|
||||
export type AdminTaxRegionListResponse = PaginatedResponse<{
|
||||
tax_regions: AdminTaxRegion[]
|
||||
}>
|
||||
|
||||
export interface AdminTaxRegionDeleteResponse
|
||||
extends DeleteResponse<"tax_region"> {}
|
||||
1
packages/core/types/src/http/tax-region/index.ts
Normal file
1
packages/core/types/src/http/tax-region/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export * from "./admin"
|
||||
@@ -1,2 +0,0 @@
|
||||
export * from "./tax-rates"
|
||||
export * from "./tax-regions"
|
||||
@@ -1,30 +0,0 @@
|
||||
import { PaginatedResponse } from "../../common"
|
||||
import { TaxRegionResponse } from "./tax-regions"
|
||||
|
||||
export interface TaxRateResponse {
|
||||
id: string
|
||||
rate: number | null
|
||||
code: string | null
|
||||
name: string
|
||||
metadata: Record<string, unknown> | null
|
||||
tax_region_id: string
|
||||
is_combinable: boolean
|
||||
is_default: boolean
|
||||
created_at: string | Date
|
||||
updated_at: string | Date
|
||||
deleted_at: Date | null
|
||||
created_by: string | null
|
||||
tax_region: TaxRegionResponse
|
||||
rules: {
|
||||
reference: string
|
||||
reference_id: string
|
||||
}[]
|
||||
}
|
||||
|
||||
export interface AdminTaxRateResponse {
|
||||
tax_rate: TaxRateResponse
|
||||
}
|
||||
|
||||
export type AdminTaxRateListResponse = PaginatedResponse<{
|
||||
tax_rates: TaxRateResponse[]
|
||||
}>
|
||||
@@ -1,32 +0,0 @@
|
||||
import { PaginatedResponse } from "../../common"
|
||||
import { TaxRateResponse } from "./tax-rates"
|
||||
|
||||
export interface TaxRegionResponse {
|
||||
id: string
|
||||
rate: number | null
|
||||
code: string | null
|
||||
country_code: string | null
|
||||
province_code: string | null
|
||||
name: string
|
||||
metadata: Record<string, unknown> | null
|
||||
tax_region_id: string
|
||||
is_combinable: boolean
|
||||
is_default: boolean
|
||||
parent_id: string | null
|
||||
created_at: string | Date
|
||||
updated_at: string | Date
|
||||
deleted_at: Date | null
|
||||
created_by: string | null
|
||||
|
||||
tax_rates: TaxRateResponse[]
|
||||
|
||||
parent: TaxRegionResponse
|
||||
}
|
||||
|
||||
export interface AdminTaxRegionResponse {
|
||||
tax_region: TaxRegionResponse
|
||||
}
|
||||
|
||||
export type AdminTaxRegionListResponse = PaginatedResponse<{
|
||||
tax_regions: TaxRegionResponse[]
|
||||
}>
|
||||
Reference in New Issue
Block a user