@vectoriox/iox-ui 5.97.0 → 5.98.0

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.
@@ -4,6 +4,7 @@ import {
4
4
  shapeKeys, requiredShapeKeys,
5
5
  } from '@vectoriox/iox-ui/generation-core';
6
6
 
7
+ import { withSellingNeed } from './needs';
7
8
  import { paletteSamples, readPalette } from './palette';
8
9
  import { StyleRead, StyleReadGround, StyleReadHeadings, StyleReadSourceKind } from './rank';
9
10
  import { AnalysisIssue, analysisFromWire, MAX_ANALYSIS_MOODS, SiteAnalysis, siteAnalysisJsonSchema, validateSiteAnalysis } from './site-analysis';
@@ -152,9 +153,14 @@ export function validateSiteReading(value: unknown, ctx: { prompt: string; pictu
152
153
 
153
154
  /** A valid reading's answer → `SiteReading` (the analysis alone answers `{ analysis }`; the facts made a map again). */
154
155
  export function decodeSiteReading(value: unknown, pictureCount: number): SiteReading {
155
- if (pictureCount <= 0) return { analysis: analysisFromWire(value).analysis as SiteAnalysis };
156
+ if (pictureCount <= 0) return { analysis: settled(analysisFromWire(value).analysis as SiteAnalysis) };
156
157
  const reading = value as SiteReading;
157
- return { ...reading, analysis: analysisFromWire(reading.analysis).analysis as SiteAnalysis };
158
+ return { ...reading, analysis: settled(analysisFromWire(reading.analysis).analysis as SiteAnalysis) };
159
+ }
160
+
161
+ /** What a reading's kind of business settles whatever the model wrote: whether it sells (`withSellingNeed`). */
162
+ function settled(analysis: SiteAnalysis): SiteAnalysis {
163
+ return Array.isArray(analysis?.needs) ? { ...analysis, needs: withSellingNeed(analysis.businessType, analysis.needs) } : analysis;
158
164
  }
159
165
 
160
166
  // ── Readings → ONE StyleRead ───────────────────────────────────────────────────────────────────────────