@zalify/storefront-kit 0.5.0 → 0.5.1

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.
@@ -10,8 +10,10 @@ export interface EditorDocuments {
10
10
  export declare const TEMPLATE_TYPES: readonly ["index", "product", "collection", "list-collections", "page", "blog", "article", "cart", "search", "404", "password", "gift_card"];
11
11
  /**
12
12
  * What is wrong with a set of template names, for a storefront's own tests:
13
- * names must be `<type>` or `<type>.<suffix>`, and a type that has alternates
14
- * must also have its default. Empty means the editor can lay them out.
13
+ * names must be `<type>` or `<type>.<suffix>` with a known type. A default is
14
+ * not required next to alternates a site with `page.about` but no generic
15
+ * page route must not invent one; the editor groups such alternates itself.
16
+ * Empty means the editor can lay them out.
15
17
  */
16
18
  export declare function templateNameProblems(names: readonly string[]): string[];
17
19
  /** Only list routes the app can actually render; never fabricate handles. */
@@ -15,13 +15,13 @@ export const TEMPLATE_TYPES = [
15
15
  ];
16
16
  /**
17
17
  * What is wrong with a set of template names, for a storefront's own tests:
18
- * names must be `<type>` or `<type>.<suffix>`, and a type that has alternates
19
- * must also have its default. Empty means the editor can lay them out.
18
+ * names must be `<type>` or `<type>.<suffix>` with a known type. A default is
19
+ * not required next to alternates a site with `page.about` but no generic
20
+ * page route must not invent one; the editor groups such alternates itself.
21
+ * Empty means the editor can lay them out.
20
22
  */
21
23
  export function templateNameProblems(names) {
22
24
  const problems = [];
23
- const known = new Set(names);
24
- const needsDefault = new Set();
25
25
  for (const name of names) {
26
26
  if (name.startsWith('customers/'))
27
27
  continue;
@@ -29,12 +29,6 @@ export function templateNameProblems(names) {
29
29
  if (!TEMPLATE_TYPES.includes(type)) {
30
30
  problems.push(`"${name}": unknown template type "${type}" — use <type>.<suffix>, e.g. "page.${name.replace(/[^a-z0-9]+/gi, '-').toLowerCase()}"`);
31
31
  }
32
- else if (name !== type && !known.has(type)) {
33
- needsDefault.add(type);
34
- }
35
- }
36
- for (const type of needsDefault) {
37
- problems.push(`"${type}.*" alternates exist but the default "${type}" template is not registered`);
38
32
  }
39
33
  return problems;
40
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zalify/storefront-kit",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
4
4
  "type": "module",
5
5
  "description": "The Zalify storefront SDK: framework-agnostic commerce logic (/commerce), the theme contract types and validators (/schemas), the canvas-editor bridge (/editor), and the React theme engine + shared components (/ui, /react/server). Consumed as TypeScript source inside the zalify-storefronts monorepo; published as compiled ESM + d.ts.",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -52,8 +52,9 @@ and from the editor.
52
52
  `page.<suffix>`.
53
53
  - Assert `templateNameProblems(names)` (from
54
54
  `@zalify/storefront-kit/editor/bootstrap`) is empty in the repo's tests.
55
- - A type that has alternates also registers its default (`page` next to
56
- `page.about`). The editor nests alternates under the default.
55
+ - Register a type's default (`page`) only when the app has a route that renders
56
+ it. Alternates without a default are fine: the editor groups them under the
57
+ type. Never add a template just to satisfy the picker.
57
58
  - `writePath` is `<templates dir>/<name>.json`; the file on disk has the same
58
59
  name. Renaming a template renames the file and every route that loads it.
59
60
  - Only advertise a preview route the app can really render. Resource routes
@@ -26,13 +26,13 @@ export const TEMPLATE_TYPES = [
26
26
 
27
27
  /**
28
28
  * What is wrong with a set of template names, for a storefront's own tests:
29
- * names must be `<type>` or `<type>.<suffix>`, and a type that has alternates
30
- * must also have its default. Empty means the editor can lay them out.
29
+ * names must be `<type>` or `<type>.<suffix>` with a known type. A default is
30
+ * not required next to alternates a site with `page.about` but no generic
31
+ * page route must not invent one; the editor groups such alternates itself.
32
+ * Empty means the editor can lay them out.
31
33
  */
32
34
  export function templateNameProblems(names: readonly string[]): string[] {
33
35
  const problems: string[] = [];
34
- const known = new Set(names);
35
- const needsDefault = new Set<string>();
36
36
  for (const name of names) {
37
37
  if (name.startsWith('customers/')) continue;
38
38
  const type = name.split('.')[0];
@@ -40,13 +40,8 @@ export function templateNameProblems(names: readonly string[]): string[] {
40
40
  problems.push(
41
41
  `"${name}": unknown template type "${type}" — use <type>.<suffix>, e.g. "page.${name.replace(/[^a-z0-9]+/gi, '-').toLowerCase()}"`,
42
42
  );
43
- } else if (name !== type && !known.has(type)) {
44
- needsDefault.add(type);
45
43
  }
46
44
  }
47
- for (const type of needsDefault) {
48
- problems.push(`"${type}.*" alternates exist but the default "${type}" template is not registered`);
49
- }
50
45
  return problems;
51
46
  }
52
47