@akinon/next 1.93.0-snapshot-ZERO-3586-20250827123110 → 1.93.0-snapshot-ZERO-3586-20250827130920

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,10 +1,10 @@
1
1
  # @akinon/next
2
2
 
3
- ## 1.93.0-snapshot-ZERO-3586-20250827123110
3
+ ## 1.93.0-snapshot-ZERO-3586-20250827130920
4
4
 
5
5
  ### Minor Changes
6
6
 
7
- - 5dfeea04: ZERO-2801: Revert ZERO-2801
7
+ - 5dfeea04a: ZERO-2801: Revert ZERO-2801
8
8
  - 823d82f9: ZERO-3393: Enhance error handling in checkout middleware to ensure errors are checked for existence before processing
9
9
  - 412f0e2: ZERO-3586: Enhance caching functionality by adding support for compressed data storage and retrieval, along with a new method for setting multiple key-value pairs.
10
10
  - 28c7ea79: ZERO-3427: Refactor redirect utility to handle undefined URL and improve locale handling
@@ -46,10 +46,10 @@
46
46
  - bbe18b9ff: ZERO-2575: Fix build error
47
47
  - 17bfadc4: ZERO-3275: Disable OpenTelemetry monitoring in production environment
48
48
  - 35dfb8f8: ZERO-3363: Refactor URL handling in checkout and redirection middlewares to use url.origin instead of process.env.NEXT_PUBLIC_URL
49
- - 4920742c: Disable getCachedTranslations
49
+ - 4920742c2: Disable getCachedTranslations
50
50
  - b6e5b624: ZERO-3257: Enhance locale middleware to redirect using existing or default locale and support 303 status for POST requests
51
51
  - 0de55738: ZERO-3418: Update remotePatterns hostname to allow all subdomains
52
- - 7e56d6b6: ZERO-2841: Update api tagTypes
52
+ - 7e56d6b6b: ZERO-2841: Update api tagTypes
53
53
  - dfaceffd: ZERO-3356: Add useLoyaltyAvailability hook and update checkout state management
54
54
  - 86642cf: ZERO-3531: Add saveSampleProducts endpoint and update URLs in checkout
55
55
  - d99a6a7d: ZERO-3457: Fixed the settings prop and made sure everything is customizable.
@@ -71,7 +71,7 @@
71
71
  - f2c92d5c7: ZERO-2816: Update cookie name
72
72
  - a420947d: ZERO-3517: Fix optional chaining for rawData in error logging for category data handlers
73
73
  - 7bd3d9928: ZERO-2801: Refactor locale middleware to handle single locale configuration
74
- - acd2afd: ZERO-3431: Fix import statement for findBaseDir in next-config test
74
+ - acd2afdf: ZERO-3431: Fix import statement for findBaseDir in next-config test
75
75
  - 2d3f1788: ZERO-3417: Enhance FileInput component with additional props for customization
76
76
  - fdd255ee: ZERO-3054: Refactor cache handler to use custom Redis handler and implement key hashing
77
77
  - b434ac8: ZERO-3545: Update fetchCheckout API URL to include page parameter
package/api/cache.ts CHANGED
@@ -21,32 +21,55 @@ async function handleRequest(...args) {
21
21
  }
22
22
 
23
23
  const formData = await req.formData();
24
- const body = {} as { key: string; value?: string; expire?: number; keyValuePairs?: string };
24
+ const body = {} as {
25
+ key: string;
26
+ value?: string;
27
+ expire?: number;
28
+ keyValuePairs?: string;
29
+ compressed?: string;
30
+ };
25
31
 
26
32
  formData.forEach((value, key) => {
27
33
  body[key] = value;
28
34
  });
29
35
 
30
- const { key, value, expire, keyValuePairs } = body;
31
- let response: string | boolean;
36
+ const { key, value, expire, keyValuePairs, compressed } = body;
37
+ let response: any;
32
38
 
33
39
  try {
34
40
  if (req.method === 'POST') {
35
- response = await Cache.get(key);
41
+ // GET request - check if compressed flag is set
42
+ if (compressed === 'true') {
43
+ response = await Cache.getCompressed(key);
44
+ } else {
45
+ response = await Cache.get(key);
46
+ }
36
47
  } else if (req.method === 'PUT') {
37
48
  if (keyValuePairs) {
38
49
  try {
39
50
  const parsedKeyValuePairs = JSON.parse(keyValuePairs);
40
- if (typeof parsedKeyValuePairs !== 'object' || parsedKeyValuePairs === null || Array.isArray(parsedKeyValuePairs)) {
51
+ if (
52
+ typeof parsedKeyValuePairs !== 'object' ||
53
+ parsedKeyValuePairs === null ||
54
+ Array.isArray(parsedKeyValuePairs)
55
+ ) {
41
56
  throw new Error('Invalid keyValuePairs format - must be an object');
42
57
  }
43
58
  response = await Cache.mset(parsedKeyValuePairs, expire);
44
59
  } catch (error) {
45
60
  logger.error('Invalid keyValuePairs in mset request', { error });
46
- return NextResponse.json({ error: 'Invalid keyValuePairs format' }, { status: 400 });
61
+ return NextResponse.json(
62
+ { error: 'Invalid keyValuePairs format' },
63
+ { status: 400 }
64
+ );
47
65
  }
48
66
  } else {
49
- response = await Cache.set(key, value, expire);
67
+ // SET request - check if compressed flag is set
68
+ if (compressed === 'true') {
69
+ response = await Cache.setCompressed(key, value, expire);
70
+ } else {
71
+ response = await Cache.set(key, value, expire);
72
+ }
50
73
  }
51
74
  }
52
75
  } catch (error) {
@@ -46,6 +46,9 @@ export const getFlatPageData = ({
46
46
  return Cache.wrap(
47
47
  CacheKey.FlatPage(pk),
48
48
  locale,
49
- getFlatPageDataHandler(pk, locale, currency, headers)
49
+ getFlatPageDataHandler(pk, locale, currency, headers),
50
+ {
51
+ compressed: true
52
+ }
50
53
  );
51
54
  };
@@ -43,6 +43,9 @@ export const getFormData = ({
43
43
  return Cache.wrap(
44
44
  CacheKey.Form(pk),
45
45
  locale,
46
- getFormDataHandler(pk, locale, currency, headers)
46
+ getFormDataHandler(pk, locale, currency, headers),
47
+ {
48
+ compressed: true
49
+ }
47
50
  );
48
51
  };
@@ -46,6 +46,9 @@ export const getLandingPageData = ({
46
46
  return Cache.wrap(
47
47
  CacheKey.LandingPage(pk),
48
48
  locale,
49
- getLandingPageHandler(pk, locale, currency, headers)
49
+ getLandingPageHandler(pk, locale, currency, headers),
50
+ {
51
+ compressed: true
52
+ }
50
53
  );
51
54
  };
@@ -43,6 +43,9 @@ export const getSeoData = async (
43
43
  return Cache.wrap(
44
44
  CacheKey.Seo(url),
45
45
  locale,
46
- getSeoDataHandler({ url, locale, currency, headers })
46
+ getSeoDataHandler({ url, locale, currency, headers }),
47
+ {
48
+ compressed: true
49
+ }
47
50
  );
48
51
  };
@@ -44,6 +44,9 @@ export const getWidgetData = async <T>({
44
44
  CacheKey.Widget(slug),
45
45
  locale,
46
46
  getWidgetDataHandler(slug, locale, currency, headers),
47
- cacheOptions
47
+ {
48
+ compressed: true,
49
+ ...cacheOptions
50
+ }
48
51
  );
49
52
  };
package/lib/cache.ts CHANGED
@@ -204,7 +204,8 @@ export class Cache {
204
204
 
205
205
  const defaultOptions: CacheOptions = {
206
206
  cache: true,
207
- expire: Settings.redis.defaultExpirationTime
207
+ expire: Settings.redis.defaultExpirationTime,
208
+ compressed: process.env.CACHE_COMPRESSION_ENABLED !== 'false'
208
209
  };
209
210
 
210
211
  const _options = Object.assign(defaultOptions, options);
@@ -223,6 +224,9 @@ export class Cache {
223
224
  const body = new URLSearchParams();
224
225
 
225
226
  body.append('key', formattedKey);
227
+ if (_options.compressed) {
228
+ body.append('compressed', 'true');
229
+ }
226
230
 
227
231
  cachedValue = await Cache.proxyRequest('POST', body);
228
232
  logger.debug('Cache proxy request success', { key });
@@ -253,6 +257,9 @@ export class Cache {
253
257
  'expire',
254
258
  String(_options?.expire ?? Settings.redis.defaultExpirationTime)
255
259
  );
260
+ if (_options.compressed) {
261
+ body.append('compressed', 'true');
262
+ }
256
263
  await Cache.proxyRequest('PUT', body);
257
264
 
258
265
  logger.debug('Cache proxy request', { key, body: body.toString() });
@@ -53,7 +53,8 @@ const resolvePrettyUrl = async (
53
53
  locale,
54
54
  resolvePrettyUrlHandler(pathname, ip),
55
55
  {
56
- useProxy: true
56
+ useProxy: true,
57
+ compressed: true
57
58
  }
58
59
  );
59
60
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@akinon/next",
3
3
  "description": "Core package for Project Zero Next",
4
- "version": "1.93.0-snapshot-ZERO-3586-20250827123110",
4
+ "version": "1.93.0-snapshot-ZERO-3586-20250827130920",
5
5
  "private": false,
6
6
  "license": "MIT",
7
7
  "bin": {
@@ -35,7 +35,7 @@
35
35
  "set-cookie-parser": "2.6.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@akinon/eslint-plugin-projectzero": "1.93.0-snapshot-ZERO-3586-20250827123110",
38
+ "@akinon/eslint-plugin-projectzero": "1.93.0-snapshot-ZERO-3586-20250827130920",
39
39
  "@babel/core": "7.26.10",
40
40
  "@babel/preset-env": "7.26.9",
41
41
  "@babel/preset-typescript": "7.27.0",