@pvh-afl/core 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,5 @@
1
1
  export * from './wizzy.service';
2
2
  export * from './wizzy.types';
3
+ export * from './search.types';
4
+ export * from './search.mapper';
3
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/integrations/search/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/integrations/search/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}
@@ -3,4 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./wizzy.service"), exports);
5
5
  tslib_1.__exportStar(require("./wizzy.types"), exports);
6
+ tslib_1.__exportStar(require("./search.types"), exports);
7
+ tslib_1.__exportStar(require("./search.mapper"), exports);
6
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/integrations/search/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC;AAChC,wDAA8B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/integrations/search/index.ts"],"names":[],"mappings":";;;AAAA,0DAAgC;AAChC,wDAA8B;AAC9B,yDAA+B;AAC/B,0DAAgC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Search Response Mapper
3
+ *
4
+ * Maps Wizzy API responses to the unified SearchProduct structure.
5
+ * Preserves all Wizzy data while conforming to the existing Product structure.
6
+ */
7
+ import { WizzyProduct, WizzyProductsPayload, WizzyResponse } from './wizzy.types';
8
+ import { SearchProduct, SearchProductsResponse, SearchMapperConfig } from './search.types';
9
+ /**
10
+ * Map a single WizzyProduct to SearchProduct
11
+ */
12
+ export declare function mapWizzyProduct(wizzyProduct: WizzyProduct, config?: SearchMapperConfig): SearchProduct;
13
+ /**
14
+ * Map a full Wizzy products response to SearchProductsResponse
15
+ */
16
+ export declare function mapWizzyProductsResponse(wizzyResponse: WizzyResponse<WizzyProductsPayload>, requestPage?: number, requestProductsCount?: number, config?: SearchMapperConfig): SearchProductsResponse;
17
+ /**
18
+ * Map Wizzy products array to SearchProduct array
19
+ * Useful when you only need the products without metadata
20
+ */
21
+ export declare function mapWizzyProducts(wizzyProducts: WizzyProduct[], config?: SearchMapperConfig): SearchProduct[];
22
+ //# sourceMappingURL=search.mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.mapper.d.ts","sourceRoot":"","sources":["../../../src/integrations/search/search.mapper.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,aAAa,EACd,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,aAAa,EACb,sBAAsB,EAOtB,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AA2IxB;;GAEG;AACH,wBAAgB,eAAe,CAC7B,YAAY,EAAE,YAAY,EAC1B,MAAM,GAAE,kBAA0C,GACjD,aAAa,CAmEf;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,aAAa,EAAE,aAAa,CAAC,oBAAoB,CAAC,EAClD,WAAW,GAAE,MAAU,EACvB,oBAAoB,GAAE,MAAW,EACjC,MAAM,GAAE,kBAA0C,GACjD,sBAAsB,CAYxB;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,aAAa,EAAE,YAAY,EAAE,EAC7B,MAAM,GAAE,kBAA0C,GACjD,aAAa,EAAE,CAEjB"}
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ /**
3
+ * Search Response Mapper
4
+ *
5
+ * Maps Wizzy API responses to the unified SearchProduct structure.
6
+ * Preserves all Wizzy data while conforming to the existing Product structure.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.mapWizzyProduct = mapWizzyProduct;
10
+ exports.mapWizzyProductsResponse = mapWizzyProductsResponse;
11
+ exports.mapWizzyProducts = mapWizzyProducts;
12
+ const search_types_1 = require("./search.types");
13
+ /**
14
+ * Extract handle from Wizzy product URL
15
+ * Example: "/products/blue-shirt" -> "blue-shirt"
16
+ */
17
+ function extractHandle(url) {
18
+ // Remove leading slash and extract last segment
19
+ const segments = url.replace(/^\/+|\/+$/g, '').split('/');
20
+ return segments[segments.length - 1] || url;
21
+ }
22
+ /**
23
+ * Create a SearchImage from a URL string
24
+ */
25
+ function createImage(url, config, altText = null) {
26
+ return {
27
+ url,
28
+ altText,
29
+ width: config.defaultImageWidth,
30
+ height: config.defaultImageHeight,
31
+ };
32
+ }
33
+ /**
34
+ * Create a Money object from a numeric price
35
+ */
36
+ function createMoney(amount, currencyCode) {
37
+ return {
38
+ amount: amount.toFixed(2),
39
+ currencyCode,
40
+ };
41
+ }
42
+ /**
43
+ * Build product options from Wizzy color/size data
44
+ */
45
+ function buildOptions(product) {
46
+ const options = [];
47
+ // Color option
48
+ if (product.colors && product.colors.length > 0) {
49
+ options.push({
50
+ id: `${product.id}-color`,
51
+ name: 'Color',
52
+ values: product.colors.map((c) => c.value),
53
+ });
54
+ }
55
+ // Size option
56
+ if (product.sizes && product.sizes.length > 0) {
57
+ options.push({
58
+ id: `${product.id}-size`,
59
+ name: 'Size',
60
+ values: product.sizes.map((s) => s.value),
61
+ });
62
+ }
63
+ return options;
64
+ }
65
+ /**
66
+ * Build product variants from Wizzy color/size combinations
67
+ *
68
+ * For listing pages, we generate basic variants based on available
69
+ * colors and sizes. Full variant details should be fetched from
70
+ * the product detail endpoint when needed.
71
+ */
72
+ function buildVariants(product, config) {
73
+ const variants = [];
74
+ const { colors, sizes, finalPrice, price } = product;
75
+ // If no colors or sizes, create a single default variant
76
+ if ((!colors || colors.length === 0) && (!sizes || sizes.length === 0)) {
77
+ return [
78
+ {
79
+ id: `${product.id}-default`,
80
+ title: 'Default',
81
+ availableForSale: product.inStock,
82
+ quantityAvailable: null, // Not provided by Wizzy list endpoint
83
+ price: createMoney(finalPrice, config.currencyCode),
84
+ compareAtPrice: price > finalPrice ? createMoney(price, config.currencyCode) : null,
85
+ selectedOptions: [],
86
+ image: product.mainImage
87
+ ? createImage(product.mainImage, config, product.name)
88
+ : null,
89
+ },
90
+ ];
91
+ }
92
+ // Build variants from colors (primary option for fashion)
93
+ const colorsToUse = colors && colors.length > 0 ? colors : [{ value: 'Default', inStock: product.inStock }];
94
+ const sizesToUse = sizes && sizes.length > 0 ? sizes : [{ value: 'Default', inStock: product.inStock }];
95
+ // For listing purposes, create one variant per color
96
+ // (Full color x size matrix would be from PDP)
97
+ for (const color of colorsToUse) {
98
+ const selectedOptions = [];
99
+ if (color.value !== 'Default') {
100
+ selectedOptions.push({ name: 'Color', value: color.value });
101
+ }
102
+ // Find a size that's in stock for this variant
103
+ const availableSize = sizesToUse.find((s) => s.inStock) || sizesToUse[0];
104
+ if (availableSize && availableSize.value !== 'Default') {
105
+ selectedOptions.push({ name: 'Size', value: availableSize.value });
106
+ }
107
+ const isAvailable = color.inStock && (availableSize?.inStock ?? product.inStock);
108
+ variants.push({
109
+ id: `${product.id}-${color.value.toLowerCase().replace(/\s+/g, '-')}`,
110
+ title: color.value === 'Default' ? 'Default' : color.value,
111
+ availableForSale: isAvailable,
112
+ quantityAvailable: null,
113
+ price: createMoney(finalPrice, config.currencyCode),
114
+ compareAtPrice: price > finalPrice ? createMoney(price, config.currencyCode) : null,
115
+ selectedOptions,
116
+ image: product.mainImage
117
+ ? createImage(product.mainImage, config, `${product.name} - ${color.value}`)
118
+ : null,
119
+ });
120
+ }
121
+ return variants;
122
+ }
123
+ /**
124
+ * Map a single WizzyProduct to SearchProduct
125
+ */
126
+ function mapWizzyProduct(wizzyProduct, config = search_types_1.DEFAULT_MAPPER_CONFIG) {
127
+ const handle = extractHandle(wizzyProduct.url);
128
+ // Build price range
129
+ const priceRange = {
130
+ minVariantPrice: createMoney(wizzyProduct.finalPrice, config.currencyCode),
131
+ maxVariantPrice: createMoney(Math.max(wizzyProduct.finalPrice, wizzyProduct.price), config.currencyCode),
132
+ };
133
+ // Build images array
134
+ const images = [];
135
+ if (wizzyProduct.mainImage) {
136
+ images.push(createImage(wizzyProduct.mainImage, config, wizzyProduct.name));
137
+ }
138
+ if (wizzyProduct.images && wizzyProduct.images.length > 0) {
139
+ for (const imgUrl of wizzyProduct.images) {
140
+ // Avoid duplicating mainImage
141
+ if (imgUrl !== wizzyProduct.mainImage) {
142
+ images.push(createImage(imgUrl, config, wizzyProduct.name));
143
+ }
144
+ }
145
+ }
146
+ // Build featured image
147
+ const featuredImage = wizzyProduct.mainImage
148
+ ? createImage(wizzyProduct.mainImage, config, wizzyProduct.name)
149
+ : null;
150
+ return {
151
+ // X fields (existing Product structure)
152
+ id: `wizzy-${wizzyProduct.id}`,
153
+ handle,
154
+ title: wizzyProduct.name,
155
+ description: '', // Not provided by Wizzy - empty default
156
+ descriptionHtml: '', // Not provided by Wizzy - empty default
157
+ vendor: wizzyProduct.brand,
158
+ productType: '', // Not provided by Wizzy - empty default
159
+ tags: [], // Not provided by Wizzy - empty default
160
+ featuredImage,
161
+ images,
162
+ options: buildOptions(wizzyProduct),
163
+ variants: buildVariants(wizzyProduct, config),
164
+ priceRange,
165
+ // Y fields (additional Wizzy-specific)
166
+ wizzyId: wizzyProduct.id,
167
+ groupId: wizzyProduct.groupId,
168
+ gender: wizzyProduct.gender ?? null,
169
+ hoverImage: wizzyProduct.hoverImage ?? null,
170
+ discount: wizzyProduct.discount,
171
+ discountPercentage: wizzyProduct.discountPercentage,
172
+ sellingPrice: wizzyProduct.sellingPrice,
173
+ finalPrice: wizzyProduct.finalPrice,
174
+ originalPrice: wizzyProduct.price,
175
+ categories: wizzyProduct.categories ?? [],
176
+ colors: wizzyProduct.colors ?? [],
177
+ sizes: wizzyProduct.sizes ?? [],
178
+ skus: wizzyProduct.sku ?? [],
179
+ avgRatings: wizzyProduct.avgRatings,
180
+ totalReviews: wizzyProduct.totalReviews,
181
+ attributes: wizzyProduct.attributes ?? [],
182
+ inStock: wizzyProduct.inStock,
183
+ wizzyUrl: wizzyProduct.url,
184
+ };
185
+ }
186
+ /**
187
+ * Map a full Wizzy products response to SearchProductsResponse
188
+ */
189
+ function mapWizzyProductsResponse(wizzyResponse, requestPage = 1, requestProductsCount = 20, config = search_types_1.DEFAULT_MAPPER_CONFIG) {
190
+ const payload = wizzyResponse.payload;
191
+ return {
192
+ products: payload.result.map((p) => mapWizzyProduct(p, config)),
193
+ total: payload.total,
194
+ pages: payload.pages,
195
+ currentPage: requestPage,
196
+ productsPerPage: requestProductsCount,
197
+ hasExactMatch: payload.hasExactMatch ?? false,
198
+ facets: payload.facets ?? [],
199
+ };
200
+ }
201
+ /**
202
+ * Map Wizzy products array to SearchProduct array
203
+ * Useful when you only need the products without metadata
204
+ */
205
+ function mapWizzyProducts(wizzyProducts, config = search_types_1.DEFAULT_MAPPER_CONFIG) {
206
+ return wizzyProducts.map((p) => mapWizzyProduct(p, config));
207
+ }
208
+ //# sourceMappingURL=search.mapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.mapper.js","sourceRoot":"","sources":["../../../src/integrations/search/search.mapper.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AAgKH,0CAsEC;AAKD,4DAiBC;AAMD,4CAKC;AAhQD,iDAWwB;AAExB;;;GAGG;AACH,SAAS,aAAa,CAAC,GAAW;IAChC,gDAAgD;IAChD,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1D,OAAO,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,GAAG,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AI,EAAE,YAAY,CAAC,GAAG,IAAI,EAAE;QAC5B,UAAU,EAAE,YAAY,CAAC,UAAU;QACnC,YAAY,EAAE,YAAY,CAAC,YAAY;QACvC,UAAU,EAAE,YAAY,CAAC,UAAU,IAAI,EAAE;QACzC,OAAO,EAAE,YAAY,CAAC,OAAO;QAC7B,QAAQ,EAAE,YAAY,CAAC,GAAG;KAC3B,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAgB,wBAAwB,CACtC,aAAkD,EAClD,cAAsB,CAAC,EACvB,uBAA+B,EAAE,EACjC,SAA6B,oCAAqB;IAElD,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,CAAC;IAEtC,OAAO;QACL,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;QAC/D,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,WAAW,EAAE,WAAW;QACxB,eAAe,EAAE,oBAAoB;QACrC,aAAa,EAAE,OAAO,CAAC,aAAa,IAAI,KAAK;QAC7C,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;KAC7B,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAgB,gBAAgB,CAC9B,aAA6B,EAC7B,SAA6B,oCAAqB;IAElD,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAC9D,CAAC"}
@@ -0,0 +1,185 @@
1
+ /**
2
+ * Unified Search Types
3
+ *
4
+ * These types represent the mapped search responses that combine
5
+ * the existing Product/Collection structure with Wizzy-specific fields.
6
+ * This ensures no data loss while maintaining API compatibility.
7
+ */
8
+ import { WizzyColorOption, WizzySizeOption, WizzyCategory, WizzyAttribute, WizzyFacet } from './wizzy.types';
9
+ export interface SearchImage {
10
+ url: string;
11
+ altText: string | null;
12
+ width: number;
13
+ height: number;
14
+ }
15
+ export interface SearchMoney {
16
+ amount: string;
17
+ currencyCode: string;
18
+ }
19
+ export interface SearchPriceRange {
20
+ minVariantPrice: SearchMoney;
21
+ maxVariantPrice: SearchMoney;
22
+ }
23
+ export interface SearchSelectedOption {
24
+ name: string;
25
+ value: string;
26
+ }
27
+ export interface SearchProductVariant {
28
+ id: string;
29
+ title: string;
30
+ availableForSale: boolean;
31
+ quantityAvailable: number | null;
32
+ price: SearchMoney;
33
+ compareAtPrice: SearchMoney | null;
34
+ selectedOptions: SearchSelectedOption[];
35
+ image: SearchImage | null;
36
+ }
37
+ export interface SearchProductOption {
38
+ id: string;
39
+ name: string;
40
+ values: string[];
41
+ }
42
+ /**
43
+ * SearchProduct - Unified product structure
44
+ *
45
+ * X fields (existing Product structure):
46
+ * - id, handle, title, description, descriptionHtml, vendor, productType, tags
47
+ * - featuredImage, images, options, variants, priceRange
48
+ *
49
+ * Y fields (additional from Wizzy):
50
+ * - wizzyId, groupId, gender, hoverImage, discount, discountPercentage
51
+ * - sellingPrice, finalPrice, categories, colors, sizes, skus
52
+ * - avgRatings, totalReviews, attributes
53
+ */
54
+ export interface SearchProduct {
55
+ /** Shopify-style ID (mapped from Wizzy id or url) */
56
+ id: string;
57
+ /** Product URL handle (extracted from Wizzy url) */
58
+ handle: string;
59
+ /** Product title (from Wizzy name) */
60
+ title: string;
61
+ /** Product description (empty default - not provided by Wizzy) */
62
+ description: string;
63
+ /** HTML description (empty default - not provided by Wizzy) */
64
+ descriptionHtml: string;
65
+ /** Product vendor/brand (from Wizzy brand) */
66
+ vendor: string;
67
+ /** Product type (empty default - not provided by Wizzy) */
68
+ productType: string;
69
+ /** Product tags (empty default - not provided by Wizzy) */
70
+ tags: string[];
71
+ /** Featured image (from Wizzy mainImage) */
72
+ featuredImage: SearchImage | null;
73
+ /** All product images (from Wizzy images) */
74
+ images: SearchImage[];
75
+ /** Product options - Color/Size derived from Wizzy colors/sizes */
76
+ options: SearchProductOption[];
77
+ /** Product variants (generated from Wizzy color/size combinations) */
78
+ variants: SearchProductVariant[];
79
+ /** Price range (from Wizzy finalPrice/price) */
80
+ priceRange: SearchPriceRange;
81
+ /** Original Wizzy product ID */
82
+ wizzyId: number;
83
+ /** Wizzy group ID for product variants */
84
+ groupId: number;
85
+ /** Product gender (from Wizzy gender) */
86
+ gender: string | null;
87
+ /** Hover/secondary image URL */
88
+ hoverImage: string | null;
89
+ /** Discount amount (absolute) */
90
+ discount: number;
91
+ /** Discount percentage */
92
+ discountPercentage: number;
93
+ /** Selling price (raw number) */
94
+ sellingPrice: number;
95
+ /** Final price after discount (raw number) */
96
+ finalPrice: number;
97
+ /** Original price before discount (raw number) */
98
+ originalPrice: number;
99
+ /** Product categories with metadata */
100
+ categories: WizzyCategory[];
101
+ /** Color options with stock info (original Wizzy structure) */
102
+ colors: WizzyColorOption[];
103
+ /** Size options with stock info (original Wizzy structure) */
104
+ sizes: WizzySizeOption[];
105
+ /** Product SKUs */
106
+ skus: string[];
107
+ /** Average rating score */
108
+ avgRatings: number;
109
+ /** Total number of reviews */
110
+ totalReviews: number;
111
+ /** Additional attributes from Wizzy */
112
+ attributes: WizzyAttribute[];
113
+ /** Stock availability */
114
+ inStock: boolean;
115
+ /** Original Wizzy URL */
116
+ wizzyUrl: string;
117
+ }
118
+ /**
119
+ * Unified search response for product filter/search endpoints
120
+ * Combines mapped products with Wizzy metadata (facets, pagination)
121
+ */
122
+ export interface SearchProductsResponse {
123
+ /** Mapped products in unified structure */
124
+ products: SearchProduct[];
125
+ /** Total number of matching products */
126
+ total: number;
127
+ /** Total number of pages */
128
+ pages: number;
129
+ /** Current page number (1-indexed) */
130
+ currentPage: number;
131
+ /** Products per page */
132
+ productsPerPage: number;
133
+ /** Whether search had exact matches */
134
+ hasExactMatch: boolean;
135
+ /** Facets for filtering UI */
136
+ facets: WizzyFacet[];
137
+ }
138
+ /**
139
+ * Search request with pagination
140
+ */
141
+ export interface SearchProductsRequest {
142
+ /** Search query (for keyword search) */
143
+ q?: string;
144
+ /** Filter options */
145
+ filters?: {
146
+ categories?: string[];
147
+ brands?: string[];
148
+ genders?: string[];
149
+ colors?: string[];
150
+ sizes?: string[];
151
+ groupIds?: string[];
152
+ inStock?: boolean[];
153
+ priceRange?: {
154
+ min?: number;
155
+ max?: number;
156
+ };
157
+ discountPercentage?: {
158
+ min?: number;
159
+ max?: number;
160
+ };
161
+ avgRatings?: {
162
+ min?: number;
163
+ max?: number;
164
+ };
165
+ };
166
+ /** Pagination */
167
+ page?: number;
168
+ productsCount?: number;
169
+ /** Sorting */
170
+ sort?: {
171
+ field: string;
172
+ order: 'asc' | 'desc';
173
+ }[];
174
+ /** Facets to include in response */
175
+ facets?: string[];
176
+ }
177
+ export interface SearchMapperConfig {
178
+ /** Currency code to use for prices (default: 'INR') */
179
+ currencyCode: string;
180
+ /** Default image dimensions when not provided */
181
+ defaultImageWidth: number;
182
+ defaultImageHeight: number;
183
+ }
184
+ export declare const DEFAULT_MAPPER_CONFIG: SearchMapperConfig;
185
+ //# sourceMappingURL=search.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.types.d.ts","sourceRoot":"","sources":["../../../src/integrations/search/search.types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,cAAc,EACd,UAAU,EACX,MAAM,eAAe,CAAC;AAMvB,MAAM,WAAW,WAAW;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,eAAe,EAAE,WAAW,CAAC;IAC7B,eAAe,E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M,CAAC;CAC5B;AAED,eAAO,MAAM,qBAAqB,EAAE,kBAInC,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ /**
3
+ * Unified Search Types
4
+ *
5
+ * These types represent the mapped search responses that combine
6
+ * the existing Product/Collection structure with Wizzy-specific fields.
7
+ * This ensures no data loss while maintaining API compatibility.
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.DEFAULT_MAPPER_CONFIG = void 0;
11
+ exports.DEFAULT_MAPPER_CONFIG = {
12
+ currencyCode: 'INR',
13
+ defaultImageWidth: 800,
14
+ defaultImageHeight: 1000,
15
+ };
16
+ //# sourceMappingURL=search.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search.types.js","sourceRoot":"","sources":["../../../src/integrations/search/search.types.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAqPU,QAAA,qBAAqB,GAAuB;IACvD,YAAY,EAAE,KAAK;IACnB,iBAAiB,EAAE,GAAG;IACtB,kBAAkB,EAAE,IAAI;CACzB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pvh-afl/core",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "AFL Core - Shared services for multi-brand commerce platform",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",