@vectoriox/iox-ui 5.103.0 → 5.104.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectoriox/iox-ui",
3
- "version": "5.103.0",
3
+ "version": "5.104.0",
4
4
  "peerDependencies": {
5
5
  "@angular/common": ">=20.0.0",
6
6
  "@angular/core": ">=20.0.0",
@@ -16,6 +16,7 @@ export * from './labels';
16
16
  export * from './limits';
17
17
  export * from './vat';
18
18
  export * from './catalog';
19
+ export * from './storefront-fields';
19
20
  export * from './shipping';
20
21
  export * from './coupons';
21
22
  export * from './cart';
@@ -0,0 +1,72 @@
1
+ /**
2
+ * What a VISITOR may see of a shop row (commerce plan F4, iox-cms#67) — the ONE allowlist, here so the server that
3
+ * projects a row (iox-cms `storefront-projection.ts`) and the builder that offers its fields to bind (iox-cms-client#50)
4
+ * read the same list. An ALLOWLIST: a field added to a shop schema stays private until it is named here — stock counts,
5
+ * SKUs, the organization, the build bookkeeping and the sample mark never leave the server.
6
+ */
7
+
8
+ /** A top-level field the storefront serves: `true` as stored, or the sub-fields of each nested row it keeps. */
9
+ export type StorefrontFieldSpec = true | ReadonlyArray<string>;
10
+
11
+ /** The shop collections a storefront reads (iox-cms `ShopCollection`, orders excluded — never public). */
12
+ export enum StorefrontCollection {
13
+ Products = 'products',
14
+ Categories = 'categories',
15
+ SubCategories = 'subCategories',
16
+ }
17
+
18
+ const PRODUCT_FIELDS: Readonly<Record<string, StorefrontFieldSpec>> = {
19
+ _id: true,
20
+ title: true,
21
+ slug: true,
22
+ description: true,
23
+ category: true,
24
+ subCategory: true,
25
+ mainImage: true,
26
+ media: true,
27
+ productVariants: true,
28
+ digital: true,
29
+ pricing: ['price', 'compareat'],
30
+ options: ['_id', 'name', 'values'],
31
+ variants: ['_id', 'enable', 'name', 'image', 'price', 'compareat'],
32
+ };
33
+
34
+ const CATEGORY_FIELDS: Readonly<Record<string, StorefrontFieldSpec>> = { _id: true, label: true, slug: true, color: true };
35
+
36
+ export const STOREFRONT_FIELDS: Readonly<Record<string, Readonly<Record<string, StorefrontFieldSpec>>>> = {
37
+ [StorefrontCollection.Products]: PRODUCT_FIELDS,
38
+ [StorefrontCollection.Categories]: CATEGORY_FIELDS,
39
+ [StorefrontCollection.SubCategories]: { ...CATEGORY_FIELDS, categoryId: true },
40
+ };
41
+
42
+ /**
43
+ * What the server ADDS to a projected row — never stored, so never sortable or filterable: a product's `currency` (ISO
44
+ * 4217) and its stock as a WORD (`availability`, commerce-core `Availability`), also on each variant. A product card
45
+ * binds `availability`, never a count.
46
+ */
47
+ export const STOREFRONT_COMPUTED_FIELDS: Readonly<Record<string, ReadonlyArray<string>>> = {
48
+ [StorefrontCollection.Products]: ['currency', 'availability', 'variants.availability'],
49
+ };
50
+
51
+ /**
52
+ * True when `path` (`title`, `pricing.price`, `variants.name`) is a STORED field a visitor sees — what a storefront
53
+ * query may filter or sort by. A computed field is not one; nor is anything deeper than one nested level.
54
+ */
55
+ export function isStorefrontField(collection: string, path: string): boolean {
56
+ const fields = STOREFRONT_FIELDS[collection];
57
+ if (!fields || typeof path !== 'string') return false;
58
+ const [root, sub, ...rest] = path.split('.');
59
+ const spec = fields[root];
60
+ if (!spec || rest.length) return false;
61
+ return sub === undefined || (spec !== true && spec.includes(sub));
62
+ }
63
+
64
+ /**
65
+ * The fields a page may BIND from a shop source: the stored paths a schema lists that a visitor sees, then the computed
66
+ * ones — a stock count or a SKU in the schema is never offered, because the live site never has it.
67
+ */
68
+ export function storefrontBindPaths(collection: string, schemaPaths: ReadonlyArray<string>): string[] {
69
+ const stored = schemaPaths.filter(path => isStorefrontField(collection, path));
70
+ const computed = (STOREFRONT_COMPUTED_FIELDS[collection] ?? []).filter(path => !stored.includes(path));
71
+ return [...stored, ...computed];
72
+ }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/vectoriox-iox-ui-actions-core.mjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/vectoriox-iox-ui-commerce-core.mjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/vectoriox-iox-ui-composite-core.mjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/vectoriox-iox-ui-consent-core.mjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/vectoriox-iox-ui-data-core.mjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/vectoriox-iox-ui-design-core.mjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/vectoriox-iox-ui-forms-core.mjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/vectoriox-iox-ui-generation-core.mjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/vectoriox-iox-ui-harness-core.mjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/vectoriox-iox-ui-identity-core.mjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/vectoriox-iox-ui-media-core.mjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/vectoriox-iox-ui-scene-core.mjs"
3
- }
@@ -1,3 +0,0 @@
1
- {
2
- "module": "../fesm2022/vectoriox-iox-ui-seo-core.mjs"
3
- }