@graphcommerce/next-config 8.1.0-canary.8 → 9.0.0-canary.100
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 +266 -65
- package/Config.graphqls +5 -5
- package/__tests__/config/utils/__snapshots__/mergeEnvIntoConfig.ts.snap +159 -3
- package/__tests__/config/utils/configToImportMeta.ts +0 -4
- package/__tests__/config/utils/mergeEnvIntoConfig.ts +20 -2
- package/__tests__/config/utils/rewriteLegancyEnv.ts +1 -1
- package/__tests__/interceptors/findPlugins.ts +366 -240
- package/__tests__/interceptors/generateInterceptors.ts +138 -59
- package/__tests__/interceptors/parseStructure.ts +132 -2
- package/__tests__/utils/resolveDependenciesSync.ts +39 -33
- package/dist/config/commands/exportConfig.js +1 -2
- package/dist/config/commands/generateConfig.js +1 -2
- package/dist/config/demoConfig.js +5 -0
- package/dist/config/loadConfig.js +1 -2
- package/dist/config/utils/configToImportMeta.js +1 -2
- package/dist/config/utils/diff.js +1 -1
- package/dist/config/utils/exportConfigToEnv.js +1 -2
- package/dist/config/utils/mergeEnvIntoConfig.js +12 -5
- package/dist/config/utils/replaceConfigInString.js +1 -2
- package/dist/config/utils/rewriteLegacyEnv.js +1 -2
- package/dist/generated/config.js +39 -17
- package/dist/interceptors/Visitor.js +1 -1
- package/dist/interceptors/commands/codegenInterceptors.js +1 -2
- package/dist/interceptors/extractExports.js +23 -20
- package/dist/interceptors/findOriginalSource.js +19 -4
- package/dist/interceptors/findPlugins.js +1 -2
- package/dist/interceptors/generateInterceptor.js +11 -12
- package/dist/interceptors/generateInterceptors.js +1 -2
- package/dist/interceptors/parseStructure.js +20 -7
- package/dist/interceptors/swc.js +2 -3
- package/dist/interceptors/writeInterceptors.js +8 -9
- package/dist/utils/isMonorepo.js +1 -2
- package/dist/utils/resolveDependenciesSync.js +3 -4
- package/dist/withGraphCommerce.js +22 -15
- package/package.json +10 -11
- package/src/config/demoConfig.ts +5 -0
- package/src/config/utils/mergeEnvIntoConfig.ts +9 -1
- package/src/generated/config.ts +116 -23
- package/src/interceptors/Visitor.ts +1 -1
- package/src/interceptors/extractExports.ts +21 -21
- package/src/interceptors/findOriginalSource.ts +17 -2
- package/src/interceptors/generateInterceptor.ts +4 -6
- package/src/interceptors/parseStructure.ts +25 -5
- package/src/interceptors/writeInterceptors.ts +7 -7
- package/src/utils/resolveDependenciesSync.ts +1 -1
- package/src/withGraphCommerce.ts +21 -13
package/dist/interceptors/swc.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
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 =
|
|
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.
|
|
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.
|
|
29
|
-
|
|
28
|
+
if (existing.has(relativeFile)) {
|
|
29
|
+
existing.delete(relativeFile);
|
|
30
30
|
}
|
|
31
|
-
if (existing.
|
|
32
|
-
|
|
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;
|
package/dist/utils/isMonorepo.js
CHANGED
|
@@ -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 =
|
|
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.
|
|
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
|
-
|
|
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 =
|
|
7
|
-
|
|
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
|
-
|
|
98
|
-
|
|
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
|
-
|
|
108
|
-
|
|
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": "
|
|
5
|
+
"version": "9.0.0-canary.100",
|
|
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.
|
|
17
|
-
"@lingui/swc-plugin": "4.0.
|
|
18
|
-
"@swc/core": "1.
|
|
19
|
-
"@swc/wasm-web": "^1.
|
|
16
|
+
"@lingui/loader": "4.11.2",
|
|
17
|
+
"@lingui/swc-plugin": "4.0.8",
|
|
18
|
+
"@swc/core": "1.6.13",
|
|
19
|
+
"@swc/wasm-web": "^1.6.7",
|
|
20
20
|
"circular-dependency-plugin": "^5.2.2",
|
|
21
|
-
"glob": "^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.
|
|
26
|
+
"zod": "^3.23.8"
|
|
28
27
|
},
|
|
29
28
|
"devDependencies": {
|
|
30
29
|
"@types/circular-dependency-plugin": "^5.0.8",
|
|
31
|
-
"@types/lodash": "^4.
|
|
32
|
-
"typescript": "5.
|
|
30
|
+
"@types/lodash": "^4.17.7",
|
|
31
|
+
"typescript": "5.5.3"
|
|
33
32
|
},
|
|
34
33
|
"peerDependencies": {
|
|
35
34
|
"@lingui/macro": "^4.2.1",
|
|
36
35
|
"graphql": "^16",
|
|
37
36
|
"next": "*",
|
|
38
|
-
"webpack": "
|
|
37
|
+
"webpack": "~5.92.1"
|
|
39
38
|
}
|
|
40
39
|
}
|
package/src/config/demoConfig.ts
CHANGED
|
@@ -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
|
|
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
|
package/src/generated/config.ts
CHANGED
|
@@ -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
|
-
*
|
|
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
|
|
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
|
-
|
|
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
|
-
*
|
|
243
|
+
* Hygraph Management API. **Only used for migrations.**
|
|
227
244
|
*
|
|
228
|
-
*
|
|
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
|
-
*
|
|
252
|
+
* Optional: If the hygraphEndpoint is configured with the 'High Performance Content
|
|
253
|
+
* API', this field is not required.
|
|
231
254
|
*/
|
|
232
|
-
|
|
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,16 @@ export type GraphCommerceDebugConfig = {
|
|
|
332
369
|
webpackDuplicatesPlugin?: InputMaybe<Scalars['Boolean']['input']>;
|
|
333
370
|
};
|
|
334
371
|
|
|
372
|
+
export type GraphCommercePermissions = {
|
|
373
|
+
/** Changes the availability of the add to cart buttons and the cart page to either customer only or completely disables it. */
|
|
374
|
+
cart?: InputMaybe<CartPermissions>;
|
|
375
|
+
/** Changes the availability of the checkout to either customer only or completely disables it. */
|
|
376
|
+
checkout?: InputMaybe<CartPermissions>;
|
|
377
|
+
/** Enables / disabled the account section of the website. DISABLE_REGISTRATION will only disable the registration page. */
|
|
378
|
+
customerAccount?: InputMaybe<CustomerAccountPermissions>;
|
|
379
|
+
website?: InputMaybe<WebsitePermissions>;
|
|
380
|
+
};
|
|
381
|
+
|
|
335
382
|
/** All storefront configuration for the project */
|
|
336
383
|
export type GraphCommerceStorefrontConfig = {
|
|
337
384
|
/**
|
|
@@ -345,6 +392,12 @@ export type GraphCommerceStorefrontConfig = {
|
|
|
345
392
|
canonicalBaseUrl?: InputMaybe<Scalars['String']['input']>;
|
|
346
393
|
/** 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
394
|
cartDisplayPricesInclTax?: InputMaybe<Scalars['Boolean']['input']>;
|
|
395
|
+
/**
|
|
396
|
+
* Enables company fields inside the checkout:
|
|
397
|
+
* - Company name
|
|
398
|
+
* - VAT ID
|
|
399
|
+
*/
|
|
400
|
+
customerCompanyFieldsEnable?: InputMaybe<Scalars['Boolean']['input']>;
|
|
348
401
|
/**
|
|
349
402
|
* There can only be one entry with defaultLocale set to true.
|
|
350
403
|
* - If there are more, the first one is used.
|
|
@@ -384,6 +437,13 @@ export type GraphCommerceStorefrontConfig = {
|
|
|
384
437
|
* - b2b-us
|
|
385
438
|
*/
|
|
386
439
|
magentoStoreCode: Scalars['String']['input'];
|
|
440
|
+
/** Allows the option to require login or completely disable certain sections of the site on a per store basis */
|
|
441
|
+
permissions?: InputMaybe<GraphCommercePermissions>;
|
|
442
|
+
/**
|
|
443
|
+
* Allow the site to be indexed by search engines.
|
|
444
|
+
* If false, the robots.txt file will be set to disallow all.
|
|
445
|
+
*/
|
|
446
|
+
robotsAllow?: InputMaybe<Scalars['Boolean']['input']>;
|
|
387
447
|
};
|
|
388
448
|
|
|
389
449
|
/** Options to configure which values will be replaced when a variant is selected on the product page. */
|
|
@@ -403,6 +463,10 @@ export type MagentoConfigurableVariantValues = {
|
|
|
403
463
|
url?: InputMaybe<Scalars['Boolean']['input']>;
|
|
404
464
|
};
|
|
405
465
|
|
|
466
|
+
export type PaginationVariant =
|
|
467
|
+
| 'COMPACT'
|
|
468
|
+
| 'EXTENDED';
|
|
469
|
+
|
|
406
470
|
export type ProductFiltersLayout =
|
|
407
471
|
| 'DEFAULT'
|
|
408
472
|
| 'SIDEBAR';
|
|
@@ -426,6 +490,9 @@ export type SidebarGalleryPaginationVariant =
|
|
|
426
490
|
| 'DOTS'
|
|
427
491
|
| 'THUMBNAILS_BOTTOM';
|
|
428
492
|
|
|
493
|
+
export type WebsitePermissions =
|
|
494
|
+
| 'ENABLED';
|
|
495
|
+
|
|
429
496
|
|
|
430
497
|
type Properties<T> = Required<{
|
|
431
498
|
[K in keyof T]: z.ZodType<T[K], any, T[K]>;
|
|
@@ -437,12 +504,20 @@ export const isDefinedNonNullAny = (v: any): v is definedNonNullAny => v !== und
|
|
|
437
504
|
|
|
438
505
|
export const definedNonNullAnySchema = z.any().refine((v) => isDefinedNonNullAny(v));
|
|
439
506
|
|
|
507
|
+
export const CartPermissionsSchema = z.enum(['CUSTOMER_ONLY', 'DISABLED', 'ENABLED']);
|
|
508
|
+
|
|
440
509
|
export const CompareVariantSchema = z.enum(['CHECKBOX', 'ICON']);
|
|
441
510
|
|
|
511
|
+
export const CustomerAccountPermissionsSchema = z.enum(['DISABLED', 'DISABLE_REGISTRATION', 'ENABLED']);
|
|
512
|
+
|
|
513
|
+
export const PaginationVariantSchema = z.enum(['COMPACT', 'EXTENDED']);
|
|
514
|
+
|
|
442
515
|
export const ProductFiltersLayoutSchema = z.enum(['DEFAULT', 'SIDEBAR']);
|
|
443
516
|
|
|
444
517
|
export const SidebarGalleryPaginationVariantSchema = z.enum(['DOTS', 'THUMBNAILS_BOTTOM']);
|
|
445
518
|
|
|
519
|
+
export const WebsitePermissionsSchema = z.enum(['ENABLED']);
|
|
520
|
+
|
|
446
521
|
export function DatalayerConfigSchema(): z.ZodObject<Properties<DatalayerConfig>> {
|
|
447
522
|
return z.object({
|
|
448
523
|
coreWebVitals: z.boolean().nullish()
|
|
@@ -451,18 +526,22 @@ export function DatalayerConfigSchema(): z.ZodObject<Properties<DatalayerConfig>
|
|
|
451
526
|
|
|
452
527
|
export function GraphCommerceConfigSchema(): z.ZodObject<Properties<GraphCommerceConfig>> {
|
|
453
528
|
return z.object({
|
|
529
|
+
breadcrumbs: z.boolean().default(false).nullish(),
|
|
454
530
|
canonicalBaseUrl: z.string().min(1),
|
|
455
531
|
cartDisplayPricesInclTax: z.boolean().nullish(),
|
|
456
532
|
compare: z.boolean().nullish(),
|
|
457
|
-
compareVariant: CompareVariantSchema.nullish(),
|
|
458
|
-
configurableVariantForSimple: z.boolean().nullish(),
|
|
533
|
+
compareVariant: CompareVariantSchema.default("ICON").nullish(),
|
|
534
|
+
configurableVariantForSimple: z.boolean().default(false).nullish(),
|
|
459
535
|
configurableVariantValues: MagentoConfigurableVariantValuesSchema().nullish(),
|
|
460
|
-
crossSellsHideCartItems: z.boolean().nullish(),
|
|
461
|
-
crossSellsRedirectItems: z.boolean().nullish(),
|
|
462
|
-
|
|
536
|
+
crossSellsHideCartItems: z.boolean().default(false).nullish(),
|
|
537
|
+
crossSellsRedirectItems: z.boolean().default(false).nullish(),
|
|
538
|
+
customerAddressNoteEnable: z.boolean().nullish(),
|
|
539
|
+
customerCompanyFieldsEnable: z.boolean().nullish(),
|
|
540
|
+
customerDeleteEnabled: z.boolean().nullish(),
|
|
541
|
+
customerXMagentoCacheIdDisable: z.boolean().nullish(),
|
|
463
542
|
dataLayer: DatalayerConfigSchema().nullish(),
|
|
464
543
|
debug: GraphCommerceDebugConfigSchema().nullish(),
|
|
465
|
-
demoMode: z.boolean().nullish(),
|
|
544
|
+
demoMode: z.boolean().default(true).nullish(),
|
|
466
545
|
enableGuestCheckoutLogin: z.boolean().nullish(),
|
|
467
546
|
googleAnalyticsId: z.string().nullish(),
|
|
468
547
|
googleRecaptchaKey: z.string().nullish(),
|
|
@@ -470,13 +549,15 @@ export function GraphCommerceConfigSchema(): z.ZodObject<Properties<GraphCommerc
|
|
|
470
549
|
hygraphEndpoint: z.string().min(1),
|
|
471
550
|
hygraphManagementApi: z.string().nullish(),
|
|
472
551
|
hygraphProjectId: z.string().nullish(),
|
|
473
|
-
hygraphWriteAccessEndpoint: z.string().nullish(),
|
|
474
552
|
hygraphWriteAccessToken: z.string().nullish(),
|
|
475
553
|
limitSsg: z.boolean().nullish(),
|
|
476
554
|
magentoEndpoint: z.string().min(1),
|
|
555
|
+
magentoVersion: z.number(),
|
|
556
|
+
permissions: GraphCommercePermissionsSchema().nullish(),
|
|
477
557
|
previewSecret: z.string().nullish(),
|
|
478
|
-
productFiltersLayout: ProductFiltersLayoutSchema.nullish(),
|
|
558
|
+
productFiltersLayout: ProductFiltersLayoutSchema.default("DEFAULT").nullish(),
|
|
479
559
|
productFiltersPro: z.boolean().nullish(),
|
|
560
|
+
productListPaginationVariant: PaginationVariantSchema.default("COMPACT").nullish(),
|
|
480
561
|
productRoute: z.string().nullish(),
|
|
481
562
|
recentlyViewedProducts: RecentlyViewedProductsConfigSchema().nullish(),
|
|
482
563
|
robotsAllow: z.boolean().nullish(),
|
|
@@ -496,10 +577,20 @@ export function GraphCommerceDebugConfigSchema(): z.ZodObject<Properties<GraphCo
|
|
|
496
577
|
})
|
|
497
578
|
}
|
|
498
579
|
|
|
580
|
+
export function GraphCommercePermissionsSchema(): z.ZodObject<Properties<GraphCommercePermissions>> {
|
|
581
|
+
return z.object({
|
|
582
|
+
cart: CartPermissionsSchema.nullish(),
|
|
583
|
+
checkout: CartPermissionsSchema.nullish(),
|
|
584
|
+
customerAccount: CustomerAccountPermissionsSchema.nullish(),
|
|
585
|
+
website: WebsitePermissionsSchema.nullish()
|
|
586
|
+
})
|
|
587
|
+
}
|
|
588
|
+
|
|
499
589
|
export function GraphCommerceStorefrontConfigSchema(): z.ZodObject<Properties<GraphCommerceStorefrontConfig>> {
|
|
500
590
|
return z.object({
|
|
501
591
|
canonicalBaseUrl: z.string().nullish(),
|
|
502
592
|
cartDisplayPricesInclTax: z.boolean().nullish(),
|
|
593
|
+
customerCompanyFieldsEnable: z.boolean().nullish(),
|
|
503
594
|
defaultLocale: z.boolean().nullish(),
|
|
504
595
|
domain: z.string().nullish(),
|
|
505
596
|
googleAnalyticsId: z.string().nullish(),
|
|
@@ -508,7 +599,9 @@ export function GraphCommerceStorefrontConfigSchema(): z.ZodObject<Properties<Gr
|
|
|
508
599
|
hygraphLocales: z.array(z.string().min(1)).nullish(),
|
|
509
600
|
linguiLocale: z.string().nullish(),
|
|
510
601
|
locale: z.string().min(1),
|
|
511
|
-
magentoStoreCode: z.string().min(1)
|
|
602
|
+
magentoStoreCode: z.string().min(1),
|
|
603
|
+
permissions: GraphCommercePermissionsSchema().nullish(),
|
|
604
|
+
robotsAllow: z.boolean().nullish()
|
|
512
605
|
})
|
|
513
606
|
}
|
|
514
607
|
|
|
@@ -873,7 +873,7 @@ export class Visitor {
|
|
|
873
873
|
}
|
|
874
874
|
|
|
875
875
|
visitTsFnParameters(params: TsFnParameter[]): TsFnParameter[] {
|
|
876
|
-
return params
|
|
876
|
+
return params?.map(this.visitTsFnParameter.bind(this))
|
|
877
877
|
}
|
|
878
878
|
|
|
879
879
|
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
|
-
|
|
116
|
-
|
|
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
|
-
|
|
127
|
-
throw new UnsupportedValueError(
|
|
128
|
-
|
|
129
|
-
|
|
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
|
-
|
|
148
|
-
throw new UnsupportedValueError(
|
|
149
|
-
|
|
150
|
-
|
|
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
|
-
|
|
163
|
-
throw new UnsupportedValueError(
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|