diff --git a/.changeset/chilly-pugs-doubt.md b/.changeset/chilly-pugs-doubt.md new file mode 100644 index 0000000000..21f68cc002 --- /dev/null +++ b/.changeset/chilly-pugs-doubt.md @@ -0,0 +1,6 @@ +--- +"@medusajs/medusa": patch +"@medusajs/types": patch +--- + +fix(medusa, types): Mark properties as nullable to reflect their correct types diff --git a/packages/medusa/src/models/product-variant.ts b/packages/medusa/src/models/product-variant.ts index 3d921eb506..32b2f3f4d6 100644 --- a/packages/medusa/src/models/product-variant.ts +++ b/packages/medusa/src/models/product-variant.ts @@ -46,24 +46,24 @@ export class ProductVariant extends SoftDeletableEntity { }) prices: MoneyAmount[] - @Column({ nullable: true }) + @Column({ nullable: true, type: "text" }) @Index({ unique: true, where: "deleted_at IS NULL" }) - sku: string + sku: string | null - @Column({ nullable: true }) + @Column({ nullable: true, type: "text" }) @Index({ unique: true, where: "deleted_at IS NULL" }) - barcode: string + barcode: string | null - @Column({ nullable: true }) + @Column({ nullable: true, type: "text" }) @Index({ unique: true, where: "deleted_at IS NULL" }) - ean: string + ean: string | null - @Column({ nullable: true }) + @Column({ nullable: true, type: "text" }) @Index({ unique: true, where: "deleted_at IS NULL" }) - upc: string + upc: string | null - @Column({ nullable: true, default: 0 }) - variant_rank: number + @Column({ nullable: true, type: "text", default: 0 }) + variant_rank: number | null @Column({ type: "int" }) inventory_quantity: number @@ -74,29 +74,29 @@ export class ProductVariant extends SoftDeletableEntity { @Column({ default: true }) manage_inventory: boolean - @Column({ nullable: true }) - hs_code: string + @Column({ nullable: true, type: "text" }) + hs_code: string | null - @Column({ nullable: true }) - origin_country: string + @Column({ nullable: true, type: "text" }) + origin_country: string | null - @Column({ nullable: true }) - mid_code: string + @Column({ nullable: true, type: "text" }) + mid_code: string | null - @Column({ nullable: true }) - material: string + @Column({ nullable: true, type: "text" }) + material: string | null @Column({ type: "int", nullable: true }) - weight: number + weight: number | null @Column({ type: "int", nullable: true }) - length: number + length: number | null @Column({ type: "int", nullable: true }) - height: number + height: number | null @Column({ type: "int", nullable: true }) - width: number + width: number | null @OneToMany(() => ProductOptionValue, (optionValue) => optionValue.variant, { cascade: true, @@ -113,7 +113,7 @@ export class ProductVariant extends SoftDeletableEntity { inventory_items: ProductVariantInventoryItem[] @DbAwareColumn({ type: "jsonb", nullable: true }) - metadata: Record + metadata: Record | null purchasable?: boolean diff --git a/packages/types/src/inventory/common.ts b/packages/types/src/inventory/common.ts index 1e3af18cea..640f38d458 100644 --- a/packages/types/src/inventory/common.ts +++ b/packages/types/src/inventory/common.ts @@ -220,19 +220,19 @@ export type FilterableInventoryItemProps = { } export type CreateInventoryItemInput = { - sku?: string - origin_country?: string - mid_code?: string - material?: string - weight?: number - length?: number - height?: number - width?: number - title?: string - description?: string - thumbnail?: string + sku?: string | null + origin_country?: string | null + mid_code?: string | null + material?: string | null + weight?: number | null + length?: number | null + height?: number | null + width?: number | null + title?: string | null + description?: string | null + thumbnail?: string | null metadata?: Record | null - hs_code?: string + hs_code?: string | null requires_shipping?: boolean } @@ -242,7 +242,7 @@ export type CreateReservationItemInput = { location_id: string quantity: number description?: string - created_by?: string + created_by?: string external_id?: string metadata?: Record | null }