@graphcommerce/magento-store 8.1.0-canary.9 → 9.0.0-canary.101
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 +219 -20
- package/Money.tsx +12 -33
- package/StoreConfigFragment.graphql +6 -1
- package/index.ts +0 -1
- package/package.json +8 -8
- package/plugins/magentoStoreGraphqlConfig.ts +29 -3
- package/utils/redirectOrNotFound.ts +26 -2
- package/link/createStoreLink.ts +0 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,209 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 9.0.0-canary.101
|
|
4
|
+
|
|
5
|
+
## 9.0.0-canary.100
|
|
6
|
+
|
|
7
|
+
## 9.0.0-canary.99
|
|
8
|
+
|
|
9
|
+
## 9.0.0-canary.98
|
|
10
|
+
|
|
11
|
+
## 9.0.0-canary.97
|
|
12
|
+
|
|
13
|
+
## 9.0.0-canary.96
|
|
14
|
+
|
|
15
|
+
## 9.0.0-canary.95
|
|
16
|
+
|
|
17
|
+
## 9.0.0-canary.94
|
|
18
|
+
|
|
19
|
+
## 9.0.0-canary.93
|
|
20
|
+
|
|
21
|
+
## 9.0.0-canary.92
|
|
22
|
+
|
|
23
|
+
## 9.0.0-canary.91
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- [#2367](https://github.com/graphcommerce-org/graphcommerce/pull/2367) [`71d412d`](https://github.com/graphcommerce-org/graphcommerce/commit/71d412d202bc94a0e676745547de5d809a7a850b) - When a user access a category page which is beyond the available total_pages, the user will be redirected to the last available page. ([@paales](https://github.com/paales))
|
|
28
|
+
|
|
29
|
+
## 9.0.0-canary.90
|
|
30
|
+
|
|
31
|
+
## 9.0.0-canary.89
|
|
32
|
+
|
|
33
|
+
## 9.0.0-canary.88
|
|
34
|
+
|
|
35
|
+
## 9.0.0-canary.87
|
|
36
|
+
|
|
37
|
+
## 9.0.0-canary.86
|
|
38
|
+
|
|
39
|
+
## 9.0.0-canary.85
|
|
40
|
+
|
|
41
|
+
## 9.0.0-canary.84
|
|
42
|
+
|
|
43
|
+
## 9.0.0-canary.83
|
|
44
|
+
|
|
45
|
+
### Patch Changes
|
|
46
|
+
|
|
47
|
+
- [#2374](https://github.com/graphcommerce-org/graphcommerce/pull/2374) [`e61e1f4`](https://github.com/graphcommerce-org/graphcommerce/commit/e61e1f4fb1086f7a6341b42502135abf1839e43d) - Default to permanent redirects unless specified ([@hnsr](https://github.com/hnsr))
|
|
48
|
+
|
|
49
|
+
## 9.0.0-canary.82
|
|
50
|
+
|
|
51
|
+
## 9.0.0-canary.81
|
|
52
|
+
|
|
53
|
+
### Minor Changes
|
|
54
|
+
|
|
55
|
+
- [#2373](https://github.com/graphcommerce-org/graphcommerce/pull/2373) [`53ffc91`](https://github.com/graphcommerce-org/graphcommerce/commit/53ffc91f9bfbe1183c002c62b1fe0c3f415d7b94) - Handle the case where one switches from using the default .html URL suffix, to not using one ([@hnsr](https://github.com/hnsr))
|
|
56
|
+
|
|
57
|
+
## 9.0.0-canary.80
|
|
58
|
+
|
|
59
|
+
## 9.0.0-canary.79
|
|
60
|
+
|
|
61
|
+
## 9.0.0-canary.78
|
|
62
|
+
|
|
63
|
+
## 9.0.0-canary.77
|
|
64
|
+
|
|
65
|
+
## 9.0.0-canary.76
|
|
66
|
+
|
|
67
|
+
## 9.0.0-canary.75
|
|
68
|
+
|
|
69
|
+
## 9.0.0-canary.74
|
|
70
|
+
|
|
71
|
+
## 9.0.0-canary.73
|
|
72
|
+
|
|
73
|
+
## 9.0.0-canary.72
|
|
74
|
+
|
|
75
|
+
## 9.0.0-canary.71
|
|
76
|
+
|
|
77
|
+
## 9.0.0-canary.70
|
|
78
|
+
|
|
79
|
+
## 9.0.0-canary.69
|
|
80
|
+
|
|
81
|
+
## 9.0.0-canary.68
|
|
82
|
+
|
|
83
|
+
## 9.0.0-canary.67
|
|
84
|
+
|
|
85
|
+
## 9.0.0-canary.66
|
|
86
|
+
|
|
87
|
+
## 9.0.0-canary.65
|
|
88
|
+
|
|
89
|
+
## 9.0.0-canary.64
|
|
90
|
+
|
|
91
|
+
## 9.0.0-canary.63
|
|
92
|
+
|
|
93
|
+
## 9.0.0-canary.62
|
|
94
|
+
|
|
95
|
+
## 9.0.0-canary.61
|
|
96
|
+
|
|
97
|
+
### Minor Changes
|
|
98
|
+
|
|
99
|
+
- [#2327](https://github.com/graphcommerce-org/graphcommerce/pull/2327) [`be719fc`](https://github.com/graphcommerce-org/graphcommerce/commit/be719fc465c8804ddcb720a93813262e3a292b69) - Implement CancelOrder mutation, add cancel order overlay to account section ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
|
|
100
|
+
|
|
101
|
+
## 9.0.0-canary.60
|
|
102
|
+
|
|
103
|
+
## 9.0.0-canary.59
|
|
104
|
+
|
|
105
|
+
## 9.0.0-canary.58
|
|
106
|
+
|
|
107
|
+
## 9.0.0-canary.57
|
|
108
|
+
|
|
109
|
+
## 9.0.0-canary.56
|
|
110
|
+
|
|
111
|
+
## 9.0.0-canary.55
|
|
112
|
+
|
|
113
|
+
## 9.0.0-canary.54
|
|
114
|
+
|
|
115
|
+
## 8.1.0-canary.53
|
|
116
|
+
|
|
117
|
+
## 8.1.0-canary.52
|
|
118
|
+
|
|
119
|
+
## 8.1.0-canary.51
|
|
120
|
+
|
|
121
|
+
## 8.1.0-canary.50
|
|
122
|
+
|
|
123
|
+
## 8.1.0-canary.49
|
|
124
|
+
|
|
125
|
+
## 8.1.0-canary.48
|
|
126
|
+
|
|
127
|
+
## 8.1.0-canary.47
|
|
128
|
+
|
|
129
|
+
## 8.1.0-canary.46
|
|
130
|
+
|
|
131
|
+
## 8.1.0-canary.45
|
|
132
|
+
|
|
133
|
+
## 8.1.0-canary.44
|
|
134
|
+
|
|
135
|
+
## 8.1.0-canary.43
|
|
136
|
+
|
|
137
|
+
## 8.1.0-canary.42
|
|
138
|
+
|
|
139
|
+
## 8.1.0-canary.41
|
|
140
|
+
|
|
141
|
+
## 8.1.0-canary.40
|
|
142
|
+
|
|
143
|
+
## 8.1.0-canary.39
|
|
144
|
+
|
|
145
|
+
## 8.1.0-canary.38
|
|
146
|
+
|
|
147
|
+
## 8.1.0-canary.37
|
|
148
|
+
|
|
149
|
+
## 8.1.0-canary.36
|
|
150
|
+
|
|
151
|
+
## 8.1.0-canary.35
|
|
152
|
+
|
|
153
|
+
### Minor Changes
|
|
154
|
+
|
|
155
|
+
- [#2301](https://github.com/graphcommerce-org/graphcommerce/pull/2301) [`47bb47b`](https://github.com/graphcommerce-org/graphcommerce/commit/47bb47bac4b3689a6859afbc587274d813e0b072) - Implement confirm email functionality ([@Giovanni-Schroevers](https://github.com/Giovanni-Schroevers))
|
|
156
|
+
|
|
157
|
+
## 8.1.0-canary.34
|
|
158
|
+
|
|
159
|
+
## 8.1.0-canary.33
|
|
160
|
+
|
|
161
|
+
## 8.1.0-canary.32
|
|
162
|
+
|
|
163
|
+
## 8.1.0-canary.31
|
|
164
|
+
|
|
165
|
+
## 8.1.0-canary.30
|
|
166
|
+
|
|
167
|
+
## 8.1.0-canary.29
|
|
168
|
+
|
|
169
|
+
## 8.1.0-canary.28
|
|
170
|
+
|
|
171
|
+
## 8.1.0-canary.27
|
|
172
|
+
|
|
173
|
+
## 8.1.0-canary.26
|
|
174
|
+
|
|
175
|
+
## 8.1.0-canary.25
|
|
176
|
+
|
|
177
|
+
## 8.1.0-canary.24
|
|
178
|
+
|
|
179
|
+
## 8.1.0-canary.23
|
|
180
|
+
|
|
181
|
+
## 8.1.0-canary.22
|
|
182
|
+
|
|
183
|
+
## 8.1.0-canary.21
|
|
184
|
+
|
|
185
|
+
## 8.1.0-canary.20
|
|
186
|
+
|
|
187
|
+
## 8.1.0-canary.19
|
|
188
|
+
|
|
189
|
+
## 8.1.0-canary.18
|
|
190
|
+
|
|
191
|
+
## 8.1.0-canary.17
|
|
192
|
+
|
|
193
|
+
## 8.1.0-canary.16
|
|
194
|
+
|
|
195
|
+
## 8.1.0-canary.15
|
|
196
|
+
|
|
197
|
+
## 8.1.0-canary.14
|
|
198
|
+
|
|
199
|
+
## 8.1.0-canary.13
|
|
200
|
+
|
|
201
|
+
## 8.1.0-canary.12
|
|
202
|
+
|
|
203
|
+
## 8.1.0-canary.11
|
|
204
|
+
|
|
205
|
+
## 8.1.0-canary.10
|
|
206
|
+
|
|
3
207
|
## 8.1.0-canary.9
|
|
4
208
|
|
|
5
209
|
## 8.1.0-canary.8
|
|
@@ -80,8 +284,7 @@
|
|
|
80
284
|
|
|
81
285
|
### Patch Changes
|
|
82
286
|
|
|
83
|
-
- [#2187](https://github.com/graphcommerce-org/graphcommerce/pull/2187) [`61f90af`](https://github.com/graphcommerce-org/graphcommerce/commit/61f90afc8bc229b2cd4793f724509783af138deb) - redirectOrNotFound would log the incorrect request URL
|
|
84
|
-
([@paales](https://github.com/paales))
|
|
287
|
+
- [#2187](https://github.com/graphcommerce-org/graphcommerce/pull/2187) [`61f90af`](https://github.com/graphcommerce-org/graphcommerce/commit/61f90afc8bc229b2cd4793f724509783af138deb) - redirectOrNotFound would log the incorrect request URL ([@paales](https://github.com/paales))
|
|
85
288
|
|
|
86
289
|
## 8.0.1-canary.4
|
|
87
290
|
|
|
@@ -95,18 +298,15 @@
|
|
|
95
298
|
|
|
96
299
|
### Patch Changes
|
|
97
300
|
|
|
98
|
-
- [#2187](https://github.com/graphcommerce-org/graphcommerce/pull/2187) [`61f90af`](https://github.com/graphcommerce-org/graphcommerce/commit/61f90afc8bc229b2cd4793f724509783af138deb) - redirectOrNotFound would log the incorrect request URL
|
|
99
|
-
([@paales](https://github.com/paales))
|
|
301
|
+
- [#2187](https://github.com/graphcommerce-org/graphcommerce/pull/2187) [`61f90af`](https://github.com/graphcommerce-org/graphcommerce/commit/61f90afc8bc229b2cd4793f724509783af138deb) - redirectOrNotFound would log the incorrect request URL ([@paales](https://github.com/paales))
|
|
100
302
|
|
|
101
303
|
## 8.0.0
|
|
102
304
|
|
|
103
305
|
### Patch Changes
|
|
104
306
|
|
|
105
|
-
- [#2067](https://github.com/graphcommerce-org/graphcommerce/pull/2067) [`3406794`](https://github.com/graphcommerce-org/graphcommerce/commit/340679434e0ff1033c8158ef03a091e06e20e6a9) - Prevent HandleRedirect errors by filtering out empty URL values from the candidates array.
|
|
106
|
-
([@carlocarels90](https://github.com/carlocarels90))
|
|
307
|
+
- [#2067](https://github.com/graphcommerce-org/graphcommerce/pull/2067) [`3406794`](https://github.com/graphcommerce-org/graphcommerce/commit/340679434e0ff1033c8158ef03a091e06e20e6a9) - Prevent HandleRedirect errors by filtering out empty URL values from the candidates array. ([@carlocarels90](https://github.com/carlocarels90))
|
|
107
308
|
|
|
108
|
-
- [#2140](https://github.com/graphcommerce-org/graphcommerce/pull/2140) [`b34d85c`](https://github.com/graphcommerce-org/graphcommerce/commit/b34d85c8c5403c6f49b506b714ee314b8344fd99) - Solve incorrect redirect when locale has own domain
|
|
109
|
-
([@hnsr](https://github.com/hnsr))
|
|
309
|
+
- [#2140](https://github.com/graphcommerce-org/graphcommerce/pull/2140) [`b34d85c`](https://github.com/graphcommerce-org/graphcommerce/commit/b34d85c8c5403c6f49b506b714ee314b8344fd99) - Solve incorrect redirect when locale has own domain ([@hnsr](https://github.com/hnsr))
|
|
110
310
|
|
|
111
311
|
## 8.0.0-canary.100
|
|
112
312
|
|
|
@@ -150,8 +350,7 @@
|
|
|
150
350
|
|
|
151
351
|
### Patch Changes
|
|
152
352
|
|
|
153
|
-
- [#2140](https://github.com/graphcommerce-org/graphcommerce/pull/2140) [`b34d85c`](https://github.com/graphcommerce-org/graphcommerce/commit/b34d85c8c5403c6f49b506b714ee314b8344fd99) - Fix incorrect redirect when locale has own domain
|
|
154
|
-
([@hnsr](https://github.com/hnsr))
|
|
353
|
+
- [#2140](https://github.com/graphcommerce-org/graphcommerce/pull/2140) [`b34d85c`](https://github.com/graphcommerce-org/graphcommerce/commit/b34d85c8c5403c6f49b506b714ee314b8344fd99) - Fix incorrect redirect when locale has own domain ([@hnsr](https://github.com/hnsr))
|
|
155
354
|
|
|
156
355
|
## 8.0.0-canary.80
|
|
157
356
|
|
|
@@ -1296,31 +1495,31 @@
|
|
|
1296
1495
|
All occurences of `<Trans>` and `t` need to be replaced:
|
|
1297
1496
|
|
|
1298
1497
|
```tsx
|
|
1299
|
-
import { Trans, t } from
|
|
1498
|
+
import { Trans, t } from '@lingui/macro'
|
|
1300
1499
|
|
|
1301
1500
|
function MyComponent() {
|
|
1302
|
-
const foo =
|
|
1501
|
+
const foo = 'bar'
|
|
1303
1502
|
return (
|
|
1304
1503
|
<div aria-label={t`Account ${foo}`}>
|
|
1305
1504
|
<Trans>My Translation {foo}</Trans>
|
|
1306
1505
|
</div>
|
|
1307
|
-
)
|
|
1506
|
+
)
|
|
1308
1507
|
}
|
|
1309
1508
|
```
|
|
1310
1509
|
|
|
1311
1510
|
Needs to be replaced with:
|
|
1312
1511
|
|
|
1313
1512
|
```tsx
|
|
1314
|
-
import { Trans } from
|
|
1315
|
-
import { i18n } from
|
|
1513
|
+
import { Trans } from '@lingui/react'
|
|
1514
|
+
import { i18n } from '@lingui/core'
|
|
1316
1515
|
|
|
1317
1516
|
function MyComponent() {
|
|
1318
|
-
const foo =
|
|
1517
|
+
const foo = 'bar'
|
|
1319
1518
|
return (
|
|
1320
1519
|
<div aria-label={i18n._(/* i18n */ `Account {foo}`, { foo })}>
|
|
1321
|
-
<Trans key=
|
|
1520
|
+
<Trans key='My Translation {foo}' values={{ foo }}></Trans>
|
|
1322
1521
|
</div>
|
|
1323
|
-
)
|
|
1522
|
+
)
|
|
1324
1523
|
}
|
|
1325
1524
|
```
|
|
1326
1525
|
|
|
@@ -1457,11 +1656,11 @@
|
|
|
1457
1656
|
defaultProps: {
|
|
1458
1657
|
round: true,
|
|
1459
1658
|
formatOptions: {
|
|
1460
|
-
style:
|
|
1659
|
+
style: 'decimal',
|
|
1461
1660
|
},
|
|
1462
1661
|
},
|
|
1463
1662
|
},
|
|
1464
|
-
})
|
|
1663
|
+
})
|
|
1465
1664
|
```
|
|
1466
1665
|
|
|
1467
1666
|
### Patch Changes
|
package/Money.tsx
CHANGED
|
@@ -1,50 +1,29 @@
|
|
|
1
1
|
import { useQuery } from '@graphcommerce/graphql'
|
|
2
|
-
import {
|
|
3
|
-
import { useThemeProps } from '@mui/material'
|
|
4
|
-
import { useMemo } from 'react'
|
|
2
|
+
import { CurrencyFormat, CurrencyFormatProps } from '@graphcommerce/next-ui'
|
|
5
3
|
import { MoneyFragment } from './Money.gql'
|
|
6
4
|
import { StoreConfigDocument } from './StoreConfig.gql'
|
|
7
5
|
|
|
8
6
|
type OverridableProps = {
|
|
9
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
10
7
|
round?: boolean
|
|
11
|
-
|
|
12
|
-
// eslint-disable-next-line react/no-unused-prop-types
|
|
13
|
-
formatOptions?: Intl.NumberFormatOptions
|
|
8
|
+
formatOptions?: Omit<CurrencyFormatProps, 'currency'>
|
|
14
9
|
}
|
|
15
10
|
|
|
16
11
|
export type MoneyProps = MoneyFragment & OverridableProps
|
|
17
12
|
|
|
18
|
-
const name = 'Money'
|
|
19
|
-
|
|
20
|
-
/** Expose the component to be exendable in your theme.components */
|
|
21
|
-
declare module '@mui/material/styles/components' {
|
|
22
|
-
interface Components {
|
|
23
|
-
Money?: Pick<ExtendableComponent<OverridableProps>, 'defaultProps'>
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
13
|
export function Money(props: MoneyProps) {
|
|
28
|
-
const { currency, value, round = false, formatOptions } =
|
|
29
|
-
|
|
14
|
+
const { currency, value, round = false, formatOptions } = props
|
|
30
15
|
const { data: config } = useQuery(StoreConfigDocument)
|
|
31
|
-
|
|
32
16
|
const digits = (value ?? 0) % 1 !== 0
|
|
33
17
|
|
|
34
|
-
const options: Intl.NumberFormatOptions = useMemo(
|
|
35
|
-
() => ({
|
|
36
|
-
style: 'currency',
|
|
37
|
-
currency: currency ?? config?.storeConfig?.base_currency_code ?? '',
|
|
38
|
-
...(round && !digits && { minimumFractionDigits: 0 }),
|
|
39
|
-
...(round && digits && { minimumFractionDigits: 2 }),
|
|
40
|
-
...(!round && { minimumFractionDigits: 2 }),
|
|
41
|
-
...formatOptions,
|
|
42
|
-
}),
|
|
43
|
-
[config?.storeConfig?.base_currency_code, currency, digits, formatOptions, round],
|
|
44
|
-
)
|
|
45
|
-
const numberFormatter = useNumberFormat(options)
|
|
46
|
-
|
|
47
18
|
if (typeof value === 'undefined' || value === null) return null
|
|
48
19
|
|
|
49
|
-
return
|
|
20
|
+
return (
|
|
21
|
+
<CurrencyFormat
|
|
22
|
+
currency={currency ?? config?.storeConfig?.base_currency_code ?? ''}
|
|
23
|
+
maximumFractionDigits={round && !digits ? 0 : 2}
|
|
24
|
+
{...formatOptions}
|
|
25
|
+
>
|
|
26
|
+
{value}
|
|
27
|
+
</CurrencyFormat>
|
|
28
|
+
)
|
|
50
29
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
fragment StoreConfigFragment on StoreConfig
|
|
1
|
+
fragment StoreConfigFragment on StoreConfig {
|
|
2
2
|
website_name
|
|
3
3
|
store_code
|
|
4
4
|
store_name
|
|
@@ -30,4 +30,9 @@ fragment StoreConfigFragment on StoreConfig @injectable {
|
|
|
30
30
|
grid_per_page
|
|
31
31
|
grid_per_page_values
|
|
32
32
|
list_per_page
|
|
33
|
+
create_account_confirmation
|
|
34
|
+
order_cancellation_enabled
|
|
35
|
+
order_cancellation_reasons {
|
|
36
|
+
description
|
|
37
|
+
}
|
|
33
38
|
}
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@graphcommerce/magento-store",
|
|
3
3
|
"homepage": "https://www.graphcommerce.org/",
|
|
4
4
|
"repository": "github:graphcommerce-org/graphcommerce",
|
|
5
|
-
"version": "
|
|
5
|
+
"version": "9.0.0-canary.101",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"prettier": "@graphcommerce/prettier-config-pwa",
|
|
8
8
|
"eslintConfig": {
|
|
@@ -12,13 +12,13 @@
|
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
"peerDependencies": {
|
|
15
|
-
"@graphcommerce/eslint-config-pwa": "^
|
|
16
|
-
"@graphcommerce/graphql": "^
|
|
17
|
-
"@graphcommerce/graphql-mesh": "^
|
|
18
|
-
"@graphcommerce/image": "^
|
|
19
|
-
"@graphcommerce/next-ui": "^
|
|
20
|
-
"@graphcommerce/prettier-config-pwa": "^
|
|
21
|
-
"@graphcommerce/typescript-config-pwa": "^
|
|
15
|
+
"@graphcommerce/eslint-config-pwa": "^9.0.0-canary.101",
|
|
16
|
+
"@graphcommerce/graphql": "^9.0.0-canary.101",
|
|
17
|
+
"@graphcommerce/graphql-mesh": "^9.0.0-canary.101",
|
|
18
|
+
"@graphcommerce/image": "^9.0.0-canary.101",
|
|
19
|
+
"@graphcommerce/next-ui": "^9.0.0-canary.101",
|
|
20
|
+
"@graphcommerce/prettier-config-pwa": "^9.0.0-canary.101",
|
|
21
|
+
"@graphcommerce/typescript-config-pwa": "^9.0.0-canary.101",
|
|
22
22
|
"@lingui/core": "^4.2.1",
|
|
23
23
|
"@lingui/macro": "^4.2.1",
|
|
24
24
|
"@lingui/react": "^4.2.1",
|
|
@@ -1,13 +1,39 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { setContext, type graphqlConfig as graphqlConfigType } from '@graphcommerce/graphql'
|
|
2
2
|
import type { FunctionPlugin, PluginConfig } from '@graphcommerce/next-config'
|
|
3
|
-
import { createStoreLink } from '../link/createStoreLink'
|
|
4
3
|
|
|
5
4
|
export const config: PluginConfig = {
|
|
6
5
|
type: 'function',
|
|
7
6
|
module: '@graphcommerce/graphql',
|
|
8
7
|
}
|
|
9
8
|
|
|
9
|
+
declare module '@graphcommerce/graphql/config' {
|
|
10
|
+
interface PreviewData {
|
|
11
|
+
magentoPreviewVersion?: string
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
10
15
|
export const graphqlConfig: FunctionPlugin<typeof graphqlConfigType> = (prev, conf) => {
|
|
11
16
|
const results = prev(conf)
|
|
12
|
-
|
|
17
|
+
|
|
18
|
+
const previewVersion = conf.previewData?.magentoPreviewVersion
|
|
19
|
+
|
|
20
|
+
return {
|
|
21
|
+
...results,
|
|
22
|
+
links: [
|
|
23
|
+
...results.links,
|
|
24
|
+
setContext((_, context) => {
|
|
25
|
+
if (!context.headers) context.headers = {}
|
|
26
|
+
context.headers.store = conf.storefront.magentoStoreCode
|
|
27
|
+
if (conf.preview) {
|
|
28
|
+
// To disable caching from the backend, we provide a bogus cache ID.
|
|
29
|
+
context.headers['x-magento-cache-id'] =
|
|
30
|
+
`random-cache-id${Math.random().toString(36).slice(2)}`
|
|
31
|
+
if (previewVersion) {
|
|
32
|
+
context.headers['preview-version'] = previewVersion
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return context
|
|
36
|
+
}),
|
|
37
|
+
],
|
|
38
|
+
}
|
|
13
39
|
}
|
|
@@ -23,6 +23,25 @@ const notFound = (from: string, reason: string) => {
|
|
|
23
23
|
return { notFound: true, revalidate: 60 * 20 } as const
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
const urlPrefix = (locale?: string) => {
|
|
27
|
+
const localeHasDomain = Boolean(storefrontConfig(locale)?.domain)
|
|
28
|
+
return localeHasDomain || locale === defaultLocale() ? '' : `/${locale}`
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const redirectTo = (
|
|
32
|
+
to: string,
|
|
33
|
+
permanent: boolean,
|
|
34
|
+
locale?: string,
|
|
35
|
+
): { redirect: Redirect; revalidate?: number | boolean } => {
|
|
36
|
+
console.log(
|
|
37
|
+
`[redirectTo]: ${permanent ? 'Permanent' : 'Temporary'} redirect to ${urlPrefix(locale)}${to}`,
|
|
38
|
+
)
|
|
39
|
+
return {
|
|
40
|
+
redirect: { destination: `${urlPrefix(locale)}${to}`, permanent },
|
|
41
|
+
revalidate: 60 * 20,
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
26
45
|
const redirect = (from: string, to: string, permanent: boolean, locale?: string) => {
|
|
27
46
|
const localeHasDomain = Boolean(storefrontConfig(locale)?.domain)
|
|
28
47
|
const prefix = localeHasDomain || locale === defaultLocale() ? '' : `/${locale}`
|
|
@@ -68,6 +87,11 @@ export async function redirectOrNotFound(
|
|
|
68
87
|
candidates.add(from.endsWith(suffix) ? from.slice(0, -suffix.length) : `${from}${suffix}`)
|
|
69
88
|
})
|
|
70
89
|
|
|
90
|
+
// Handle the case where we transition from using the default .html suffix, to not using one
|
|
91
|
+
if (from.endsWith('.html')) {
|
|
92
|
+
candidates.add(from.slice(0, -('.html'.length)))
|
|
93
|
+
}
|
|
94
|
+
|
|
71
95
|
const routePromises = [...candidates].filter(Boolean).map(
|
|
72
96
|
async (url) =>
|
|
73
97
|
(
|
|
@@ -100,8 +124,8 @@ export async function redirectOrNotFound(
|
|
|
100
124
|
? routeData.route.relative_url
|
|
101
125
|
: undefined
|
|
102
126
|
|
|
103
|
-
//
|
|
104
|
-
const permanent = routeData.route?.redirect_code === 301
|
|
127
|
+
// For implicit redirects, always use permanent, otherwise use the given redirect type
|
|
128
|
+
const permanent = !routeData.route?.redirect_code || routeData.route?.redirect_code === 301
|
|
105
129
|
|
|
106
130
|
if (
|
|
107
131
|
isTypename(routeData.route, [
|
package/link/createStoreLink.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { setContext } from '@graphcommerce/graphql'
|
|
2
|
-
import { localeToStore } from '../localeToStore'
|
|
3
|
-
|
|
4
|
-
/** Apollo link to set the store header in the context */
|
|
5
|
-
export const createStoreLink = (locale?: string) =>
|
|
6
|
-
setContext((_, context) => {
|
|
7
|
-
if (!context.headers) context.headers = {}
|
|
8
|
-
context.headers.store = localeToStore(locale)
|
|
9
|
-
return context
|
|
10
|
-
})
|