@primestyleai/tryon 5.6.18 → 5.6.19

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.
@@ -330,12 +330,30 @@ async function recommendForProduct(input) {
330
330
  if (!input.skipCache) {
331
331
  const cached = getCachedSize(profile, input.productId);
332
332
  if (cached) {
333
+ const reconstructedRaw = cached.sectionsFull ? {
334
+ recommendedSize: cached.recommendedSize,
335
+ confidence: cached.confidence || "high",
336
+ reasoning: "",
337
+ recommendedLength: cached.recommendedLength,
338
+ sections: Object.fromEntries(
339
+ Object.entries(cached.sectionsFull).map(([name, sec]) => [
340
+ name,
341
+ { ...sec, matchDetails: [] }
342
+ ])
343
+ )
344
+ } : {
345
+ recommendedSize: cached.recommendedSize,
346
+ confidence: cached.confidence || "high",
347
+ reasoning: "",
348
+ recommendedLength: cached.recommendedLength
349
+ };
333
350
  return {
334
351
  recommendedSize: cached.recommendedSize,
335
352
  confidence: cached.confidence,
336
353
  sections: cached.sections,
337
354
  profileId: profile.id,
338
- fromCache: true
355
+ fromCache: true,
356
+ raw: reconstructedRaw
339
357
  };
340
358
  }
341
359
  }
@@ -405,6 +423,19 @@ async function recommendForProduct(input) {
405
423
  const sectionsMap = result.sections ? Object.fromEntries(
406
424
  Object.entries(result.sections).map(([name, sec]) => [name, sec.recommendedSize])
407
425
  ) : void 0;
426
+ const sectionsFull = result.sections ? Object.fromEntries(
427
+ Object.entries(result.sections).map(([name, sec]) => [
428
+ name,
429
+ {
430
+ recommendedSize: sec.recommendedSize,
431
+ // Backend may include these on merged Jacket/Pants entries
432
+ size: sec.size,
433
+ length: sec.length,
434
+ availableSizes: sec.availableSizes,
435
+ availableLengths: sec.availableLengths
436
+ }
437
+ ])
438
+ ) : void 0;
408
439
  addSizeToHistory(profile.id, {
409
440
  productId: input.productId,
410
441
  productTitle: input.productTitle,
@@ -412,6 +443,8 @@ async function recommendForProduct(input) {
412
443
  recommendedSize: result.recommendedSize,
413
444
  confidence: result.confidence,
414
445
  sections: sectionsMap,
446
+ sectionsFull,
447
+ recommendedLength: result.recommendedLength || void 0,
415
448
  savedAt: Date.now()
416
449
  });
417
450
  return {
@@ -32,6 +32,18 @@ export interface SizeHistoryEntry {
32
32
  confidence?: string;
33
33
  /** For multi-section products: { "Jacket Size": "50", "Pants": "34", ... } */
34
34
  sections?: Record<string, string>;
35
+ /** Full per-section data (size/length/availableSizes/...) — preserved so
36
+ * cached recommendations carry the same detail as a fresh API response. */
37
+ sectionsFull?: Record<string, {
38
+ recommendedSize: string;
39
+ size?: string;
40
+ length?: string;
41
+ availableSizes?: string[];
42
+ availableLengths?: string[];
43
+ }>;
44
+ /** Top-level recommended length (single-piece products that have a separate
45
+ * length axis like Regular / Long / Short). */
46
+ recommendedLength?: string;
35
47
  savedAt: number;
36
48
  }
37
49
  export interface Profile {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@primestyleai/tryon",
3
- "version": "5.6.18",
3
+ "version": "5.6.19",
4
4
  "description": "PrimeStyle Virtual Try-On SDK — React component & Web Component",
5
5
  "type": "module",
6
6
  "main": "dist/primestyle-tryon.js",