@snowcone-app/mockup-resolver 1.0.10 → 1.0.12

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @snowcone-app/mockup-resolver
2
2
 
3
+ ## 1.0.12
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`126e84a`](https://github.com/snowcone-app/snowcone-monorepo/commit/126e84a5ab7e7e5d5cd60e37311bd8c3daca07d8)]:
8
+ - @snowcone-app/mockup-url@0.6.1
9
+
10
+ ## 1.0.11
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies [[`0088c4a`](https://github.com/snowcone-app/snowcone-monorepo/commit/0088c4a11e30ca0322a15d38c7be577ed0b0616b)]:
15
+ - @snowcone-app/mockup-url@0.6.0
16
+
3
17
  ## 1.0.10
4
18
 
5
19
  ### Patch Changes
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@snowcone-app/mockup-resolver",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "URL signing and verification Cloudflare Worker",
5
5
  "main": "dist/index.js",
6
6
  "author": "",
7
7
  "license": "ISC",
8
8
  "dependencies": {
9
- "@snowcone-app/mockup-url": "0.5.0"
9
+ "@snowcone-app/mockup-url": "0.6.1"
10
10
  },
11
11
  "devDependencies": {
12
12
  "@cloudflare/workers-types": "^4.20250303.0",
@@ -16,8 +16,8 @@
16
16
  "node-fetch": "^3.3.2",
17
17
  "tsx": "^4.19.3",
18
18
  "typescript": "^5.6.2",
19
- "vite": "^5.0.0",
20
- "vitest": "^2.0.0",
19
+ "vite": "^5.4.21",
20
+ "vitest": "^2.1.9",
21
21
  "wrangler": "^3.37.0"
22
22
  },
23
23
  "scripts": {
package/src/index.ts CHANGED
@@ -48,7 +48,7 @@ interface RateLimiterStub extends DurableObjectStub {
48
48
  // Interface for environment bindings
49
49
  interface Env {
50
50
  URL_SIGNING_SECRET: string;
51
- /** Comma-separated client IPs exempt from the per-IP public caps (our 9 metro relays running the load generator). Exact match only; change via PR. */
51
+ /** Comma-separated client IPs exempt from the per-IP public caps (relay-lax-1 running the load generator). Exact match only; change via PR. */
52
52
  LOADTEST_EXEMPT_IPS?: string;
53
53
  /**
54
54
  * rc#262 — Ed25519 seal signing key (PKCS#8 DER, base64). When SET, every
@@ -1006,6 +1006,8 @@ import {
1006
1006
  renderUrlLengthError,
1007
1007
  E_RENDER_URL_TOO_LONG,
1008
1008
  MAX_DESIGN_ELEMENTS,
1009
+ expandIngestHandle,
1010
+ isIngestHandle,
1009
1011
  PARAMS,
1010
1012
  type DesignElement,
1011
1013
  } from "@snowcone-app/mockup-url";
@@ -1013,6 +1015,7 @@ import {
1013
1015
  assembleArtwork,
1014
1016
  fetchProduct,
1015
1017
  looksLikeResolveRequest,
1018
+ expandIngestHandles,
1016
1019
  resolveAlbumPagePlacement,
1017
1020
  resolveBundleScene,
1018
1021
  resolveDefaults,
@@ -1357,8 +1360,18 @@ async function handlePublicResolve(
1357
1360
  // design map (`asset.<key>`/`color.<key>`/`tile.<key>`/`align.<key>`) + variant
1358
1361
  // option picks (`opt.<attr>`).
1359
1362
  const parsed = parsePublicUrl(reqUrl);
1360
- const asset = q.get(PARAMS.asset);
1361
- const design = parsed.design ?? {};
1363
+ // First-party asset handles (ADR-0099 D3): `ingest:<sha256>` expands to the
1364
+ // ingested artwork's first-party URL before anything else reads the asset
1365
+ // values; the expanded URLs skip the origin allowlist (platform provenance).
1366
+ const handles = expandIngestHandles(
1367
+ q.get(PARAMS.asset),
1368
+ parsed.design ?? {},
1369
+ expandIngestHandle,
1370
+ isIngestHandle
1371
+ );
1372
+ if (!handles.ok) return errResp(handles.status, handles.message, handles.code);
1373
+ const asset = handles.asset;
1374
+ const design = handles.design;
1362
1375
  const optionPicks = parsed.options ?? {};
1363
1376
  const designKeys = Object.keys(design);
1364
1377
  // Catalog design reference (ADR-0086): `design=<pairingId|slug>` renders a
@@ -1459,10 +1472,10 @@ async function handlePublicResolve(
1459
1472
  // per-placement srcs). Reserved `default` tokens are EXCLUDED — they are
1460
1473
  // platform-injected (resolved to `house`), so they bypass L2 by provenance.
1461
1474
  const imageUrls: string[] = [];
1462
- if (asset && !isDefaultToken(asset)) imageUrls.push(asset);
1475
+ if (asset && !isDefaultToken(asset) && !handles.expanded.has(asset)) imageUrls.push(asset);
1463
1476
  for (const k of designKeys) {
1464
1477
  const src = design[k].src;
1465
- if (src && !isDefaultToken(src)) imageUrls.push(src);
1478
+ if (src && !isDefaultToken(src) && !handles.expanded.has(src)) imageUrls.push(src);
1466
1479
  }
1467
1480
 
1468
1481
  // 2b. L2 — asset-source allowlist (checked for EVERY image URL's hostname).
@@ -1735,6 +1748,7 @@ async function handlePublicResolve(
1735
1748
  // 2026-09-06). Named, with the valid values, like unknown placement keys.
1736
1749
  let vr: VariantResolution;
1737
1750
  let scene: ResolveDefaults;
1751
+ let previewVariantHeader: string | undefined;
1738
1752
  if (bundleScene) {
1739
1753
  vr = { variantId: bundleScene.variantToken, optionSelections: bundleScene.optionSelections };
1740
1754
  scene = {
@@ -1765,16 +1779,18 @@ async function handlePublicResolve(
1765
1779
  if (!resolvedVariant) {
1766
1780
  return errResp(422, `Product ${productCode} has no renderable combination`);
1767
1781
  }
1768
- vr = resolvedVariant;
1769
1782
  const resolvedScene = resolveDefaults(product, {
1770
- variant: vr.variantId,
1783
+ variant: resolvedVariant.variantId,
1771
1784
  mockupId: mockupOverride,
1772
1785
  placement: placementOverride,
1786
+ variantIsDefault: !variantOverride && Object.keys(optionPicks).length === 0,
1773
1787
  });
1774
1788
  if (!resolvedScene) {
1775
1789
  return errResp(422, `Product ${productCode} has no renderable combination`);
1776
1790
  }
1791
+ vr = { ...resolvedVariant, variantId: resolvedScene.variantId };
1777
1792
  scene = resolvedScene;
1793
+ if (resolvedScene.previewFor) previewVariantHeader = `${resolvedScene.variantId}; for=${resolvedScene.previewFor}`;
1778
1794
  // page=N selects which album page feeds the scene: the resolved default
1779
1795
  // placement becomes the repeating page placement's geometry.
1780
1796
  if (pagePlacement) scene.placement = pagePlacement;
@@ -1821,14 +1837,15 @@ async function handlePublicResolve(
1821
1837
  });
1822
1838
  }
1823
1839
  } else if (catalogDesign.asset) {
1824
- designElements.push({
1825
- type: "image",
1826
- imageUrl: catalogDesign.asset,
1827
- placement: scene.placement.label,
1828
- width: scene.placement.width,
1829
- height: scene.placement.height,
1830
- alignment: "center",
1831
- });
1840
+ // One flattened design and no per-placement map: the design names no placement, so it is the SPREAD — seeded
1841
+ // on every placement exactly as a bare `asset=` is (assembleArtwork). Labelling it with the scene's default
1842
+ // placement alone made it look chosen, and a chosen label prints there only (the placement rule, 2026-11-10):
1843
+ // a hardcover would show its back cover alone.
1844
+ const assembled = assembleArtwork(renderProduct, { asset: catalogDesign.asset, design: {}, house, findPlacement });
1845
+ if (!assembled.ok) {
1846
+ return errResp(assembled.status, assembled.message, assembled.code);
1847
+ }
1848
+ designElements.push(...assembled.elements);
1832
1849
  }
1833
1850
  } else {
1834
1851
  // ADR-0089 base+override: the scalar `asset=` SEEDS every placement (each
@@ -1977,6 +1994,8 @@ async function handlePublicResolve(
1977
1994
  const edgeTotalMs = Number((/(?:^|[ ,])edge_total;dur=([0-9.]+)/.exec(edgeRes.headers.get("Server-Timing") || "") || [])[1] ?? NaN);
1978
1995
  const hopMs = Number.isFinite(edgeTotalMs) ? Math.max(0, Math.round(edgeWallMs - edgeTotalMs)) : edgeWallMs;
1979
1996
  const headers = new Headers(edgeRes.headers);
1997
+ // a chosen size with no scene rendered its listed size sibling: said, machine-readable (never a silent swap)
1998
+ if (previewVariantHeader) headers.set("X-Preview-Variant", previewVariantHeader);
1980
1999
  // Revalidation (ADR-0096 amendment, 2026-09-04): the edge stamps the render
1981
2000
  // key as a strong ETag and answers If-None-Match with a 304 — the browser's
1982
2001
  // header rides through on `request.headers` above. A 304 is a SUCCESS here:
@@ -1998,7 +2017,7 @@ async function handlePublicResolve(
1998
2017
  // encoder choice off cross-origin responses.
1999
2018
  headers.set(
2000
2019
  "Access-Control-Expose-Headers",
2001
- "ETag, Server-Timing, X-Render-Box, X-Render-Pinned, X-Render-Overflow, X-Encoder"
2020
+ "ETag, Server-Timing, X-Render-Box, X-Render-Pinned, X-Render-Overflow, X-Encoder, X-Preview-Variant"
2002
2021
  );
2003
2022
  headers.append(
2004
2023
  "Server-Timing",
@@ -1,4 +1,4 @@
1
- /** Per-IP public rate-limit exemption for our own load generators (the metro relays).
1
+ /** Per-IP public rate-limit exemption for our own load generator (relay-lax-1).
2
2
  * Exact-IP match only: no CIDR, no wildcards. The list is a plain wrangler var. */
3
3
  export function isLoadtestExempt(clientIp: string, list: string | undefined): boolean {
4
4
  if (!list || !clientIp || clientIp === "unknown-ip") return false;
package/src/resolve.ts CHANGED
@@ -200,6 +200,36 @@ export interface ResolveDefaults {
200
200
  variantId: string;
201
201
  mockupId: string;
202
202
  placement: ResolvedPlacement;
203
+ /** Set when the render uses a different variant than the one asked for (a size the mockup lists no scene for
204
+ * previews its listed size sibling): the asked variant. The response says so in X-Preview-Variant. */
205
+ previewFor?: string;
206
+ }
207
+
208
+ const SIZE_ATTRIBUTE = /^size$/i;
209
+
210
+ /**
211
+ * The variant this mockup lists that differs from `variantId` ONLY by size (the SDK's resolvePreviewVariantId rule,
212
+ * #4074, applied where a public URL resolves). Scenes exist only for the variants a mockup lists and a size doesn't
213
+ * change the picture, so `opt.size=M` on a mockup built for S renders S, never a 503 E_SCENE_NOT_COMPILED. Anything
214
+ * else about the row must match, so a colour (a combination attribute) is never swapped. null: no such sibling.
215
+ */
216
+ export function listedSizeSibling(product: Pick<ResolvedProduct, "combinations">, mockup: { gvids: string[] }, variantId: string): string | null {
217
+ const rows = product.combinations ?? [];
218
+ const asked = rows.find((r) => r.variantId === variantId);
219
+ if (!asked) return null;
220
+ const sizeKey = Object.keys(asked.options).find((k) => SIZE_ATTRIBUTE.test(k));
221
+ if (!sizeKey) return null;
222
+ const others = (o: Record<string, string>) => Object.keys(o).filter((k) => k !== sizeKey).sort();
223
+ const sameExceptSize = (r: { options: Record<string, string> }) => {
224
+ const a = others(asked.options), b = others(r.options);
225
+ return a.length === b.length && a.every((k, i) => k === b[i] && r.options[k] === asked.options[k]);
226
+ };
227
+ // the mockup's own order: its first listed gvid is the one it was built for
228
+ for (const g of mockup.gvids) {
229
+ const r = rows.find((x) => x.variantId === g);
230
+ if (r && sameExceptSize(r)) return g;
231
+ }
232
+ return null;
203
233
  }
204
234
 
205
235
  export interface VariantResolution {
@@ -577,7 +607,13 @@ function toResolvedProduct(raw: RawProduct, version: string, renderVersion: stri
577
607
  */
578
608
  export function resolveDefaults(
579
609
  product: ResolvedProduct,
580
- overrides: { variant?: string; mockupId?: string; placement?: string }
610
+ overrides: {
611
+ variant?: string;
612
+ mockupId?: string;
613
+ placement?: string;
614
+ /** Nobody chose this variant (no `variant=`, no option picks): it may follow the mockup to one with a scene. */
615
+ variantIsDefault?: boolean;
616
+ }
581
617
  ): ResolveDefaults | null {
582
618
  const variantId =
583
619
  overrides.variant ?? product.defaultGvid ?? product.variants[0]?.gvid;
@@ -590,6 +626,14 @@ export function resolveDefaults(
590
626
  product.mockups.find((m) => m.gvids.includes(variantId)) ??
591
627
  product.mockups[0];
592
628
  if (!mockup) return null;
629
+ // Scenes exist only for the variants a mockup lists. A default that isn't listed is a broken image nobody asked for
630
+ // (XTNA6J's home card, 2026-11); a variant someone chose is theirs, and may be a colour, so it is never swapped.
631
+ // A chosen SIZE with no scene previews the listed size sibling (declared in X-Preview-Variant), never a 503.
632
+ const listed = mockup.gvids.length === 0 || mockup.gvids.includes(variantId);
633
+ const sibling = listed ? null : listedSizeSibling(product, mockup, variantId);
634
+ const renderVariantId = listed
635
+ ? variantId
636
+ : sibling ?? (overrides.variantIsDefault ? mockup.gvids[0] : variantId);
593
637
 
594
638
  const placement =
595
639
  (overrides.placement
@@ -597,7 +641,7 @@ export function resolveDefaults(
597
641
  : undefined) ?? product.placements[0];
598
642
  if (!placement) return null;
599
643
 
600
- return { variantId, mockupId: mockup.id, placement };
644
+ return { variantId: renderVariantId, mockupId: mockup.id, placement, ...(renderVariantId !== variantId ? { previewFor: variantId } : {}) };
601
645
  }
602
646
 
603
647
  export interface UnknownOptionPick {
@@ -701,6 +745,53 @@ export function resolveVariant(
701
745
  return { variantId, optionSelections };
702
746
  }
703
747
 
748
+ // ─── First-party asset handles (ADR-0099 D3 / ADR-0095) ────────────────────
749
+
750
+ export type ExpandHandlesResult =
751
+ | { ok: true; asset: string | null; design: Record<string, ParsedFill>; expanded: Set<string> }
752
+ | { ok: false; status: number; code: string; message: string };
753
+
754
+ /**
755
+ * Replace every `ingest:<sha256>` asset value (bare `asset=` and per-key
756
+ * `asset.<key>=` sources) with its first-party URL. Returns the set of URLs
757
+ * that came from handles so the caller can skip the origin allowlist for
758
+ * them (platform provenance, like the `default` token). A malformed handle
759
+ * fails loudly — never falls back to fetching the literal string.
760
+ */
761
+ export function expandIngestHandles(
762
+ asset: string | null,
763
+ design: Record<string, ParsedFill>,
764
+ expand: (value: string) => string | null,
765
+ isHandle: (value: unknown) => boolean
766
+ ): ExpandHandlesResult {
767
+ const expanded = new Set<string>();
768
+ const bad = (where: string, value: string): ExpandHandlesResult => ({
769
+ ok: false,
770
+ status: 400,
771
+ code: "E_INGEST_HANDLE_INVALID",
772
+ message: `${where} is not a valid asset handle: "${value}". Expected ingest:<64 lowercase hex sha256> (the sha256 of the ingested source URL).`,
773
+ });
774
+ let outAsset = asset;
775
+ if (asset !== null && isHandle(asset)) {
776
+ const url = expand(asset);
777
+ if (!url) return bad("asset", asset);
778
+ outAsset = url;
779
+ expanded.add(url);
780
+ }
781
+ const outDesign: Record<string, ParsedFill> = {};
782
+ for (const [key, fill] of Object.entries(design)) {
783
+ if (fill.src && isHandle(fill.src)) {
784
+ const url = expand(fill.src);
785
+ if (!url) return bad(`asset.${key}`, fill.src);
786
+ outDesign[key] = { ...fill, src: url };
787
+ expanded.add(url);
788
+ } else {
789
+ outDesign[key] = fill;
790
+ }
791
+ }
792
+ return { ok: true, asset: outAsset, design: outDesign, expanded };
793
+ }
794
+
704
795
  // ─── Bundles (ADR-0099): picks, per-role variants, the mockup, the placements ──
705
796
 
706
797
  export interface BundleSceneInput {
@@ -20,15 +20,15 @@ import {
20
20
  * stated here so nobody reads a green run as "cross-checked".
21
21
  */
22
22
  describe('MAX_DESIGN_ELEMENTS drift pin (resolver ↔ buy ↔ render box)', () => {
23
- it('pins the literal the render box enforces (rendercenter shared CACHE_LIMITS.MAX_ELEMENTS = 10)', () => {
24
- expect(MAX_DESIGN_ELEMENTS).toBe(10)
23
+ it('pins the literal the render box enforces (rendercenter shared CACHE_LIMITS.MAX_ELEMENTS = 24)', () => {
24
+ expect(MAX_DESIGN_ELEMENTS).toBe(24)
25
25
  })
26
26
 
27
27
  it('matches the submodule copy when services/rendercenter is checked out (literal-only in CI)', () => {
28
28
  const typesTs = resolve(__dirname, '../../../services/rendercenter/shared/src/types.ts')
29
29
  if (!existsSync(typesTs)) {
30
30
  // Submodule absent (CI): the literal pin above is the assertion.
31
- expect(MAX_DESIGN_ELEMENTS).toBe(10)
31
+ expect(MAX_DESIGN_ELEMENTS).toBe(24)
32
32
  return
33
33
  }
34
34
  const m = /MAX_ELEMENTS:\s*(\d+)/.exec(readFileSync(typesTs, 'utf8'))
@@ -10,6 +10,7 @@ import {
10
10
  type ResolvedPlacement,
11
11
  type ResolvedProduct,
12
12
  fetchProduct,
13
+ resolveDefaults,
13
14
  } from "../src/resolve";
14
15
 
15
16
  // A size×color-style product WITH combinations (picks select the SKU).
@@ -672,3 +673,95 @@ function ok2(r: ReturnType<typeof resolveBundleScene>) {
672
673
  if (!r.ok) throw new Error(`${r.code}: ${r.message}`);
673
674
  return r.scene;
674
675
  }
676
+
677
+ // ─── First-party asset handles (ADR-0099 D3) ─────────────────────────────────
678
+ import { expandIngestHandles } from "../src/resolve";
679
+ import { expandIngestHandle, isIngestHandle } from "@snowcone-app/mockup-url";
680
+
681
+ describe("expandIngestHandles", () => {
682
+ const sha = "a".repeat(64);
683
+ it("expands bare and per-key handles to the first-party URL and reports them as platform-provenance", () => {
684
+ const r = expandIngestHandles(`ingest:${sha}`, { back: { src: `ingest:${sha}` }, left: { src: "https://x/y.png" } }, expandIngestHandle, isIngestHandle);
685
+ expect(r.ok).toBe(true);
686
+ if (r.ok) {
687
+ expect(r.asset).toBe(`https://raws.snowcone.app/art-ingest/${sha}`);
688
+ expect(r.design.back.src).toBe(`https://raws.snowcone.app/art-ingest/${sha}`);
689
+ expect(r.design.left.src).toBe("https://x/y.png");
690
+ expect([...r.expanded]).toEqual([`https://raws.snowcone.app/art-ingest/${sha}`]);
691
+ }
692
+ });
693
+ it("a malformed handle is a typed 400, never fetched literally", () => {
694
+ const r = expandIngestHandles("ingest:nope", {}, expandIngestHandle, isIngestHandle);
695
+ expect(r.ok).toBe(false);
696
+ if (!r.ok) expect([r.status, r.code]).toEqual([400, "E_INGEST_HANDLE_INVALID"]);
697
+ const r2 = expandIngestHandles(null, { front: { src: "ingest:ABC" } }, expandIngestHandle, isIngestHandle);
698
+ expect(r2.ok).toBe(false);
699
+ if (!r2.ok) expect(r2.message).toMatch(/asset\.front/);
700
+ });
701
+ it("leaves non-handle values untouched", () => {
702
+ const r = expandIngestHandles("https://a/b.png", { front: { color: "ff0000" } }, expandIngestHandle, isIngestHandle);
703
+ expect(r.ok && r.asset).toBe("https://a/b.png");
704
+ expect(r.ok && r.expanded.size).toBe(0);
705
+ });
706
+ });
707
+
708
+ describe("resolveDefaults: a variant nobody chose follows the mockup to one with a scene", () => {
709
+ const product = {
710
+ defaultGvid: "stale",
711
+ variants: [{ gvid: "stale" }],
712
+ mockups: [{ id: "M1", gvids: ["built"] }, { id: "M2", gvids: [] }],
713
+ placements: [{ label: "Front" }],
714
+ } as unknown as Parameters<typeof resolveDefaults>[0];
715
+
716
+ it("default not listed: uses the mockup's listed variant (XTNA6J's stale defaultGvid)", () => {
717
+ expect(resolveDefaults(product, { variant: "stale", variantIsDefault: true })?.variantId).toBe("built");
718
+ });
719
+ it("a chosen variant is never swapped: it may be a colour", () => {
720
+ expect(resolveDefaults(product, { variant: "chosen" })?.variantId).toBe("chosen");
721
+ expect(resolveDefaults(product, { variant: "chosen", mockupId: "M1" })?.variantId).toBe("chosen");
722
+ });
723
+ it("default already listed stays", () => {
724
+ expect(resolveDefaults(product, { variant: "built", variantIsDefault: true })?.variantId).toBe("built");
725
+ });
726
+ it("a mockup listing nothing keeps the default", () => {
727
+ expect(resolveDefaults(product, { variant: "stale", mockupId: "M2", variantIsDefault: true })?.variantId).toBe("stale");
728
+ });
729
+ });
730
+
731
+ describe("a chosen SIZE no mockup lists renders the listed size sibling, said in previewFor (#4342/#4388)", async () => {
732
+ const { listedSizeSibling, resolveVariant: rv } = await import("../src/resolve");
733
+ // XTNA6J, 2026-11-11: sizes are combination rows, colour is an option (affectsCombinations false); every live mockup
734
+ // lists only S (47448b) and the default is XL (296448).
735
+ const sizes: Array<[string, string]> = [["S", "47448b"], ["M", "731fb0"], ["L", "l00000"], ["XL", "296448"], ["2XL", "c9f1ea"]];
736
+ const hoodie = {
737
+ defaultGvid: "296448",
738
+ variants: sizes.map(([, g]) => ({ gvid: g })),
739
+ attributes: { Size: { affectsCombinations: true, choices: sizes.map(([s]) => s) }, Color: { affectsCombinations: false, choices: ["Black", "White"] } },
740
+ combinations: sizes.map(([s, g]) => ({ variantId: g, options: { Size: s } })),
741
+ mockups: [{ id: "3VPV6M", gvids: ["47448b"] }, { id: "9XC4GD", gvids: ["47448b"] }],
742
+ placements: [{ label: "Front left" }],
743
+ } as unknown as Parameters<typeof resolveDefaults>[0];
744
+ const resolveUrl = (picks: Record<string, string>, variantOverride?: string) => {
745
+ const v = rv(hoodie as any, picks, variantOverride)!;
746
+ return resolveDefaults(hoodie, { variant: v.variantId, variantIsDefault: !variantOverride && Object.keys(picks).length === 0 });
747
+ };
748
+
749
+ it("the lead's six URLs: plain, size S/M/XL/2XL, XL+White, White or Black alone: all render 47448b; a swap names the asked size", () => {
750
+ expect(resolveUrl({})).toMatchObject({ variantId: "47448b", previewFor: "296448" });
751
+ expect(resolveUrl({ size: "S" })).toEqual(expect.objectContaining({ variantId: "47448b" }));
752
+ expect(resolveUrl({ size: "S" })?.previewFor).toBeUndefined();
753
+ for (const [s, g] of [["M", "731fb0"], ["XL", "296448"], ["2XL", "c9f1ea"]]) expect(resolveUrl({ size: s })).toMatchObject({ variantId: "47448b", previewFor: g });
754
+ expect(resolveUrl({ size: "XL", color: "White" })).toMatchObject({ variantId: "47448b", previewFor: "296448" });
755
+ for (const c of ["White", "Black"]) expect(resolveUrl({ color: c })).toMatchObject({ variantId: "47448b", previewFor: "296448" });
756
+ });
757
+
758
+ it("never swaps a colour that is a combination attribute (a tee whose mockups list only Black)", () => {
759
+ const tee = { combinations: [{ variantId: "bk-m", options: { Color: "Black", Size: "M" } }, { variantId: "wh-m", options: { Color: "White", Size: "M" } }, { variantId: "bk-s", options: { Color: "Black", Size: "S" } }] };
760
+ expect(listedSizeSibling(tee as any, { gvids: ["bk-s"] }, "bk-m")).toBe("bk-s");
761
+ expect(listedSizeSibling(tee as any, { gvids: ["bk-s"] }, "wh-m")).toBeNull();
762
+ });
763
+
764
+ it("a variant= the caller named with no size sibling is theirs (the box's typed refusal stands)", () => {
765
+ expect(resolveDefaults(hoodie, { variant: "nope" })?.variantId).toBe("nope");
766
+ });
767
+ });
package/wrangler.jsonc CHANGED
@@ -30,8 +30,9 @@
30
30
  // to override these prod defaults. For standalone `pnpm dev`, copy
31
31
  // .dev.vars.example -> .dev.vars.
32
32
  "vars": {
33
- // Our nine metro relays (relay-<metro>-1): the production-shape load generator. Exact IPs; change via PR.
34
- "LOADTEST_EXEMPT_IPS": "172.236.245.89,139.144.31.189,45.79.3.111,172.104.24.94,172.234.136.102,172.235.133.146,172.237.142.112,172.234.252.106,50.116.2.79",
33
+ // relay-lax-1, our one remaining relay: the production-shape load generator. Exact IPs; change via PR.
34
+ // (The eight other metro relays were deleted 2026-10-20 — their IPs return to Linode's pool, so they must never stay listed.)
35
+ "LOADTEST_EXEMPT_IPS": "172.236.245.89",
35
36
  "TTL_DEFAULT": "86400",
36
37
  "LOG_LEVEL": "info",
37
38
  // MEILISEARCH_API_KEY is the public read-only search key (same as apps/www);