fix(medusa, pricing, types): pass dates as Date-objects rather than strings to the pricing module (#5768)
* init * remove date string validator; * add transformOptionalDate transformer to api * move type conversion to the datalayer * fix final module integration test * update arrow-function * make string optional * move work to utils * make check for value exists * move util back to pricng * change utils * refactor get-iso-string * fix build * flip transform condition * add null check for isDate * feat(pricing): Separate Pricing Module internal types from `@medusajs/types` (#5777) * create types for pricing repositories * create RepositoryTypes input * add service types * use models for repository types * fix build * update types to match interface types * add aliases * types instead of moduletypes * move repository to types for pricing module * add changeset * fix merge error * fix conflict * fix build * re-add validation of dates in updatePriceLists_
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { IdMap } from "medusa-test-utils"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
import { PriceListServiceMock } from "../../../../../services/__mocks__/price-list"
|
||||
import { request } from "../../../../../helpers/test-request"
|
||||
|
||||
jest.setTimeout(10000)
|
||||
describe("POST /price-lists", () => {
|
||||
@@ -58,8 +58,8 @@ describe("POST /price-lists", () => {
|
||||
expect(PriceListServiceMock.create).toHaveBeenCalledWith({
|
||||
name: "My Price List",
|
||||
description: "testing",
|
||||
ends_at: "2022-03-14T08:28:38.551Z",
|
||||
starts_at: "2022-03-14T08:28:38.551Z",
|
||||
ends_at: new Date("2022-03-14T08:28:38.551Z"),
|
||||
starts_at: new Date("2022-03-14T08:28:38.551Z"),
|
||||
customer_groups: [
|
||||
{
|
||||
id: "gc_123",
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
PriceListType,
|
||||
} from "@medusajs/utils"
|
||||
import { createPriceLists } from "@medusajs/core-flows"
|
||||
import { Type } from "class-transformer"
|
||||
import { Transform, Type } from "class-transformer"
|
||||
import {
|
||||
IsArray,
|
||||
IsBoolean,
|
||||
@@ -27,6 +27,7 @@ import {
|
||||
} from "../../../../types/price-list"
|
||||
import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators"
|
||||
import { getPriceListPricingModule } from "./modules-queries"
|
||||
import { transformOptionalDate } from "../../../../utils/validators/date-transform"
|
||||
|
||||
/**
|
||||
* @oas [post] /admin/price-lists
|
||||
@@ -263,9 +264,11 @@ export class AdminPostPriceListsPriceListReq {
|
||||
description: string
|
||||
|
||||
@IsOptional()
|
||||
@Transform(transformOptionalDate)
|
||||
starts_at?: Date
|
||||
|
||||
@IsOptional()
|
||||
@Transform(transformOptionalDate)
|
||||
ends_at?: Date
|
||||
|
||||
@IsOptional()
|
||||
|
||||
@@ -11,7 +11,7 @@ import {
|
||||
import { defaultAdminPriceListFields, defaultAdminPriceListRelations } from "."
|
||||
|
||||
import { updatePriceLists } from "@medusajs/core-flows"
|
||||
import { Type } from "class-transformer"
|
||||
import { Transform, Type } from "class-transformer"
|
||||
import { EntityManager } from "typeorm"
|
||||
import { PriceList } from "../../../.."
|
||||
import TaxInclusivePricingFeatureFlag from "../../../../loaders/feature-flags/tax-inclusive-pricing"
|
||||
@@ -20,6 +20,7 @@ import { AdminPriceListPricesUpdateReq } from "../../../../types/price-list"
|
||||
import { FeatureFlagDecorators } from "../../../../utils/feature-flag-decorators"
|
||||
import { validator } from "../../../../utils/validator"
|
||||
import { getPriceListPricingModule } from "./modules-queries"
|
||||
import { transformOptionalDate } from "../../../../utils/validators/date-transform"
|
||||
|
||||
/**
|
||||
* @oas [post] /admin/price-lists/{id}
|
||||
@@ -238,9 +239,11 @@ export class AdminPostPriceListsPriceListPriceListReq {
|
||||
description?: string
|
||||
|
||||
@IsOptional()
|
||||
@Transform(transformOptionalDate)
|
||||
starts_at?: Date | null
|
||||
|
||||
@IsOptional()
|
||||
@Transform(transformOptionalDate)
|
||||
ends_at?: Date | null
|
||||
|
||||
@IsOptional()
|
||||
|
||||
Reference in New Issue
Block a user