platform-types 1.10.753 → 1.10.754

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.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.STOREFRONT_PREVIEW_PROTOCOL_ERRORS = exports.STOREFRONT_PREVIEW_READ_OPERATIONS = exports.STOREFRONT_BENEFIT_ICONS = exports.STOREFRONT_RESERVED_SLUGS = exports.STOREFRONT_CONTACT_FIELDS = exports.STOREFRONT_PROTECTED_BUILTIN_DESTINATIONS = exports.STOREFRONT_BUILTIN_DESTINATIONS = exports.STOREFRONT_REPEATABLE_SECTION_TYPES = exports.STOREFRONT_SECTION_TYPES = exports.isStorefrontPageSlug = exports.STOREFRONT_PAGE_SLUG_RE = exports.STOREFRONT_DESIGN_LIMITS = exports.STOREFRONT_SOCIAL_HOSTS = void 0;
3
+ exports.STOREFRONT_PREVIEW_PROTOCOL_ERRORS = exports.STOREFRONT_PREVIEW_READ_OPERATIONS = exports.STOREFRONT_DESIGN_AUDIENCES = exports.STOREFRONT_BENEFIT_ICONS = exports.STOREFRONT_RESERVED_SLUGS = exports.STOREFRONT_CONTACT_FIELDS = exports.STOREFRONT_PROTECTED_BUILTIN_DESTINATIONS = exports.STOREFRONT_BUILTIN_DESTINATIONS = exports.STOREFRONT_REPEATABLE_SECTION_TYPES = exports.STOREFRONT_SECTION_TYPES = exports.isStorefrontPageSlug = exports.STOREFRONT_PAGE_SLUG_RE = exports.STOREFRONT_DESIGN_LIMITS = exports.STOREFRONT_SOCIAL_HOSTS = void 0;
4
4
  exports.createStorefrontDesignV1 = createStorefrontDesignV1;
5
5
  exports.parseStorefrontPreviewDocument = parseStorefrontPreviewDocument;
6
6
  exports.parseStorefrontPreviewMessage = parseStorefrontPreviewMessage;
@@ -37,6 +37,8 @@ exports.STOREFRONT_DESIGN_LIMITS = {
37
37
  benefits: 8,
38
38
  historyEntries: 20,
39
39
  selectedSourceIds: 50,
40
+ /** A `visibility` rule's `priceLists`: the store's own cap on price lists. */
41
+ visibilityPriceLists: 64,
40
42
  documentBytes: 256 * 1024,
41
43
  heading: 120,
42
44
  label: 80,
@@ -168,6 +170,12 @@ exports.STOREFRONT_RESERVED_SLUGS = [
168
170
  'mantenimiento',
169
171
  ];
170
172
  exports.STOREFRONT_BENEFIT_ICONS = ['truck', 'shield', 'credit-card', 'store', 'heart', 'check'];
173
+ /**
174
+ * Who a `visibility` rule may name. `guest`: no approved customer resolved. `customer`: any
175
+ * approved customer. `retail` / `wholesale`: an approved customer whose list's `audienceClass`
176
+ * is that class, an absent class meaning `retail`.
177
+ */
178
+ exports.STOREFRONT_DESIGN_AUDIENCES = ['guest', 'customer', 'retail', 'wholesale'];
171
179
  function createStorefrontDesignV1() {
172
180
  return {
173
181
  schemaVersion: 1,
@@ -232,6 +240,29 @@ function previewWithinBytes(value, maximum) {
232
240
  return false;
233
241
  }
234
242
  }
243
+ /**
244
+ * A `visibility` rule kept on the transport only when well-formed: known audiences, and integer
245
+ * price lists within the store cap. Anything else is left off rather than failing the frame — the
246
+ * preview never filters by it, it only shows the rule the editor authored.
247
+ */
248
+ function previewVisibility(input) {
249
+ if (!previewRecord(input) || !Array.isArray(input.audiences))
250
+ return {};
251
+ const { audiences, priceLists } = input;
252
+ if (!audiences.every((entry) => exports.STOREFRONT_DESIGN_AUDIENCES.includes(entry)))
253
+ return {};
254
+ if (priceLists !== undefined &&
255
+ (!Array.isArray(priceLists) ||
256
+ priceLists.length > exports.STOREFRONT_DESIGN_LIMITS.visibilityPriceLists ||
257
+ !priceLists.every((entry) => Number.isInteger(entry))))
258
+ return {};
259
+ return {
260
+ visibility: {
261
+ audiences: [...audiences],
262
+ ...(priceLists === undefined ? {} : { priceLists: [...priceLists] }),
263
+ },
264
+ };
265
+ }
235
266
  function previewSections(input) {
236
267
  if (!Array.isArray(input) || input.length > exports.STOREFRONT_DESIGN_LIMITS.sectionsPerPage)
237
268
  return undefined;
@@ -248,6 +279,7 @@ function previewSections(input) {
248
279
  type: entry.type,
249
280
  enabled: entry.enabled,
250
281
  content: entry.content,
282
+ ...previewVisibility(entry.visibility),
251
283
  });
252
284
  }
253
285
  return sections;
@@ -270,6 +302,7 @@ function previewPage(input) {
270
302
  enabled: input.enabled,
271
303
  sections,
272
304
  ...(input.seo === undefined ? {} : { seo: input.seo }),
305
+ ...previewVisibility(input.visibility),
273
306
  };
274
307
  }
275
308
  /** Checks transport structure and UTF-8 size; unfamiliar section types are skipped, never rendered. */
@@ -31,6 +31,8 @@ export declare const STOREFRONT_DESIGN_LIMITS: {
31
31
  readonly benefits: 8;
32
32
  readonly historyEntries: 20;
33
33
  readonly selectedSourceIds: 50;
34
+ /** A `visibility` rule's `priceLists`: the store's own cap on price lists. */
35
+ readonly visibilityPriceLists: 64;
34
36
  readonly documentBytes: number;
35
37
  readonly heading: 120;
36
38
  readonly label: 80;
@@ -91,6 +93,12 @@ export declare const STOREFRONT_PROTECTED_BUILTIN_DESTINATIONS: readonly ["searc
91
93
  export declare const STOREFRONT_CONTACT_FIELDS: readonly ["email", "phone", "whatsapp", "address", "hours", "socials"];
92
94
  export declare const STOREFRONT_RESERVED_SLUGS: readonly ["home", "index", "api", "auth", "login", "logout", "account", "cart", "checkout", "orders", "search", "products", "product", "producto", "coleccion", "categories", "brands", "sale", "new", "privacy", "terms", "sitemap", "robots", "manifest", "assets", "preview", "admin", "storefront", "pagina", "basket", "profile", "favorites", "invoices", "payments", "payment-methods", "user", "mantenimiento"];
93
95
  export declare const STOREFRONT_BENEFIT_ICONS: readonly ["truck", "shield", "credit-card", "store", "heart", "check"];
96
+ /**
97
+ * Who a `visibility` rule may name. `guest`: no approved customer resolved. `customer`: any
98
+ * approved customer. `retail` / `wholesale`: an approved customer whose list's `audienceClass`
99
+ * is that class, an absent class meaning `retail`.
100
+ */
101
+ export declare const STOREFRONT_DESIGN_AUDIENCES: readonly ["guest", "customer", "retail", "wholesale"];
94
102
  export declare function createStorefrontDesignV1(): StorefrontDesignV1;
95
103
  declare global {
96
104
  type StorefrontDesignSectionType = (typeof STOREFRONT_SECTION_TYPES)[number];
@@ -202,12 +210,27 @@ declare global {
202
210
  showDelivery?: boolean;
203
211
  };
204
212
  }
213
+ type StorefrontDesignAudience = (typeof STOREFRONT_DESIGN_AUDIENCES)[number];
214
+ /**
215
+ * Who sees a section, page, navigation entry (top level or child) or footer link. Absent means
216
+ * everyone. A caller sees the item when any listed audience matches it, or when its price list
217
+ * is in `priceLists`. A list deleted after publish matches no one. Carries no `kind` or `id` key,
218
+ * so the reference and identity walkers pass over it.
219
+ *
220
+ * Web `GET /store` filters by it and strips it, marking each item visible through a rule
221
+ * `audienceScoped: true`. The private preview is not filtered and carries it as authored.
222
+ */
223
+ interface StorefrontDesignVisibility {
224
+ audiences: StorefrontDesignAudience[];
225
+ priceLists?: number[];
226
+ }
205
227
  type StorefrontDesignSection = {
206
228
  [K in StorefrontDesignSectionType]: {
207
229
  id: string;
208
230
  type: K;
209
231
  enabled: boolean;
210
232
  content: StorefrontDesignSectionContent[K];
233
+ visibility?: StorefrontDesignVisibility;
211
234
  };
212
235
  }[StorefrontDesignSectionType];
213
236
  interface StorefrontDesignPublicationMetadata {
@@ -227,6 +250,7 @@ declare global {
227
250
  enabled: boolean;
228
251
  seo?: StorefrontDesignSeo;
229
252
  sections: StorefrontDesignSection[];
253
+ visibility?: StorefrontDesignVisibility;
230
254
  }
231
255
  interface StorefrontDesignHome {
232
256
  id: 'home';
@@ -238,6 +262,7 @@ declare global {
238
262
  id: string;
239
263
  label?: string;
240
264
  target?: StorefrontDesignLinkTarget;
265
+ visibility?: StorefrontDesignVisibility;
241
266
  }
242
267
  interface StorefrontDesignNavigationEntry extends StorefrontDesignMenuLink {
243
268
  children?: StorefrontDesignMenuLink[];
@@ -305,6 +330,10 @@ declare global {
305
330
  * alone is not servable. Never route it through `/fit-in/`: the media path is refused there.
306
331
  * Private preview envelopes instead supply `/preview/read?operation=asset&assetId=...`; the
307
332
  * preview transport adds a variant query and its in-memory grant, then renders returned bytes.
333
+ *
334
+ * An item that can carry `visibility` (section, page, navigation entry, footer link) may also
335
+ * carry `audienceScoped: true`: web `GET /store` sets it on an item it returned because the
336
+ * caller matched that item's rule, and strips every `visibility`. The preview never sets it.
308
337
  */
309
338
  type PublicStorefrontDesignValue<T> = T extends StorefrontDesignImagePlacement ? T & {
310
339
  url: string;
@@ -314,7 +343,11 @@ declare global {
314
343
  id: string;
315
344
  } ? T & {
316
345
  slug: string;
317
- } : T extends readonly (infer V)[] ? PublicStorefrontDesignValue<V>[] : T extends object ? {
346
+ } : T extends readonly (infer V)[] ? PublicStorefrontDesignValue<V>[] : T extends object ? 'visibility' extends keyof T ? {
347
+ [K in keyof T]: PublicStorefrontDesignValue<T[K]>;
348
+ } & {
349
+ audienceScoped?: true;
350
+ } : {
318
351
  [K in keyof T]: PublicStorefrontDesignValue<T[K]>;
319
352
  } : T;
320
353
  type PublicStorefrontDesign = PublicStorefrontDesignValue<Omit<StorefrontDesignPublic, 'literalOverrides'>>;
@@ -351,7 +384,9 @@ declare global {
351
384
  * At `<page>.sections.<index>.type`, `DUPLICATE` is a second section of a once-per-page type and
352
385
  * `SECTION_TYPE_LIMIT` is a section past `repeatableSectionsPerType` of a repeatable type.
353
386
  */
354
- type StorefrontDesignFieldErrorCode = 'INVALID' | 'REQUIRED' | 'UNKNOWN_KEY' | 'DUPLICATE' | 'SECTION_TYPE_LIMIT' | 'RESERVED_SLUG' | 'ALIAS_CONFLICT' | 'ALIAS_LIMIT' | 'DANGLING_REFERENCE' | 'MAPPING_CONFLICT' | 'TOO_LARGE';
387
+ type StorefrontDesignFieldErrorCode = 'INVALID' | 'REQUIRED' | 'UNKNOWN_KEY' | 'DUPLICATE' | 'SECTION_TYPE_LIMIT' | 'RESERVED_SLUG' | 'ALIAS_CONFLICT' | 'ALIAS_LIMIT' | 'DANGLING_REFERENCE' | 'MAPPING_CONFLICT' | 'TOO_LARGE'
388
+ /** A `visibility.priceLists` entry naming no list of the store's `priceLists`; refused on draft save. */
389
+ | 'UNKNOWN_PRICE_LIST';
355
390
  interface StorefrontDesignFieldError {
356
391
  path: string;
357
392
  code: StorefrontDesignFieldErrorCode;
@@ -667,6 +702,8 @@ declare global {
667
702
  type: StorefrontDesignSectionType;
668
703
  enabled: boolean;
669
704
  content: Record<string, unknown>;
705
+ /** Carried as authored when well-formed, as navigation and footer entries carry theirs; never applied. */
706
+ visibility?: StorefrontDesignVisibility;
670
707
  }
671
708
  interface StorefrontPreviewDocument {
672
709
  schemaVersion: 1;
@@ -686,6 +723,7 @@ declare global {
686
723
  enabled: boolean;
687
724
  sections: StorefrontPreviewSection[];
688
725
  seo?: object;
726
+ visibility?: StorefrontDesignVisibility;
689
727
  }[];
690
728
  navigation: object[];
691
729
  footer: object[];
@@ -30,6 +30,8 @@ export const STOREFRONT_DESIGN_LIMITS = {
30
30
  benefits: 8,
31
31
  historyEntries: 20,
32
32
  selectedSourceIds: 50,
33
+ /** A `visibility` rule's `priceLists`: the store's own cap on price lists. */
34
+ visibilityPriceLists: 64,
33
35
  documentBytes: 256 * 1024,
34
36
  heading: 120,
35
37
  label: 80,
@@ -160,6 +162,12 @@ export const STOREFRONT_RESERVED_SLUGS = [
160
162
  'mantenimiento',
161
163
  ];
162
164
  export const STOREFRONT_BENEFIT_ICONS = ['truck', 'shield', 'credit-card', 'store', 'heart', 'check'];
165
+ /**
166
+ * Who a `visibility` rule may name. `guest`: no approved customer resolved. `customer`: any
167
+ * approved customer. `retail` / `wholesale`: an approved customer whose list's `audienceClass`
168
+ * is that class, an absent class meaning `retail`.
169
+ */
170
+ export const STOREFRONT_DESIGN_AUDIENCES = ['guest', 'customer', 'retail', 'wholesale'];
163
171
  export function createStorefrontDesignV1() {
164
172
  return {
165
173
  schemaVersion: 1,
@@ -224,6 +232,29 @@ function previewWithinBytes(value, maximum) {
224
232
  return false;
225
233
  }
226
234
  }
235
+ /**
236
+ * A `visibility` rule kept on the transport only when well-formed: known audiences, and integer
237
+ * price lists within the store cap. Anything else is left off rather than failing the frame — the
238
+ * preview never filters by it, it only shows the rule the editor authored.
239
+ */
240
+ function previewVisibility(input) {
241
+ if (!previewRecord(input) || !Array.isArray(input.audiences))
242
+ return {};
243
+ const { audiences, priceLists } = input;
244
+ if (!audiences.every((entry) => STOREFRONT_DESIGN_AUDIENCES.includes(entry)))
245
+ return {};
246
+ if (priceLists !== undefined &&
247
+ (!Array.isArray(priceLists) ||
248
+ priceLists.length > STOREFRONT_DESIGN_LIMITS.visibilityPriceLists ||
249
+ !priceLists.every((entry) => Number.isInteger(entry))))
250
+ return {};
251
+ return {
252
+ visibility: {
253
+ audiences: [...audiences],
254
+ ...(priceLists === undefined ? {} : { priceLists: [...priceLists] }),
255
+ },
256
+ };
257
+ }
227
258
  function previewSections(input) {
228
259
  if (!Array.isArray(input) || input.length > STOREFRONT_DESIGN_LIMITS.sectionsPerPage)
229
260
  return undefined;
@@ -240,6 +271,7 @@ function previewSections(input) {
240
271
  type: entry.type,
241
272
  enabled: entry.enabled,
242
273
  content: entry.content,
274
+ ...previewVisibility(entry.visibility),
243
275
  });
244
276
  }
245
277
  return sections;
@@ -262,6 +294,7 @@ function previewPage(input) {
262
294
  enabled: input.enabled,
263
295
  sections,
264
296
  ...(input.seo === undefined ? {} : { seo: input.seo }),
297
+ ...previewVisibility(input.visibility),
265
298
  };
266
299
  }
267
300
  /** Checks transport structure and UTF-8 size; unfamiliar section types are skipped, never rendered. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "platform-types",
3
- "version": "1.10.753",
3
+ "version": "1.10.754",
4
4
  "description": "Shared wire and entity contracts for the platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",