@eldrajs/theme-cli 0.2.3 → 0.2.4

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 (51) hide show
  1. package/dist/cli.js +2 -3
  2. package/dist/index.d.ts +0 -12
  3. package/dist/index.js +1 -1
  4. package/dist/{validate-DprFpjV7.js → validate-FjQ-5_ne.js} +9 -18
  5. package/package.json +3 -3
  6. package/template/.eldra/previews.json +35 -35
  7. package/template/app/storefront/gateway.ts +0 -3
  8. package/template/app/storefront/structuredData.ts +2 -2
  9. package/template/app/storefront/types.ts +0 -5
  10. package/template/app/utils/seoInput.ts +0 -1
  11. package/template/blocks/announcement-bar/preview.png +0 -0
  12. package/template/blocks/article/preview.png +0 -0
  13. package/template/blocks/article-list/preview.png +0 -0
  14. package/template/blocks/breadcrumbs/preview.png +0 -0
  15. package/template/blocks/cart/preview.png +0 -0
  16. package/template/blocks/collection-grid/preview.png +0 -0
  17. package/template/blocks/collection-header/preview.png +0 -0
  18. package/template/blocks/contact/preview.png +0 -0
  19. package/template/blocks/cta/preview.png +0 -0
  20. package/template/blocks/faq/preview.png +0 -0
  21. package/template/blocks/feature-grid/preview.png +0 -0
  22. package/template/blocks/footer/preview.png +0 -0
  23. package/template/blocks/form/preview.png +0 -0
  24. package/template/blocks/gallery/preview.png +0 -0
  25. package/template/blocks/hero/preview.png +0 -0
  26. package/template/blocks/image/preview.png +0 -0
  27. package/template/blocks/logo-cloud/preview.png +0 -0
  28. package/template/blocks/navigation/preview.png +0 -0
  29. package/template/blocks/newsletter/preview.png +0 -0
  30. package/template/blocks/order-status/preview.png +0 -0
  31. package/template/blocks/pricing-table/preview.png +0 -0
  32. package/template/blocks/product-carousel/preview.png +0 -0
  33. package/template/blocks/product-detail/preview.png +0 -0
  34. package/template/blocks/quote/preview.png +0 -0
  35. package/template/blocks/rich-text/preview.png +0 -0
  36. package/template/blocks/search/preview.png +0 -0
  37. package/template/blocks/split-content/preview.png +0 -0
  38. package/template/blocks/stats/preview.png +0 -0
  39. package/template/blocks/tabs/preview.png +0 -0
  40. package/template/blocks/team/preview.png +0 -0
  41. package/template/blocks/testimonials/preview.png +0 -0
  42. package/template/blocks/timeline/preview.png +0 -0
  43. package/template/blocks/trust-strip/preview.png +0 -0
  44. package/template/blocks/video-embed/preview.png +0 -0
  45. package/template/blocks/wishlist/preview.png +0 -0
  46. package/template/package.json +1 -1
  47. package/template/test/prerenderRefresh.browser.spec.ts +50 -0
  48. package/template/test/seoInput.spec.ts +5 -4
  49. package/template/test/storefront/structuredData.spec.ts +3 -6
  50. package/template/test/structuredData.generate.spec.ts +1 -1
  51. package/template/test/support/mockGateway.ts +8 -3
package/dist/cli.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
- import { a as initTheme, i as scaffoldBlock, n as generateBlockTypesFile, o as DeployError, r as generateTypes, s as deployTheme, t as validateTheme } from "./validate-DprFpjV7.js";
2
+ import { a as initTheme, i as scaffoldBlock, n as generateBlockTypesFile, o as DeployError, r as generateTypes, s as deployTheme, t as validateTheme } from "./validate-FjQ-5_ne.js";
3
3
  import { resolve } from "node:path";
4
4
  import { defineCommand, runMain } from "citty";
5
- //#region src/cli.ts
5
+ // src/cli.ts
6
6
  const gatewayArgs = {
7
7
  "gateway-url": {
8
8
  type: "string",
@@ -199,5 +199,4 @@ const main = defineCommand({
199
199
  }
200
200
  });
201
201
  await runMain(main);
202
- //#endregion
203
202
  export {};
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import { DeclaredThemeCodePage } from "@eldrajs/vite-plugin-theme";
2
2
  import { scanTheme } from "@eldrajs/vite-plugin-theme/scan";
3
- //#region src/deployReport.d.ts
4
3
  /**
5
4
  * What a deploy did to existing content, in the words an author needs.
6
5
  *
@@ -78,8 +77,6 @@ interface FieldMigrationReport {
78
77
  * deploy command only forwards these to its logger.
79
78
  */
80
79
  export declare function fieldMigrationLines(report: FieldMigrationReport | undefined | null): string[];
81
- //#endregion
82
- //#region src/commands/deploy.d.ts
83
80
  export declare class DeployError extends Error {
84
81
  readonly code: string | null;
85
82
  constructor(message: string, code?: string | null);
@@ -119,11 +116,7 @@ export declare function detectCommitSha(env: {
119
116
  BITBUCKET_COMMIT?: string;
120
117
  }): string | null;
121
118
  export declare function deployTheme(opts: DeployOptions): Promise<DeployResult>;
122
- //#endregion
123
- //#region src/commands/init.d.ts
124
119
  export declare function initTheme(targetDir: string): void;
125
- //#endregion
126
- //#region src/commands/scaffold.d.ts
127
120
  interface ScaffoldBlockOptions {
128
121
  themeDir: string;
129
122
  apiId: string;
@@ -134,8 +127,6 @@ interface ScaffoldBlockOptions {
134
127
  export declare function scaffoldBlock(opts: ScaffoldBlockOptions): {
135
128
  created: string[];
136
129
  };
137
- //#endregion
138
- //#region src/commands/types.d.ts
139
130
  export declare function generateTypes(opts: {
140
131
  themeDir: string;
141
132
  gatewayUrl: string;
@@ -154,8 +145,6 @@ export declare function generateTypes(opts: {
154
145
  export declare function generateBlockTypesFile(opts: {
155
146
  themeDir: string;
156
147
  }): string;
157
- //#endregion
158
- //#region src/commands/validate.d.ts
159
148
  interface ValidateOptions {
160
149
  themeDir: string;
161
150
  remote: boolean;
@@ -170,5 +159,4 @@ interface ValidateResult {
170
159
  blockCount: number;
171
160
  }
172
161
  export declare function validateTheme(opts: ValidateOptions): Promise<ValidateResult>;
173
- //#endregion
174
162
  export { type ConvertedFieldMigration, type DeployOptions, type DeployResult, type DeploySyncResult, type DroppedLinkRows, type FieldMigrationReport, type RetiredFieldMigration, type ScaffoldBlockOptions, type ValidateOptions, type ValidateResult, scanTheme };
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as initTheme, c as detectCommitSha, i as scaffoldBlock, l as fieldMigrationLines, n as generateBlockTypesFile, o as DeployError, r as generateTypes, s as deployTheme, t as validateTheme } from "./validate-DprFpjV7.js";
1
+ import { a as initTheme, c as detectCommitSha, i as scaffoldBlock, l as fieldMigrationLines, n as generateBlockTypesFile, o as DeployError, r as generateTypes, s as deployTheme, t as validateTheme } from "./validate-FjQ-5_ne.js";
2
2
  import { scanTheme } from "@eldrajs/vite-plugin-theme/scan";
3
3
  export { DeployError, deployTheme, detectCommitSha, fieldMigrationLines, generateBlockTypesFile, generateTypes, initTheme, scaffoldBlock, scanTheme, validateTheme };
@@ -7,7 +7,7 @@ import * as tar from "tar";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { generateBlockTypes } from "@eldrajs/vite-plugin-theme";
9
9
  import { readPreviousManifest, scanTheme } from "@eldrajs/vite-plugin-theme/scan";
10
- //#region src/deployReport.ts
10
+ // src/deployReport.ts
11
11
  /** The drop reasons this version can say in words. Anything else prints as the
12
12
  * code the gateway sent, so a reason added later is still reported. */
13
13
  const DROP_REASONS = { "kind-not-offered": "the field does not offer that kind" };
@@ -88,8 +88,7 @@ function nameOf(value) {
88
88
  function asArray(value) {
89
89
  return Array.isArray(value) ? value : [];
90
90
  }
91
- //#endregion
92
- //#region src/urls.ts
91
+ // src/urls.ts
93
92
  /**
94
93
  * Strips every trailing `/` from a URL (`https://x///` → `https://x`). A
95
94
  * regex equivalent (`/\/+$/`) backtracks polynomially on a long run of
@@ -105,8 +104,7 @@ function stripTrailingSlashes(value) {
105
104
  while (end > 0 && value.charCodeAt(end - 1) === 47) end--;
106
105
  return value.slice(0, end);
107
106
  }
108
- //#endregion
109
- //#region src/commands/deploy.ts
107
+ // src/commands/deploy.ts
110
108
  const MAX_FILES = 2e4;
111
109
  const MAX_FILE_BYTES = 26214400;
112
110
  const MAX_DESIGN_TOKEN_MAPPING_BYTES = 16384;
@@ -286,8 +284,7 @@ async function toDeployError(res) {
286
284
  if (res.status === 413 && bodyUnparseable) return new DeployError("deploy: gateway responded 413 (payload too large) with no error body — a proxy/CDN in front of it may have a smaller limit than the app's own (≤ 20,000 files, ≤ 25 MiB/file, ≤ 500 MiB unpacked, ≤ 200 MiB compressed), or the request exceeds one of those; check the artifact size, and if it is within them ask infra about the proxy limit");
287
285
  return new DeployError(`deploy: ${messages[detail ?? ""] ?? `gateway responded ${res.status}${detail ? ` (${detail})` : ""}`}`, detail);
288
286
  }
289
- //#endregion
290
- //#region src/templateExclude.mjs
287
+ // src/templateExclude.mjs
291
288
  /** A directory with this name, at any depth, is never copied. */
292
289
  const EXCLUDE_DIR_NAMES = [
293
290
  "node_modules",
@@ -321,8 +318,7 @@ function shouldCopyTemplatePath(path) {
321
318
  if (parts.some((part) => EXCLUDE_DIR_NAMES.includes(part))) return false;
322
319
  return !parts.some((part, index) => EXCLUDE_NESTED_DIRS.some((nested) => part === nested.parent && parts[index + 1] === nested.name));
323
320
  }
324
- //#endregion
325
- //#region src/commands/init.ts
321
+ // src/commands/init.ts
326
322
  function initTheme(targetDir) {
327
323
  if (existsSync(targetDir) && readdirSync(targetDir).length > 0) throw new Error(`init: target directory ${targetDir} is not empty`);
328
324
  const source = templateSource();
@@ -350,8 +346,7 @@ function templateSource() {
350
346
  if (source === void 0) throw new Error("starter template not found (package built without template/)");
351
347
  return source;
352
348
  }
353
- //#endregion
354
- //#region src/commands/scaffold.ts
349
+ // src/commands/scaffold.ts
355
350
  const API_ID_RE = /^[a-z][a-z0-9-]{1,48}$/;
356
351
  function scaffoldBlock(opts) {
357
352
  if (!API_ID_RE.test(opts.apiId)) throw new Error(`scaffoldBlock: apiId "${opts.apiId}" must match ${API_ID_RE.source}`);
@@ -404,8 +399,7 @@ function scaffoldBlock(opts) {
404
399
  function titleCase(apiId) {
405
400
  return apiId.split("-").map((word) => `${word[0].toUpperCase()}${word.slice(1)}`).join(" ");
406
401
  }
407
- //#endregion
408
- //#region src/commands/types.ts
402
+ // src/commands/types.ts
409
403
  async function generateTypes(opts) {
410
404
  const definitions = await createEldraClient({
411
405
  gatewayUrl: opts.gatewayUrl,
@@ -436,8 +430,7 @@ function generateBlockTypesFile(opts) {
436
430
  writeFileSync(target, content);
437
431
  return target;
438
432
  }
439
- //#endregion
440
- //#region src/knownFieldTypes.ts
433
+ // src/knownFieldTypes.ts
441
434
  const KNOWN_FIELD_TYPES = [
442
435
  "bool",
443
436
  "color",
@@ -463,8 +456,7 @@ const KNOWN_FIELD_TYPES = [
463
456
  "text",
464
457
  "uuid"
465
458
  ];
466
- //#endregion
467
- //#region src/commands/validate.ts
459
+ // src/commands/validate.ts
468
460
  const DEFAULT_CAPABLE_FIELD_TYPES = /* @__PURE__ */ new Set([
469
461
  "string",
470
462
  "text",
@@ -531,5 +523,4 @@ function validateFields(apiId, fields, validTypes, errors, path) {
531
523
  if (typeof nested.item === "object" && nested.item !== null) validateFields(apiId, [nested.item], validTypes, errors, `${fieldPath}.metadata.item`);
532
524
  });
533
525
  }
534
- //#endregion
535
526
  export { initTheme as a, detectCommitSha as c, scaffoldBlock as i, fieldMigrationLines as l, generateBlockTypesFile as n, DeployError as o, generateTypes as r, deployTheme as s, validateTheme as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eldrajs/theme-cli",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "CLI for Eldra themes: init from the starter, scaffold blocks, validate, generate types, deploy a static build to Eldra.",
5
5
  "keywords": [
6
6
  "cli",
@@ -42,8 +42,8 @@
42
42
  "dependencies": {
43
43
  "citty": "^0.1.6",
44
44
  "tar": "^7.4.3",
45
- "@eldrajs/theme-core": "^0.3.2",
46
- "@eldrajs/vite-plugin-theme": "^0.3.2"
45
+ "@eldrajs/theme-core": "^0.3.3",
46
+ "@eldrajs/vite-plugin-theme": "^0.3.3"
47
47
  },
48
48
  "devDependencies": {
49
49
  "execa": "^9.5.2"
@@ -1,37 +1,37 @@
1
1
  {
2
- "announcement-bar": "8a689cf55c908f2049731c24d89007f12b303b686c331d11e3fef18263f43fee",
3
- "article": "e3de7c95a5aa30507e551e37ccbec0c28067c500c7623dc8b77902b59893d828",
4
- "article-list": "673c37d8c8019aa15facba9459a523aa9c89dc183ef27fa7b512a0a3574db377",
5
- "breadcrumbs": "3b4f9c9144592a1d83b07f7bcecc7efdf875e789643412625335903e4f06c0c2",
6
- "cart": "4dee720ac08788d623e814bbc02fe4e8f63e9471770ce445d189c7621421a639",
7
- "collection-grid": "b1e016552881b4325eff64ec69a1232b3349fadfa136f7f8f1113a487c07848a",
8
- "collection-header": "1eabde9b00ef3566cedab4566d021ff5c0bad20e69aafbed5b57a7788c0eb34f",
9
- "contact": "061036ca4bd571a058230c54fff612686dfdc6465b59e28991b4c313c001fd3c",
10
- "cta": "ace9143e94d3a8136ab06daf4875c493c5dff738a6a91d4e0486440aa2d65a21",
11
- "faq": "b67c46e039e67ba5c3ee1a6050ff0c15d647b80d8e801516a89532f3e461f6b7",
12
- "feature-grid": "44fb41a30935185fe2e00b0028b7b9fa46c98e71d20c9bd92d0a440513e44163",
13
- "footer": "70c6b557b65a9e50db7d7345a40d516b82a1762251d1bd572b12dd3eebdf29e1",
14
- "form": "0afb1e35077d8e9e43350f9e6e78192326c98d4b29ffe0c9caf916a9cdd36569",
15
- "gallery": "a2c652a4ca579c581196fac0a698916b76cca52232df6e873f7bf80941353446",
16
- "hero": "b9c98af851deb55a2747880d0da555b91e354081adad68dce84672d28178f774",
17
- "image": "3fe172e731e1ff31f998155ba9cce82fb159b496a850f372af80941bd6dc660b",
18
- "logo-cloud": "f5818878f713c885148161e90fa7d006aae35578fd893b9da511652dc29b88f9",
19
- "navigation": "67b29fcfb822d5572ecd74c203070f92ec387e96607c137e662b953fcda73580",
20
- "newsletter": "77d5c21da977426e037f38627c87b3a7ebbe4afec94936480d342642ac6d1d02",
21
- "order-status": "0f7f858848ab13a4437c4c5e709ef4e232fe64dd2e868ebb8c5d79dc0a8728e8",
22
- "pricing-table": "9c1a947af841e97cc87ff600edf3c53c7a54a9065a4bd72a42121e7b8bc2f715",
23
- "product-carousel": "67379d314525e362d91c97e765cd2f6c60a58ab71ef993279a35a2d413f053ff",
24
- "product-detail": "11b47a73b8ea60c2b73577b276da10a8fab5ca148070be7f4fe23ab390fca106",
25
- "quote": "0a3aebe57b2b5d4128b3a8479b7fdb28951b182e576fae3d063e7b544d40dc5d",
26
- "rich-text": "fe0eac23870282628672872bd8b57050415e2925b317390bf1a378670a628ea1",
27
- "search": "418b02e1f70bd654670206a14bb8bbdc6da3f4b5e9871a637cd995fb9273cff3",
28
- "split-content": "76a2ae7167ba86c15d1853bf391fa02f510822d348ac3d0a0b5ccfbc1f1b4f6c",
29
- "stats": "42e663f6e51a95489797620f03423c739f6a6a602b79449b7a7bb992cf3cc1b1",
30
- "tabs": "e8149e00646111ee090acf2fcc35cc4f55f3ccc3bfdbca0c692b9dd9dca0af52",
31
- "team": "4351405de230c1b44ae354b24adc8effd403b97a3d65156a7f3cff0e28644e06",
32
- "testimonials": "e4732b33affc438566c4c06bc06a35ab92d008c42e07390936bf42b830d3636c",
33
- "timeline": "3e311d49e2d167e64899af12ca5677203ceb56159ef1a92bf390f8442057b65f",
34
- "trust-strip": "4635537d093f5da1fc7f9bab83d4a43861280fc49d1546014102affc2355b675",
35
- "video-embed": "e8065f78c5a1b51c2703b5cf70108f7d41100aa46dc78fc64f9232e138d7d832",
36
- "wishlist": "b2b67468462794e4e28d6c72c31ad29ddb0730c7531f61f8773c9cbab0d8676c"
2
+ "announcement-bar": "2b057546d7d017f6481e5c89e7af3ee67c1f03fc503ba29ef3485a8b3b72ca3e",
3
+ "article": "0f1d1229dc640ef3580442855b1eb4be83bbad43e6d828b71edd218018581b7e",
4
+ "article-list": "4132ded9bc945513dbdf0d6138c85a081aaeae65cb66f101e091acbd302c3274",
5
+ "breadcrumbs": "637c19cb81ba8e5a979df0e5f7bf6444ce85feb618c8168ac76df91434e00aad",
6
+ "cart": "7163dc4cdb18e2ea39b573e0e33c70c04202261266616671f06fd0837c141c70",
7
+ "collection-grid": "2062ade27f90aac810114c3d9a4bbd5efddd5b74c869a2b891dc3589c149eda6",
8
+ "collection-header": "cbcfacb1d8ab6638fb8094a8517baec3ff3911f9df744007babeee402e75715f",
9
+ "contact": "0af119acf554c453d8f545f3cd7a37ed4f3afa9a2472e105978e4f48f7d51616",
10
+ "cta": "0e3fc7d629f34d451b9f785d57fdd88c7853f737dab55136ec2e07b282cc4d81",
11
+ "faq": "90baa9a0832632aa47cd9ce1fe29682c16e045ea9739464e67d7287c6b0b94c8",
12
+ "feature-grid": "9bb14686453ba8ec7758442a6a55ffec797208ad02aed05d465ab384b42ff6c1",
13
+ "footer": "cbf8e902d28cc54eed9b57c75f1de122bbdbbda9845097a5f751e4864f3b3b9e",
14
+ "form": "55c897592a0048fb4465485d66c240084173479dad56e692608111c20f9d1a1d",
15
+ "gallery": "aaaae7b8b72f8a54c96bdac673317ba260e946c52fc7a62dbc439aab87f1f5a3",
16
+ "hero": "17309fd9ed6ca109725906c064c07d24187a7888175db2a1fb900966999a69f9",
17
+ "image": "7e2eaff913b3daf5eb96013e4e1762400b0c1eb06ccfb51cdb4eaee39e54c4aa",
18
+ "logo-cloud": "281e3cd1b8a4d3f3983623b22cfad7072aed6ab467a0d06eafcf3d884655a25a",
19
+ "navigation": "6377021a405f0ced6ad0f4013a19e20f42b2f1ea0d2a35f0646d9584b0a75088",
20
+ "newsletter": "fed26701771229ce4573d01ee79383ed482683bc904e225b30549d28f5b25697",
21
+ "order-status": "260384a10709343107828059b42a3e1238083aae94b9bc812c6feaa999adf522",
22
+ "pricing-table": "99890127509926177dc6a55b74a355577c8c8179a053290a3e866846e875be80",
23
+ "product-carousel": "4f2d1269f8432e1e7ba39abc57f4bc2330efbf7db1cd473004731c066fc23cd3",
24
+ "product-detail": "8e4cd802a3b0e9f7514edb4978b7dfff2fc1bd32d5fd0f7da9c041b1259b7222",
25
+ "quote": "e173b6e75861006d6c9a7397f9cf7d11834a2116bff27029e8df58799143bdf4",
26
+ "rich-text": "3239b3aa81b99b807409bbc5e1def629db64c8ee73140c7f6382d535c7a2ae48",
27
+ "search": "d6501ae66f353842724b2dd90413d01ead20ab75f2c17722a9cd87527ccf6418",
28
+ "split-content": "41b84b530d65d37777c3df6f55cf12a62a090edf938f784491641c5967b6d602",
29
+ "stats": "e7bf6d2134a6f404d9e3cce87892c36838e9b4ed247f7b3e34882eca61412ad1",
30
+ "tabs": "352eaed3dea3c54d7bcb7665feafb770a9977f0fa0029abf9e3fb83c23960936",
31
+ "team": "52ca9e5827f11c68344593aa44508cb41f3322576a6aac3cb9454df2c381827a",
32
+ "testimonials": "a4477a2a42c2634ea7180ba2801412580962661651baee2697703b1ca854dd45",
33
+ "timeline": "c5ab8481388681dec370959c815f835130da75f37cbaa0745dbc39f1afc825b6",
34
+ "trust-strip": "babe3d988c88a93a8452881a0d8ecc6d1872004c604d550471edcae52d565066",
35
+ "video-embed": "4cd7b65b4ee6c7cc86b0dc5ef27e29c2e144afcdc9736bf6b2ac5b750ada4ce0",
36
+ "wishlist": "6051e425cb5b40a638c08b86d452bbeed4cba590582ed7092f29697ea2fd1636"
37
37
  }
@@ -239,8 +239,6 @@ interface RawProductDetails {
239
239
  * knows the response carries it rather than inferring the catalogue only ever assigns one.
240
240
  */
241
241
  categoryIds?: string[] | null;
242
- /** Per-product brand, for `Product.brand` in the structured data. */
243
- brand?: string | null;
244
242
  description?: Record<string, unknown>;
245
243
  mediaLinks?: RawMediaItem[] | null;
246
244
  options?: RawProductOption[] | null;
@@ -602,7 +600,6 @@ function mapProductDetails(
602
600
  ? (stock?.get(countableVariant.id)?.availableQuantity ?? null)
603
601
  : null,
604
602
  stock: variantStock(firstAvailable, stock),
605
- brand: raw.brand?.trim() || null,
606
603
  // Each variant's own price and stock state, for the page's structured data: the same
607
604
  // `variantStock` rule the buy box's line uses, so the markup and the page cannot disagree.
608
605
  variants: variants.map((variant) => ({
@@ -159,8 +159,8 @@ export function pageStructuredData(parts: PageLdParts): StructuredDataEntry[] {
159
159
  name: product.title,
160
160
  description: ldPlainText(product.description),
161
161
  images: product.images.map((image) => image.src),
162
- // A product with no brand of its own is sold under the shop's name (the site profile's).
163
- brand: product.brand ?? parts.profile.name,
162
+ // Products carry no brand of their own: they are sold under the shop's name.
163
+ brand: parts.profile.name,
164
164
  variants: variantsOf(product, parts.currentUrl),
165
165
  currency: parts.currency,
166
166
  ratings: product.rating,
@@ -179,11 +179,6 @@ export interface StorefrontProduct extends StorefrontProductListItem {
179
179
  */
180
180
  inventory: number | null;
181
181
  shipsBy?: string | null;
182
- /**
183
- * The product's brand, when the platform carries one (`brand` on the public product read). Read
184
- * by the page's structured data only; the page itself does not show it.
185
- */
186
- brand?: string | null;
187
182
  /**
188
183
  * **Every variant, with the price and stock the page's own variant resolves from** — what the
189
184
  * page's structured data writes one offer per. Absent from a source that has no variants to
@@ -72,7 +72,6 @@ export function seoInput(parts: SeoInputParts): SeoInput {
72
72
  data['product.sku'] = text(variants[0]?.sku) ?? '';
73
73
  data['product.price'] = prices.length === 0 ? '' : parts.formatPrice(Math.min(...prices));
74
74
  data['product.shortDescription'] = shortDescription(entryData.description);
75
- data['product.brand'] = text(entryData.brand) ?? '';
76
75
  data['product.category'] = text(parts.productCategory) ?? '';
77
76
  contentImage = shareImage(list(entryData.images)[0]);
78
77
  } else if (catalogKind !== null) {
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -23,7 +23,7 @@
23
23
  "@eldrajs/ui": "workspace:*",
24
24
  "@tabler/icons": "^3.34.0",
25
25
  "nuxt": "^4.0.0",
26
- "vue-i18n": "11.4.13"
26
+ "vue-i18n": "11.4.16"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@eldrajs/theme-cli": "workspace:*",
@@ -1254,6 +1254,56 @@ describe('prerendered commerce data on the generated static site', () => {
1254
1254
  }
1255
1255
  });
1256
1256
 
1257
+ /** A campaign mail's link, through `@eldrajs/theme-nuxt`'s capture and the SDK's cart add, on a generated site. */
1258
+ it('credits the cart to the campaign the visitor landed from, once they agree', async () => {
1259
+ const campaignId = '0b9f8a52-3c1d-4e6f-9a7b-2c4d6e8f0a1b';
1260
+ const attribution = {
1261
+ campaignId,
1262
+ utmSource: 'eldra',
1263
+ utmMedium: 'email',
1264
+ utmCampaign: 'haustutsala',
1265
+ };
1266
+ const page = await browser.newPage();
1267
+ try {
1268
+ await page.goto(
1269
+ `${statics.origin}${productPage}?utm_source=eldra&utm_medium=email&utm_campaign=haustutsala` +
1270
+ `&utm_id=${campaignId}&gclid=not-kept`,
1271
+ { waitUntil: 'domcontentloaded' }
1272
+ );
1273
+ await page.waitForTimeout(CATALOG_DELAY_MS + 1500);
1274
+ const kept = () => page.evaluate(() => localStorage.getItem('eldra.campaignAttribution'));
1275
+ expect(await kept(), 'nothing is kept before the visitor agrees').toBeNull();
1276
+ const answer = (granted: boolean) =>
1277
+ page.evaluate((value) => {
1278
+ (
1279
+ window as Window & { eldraCampaignAttributionConsent?: boolean }
1280
+ ).eldraCampaignAttributionConsent = value;
1281
+ window.dispatchEvent(new Event('eldra:campaign-attribution-consent'));
1282
+ }, granted);
1283
+ await answer(true);
1284
+ const stored = await kept();
1285
+ expect(JSON.parse(stored ?? 'null')).toMatchObject({ ...attribution, consented: true });
1286
+ expect(stored).not.toContain('gclid');
1287
+
1288
+ gateway.reset();
1289
+ await page.locator('main button[type="submit"]', { hasText: 'Add to cart' }).first().click();
1290
+ await expect.poll(() => gateway.cartAdds.length, { timeout: 5000 }).toBe(1);
1291
+ expect(gateway.cartAdds[0]).toMatchObject({
1292
+ productId: expect.any(String),
1293
+ variantId: `var-${PRODUCT_HANDLE}`,
1294
+ attribution,
1295
+ });
1296
+
1297
+ await answer(false);
1298
+ expect(await kept(), 'withdrawing removes it').toBeNull();
1299
+ await page.locator('main button[type="submit"]', { hasText: 'Add to cart' }).first().click();
1300
+ await expect.poll(() => gateway.cartAdds.length, { timeout: 5000 }).toBe(2);
1301
+ expect(gateway.cartAdds[1]).not.toHaveProperty('attribution');
1302
+ } finally {
1303
+ await page.close();
1304
+ }
1305
+ });
1306
+
1257
1307
  /**
1258
1308
  * **A reload with a cart already in the browser.**
1259
1309
  *
@@ -50,23 +50,24 @@ describe('seoInput', () => {
50
50
  expect(input.options.contentImage).toMatch(/\/lg$/);
51
51
  });
52
52
 
53
- it('sets product.brand from the projection and product.category from the resolved name', () => {
53
+ it('sets product.category from the resolved name and no product.brand, even from a record that has one', () => {
54
54
  const input = seoInput({
55
55
  ...base,
56
56
  catalog: { kind: 'product', slug: 'mug' },
57
57
  productCategory: 'Mugs',
58
58
  entry: { data: { title: 'Mug', brand: 'Acme', variants: [] } },
59
59
  });
60
- expect(input.data).toMatchObject({ 'product.brand': 'Acme', 'product.category': 'Mugs' });
60
+ expect(input.data).toMatchObject({ 'product.category': 'Mugs' });
61
+ expect('product.brand' in input.data).toBe(false);
61
62
  });
62
63
 
63
- it('leaves product.brand and product.category empty when the product has none', () => {
64
+ it('leaves product.category empty when the product has none', () => {
64
65
  const input = seoInput({
65
66
  ...base,
66
67
  catalog: { kind: 'product', slug: 'mug' },
67
68
  entry: { data: { title: 'Mug' } },
68
69
  });
69
- expect(input.data).toMatchObject({ 'product.brand': '', 'product.category': '' });
70
+ expect(input.data).toMatchObject({ 'product.category': '' });
70
71
  });
71
72
 
72
73
  it('leaves a missing price empty instead of inventing one', () => {
@@ -105,7 +105,7 @@ describe('pageStructuredData', () => {
105
105
  title: 'Mug',
106
106
  currentUrl: `${ORIGIN}/products/mug`,
107
107
  trail: [{ label: 'Cups', path: '/categories/cups' }],
108
- product: product({ brand: 'Acme' }),
108
+ product: product(),
109
109
  })
110
110
  );
111
111
  expect(types(entries)).toEqual(['breadcrumb', 'product']);
@@ -117,14 +117,14 @@ describe('pageStructuredData', () => {
117
117
  name: 'Mug',
118
118
  description: 'A hand-thrown mug.',
119
119
  image: ['https://cdn.test/mug.jpg'],
120
- brand: { name: 'Acme' },
120
+ brand: { name: 'Shop' },
121
121
  offers: { price: 2800, priceCurrency: 'ISK', availability: 'https://schema.org/InStock' },
122
122
  });
123
123
  // The number the markup states is the number the visible price is formatted from.
124
124
  expect(formatMoney(node.offers.price, 'ISK', 'en-US')).toContain('2,800');
125
125
  });
126
126
 
127
- it('maps stock states to availability and falls back to the shop name as brand', () => {
127
+ it('maps stock states to availability', () => {
128
128
  const availability = (stock: StorefrontProduct['stock']) =>
129
129
  (
130
130
  pageStructuredData(parts({ kind: 'product', product: product({ stock }) }))[1]!.node
@@ -133,9 +133,6 @@ describe('pageStructuredData', () => {
133
133
  expect(availability('out')).toBe('https://schema.org/OutOfStock');
134
134
  expect(availability('preorder')).toBe('https://schema.org/PreOrder');
135
135
  expect(availability('low')).toBe('https://schema.org/LimitedAvailability');
136
- expect(
137
- pageStructuredData(parts({ kind: 'product', product: product() }))[1]!.node.brand
138
- ).toEqual({ '@type': 'Brand', name: 'Shop' });
139
136
  });
140
137
 
141
138
  it('writes one offer per variant, AggregateOffer when prices differ, and drops a bad barcode', () => {
@@ -112,7 +112,7 @@ describe('generated pages carry schema.org JSON-LD', () => {
112
112
  expect(product).toMatchObject({
113
113
  name: 'Ash glaze mug',
114
114
  url: `${ORIGIN}/products/${PRODUCT_HANDLE}`,
115
- brand: { name: 'Northwind Ceramics' },
115
+ brand: { name: 'Northwind Goods' },
116
116
  sku: PRODUCT_HANDLE.toUpperCase(),
117
117
  gtin: '4006381333931',
118
118
  offers: {
@@ -65,7 +65,6 @@ interface MockProduct {
65
65
  minPrice: number;
66
66
  maxPrice: number;
67
67
  compareAtPrice?: number;
68
- brand?: string;
69
68
  variants: MockVariant[];
70
69
  }
71
70
 
@@ -92,7 +91,6 @@ export const COLLECTION_HANDLE = 'the-winter-edit';
92
91
 
93
92
  export const PRODUCTS: MockProduct[] = [
94
93
  product(PRODUCT_HANDLE, 'Ash glaze mug', 42, {
95
- brand: 'Northwind Ceramics',
96
94
  variants: [
97
95
  {
98
96
  id: `var-${PRODUCT_HANDLE}`,
@@ -234,7 +232,6 @@ const detailOf = (row: MockProduct): Record<string, unknown> => ({
234
232
  // already read. Both, with the same value, is what a live response looks like.
235
233
  primaryCategoryId: row.categoryId,
236
234
  categoryIds: [row.categoryId],
237
- ...(row.brand === undefined ? {} : { brand: row.brand }),
238
235
  description: { text: `${row.title} — thrown by hand, glazed in ash.` },
239
236
  mediaLinks: [],
240
237
  options: [],
@@ -797,6 +794,8 @@ export interface MockGateway {
797
794
  url: string;
798
795
  /** `pathname + search` of every request, in order. */
799
796
  requests: string[];
797
+ /** The JSON body of every `POST /shopping-cart/v1/cart/items`, in order; each answers the seeded cart. */
798
+ cartAdds: unknown[];
800
799
  /** Milliseconds every `/catalog/v1/**` answer is held back. Settable between phases. */
801
800
  catalogDelayMs: number;
802
801
  /**
@@ -828,6 +827,7 @@ export function startMockGateway(
828
827
  setMockCatalogContract(options.catalogContract ?? '3.8.0');
829
828
  return new Promise((resolve) => {
830
829
  const requests: string[] = [];
830
+ const cartAdds: unknown[] = [];
831
831
  const state = {
832
832
  catalogDelayMs: 0,
833
833
  cartDelayMs: 0,
@@ -965,6 +965,9 @@ export function startMockGateway(
965
965
  );
966
966
  } else if (url.pathname === '/inventory/v1/stock/availability') {
967
967
  answer(availabilityOf(await readJsonBody(req)));
968
+ } else if (url.pathname === '/shopping-cart/v1/cart/items' && req.method === 'POST') {
969
+ cartAdds.push(await readJsonBody(req));
970
+ answer(seededCart());
968
971
  } else if (segments[0] === 'shopping-cart' && segments[2] === 'cart') {
969
972
  // The one cart this mock knows, and only by the id a test seeded. Any other id is a cart
970
973
  // the gateway has forgotten — which the store answers by clearing `eldra.cartId` and
@@ -1014,6 +1017,7 @@ export function startMockGateway(
1014
1017
  server,
1015
1018
  url: `http://127.0.0.1:${address.port}`,
1016
1019
  requests,
1020
+ cartAdds,
1017
1021
  get catalogDelayMs() {
1018
1022
  return state.catalogDelayMs;
1019
1023
  },
@@ -1034,6 +1038,7 @@ export function startMockGateway(
1034
1038
  },
1035
1039
  reset() {
1036
1040
  requests.length = 0;
1041
+ cartAdds.length = 0;
1037
1042
  },
1038
1043
  close: () =>
1039
1044
  new Promise<void>((done, fail) =>