@vectoriox/iox-ui 5.96.2 → 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.
Files changed (38) hide show
  1. package/commerce-core/index.d.ts +274 -2
  2. package/fesm2022/vectoriox-iox-ui-commerce-core.mjs +312 -1
  3. package/fesm2022/vectoriox-iox-ui-commerce-core.mjs.map +1 -1
  4. package/fesm2022/vectoriox-iox-ui-composite-core.mjs +2 -8
  5. package/fesm2022/vectoriox-iox-ui-composite-core.mjs.map +1 -1
  6. package/fesm2022/vectoriox-iox-ui-generation-core.mjs +1114 -223
  7. package/fesm2022/vectoriox-iox-ui-generation-core.mjs.map +1 -1
  8. package/fesm2022/vectoriox-iox-ui-harness-core.mjs +115 -42
  9. package/fesm2022/vectoriox-iox-ui-harness-core.mjs.map +1 -1
  10. package/generation-core/index.d.ts +515 -17
  11. package/harness-core/index.d.ts +66 -6
  12. package/package.json +1 -1
  13. package/src/commerce-core/public-api.ts +2 -0
  14. package/src/commerce-core/shipping.ts +22 -0
  15. package/src/commerce-core/site-checkout.ts +406 -0
  16. package/src/commerce-core/variants.ts +20 -0
  17. package/src/composite-core/shop-runtime.ts +2 -8
  18. package/src/generation-core/audit-site.ts +8 -0
  19. package/src/generation-core/compose-site.ts +130 -4
  20. package/src/generation-core/nav-shape.ts +4 -2
  21. package/src/generation-core/patterns.ts +25 -1
  22. package/src/generation-core/pictures.ts +1 -1
  23. package/src/generation-core/plan-derived.ts +10 -5
  24. package/src/generation-core/plan-edits.ts +8 -7
  25. package/src/generation-core/plan-wire.ts +59 -10
  26. package/src/generation-core/plan-words.ts +18 -1
  27. package/src/generation-core/public-api.ts +1 -0
  28. package/src/generation-core/shop-plan.ts +165 -0
  29. package/src/generation-core/showcase.ts +29 -4
  30. package/src/generation-core/site-build-run.ts +25 -0
  31. package/src/generation-core/site-plan.model.ts +49 -1
  32. package/src/generation-core/site-spec.generated.ts +330 -2
  33. package/src/generation-core/stock-photos.ts +19 -2
  34. package/src/generation-core/validate-site-plan.ts +146 -8
  35. package/src/harness-core/business-types.ts +13 -0
  36. package/src/harness-core/harness-spec.generated.ts +69 -39
  37. package/src/harness-core/needs.ts +30 -1
  38. package/src/harness-core/site-reading.ts +8 -2
@@ -0,0 +1,165 @@
1
+ import { VARIANT_NAME_SEPARATOR } from '@vectoriox/iox-ui/commerce-core';
2
+
3
+ import { isNonEmptyString, isPlainObject, PlainObject } from './shape-check';
4
+ import {
5
+ ContentFieldControl, ContentFieldPlan, ContentRoles, ContentTypePlan, DataSourcePlan, FIELD_TYPE_OF_CONTROL, PlanDataSourceMode, PlanDataSourceType,
6
+ ShopDataSourcePlan, ShopProductPlan, ShopResource, SitePlan,
7
+ } from './site-plan.model';
8
+
9
+ /**
10
+ * Commerce C-D21 (track G1; shop-aware A-D1, A-D2): a selling business's products are the studio's SHOP — never a
11
+ * content type of the plan. What a plan says about the shop is only WHAT the business sells (`plan.shop`: up to six
12
+ * sample products by name, their categories, how they vary — never a price, stock or a fee). Everything that follows
13
+ * from selling is derived here, never asked: the shop's data sources (the list, the newest, one product by its slug), the
14
+ * roles its rows play (fixed — the shop's own fields), and that the site is a whole store (the composer's cart button and
15
+ * cart drawer). Pure.
16
+ */
17
+
18
+ /** The need a reading names for a business that sells (harness-core `NEEDS.products`). */
19
+ export const SHOP_NEED = 'products';
20
+
21
+ /** At most this many sample products in a plan (commerce §3j: "≤ 6 sample products by name"). */
22
+ export const SHOP_PRODUCTS_MAX = 6;
23
+
24
+ /** The field each role is on a shop row — the storefront's own fields (iox-cms `storefront-projection.ts`). */
25
+ export const SHOP_ROLES: Readonly<Record<`${ShopResource}`, ContentRoles>> = {
26
+ [ShopResource.Products]: {
27
+ title: 'title', summary: 'description', image: 'mainImage', gallery: 'media', price: 'pricing.price', compareAt: 'pricing.compareat',
28
+ },
29
+ [ShopResource.Categories]: { title: 'label' },
30
+ };
31
+
32
+ const field = (name: string, controller: ContentFieldControl): ContentFieldPlan => ({ name, type: FIELD_TYPE_OF_CONTROL[controller], controller });
33
+
34
+ /** The shop's fields as a pattern's list rules read them (`patternListGap`): its own, fixed. */
35
+ export const SHOP_FIELDS: Readonly<Record<`${ShopResource}`, ReadonlyArray<ContentFieldPlan>>> = {
36
+ [ShopResource.Products]: [
37
+ field('title', ContentFieldControl.Text), field('slug', ContentFieldControl.Text), field('description', ContentFieldControl.Textarea),
38
+ field('mainImage', ContentFieldControl.Media), field('media', ContentFieldControl.Gallery),
39
+ field('pricing.price', ContentFieldControl.Number), field('pricing.compareat', ContentFieldControl.Number),
40
+ ],
41
+ [ShopResource.Categories]: [field('label', ContentFieldControl.Text), field('slug', ContentFieldControl.Text)],
42
+ };
43
+
44
+ const SHOP_LABELS: Readonly<Record<`${ShopResource}`, string>> = { [ShopResource.Products]: 'Products', [ShopResource.Categories]: 'Categories' };
45
+
46
+ /** The shop list as the composer and the validator read a content type: its fixed roles and fields. Never written. */
47
+ export function shopContentType(resource: `${ShopResource}`): ContentTypePlan {
48
+ return { name: resource, label: SHOP_LABELS[resource], roles: SHOP_ROLES[resource], fields: SHOP_FIELDS[resource] };
49
+ }
50
+
51
+ export const isShopResource = (value: unknown): value is `${ShopResource}` => (Object.values(ShopResource) as unknown[]).includes(value);
52
+
53
+ /** The field a product page's route param matches (the shop's slug, shop-aware §3d). */
54
+ export const SHOP_SLUG_FIELD = 'slug';
55
+ /** How many products the shop's list shows (shop-aware §8: one page, no paging until Plan B). */
56
+ export const SHOP_LIST_LIMIT = 24;
57
+ /** How many the newest list shows (a home page's row of cards). */
58
+ export const SHOP_LATEST_LIMIT = 3;
59
+
60
+ /** The shop's sources a selling plan holds — derived (`derivedShopSources`), each by its part in the store. */
61
+ export enum ShopSourceRole {
62
+ /** Every product (the shop page). */
63
+ List = 'list',
64
+ /** The newest few (the home page). */
65
+ Latest = 'latest',
66
+ /** One product, by the route's `:slug` (the product page). */
67
+ Item = 'item',
68
+ }
69
+
70
+ interface ShopSourceSpec {
71
+ alias: string;
72
+ mode: `${PlanDataSourceMode}`;
73
+ limit?: number;
74
+ byRoute?: boolean;
75
+ }
76
+
77
+ const SHOP_SOURCE_SPECS: Readonly<Record<ShopSourceRole, ShopSourceSpec>> = {
78
+ [ShopSourceRole.List]: { alias: 'products', mode: PlanDataSourceMode.Query, limit: SHOP_LIST_LIMIT },
79
+ [ShopSourceRole.Latest]: { alias: 'productsLatest', mode: PlanDataSourceMode.Query, limit: SHOP_LATEST_LIMIT },
80
+ [ShopSourceRole.Item]: { alias: 'product', mode: PlanDataSourceMode.Single, byRoute: true },
81
+ };
82
+
83
+ const SHOP_ROUTE_PARAM = 'slug';
84
+
85
+ /** The source a role is: the products list it reads, its mode, its limit, its route lookup. */
86
+ function shopSourceOf(role: ShopSourceRole, alias: string): ShopDataSourcePlan {
87
+ const spec = SHOP_SOURCE_SPECS[role];
88
+ return {
89
+ alias, type: PlanDataSourceType.Shop, mode: spec.mode, resource: ShopResource.Products,
90
+ ...(spec.limit ? { limit: spec.limit } : {}),
91
+ ...(spec.byRoute ? { filterByRouteParam: { field: SHOP_SLUG_FIELD, routeParam: SHOP_ROUTE_PARAM } } : {}),
92
+ };
93
+ }
94
+
95
+ /** The role a source plays in the store, or null (a source of some other shape stays the plan's own). */
96
+ function roleOfSource(raw: unknown): ShopSourceRole | null {
97
+ if (!isPlainObject(raw) || raw['type'] !== PlanDataSourceType.Shop || raw['resource'] !== ShopResource.Products) return null;
98
+ for (const [role, spec] of Object.entries(SHOP_SOURCE_SPECS) as Array<[ShopSourceRole, ShopSourceSpec]>) {
99
+ if (raw['mode'] !== spec.mode) continue;
100
+ const byRoute = isPlainObject(raw['filterByRouteParam']);
101
+ if (spec.byRoute ? byRoute : !byRoute && raw['limit'] === spec.limit) return role;
102
+ }
103
+ return null;
104
+ }
105
+
106
+ /** True when `plan` (a plan, or a part of one being written) says the business sells: its `shop` names a product. */
107
+ export function planSells(plan: unknown): boolean {
108
+ const shop = isPlainObject(plan) ? plan['shop'] : undefined;
109
+ return isPlainObject(shop) && Array.isArray(shop['products']) && shop['products'].length > 0;
110
+ }
111
+
112
+ /** The store's sources a plan holds, by role (the first of each) — the aliases the pages bind. */
113
+ export function shopSourceAliases(plan: unknown): Partial<Record<ShopSourceRole, string>> {
114
+ const out: Partial<Record<ShopSourceRole, string>> = {};
115
+ const list = isPlainObject(plan) && Array.isArray(plan['dataSources']) ? plan['dataSources'] : [];
116
+ for (const raw of list) {
117
+ const role = roleOfSource(raw);
118
+ if (role && !out[role] && isNonEmptyString((raw as PlainObject)['alias'])) out[role] = (raw as PlainObject)['alias'] as string;
119
+ }
120
+ return out;
121
+ }
122
+
123
+ /** The alias itself, else the first of `<alias>2`, `<alias>3`… no source has. */
124
+ function freeAlias(base: string, taken: ReadonlySet<string>): string {
125
+ let alias = base;
126
+ for (let n = 2; taken.has(alias); n++) alias = `${base}${n}`;
127
+ return alias;
128
+ }
129
+
130
+ /**
131
+ * The shop sources a selling plan lacks (shop-aware A-D1, the derived-not-asked rule of `plan-derived.ts`): the list,
132
+ * the newest and one product by its slug. Idempotent — a plan holding one of each gains nothing; a plan that sells
133
+ * nothing gains nothing. Tolerates any value.
134
+ */
135
+ export function derivedShopSources(plan: unknown): DataSourcePlan[] {
136
+ if (!planSells(plan) || !Array.isArray((plan as PlainObject)['dataSources'])) return [];
137
+ const have = shopSourceAliases(plan);
138
+ const taken = new Set(((plan as PlainObject)['dataSources'] as unknown[]).map(d => (isPlainObject(d) ? d['alias'] : undefined)).filter(isNonEmptyString));
139
+ const out: DataSourcePlan[] = [];
140
+ for (const role of Object.values(ShopSourceRole)) {
141
+ if (have[role]) continue;
142
+ const alias = freeAlias(SHOP_SOURCE_SPECS[role].alias, taken);
143
+ taken.add(alias);
144
+ out.push(shopSourceOf(role, alias));
145
+ }
146
+ return out;
147
+ }
148
+
149
+ /** The categories of a plan's products, in order, each once (what the wire derives from the products). */
150
+ export function shopCategoriesOf(products: ReadonlyArray<Pick<ShopProductPlan, 'category'>>): string[] {
151
+ return [...new Set(products.map(p => p.category).filter(isNonEmptyString).map(c => c.trim()))];
152
+ }
153
+
154
+ /** True when `plan` holds a shop source (a whole store's data). */
155
+ export function planHasShopSource(plan: Pick<SitePlan, 'dataSources'>): boolean {
156
+ return plan.dataSources.some(d => d.type === PlanDataSourceType.Shop);
157
+ }
158
+
159
+ /** A product's variants by name — one per combination of its options' values, in order (`Glaze-Sand-24 cm`'s shape, the
160
+ * shop's own: `VARIANT_NAME_SEPARATOR`). No options: none (the shop keeps its one Default). */
161
+ export function variantNamesOf(options: ReadonlyArray<{ readonly values: ReadonlyArray<string> }>): string[] {
162
+ const lists = options.map(o => o.values).filter(v => v.length);
163
+ if (!lists.length) return [];
164
+ return lists.reduce<string[][]>((combos, values) => combos.flatMap(c => values.map(v => [...c, v])), [[]]).map(c => c.join(VARIANT_NAME_SEPARATOR));
165
+ }
@@ -2,7 +2,9 @@ import type { DesignChoices } from '@vectoriox/iox-ui/design-core';
2
2
  import { FILM_PREPARED_PICTURES, FrameExtension, FrameSequence } from '@vectoriox/iox-ui/media-core';
3
3
 
4
4
  import { BindScope, patternNeedsBinding, PatternGlobalPosition, patternScopes, SCENE_LEVEL, SITE_PATTERNS } from './patterns';
5
- import { GlobalSlot, PagePlan, PageSectionPlan, SiteBusiness, SiteLocale, SitePlan, SitePlanSourceKind, SITE_PLAN_VERSION } from './site-plan.model';
5
+ import { withDerivedSources } from './plan-derived';
6
+ import { GlobalSlot, PagePlan, PageSectionPlan, ShopPlan, ShopResource, SiteBusiness, SiteLocale, SitePlan, SitePlanSourceKind, SITE_PLAN_VERSION } from './site-plan.model';
7
+ import { shopCategoriesOf, ShopSourceRole, shopSourceAliases } from './shop-plan';
6
8
  import { STUDIO_TEMPLATE } from './templates';
7
9
 
8
10
  /**
@@ -49,7 +51,7 @@ export function showcasePages(): PagePlan[] {
49
51
  const byFamily = new Map<string, string[]>();
50
52
  const onItemPage: string[] = [];
51
53
  for (const [id, p] of Object.entries(SITE_PATTERNS)) {
52
- if (p.global || p.scene) continue;
54
+ if (p.global || p.scene || p.shop) continue;
53
55
  if (readsRouteItem(id)) { onItemPage.push(id); continue; }
54
56
  byFamily.set(p.family, [...(byFamily.get(p.family) ?? []), id]);
55
57
  }
@@ -77,10 +79,31 @@ export function showcaseScenes(): string[] {
77
79
  return Object.entries(SITE_PATTERNS).filter(([, p]) => p.scene && !p.global).map(([id]) => id);
78
80
  }
79
81
 
82
+ /** Commerce G1: what the showcase's store sells — three samples in two categories, one with options; never a price. */
83
+ const SHOWCASE_PRODUCTS: ShopPlan['products'] = [
84
+ { name: 'Tall speckled vase', category: 'Vases', description: 'Thrown by hand, glazed in two tones.', options: [{ name: 'Glaze', values: ['Sand', 'Charcoal'] }, { name: 'Size', values: ['24 cm', '32 cm'] }] },
85
+ { name: 'Low serving bowl', category: 'Tableware', description: 'Wide and shallow, for the middle of the table.', options: [] },
86
+ { name: 'Bud vase', category: 'Vases', description: 'One stem, one shelf.', options: [] },
87
+ ];
88
+ export const SHOWCASE_SHOP: ShopPlan = { categories: shopCategoriesOf(SHOWCASE_PRODUCTS), products: SHOWCASE_PRODUCTS };
89
+
90
+ /** The store patterns (`shop`), each on the page a store shows it on: a list on the shop page, one product on its own. */
91
+ export function showcaseStorePages(sources: Partial<Record<ShopSourceRole, string>>): PagePlan[] {
92
+ const store = Object.entries(SITE_PATTERNS).filter(([, p]) => p.shop && !p.global);
93
+ const list = store.filter(([id]) => !readsRouteItem(id)).map(([id]) => ({ pattern: id, binding: sources[ShopSourceRole.List] }));
94
+ const item = store.filter(([id]) => readsRouteItem(id)).map(([id]) => ({ pattern: id }));
95
+ return [
96
+ { key: 'home', name: 'Home', route: '/', isHome: true, inNav: false, sections: [] },
97
+ { key: 'shop', name: 'Shop', route: '/shop', inNav: true, sections: list },
98
+ { key: 'product', name: 'Product', route: '/shop/:slug', inNav: false, template: ShopResource.Products, routeSource: sources[ShopSourceRole.Item], sections: item },
99
+ ];
100
+ }
101
+
80
102
  /**
81
103
  * The showcase as Site Plans — as many as it takes for every header and every footer to be composed once, then one per
82
104
  * Scene pattern (SC6): its home page holds that Scene and nothing else, at How animated Expressive, the only level a
83
- * Scene is composed at; the film's Scene with a film (SC6b).
105
+ * Scene is composed at; the film's Scene with a film (SC6b); then the store (commerce G1): the store patterns over the
106
+ * shop's derived sources, with the bag in the header and the cart drawer.
84
107
  */
85
108
  export function showcasePlans(input: ShowcaseInput): SitePlan[] {
86
109
  const { headers, footers } = showcaseGlobals();
@@ -102,5 +125,7 @@ export function showcasePlans(input: ShowcaseInput): SitePlan[] {
102
125
  // A film's Scene plays a film (SC6b): the plan carries one, as the build's would.
103
126
  return SITE_PATTERNS[id].film ? { ...scene, film: { sequence: JSON.parse(JSON.stringify(input.film ?? SHOWCASE_FILM)) } } : scene;
104
127
  });
105
- return [...Array.from({ length: count }, (_, i) => plan(i, pages, input.design)), ...scenes];
128
+ const selling = withDerivedSources({ ...plan(0, [], input.design), shop: JSON.parse(JSON.stringify(SHOWCASE_SHOP)) as ShopPlan });
129
+ const store: SitePlan = { ...selling, pages: showcaseStorePages(shopSourceAliases(selling)) };
130
+ return [...Array.from({ length: count }, (_, i) => plan(i, pages, input.design)), ...scenes, store];
106
131
  }
@@ -1,6 +1,7 @@
1
1
  import { ComposedPlaceholder, ComposeIssue } from './compose-site';
2
2
  import { SitePlan, SitePlanSource } from './site-plan.model';
3
3
  import { SitePlanIssueCode } from './validate-site-plan';
4
+ import { planSells } from './shop-plan';
4
5
 
5
6
  /**
6
7
  * A site build's WIRE vocabulary (AI plan §3b, W2): what iox-cms's `site-builds` API answers and what every
@@ -32,6 +33,8 @@ export enum BuildStep {
32
33
  /** I2: the curated stock photos the plan's empty picture slots take, copied into the studio (never hot-linked). */
33
34
  StockPhotos = 'stock-photos',
34
35
  Items = 'items',
36
+ /** Commerce G1: what the business sells, into the studio's SHOP — its categories, then sample products (no price). */
37
+ Shop = 'shop',
35
38
  DataSources = 'data-sources',
36
39
  Pages = 'pages',
37
40
  Globals = 'globals',
@@ -40,6 +43,12 @@ export enum BuildStep {
40
43
 
41
44
  export const BUILD_STEPS: ReadonlyArray<BuildStep> = Object.values(BuildStep);
42
45
 
46
+ /** The steps a build of `plan` takes, in order: every one, the shop's only when the plan sells (commerce G1). */
47
+ export function buildStepsOf(plan: unknown): BuildStep[] {
48
+ const sells = planSells(plan);
49
+ return BUILD_STEPS.filter(step => step !== BuildStep.Shop || sells);
50
+ }
51
+
43
52
  export enum StepState {
44
53
  Wait = 'wait',
45
54
  Run = 'run',
@@ -56,6 +65,10 @@ export enum CreatedKind {
56
65
  /** A stock photo copied into the studio's storage (`media/stock/…`), with its assets row. */
57
66
  StockPhoto = 'stock-photo',
58
67
  Item = 'item',
68
+ /** Commerce G1: a shop category the build added (one the studio had is reused, never recorded). */
69
+ ShopCategory = 'shop-category',
70
+ /** Commerce G1: a sample product, written through the shop's own write path. */
71
+ ShopProduct = 'shop-product',
59
72
  DataSource = 'data-source',
60
73
  Page = 'page',
61
74
  Global = 'global',
@@ -132,6 +145,11 @@ export enum BuildNoticeCode {
132
145
  /** M7: a picture made for the site was refused by its review twice (or its second try did not fit the cost shown):
133
146
  * stock or the empty box stands in, and the run says so. */
134
147
  PictureFallback = 'picture-fallback',
148
+ /** Commerce G1 (shop-aware A-D9): the studio already sells products — the site shows them, and no sample is added. */
149
+ ShopHasProducts = 'shop-has-products',
150
+ /** Commerce G1: the studio had never set its currency and VAT — the build stored the ones its language implies
151
+ * (Hebrew: ILS and 18%), said here so the owner checks them in Settings ▸ General before setting prices. */
152
+ ShopMoneyInferred = 'shop-money-inferred',
135
153
  }
136
154
 
137
155
  export interface BuildNotice {
@@ -206,6 +224,8 @@ export const buildKeys = {
206
224
  contentType: (name: string) => `schema:${name}`,
207
225
  contentTypeFields: (name: string) => `schema-fields:${name}`,
208
226
  item: (contentType: string, n: number) => `item:${contentType}:${n}`,
227
+ shopCategory: (n: number) => `shop-category:${n}`,
228
+ shopProduct: (n: number) => `shop-product:${n}`,
209
229
  sampleImage: (n: number) => `sample-image:${n}`,
210
230
  stockPhoto: (libraryKey: string) => `stock-photo:${libraryKey}`,
211
231
  dataSource: (alias: string) => `data-source:${alias}`,
@@ -249,6 +269,9 @@ export interface BuildStepFacts {
249
269
  contentTypeActions: Partial<Record<ContentTypeAction, string[]>>;
250
270
  /** Sample items, all types together. */
251
271
  items: number;
272
+ /** Commerce G1: sample products for the shop (0 = the plan sells nothing) and their categories. */
273
+ products: number;
274
+ categories: number;
252
275
  /** Pages (template pages included) and their routes. */
253
276
  pages: number;
254
277
  routes: string[];
@@ -268,6 +291,8 @@ export function buildStepFacts(plan: SitePlan, actions: Readonly<Record<string,
268
291
  contentTypes: plan.contentTypes.map(t => t.label),
269
292
  contentTypeActions,
270
293
  items: plan.contentTypes.reduce((n, t) => n + (t.seed?.count ?? 0), 0),
294
+ products: plan.shop?.products.length ?? 0,
295
+ categories: plan.shop?.categories.length ?? 0,
271
296
  pages: plan.pages.length,
272
297
  routes: plan.pages.map(p => p.route),
273
298
  navLinks: plan.pages.filter(p => p.inNav).length,
@@ -96,8 +96,15 @@ export enum ContentRole {
96
96
  Meta = 'meta',
97
97
  Date = 'date',
98
98
  Gallery = 'gallery',
99
+ /** Commerce C-D21: the shop's own price — played only by the shop's fields (`SHOP_ROLES`), never a content type's. */
100
+ Price = 'price',
101
+ /** Commerce C-D21: the shop's earlier price, struck through. */
102
+ CompareAt = 'compareAt',
99
103
  }
100
104
 
105
+ /** The roles only the shop plays (contract `site.roles` less `planShape.roles`): a content type never names them. */
106
+ export const SHOP_ONLY_CONTENT_ROLES: ReadonlyArray<`${ContentRole}`> = [ContentRole.Price, ContentRole.CompareAt];
107
+
101
108
  /** What each role means, verbatim from the contract — what the model reads. */
102
109
  export const CONTENT_ROLE_MEANINGS: Readonly<Record<`${ContentRole}`, string>> = SPEC_SITE_ROLES;
103
110
  export const REQUIRED_CONTENT_ROLES: ReadonlyArray<`${ContentRole}`> = SPEC_SITE_REQUIRED_ROLES;
@@ -126,6 +133,14 @@ export function roleField(type: Pick<ContentTypePlan, 'roles'> | null | undefine
126
133
  export enum PlanDataSourceType {
127
134
  Cms = 'cms',
128
135
  Relative = 'relative',
136
+ /** Commerce C-D21 (shop-aware A-D1): the studio's SHOP — products a visitor buys are never a content type. */
137
+ Shop = 'shop',
138
+ }
139
+
140
+ /** The shop lists a plan's shop source may read (closed, so a plan can never name `orders`). */
141
+ export enum ShopResource {
142
+ Products = 'products',
143
+ Categories = 'categories',
129
144
  }
130
145
 
131
146
  export enum PlanDataSourceMode {
@@ -158,7 +173,37 @@ export interface RelativeDataSourcePlan {
158
173
  readonly within: string;
159
174
  }
160
175
 
161
- export type DataSourcePlan = CmsDataSourcePlan | RelativeDataSourcePlan;
176
+ /** Commerce C-D21: a list of the shop (or one row of it, by a route param) — derived from the plan's `shop`, never asked. */
177
+ export interface ShopDataSourcePlan {
178
+ readonly alias: string;
179
+ readonly type: `${PlanDataSourceType.Shop}`;
180
+ readonly mode: `${PlanDataSourceMode}`;
181
+ readonly resource: `${ShopResource}`;
182
+ readonly limit?: number;
183
+ readonly filterByRouteParam?: { readonly field: string; readonly routeParam: string };
184
+ }
185
+
186
+ export type DataSourcePlan = CmsDataSourcePlan | RelativeDataSourcePlan | ShopDataSourcePlan;
187
+
188
+ /** One way a product varies (Size: S, M, L). */
189
+ export interface ShopOptionPlan {
190
+ readonly name: string;
191
+ readonly values: ReadonlyArray<string>;
192
+ }
193
+
194
+ /** A sample product, by name (commerce §3j): never a price, stock or a fee — the owner sets those. */
195
+ export interface ShopProductPlan {
196
+ readonly name: string;
197
+ readonly category: string;
198
+ readonly description: string;
199
+ readonly options: ReadonlyArray<ShopOptionPlan>;
200
+ }
201
+
202
+ /** What the business sells (commerce C-D21): its categories and up to six sample products. */
203
+ export interface ShopPlan {
204
+ readonly categories: ReadonlyArray<string>;
205
+ readonly products: ReadonlyArray<ShopProductPlan>;
206
+ }
162
207
 
163
208
  export interface PageSectionPlan {
164
209
  readonly pattern: string;
@@ -254,6 +299,9 @@ export interface SitePlan {
254
299
  readonly dataSources: ReadonlyArray<DataSourcePlan>;
255
300
  readonly pages: ReadonlyArray<PagePlan>;
256
301
  readonly globals: Readonly<Record<`${GlobalSlot}`, string>>;
302
+ /** Commerce C-D21: what the business sells — present = the site is a whole store (shop sources, product pages, the
303
+ * cart button in the header, the cart drawer). */
304
+ readonly shop?: ShopPlan;
257
305
  /** SC6b: the owner's film as pictures, set by the build and placed by `placeFilm` — never a model's. */
258
306
  readonly film?: PlanFilm;
259
307
  /** M7: what every picture made for the site shares (a world and its five parts) — set by the generation from the