chore(types, medusa): [3/3] add missing query type arguments (#8880)

Add missing type arguments in listing requests.

3/3
This commit is contained in:
Shahed Nasser
2024-08-30 10:07:18 +03:00
committed by GitHub
parent e0cb5ff0aa
commit 9f495fd853
34 changed files with 114 additions and 77 deletions

View File

@@ -1,3 +1,6 @@
import { OperatorMap } from "../../../dal";
import { BaseCollectionListParams } from "../common";
export interface StoreCollectionFilters extends BaseCollectionListParams {}
export interface StoreCollectionFilters extends Omit<BaseCollectionListParams, "id"> {
deleted_at?: OperatorMap<string>
}

View File

@@ -1,2 +1,3 @@
export * from "./entities"
export * from "./queries"
export * from "./responses"

View File

@@ -0,0 +1,8 @@
import { BaseFilterable } from "../../../dal";
import { FindParams } from "../../common";
export interface StoreGetCurrencyListParams extends
FindParams, BaseFilterable<StoreGetCurrencyListParams> {
q?: string
code?: string | string[]
}

View File

@@ -1,3 +1,8 @@
import { BaseOrderFilters } from "../common";
import { BaseFilterable } from "../../../dal";
import { FindParams } from "../../common";
export interface StoreOrderFilters extends BaseOrderFilters {}
export interface StoreOrderFilters extends
FindParams, BaseFilterable<StoreOrderFilters> {
id?: string | string[]
name?: string | string[]
}

View File

@@ -1,3 +1,4 @@
export * from "./entities"
export * from "./payloads"
export * from "./queries"
export * from "./responses"

View File

@@ -0,0 +1,3 @@
export interface StoreCreatePaymentCollection {
cart_id: string
}

View File

@@ -5,7 +5,9 @@ import {
} from "../common"
export interface StorePaymentProviderFilters
extends BasePaymentProviderFilters {}
extends BasePaymentProviderFilters {
is_enabled?: boolean
}
export interface StorePaymentCollectionFilters
extends BasePaymentCollectionFilters {}
export interface StorePaymentSessionFilters extends BasePaymentSessionFilters {}

View File

@@ -11,4 +11,5 @@ export interface StoreProductParams extends BaseProductListParams {
region_id?: string
currency_code?: string
variants?: StoreProductVariantParams
province?: string
}

View File

@@ -25,9 +25,8 @@ export interface BaseRegionCountry {
export interface BaseRegionFilters extends BaseFilterable<BaseRegionFilters> {
q?: string
id?: string[] | string | OperatorMap<string | string[]>
name?: string | OperatorMap<string>
currency_code?: string | OperatorMap<string>
metadata?: Record<string, unknown> | OperatorMap<Record<string, unknown>>
name?: string | string[]
code?: string | string[]
created_at?: OperatorMap<string>
updated_at?: OperatorMap<string>
}

View File

@@ -1,2 +1,3 @@
export * from "./entities"
export * from "./payloads"
export * from "./responses"

View File

@@ -0,0 +1,20 @@
interface StoreCreateReturnItem {
id: string
quantity: number
reason_id?: string | null
note?: string | null
}
interface StoreCreateReturnShipping {
option_id: string
price?: number
}
export interface StoreCreateReturn {
order_id: string
items: StoreCreateReturnItem[]
return_shipping: StoreCreateReturnShipping
note?: string | null
receive_now?: boolean
location_id?: string | null
}

View File

@@ -1,2 +1,3 @@
export * from "./entities"
export * from "./queries"
export * from "./responses"

View File

@@ -0,0 +1,7 @@
import { BaseFilterable } from "../../../dal";
import { FindParams } from "../../common";
export interface StoreGetShippingOptionList extends
FindParams, BaseFilterable<StoreGetShippingOptionList> {
cart_id: string
}

View File

@@ -1,11 +1,16 @@
import { BaseFilterable, OperatorMap } from "../../../dal"
import { FindParams } from "../../common"
export interface AdminStockLocationListParams extends FindParams {
id?: string | string[]
q?: string
name?: string | string[]
address_id?: string | string[]
sales_channel_id?: string | string[]
$and?: AdminStockLocationListParams[]
$or?: AdminStockLocationListParams[]
}
export interface AdminStockLocationListParams extends
FindParams, BaseFilterable<AdminStockLocationListParams> {
id?: string | string[]
q?: string
name?: string | string[]
address_id?: string | string[]
sales_channel_id?: string | string[]
$and?: AdminStockLocationListParams[]
$or?: AdminStockLocationListParams[]
created_at?: OperatorMap<string>
updated_at?: OperatorMap<string>
deleted_at?: OperatorMap<string>
}

View File

@@ -1,16 +1,16 @@
import { OperatorMap } from "../../../dal"
import { BaseFilterable, 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>
}
export interface AdminTaxRateListParams extends
FindParams, BaseFilterable<AdminTaxRateListParams> {
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?: OperatorMap<string>
updated_at?: OperatorMap<string>
deleted_at?: OperatorMap<string>
}

View File

@@ -12,7 +12,7 @@ import { refetchCustomer } from "../../helpers"
import { AdditionalData, HttpTypes } from "@medusajs/types"
export const GET = async (
req: AuthenticatedMedusaRequest,
req: AuthenticatedMedusaRequest<HttpTypes.AdminCustomerAddressFilters>,
res: MedusaResponse<HttpTypes.AdminCustomerAddressListResponse>
) => {
const customerId = req.params.id

View File

@@ -9,15 +9,11 @@ import {
import { createStockLocationsWorkflow } from "@medusajs/core-flows"
import { refetchStockLocation } from "./helpers"
import {
AdminCreateStockLocationType,
AdminGetStockLocationsParamsType,
} from "./validators"
import { HttpTypes } from "@medusajs/types"
// Create stock location
export const POST = async (
req: AuthenticatedMedusaRequest<AdminCreateStockLocationType>,
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateStockLocation>,
res: MedusaResponse<HttpTypes.AdminStockLocationResponse>
) => {
const { result } = await createStockLocationsWorkflow(req.scope).run({
@@ -34,7 +30,7 @@ export const POST = async (
}
export const GET = async (
req: AuthenticatedMedusaRequest<AdminGetStockLocationsParamsType>,
req: AuthenticatedMedusaRequest<HttpTypes.AdminStockLocationListParams>,
res: MedusaResponse<HttpTypes.AdminStockLocationListResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)

View File

@@ -6,11 +6,10 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "../../../types/routing"
import { AdminGetStoresParamsType } from "./validators"
import { HttpTypes } from "@medusajs/types"
export const GET = async (
req: AuthenticatedMedusaRequest<AdminGetStoresParamsType>,
req: AuthenticatedMedusaRequest<HttpTypes.AdminStoreListParams>,
res: MedusaResponse<HttpTypes.AdminStoreListResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)

View File

@@ -8,14 +8,10 @@ import {
MedusaResponse,
} from "../../../types/routing"
import { refetchTaxRate } from "./helpers"
import {
AdminCreateTaxRateType,
AdminGetTaxRatesParamsType,
} from "./validators"
import { HttpTypes } from "@medusajs/types"
export const POST = async (
req: AuthenticatedMedusaRequest<AdminCreateTaxRateType>,
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateTaxRate>,
res: MedusaResponse<HttpTypes.AdminTaxRateResponse>
) => {
const { result } = await createTaxRatesWorkflow(req.scope).run({
@@ -36,7 +32,7 @@ export const POST = async (
}
export const GET = async (
req: AuthenticatedMedusaRequest<AdminGetTaxRatesParamsType>,
req: AuthenticatedMedusaRequest<HttpTypes.AdminTaxRateListParams>,
res: MedusaResponse<HttpTypes.AdminTaxRateListResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)

View File

@@ -7,15 +7,11 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "../../../types/routing"
import {
AdminCreateTaxRegionType,
AdminGetTaxRegionsParamsType,
} from "./validators"
import { refetchTaxRegion } from "./helpers"
import { HttpTypes } from "@medusajs/types"
export const POST = async (
req: AuthenticatedMedusaRequest<AdminCreateTaxRegionType>,
req: AuthenticatedMedusaRequest<HttpTypes.AdminCreateTaxRegion>,
res: MedusaResponse<HttpTypes.AdminTaxRegionResponse>
) => {
const { result } = await createTaxRegionsWorkflow(req.scope).run({
@@ -36,7 +32,7 @@ export const POST = async (
}
export const GET = async (
req: AuthenticatedMedusaRequest<AdminGetTaxRegionsParamsType>,
req: AuthenticatedMedusaRequest<HttpTypes.AdminTaxRegionListParams>,
res: MedusaResponse<HttpTypes.AdminTaxRegionListResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)

View File

@@ -4,11 +4,10 @@ import {
MedusaResponse,
} from "../../../types/routing"
import { MedusaError } from "@medusajs/utils"
import { AdminGetUploadParamsType } from "./validators"
import { HttpTypes } from "@medusajs/types"
export const POST = async (
req: AuthenticatedMedusaRequest<AdminGetUploadParamsType>,
req: AuthenticatedMedusaRequest<HttpTypes.AdminUploadFile>,
res: MedusaResponse<HttpTypes.AdminFileListResponse>
) => {
const input = req.files as Express.Multer.File[]

View File

@@ -9,7 +9,7 @@ import {
} from "../../../types/routing"
export const GET = async (
req: AuthenticatedMedusaRequest,
req: AuthenticatedMedusaRequest<HttpTypes.AdminUserListParams>,
res: MedusaResponse<HttpTypes.AdminUserListResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)

View File

@@ -3,15 +3,13 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "../../../types/routing"
import { AdminGetWorkflowExecutionsParamsType } from "./validators"
import {
ContainerRegistrationKeys,
remoteQueryObjectFromString,
} from "@medusajs/utils"
export const GET = async (
req: AuthenticatedMedusaRequest<AdminGetWorkflowExecutionsParamsType>,
req: AuthenticatedMedusaRequest<HttpTypes.AdminGetWorkflowExecutionsParams>,
res: MedusaResponse<HttpTypes.AdminWorkflowExecutionListResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)

View File

@@ -10,7 +10,7 @@ import {
} from "@medusajs/utils"
export const GET = async (
req: AuthenticatedMedusaRequest,
req: AuthenticatedMedusaRequest<HttpTypes.StoreCollectionFilters>,
res: MedusaResponse<HttpTypes.StoreCollectionListResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)

View File

@@ -6,7 +6,7 @@ import { MedusaRequest, MedusaResponse } from "../../../types/routing"
import { HttpTypes } from "@medusajs/types"
export const GET = async (
req: MedusaRequest,
req: MedusaRequest<HttpTypes.StoreGetCurrencyListParams>,
res: MedusaResponse<HttpTypes.StoreCurrencyListResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)

View File

@@ -6,11 +6,10 @@ import { MedusaError } from "@medusajs/utils"
import { createCustomerAccountWorkflow } from "@medusajs/core-flows"
import { refetchCustomer } from "./helpers"
import { StoreCreateCustomerType } from "./validators"
import { HttpTypes } from "@medusajs/types"
export const POST = async (
req: AuthenticatedMedusaRequest<StoreCreateCustomerType>,
req: AuthenticatedMedusaRequest<HttpTypes.StoreCreateCustomer>,
res: MedusaResponse<HttpTypes.StoreCustomerResponse>
) => {
// If `actor_id` is present, the request carries authentication for an existing customer

View File

@@ -6,11 +6,10 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "../../../types/routing"
import { AdminGetOrdersParamsType } from "../../admin/draft-orders/validators"
import { HttpTypes } from "@medusajs/types"
export const GET = async (
req: AuthenticatedMedusaRequest<AdminGetOrdersParamsType>,
req: AuthenticatedMedusaRequest<HttpTypes.StoreOrderFilters>,
res: MedusaResponse<HttpTypes.StoreOrderListResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)

View File

@@ -7,11 +7,10 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "../../../types/routing"
import { StoreCreatePaymentCollectionType } from "./validators"
import { HttpTypes } from "@medusajs/types"
export const POST = async (
req: AuthenticatedMedusaRequest<StoreCreatePaymentCollectionType>,
req: AuthenticatedMedusaRequest<HttpTypes.StoreCreatePaymentCollection>,
res: MedusaResponse<HttpTypes.StorePaymentCollectionResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)

View File

@@ -7,12 +7,11 @@ import {
MedusaError,
remoteQueryObjectFromString,
} from "@medusajs/utils"
import { StoreGetPaymentProvidersParamsType } from "./validators"
import { HttpTypes } from "@medusajs/types"
// TODO: Add more fields to provider, such as default name and maybe logo.
export const GET = async (
req: AuthenticatedMedusaRequest<StoreGetPaymentProvidersParamsType>,
req: AuthenticatedMedusaRequest<HttpTypes.StorePaymentProviderFilters>,
res: MedusaResponse<HttpTypes.StorePaymentProviderListResponse>
) => {
if (!req.filterableFields.region_id) {

View File

@@ -1,4 +1,7 @@
import { StoreProductCategoryListResponse } from "@medusajs/types"
import {
StoreProductCategoryListParams,
StoreProductCategoryListResponse,
} from "@medusajs/types"
import {
ContainerRegistrationKeys,
remoteQueryObjectFromString,
@@ -7,10 +10,9 @@ import {
AuthenticatedMedusaRequest,
MedusaResponse,
} from "../../../types/routing"
import { StoreProductCategoriesParamsType } from "./validators"
export const GET = async (
req: AuthenticatedMedusaRequest<StoreProductCategoriesParamsType>,
req: AuthenticatedMedusaRequest<StoreProductCategoryListParams>,
res: MedusaResponse<StoreProductCategoryListResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)

View File

@@ -5,12 +5,11 @@ import {
} from "@medusajs/utils"
import { MedusaResponse } from "../../../types/routing"
import { wrapVariantsWithInventoryQuantity } from "../../utils/middlewares"
import { StoreGetProductsParamsType } from "./validators"
import { RequestWithContext, wrapProductsWithTaxPrices } from "./helpers"
import { HttpTypes } from "@medusajs/types"
export const GET = async (
req: RequestWithContext<StoreGetProductsParamsType>,
req: RequestWithContext<HttpTypes.StoreProductParams>,
res: MedusaResponse<HttpTypes.StoreProductListResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)

View File

@@ -6,7 +6,7 @@ import { MedusaRequest, MedusaResponse } from "../../../types/routing"
import { HttpTypes } from "@medusajs/types"
export const GET = async (
req: MedusaRequest,
req: MedusaRequest<HttpTypes.StoreRegionFilters>,
res: MedusaResponse<HttpTypes.StoreRegionListResponse>
) => {
const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY)

View File

@@ -1,13 +1,12 @@
import { createAndCompleteReturnOrderWorkflow } from "@medusajs/core-flows"
import { MedusaRequest, MedusaResponse } from "../../../types/routing"
import { StorePostReturnsReqSchemaType } from "./validators"
import { HttpTypes } from "@medusajs/types"
export const POST = async (
req: MedusaRequest<StorePostReturnsReqSchemaType>,
req: MedusaRequest<HttpTypes.StoreCreateReturn>,
res: MedusaResponse<HttpTypes.StoreReturnResponse>
) => {
const input = req.validatedBody as StorePostReturnsReqSchemaType
const input = req.validatedBody as HttpTypes.StoreCreateReturn
const workflow = createAndCompleteReturnOrderWorkflow(req.scope)
const { result } = await workflow.run({

View File

@@ -4,7 +4,7 @@ import { MedusaError, ModuleRegistrationName } from "@medusajs/utils"
import { MedusaRequest, MedusaResponse } from "../../../types/routing"
export const GET = async (
req: MedusaRequest,
req: MedusaRequest<HttpTypes.StoreGetShippingOptionList>,
res: MedusaResponse<HttpTypes.StoreShippingOptionListResponse>
) => {
const { cart_id } = req.filterableFields as { cart_id: string }