@graphcommerce/next-config 8.1.0-canary.9 → 9.0.0-canary.101

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 (45) hide show
  1. package/CHANGELOG.md +272 -67
  2. package/__tests__/config/utils/__snapshots__/mergeEnvIntoConfig.ts.snap +159 -3
  3. package/__tests__/config/utils/configToImportMeta.ts +0 -4
  4. package/__tests__/config/utils/mergeEnvIntoConfig.ts +20 -2
  5. package/__tests__/config/utils/rewriteLegancyEnv.ts +1 -1
  6. package/__tests__/interceptors/findPlugins.ts +366 -240
  7. package/__tests__/interceptors/generateInterceptors.ts +138 -59
  8. package/__tests__/interceptors/parseStructure.ts +132 -2
  9. package/__tests__/utils/resolveDependenciesSync.ts +39 -33
  10. package/dist/config/commands/exportConfig.js +1 -2
  11. package/dist/config/commands/generateConfig.js +1 -2
  12. package/dist/config/demoConfig.js +5 -0
  13. package/dist/config/loadConfig.js +1 -2
  14. package/dist/config/utils/configToImportMeta.js +1 -2
  15. package/dist/config/utils/diff.js +1 -1
  16. package/dist/config/utils/exportConfigToEnv.js +1 -2
  17. package/dist/config/utils/mergeEnvIntoConfig.js +12 -5
  18. package/dist/config/utils/replaceConfigInString.js +1 -2
  19. package/dist/config/utils/rewriteLegacyEnv.js +1 -2
  20. package/dist/generated/config.js +37 -16
  21. package/dist/interceptors/Visitor.js +1 -2
  22. package/dist/interceptors/commands/codegenInterceptors.js +1 -2
  23. package/dist/interceptors/extractExports.js +23 -20
  24. package/dist/interceptors/findOriginalSource.js +19 -4
  25. package/dist/interceptors/findPlugins.js +1 -2
  26. package/dist/interceptors/generateInterceptor.js +11 -12
  27. package/dist/interceptors/generateInterceptors.js +1 -2
  28. package/dist/interceptors/parseStructure.js +20 -7
  29. package/dist/interceptors/swc.js +2 -3
  30. package/dist/interceptors/writeInterceptors.js +8 -9
  31. package/dist/utils/isMonorepo.js +1 -2
  32. package/dist/utils/resolveDependenciesSync.js +3 -4
  33. package/dist/withGraphCommerce.js +22 -15
  34. package/package.json +10 -11
  35. package/src/config/demoConfig.ts +5 -0
  36. package/src/config/utils/mergeEnvIntoConfig.ts +9 -1
  37. package/src/generated/config.ts +111 -22
  38. package/src/interceptors/Visitor.ts +1 -2
  39. package/src/interceptors/extractExports.ts +21 -21
  40. package/src/interceptors/findOriginalSource.ts +17 -2
  41. package/src/interceptors/generateInterceptor.ts +4 -6
  42. package/src/interceptors/parseStructure.ts +25 -5
  43. package/src/interceptors/writeInterceptors.ts +7 -7
  44. package/src/utils/resolveDependenciesSync.ts +1 -1
  45. package/src/withGraphCommerce.ts +21 -13
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.printSync = exports.parseSync = void 0;
3
+ exports.parseSync = parseSync;
4
+ exports.printSync = printSync;
4
5
  const core_1 = require("@swc/core");
5
6
  function parseSync(src) {
6
7
  return (0, core_1.parseSync)(src, {
@@ -9,8 +10,6 @@ function parseSync(src) {
9
10
  comments: true,
10
11
  });
11
12
  }
12
- exports.parseSync = parseSync;
13
13
  function printSync(m) {
14
14
  return (0, core_1.printSync)(m);
15
15
  }
16
- exports.printSync = printSync;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.writeInterceptors = void 0;
6
+ exports.writeInterceptors = writeInterceptors;
7
7
  const promises_1 = __importDefault(require("node:fs/promises"));
8
8
  const path_1 = __importDefault(require("path"));
9
9
  // eslint-disable-next-line import/no-extraneous-dependencies
@@ -17,19 +17,19 @@ function checkFileExists(file) {
17
17
  }
18
18
  async function writeInterceptors(interceptors, cwd = process.cwd()) {
19
19
  const dependencies = (0, resolveDependenciesSync_1.resolveDependenciesSync)(cwd);
20
- const existing = [];
20
+ const existing = new Set();
21
21
  dependencies.forEach((dependency) => {
22
22
  const files = (0, glob_1.sync)([`${dependency}/**/*.interceptor.tsx`, `${dependency}/**/*.interceptor.ts`], { cwd });
23
- existing.push(...files);
23
+ files.forEach((file) => existing.add(file));
24
24
  });
25
25
  const written = Object.entries(interceptors).map(async ([, plugin]) => {
26
26
  const extension = plugin.sourcePath.endsWith('.tsx') ? '.tsx' : '.ts';
27
27
  const relativeFile = `${plugin.fromRoot}.interceptor${extension}`;
28
- if (existing.includes(relativeFile)) {
29
- delete existing[existing.indexOf(relativeFile)];
28
+ if (existing.has(relativeFile)) {
29
+ existing.delete(relativeFile);
30
30
  }
31
- if (existing.includes(`./${relativeFile}`)) {
32
- delete existing[existing.indexOf(`./${relativeFile}`)];
31
+ if (existing.has(`./${relativeFile}`)) {
32
+ existing.delete(`./${relativeFile}`);
33
33
  }
34
34
  const fileToWrite = path_1.default.join(cwd, relativeFile);
35
35
  const isSame = (await checkFileExists(fileToWrite)) &&
@@ -38,8 +38,7 @@ async function writeInterceptors(interceptors, cwd = process.cwd()) {
38
38
  await promises_1.default.writeFile(fileToWrite, plugin.template);
39
39
  });
40
40
  // Cleanup unused interceptors
41
- const cleaned = existing.map(async (file) => (await checkFileExists(file)) && (await promises_1.default.unlink(file)));
41
+ const cleaned = [...existing].map(async (file) => (await checkFileExists(file)) && (await promises_1.default.unlink(file)));
42
42
  await Promise.all(written);
43
43
  await Promise.all(cleaned);
44
44
  }
45
- exports.writeInterceptors = writeInterceptors;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isMonorepo = void 0;
6
+ exports.isMonorepo = isMonorepo;
7
7
  const node_path_1 = __importDefault(require("node:path"));
8
8
  function isMonorepo() {
9
9
  const root = process.cwd();
@@ -11,4 +11,3 @@ function isMonorepo() {
11
11
  const relativePath = node_path_1.default.join(node_path_1.default.relative(meshDir, root), '/');
12
12
  return relativePath.startsWith(`..${node_path_1.default.sep}..${node_path_1.default.sep}examples`);
13
13
  }
14
- exports.isMonorepo = isMonorepo;
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.resolveDependenciesSync = exports.sortDependencies = void 0;
6
+ exports.sortDependencies = sortDependencies;
7
+ exports.resolveDependenciesSync = resolveDependenciesSync;
7
8
  const node_fs_1 = __importDefault(require("node:fs"));
8
9
  const node_path_1 = __importDefault(require("node:path"));
9
10
  const PackagesSort_1 = require("./PackagesSort");
@@ -25,7 +26,7 @@ function resolveRecursivePackageJson(dependencyPath, dependencyStructure, root,
25
26
  ...Object.keys(packageJson.dependencies ?? []),
26
27
  ...Object.keys(packageJson.devDependencies ?? []),
27
28
  ...additionalDependencies,
28
- // ...Object.keys(packageJson.peerDependencies ?? {}),
29
+ ...Object.keys(packageJson.peerDependencies ?? {}),
29
30
  ].filter((name) => name.includes('graphcommerce'))),
30
31
  ];
31
32
  const name = isRoot ? '.' : packageJson.name;
@@ -50,7 +51,6 @@ function sortDependencies(dependencyStructure) {
50
51
  const sortedKeys = [...sorter.sort().keys()];
51
52
  return new Map(sortedKeys.map((key) => [key, dependencyStructure[key].dirName]));
52
53
  }
53
- exports.sortDependencies = sortDependencies;
54
54
  /**
55
55
  * This will return a list of all dependencies that have `graphcommerce` in the name, matching:
56
56
  *
@@ -69,4 +69,3 @@ function resolveDependenciesSync(root = process.cwd()) {
69
69
  resolveCache.set(root, sorted);
70
70
  return sorted;
71
71
  }
72
- exports.resolveDependenciesSync = resolveDependenciesSync;
@@ -1,10 +1,7 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.withGraphCommerce = void 0;
7
- const circular_dependency_plugin_1 = __importDefault(require("circular-dependency-plugin"));
3
+ exports.withGraphCommerce = withGraphCommerce;
4
+ // import CircularDependencyPlugin from 'circular-dependency-plugin'
8
5
  const plugin_1 = require("inspectpack/plugin");
9
6
  const webpack_1 = require("webpack");
10
7
  const loadConfig_1 = require("./config/loadConfig");
@@ -94,8 +91,19 @@ function withGraphCommerce(nextConfig, cwd) {
94
91
  },
95
92
  transpilePackages,
96
93
  webpack: (config, options) => {
97
- // Allow importing yml/yaml files for graphql-mesh
98
- config.module?.rules?.push({ test: /\.ya?ml$/, use: 'js-yaml-loader' });
94
+ if (!config.module)
95
+ config.module = { rules: [] };
96
+ config.module = {
97
+ ...config.module,
98
+ rules: [
99
+ ...(config.module.rules ?? []),
100
+ // Allow importing yml/yaml files for graphql-mesh
101
+ { test: /\.ya?ml$/, use: 'js-yaml-loader' },
102
+ // @lingui .po file support
103
+ { test: /\.po/, use: '@lingui/loader' },
104
+ ],
105
+ exprContextCritical: false,
106
+ };
99
107
  if (!config.plugins)
100
108
  config.plugins = [];
101
109
  // Make import.meta.graphCommerce available for usage.
@@ -103,11 +111,13 @@ function withGraphCommerce(nextConfig, cwd) {
103
111
  // To properly properly treeshake @apollo/client we need to define the __DEV__ property
104
112
  config.plugins.push(new webpack_1.DefinePlugin({ 'globalThis.__DEV__': options.dev }));
105
113
  if (!options.isServer) {
106
- if (graphcommerceConfig.debug?.webpackCircularDependencyPlugin) {
107
- config.plugins.push(new circular_dependency_plugin_1.default({
108
- exclude: /readable-stream|duplexer2|node_modules\/next/,
109
- }));
110
- }
114
+ // if (graphcommerceConfig.debug?.webpackCircularDependencyPlugin) {
115
+ // config.plugins.push(
116
+ // new CircularDependencyPlugin({
117
+ // exclude: /readable-stream|duplexer2|node_modules\/next/,
118
+ // }),
119
+ // )
120
+ // }
111
121
  if (graphcommerceConfig.debug?.webpackDuplicatesPlugin) {
112
122
  config.plugins.push(new plugin_1.DuplicatesPlugin({
113
123
  ignoredPackages: [
@@ -122,8 +132,6 @@ function withGraphCommerce(nextConfig, cwd) {
122
132
  }));
123
133
  }
124
134
  }
125
- // @lingui .po file support
126
- config.module?.rules?.push({ test: /\.po/, use: '@lingui/loader' });
127
135
  config.snapshot = {
128
136
  ...(config.snapshot ?? {}),
129
137
  managedPaths: [
@@ -151,4 +159,3 @@ function withGraphCommerce(nextConfig, cwd) {
151
159
  },
152
160
  };
153
161
  }
154
- exports.withGraphCommerce = withGraphCommerce;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@graphcommerce/next-config",
3
3
  "homepage": "https://www.graphcommerce.org/",
4
4
  "repository": "github:graphcommerce-org/graphcommerce",
5
- "version": "8.1.0-canary.9",
5
+ "version": "9.0.0-canary.101",
6
6
  "type": "commonjs",
7
7
  "main": "dist/index.js",
8
8
  "types": "src/index.ts",
@@ -13,28 +13,27 @@
13
13
  },
14
14
  "dependencies": {
15
15
  "@graphql-mesh/cli": "latest",
16
- "@lingui/loader": "4.7.0",
17
- "@lingui/swc-plugin": "4.0.4",
18
- "@swc/core": "1.3.104",
19
- "@swc/wasm-web": "^1.4.8",
16
+ "@lingui/loader": "4.11.4",
17
+ "@lingui/swc-plugin": "4.0.8",
18
+ "@swc/core": "1.7.26",
19
+ "@swc/wasm-web": "^1.7.28",
20
20
  "circular-dependency-plugin": "^5.2.2",
21
- "glob": "^10.3.10",
21
+ "glob": "^10.4.5",
22
22
  "inspectpack": "^4.7.1",
23
23
  "js-yaml-loader": "^1.2.2",
24
24
  "lodash": "^4.17.21",
25
- "woodpile": "^0.0.5",
26
25
  "znv": "^0.4.0",
27
- "zod": "^3.22.4"
26
+ "zod": "^3.23.8"
28
27
  },
29
28
  "devDependencies": {
30
29
  "@types/circular-dependency-plugin": "^5.0.8",
31
- "@types/lodash": "^4.14.202",
32
- "typescript": "5.3.3"
30
+ "@types/lodash": "^4.17.10",
31
+ "typescript": "5.6.2"
33
32
  },
34
33
  "peerDependencies": {
35
34
  "@lingui/macro": "^4.2.1",
36
35
  "graphql": "^16",
37
36
  "next": "*",
38
- "webpack": "^5.0.0"
37
+ "webpack": "~5.92.1"
39
38
  }
40
39
  }
@@ -7,6 +7,7 @@ export const demoConfig: PartialDeep<GraphCommerceConfig, { recurseIntoArrays: t
7
7
  canonicalBaseUrl: 'https://graphcommerce.vercel.app',
8
8
  hygraphEndpoint: 'https://eu-central-1.cdn.hygraph.com/content/ckhx7xadya6xs01yxdujt8i80/master',
9
9
  magentoEndpoint: 'https://backend.reachdigital.dev/graphql',
10
+ magentoVersion: 246,
10
11
  storefront: [
11
12
  { locale: 'en', magentoStoreCode: 'en_US', defaultLocale: true },
12
13
  {
@@ -37,6 +38,7 @@ export const demoConfig: PartialDeep<GraphCommerceConfig, { recurseIntoArrays: t
37
38
  ],
38
39
  productFiltersPro: true,
39
40
  productFiltersLayout: 'DEFAULT',
41
+ productListPaginationVariant: 'COMPACT',
40
42
  compareVariant: 'ICON',
41
43
  robotsAllow: false,
42
44
 
@@ -47,4 +49,7 @@ export const demoConfig: PartialDeep<GraphCommerceConfig, { recurseIntoArrays: t
47
49
  configurableVariantForSimple: true,
48
50
  configurableVariantValues: { url: true, content: true, gallery: true },
49
51
  recentlyViewedProducts: { enabled: true, maxCount: 20 },
52
+ breadcrumbs: false,
53
+ customerDeleteEnabled: true,
54
+ previewSecret: 'SECRET',
50
55
  }
@@ -17,6 +17,7 @@ import {
17
17
  ZodEnum,
18
18
  ZodTypeAny,
19
19
  ZodAny,
20
+ ZodDefault,
20
21
  } from 'zod'
21
22
  import diff from './diff'
22
23
 
@@ -61,6 +62,7 @@ export function configToEnvSchema(schema: ZodNode) {
61
62
  if (node instanceof ZodEffects) node = node.innerType()
62
63
  if (node instanceof ZodOptional) node = node.unwrap()
63
64
  if (node instanceof ZodNullable) node = node.unwrap()
65
+ if (node instanceof ZodDefault) node = node.removeDefault()
64
66
 
65
67
  if (node instanceof ZodObject) {
66
68
  if (path.length > 0) {
@@ -99,7 +101,13 @@ export function configToEnvSchema(schema: ZodNode) {
99
101
  return
100
102
  }
101
103
 
102
- if (node instanceof ZodString || node instanceof ZodNumber || node instanceof ZodEnum) {
104
+ if (node instanceof ZodNumber) {
105
+ envSchema[toEnvStr(path)] = z.coerce.number().optional()
106
+ envToDot[toEnvStr(path)] = dotNotation(path)
107
+ return
108
+ }
109
+
110
+ if (node instanceof ZodString || node instanceof ZodEnum) {
103
111
  envSchema[toEnvStr(path)] = node.optional()
104
112
  envToDot[toEnvStr(path)] = dotNotation(path)
105
113
  return
@@ -16,10 +16,20 @@ export type Scalars = {
16
16
  Float: { input: number; output: number; }
17
17
  };
18
18
 
19
+ export type CartPermissions =
20
+ | 'CUSTOMER_ONLY'
21
+ | 'DISABLED'
22
+ | 'ENABLED';
23
+
19
24
  export type CompareVariant =
20
25
  | 'CHECKBOX'
21
26
  | 'ICON';
22
27
 
28
+ export type CustomerAccountPermissions =
29
+ | 'DISABLED'
30
+ | 'DISABLE_REGISTRATION'
31
+ | 'ENABLED';
32
+
23
33
  /** GoogleDatalayerConfig to allow enabling certain aspects of the datalayer */
24
34
  export type DatalayerConfig = {
25
35
  /** Enable core web vitals tracking for GraphCommerce */
@@ -104,6 +114,8 @@ export type DatalayerConfig = {
104
114
  * Below is a list of all possible configurations that can be set by GraphCommerce.
105
115
  */
106
116
  export type GraphCommerceConfig = {
117
+ /** Configuration for the SidebarGallery component */
118
+ breadcrumbs?: InputMaybe<Scalars['Boolean']['input']>;
107
119
  /**
108
120
  * The canonical base URL is used for SEO purposes.
109
121
  *
@@ -157,14 +169,23 @@ export type GraphCommerceConfig = {
157
169
  * Default: 'false'
158
170
  */
159
171
  crossSellsRedirectItems?: InputMaybe<Scalars['Boolean']['input']>;
172
+ /** Enables the shipping notes field in the checkout */
173
+ customerAddressNoteEnable?: InputMaybe<Scalars['Boolean']['input']>;
174
+ /**
175
+ * Enables company fields inside the checkout:
176
+ * - Company name
177
+ * - VAT ID
178
+ */
179
+ customerCompanyFieldsEnable?: InputMaybe<Scalars['Boolean']['input']>;
180
+ /** Enable customer account deletion through the account section */
181
+ customerDeleteEnabled?: InputMaybe<Scalars['Boolean']['input']>;
160
182
  /**
161
- * Due to a limitation in the GraphQL API of Magento 2, we need to know if the
162
- * customer requires email confirmation.
183
+ * X-Magento-Cache-Id allows Varnish to cache requests that are made in the browser while users are logged in. For example the products query can now be cached for logged in users.
163
184
  *
164
- * This value should match Magento 2's configuration value for
165
- * `customer/create_account/confirm` and should be removed once we can query
185
+ * This can be disabled when Varnish is running out of available memory.
166
186
  */
167
- customerRequireEmailConfirmation?: InputMaybe<Scalars['Boolean']['input']>;
187
+ customerXMagentoCacheIdDisable?: InputMaybe<Scalars['Boolean']['input']>;
188
+ /** Datalayer config */
168
189
  dataLayer?: InputMaybe<DatalayerConfig>;
169
190
  /** Debug configuration for GraphCommerce */
170
191
  debug?: InputMaybe<GraphCommerceDebugConfig>;
@@ -218,18 +239,20 @@ export type GraphCommerceConfig = {
218
239
  * Project settings -> API Access -> High Performance Read-only Content API
219
240
  */
220
241
  hygraphEndpoint: Scalars['String']['input'];
221
- /** Hygraph Management API. **Only used for migrations.** */
222
- hygraphManagementApi?: InputMaybe<Scalars['String']['input']>;
223
- /** Hygraph Project ID. **Only used for migrations.** */
224
- hygraphProjectId?: InputMaybe<Scalars['String']['input']>;
225
242
  /**
226
- * Content API. **Only used for migrations.**
243
+ * Hygraph Management API. **Only used for migrations.**
227
244
  *
228
- * > Regular read & write endpoint that allows querying and mutating data in your project.
245
+ * Optional: If the hygraphEndpoint is configured with the 'High Performance Content
246
+ * API', this field is not required.
247
+ */
248
+ hygraphManagementApi?: InputMaybe<Scalars['String']['input']>;
249
+ /**
250
+ * Hygraph Project ID. **Only used for migrations.**
229
251
  *
230
- * Project settings -> API Access -> Content API
252
+ * Optional: If the hygraphEndpoint is configured with the 'High Performance Content
253
+ * API', this field is not required.
231
254
  */
232
- hygraphWriteAccessEndpoint?: InputMaybe<Scalars['String']['input']>;
255
+ hygraphProjectId?: InputMaybe<Scalars['String']['input']>;
233
256
  /**
234
257
  * Hygraph Management SDK Authorization Token. **Only used for migrations.**
235
258
  *
@@ -256,7 +279,6 @@ export type GraphCommerceConfig = {
256
279
  * - Can see schema view
257
280
  *
258
281
  * ```
259
- * GC_HYGRAPH_WRITE_ACCESS_ENDPOINT="https://...hygraph.com/v2/..."
260
282
  * GC_HYGRAPH_WRITE_ACCESS_TOKEN="AccessTokenFromHygraph"
261
283
  * yarn graphcommerce hygraph-migrate
262
284
  * ```
@@ -275,6 +297,14 @@ export type GraphCommerceConfig = {
275
297
  * - https://magento2.test/graphql
276
298
  */
277
299
  magentoEndpoint: Scalars['String']['input'];
300
+ /**
301
+ * Version of the Magento backend.
302
+ *
303
+ * Values: 245, 246, 247 for Magento 2.4.5, 2.4.6, 2.4.7 respectively.
304
+ */
305
+ magentoVersion: Scalars['Int']['input'];
306
+ /** Allows the option to require login or completely disable certain sections of the site, can be overriden per storeview with the storefrontConfig */
307
+ permissions?: InputMaybe<GraphCommercePermissions>;
278
308
  /** To enable next.js' preview mode, configure the secret you'd like to use. */
279
309
  previewSecret?: InputMaybe<Scalars['String']['input']>;
280
310
  /**
@@ -285,6 +315,13 @@ export type GraphCommerceConfig = {
285
315
  productFiltersLayout?: InputMaybe<ProductFiltersLayout>;
286
316
  /** Product filters with better UI for mobile and desktop. */
287
317
  productFiltersPro?: InputMaybe<Scalars['Boolean']['input']>;
318
+ /**
319
+ * Pagination variant for the product listings.
320
+ *
321
+ * COMPACT means: "< Page X of Y >"
322
+ * EXTENDED means: "< 1 2 ... 4 [5] 6 ... 10 11 >"
323
+ */
324
+ productListPaginationVariant?: InputMaybe<PaginationVariant>;
288
325
  /**
289
326
  * By default we route products to /p/[url] but you can change this to /product/[url] if you wish.
290
327
  *
@@ -332,6 +369,18 @@ export type GraphCommerceDebugConfig = {
332
369
  webpackDuplicatesPlugin?: InputMaybe<Scalars['Boolean']['input']>;
333
370
  };
334
371
 
372
+ /** Permissions input */
373
+ export type GraphCommercePermissions = {
374
+ /** Changes the availability of the add to cart buttons and the cart page to either customer only or completely disables it. */
375
+ cart?: InputMaybe<CartPermissions>;
376
+ /** Changes the availability of the checkout to either customer only or completely disables it. */
377
+ checkout?: InputMaybe<CartPermissions>;
378
+ /** Enables / disabled the account section of the website. DISABLE_REGISTRATION will only disable the registration page. */
379
+ customerAccount?: InputMaybe<CustomerAccountPermissions>;
380
+ /** Allows the option to require login or completely disable the site. */
381
+ website?: InputMaybe<WebsitePermissions>;
382
+ };
383
+
335
384
  /** All storefront configuration for the project */
336
385
  export type GraphCommerceStorefrontConfig = {
337
386
  /**
@@ -345,6 +394,12 @@ export type GraphCommerceStorefrontConfig = {
345
394
  canonicalBaseUrl?: InputMaybe<Scalars['String']['input']>;
346
395
  /** Due to a limitation of the GraphQL API it is not possible to determine if a cart should be displayed including or excluding tax. */
347
396
  cartDisplayPricesInclTax?: InputMaybe<Scalars['Boolean']['input']>;
397
+ /**
398
+ * Enables company fields inside the checkout:
399
+ * - Company name
400
+ * - VAT ID
401
+ */
402
+ customerCompanyFieldsEnable?: InputMaybe<Scalars['Boolean']['input']>;
348
403
  /**
349
404
  * There can only be one entry with defaultLocale set to true.
350
405
  * - If there are more, the first one is used.
@@ -384,6 +439,8 @@ export type GraphCommerceStorefrontConfig = {
384
439
  * - b2b-us
385
440
  */
386
441
  magentoStoreCode: Scalars['String']['input'];
442
+ /** Allows the option to require login or completely disable certain sections of the site on a per store basis */
443
+ permissions?: InputMaybe<GraphCommercePermissions>;
387
444
  /**
388
445
  * Allow the site to be indexed by search engines.
389
446
  * If false, the robots.txt file will be set to disallow all.
@@ -408,6 +465,10 @@ export type MagentoConfigurableVariantValues = {
408
465
  url?: InputMaybe<Scalars['Boolean']['input']>;
409
466
  };
410
467
 
468
+ export type PaginationVariant =
469
+ | 'COMPACT'
470
+ | 'EXTENDED';
471
+
411
472
  export type ProductFiltersLayout =
412
473
  | 'DEFAULT'
413
474
  | 'SIDEBAR';
@@ -431,6 +492,9 @@ export type SidebarGalleryPaginationVariant =
431
492
  | 'DOTS'
432
493
  | 'THUMBNAILS_BOTTOM';
433
494
 
495
+ export type WebsitePermissions =
496
+ | 'ENABLED';
497
+
434
498
 
435
499
  type Properties<T> = Required<{
436
500
  [K in keyof T]: z.ZodType<T[K], any, T[K]>;
@@ -442,12 +506,20 @@ export const isDefinedNonNullAny = (v: any): v is definedNonNullAny => v !== und
442
506
 
443
507
  export const definedNonNullAnySchema = z.any().refine((v) => isDefinedNonNullAny(v));
444
508
 
509
+ export const CartPermissionsSchema = z.enum(['CUSTOMER_ONLY', 'DISABLED', 'ENABLED']);
510
+
445
511
  export const CompareVariantSchema = z.enum(['CHECKBOX', 'ICON']);
446
512
 
513
+ export const CustomerAccountPermissionsSchema = z.enum(['DISABLED', 'DISABLE_REGISTRATION', 'ENABLED']);
514
+
515
+ export const PaginationVariantSchema = z.enum(['COMPACT', 'EXTENDED']);
516
+
447
517
  export const ProductFiltersLayoutSchema = z.enum(['DEFAULT', 'SIDEBAR']);
448
518
 
449
519
  export const SidebarGalleryPaginationVariantSchema = z.enum(['DOTS', 'THUMBNAILS_BOTTOM']);
450
520
 
521
+ export const WebsitePermissionsSchema = z.enum(['ENABLED']);
522
+
451
523
  export function DatalayerConfigSchema(): z.ZodObject<Properties<DatalayerConfig>> {
452
524
  return z.object({
453
525
  coreWebVitals: z.boolean().nullish()
@@ -456,18 +528,22 @@ export function DatalayerConfigSchema(): z.ZodObject<Properties<DatalayerConfig>
456
528
 
457
529
  export function GraphCommerceConfigSchema(): z.ZodObject<Properties<GraphCommerceConfig>> {
458
530
  return z.object({
531
+ breadcrumbs: z.boolean().default(false).nullish(),
459
532
  canonicalBaseUrl: z.string().min(1),
460
533
  cartDisplayPricesInclTax: z.boolean().nullish(),
461
534
  compare: z.boolean().nullish(),
462
- compareVariant: CompareVariantSchema.nullish(),
463
- configurableVariantForSimple: z.boolean().nullish(),
535
+ compareVariant: CompareVariantSchema.default("ICON").nullish(),
536
+ configurableVariantForSimple: z.boolean().default(false).nullish(),
464
537
  configurableVariantValues: MagentoConfigurableVariantValuesSchema().nullish(),
465
- crossSellsHideCartItems: z.boolean().nullish(),
466
- crossSellsRedirectItems: z.boolean().nullish(),
467
- customerRequireEmailConfirmation: z.boolean().nullish(),
538
+ crossSellsHideCartItems: z.boolean().default(false).nullish(),
539
+ crossSellsRedirectItems: z.boolean().default(false).nullish(),
540
+ customerAddressNoteEnable: z.boolean().nullish(),
541
+ customerCompanyFieldsEnable: z.boolean().nullish(),
542
+ customerDeleteEnabled: z.boolean().nullish(),
543
+ customerXMagentoCacheIdDisable: z.boolean().nullish(),
468
544
  dataLayer: DatalayerConfigSchema().nullish(),
469
545
  debug: GraphCommerceDebugConfigSchema().nullish(),
470
- demoMode: z.boolean().nullish(),
546
+ demoMode: z.boolean().default(true).nullish(),
471
547
  enableGuestCheckoutLogin: z.boolean().nullish(),
472
548
  googleAnalyticsId: z.string().nullish(),
473
549
  googleRecaptchaKey: z.string().nullish(),
@@ -475,13 +551,15 @@ export function GraphCommerceConfigSchema(): z.ZodObject<Properties<GraphCommerc
475
551
  hygraphEndpoint: z.string().min(1),
476
552
  hygraphManagementApi: z.string().nullish(),
477
553
  hygraphProjectId: z.string().nullish(),
478
- hygraphWriteAccessEndpoint: z.string().nullish(),
479
554
  hygraphWriteAccessToken: z.string().nullish(),
480
555
  limitSsg: z.boolean().nullish(),
481
556
  magentoEndpoint: z.string().min(1),
557
+ magentoVersion: z.number(),
558
+ permissions: GraphCommercePermissionsSchema().nullish(),
482
559
  previewSecret: z.string().nullish(),
483
- productFiltersLayout: ProductFiltersLayoutSchema.nullish(),
560
+ productFiltersLayout: ProductFiltersLayoutSchema.default("DEFAULT").nullish(),
484
561
  productFiltersPro: z.boolean().nullish(),
562
+ productListPaginationVariant: PaginationVariantSchema.default("COMPACT").nullish(),
485
563
  productRoute: z.string().nullish(),
486
564
  recentlyViewedProducts: RecentlyViewedProductsConfigSchema().nullish(),
487
565
  robotsAllow: z.boolean().nullish(),
@@ -501,10 +579,20 @@ export function GraphCommerceDebugConfigSchema(): z.ZodObject<Properties<GraphCo
501
579
  })
502
580
  }
503
581
 
582
+ export function GraphCommercePermissionsSchema(): z.ZodObject<Properties<GraphCommercePermissions>> {
583
+ return z.object({
584
+ cart: CartPermissionsSchema.nullish(),
585
+ checkout: CartPermissionsSchema.nullish(),
586
+ customerAccount: CustomerAccountPermissionsSchema.nullish(),
587
+ website: WebsitePermissionsSchema.nullish()
588
+ })
589
+ }
590
+
504
591
  export function GraphCommerceStorefrontConfigSchema(): z.ZodObject<Properties<GraphCommerceStorefrontConfig>> {
505
592
  return z.object({
506
593
  canonicalBaseUrl: z.string().nullish(),
507
594
  cartDisplayPricesInclTax: z.boolean().nullish(),
595
+ customerCompanyFieldsEnable: z.boolean().nullish(),
508
596
  defaultLocale: z.boolean().nullish(),
509
597
  domain: z.string().nullish(),
510
598
  googleAnalyticsId: z.string().nullish(),
@@ -514,6 +602,7 @@ export function GraphCommerceStorefrontConfigSchema(): z.ZodObject<Properties<Gr
514
602
  linguiLocale: z.string().nullish(),
515
603
  locale: z.string().min(1),
516
604
  magentoStoreCode: z.string().min(1),
605
+ permissions: GraphCommercePermissionsSchema().nullish(),
517
606
  robotsAllow: z.boolean().nullish()
518
607
  })
519
608
  }
@@ -782,7 +782,6 @@ export class Visitor {
782
782
  }
783
783
 
784
784
  visitTsPropertySignature(n: TsPropertySignature): TsPropertySignature {
785
- n.params = this.visitTsFnParameters(n.params)
786
785
  n.typeAnnotation = this.visitTsTypeAnnotation(n.typeAnnotation)
787
786
  return n
788
787
  }
@@ -873,7 +872,7 @@ export class Visitor {
873
872
  }
874
873
 
875
874
  visitTsFnParameters(params: TsFnParameter[]): TsFnParameter[] {
876
- return params.map(this.visitTsFnParameter.bind(this))
875
+ return params?.map(this.visitTsFnParameter.bind(this))
877
876
  }
878
877
 
879
878
  visitTsFnParameter(n: TsFnParameter): TsFnParameter {
@@ -112,8 +112,8 @@ function extractValue(node: Node, path?: string[], optional: boolean = false): a
112
112
  case 'undefined':
113
113
  return undefined
114
114
  default:
115
- if (optional) return RUNTIME_VALUE
116
- throw new UnsupportedValueError(`Unknown identifier "${node.value}"`, path)
115
+ return RUNTIME_VALUE
116
+ // throw new UnsupportedValueError(`Unknown identifier "${node.value}"`, path)
117
117
  }
118
118
  } else if (isArrayExpression(node)) {
119
119
  // e.g. [1, 2, 3]
@@ -123,11 +123,11 @@ function extractValue(node: Node, path?: string[], optional: boolean = false): a
123
123
  if (elem) {
124
124
  if (elem.spread) {
125
125
  // e.g. [ ...a ]
126
- if (optional) return RUNTIME_VALUE
127
- throw new UnsupportedValueError(
128
- 'Unsupported spread operator in the Array Expression',
129
- path,
130
- )
126
+ return RUNTIME_VALUE
127
+ // throw new UnsupportedValueError(
128
+ // 'Unsupported spread operator in the Array Expression',
129
+ // path,
130
+ // )
131
131
  }
132
132
 
133
133
  arr.push(extractValue(elem.expression, path && [...path, `[${i}]`], optional))
@@ -144,11 +144,11 @@ function extractValue(node: Node, path?: string[], optional: boolean = false): a
144
144
  for (const prop of node.properties) {
145
145
  if (!isKeyValueProperty(prop)) {
146
146
  // e.g. { ...a }
147
- if (optional) return RUNTIME_VALUE
148
- throw new UnsupportedValueError(
149
- 'Unsupported spread operator in the Object Expression',
150
- path,
151
- )
147
+ return RUNTIME_VALUE
148
+ // throw new UnsupportedValueError(
149
+ // 'Unsupported spread operator in the Object Expression',
150
+ // path,
151
+ // )
152
152
  }
153
153
 
154
154
  let key
@@ -159,11 +159,11 @@ function extractValue(node: Node, path?: string[], optional: boolean = false): a
159
159
  // e.g. { "a": 1, "b": 2 }
160
160
  key = prop.key.value
161
161
  } else {
162
- if (optional) return RUNTIME_VALUE
163
- throw new UnsupportedValueError(
164
- `Unsupported key type "${prop.key.type}" in the Object Expression`,
165
- path,
166
- )
162
+ return RUNTIME_VALUE
163
+ // throw new UnsupportedValueError(
164
+ // `Unsupported key type "${prop.key.type}" in the Object Expression`,
165
+ // path,
166
+ // )
167
167
  }
168
168
 
169
169
  obj[key] = extractValue(prop.value, path && [...path, key])
@@ -174,8 +174,8 @@ function extractValue(node: Node, path?: string[], optional: boolean = false): a
174
174
  // e.g. `abc`
175
175
  if (node.expressions.length !== 0) {
176
176
  // TODO: should we add support for `${'e'}d${'g'}'e'`?
177
- if (optional) return RUNTIME_VALUE
178
- throw new UnsupportedValueError('Unsupported template literal with expressions', path)
177
+ return RUNTIME_VALUE
178
+ // throw new UnsupportedValueError('Unsupported template literal with expressions', path)
179
179
  }
180
180
 
181
181
  // When TemplateLiteral has 0 expressions, the length of quasis is always 1.
@@ -191,8 +191,8 @@ function extractValue(node: Node, path?: string[], optional: boolean = false): a
191
191
 
192
192
  return cooked ?? raw
193
193
  } else {
194
- if (optional) return RUNTIME_VALUE
195
- throw new UnsupportedValueError(`Unsupported node type "${node.type}"`, path)
194
+ return RUNTIME_VALUE
195
+ // throw new UnsupportedValueError(`Unsupported node type "${node.type}"`, path)
196
196
  }
197
197
  }
198
198