@akinon/projectzero 1.69.0-rc.2 → 1.69.0-rc.4

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,5 +1,9 @@
1
1
  # @akinon/projectzero
2
2
 
3
+ ## 1.69.0-rc.4
4
+
5
+ ## 1.69.0-rc.3
6
+
3
7
  ## 1.69.0-rc.2
4
8
 
5
9
  ## 1.69.0-rc.1
@@ -1,5 +1,55 @@
1
1
  # projectzeronext
2
2
 
3
+ ## 1.69.0-rc.4
4
+
5
+ ### Minor Changes
6
+
7
+ - 063da74: ZERO-3010: Remove pz-iyzico-saved-card package
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [063da74]
12
+ - @akinon/next@1.69.0-rc.4
13
+ - @akinon/pz-akifast@1.69.0-rc.4
14
+ - @akinon/pz-b2b@1.69.0-rc.4
15
+ - @akinon/pz-basket-gift-pack@1.69.0-rc.4
16
+ - @akinon/pz-bkm@1.69.0-rc.4
17
+ - @akinon/pz-checkout-gift-pack@1.69.0-rc.4
18
+ - @akinon/pz-click-collect@1.69.0-rc.4
19
+ - @akinon/pz-credit-payment@1.69.0-rc.4
20
+ - @akinon/pz-gpay@1.69.0-rc.4
21
+ - @akinon/pz-masterpass@1.69.0-rc.4
22
+ - @akinon/pz-one-click-checkout@1.69.0-rc.4
23
+ - @akinon/pz-otp@1.69.0-rc.4
24
+ - @akinon/pz-pay-on-delivery@1.69.0-rc.4
25
+ - @akinon/pz-saved-card@1.69.0-rc.4
26
+ - @akinon/pz-tabby-extension@1.69.0-rc.4
27
+
28
+ ## 1.69.0-rc.3
29
+
30
+ ### Minor Changes
31
+
32
+ - cbdb0c8: ZERO-3010: Move pretty url page into project
33
+
34
+ ### Patch Changes
35
+
36
+ - Updated dependencies [cbdb0c8]
37
+ - @akinon/next@1.69.0-rc.3
38
+ - @akinon/pz-akifast@1.69.0-rc.3
39
+ - @akinon/pz-b2b@1.69.0-rc.3
40
+ - @akinon/pz-basket-gift-pack@1.69.0-rc.3
41
+ - @akinon/pz-bkm@1.69.0-rc.3
42
+ - @akinon/pz-checkout-gift-pack@1.69.0-rc.3
43
+ - @akinon/pz-click-collect@1.69.0-rc.3
44
+ - @akinon/pz-credit-payment@1.69.0-rc.3
45
+ - @akinon/pz-gpay@1.69.0-rc.3
46
+ - @akinon/pz-masterpass@1.69.0-rc.3
47
+ - @akinon/pz-one-click-checkout@1.69.0-rc.3
48
+ - @akinon/pz-otp@1.69.0-rc.3
49
+ - @akinon/pz-pay-on-delivery@1.69.0-rc.3
50
+ - @akinon/pz-saved-card@1.69.0-rc.3
51
+ - @akinon/pz-tabby-extension@1.69.0-rc.3
52
+
3
53
  ## 1.69.0-rc.2
4
54
 
5
55
  ### Patch Changes
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "projectzeronext",
3
- "version": "1.69.0-rc.2",
3
+ "version": "1.69.0-rc.4",
4
4
  "private": true,
5
5
  "license": "MIT",
6
6
  "scripts": {
@@ -22,21 +22,21 @@
22
22
  "prestart": "pz-prestart"
23
23
  },
24
24
  "dependencies": {
25
- "@akinon/next": "1.69.0-rc.2",
26
- "@akinon/pz-akifast": "1.69.0-rc.2",
27
- "@akinon/pz-b2b": "1.69.0-rc.2",
28
- "@akinon/pz-basket-gift-pack": "1.69.0-rc.2",
29
- "@akinon/pz-bkm": "1.69.0-rc.2",
30
- "@akinon/pz-checkout-gift-pack": "1.69.0-rc.2",
31
- "@akinon/pz-click-collect": "1.69.0-rc.2",
32
- "@akinon/pz-credit-payment": "1.69.0-rc.2",
33
- "@akinon/pz-gpay": "1.69.0-rc.2",
34
- "@akinon/pz-masterpass": "1.69.0-rc.2",
35
- "@akinon/pz-one-click-checkout": "1.69.0-rc.2",
36
- "@akinon/pz-otp": "1.69.0-rc.2",
37
- "@akinon/pz-pay-on-delivery": "1.69.0-rc.2",
38
- "@akinon/pz-saved-card": "1.69.0-rc.2",
39
- "@akinon/pz-tabby-extension": "1.69.0-rc.2",
25
+ "@akinon/next": "1.69.0-rc.4",
26
+ "@akinon/pz-akifast": "1.69.0-rc.4",
27
+ "@akinon/pz-b2b": "1.69.0-rc.4",
28
+ "@akinon/pz-basket-gift-pack": "1.69.0-rc.4",
29
+ "@akinon/pz-bkm": "1.69.0-rc.4",
30
+ "@akinon/pz-checkout-gift-pack": "1.69.0-rc.4",
31
+ "@akinon/pz-click-collect": "1.69.0-rc.4",
32
+ "@akinon/pz-credit-payment": "1.69.0-rc.4",
33
+ "@akinon/pz-gpay": "1.69.0-rc.4",
34
+ "@akinon/pz-masterpass": "1.69.0-rc.4",
35
+ "@akinon/pz-one-click-checkout": "1.69.0-rc.4",
36
+ "@akinon/pz-otp": "1.69.0-rc.4",
37
+ "@akinon/pz-pay-on-delivery": "1.69.0-rc.4",
38
+ "@akinon/pz-saved-card": "1.69.0-rc.4",
39
+ "@akinon/pz-tabby-extension": "1.69.0-rc.4",
40
40
  "@hookform/resolvers": "2.9.0",
41
41
  "@next/third-parties": "14.1.0",
42
42
  "@react-google-maps/api": "2.17.1",
@@ -60,7 +60,7 @@
60
60
  "yup": "0.32.11"
61
61
  },
62
62
  "devDependencies": {
63
- "@akinon/eslint-plugin-projectzero": "1.69.0-rc.2",
63
+ "@akinon/eslint-plugin-projectzero": "1.69.0-rc.4",
64
64
  "@semantic-release/changelog": "6.0.2",
65
65
  "@semantic-release/exec": "6.0.3",
66
66
  "@semantic-release/git": "10.0.1",
@@ -1,8 +1,191 @@
1
- import Page, {
2
- dynamic,
3
- revalidate,
4
- generateMetadata
5
- } from '@akinon/next/routes/pretty-url';
6
-
7
- export { dynamic, revalidate, generateMetadata };
8
- export default Page;
1
+ import { URLS } from '@akinon/next/data/urls';
2
+ import { Metadata, PageProps } from '@akinon/next/types';
3
+ import logger from '@akinon/next/utils/log';
4
+ import { notFound } from 'next/navigation';
5
+
6
+ type PrettyUrlResult = {
7
+ matched: boolean;
8
+ path?: string;
9
+ pk?: number;
10
+ };
11
+
12
+ const resolvePrettyUrlHandler =
13
+ (pathname: string, ip: string | null) => async () => {
14
+ let results = [] as { old_path: string }[];
15
+ let prettyUrlResult: PrettyUrlResult = {
16
+ matched: false
17
+ };
18
+
19
+ try {
20
+ const requestUrl = URLS.misc.prettyUrls(`/${pathname}/`);
21
+
22
+ logger.debug(`Resolving pretty url`, { pathname, requestUrl, ip });
23
+
24
+ const start = Date.now();
25
+ const apiResponse = await fetch(requestUrl, {
26
+ next: {
27
+ revalidate: 0
28
+ }
29
+ });
30
+ const data = await apiResponse.json();
31
+ ({ results } = data);
32
+ const end = Date.now();
33
+ console.warn('Pretty url response time', end - start, requestUrl);
34
+
35
+ const matched = results.length > 0;
36
+ const [{ old_path: path } = { old_path: '' }] = results;
37
+ let pk;
38
+
39
+ if (matched) {
40
+ const pkRegex = /\/(\d+)\/$/;
41
+ const match = path.match(pkRegex);
42
+ pk = match ? parseInt(match[1]) : undefined;
43
+ }
44
+
45
+ prettyUrlResult = {
46
+ matched,
47
+ path,
48
+ pk
49
+ };
50
+
51
+ logger.trace('Pretty url result', { prettyUrlResult, ip });
52
+ } catch (error) {
53
+ logger.error('Error resolving pretty url', { error, pathname, ip });
54
+ }
55
+
56
+ return prettyUrlResult;
57
+ };
58
+
59
+ export async function generateMetadata({ params }: PageProps) {
60
+ let result: Metadata = {};
61
+ const { prettyurl } = params;
62
+ const pageSlug = prettyurl
63
+ .filter((x) => !x.startsWith('searchparams'))
64
+ .join('/');
65
+
66
+ const searchParams = new URLSearchParams(
67
+ decodeURIComponent(
68
+ prettyurl
69
+ .find((x) => x.startsWith('searchparams'))
70
+ ?.replace('searchparams%7C', '')
71
+ ) ?? {}
72
+ );
73
+ const prettyUrlResult = await resolvePrettyUrlHandler(pageSlug, null)();
74
+
75
+ if (!prettyUrlResult.matched) {
76
+ return notFound();
77
+ }
78
+
79
+ const commonProps = {
80
+ params: {
81
+ ...params,
82
+ pk: prettyUrlResult.pk
83
+ },
84
+ searchParams
85
+ };
86
+
87
+ try {
88
+ if (prettyUrlResult.path.startsWith('/product/')) {
89
+ await import('@product/[pk]/page').then(async (module) => {
90
+ result = await module['generateMetadata']?.(commonProps);
91
+ });
92
+ }
93
+
94
+ if (prettyUrlResult.path.startsWith('/group-product/')) {
95
+ await import('@group-product/[pk]/page').then(async (module) => {
96
+ result = await module['generateMetadata']?.(commonProps);
97
+ });
98
+ }
99
+
100
+ if (prettyUrlResult.path.startsWith('/category/')) {
101
+ await import('@category/[pk]/page').then(async (module) => {
102
+ result = await module['generateMetadata']?.(commonProps);
103
+ });
104
+ }
105
+
106
+ if (prettyUrlResult.path.startsWith('/special-page/')) {
107
+ await import('@special-page/[pk]/page').then(async (module) => {
108
+ result = await module['generateMetadata']?.(commonProps);
109
+ });
110
+ }
111
+
112
+ if (prettyUrlResult.path.startsWith('/flat-page/')) {
113
+ await import('@flat-page/[pk]/page').then(async (module) => {
114
+ result = await module['generateMetadata']?.(commonProps);
115
+ });
116
+ }
117
+ // eslint-disable-next-line no-empty
118
+ } catch (error) {}
119
+
120
+ return result;
121
+ }
122
+
123
+ export const dynamic = 'force-static';
124
+ export const revalidate = 300;
125
+
126
+ export default async function Page({ params }) {
127
+ const { prettyurl } = params;
128
+ const pageSlug = prettyurl
129
+ .filter((x) => !x.startsWith('searchparams'))
130
+ .join('/');
131
+
132
+ const urlSearchParams = new URLSearchParams(
133
+ decodeURIComponent(
134
+ prettyurl
135
+ .find((x) => x.startsWith('searchparams'))
136
+ ?.replace('searchparams%7C', '')
137
+ ) ?? {}
138
+ );
139
+
140
+ const searchParams = {};
141
+
142
+ for (const [key, value] of urlSearchParams.entries() as unknown as Array<
143
+ [string, string]
144
+ >) {
145
+ if (!searchParams[key]) {
146
+ searchParams[key] = [];
147
+ }
148
+ searchParams[key].push(value);
149
+ }
150
+
151
+ const result = await resolvePrettyUrlHandler(pageSlug, null)();
152
+
153
+ if (!result.matched) {
154
+ return notFound();
155
+ }
156
+
157
+ const commonProps = {
158
+ params: {
159
+ ...params,
160
+ pk: result.pk
161
+ },
162
+ searchParams: urlSearchParams
163
+ };
164
+
165
+ if (result.path.startsWith('/category/')) {
166
+ const CategoryPage = (await import('@category/[pk]/page')).default;
167
+ return <CategoryPage {...commonProps} />;
168
+ }
169
+
170
+ if (result.path.startsWith('/product/')) {
171
+ const ProductPage = (await import('@product/[pk]/page')).default;
172
+ return <ProductPage {...commonProps} />;
173
+ }
174
+
175
+ if (result.path.startsWith('/group-product/')) {
176
+ const GroupProduct = (await import('@group-product/[pk]/page')).default;
177
+ return <GroupProduct {...commonProps} />;
178
+ }
179
+
180
+ if (result.path.startsWith('/special-page/')) {
181
+ const SpecialPage = (await import('@special-page/[pk]/page')).default;
182
+ return <SpecialPage {...commonProps} />;
183
+ }
184
+
185
+ if (result.path.startsWith('/flat-page/')) {
186
+ const FlatPage = (await import('@flat-page/[pk]/page')).default;
187
+ return <FlatPage {...commonProps} />;
188
+ }
189
+
190
+ return null;
191
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akinon/projectzero",
3
- "version": "1.69.0-rc.2",
3
+ "version": "1.69.0-rc.4",
4
4
  "private": false,
5
5
  "description": "CLI tool to manage your Project Zero Next project",
6
6
  "bin": {