diff --git a/packages/core/types/src/http/campaign/admin/payloads.ts b/packages/core/types/src/http/campaign/admin/payloads.ts index a9cbba6300..850a4023fc 100644 --- a/packages/core/types/src/http/campaign/admin/payloads.ts +++ b/packages/core/types/src/http/campaign/admin/payloads.ts @@ -4,22 +4,15 @@ export interface AdminCreateCampaign { /** * The campaign's name. */ - name?: string + name: string /** * The campaign's description. */ - description?: string - /** - * The campaign's currency code. - * - * @example - * usd - */ - currency?: string | null + description?: string | null /** * The campaign's identifier. */ - campaign_identifier?: string + campaign_identifier: string /** * The date the campaign and its promotions start at. */ @@ -70,14 +63,7 @@ export interface AdminUpdateCampaign { /** * The campaign's description. */ - description?: string - /** - * The campaign's currency code. - * - * @example - * usd - */ - currency?: string | null + description?: string | null /** * The campaign's identifier. */ @@ -94,21 +80,9 @@ export interface AdminUpdateCampaign { * The campaign's budget. */ budget?: { - /** - * The budget's type. `spend` means the limit is set on the total amount discounted by the campaign's promotions; - * `usage` means the limit is set on the total number of times the campaign's promotions can be used. - */ - type?: CampaignBudgetTypeValues - /** - * The budget's currency code. - * - * @example - * usd - */ - currency_code?: string | null /** * The budget's limit. */ limit?: number | null - } | null + } } diff --git a/packages/core/types/src/http/promotion/admin/queries.ts b/packages/core/types/src/http/promotion/admin/queries.ts index 6bea404e61..f67bc2ca31 100644 --- a/packages/core/types/src/http/promotion/admin/queries.ts +++ b/packages/core/types/src/http/promotion/admin/queries.ts @@ -78,7 +78,7 @@ export interface AdminGetPromotionRuleParams { */ application_method_type?: ApplicationMethodTypeValues /** - * The type of application method to retrieve the attributes for. + * The target type of application method to retrieve the attributes for. */ application_method_target_type?: ApplicationMethodTargetTypeValues } @@ -92,6 +92,10 @@ export interface AdminGetPromotionRuleTypeParams extends SelectParams { * The type of application method to retrieve the attributes for. */ application_method_type?: ApplicationMethodTypeValues + /** + * The target type of application method to retrieve the attributes for. + */ + application_method_target_type?: ApplicationMethodTargetTypeValues } export interface AdminGetPromotionsRuleValueParams extends FindParams { @@ -103,5 +107,8 @@ export interface AdminGetPromotionsRuleValueParams extends FindParams { * Filter by rule value. */ value?: string | string[] + /** + * The target type of application method to retrieve the attributes for. + */ application_method_target_type?: ApplicationMethodTargetTypeValues } diff --git a/packages/medusa/src/api/admin/campaigns/[id]/promotions/route.ts b/packages/medusa/src/api/admin/campaigns/[id]/promotions/route.ts index e5c34de356..030e682433 100644 --- a/packages/medusa/src/api/admin/campaigns/[id]/promotions/route.ts +++ b/packages/medusa/src/api/admin/campaigns/[id]/promotions/route.ts @@ -4,11 +4,14 @@ import { } from "@medusajs/framework/http" import { addOrRemoveCampaignPromotionsWorkflow } from "@medusajs/core-flows" -import { HttpTypes, LinkMethodRequest } from "@medusajs/framework/types" +import { HttpTypes } from "@medusajs/framework/types" import { refetchCampaign } from "../../helpers" export const POST = async ( - req: AuthenticatedMedusaRequest, + req: AuthenticatedMedusaRequest< + HttpTypes.AdminBatchLink, + HttpTypes.AdminGetCampaignParams + >, res: MedusaResponse ) => { const { id } = req.params diff --git a/packages/medusa/src/api/admin/campaigns/[id]/route.ts b/packages/medusa/src/api/admin/campaigns/[id]/route.ts index 9c378da7bf..4d36c6ee29 100644 --- a/packages/medusa/src/api/admin/campaigns/[id]/route.ts +++ b/packages/medusa/src/api/admin/campaigns/[id]/route.ts @@ -8,12 +8,11 @@ import { } from "@medusajs/core-flows" import { refetchCampaign } from "../helpers" -import { AdminUpdateCampaignType } from "../validators" import { MedusaError } from "@medusajs/framework/utils" import { AdditionalData, HttpTypes } from "@medusajs/framework/types" export const GET = async ( - req: AuthenticatedMedusaRequest, + req: AuthenticatedMedusaRequest, res: MedusaResponse ) => { const campaign = await refetchCampaign( @@ -33,7 +32,10 @@ export const GET = async ( } export const POST = async ( - req: AuthenticatedMedusaRequest, + req: AuthenticatedMedusaRequest< + HttpTypes.AdminUpdateCampaign & AdditionalData, + HttpTypes.AdminGetCampaignParams + >, res: MedusaResponse ) => { const existingCampaign = await refetchCampaign(req.params.id, req.scope, [ diff --git a/packages/medusa/src/api/admin/campaigns/route.ts b/packages/medusa/src/api/admin/campaigns/route.ts index afd8ecc182..ff088407b5 100644 --- a/packages/medusa/src/api/admin/campaigns/route.ts +++ b/packages/medusa/src/api/admin/campaigns/route.ts @@ -7,12 +7,11 @@ import { ContainerRegistrationKeys, remoteQueryObjectFromString, } from "@medusajs/framework/utils" -import { AdminCreateCampaignType } from "./validators" import { refetchCampaign } from "./helpers" import { AdditionalData, HttpTypes } from "@medusajs/framework/types" export const GET = async ( - req: AuthenticatedMedusaRequest, + req: AuthenticatedMedusaRequest, res: MedusaResponse ) => { const remoteQuery = req.scope.resolve(ContainerRegistrationKeys.REMOTE_QUERY) @@ -37,7 +36,10 @@ export const GET = async ( } export const POST = async ( - req: AuthenticatedMedusaRequest, + req: AuthenticatedMedusaRequest< + HttpTypes.AdminCreateCampaign & AdditionalData, + HttpTypes.AdminGetCampaignParams + >, res: MedusaResponse ) => { const { additional_data, ...rest } = req.validatedBody diff --git a/packages/medusa/src/api/admin/promotions/[id]/[rule_type]/route.ts b/packages/medusa/src/api/admin/promotions/[id]/[rule_type]/route.ts index 7fb762f3a5..11b6fa1979 100644 --- a/packages/medusa/src/api/admin/promotions/[id]/[rule_type]/route.ts +++ b/packages/medusa/src/api/admin/promotions/[id]/[rule_type]/route.ts @@ -17,7 +17,7 @@ import { } from "../../utils" export const GET = async ( - req: AuthenticatedMedusaRequest, + req: AuthenticatedMedusaRequest, res: MedusaResponse ) => { const { id, rule_type: ruleType } = req.params diff --git a/packages/medusa/src/api/admin/promotions/[id]/buy-rules/batch/route.ts b/packages/medusa/src/api/admin/promotions/[id]/buy-rules/batch/route.ts index b9c49543f6..bdafd5a002 100644 --- a/packages/medusa/src/api/admin/promotions/[id]/buy-rules/batch/route.ts +++ b/packages/medusa/src/api/admin/promotions/[id]/buy-rules/batch/route.ts @@ -12,7 +12,8 @@ export const POST = async ( BatchMethodRequest< HttpTypes.AdminCreatePromotionRule, HttpTypes.AdminUpdatePromotionRule - > + >, + HttpTypes.AdminGetPromotionRuleParams >, res: MedusaResponse ) => { diff --git a/packages/medusa/src/api/admin/promotions/[id]/route.ts b/packages/medusa/src/api/admin/promotions/[id]/route.ts index 0fec6cb26b..ec2a63eb79 100644 --- a/packages/medusa/src/api/admin/promotions/[id]/route.ts +++ b/packages/medusa/src/api/admin/promotions/[id]/route.ts @@ -12,14 +12,10 @@ import { MedusaResponse, } from "@medusajs/framework/http" import { refetchPromotion } from "../helpers" -import { - AdminGetPromotionParamsType, - AdminUpdatePromotionType, -} from "../validators" import { AdditionalData, HttpTypes } from "@medusajs/framework/types" export const GET = async ( - req: AuthenticatedMedusaRequest, + req: AuthenticatedMedusaRequest, res: MedusaResponse ) => { const idOrCode = req.params.id @@ -44,7 +40,10 @@ export const GET = async ( } export const POST = async ( - req: AuthenticatedMedusaRequest, + req: AuthenticatedMedusaRequest< + HttpTypes.AdminUpdatePromotion & AdditionalData, + HttpTypes.AdminGetPromotionParams + >, res: MedusaResponse ) => { const { additional_data, ...rest } = req.validatedBody diff --git a/packages/medusa/src/api/admin/promotions/[id]/rules/batch/route.ts b/packages/medusa/src/api/admin/promotions/[id]/rules/batch/route.ts index 84bf3548b9..924e970f25 100644 --- a/packages/medusa/src/api/admin/promotions/[id]/rules/batch/route.ts +++ b/packages/medusa/src/api/admin/promotions/[id]/rules/batch/route.ts @@ -12,7 +12,8 @@ export const POST = async ( BatchMethodRequest< HttpTypes.AdminCreatePromotionRule, HttpTypes.AdminUpdatePromotionRule - > + >, + HttpTypes.AdminGetPromotionRuleParams >, res: MedusaResponse ) => { diff --git a/packages/medusa/src/api/admin/promotions/[id]/target-rules/batch/route.ts b/packages/medusa/src/api/admin/promotions/[id]/target-rules/batch/route.ts index f9d3138944..e0369c7174 100644 --- a/packages/medusa/src/api/admin/promotions/[id]/target-rules/batch/route.ts +++ b/packages/medusa/src/api/admin/promotions/[id]/target-rules/batch/route.ts @@ -12,7 +12,8 @@ export const POST = async ( BatchMethodRequest< HttpTypes.AdminCreatePromotionRule, HttpTypes.AdminUpdatePromotionRule - > + >, + HttpTypes.AdminGetPromotionRuleParams >, res: MedusaResponse ) => { diff --git a/packages/medusa/src/api/admin/promotions/route.ts b/packages/medusa/src/api/admin/promotions/route.ts index 77134f48b1..7a46e14ced 100644 --- a/packages/medusa/src/api/admin/promotions/route.ts +++ b/packages/medusa/src/api/admin/promotions/route.ts @@ -37,7 +37,8 @@ export const GET = async ( export const POST = async ( req: AuthenticatedMedusaRequest< - HttpTypes.AdminCreatePromotion & AdditionalData + HttpTypes.AdminCreatePromotion & AdditionalData, + HttpTypes.AdminGetPromotionParams >, res: MedusaResponse ) => { diff --git a/packages/medusa/src/api/admin/promotions/rule-value-options/[rule_type]/[rule_attribute_id]/route.ts b/packages/medusa/src/api/admin/promotions/rule-value-options/[rule_type]/[rule_attribute_id]/route.ts index 62f2cdcadc..dbf04b4a9e 100644 --- a/packages/medusa/src/api/admin/promotions/rule-value-options/[rule_type]/[rule_attribute_id]/route.ts +++ b/packages/medusa/src/api/admin/promotions/rule-value-options/[rule_type]/[rule_attribute_id]/route.ts @@ -12,7 +12,6 @@ import { validateRuleAttribute, validateRuleType, } from "../../../utils" -import { AdminGetPromotionRuleParamsType } from "../../../validators" import { ApplicationMethodTargetTypeValues, RuleTypeValues, @@ -26,7 +25,7 @@ import { from the currency module. */ export const GET = async ( - req: AuthenticatedMedusaRequest, + req: AuthenticatedMedusaRequest, res: MedusaResponse ) => { const { rule_type: ruleType, rule_attribute_id: ruleAttributeId } = req.params