platform-types 1.10.697 → 1.10.699

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.
@@ -2,6 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveStorefrontTheme = exports.resolveStorefrontEffectiveSettings = exports.storefrontGlobalSettingsLayer = exports.storefrontContrastRatio = void 0;
4
4
  const storefrontDesignRegistry_ts_1 = require("./storefrontDesignRegistry.js");
5
+ /*
6
+ * The one binding of a warning role and of a surface to the setting it reads: `surfaceTokens`
7
+ * and `makeMode` read the colours THROUGH these maps, and the `warnings` filter judges by them,
8
+ * so the tokens and the "design caused it" filter cannot name different settings.
9
+ */
5
10
  const WARNING_SETTING = {
6
11
  link: 'primaryColor',
7
12
  button: 'primaryColor',
@@ -54,22 +59,23 @@ const ensureContrast = (color, background, minimum) => {
54
59
  return target;
55
60
  };
56
61
  const surfaceTokens = (background, settings, mode, surface, warnings) => {
57
- const adjusted = (role, requested, minimum) => {
62
+ const adjusted = (role, minimum) => {
63
+ const requested = settings[WARNING_SETTING[role]];
58
64
  const effective = ensureContrast(requested, background, minimum);
59
65
  if (effective !== requested.toUpperCase())
60
66
  warnings.push({ mode, surface, role, requested, effective });
61
67
  return effective;
62
68
  };
63
69
  const text = readableText(background);
64
- const button = adjusted('button', settings.primaryColor, 3);
70
+ const button = adjusted('button', 3);
65
71
  const hover = ensureContrast(mix(button, readableText(background), 0.2), background, 3);
66
72
  const disabledBackground = mix(background, text, 0.12);
67
73
  return {
68
74
  background,
69
75
  text,
70
76
  secondaryText: ensureContrast(mix(background, text, 0.6), background, 4.5),
71
- link: adjusted('link', settings.primaryColor, 4.5),
72
- focus: adjusted('focus', settings.accentColor, 3),
77
+ link: adjusted('link', 4.5),
78
+ focus: adjusted('focus', 3),
73
79
  border: ensureContrast(mix(background, text, 0.3), background, 3),
74
80
  button: { background: button, text: readableText(button), hover, hoverText: readableText(hover) },
75
81
  disabled: { background: disabledBackground, text: readableText(disabledBackground) },
@@ -117,11 +123,8 @@ const resolveStorefrontTheme = (overrides = {}, globalsRow) => {
117
123
  const warnings = [];
118
124
  const makeMode = (mode) => {
119
125
  const background = (requested) => mode === 'light' ? requested.toUpperCase() : mix(requested, '#000000', 0.9);
120
- return {
121
- page: surfaceTokens(background(settings.backgroundColor), settings, mode, 'page', warnings),
122
- header: surfaceTokens(background(settings.headerColor), settings, mode, 'header', warnings),
123
- footer: surfaceTokens(background(settings.footerColor), settings, mode, 'footer', warnings),
124
- };
126
+ const surface = (id) => surfaceTokens(background(settings[SURFACE_SETTING[id]]), settings, mode, id, warnings);
127
+ return { page: surface('page'), header: surface('header'), footer: surface('footer') };
125
128
  };
126
129
  const scale = { compact: 0.875, standard: 1, large: 1.125 }[settings.textSize];
127
130
  return {
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAllowedStorefrontLiteralValue = exports.isStorefrontLiteralKey = exports.STOREFRONT_WEB_LITERAL_KEYS = void 0;
3
+ exports.isAdoptableStorefrontLiteral = exports.isAllowedStorefrontLiteralValue = exports.isStorefrontLiteralKey = exports.STOREFRONT_WEB_LITERAL_KEYS = void 0;
4
+ const storefrontDesignRegistry_ts_1 = require("./storefrontDesignRegistry.js");
4
5
  /**
5
6
  * Every storefront `WEB` literal key a shop may override, in code-unit order.
6
7
  *
@@ -1178,3 +1179,14 @@ const STOREFRONT_SAME_ORIGIN_PATH_RE = /^\/(?![/\\])[^\s\\\p{Cc}\p{Cf}]*$/u;
1178
1179
  */
1179
1180
  const isAllowedStorefrontLiteralValue = (key, value) => !key.startsWith(STOREFRONT_NAVIGATE_LITERAL_PREFIX) || STOREFRONT_SAME_ORIGIN_PATH_RE.test(value);
1180
1181
  exports.isAllowedStorefrontLiteralValue = isAllowedStorefrontLiteralValue;
1182
+ /**
1183
+ * Whether a shop's stored `value` for `key` is one a save keeps, a read serves and the editor
1184
+ * baseline adopts: a shop-overridable key, a well-formed string within
1185
+ * {@link STOREFRONT_DESIGN_LITERAL_MAX_CODE_POINTS} code points, and an allowed value for it.
1186
+ */
1187
+ const isAdoptableStorefrontLiteral = (key, value) => (0, exports.isStorefrontLiteralKey)(key) &&
1188
+ typeof value === 'string' &&
1189
+ value.isWellFormed() &&
1190
+ Array.from(value).length <= storefrontDesignRegistry_ts_1.STOREFRONT_DESIGN_LITERAL_MAX_CODE_POINTS &&
1191
+ (0, exports.isAllowedStorefrontLiteralValue)(key, value);
1192
+ exports.isAdoptableStorefrontLiteral = isAdoptableStorefrontLiteral;
@@ -358,7 +358,11 @@ declare global {
358
358
  /** Always `[]`: an invalid colour, an unmapped Home switch, the banner and every refused or oversized literal fall back to defaults. */
359
359
  mappingConflicts: StorefrontDesignMappingConflict[];
360
360
  legacySourceRevision: string;
361
- /** The store's own logo, offered as a suggestion; init copies it into `branding.logo`, and a copy that cannot complete leaves no logo and no conflict. */
361
+ /**
362
+ * The store's own logo, offered as a suggestion; init copies it into `branding.logo`. A logo
363
+ * that is not adoptable or would exceed the asset capacity leaves no logo and no conflict;
364
+ * any other copy failure answers 503 `STOREFRONT_DRAFT_UNAVAILABLE`.
365
+ */
362
366
  legacyLogo?: {
363
367
  source: 'store.photoURL';
364
368
  key: string;
@@ -476,7 +480,11 @@ declare global {
476
480
  type StorefrontDesignPublishOperationResult = StorefrontDesignPublishResult;
477
481
  type StorefrontDesignPublishOperationResponse = StorefrontDesignPublishResponse;
478
482
  interface StorefrontDesignPublishResult {
479
- /** Only adjustments to a colour the design itself sets; a default colour is never listed. */
483
+ /**
484
+ * Only adjustments the design itself caused: the adjusted colour, or the background of the
485
+ * surface it sits on, is set by the design. So a default primary or accent colour IS listed
486
+ * when the design sets that surface's background.
487
+ */
480
488
  changeSummary: {
481
489
  contrastAdjustments: StorefrontThemeWarning[];
482
490
  };
@@ -546,10 +554,12 @@ declare global {
546
554
  /**
547
555
  * Web `GET /products?updatedAt=`'s recency listing (the shop's «Ingresos» page), with the
548
556
  * same rows and cursor shape, in the grant's store: enabled products updated after
549
- * `updatedAt` (epoch ms, digits), newest first; `LastEvaluatedKey` resumes as `startKey`.
550
- * Non-digits or a `startKey` over 2048 characters answer 400 `STOREFRONT_PREVIEW_INVALID`;
551
- * an `updatedAt` past `Number.MAX_SAFE_INTEGER` answers 400 `INVALID_UPDATED_AT`; a
552
- * malformed or foreign `startKey` answers 400 `INVALID_CURSOR`.
557
+ * `updatedAt` (epoch ms), newest first; `LastEvaluatedKey` resumes as `startKey`. The web
558
+ * route's one rule: an absent or empty `updatedAt` reads from 0; anything but digits within
559
+ * `Number.MAX_SAFE_INTEGER` (`1e5`, `-5`, `0x10`, a blank) answers 400 `INVALID_UPDATED_AT`,
560
+ * on both routes alike. An `updatedAt` over 32 characters or a `startKey` over 2048 answers
561
+ * 400 `STOREFRONT_PREVIEW_INVALID`; a malformed or foreign `startKey`, one whose `updatedAt`
562
+ * DynamoDB cannot store, or one at or below the `updatedAt` floor answers 400 `INVALID_CURSOR`.
553
563
  */
554
564
  | {
555
565
  operation: 'incomes';
@@ -600,10 +610,12 @@ declare global {
600
610
  /**
601
611
  * The codes a catalogue operation answers through its public web route's own core, as that
602
612
  * route does: 404 `PRODUCT_NOT_FOUND` / `PRODUCT_GROUP_NOT_FOUND` / `COLLECTION_NOT_FOUND`,
603
- * 400 `INVALID_CURSOR` / `INVALID_DISCOVERY_QUERY`, 409 `CURSOR_STALE` (a collection that
604
- * changed between the reads bracketing a page) and 503 `PRODUCT_LOOKUP_INCOMPLETE`.
613
+ * 400 `INVALID_CURSOR` / `INVALID_DISCOVERY_QUERY` / `INVALID_UPDATED_AT` (an `incomes`
614
+ * `updatedAt` that is not digits within the safe-integer range), 409 `CURSOR_STALE` (a
615
+ * collection that changed between the reads bracketing a page) and 503
616
+ * `PRODUCT_LOOKUP_INCOMPLETE`.
605
617
  */
606
- type StorefrontPreviewCatalogueErrorCode = 'PRODUCT_NOT_FOUND' | 'PRODUCT_GROUP_NOT_FOUND' | 'COLLECTION_NOT_FOUND' | 'INVALID_CURSOR' | 'INVALID_DISCOVERY_QUERY' | 'CURSOR_STALE' | 'PRODUCT_LOOKUP_INCOMPLETE';
618
+ type StorefrontPreviewCatalogueErrorCode = 'PRODUCT_NOT_FOUND' | 'PRODUCT_GROUP_NOT_FOUND' | 'COLLECTION_NOT_FOUND' | 'INVALID_CURSOR' | 'INVALID_DISCOVERY_QUERY' | 'INVALID_UPDATED_AT' | 'CURSOR_STALE' | 'PRODUCT_LOOKUP_INCOMPLETE';
607
619
  interface StorefrontPreviewReadFailure {
608
620
  message: string;
609
621
  error: StorefrontPreviewReadErrorCode | StorefrontPreviewCatalogueErrorCode;
@@ -1,4 +1,9 @@
1
1
  import { resolveStorefrontDesignSettings, validateStorefrontDesignSetting, } from "./storefrontDesignRegistry.js";
2
+ /*
3
+ * The one binding of a warning role and of a surface to the setting it reads: `surfaceTokens`
4
+ * and `makeMode` read the colours THROUGH these maps, and the `warnings` filter judges by them,
5
+ * so the tokens and the "design caused it" filter cannot name different settings.
6
+ */
2
7
  const WARNING_SETTING = {
3
8
  link: 'primaryColor',
4
9
  button: 'primaryColor',
@@ -50,22 +55,23 @@ const ensureContrast = (color, background, minimum) => {
50
55
  return target;
51
56
  };
52
57
  const surfaceTokens = (background, settings, mode, surface, warnings) => {
53
- const adjusted = (role, requested, minimum) => {
58
+ const adjusted = (role, minimum) => {
59
+ const requested = settings[WARNING_SETTING[role]];
54
60
  const effective = ensureContrast(requested, background, minimum);
55
61
  if (effective !== requested.toUpperCase())
56
62
  warnings.push({ mode, surface, role, requested, effective });
57
63
  return effective;
58
64
  };
59
65
  const text = readableText(background);
60
- const button = adjusted('button', settings.primaryColor, 3);
66
+ const button = adjusted('button', 3);
61
67
  const hover = ensureContrast(mix(button, readableText(background), 0.2), background, 3);
62
68
  const disabledBackground = mix(background, text, 0.12);
63
69
  return {
64
70
  background,
65
71
  text,
66
72
  secondaryText: ensureContrast(mix(background, text, 0.6), background, 4.5),
67
- link: adjusted('link', settings.primaryColor, 4.5),
68
- focus: adjusted('focus', settings.accentColor, 3),
73
+ link: adjusted('link', 4.5),
74
+ focus: adjusted('focus', 3),
69
75
  border: ensureContrast(mix(background, text, 0.3), background, 3),
70
76
  button: { background: button, text: readableText(button), hover, hoverText: readableText(hover) },
71
77
  disabled: { background: disabledBackground, text: readableText(disabledBackground) },
@@ -111,11 +117,8 @@ export const resolveStorefrontTheme = (overrides = {}, globalsRow) => {
111
117
  const warnings = [];
112
118
  const makeMode = (mode) => {
113
119
  const background = (requested) => mode === 'light' ? requested.toUpperCase() : mix(requested, '#000000', 0.9);
114
- return {
115
- page: surfaceTokens(background(settings.backgroundColor), settings, mode, 'page', warnings),
116
- header: surfaceTokens(background(settings.headerColor), settings, mode, 'header', warnings),
117
- footer: surfaceTokens(background(settings.footerColor), settings, mode, 'footer', warnings),
118
- };
120
+ const surface = (id) => surfaceTokens(background(settings[SURFACE_SETTING[id]]), settings, mode, id, warnings);
121
+ return { page: surface('page'), header: surface('header'), footer: surface('footer') };
119
122
  };
120
123
  const scale = { compact: 0.875, standard: 1, large: 1.125 }[settings.textSize];
121
124
  return {
@@ -28,3 +28,9 @@ export declare const isStorefrontLiteralKey: (key: string) => boolean;
28
28
  * unconstrained here (key membership, well-formedness and length are checked apart).
29
29
  */
30
30
  export declare const isAllowedStorefrontLiteralValue: (key: string, value: string) => boolean;
31
+ /**
32
+ * Whether a shop's stored `value` for `key` is one a save keeps, a read serves and the editor
33
+ * baseline adopts: a shop-overridable key, a well-formed string within
34
+ * {@link STOREFRONT_DESIGN_LITERAL_MAX_CODE_POINTS} code points, and an allowed value for it.
35
+ */
36
+ export declare const isAdoptableStorefrontLiteral: (key: string, value: unknown) => value is string;
@@ -1,3 +1,4 @@
1
+ import { STOREFRONT_DESIGN_LITERAL_MAX_CODE_POINTS } from "./storefrontDesignRegistry.js";
1
2
  /**
2
3
  * Every storefront `WEB` literal key a shop may override, in code-unit order.
3
4
  *
@@ -1173,3 +1174,13 @@ const STOREFRONT_SAME_ORIGIN_PATH_RE = /^\/(?![/\\])[^\s\\\p{Cc}\p{Cf}]*$/u;
1173
1174
  * unconstrained here (key membership, well-formedness and length are checked apart).
1174
1175
  */
1175
1176
  export const isAllowedStorefrontLiteralValue = (key, value) => !key.startsWith(STOREFRONT_NAVIGATE_LITERAL_PREFIX) || STOREFRONT_SAME_ORIGIN_PATH_RE.test(value);
1177
+ /**
1178
+ * Whether a shop's stored `value` for `key` is one a save keeps, a read serves and the editor
1179
+ * baseline adopts: a shop-overridable key, a well-formed string within
1180
+ * {@link STOREFRONT_DESIGN_LITERAL_MAX_CODE_POINTS} code points, and an allowed value for it.
1181
+ */
1182
+ export const isAdoptableStorefrontLiteral = (key, value) => isStorefrontLiteralKey(key) &&
1183
+ typeof value === 'string' &&
1184
+ value.isWellFormed() &&
1185
+ Array.from(value).length <= STOREFRONT_DESIGN_LITERAL_MAX_CODE_POINTS &&
1186
+ isAllowedStorefrontLiteralValue(key, value);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "platform-types",
3
- "version": "1.10.697",
3
+ "version": "1.10.699",
4
4
  "description": "Shared wire and entity contracts for the platform.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",