@akinon/next 1.20.0 → 1.21.0-rc.1
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 +13 -0
- package/bin/pz-install-plugins.js +0 -0
- package/bin/pz-install-theme.js +0 -0
- package/bin/pz-postbuild.js +0 -0
- package/bin/pz-postdev.js +0 -0
- package/bin/pz-postinstall.js +0 -0
- package/bin/pz-poststart.js +0 -0
- package/bin/pz-prebuild.js +0 -0
- package/bin/pz-predev.js +0 -0
- package/bin/pz-prestart.js +0 -0
- package/data/client/checkout.ts +23 -0
- package/data/urls.ts +2 -1
- package/lib/cache.ts +55 -27
- package/package.json +5 -4
- package/with-pz-config.js +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @akinon/next
|
|
2
2
|
|
|
3
|
+
## 1.21.0-rc.1
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e910b228: ZERO-2421: Upgrade next version to 14.1.0
|
|
8
|
+
- 1b4b0fa1: Redis connection change to connection pool
|
|
9
|
+
|
|
10
|
+
## 1.21.0-rc.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- 26a74c9: ZERO-2436: Add getCoupons and setCoupon API endpoints
|
|
15
|
+
|
|
3
16
|
## 1.20.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
|
File without changes
|
package/bin/pz-install-theme.js
CHANGED
|
File without changes
|
package/bin/pz-postbuild.js
CHANGED
|
File without changes
|
package/bin/pz-postdev.js
CHANGED
|
File without changes
|
package/bin/pz-postinstall.js
CHANGED
|
File without changes
|
package/bin/pz-poststart.js
CHANGED
|
File without changes
|
package/bin/pz-prebuild.js
CHANGED
|
File without changes
|
package/bin/pz-predev.js
CHANGED
|
File without changes
|
package/bin/pz-prestart.js
CHANGED
|
File without changes
|
package/data/client/checkout.ts
CHANGED
|
@@ -177,6 +177,27 @@ export const checkoutApi = api.injectEndpoints({
|
|
|
177
177
|
responseType: 'text'
|
|
178
178
|
})
|
|
179
179
|
}),
|
|
180
|
+
getCoupons: build.query<CheckoutResponse, void>({
|
|
181
|
+
query: () => ({
|
|
182
|
+
url: buildClientRequestUrl(checkout.couponSelectionPage)
|
|
183
|
+
})
|
|
184
|
+
}),
|
|
185
|
+
|
|
186
|
+
setCoupon: build.mutation<CheckoutResponse, { pk: number; action: string }>(
|
|
187
|
+
{
|
|
188
|
+
query: ({ pk, action }) => ({
|
|
189
|
+
url: buildClientRequestUrl(checkout.couponSelectionPage, {
|
|
190
|
+
useFormData: true
|
|
191
|
+
}),
|
|
192
|
+
method: 'POST',
|
|
193
|
+
body: {
|
|
194
|
+
coupon: pk,
|
|
195
|
+
action
|
|
196
|
+
}
|
|
197
|
+
}),
|
|
198
|
+
invalidatesTags: ['Basket']
|
|
199
|
+
}
|
|
200
|
+
),
|
|
180
201
|
completeCreditCardPayment: build.mutation<
|
|
181
202
|
CheckoutResponse,
|
|
182
203
|
CompleteCreditCardParams
|
|
@@ -630,6 +651,8 @@ export const {
|
|
|
630
651
|
useFetchCheckoutResultQuery,
|
|
631
652
|
useGet3dRedirectFormQuery,
|
|
632
653
|
useGetContractQuery,
|
|
654
|
+
useGetCouponsQuery,
|
|
655
|
+
useSetCouponMutation,
|
|
633
656
|
useCompleteCreditCardPaymentMutation,
|
|
634
657
|
useCompleteFundsTransferMutation,
|
|
635
658
|
useGuestLoginMutation,
|
package/data/urls.ts
CHANGED
|
@@ -103,7 +103,8 @@ export const checkout = {
|
|
|
103
103
|
'/orders/checkout/?page=ConfirmationPaymentCompletePage',
|
|
104
104
|
completeLoyaltyPayment: '/orders/checkout/?page=LoyaltyPaymentSelectedPage',
|
|
105
105
|
loyaltyMoneyUsage: '/orders/checkout/?page=LoyaltyMoneyUsagePage',
|
|
106
|
-
setOrderNote: '/orders/checkout/?page=OrderNotePage'
|
|
106
|
+
setOrderNote: '/orders/checkout/?page=OrderNotePage',
|
|
107
|
+
couponSelectionPage: '/orders/checkout/?page=CouponSelectionPage'
|
|
107
108
|
};
|
|
108
109
|
|
|
109
110
|
export const flatpage = {
|
package/lib/cache.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createPool, Pool } from 'generic-pool';
|
|
1
2
|
import { RedisClientType } from 'redis';
|
|
2
3
|
import Settings from 'settings';
|
|
3
4
|
import { CacheOptions } from '../types';
|
|
@@ -64,21 +65,38 @@ export class Cache {
|
|
|
64
65
|
);
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
static
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
static clientPool: Pool<RedisClientType> = createPool(
|
|
69
|
+
{
|
|
70
|
+
create: async () => {
|
|
71
|
+
const { createClient } = await import('redis');
|
|
72
|
+
const redisUrl = `redis://${process.env.CACHE_HOST}:${
|
|
73
|
+
process.env.CACHE_PORT
|
|
74
|
+
}/${process.env.CACHE_BUCKET ?? '0'}`;
|
|
75
|
+
|
|
76
|
+
const client: RedisClientType = createClient({
|
|
77
|
+
url: redisUrl
|
|
78
|
+
});
|
|
72
79
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
client.on('error', (error) => {
|
|
81
|
+
logger.error('Redis client error', { redisUrl, error });
|
|
82
|
+
});
|
|
76
83
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
84
|
+
await client.connect();
|
|
85
|
+
|
|
86
|
+
return client;
|
|
87
|
+
},
|
|
88
|
+
destroy: async (client: RedisClientType) => {
|
|
89
|
+
await client.disconnect();
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
max: 500,
|
|
94
|
+
min: 2
|
|
95
|
+
}
|
|
96
|
+
);
|
|
80
97
|
|
|
81
|
-
|
|
98
|
+
static async getClient() {
|
|
99
|
+
return await Cache.clientPool.acquire();
|
|
82
100
|
}
|
|
83
101
|
|
|
84
102
|
static async get(key: string) {
|
|
@@ -87,39 +105,49 @@ export class Cache {
|
|
|
87
105
|
|
|
88
106
|
try {
|
|
89
107
|
client = await Cache.getClient();
|
|
90
|
-
await client.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
108
|
+
const response = await client.get(key);
|
|
109
|
+
if (response) {
|
|
110
|
+
value = JSON.parse(response);
|
|
111
|
+
} else {
|
|
112
|
+
value = null;
|
|
113
|
+
}
|
|
114
|
+
logger.debug('Redis get success', { key, value });
|
|
95
115
|
} catch (error) {
|
|
96
116
|
logger.error('Redis get error', { key, error });
|
|
117
|
+
value = null;
|
|
97
118
|
} finally {
|
|
98
|
-
|
|
119
|
+
if (client) {
|
|
120
|
+
await Cache.clientPool.release(client);
|
|
121
|
+
}
|
|
99
122
|
}
|
|
100
123
|
|
|
101
124
|
return value;
|
|
102
125
|
}
|
|
103
126
|
|
|
104
|
-
static async set(key: string, value:
|
|
127
|
+
static async set(key: string, value: any, expire?: number) {
|
|
105
128
|
let success = false;
|
|
106
129
|
let client;
|
|
107
130
|
|
|
108
131
|
try {
|
|
109
132
|
client = await Cache.getClient();
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
EX: expire
|
|
113
|
-
});
|
|
133
|
+
const serializedValue =
|
|
134
|
+
typeof value === 'object' ? JSON.stringify(value) : value;
|
|
114
135
|
|
|
115
|
-
|
|
136
|
+
if (expire) {
|
|
137
|
+
await client.set(key, serializedValue, { EX: expire });
|
|
138
|
+
} else {
|
|
139
|
+
await client.set(key, serializedValue);
|
|
140
|
+
}
|
|
116
141
|
|
|
117
|
-
|
|
118
|
-
logger.
|
|
142
|
+
success = true;
|
|
143
|
+
logger.debug('Redis set success', { key, value });
|
|
119
144
|
} catch (error) {
|
|
120
145
|
logger.error('Redis set error', { key, error });
|
|
146
|
+
success = false;
|
|
121
147
|
} finally {
|
|
122
|
-
|
|
148
|
+
if (client) {
|
|
149
|
+
await Cache.clientPool.release(client);
|
|
150
|
+
}
|
|
123
151
|
}
|
|
124
152
|
|
|
125
153
|
return success;
|
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.
|
|
4
|
+
"version": "1.21.0-rc.1",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"bin": {
|
|
@@ -14,13 +14,14 @@
|
|
|
14
14
|
"pz-postdev": "bin/pz-postdev.js"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@opentelemetry/sdk-node": "0.46.0",
|
|
18
17
|
"@opentelemetry/exporter-trace-otlp-http": "0.46.0",
|
|
19
18
|
"@opentelemetry/resources": "1.19.0",
|
|
20
|
-
"@opentelemetry/
|
|
19
|
+
"@opentelemetry/sdk-node": "0.46.0",
|
|
21
20
|
"@opentelemetry/sdk-trace-node": "1.19.0",
|
|
21
|
+
"@opentelemetry/semantic-conventions": "1.19.0",
|
|
22
22
|
"@reduxjs/toolkit": "1.9.7",
|
|
23
23
|
"cross-spawn": "7.0.3",
|
|
24
|
+
"generic-pool": "3.9.0",
|
|
24
25
|
"react-redux": "8.1.3",
|
|
25
26
|
"react-string-replace": "1.1.1",
|
|
26
27
|
"redis": "4.5.1",
|
|
@@ -31,7 +32,7 @@
|
|
|
31
32
|
"@typescript-eslint/eslint-plugin": "6.7.4",
|
|
32
33
|
"@typescript-eslint/parser": "6.7.4",
|
|
33
34
|
"eslint": "^8.14.0",
|
|
34
|
-
"@akinon/eslint-plugin-projectzero": "1.
|
|
35
|
+
"@akinon/eslint-plugin-projectzero": "1.21.0-rc.1",
|
|
35
36
|
"eslint-config-prettier": "8.5.0"
|
|
36
37
|
}
|
|
37
38
|
}
|
package/with-pz-config.js
CHANGED
|
@@ -3,7 +3,7 @@ const deepMerge = require('./utils/deep-merge');
|
|
|
3
3
|
|
|
4
4
|
/** @type {import('next').NextConfig} */
|
|
5
5
|
const defaultConfig = {
|
|
6
|
-
experimental: {
|
|
6
|
+
experimental: { instrumentationHook: true },
|
|
7
7
|
reactStrictMode: true,
|
|
8
8
|
transpilePackages: ['@akinon/next', ...pzPlugins.map((p) => `@akinon/${p}`)],
|
|
9
9
|
skipTrailingSlashRedirect: true,
|