feat(medusa): migrate medusa unit tests / plugins integration tests to swc jest (#6820)
what: - migrates medusa package to swc/jest - migrates plugins integration tests to swc/jest - parallelises a few of the heavy test packages - fixes typeorm circular dependencies **Unit Tests** Before: 1 job => ~30 mins After: 2 jobs => ~5 mins <img width="260" alt="Screenshot 2024-03-25 at 15 11 49" src="https://github.com/medusajs/medusa/assets/5105988/e1df6985-5bd6-48d0-b87b-336d3c77d0cf"> **Plugins** Before: 1 job => ~10 mins After: 1 job => ~5 mins <img width="254" alt="Screenshot 2024-03-25 at 15 26 03" src="https://github.com/medusajs/medusa/assets/5105988/c1cec0e2-a1c3-41d1-9372-46d114d804c6"> Co-authored-by: Adrien de Peretti <25098370+adrien2p@users.noreply.github.com>
This commit is contained in:
co-authored by
Adrien de Peretti
parent
26531c5a38
commit
509ddf9a56
@@ -1,8 +1,4 @@
|
||||
import {
|
||||
AllocationType,
|
||||
DiscountConditionOperator,
|
||||
DiscountRuleType,
|
||||
} from "../../../../models"
|
||||
import { Type } from "class-transformer"
|
||||
import {
|
||||
IsArray,
|
||||
IsBoolean,
|
||||
@@ -16,14 +12,18 @@ import {
|
||||
IsString,
|
||||
ValidateNested,
|
||||
} from "class-validator"
|
||||
import { AdminUpsertConditionsReq } from "../../../../types/discount"
|
||||
import DiscountService from "../../../../services/discount"
|
||||
import { Request, Response } from "express"
|
||||
import { EntityManager } from "typeorm"
|
||||
import {
|
||||
AllocationType,
|
||||
DiscountConditionOperator,
|
||||
DiscountRuleType,
|
||||
} from "../../../../models"
|
||||
import DiscountService from "../../../../services/discount"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
import { AdminUpsertConditionsReq } from "../../../../types/discount"
|
||||
import { IsGreaterThan } from "../../../../utils/validators/greater-than"
|
||||
import { IsISO8601Duration } from "../../../../utils/validators/iso8601-duration"
|
||||
import { Type } from "class-transformer"
|
||||
import { Request, Response } from "express"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
|
||||
/**
|
||||
* @oas [post] /admin/discounts
|
||||
@@ -164,6 +164,49 @@ export default async (req: Request, res: Response) => {
|
||||
res.status(200).json({ discount })
|
||||
}
|
||||
|
||||
/**
|
||||
* Details of the discount rule to create.
|
||||
*/
|
||||
export class AdminPostDiscountsDiscountRule {
|
||||
/**
|
||||
* The discount rule's description.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
description?: string
|
||||
|
||||
/**
|
||||
* The discount rule's type.
|
||||
*/
|
||||
@IsEnum(DiscountRuleType, {
|
||||
message: `Invalid rule type, must be one of "fixed", "percentage" or "free_shipping"`,
|
||||
})
|
||||
type: DiscountRuleType
|
||||
|
||||
/**
|
||||
* The discount rule's value.
|
||||
*/
|
||||
@IsNumber()
|
||||
value: number
|
||||
|
||||
/**
|
||||
* The discount rule's allocation.
|
||||
*/
|
||||
@IsEnum(AllocationType, {
|
||||
message: `Invalid allocation type, must be one of "total" or "item"`,
|
||||
})
|
||||
allocation: AllocationType
|
||||
|
||||
/**
|
||||
* The discount rule's conditions.
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => AdminCreateCondition)
|
||||
conditions?: AdminCreateCondition[]
|
||||
}
|
||||
|
||||
/**
|
||||
* @schema AdminPostDiscountsReq
|
||||
* type: object
|
||||
@@ -322,49 +365,6 @@ export class AdminPostDiscountsReq {
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* Details of the discount rule to create.
|
||||
*/
|
||||
export class AdminPostDiscountsDiscountRule {
|
||||
/**
|
||||
* The discount rule's description.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
description?: string
|
||||
|
||||
/**
|
||||
* The discount rule's type.
|
||||
*/
|
||||
@IsEnum(DiscountRuleType, {
|
||||
message: `Invalid rule type, must be one of "fixed", "percentage" or "free_shipping"`,
|
||||
})
|
||||
type: DiscountRuleType
|
||||
|
||||
/**
|
||||
* The discount rule's value.
|
||||
*/
|
||||
@IsNumber()
|
||||
value: number
|
||||
|
||||
/**
|
||||
* The discount rule's allocation.
|
||||
*/
|
||||
@IsEnum(AllocationType, {
|
||||
message: `Invalid allocation type, must be one of "total" or "item"`,
|
||||
})
|
||||
allocation: AllocationType
|
||||
|
||||
/**
|
||||
* The discount rule's conditions.
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => AdminCreateCondition)
|
||||
conditions?: AdminCreateCondition[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Details of the discount condition to create.
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import { Request, Response } from "express"
|
||||
import { AllocationType, DiscountConditionOperator } from "../../../../models"
|
||||
import {
|
||||
IsArray,
|
||||
IsBoolean,
|
||||
@@ -13,14 +11,16 @@ import {
|
||||
IsString,
|
||||
ValidateNested,
|
||||
} from "class-validator"
|
||||
import { Request, Response } from "express"
|
||||
import { AllocationType, DiscountConditionOperator } from "../../../../models"
|
||||
|
||||
import { AdminUpsertConditionsReq } from "../../../../types/discount"
|
||||
import DiscountService from "../../../../services/discount"
|
||||
import { Type } from "class-transformer"
|
||||
import { EntityManager } from "typeorm"
|
||||
import DiscountService from "../../../../services/discount"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
import { AdminUpsertConditionsReq } from "../../../../types/discount"
|
||||
import { IsGreaterThan } from "../../../../utils/validators/greater-than"
|
||||
import { IsISO8601Duration } from "../../../../utils/validators/iso8601-duration"
|
||||
import { Type } from "class-transformer"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
|
||||
/**
|
||||
* @oas [post] /admin/discounts/{id}
|
||||
@@ -132,6 +132,50 @@ export default async (req: Request, res: Response) => {
|
||||
res.status(200).json({ discount })
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes of the discount rule to update.
|
||||
*/
|
||||
export class AdminUpdateDiscountRule {
|
||||
/**
|
||||
* The discount rule's ID.
|
||||
*/
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
id: string
|
||||
|
||||
/**
|
||||
* The discount rule's description.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
description?: string
|
||||
|
||||
/**
|
||||
* The discount rule's value.
|
||||
*/
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
value?: number
|
||||
|
||||
/**
|
||||
* The discount rule's allocation.
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsEnum(AllocationType, {
|
||||
message: `Invalid allocation type, must be one of "total" or "item"`,
|
||||
})
|
||||
allocation?: AllocationType
|
||||
|
||||
/**
|
||||
* The discount rule's discount conditions.
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => AdminUpsertCondition)
|
||||
conditions?: AdminUpsertCondition[]
|
||||
}
|
||||
|
||||
/**
|
||||
* @schema AdminPostDiscountsDiscountReq
|
||||
* type: object
|
||||
@@ -277,50 +321,6 @@ export class AdminPostDiscountsDiscountReq {
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes of the discount rule to update.
|
||||
*/
|
||||
export class AdminUpdateDiscountRule {
|
||||
/**
|
||||
* The discount rule's ID.
|
||||
*/
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
id: string
|
||||
|
||||
/**
|
||||
* The discount rule's description.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
description?: string
|
||||
|
||||
/**
|
||||
* The discount rule's value.
|
||||
*/
|
||||
@IsNumber()
|
||||
@IsOptional()
|
||||
value?: number
|
||||
|
||||
/**
|
||||
* The discount rule's allocation.
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsEnum(AllocationType, {
|
||||
message: `Invalid allocation type, must be one of "total" or "item"`,
|
||||
})
|
||||
allocation?: AllocationType
|
||||
|
||||
/**
|
||||
* The discount rule's discount conditions.
|
||||
*/
|
||||
@IsOptional()
|
||||
@IsArray()
|
||||
@ValidateNested({ each: true })
|
||||
@Type(() => AdminUpsertCondition)
|
||||
conditions?: AdminUpsertCondition[]
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes to create or update in the discount condition.
|
||||
*/
|
||||
|
||||
@@ -342,6 +342,81 @@ export default async (req, res) => {
|
||||
res.status(idempotencyKey.response_code).json(idempotencyKey.response_body)
|
||||
}
|
||||
|
||||
/**
|
||||
* The return's shipping method details.
|
||||
*/
|
||||
class ReturnShipping {
|
||||
/**
|
||||
* The ID of the shipping option used for the return.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
option_id?: string
|
||||
|
||||
/**
|
||||
* The shipping method's price.
|
||||
*/
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
price?: number
|
||||
}
|
||||
|
||||
class ShippingMethod {
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
id?: string
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
option_id?: string
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
price?: number
|
||||
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
data?: Record<string, unknown>
|
||||
}
|
||||
|
||||
class Item {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
item_id: string
|
||||
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
quantity: number
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
note?: string
|
||||
|
||||
@IsEnum(ClaimReason)
|
||||
@IsOptional()
|
||||
reason?: ClaimReason
|
||||
|
||||
@IsArray()
|
||||
@IsOptional()
|
||||
@IsString({ each: true })
|
||||
tags?: string[]
|
||||
|
||||
@IsArray()
|
||||
@IsOptional()
|
||||
@IsString({ each: true })
|
||||
images?: string[]
|
||||
}
|
||||
|
||||
class AdditionalItem {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
variant_id: string
|
||||
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
quantity: number
|
||||
}
|
||||
|
||||
/**
|
||||
* @schema AdminPostOrdersOrderClaimsReq
|
||||
* type: object
|
||||
@@ -505,79 +580,4 @@ export class AdminPostOrdersOrderClaimsReq {
|
||||
metadata?: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* The return's shipping method details.
|
||||
*/
|
||||
class ReturnShipping {
|
||||
/**
|
||||
* The ID of the shipping option used for the return.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
option_id?: string
|
||||
|
||||
/**
|
||||
* The shipping method's price.
|
||||
*/
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
price?: number
|
||||
}
|
||||
|
||||
class ShippingMethod {
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
id?: string
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
option_id?: string
|
||||
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
price?: number
|
||||
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
data?: Record<string, unknown>
|
||||
}
|
||||
|
||||
class Item {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
item_id: string
|
||||
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
quantity: number
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
note?: string
|
||||
|
||||
@IsEnum(ClaimReason)
|
||||
@IsOptional()
|
||||
reason?: ClaimReason
|
||||
|
||||
@IsArray()
|
||||
@IsOptional()
|
||||
@IsString({ each: true })
|
||||
tags?: string[]
|
||||
|
||||
@IsArray()
|
||||
@IsOptional()
|
||||
@IsString({ each: true })
|
||||
images?: string[]
|
||||
}
|
||||
|
||||
class AdditionalItem {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
variant_id: string
|
||||
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
quantity: number
|
||||
}
|
||||
|
||||
export class AdminPostOrdersOrderClaimsParams extends FindParams {}
|
||||
|
||||
@@ -1,9 +1,3 @@
|
||||
import {
|
||||
IdempotencyKeyService,
|
||||
OrderService,
|
||||
ReturnService,
|
||||
SwapService,
|
||||
} from "../../../../services"
|
||||
import {
|
||||
IsArray,
|
||||
IsBoolean,
|
||||
@@ -16,11 +10,17 @@ import {
|
||||
Min,
|
||||
ValidateNested,
|
||||
} from "class-validator"
|
||||
import {
|
||||
IdempotencyKeyService,
|
||||
OrderService,
|
||||
ReturnService,
|
||||
SwapService,
|
||||
} from "../../../../services"
|
||||
|
||||
import { Type } from "class-transformer"
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { FindParams } from "../../../../types/common"
|
||||
import { MedusaError } from "medusa-core-utils"
|
||||
import { Type } from "class-transformer"
|
||||
import { cleanResponseData } from "../../../../utils/clean-response-data"
|
||||
|
||||
/**
|
||||
@@ -298,6 +298,64 @@ export default async (req, res) => {
|
||||
res.status(idempotencyKey.response_code).json(idempotencyKey.response_body)
|
||||
}
|
||||
|
||||
class ReturnItem {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
item_id: string
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
@Min(1)
|
||||
quantity: number
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
reason_id?: string
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
note?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* The return's shipping method details.
|
||||
*/
|
||||
class ReturnShipping {
|
||||
/**
|
||||
* The ID of the shipping option used for the return.
|
||||
*/
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
option_id: string
|
||||
|
||||
/**
|
||||
* The shipping method's price.
|
||||
*/
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
price?: number
|
||||
}
|
||||
|
||||
class CustomShippingOption {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
option_id: string
|
||||
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
price: number
|
||||
}
|
||||
|
||||
class AdditionalItem {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
variant_id: string
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
quantity: number
|
||||
}
|
||||
|
||||
/**
|
||||
* @schema AdminPostOrdersOrderSwapsReq
|
||||
* type: object
|
||||
@@ -426,62 +484,4 @@ export class AdminPostOrdersOrderSwapsReq {
|
||||
allow_backorder?: boolean = true
|
||||
}
|
||||
|
||||
class ReturnItem {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
item_id: string
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
@Min(1)
|
||||
quantity: number
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
reason_id?: string
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
note?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* The return's shipping method details.
|
||||
*/
|
||||
class ReturnShipping {
|
||||
/**
|
||||
* The ID of the shipping option used for the return.
|
||||
*/
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
option_id: string
|
||||
|
||||
/**
|
||||
* The shipping method's price.
|
||||
*/
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
price?: number
|
||||
}
|
||||
|
||||
class CustomShippingOption {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
option_id: string
|
||||
|
||||
@IsInt()
|
||||
@IsNotEmpty()
|
||||
price: number
|
||||
}
|
||||
|
||||
class AdditionalItem {
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
variant_id: string
|
||||
|
||||
@IsNumber()
|
||||
@IsNotEmpty()
|
||||
quantity: number
|
||||
}
|
||||
|
||||
export class AdminPostOrdersOrderSwapsParams extends FindParams {}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Logger } from "@medusajs/types"
|
||||
import { isDefined, MedusaError } from "@medusajs/utils"
|
||||
import { Type } from "class-transformer"
|
||||
import {
|
||||
@@ -18,7 +19,6 @@ import {
|
||||
import { FindParams } from "../../../../types/common"
|
||||
import { OrdersReturnItem } from "../../../../types/orders"
|
||||
import { cleanResponseData } from "../../../../utils/clean-response-data"
|
||||
import { Logger } from "@medusajs/types"
|
||||
|
||||
/**
|
||||
* @oas [post] /admin/orders/{id}/return
|
||||
@@ -339,6 +339,25 @@ type ReturnObj = {
|
||||
location_id?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* The return's shipping method details.
|
||||
*/
|
||||
class ReturnShipping {
|
||||
/**
|
||||
* The ID of the shipping option used for the return.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
option_id?: string
|
||||
|
||||
/**
|
||||
* The shipping method's price.
|
||||
*/
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
price?: number
|
||||
}
|
||||
|
||||
/**
|
||||
* @schema AdminPostOrdersOrderReturnsReq
|
||||
* type: object
|
||||
@@ -427,23 +446,4 @@ export class AdminPostOrdersOrderReturnsReq {
|
||||
location_id?: string
|
||||
}
|
||||
|
||||
/**
|
||||
* The return's shipping method details.
|
||||
*/
|
||||
class ReturnShipping {
|
||||
/**
|
||||
* The ID of the shipping option used for the return.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
option_id?: string
|
||||
|
||||
/**
|
||||
* The shipping method's price.
|
||||
*/
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
price?: number
|
||||
}
|
||||
|
||||
export class AdminPostOrdersOrderReturnsParams extends FindParams {}
|
||||
|
||||
@@ -9,10 +9,10 @@ import {
|
||||
ValidateNested,
|
||||
} from "class-validator"
|
||||
|
||||
import { AddressPayload, FindParams } from "../../../../types/common"
|
||||
import { Type } from "class-transformer"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { OrderService } from "../../../../services"
|
||||
import { Type } from "class-transformer"
|
||||
import { AddressPayload, FindParams } from "../../../../types/common"
|
||||
import { cleanResponseData } from "../../../../utils/clean-response-data"
|
||||
|
||||
/**
|
||||
@@ -132,6 +132,65 @@ export default async (req, res) => {
|
||||
res.status(200).json({ order: cleanResponseData(order, []) })
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes to update in the order's payment method.
|
||||
*/
|
||||
class PaymentMethod {
|
||||
/**
|
||||
* The ID of the payment provider used in the order.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
provider_id?: string
|
||||
|
||||
/**
|
||||
* The data to attach to the payment.
|
||||
*/
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
data?: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes to update in the order's shipping method.
|
||||
*/
|
||||
class ShippingMethod {
|
||||
/**
|
||||
* The ID of the shipping provider used in the order.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
provider_id?: string
|
||||
|
||||
/**
|
||||
* The ID of the shipping profile used in the order.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
profile_id?: string
|
||||
|
||||
/**
|
||||
* The price of the shipping method.
|
||||
*/
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
price?: number
|
||||
|
||||
/**
|
||||
* The data to attach to the shipping method.
|
||||
*/
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
data?: Record<string, unknown>
|
||||
|
||||
/**
|
||||
* The line items associated with this shipping methods.
|
||||
*/
|
||||
@IsArray()
|
||||
@IsOptional()
|
||||
items?: Record<string, unknown>[]
|
||||
}
|
||||
|
||||
/**
|
||||
* @schema AdminPostOrdersOrderReq
|
||||
* type: object
|
||||
@@ -244,65 +303,6 @@ export class AdminPostOrdersOrderReq {
|
||||
no_notification?: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes to update in the order's payment method.
|
||||
*/
|
||||
class PaymentMethod {
|
||||
/**
|
||||
* The ID of the payment provider used in the order.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
provider_id?: string
|
||||
|
||||
/**
|
||||
* The data to attach to the payment.
|
||||
*/
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
data?: Record<string, unknown>
|
||||
}
|
||||
|
||||
/**
|
||||
* The attributes to update in the order's shipping method.
|
||||
*/
|
||||
class ShippingMethod {
|
||||
/**
|
||||
* The ID of the shipping provider used in the order.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
provider_id?: string
|
||||
|
||||
/**
|
||||
* The ID of the shipping profile used in the order.
|
||||
*/
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
profile_id?: string
|
||||
|
||||
/**
|
||||
* The price of the shipping method.
|
||||
*/
|
||||
@IsInt()
|
||||
@IsOptional()
|
||||
price?: number
|
||||
|
||||
/**
|
||||
* The data to attach to the shipping method.
|
||||
*/
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
data?: Record<string, unknown>
|
||||
|
||||
/**
|
||||
* The line items associated with this shipping methods.
|
||||
*/
|
||||
@IsArray()
|
||||
@IsOptional()
|
||||
items?: Record<string, unknown>[]
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameters used to configure the retrieved order.
|
||||
*/
|
||||
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
import { Request } from "express"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { defaultAdminPriceListFields, defaultAdminPriceListRelations } from "."
|
||||
import { featureFlagRouter } from "../../../../loaders/feature-flags"
|
||||
import TaxInclusivePricingFeatureFlag from "../../../../loaders/feature-flags/tax-inclusive-pricing"
|
||||
import { PriceList } from "../../../../models"
|
||||
import PriceListService from "../../../../services/price-list"
|
||||
|
||||
@@ -15,6 +15,7 @@ import {
|
||||
defaultAdminProductRelations,
|
||||
defaultAdminProductRemoteQueryObject,
|
||||
} from "."
|
||||
import { featureFlagRouter } from "../../../../loaders/feature-flags"
|
||||
import {
|
||||
PricingService,
|
||||
ProductService,
|
||||
@@ -767,4 +768,10 @@ export class AdminPostProductsReq {
|
||||
@IsObject()
|
||||
@IsOptional()
|
||||
metadata?: Record<string, unknown>
|
||||
|
||||
constructor() {
|
||||
if (!featureFlagRouter.isFeatureEnabled(SalesChannelFeatureFlag.key)) {
|
||||
delete this.sales_channels
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user