Skip to content

Commit cec755c

Browse files
authored
docs: add TSDocs for 67499a8 (#15081)
Co-authored-by: shahednasser <[email protected]>
1 parent ab320d3 commit cec755c

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

packages/core/core-flows/src/product/helpers/normalize-for-import.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,29 @@ import type { ProductTypes } from "@medusajs/framework/types"
22
import type { HttpTypes, RegionTypes } from "@medusajs/framework/types"
33
import { MedusaError, lowerCaseFirst, normalizeCurrencyCode } from "@medusajs/framework/utils"
44

5-
// We want to convert the csv data format to a standard DTO format.
5+
/**
6+
* Normalizes raw CSV product data into standardized AdminCreateProduct DTOs.
7+
*
8+
* This function converts product data from CSV import format to the standard DTO format
9+
* expected by the product creation API. It handles product grouping by handle,
10+
* variant aggregation, option extraction, and validation against existing regions and tags.
11+
*
12+
* @param rawProducts - Array of raw product objects from CSV import
13+
* @param additional - Additional context data needed for normalization
14+
* @param additional.regions - Available regions for price validation
15+
* @param additional.tags - Available product tags for validation
16+
* @returns Array of normalized AdminCreateProduct DTOs ready for import
17+
*
18+
* @throws {MedusaError} When referenced tags or regions are not found
19+
*
20+
* @example
21+
* ```typescript
22+
* const products = normalizeForImport(csvData, {
23+
* regions: existingRegions,
24+
* tags: existingTags
25+
* })
26+
* ```
27+
*/
628
export const normalizeForImport = (
729
rawProducts: object[],
830
additional: {

0 commit comments

Comments
 (0)