@vectoriox/iox-ui 5.124.0 → 5.126.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.
@@ -8,7 +8,7 @@ import {
8
8
  patternSlots, PatternGlobalPosition, slotBudget, SCENE_LEVEL, SCENE_OTHER_PAGES } from './patterns';
9
9
  import { ContentFieldControl, FIELD_TYPE_OF_CONTROL,
10
10
  FACT_KEYS, GlobalSlot, PAGE_ARCHETYPES, SITE_NEED_IDS, PlanDataSourceMode, PlanDataSourceType, RelativeOp, REQUIRED_CONTENT_ROLES, ShopResource, SitePlan,
11
- SitePlanSourceKind, SITE_LOCALES, SITE_PLAN_VERSION,
11
+ SitePlanSourceKind, SITE_LOCALES, SITE_PLAN_VERSION, GenerationTier, STAMPED_PAGE_ARCHETYPES,
12
12
  } from './site-plan.model';
13
13
  import { pricesIn } from './plan-words';
14
14
  import { isShopResource, planSells, SHOP_PRODUCTS_MAX, SHOP_SLUG_FIELD, shopContentType } from './shop-plan';
@@ -105,6 +105,11 @@ export interface SitePlanContext {
105
105
  /** True: the business sells (the reading's need `products`) — the plan must name what. False: it sells nothing — the
106
106
  * plan holds no shop. Absent: the plan is judged as written (a template, a stored plan). */
107
107
  readonly sells?: boolean;
108
+ /** The tier the plan was made at (AW-D23) — how many pages it may compose: Basic (and ABSENT — the safe default) at
109
+ * most `site.layout.limits.composedPages`; only an explicit Award lifts the count, to every page that is not a page
110
+ * per item or a stamped type. A plan made on Pro builds after a downgrade because its own generation's stored tier
111
+ * is passed here, never because a tier is missing. */
112
+ readonly tier?: `${GenerationTier}`;
108
113
  }
109
114
 
110
115
  export type SitePlanIssue = PathIssue<SitePlanIssueCode>;
@@ -169,6 +174,17 @@ export function routeParams(route: string): string[] {
169
174
  return [...route.matchAll(ROUTE_PARAM)].map(m => m[1]);
170
175
  }
171
176
 
177
+ /** A page per item — a template page, a page bound to the route item, or a route with a param: it shows its item from
178
+ * patterns and is never composed. Duck-typed: the validator asks it of a page as written. */
179
+ export function isPerItemPage(page: { readonly template?: unknown; readonly routeSource?: unknown; readonly route?: unknown }): boolean {
180
+ return page.template !== undefined || page.routeSource !== undefined || (typeof page.route === 'string' && routeParams(page.route).length > 0);
181
+ }
182
+
183
+ /** How many pages a tier composes at most (Infinity: no count — every page that may be composed). */
184
+ export function composedPagesMax(tier: `${GenerationTier}`): number {
185
+ return tier === GenerationTier.Award ? Infinity : COMPOSED_PAGES_MAX;
186
+ }
187
+
172
188
  class Collector extends PathIssueCollector<SitePlanIssueCode> {
173
189
  constructor() {
174
190
  super('plan', { shape: SitePlanIssueCode.Shape, unknownKey: SitePlanIssueCode.UnknownKey, duplicate: SitePlanIssueCode.Duplicate });
@@ -730,7 +746,7 @@ export function validateSitePlan(plan: unknown, ctx: SitePlanContext = {}): Site
730
746
  validateFilm(c, plan['film'], c.array(plan, 'pages', ''));
731
747
  validateArtDirection(c, plan['artDirection']);
732
748
  validateDirection(c, plan['direction']);
733
- validateComposed(c, c.array(plan, 'pages', ''));
749
+ validateComposed(c, c.array(plan, 'pages', ''), ctx.tier);
734
750
  return { valid: c.issues.length === 0, issues: c.issues };
735
751
  }
736
752
 
@@ -751,7 +767,7 @@ function validateDirection(c: Collector, direction: unknown): void {
751
767
  * item); a layout only on a page marked `compose`, its dial one of the dials and 4–8 sections (the rest is `checkLayout`'s
752
768
  * — the plan stage runs it with the photos, `layoutIssues` on a whole plan).
753
769
  */
754
- function validateComposed(c: Collector, pages: unknown[]): void {
770
+ function validateComposed(c: Collector, pages: unknown[], tier: `${GenerationTier}` | undefined): void {
755
771
  let composed = 0;
756
772
  pages.forEach((raw, i) => {
757
773
  if (!isObject(raw)) return;
@@ -760,8 +776,10 @@ function validateComposed(c: Collector, pages: unknown[]): void {
760
776
  const compose = raw['compose'] === true;
761
777
  if (compose) {
762
778
  composed++;
763
- if (raw['template'] !== undefined || raw['routeSource'] !== undefined || (typeof raw['route'] === 'string' && routeParams(raw['route']).length)) {
779
+ if (isPerItemPage(raw)) {
764
780
  c.add(SitePlanIssueCode.Compose, `${path}.compose`, 'a per-item page shows its item from patterns — it is not composed');
781
+ } else if (tier === GenerationTier.Award && typeof raw['archetype'] === 'string' && STAMPED_PAGE_ARCHETYPES.has(raw['archetype'])) {
782
+ c.add(SitePlanIssueCode.Compose, `${path}.compose`, `a ${raw['archetype']} page is stamped from patterns — it is not composed`);
765
783
  }
766
784
  }
767
785
  const layout = raw['layout'];
@@ -772,7 +790,7 @@ function validateComposed(c: Collector, pages: unknown[]): void {
772
790
  if (!LAYOUT_DIALS.includes(String(layout['dial']))) c.add(SitePlanIssueCode.Layout, `${path}.layout.dial`, LAYOUT_DIALS.join(' | '));
773
791
  if (!Array.isArray(layout['sections'])) c.add(SitePlanIssueCode.Shape, `${path}.layout.sections`, 'must be an array');
774
792
  });
775
- if (composed > COMPOSED_PAGES_MAX) c.add(SitePlanIssueCode.Compose, 'pages', `${composed} composed pages — the home page and at most ${COMPOSED_PAGES_MAX - 1} other`);
793
+ if (composed > composedPagesMax(tier ?? GenerationTier.Basic)) c.add(SitePlanIssueCode.Compose, 'pages', `${composed} composed pages — the home page and at most ${COMPOSED_PAGES_MAX - 1} other`);
776
794
  }
777
795
 
778
796
  /** The plan's content types and, for each shop list a source reads, the shop's own (fixed fields and roles). */
@@ -787,8 +805,8 @@ function withShopTypes(types: Map<string, ContentTypeInfo>, sources: Map<string,
787
805
  }
788
806
 
789
807
  /** Throw a `SitePlanError` carrying every issue unless the plan is valid. */
790
- export function assertValidSitePlan(plan: unknown): void {
791
- const result = validateSitePlan(plan);
808
+ export function assertValidSitePlan(plan: unknown, ctx: SitePlanContext = {}): void {
809
+ const result = validateSitePlan(plan, ctx);
792
810
  if (!result.valid) throw new SitePlanError(result.issues);
793
811
  }
794
812