@tokenoftrust/cli 2.4.13 → 2.4.14

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": "@tokenoftrust/cli",
3
- "version": "2.4.13",
3
+ "version": "2.4.14",
4
4
  "description": "Token of Trust developer CLI — clone a tenant store, run it locally with save→reload, and submit it for preview. Installs the `tot` command.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Token of Trust",
@@ -34,7 +34,7 @@ export const SITE_TYPES = ["commerce", "marketing"];
34
34
  export const SEO_KEYS = Object.freeze(["trailingSlash", "structuredData"]);
35
35
 
36
36
  /** Every `seo.structuredData` key. */
37
- export const STRUCTURED_DATA_KEYS = Object.freeze(["graphs", "names", "reviews"]);
37
+ export const STRUCTURED_DATA_KEYS = Object.freeze(["graphs", "names", "reviews", "onlyOn"]);
38
38
 
39
39
  /**
40
40
  * The page types a structured-data profile declares a graph for. `productGroup` is a product
@@ -135,6 +135,21 @@ export function seoDeclarationProblems(seo) {
135
135
  if (data.reviews !== undefined && typeof data.reviews !== "boolean") {
136
136
  problems.push("`seo.structuredData.reviews` must be true or false");
137
137
  }
138
+ if (data.onlyOn !== undefined) {
139
+ if (!isPlainObject(data.onlyOn)) {
140
+ problems.push("`seo.structuredData.onlyOn` must map a node type to the paths it is emitted on");
141
+ } else {
142
+ for (const [token, paths] of Object.entries(/** @type {Record<string, unknown>} */ (data.onlyOn))) {
143
+ const at = `seo.structuredData.onlyOn.${token}`;
144
+ if (!STRUCTURED_DATA_NODE_TOKENS.includes(token)) {
145
+ problems.push(`\`${at}\`: ${JSON.stringify(token)} is not a node type the renderer builds`);
146
+ } else if (!Array.isArray(paths) || paths.length === 0
147
+ || !paths.every((p) => typeof p === "string" && p.startsWith("/") && !p.startsWith("//"))) {
148
+ problems.push(`\`${at}\` must be a non-empty array of root-absolute paths such as "/faq/"`);
149
+ }
150
+ }
151
+ }
152
+ }
138
153
  return problems;
139
154
  }
140
155