@akinon/next 2.0.8-rc.0 → 2.0.9-beta.0

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 CHANGED
@@ -1,30 +1,16 @@
1
1
  # @akinon/next
2
2
 
3
- ## 2.0.8-rc.0
3
+ ## 2.0.9-beta.0
4
4
 
5
5
  ### Patch Changes
6
6
 
7
- - 0cf9ea23: BRDG-16491: Prevent redirect when iframe payment is active
8
- - 324f97d5: ZERO-4219: replace masterpass-rest-complete with masterpass-rest-callback
9
- - 51ea0688: ZERO-4377: Fix checkout card type state being cleared after valid bin number responses.
10
- - ZERO-4160: Enhance oauth-login middleware with improved request handling and logging
11
- - b55acb768: ZERO-2577: Fix pagination bug and update usePagination hook and ensure pagination controls rendering correctly
12
- - 760258c1: ZERO-4160: Enhance oauth-login middleware to handle fetch errors and improve response handling
13
- - 143be2b9: ZERO-3457: Crop styles are customizable and logic improved for rendering similar products modal
14
- - 7889b08f: ZERO-4276: Enhance route generation by adding .env loading and custom skip segments support
15
- - 9f8cd3bc5: ZERO-3449: AI Search Active Filters & Crop Style changes have been implemented
16
- - bfafa3f4: ZERO-4160: Refactor oauth-login middleware to use fetchCommerce for API calls and improve cookie handling
17
- - 57d7eb30: ZERO-4276: Refactor route generation logic by removing environment loading and simplifying skip segments handling
18
- - d99a6a7d: ZERO-3457_1: Fixed the settings prop and made sure everything is customizable.
19
- - 9db81a71: ZERO-4365: Remove brand `@theme/*` alias imports from library packages
20
- - 591e345e: ZERO-3855: Enhance credit card payment handling in checkout middlewares
21
- - 4de5303c5: ZERO-2504: add cookie filter to api client request
22
- - 95b139dc: ZERO-3795: Remove duplicate entry for SavedCard in PluginComponents map
23
- - 1d00f2d0: BRDG-16664: Set secure flag for CSRF token cookies in useCaptcha and default middleware
24
- - 4ac7b2a1: ZERO-4219: fix masterpass-rest callback route format and double-encoded error cookie
25
- - 4998a963: ZERO-4168: Add server-side payload optimization
26
- - 3909d322: Edit the duplicate Plugin.SimilarProducts in the plugin-module.
27
- - e18836b2: ZERO-4160: Restore scope in Sentry addon configuration in akinon.json
7
+ - cbbbfd75: ZERO-4376: Bootstrap beta cycle (next-main pre-release motor)
8
+
9
+ ## 2.0.8
10
+
11
+ ### Patch Changes
12
+
13
+ - ef867189: ZERO-4437: Add ESLint flat config migration codemod (pz-migrate-eslint)
28
14
 
29
15
  ## 2.0.7
30
16
 
@@ -6,7 +6,6 @@ const findBaseDir = require('../utils/find-base-dir');
6
6
 
7
7
  const generateRoutes = () => {
8
8
  const baseDir = findBaseDir();
9
-
10
9
  const srcDir = path.join(baseDir, 'src');
11
10
  const appDir = path.join(srcDir, 'app');
12
11
 
@@ -35,10 +34,8 @@ const generateRoutes = () => {
35
34
  '[segment]',
36
35
  '[url]',
37
36
  '[theme]',
38
- '[member_type]',
39
- '[clienttype]'
37
+ '[member_type]'
40
38
  ];
41
-
42
39
  const skipCatchAllRoutes = ['[...prettyurl]', '[...not_found]'];
43
40
 
44
41
  const walkDirectory = (dir, basePath = '') => {
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env node
2
+
3
+ const path = require('path');
4
+ const { migrate } = require(path.join(__dirname, '..', 'codemods', 'migrate-eslint-flat'));
5
+
6
+ migrate(process.argv[2]);
@@ -0,0 +1,247 @@
1
+ /**
2
+ * ESLint flat config migration codemod.
3
+ *
4
+ * Converts a brand project from legacy `.eslintrc.js` to ESLint v9 flat config
5
+ * (`eslint.config.mjs`), consuming the shared base from
6
+ * `@akinon/next/eslint.config.base.mjs`.
7
+ *
8
+ * Idempotent: re-running on an already migrated project is a no-op for
9
+ * already-applied steps.
10
+ *
11
+ * Steps:
12
+ * 1. Read .eslintrc.js (if present) to detect brand-specific settings
13
+ * (settings.next.rootDir, custom rules).
14
+ * 2. Read .eslintignore (if present) to collect ignore patterns.
15
+ * 3. Write eslint.config.mjs (skipped if already exists).
16
+ * 4. Delete .eslintrc.js and .eslintignore.
17
+ * 5. Rewrite .lintstagedrc.js to use `eslint --fix` instead of `next lint`.
18
+ * 6. Patch package.json:
19
+ * - scripts.lint: "next lint" -> "eslint ."
20
+ * - eslint: ^8.x -> ^9.39.4
21
+ * - eslint-config-prettier: ^8.x -> ^10.1.1
22
+ * - remove @typescript-eslint/eslint-plugin and @typescript-eslint/parser
23
+ * (now provided by eslint-config-next/typescript).
24
+ */
25
+
26
+ 'use strict';
27
+
28
+ const fs = require('fs');
29
+ const path = require('path');
30
+
31
+ const ESLINT_TARGET = '9.39.4';
32
+ const ESLINT_CONFIG_PRETTIER_TARGET = '10.1.1';
33
+ const TYPESCRIPT_ESLINT_DROP = [
34
+ '@typescript-eslint/eslint-plugin',
35
+ '@typescript-eslint/parser'
36
+ ];
37
+
38
+ function buildFlatConfig({ rootDir, ignores, customRules }) {
39
+ const lines = [
40
+ "import { defineConfig, globalIgnores } from 'eslint/config';",
41
+ "import baseConfig from '@akinon/next/eslint.config.base.mjs';",
42
+ '',
43
+ 'export default defineConfig([',
44
+ ' ...baseConfig'
45
+ ];
46
+
47
+ if (rootDir) {
48
+ lines[lines.length - 1] += ',';
49
+ lines.push(
50
+ ' {',
51
+ ' settings: {',
52
+ ' next: {',
53
+ ` rootDir: ${JSON.stringify(rootDir)}`,
54
+ ' }',
55
+ ' }',
56
+ ' }'
57
+ );
58
+ }
59
+
60
+ if (customRules) {
61
+ lines[lines.length - 1] += ',';
62
+ const indented = JSON.stringify(customRules, null, 2)
63
+ .split('\n')
64
+ .map((l, i) => (i === 0 ? ' rules: ' + l : ' ' + l))
65
+ .join('\n');
66
+ lines.push(' {', indented, ' }');
67
+ }
68
+
69
+ if (ignores && ignores.length) {
70
+ lines[lines.length - 1] += ',';
71
+ lines.push(` globalIgnores(${JSON.stringify(ignores)})`);
72
+ }
73
+
74
+ lines.push(']);', '');
75
+
76
+ return lines.join('\n');
77
+ }
78
+
79
+ const LINT_STAGED_TEMPLATE = `const path = require('path');
80
+
81
+ const buildEslintCommand = (filenames) =>
82
+ \`eslint --fix \${filenames
83
+ .map((f) => \`"\${path.relative(process.cwd(), f)}"\`)
84
+ .join(' ')}\`;
85
+
86
+ module.exports = {
87
+ '**/*.(ts|tsx)': () => 'yarn tsc --noEmit',
88
+ '*.{js,jsx,ts,tsx}': [buildEslintCommand, 'prettier --write'],
89
+ '*.{css,scss}': [
90
+ 'stylelint --fix --allow-empty-input',
91
+ 'prettier --write',
92
+ 'stylelint --allow-empty-input'
93
+ ]
94
+ };
95
+ `;
96
+
97
+ function loadLegacyConfig(eslintrcPath) {
98
+ try {
99
+ delete require.cache[require.resolve(eslintrcPath)];
100
+ return require(eslintrcPath);
101
+ } catch (err) {
102
+ return { __parseError: err.message };
103
+ }
104
+ }
105
+
106
+ function readIgnoreFile(eslintignorePath) {
107
+ if (!fs.existsSync(eslintignorePath)) return [];
108
+ const raw = fs.readFileSync(eslintignorePath, 'utf8');
109
+ return raw
110
+ .split(/\r?\n/)
111
+ .map((line) => line.trim())
112
+ .filter((line) => line && !line.startsWith('#'))
113
+ .map((pattern) => (pattern.endsWith('/**') ? pattern : pattern + '/**'));
114
+ }
115
+
116
+ function patchPackageJson(pkgPath) {
117
+ const raw = fs.readFileSync(pkgPath, 'utf8');
118
+ const pkg = JSON.parse(raw);
119
+ const changes = [];
120
+
121
+ if (pkg.scripts && typeof pkg.scripts.lint === 'string') {
122
+ if (/^next\s+lint\b/.test(pkg.scripts.lint.trim())) {
123
+ pkg.scripts.lint = 'eslint .';
124
+ changes.push('scripts.lint -> "eslint ."');
125
+ }
126
+ }
127
+
128
+ const bumpDev = (name, target) => {
129
+ if (!pkg.devDependencies || !pkg.devDependencies[name]) return;
130
+ const current = pkg.devDependencies[name].replace(/^\^|^~/, '');
131
+ if (current === target) return;
132
+ pkg.devDependencies[name] = target;
133
+ changes.push(`devDependencies.${name} ${current} -> ${target}`);
134
+ };
135
+
136
+ bumpDev('eslint', ESLINT_TARGET);
137
+ bumpDev('eslint-config-prettier', ESLINT_CONFIG_PRETTIER_TARGET);
138
+
139
+ for (const dep of TYPESCRIPT_ESLINT_DROP) {
140
+ if (pkg.devDependencies && pkg.devDependencies[dep]) {
141
+ delete pkg.devDependencies[dep];
142
+ changes.push(`removed devDependencies.${dep}`);
143
+ }
144
+ }
145
+
146
+ if (changes.length === 0) return { changed: false, changes };
147
+
148
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + '\n', 'utf8');
149
+ return { changed: true, changes };
150
+ }
151
+
152
+ function migrate(projectRoot) {
153
+ const root = path.resolve(projectRoot || process.cwd());
154
+ const eslintrcPath = path.join(root, '.eslintrc.js');
155
+ const eslintignorePath = path.join(root, '.eslintignore');
156
+ const flatConfigPath = path.join(root, 'eslint.config.mjs');
157
+ const lintStagedPath = path.join(root, '.lintstagedrc.js');
158
+ const packageJsonPath = path.join(root, 'package.json');
159
+
160
+ if (!fs.existsSync(packageJsonPath)) {
161
+ console.error(`[migrate-eslint-flat] No package.json found in ${root}`);
162
+ process.exit(1);
163
+ }
164
+
165
+ console.log(`[migrate-eslint-flat] Project root: ${root}`);
166
+ const summary = [];
167
+
168
+ const legacyConfig = fs.existsSync(eslintrcPath)
169
+ ? loadLegacyConfig(eslintrcPath)
170
+ : null;
171
+
172
+ if (legacyConfig && legacyConfig.__parseError) {
173
+ console.warn(
174
+ `[migrate-eslint-flat] Could not parse .eslintrc.js: ${legacyConfig.__parseError}`
175
+ );
176
+ console.warn('Continuing with default brand-template settings.');
177
+ }
178
+
179
+ const rootDir = legacyConfig?.settings?.next?.rootDir;
180
+ const customRules =
181
+ legacyConfig && legacyConfig.rules && Object.keys(legacyConfig.rules).length
182
+ ? legacyConfig.rules
183
+ : null;
184
+
185
+ let ignores = readIgnoreFile(eslintignorePath);
186
+ if (ignores.length === 0) ignores = ['public/**'];
187
+
188
+ if (!fs.existsSync(flatConfigPath)) {
189
+ fs.writeFileSync(
190
+ flatConfigPath,
191
+ buildFlatConfig({ rootDir, ignores, customRules }),
192
+ 'utf8'
193
+ );
194
+ summary.push('created eslint.config.mjs');
195
+ } else {
196
+ summary.push('eslint.config.mjs already exists (skipped)');
197
+ }
198
+
199
+ if (fs.existsSync(eslintrcPath)) {
200
+ fs.unlinkSync(eslintrcPath);
201
+ summary.push('removed .eslintrc.js');
202
+ }
203
+
204
+ if (fs.existsSync(eslintignorePath)) {
205
+ fs.unlinkSync(eslintignorePath);
206
+ summary.push('removed .eslintignore');
207
+ }
208
+
209
+ if (fs.existsSync(lintStagedPath)) {
210
+ const before = fs.readFileSync(lintStagedPath, 'utf8');
211
+ if (before !== LINT_STAGED_TEMPLATE) {
212
+ fs.writeFileSync(lintStagedPath, LINT_STAGED_TEMPLATE, 'utf8');
213
+ summary.push('rewrote .lintstagedrc.js');
214
+ } else {
215
+ summary.push('.lintstagedrc.js already up to date (skipped)');
216
+ }
217
+ }
218
+
219
+ const pkgResult = patchPackageJson(packageJsonPath);
220
+ if (pkgResult.changed) {
221
+ summary.push(`patched package.json (${pkgResult.changes.join(', ')})`);
222
+ } else {
223
+ summary.push('package.json already up to date (skipped)');
224
+ }
225
+
226
+ console.log('\nESLint flat config migration summary:');
227
+ for (const line of summary) console.log(` - ${line}`);
228
+
229
+ if (customRules) {
230
+ console.log(
231
+ `\nNote: ${Object.keys(customRules).length} custom rule(s) from the old ` +
232
+ '.eslintrc.js were carried over into eslint.config.mjs.\nReview if ' +
233
+ 'they are still needed (some may already be covered by the base config).'
234
+ );
235
+ }
236
+
237
+ console.log('\nNext steps:');
238
+ console.log(' 1. yarn install');
239
+ console.log(' 2. yarn lint # expect 0 errors (warnings ok)');
240
+ console.log(' 3. yarn build # smoke test');
241
+ }
242
+
243
+ if (require.main === module) {
244
+ migrate(process.argv[2]);
245
+ }
246
+
247
+ module.exports = { migrate };
@@ -116,6 +116,7 @@ const PluginComponents = new Map([
116
116
  ]
117
117
  ],
118
118
  [Plugin.SavedCard, [Component.SavedCard, Component.IyzicoSavedCard]],
119
+ [Plugin.SavedCard, [Component.SavedCard]],
119
120
  [Plugin.FlowPayment, [Component.FlowPayment]],
120
121
  [
121
122
  Plugin.VirtualTryOn,
@@ -738,6 +738,7 @@ export const checkoutApi = api.injectEndpoints({
738
738
  },
739
739
  async onQueryStarted(arg, { dispatch, queryFulfilled }) {
740
740
  dispatch(setPaymentStepBusy(true));
741
+ dispatch(setCardType(arg));
741
742
  await queryFulfilled;
742
743
  dispatch(setPaymentStepBusy(false));
743
744
  }
@@ -7,8 +7,6 @@ import { parse } from 'lossless-json';
7
7
  import logger from '../../utils/log';
8
8
  import { headers as nHeaders } from 'next/headers';
9
9
  import { ServerVariables } from '../../utils/server-variables';
10
- import { optimizeCategoryResponse } from '../../utils/payload-optimizer';
11
- import settings from 'settings';
12
10
 
13
11
  function getCategoryDataHandler(
14
12
  pk: number,
@@ -82,7 +80,7 @@ function getCategoryDataHandler(
82
80
  };
83
81
  }
84
82
 
85
- export const getCategoryData = async ({
83
+ export const getCategoryData = ({
86
84
  pk,
87
85
  searchParams,
88
86
  headers,
@@ -95,7 +93,7 @@ export const getCategoryData = async ({
95
93
  searchParams?: SearchParams;
96
94
  headers?: Record<string, string>;
97
95
  }) => {
98
- const result = await Cache.wrap(
96
+ return Cache.wrap(
99
97
  CacheKey.Category(pk, searchParams, headers),
100
98
  locale,
101
99
  getCategoryDataHandler(pk, locale, currency, searchParams, headers),
@@ -104,16 +102,6 @@ export const getCategoryData = async ({
104
102
  compressed: true
105
103
  }
106
104
  );
107
-
108
- if (settings.payloadOptimization?.enabled && result?.data) {
109
- try {
110
- return { ...result, data: optimizeCategoryResponse(result.data, settings.payloadOptimization) };
111
- } catch (e) {
112
- logger.error('Payload optimization failed for category', { pk, error: (e as Error).message });
113
- }
114
- }
115
-
116
- return result;
117
105
  };
118
106
 
119
107
  function getCategoryBySlugDataHandler(
@@ -6,8 +6,6 @@ import appFetch, { FetchResponseType } from '../../utils/app-fetch';
6
6
  import { parse } from 'lossless-json';
7
7
  import logger from '../../utils/log';
8
8
  import { ServerVariables } from '../../utils/server-variables';
9
- import { optimizeCategoryResponse } from '../../utils/payload-optimizer';
10
- import settings from 'settings';
11
9
 
12
10
  const getListDataHandler = (
13
11
  locale,
@@ -68,7 +66,7 @@ export const getListData = async ({
68
66
  searchParams: SearchParams;
69
67
  headers?: Record<string, string>;
70
68
  }) => {
71
- const result = await Cache.wrap(
69
+ return Cache.wrap(
72
70
  CacheKey.List(searchParams, headers),
73
71
  locale,
74
72
  getListDataHandler(locale, currency, searchParams, headers),
@@ -77,14 +75,4 @@ export const getListData = async ({
77
75
  compressed: true
78
76
  }
79
77
  );
80
-
81
- if (settings.payloadOptimization?.enabled && result) {
82
- try {
83
- return optimizeCategoryResponse(result, settings.payloadOptimization);
84
- } catch (e) {
85
- logger.error('Payload optimization failed for list', { error: (e as Error).message });
86
- }
87
- }
88
-
89
- return result;
90
78
  };
@@ -4,8 +4,6 @@ import { ProductCategoryResult, ProductResult, SearchParams } from '../../types'
4
4
  import appFetch from '../../utils/app-fetch';
5
5
  import { ServerVariables } from '../../utils/server-variables';
6
6
  import logger from '../../utils/log';
7
- import { optimizeProductResponse } from '../../utils/payload-optimizer';
8
- import settings from 'settings';
9
7
 
10
8
  type GetProduct = {
11
9
  pk: number | string;
@@ -165,13 +163,5 @@ export const getProductData = async ({
165
163
  throw error;
166
164
  }
167
165
 
168
- if (settings.payloadOptimization?.enabled && result?.data) {
169
- try {
170
- return { ...result, data: optimizeProductResponse(result.data, settings.payloadOptimization) };
171
- } catch (e) {
172
- logger.error('Payload optimization failed for product', { pk, error: (e as Error).message });
173
- }
174
- }
175
-
176
166
  return result;
177
167
  };
@@ -4,9 +4,6 @@ import { GetCategoryResponse, SearchParams } from '../../types';
4
4
  import { generateCommerceSearchParams } from '../../utils';
5
5
  import appFetch from '../../utils/app-fetch';
6
6
  import { ServerVariables } from '../../utils/server-variables';
7
- import { optimizeCategoryResponse } from '../../utils/payload-optimizer';
8
- import logger from '../../utils/log';
9
- import settings from 'settings';
10
7
 
11
8
  const getSpecialPageDataHandler = (
12
9
  pk: number,
@@ -48,7 +45,7 @@ export const getSpecialPageData = async ({
48
45
  searchParams: SearchParams;
49
46
  headers?: Record<string, string>;
50
47
  }) => {
51
- const result = await Cache.wrap(
48
+ return Cache.wrap(
52
49
  CacheKey.SpecialPage(pk, searchParams, headers),
53
50
  locale,
54
51
  getSpecialPageDataHandler(pk, locale, currency, searchParams, headers),
@@ -57,14 +54,4 @@ export const getSpecialPageData = async ({
57
54
  compressed: true
58
55
  }
59
56
  );
60
-
61
- if (settings.payloadOptimization?.enabled && result) {
62
- try {
63
- return optimizeCategoryResponse(result, settings.payloadOptimization);
64
- } catch (e) {
65
- logger.error('Payload optimization failed for special-page', { pk, error: (e as Error).message });
66
- }
67
- }
68
-
69
- return result;
70
57
  };
@@ -4,9 +4,6 @@ import { CacheOptions, WidgetResultType, WidgetSchemaType } from '../../types';
4
4
  import appFetch from '../../utils/app-fetch';
5
5
  import { widgets } from '../urls';
6
6
  import { ServerVariables } from '../../utils/server-variables';
7
- import { optimizeWidgetResponse } from '../../utils/payload-optimizer';
8
- import logger from '../../utils/log';
9
- import settings from 'settings';
10
7
 
11
8
  const getWidgetDataHandler =
12
9
  (
@@ -56,7 +53,7 @@ export const getWidgetData = async <T>({
56
53
  cacheOptions?: CacheOptions;
57
54
  headers?: Record<string, string>;
58
55
  }): Promise<WidgetResultType<T>> => {
59
- const result = await Cache.wrap(
56
+ return Cache.wrap(
60
57
  CacheKey.Widget(slug),
61
58
  locale,
62
59
  getWidgetDataHandler(slug, locale, currency, headers),
@@ -65,16 +62,6 @@ export const getWidgetData = async <T>({
65
62
  ...cacheOptions
66
63
  }
67
64
  );
68
-
69
- if (settings.payloadOptimization?.enabled && result) {
70
- try {
71
- return optimizeWidgetResponse(result, settings.payloadOptimization) as WidgetResultType<T>;
72
- } catch (e) {
73
- logger.error('Payload optimization failed for widget', { slug, error: (e as Error).message });
74
- }
75
- }
76
-
77
- return result as WidgetResultType<T>;
78
65
  };
79
66
 
80
67
  const getCollectionWidgetDataHandler =
package/data/urls.ts CHANGED
@@ -183,11 +183,7 @@ export const product = {
183
183
  breadcrumbUrl: (menuitemmodel: string) =>
184
184
  `/menus/generate_breadcrumb/?item=${menuitemmodel}&generator_name=menu_item`,
185
185
  bundleProduct: (productPk: string, queryString: string) =>
186
- `/bundle-product/${productPk}/?${queryString}`,
187
- similarProducts: (params?: string) =>
188
- `/similar-products${params ? `?${params}` : ''}`,
189
- similarProductsList: (params?: string) =>
190
- `/similar-product-list${params ? `?${params}` : ''}`
186
+ `/bundle-product/${productPk}/?${queryString}`
191
187
  };
192
188
 
193
189
  export const wishlist = {
@@ -39,7 +39,7 @@ export const useCaptcha = () => {
39
39
  };
40
40
 
41
41
  if (csrfToken) {
42
- setCookie('csrftoken', csrfToken, { secure: true });
42
+ setCookie('csrftoken', csrfToken);
43
43
  }
44
44
 
45
45
  const onCaptchaChange = useCallback(async (response) => {
@@ -547,8 +547,7 @@ const withPzDefault =
547
547
  'csrftoken',
548
548
  csrf_token,
549
549
  {
550
- domain: rootHostname,
551
- secure: true
550
+ domain: rootHostname
552
551
  }
553
552
  );
554
553
  }