@akinon/next 1.99.0-snapshot-ZERO-3640-20250919140314 → 1.99.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,6 +1,12 @@
1
1
  # @akinon/next
2
2
 
3
- ## 1.99.0-snapshot-ZERO-3640-20250919140314
3
+ ## 1.99.0
4
+
5
+ ### Minor Changes
6
+
7
+ - cf90355: ZERO-3586_2: Enhance caching functionality by adding support for compressed data storage and retrieval, along with a new method for setting multiple key-value pairs.
8
+ - d58538b: ZERO-3638: Enhance RC pipeline: add fetch, merge, and pre-release setup with conditional commit
9
+ - 95a4cd1: ZERO-3631: add automatic route generation
4
10
 
5
11
  ## 1.98.0
6
12
 
package/api/cache.ts CHANGED
@@ -21,20 +21,56 @@ 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 };
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 } = 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
- response = await Cache.set(key, value, expire);
48
+ if (keyValuePairs) {
49
+ try {
50
+ const parsedKeyValuePairs = JSON.parse(keyValuePairs);
51
+ if (
52
+ typeof parsedKeyValuePairs !== 'object' ||
53
+ parsedKeyValuePairs === null ||
54
+ Array.isArray(parsedKeyValuePairs)
55
+ ) {
56
+ throw new Error('Invalid keyValuePairs format - must be an object');
57
+ }
58
+ response = await Cache.mset(parsedKeyValuePairs, expire);
59
+ } catch (error) {
60
+ logger.error('Invalid keyValuePairs in mset request', { error });
61
+ return NextResponse.json(
62
+ { error: 'Invalid keyValuePairs format' },
63
+ { status: 400 }
64
+ );
65
+ }
66
+ } else {
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
+ }
73
+ }
38
74
  }
39
75
  } catch (error) {
40
76
  logger.error(error);
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+ const findBaseDir = require('../utils/find-base-dir');
6
+
7
+ const generateRoutes = () => {
8
+ const baseDir = findBaseDir();
9
+ const srcDir = path.join(baseDir, 'src');
10
+ const appDir = path.join(srcDir, 'app');
11
+
12
+ const routesDir = path.join(srcDir, 'routes');
13
+ const jsOutputPath = path.join(routesDir, 'generated-routes.js');
14
+
15
+ if (!fs.existsSync(routesDir)) {
16
+ fs.mkdirSync(routesDir, { recursive: true });
17
+ }
18
+
19
+ if (!fs.existsSync(appDir)) {
20
+ console.error(`Error: app directory not found at ${appDir}`);
21
+ console.error('Make sure you have an app directory in your project');
22
+ process.exit(1);
23
+ }
24
+
25
+ const routes = [];
26
+ const excludedDirs = ['api', 'pz-not-found'];
27
+
28
+ const skipSegments = ['[commerce]', '[locale]', '[currency]'];
29
+ const skipCatchAllRoutes = ['[...prettyurl]'];
30
+
31
+ const walkDirectory = (dir, basePath = '') => {
32
+ const files = fs.readdirSync(dir);
33
+
34
+ files.forEach((file) => {
35
+ const filePath = path.join(dir, file);
36
+ const stat = fs.statSync(filePath);
37
+
38
+ if (stat.isDirectory()) {
39
+ if (excludedDirs.includes(file)) {
40
+ return;
41
+ }
42
+
43
+ if (skipCatchAllRoutes.includes(file.toLowerCase())) {
44
+ return;
45
+ }
46
+
47
+ let routePath = basePath;
48
+ if (skipSegments.includes(file.toLowerCase())) {
49
+ routePath = basePath;
50
+ } else if (file.startsWith('[') && file.endsWith(']')) {
51
+ if (file.startsWith('[...')) {
52
+ routePath = `${basePath}/.+`;
53
+ } else {
54
+ routePath = `${basePath}/[^/]+`;
55
+ }
56
+ } else if (file.startsWith('(') && file.endsWith(')')) {
57
+ routePath = basePath;
58
+ } else {
59
+ routePath = `${basePath}/${file}`;
60
+ }
61
+
62
+ const pageFiles = ['page.tsx'];
63
+ const hasPage = pageFiles.some((pageFile) =>
64
+ fs.existsSync(path.join(filePath, pageFile))
65
+ );
66
+
67
+ if (hasPage && routePath) {
68
+ routes.push(routePath === '' ? '/' : routePath);
69
+ }
70
+
71
+ walkDirectory(filePath, routePath);
72
+ }
73
+ });
74
+ };
75
+
76
+ walkDirectory(appDir);
77
+
78
+ routes.push('/');
79
+
80
+ const cleanedRoutes = routes
81
+ .map((route) => {
82
+ return route.replace(/\/+/g, '/');
83
+ })
84
+ .filter((route, index, self) => {
85
+ return self.indexOf(route) === index;
86
+ })
87
+ .sort();
88
+
89
+ const jsContent = `// Generated by pz-generate-routes script
90
+ // Do not edit manually
91
+ module.exports = ${JSON.stringify(cleanedRoutes, null, 2)};`;
92
+
93
+ fs.writeFileSync(jsOutputPath, jsContent);
94
+
95
+ console.info(
96
+ `Routes generated successfully. (Found ${cleanedRoutes.length} routes)`
97
+ );
98
+ };
99
+
100
+ try {
101
+ generateRoutes();
102
+ } catch (error) {
103
+ console.error('Error generating routes:', error);
104
+ process.exit(1);
105
+ }
@@ -6,3 +6,4 @@ runScript('pz-run-tests.js');
6
6
  runScript('pz-install-theme.js');
7
7
  runScript('pz-pre-check-dist.js');
8
8
  runScript('pz-generate-translations.js');
9
+ runScript('pz-generate-routes.js');
package/bin/pz-predev.js CHANGED
@@ -6,3 +6,4 @@ runScript('pz-install-extensions.js');
6
6
  runScript('pz-check-env.js');
7
7
  runScript('pz-install-theme.js');
8
8
  runScript('pz-generate-translations.js');
9
+ runScript('pz-generate-routes.js');
@@ -98,7 +98,8 @@ export const getCategoryData = ({
98
98
  locale,
99
99
  getCategoryDataHandler(pk, locale, currency, searchParams, headers),
100
100
  {
101
- expire: 300
101
+ expire: 300,
102
+ compressed: true
102
103
  }
103
104
  );
104
105
  };
@@ -158,7 +159,8 @@ export const getCategoryBySlugData = async ({
158
159
  locale,
159
160
  getCategoryBySlugDataHandler(slug, locale, currency),
160
161
  {
161
- expire: 300
162
+ expire: 300,
163
+ compressed: true
162
164
  }
163
165
  );
164
166
  };
@@ -42,6 +42,9 @@ export const getFlatPageData = ({
42
42
  return Cache.wrap(
43
43
  CacheKey.FlatPage(pk),
44
44
  locale,
45
- getFlatPageDataHandler(pk, locale, currency, headers)
45
+ getFlatPageDataHandler(pk, locale, currency, headers),
46
+ {
47
+ compressed: true
48
+ }
46
49
  );
47
50
  };
@@ -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
  };
@@ -42,6 +42,9 @@ export const getLandingPageData = ({
42
42
  return Cache.wrap(
43
43
  CacheKey.LandingPage(pk),
44
44
  locale,
45
- getLandingPageHandler(pk, locale, currency, headers)
45
+ getLandingPageHandler(pk, locale, currency, headers),
46
+ {
47
+ compressed: true
48
+ }
46
49
  );
47
50
  };
@@ -71,7 +71,8 @@ export const getListData = async ({
71
71
  locale,
72
72
  getListDataHandler(locale, currency, searchParams, headers),
73
73
  {
74
- expire: 300
74
+ expire: 300,
75
+ compressed: true
75
76
  }
76
77
  );
77
78
  };
@@ -48,6 +48,9 @@ export const getMenu = async (params?: MenuHandlerParams) => {
48
48
  return Cache.wrap(
49
49
  CacheKey.Menu(params?.depth ?? DEFAULT_DEPTH, params?.parent),
50
50
  params?.locale ?? ServerVariables.locale,
51
- getMenuHandler(params)
51
+ getMenuHandler(params),
52
+ {
53
+ compressed: true
54
+ }
52
55
  );
53
56
  };
@@ -116,7 +116,8 @@ export const getProductData = async ({
116
116
  headers
117
117
  }),
118
118
  {
119
- expire: 300
119
+ expire: 300,
120
+ compressed: true
120
121
  }
121
122
  );
122
123
  };
@@ -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
  };
@@ -50,7 +50,8 @@ export const getSpecialPageData = async ({
50
50
  locale,
51
51
  getSpecialPageDataHandler(pk, locale, currency, searchParams, headers),
52
52
  {
53
- expire: 300
53
+ expire: 300,
54
+ compressed: true
54
55
  }
55
56
  );
56
57
  };
@@ -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
  };