@scayle/storefront-nuxt 8.15.1 → 8.17.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 +141 -76
- package/dist/module.json +1 -1
- package/dist/module.mjs +2 -1
- package/dist/runtime/nitro/plugins/redirectOnError.d.ts +10 -0
- package/dist/runtime/nitro/plugins/redirectOnError.js +24 -0
- package/dist/runtime/server/middleware/bootstrap.js +1 -1
- package/dist/runtime/utils/zodSchema.d.ts +10 -0
- package/dist/runtime/utils/zodSchema.js +2 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,70 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 8.17.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
**@scayle/storefront-core v8.17.0**
|
|
8
|
+
|
|
9
|
+
- Minor
|
|
10
|
+
- Fix return type of `RpcMethodCall` to reflect that it returns a `Promise<TResult>` instead of `TResult`. This change emphasizes that `callRpc` in `RpcContext` is indeed an asynchronous operation.
|
|
11
|
+
- Patch
|
|
12
|
+
- Ensure that `pricePromotionKey` set in the right place when calling the deletion wishlist item operation of SAPI.
|
|
13
|
+
|
|
14
|
+
**Dependencies**
|
|
15
|
+
|
|
16
|
+
- Updated dependency to @scayle/unstorage-compression-driver@0.2.5
|
|
17
|
+
|
|
18
|
+
## 8.16.0
|
|
19
|
+
|
|
20
|
+
### Minor Changes
|
|
21
|
+
|
|
22
|
+
- [Redirects] Extend the redirects feature with a new option: `redirects.strategy`. This property can be set to two values: `before-request` and `on-missing`. When set to `before-request`, the server will check for potential redirects before processing each request. This is the current behavior and will also be used when no value is set. When `on-missing` is used, the server will check for redirects only if the response for the request is a 404.
|
|
23
|
+
|
|
24
|
+
To enable the new strategy, update your `nuxt.config.ts`.
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
export default defineNuxtConfig({
|
|
28
|
+
runtimeConfig: {
|
|
29
|
+
storefront: {
|
|
30
|
+
redirects: {
|
|
31
|
+
enabled: true,
|
|
32
|
+
strategy: 'on-missing',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
})
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Also, keep in mind that when this option is enabled, the redirect logic will only be executed when the request would otherwise result in a 404. There are three ways in which a 404 can occur.
|
|
40
|
+
|
|
41
|
+
1. No route found
|
|
42
|
+
|
|
43
|
+
If there is no matching route for the request's path, the framework will return a 404 response.
|
|
44
|
+
|
|
45
|
+
2. `Response` with 404 status
|
|
46
|
+
|
|
47
|
+
If the request handler returns a `Response` object with a `status` of 404, a 404 response will be returned to the client.
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
return new Response(null, { status: 404 })
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
3. Thrown H3Error with 404 status
|
|
54
|
+
|
|
55
|
+
If the request handler throws an H3Error with a `statusCode` 404, a 404 response will be returned to the client.
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { createError } from 'h3'
|
|
59
|
+
throw createError({ statusCode: 404 })
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Patch Changes
|
|
63
|
+
|
|
64
|
+
**@scayle/storefront-core v8.16.0**
|
|
65
|
+
|
|
66
|
+
**Dependencies**
|
|
67
|
+
|
|
3
68
|
## 8.15.1
|
|
4
69
|
|
|
5
70
|
### Patch Changes
|
|
@@ -433,28 +498,28 @@
|
|
|
433
498
|
**rpc-methods.ts**
|
|
434
499
|
|
|
435
500
|
```typescript
|
|
436
|
-
import type { RpcContext, RpcHandler } from
|
|
501
|
+
import type { RpcContext, RpcHandler } from '@scayle/storefront-nuxt'
|
|
437
502
|
|
|
438
503
|
export const foo: RpcHandler<string, number> = function testing(
|
|
439
504
|
param: string,
|
|
440
|
-
_: RpcContext
|
|
505
|
+
_: RpcContext,
|
|
441
506
|
) {
|
|
442
|
-
return param.length
|
|
443
|
-
}
|
|
507
|
+
return param.length
|
|
508
|
+
}
|
|
444
509
|
```
|
|
445
510
|
|
|
446
511
|
**module.ts**
|
|
447
512
|
|
|
448
513
|
```typescript
|
|
449
514
|
function setup() {
|
|
450
|
-
const resolver = createResolver(import.meta.url)
|
|
515
|
+
const resolver = createResolver(import.meta.url)
|
|
451
516
|
|
|
452
|
-
nuxt.hook(
|
|
517
|
+
nuxt.hook('storefront:custom-rpc:extend', (customRpcImports) => {
|
|
453
518
|
customRpcImports.push({
|
|
454
|
-
source: resolver.resolve(
|
|
455
|
-
names: [
|
|
456
|
-
})
|
|
457
|
-
})
|
|
519
|
+
source: resolver.resolve('./rpc-methods.ts'),
|
|
520
|
+
names: ['foo'],
|
|
521
|
+
})
|
|
522
|
+
})
|
|
458
523
|
}
|
|
459
524
|
```
|
|
460
525
|
|
|
@@ -676,23 +741,23 @@
|
|
|
676
741
|
storefront: {
|
|
677
742
|
// ...
|
|
678
743
|
redis: {
|
|
679
|
-
host:
|
|
744
|
+
host: 'localhost',
|
|
680
745
|
port: 6379,
|
|
681
|
-
prefix:
|
|
682
|
-
user:
|
|
683
|
-
password:
|
|
746
|
+
prefix: '',
|
|
747
|
+
user: '',
|
|
748
|
+
password: '',
|
|
684
749
|
sslTransit: false,
|
|
685
750
|
},
|
|
686
751
|
// ...
|
|
687
752
|
session: {
|
|
688
753
|
// ...
|
|
689
|
-
provider:
|
|
754
|
+
provider: 'redis',
|
|
690
755
|
},
|
|
691
756
|
},
|
|
692
757
|
// ...
|
|
693
758
|
},
|
|
694
759
|
// ...
|
|
695
|
-
})
|
|
760
|
+
})
|
|
696
761
|
```
|
|
697
762
|
|
|
698
763
|
- _Current Unified Storage Approach (`nuxt.config.ts`):_
|
|
@@ -706,13 +771,13 @@
|
|
|
706
771
|
// ...
|
|
707
772
|
storage: {
|
|
708
773
|
cache: {
|
|
709
|
-
driver:
|
|
710
|
-
host:
|
|
774
|
+
driver: 'redis',
|
|
775
|
+
host: 'localhost',
|
|
711
776
|
port: 6379,
|
|
712
777
|
},
|
|
713
778
|
session: {
|
|
714
|
-
driver:
|
|
715
|
-
host:
|
|
779
|
+
driver: 'redis',
|
|
780
|
+
host: 'localhost',
|
|
716
781
|
port: 6379,
|
|
717
782
|
},
|
|
718
783
|
// ...
|
|
@@ -722,7 +787,7 @@
|
|
|
722
787
|
// ...
|
|
723
788
|
},
|
|
724
789
|
// ...
|
|
725
|
-
})
|
|
790
|
+
})
|
|
726
791
|
```
|
|
727
792
|
|
|
728
793
|
- **\[💥 BREAKING\]** The composable `useSearch` has been replaced by `useStorefrontSearch`, consolidating and transitioning to SCAYLE Search v2.
|
|
@@ -789,9 +854,9 @@
|
|
|
789
854
|
|
|
790
855
|
```ts
|
|
791
856
|
const { activeFilters, applyFilters, resetFilterUrl, productConditions } =
|
|
792
|
-
useQueryFilterState()
|
|
857
|
+
useQueryFilterState()
|
|
793
858
|
|
|
794
|
-
applyFilters({ brand: 23, sale: true, maxPrice: 100, minPrice: 0 })
|
|
859
|
+
applyFilters({ brand: 23, sale: true, maxPrice: 100, minPrice: 0 })
|
|
795
860
|
```
|
|
796
861
|
|
|
797
862
|
- _Current Usage of `useFilter` and `useAppliedFilters`:_
|
|
@@ -804,20 +869,20 @@
|
|
|
804
869
|
resetFilters,
|
|
805
870
|
resetPriceFilter,
|
|
806
871
|
resetFilter,
|
|
807
|
-
} = useFilter()
|
|
872
|
+
} = useFilter()
|
|
808
873
|
|
|
809
|
-
applyPriceFilter([0, 100])
|
|
810
|
-
applyBooleanFilter(
|
|
811
|
-
applyAttributeFilter(
|
|
874
|
+
applyPriceFilter([0, 100])
|
|
875
|
+
applyBooleanFilter('sale', true)
|
|
876
|
+
applyAttributeFilter('brand', 23)
|
|
812
877
|
|
|
813
|
-
const route = useRoute()
|
|
878
|
+
const route = useRoute()
|
|
814
879
|
const {
|
|
815
880
|
appliedFilter,
|
|
816
881
|
appliedFiltersCount,
|
|
817
882
|
appliedAttributeValues,
|
|
818
883
|
appliedBooleanValues,
|
|
819
884
|
areFiltersApplied,
|
|
820
|
-
} = useAppliedFilters(route)
|
|
885
|
+
} = useAppliedFilters(route)
|
|
821
886
|
```
|
|
822
887
|
|
|
823
888
|
- **\[💥 BREAKING\]** The `getBadgeLabel` helper function has been removed, giving you more control over badge label display.
|
|
@@ -827,43 +892,43 @@
|
|
|
827
892
|
|
|
828
893
|
```ts
|
|
829
894
|
const BadgeLabel = {
|
|
830
|
-
NEW:
|
|
831
|
-
SOLD_OUT:
|
|
832
|
-
ONLINE_EXCLUSIVE:
|
|
833
|
-
SUSTAINABLE:
|
|
834
|
-
PREMIUM:
|
|
835
|
-
DEFAULT:
|
|
836
|
-
} as const
|
|
895
|
+
NEW: 'new',
|
|
896
|
+
SOLD_OUT: 'sold_out',
|
|
897
|
+
ONLINE_EXCLUSIVE: 'online_exclusive',
|
|
898
|
+
SUSTAINABLE: 'sustainable',
|
|
899
|
+
PREMIUM: 'premium',
|
|
900
|
+
DEFAULT: '',
|
|
901
|
+
} as const
|
|
837
902
|
|
|
838
903
|
type BadgeLabelParamsKeys =
|
|
839
|
-
|
|
|
840
|
-
|
|
|
841
|
-
|
|
|
842
|
-
|
|
|
843
|
-
|
|
|
844
|
-
type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean
|
|
904
|
+
| 'isNew'
|
|
905
|
+
| 'isSoldOut'
|
|
906
|
+
| 'isOnlineOnly'
|
|
907
|
+
| 'isSustainable'
|
|
908
|
+
| 'isPremium'
|
|
909
|
+
type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>
|
|
845
910
|
|
|
846
911
|
const getBadgeLabel = (params: BadgeLabelParams = {}): string => {
|
|
847
912
|
if (!params) {
|
|
848
|
-
return BadgeLabel.DEFAULT
|
|
913
|
+
return BadgeLabel.DEFAULT
|
|
849
914
|
}
|
|
850
915
|
const { isNew, isSoldOut, isOnlineOnly, isSustainable, isPremium } =
|
|
851
|
-
params
|
|
916
|
+
params
|
|
852
917
|
|
|
853
918
|
if (isNew) {
|
|
854
|
-
return BadgeLabel.NEW
|
|
919
|
+
return BadgeLabel.NEW
|
|
855
920
|
} else if (isSoldOut) {
|
|
856
|
-
return BadgeLabel.SOLD_OUT
|
|
921
|
+
return BadgeLabel.SOLD_OUT
|
|
857
922
|
} else if (isOnlineOnly) {
|
|
858
|
-
return BadgeLabel.ONLINE_EXCLUSIVE
|
|
923
|
+
return BadgeLabel.ONLINE_EXCLUSIVE
|
|
859
924
|
} else if (isSustainable) {
|
|
860
|
-
return BadgeLabel.SUSTAINABLE
|
|
925
|
+
return BadgeLabel.SUSTAINABLE
|
|
861
926
|
} else if (isPremium) {
|
|
862
|
-
return BadgeLabel.PREMIUM
|
|
927
|
+
return BadgeLabel.PREMIUM
|
|
863
928
|
} else {
|
|
864
|
-
return BadgeLabel.DEFAULT
|
|
929
|
+
return BadgeLabel.DEFAULT
|
|
865
930
|
}
|
|
866
|
-
}
|
|
931
|
+
}
|
|
867
932
|
```
|
|
868
933
|
|
|
869
934
|
- **\[💥 BREAKING\]** The `store` option in the module configuration has been removed. `œscayle/storefront-nuxt@7.84.0` introduced the `shops` option as a replacement, but maintained backward compatibility with the `store` option. Going forward, configuring shops must be done using the `shops` keyword.
|
|
@@ -887,7 +952,7 @@
|
|
|
887
952
|
// ...
|
|
888
953
|
},
|
|
889
954
|
// ...
|
|
890
|
-
})
|
|
955
|
+
})
|
|
891
956
|
```
|
|
892
957
|
|
|
893
958
|
- _Previous Environment Variables for Store Configuration:_
|
|
@@ -916,7 +981,7 @@
|
|
|
916
981
|
// ...
|
|
917
982
|
},
|
|
918
983
|
// ...
|
|
919
|
-
})
|
|
984
|
+
})
|
|
920
985
|
```
|
|
921
986
|
|
|
922
987
|
- _Current Environment Variables for Shops Configuration:_
|
|
@@ -936,8 +1001,8 @@
|
|
|
936
1001
|
```ts
|
|
937
1002
|
useProduct({
|
|
938
1003
|
// ...
|
|
939
|
-
key:
|
|
940
|
-
})
|
|
1004
|
+
key: 'productKey',
|
|
1005
|
+
})
|
|
941
1006
|
```
|
|
942
1007
|
|
|
943
1008
|
- _Current `key` as dedicated composables argument:_
|
|
@@ -947,8 +1012,8 @@
|
|
|
947
1012
|
{
|
|
948
1013
|
// ...
|
|
949
1014
|
},
|
|
950
|
-
|
|
951
|
-
)
|
|
1015
|
+
'productKey',
|
|
1016
|
+
)
|
|
952
1017
|
```
|
|
953
1018
|
|
|
954
1019
|
- **\[💥 BREAKING\]** Introducing a new feature flag `storefront.legacy.enableSessionMigration` to control the automatic migration of legacy session data, set to `false` by default. Starting with `@scayle/storefront-nuxt@7.68.0` Storefront uses unique session cookie names for each shop, simplifying implementation and enhancing stability.
|
|
@@ -965,27 +1030,27 @@
|
|
|
965
1030
|
- _Previous Usage of `handleIDPLoginCallback`:_
|
|
966
1031
|
|
|
967
1032
|
```ts
|
|
968
|
-
const { handleIDPLoginCallback } = await useIDP()
|
|
1033
|
+
const { handleIDPLoginCallback } = await useIDP()
|
|
969
1034
|
|
|
970
1035
|
watch(
|
|
971
1036
|
() => route.query,
|
|
972
1037
|
async (query) => {
|
|
973
1038
|
if (query.code && isString(query.code)) {
|
|
974
|
-
await handleIDPLoginCallback(query.code)
|
|
1039
|
+
await handleIDPLoginCallback(query.code)
|
|
975
1040
|
}
|
|
976
1041
|
},
|
|
977
|
-
{ immediate: true }
|
|
978
|
-
)
|
|
1042
|
+
{ immediate: true },
|
|
1043
|
+
)
|
|
979
1044
|
```
|
|
980
1045
|
|
|
981
1046
|
- _Current Usage of `loginIDP`:_
|
|
982
1047
|
|
|
983
1048
|
```ts
|
|
984
|
-
const { loginIDP } = useAuthentication(
|
|
1049
|
+
const { loginIDP } = useAuthentication('login')
|
|
985
1050
|
|
|
986
1051
|
onMounted(async () => {
|
|
987
|
-
await loginIDP(props.code)
|
|
988
|
-
})
|
|
1052
|
+
await loginIDP(props.code)
|
|
1053
|
+
})
|
|
989
1054
|
```
|
|
990
1055
|
|
|
991
1056
|
- **\[🧹 NON-BREAKING\]** Addressed various type resolution errors that were present when using the `@scayle/storefront-nuxt` package with different Node.js versions and module systems. These errors manifested as internal resolution errors or ESM dynamic import only warnings. With this fix, the package now more consistently resolves types correctly across Node.js 16 (CJS and ESM), and bundlers, ensuring a smoother developer experience.
|
|
@@ -995,17 +1060,17 @@
|
|
|
995
1060
|
- _Previous `useRpc` with `autoFetch`:_
|
|
996
1061
|
|
|
997
1062
|
```ts
|
|
998
|
-
useRpc(
|
|
1063
|
+
useRpc('rpcMethod', key, params, { autoFetch: true })
|
|
999
1064
|
|
|
1000
|
-
useUser({ autoFetch: true })
|
|
1065
|
+
useUser({ autoFetch: true })
|
|
1001
1066
|
```
|
|
1002
1067
|
|
|
1003
1068
|
- _Current `useRpc` with `immediate`:_
|
|
1004
1069
|
|
|
1005
1070
|
```ts
|
|
1006
|
-
useRpc(
|
|
1071
|
+
useRpc('rpcMethod', key, params, { immediate: true })
|
|
1007
1072
|
|
|
1008
|
-
useUser({ immediate: true })
|
|
1073
|
+
useUser({ immediate: true })
|
|
1009
1074
|
```
|
|
1010
1075
|
|
|
1011
1076
|
- **\[💥 BREAKING\]** The attribute `isCmsPreview` has been removed from `RpcContext`.
|
|
@@ -1025,18 +1090,18 @@
|
|
|
1025
1090
|
getSearchSuggestions,
|
|
1026
1091
|
fetching,
|
|
1027
1092
|
...searchData
|
|
1028
|
-
} = useStorefrontSearch(searchQuery, { key })
|
|
1093
|
+
} = useStorefrontSearch(searchQuery, { key })
|
|
1029
1094
|
|
|
1030
|
-
fetching.value
|
|
1095
|
+
fetching.value // true or false
|
|
1031
1096
|
```
|
|
1032
1097
|
|
|
1033
1098
|
- _Current `useStorefrontSearch` returning `status`:_
|
|
1034
1099
|
|
|
1035
1100
|
```ts
|
|
1036
1101
|
const { data, resolveSearch, getSearchSuggestions, status, ...searchData } =
|
|
1037
|
-
useStorefrontSearch(searchQuery, {}, key)
|
|
1102
|
+
useStorefrontSearch(searchQuery, {}, key)
|
|
1038
1103
|
|
|
1039
|
-
status.value
|
|
1104
|
+
status.value // 'idle', 'pending', 'error' or 'success'
|
|
1040
1105
|
```
|
|
1041
1106
|
|
|
1042
1107
|
- **\[💥 BREAKING\]** We've simplified composable caching and clarified the control you have over shared state behavior. The configuration option `disableDefaultGetCachedDataOverride` has been replaced with `legacy.enableDefaultGetCachedDataOverride`, and its logic has been reversed. Now, when `legacy.enableDefaultGetCachedDataOverride` is not set or set to `false`, the default behavior maintains the shared state functionality of `useRpc`, where multiple calls with the same key use the same cached data. Setting the option to `true` bypasses this shared caching, providing data isolation between calls. To maintain your existing caching behavior, simply change the value of `disableDefaultGetCachedDataOverride` to its opposite in your `nuxt.config.ts` file.
|
|
@@ -1061,7 +1126,7 @@
|
|
|
1061
1126
|
// ...
|
|
1062
1127
|
},
|
|
1063
1128
|
// ...
|
|
1064
|
-
})
|
|
1129
|
+
})
|
|
1065
1130
|
```
|
|
1066
1131
|
|
|
1067
1132
|
- _Current `enableDefaultGetCachedDataOverride`in `nuxt.config.ts`:_
|
|
@@ -1086,7 +1151,7 @@
|
|
|
1086
1151
|
// ...
|
|
1087
1152
|
},
|
|
1088
1153
|
// ...
|
|
1089
|
-
})
|
|
1154
|
+
})
|
|
1090
1155
|
```
|
|
1091
1156
|
|
|
1092
1157
|
- **\[💥 BREAKING\]** The `useRpc` composable has been updated to provide a more modern and robust data fetching experience, aligning its interface with the current and underlying [Nuxt 3 `useAsyncData`.](https://nuxt.com/docs/api/composables/use-async-data#return-values).
|
|
@@ -1108,7 +1173,7 @@
|
|
|
1108
1173
|
function myCustomRpc() {
|
|
1109
1174
|
// ...
|
|
1110
1175
|
|
|
1111
|
-
throw new BaseError(404)
|
|
1176
|
+
throw new BaseError(404)
|
|
1112
1177
|
}
|
|
1113
1178
|
```
|
|
1114
1179
|
|
|
@@ -1118,7 +1183,7 @@
|
|
|
1118
1183
|
function myCustomRpc() {
|
|
1119
1184
|
// ...
|
|
1120
1185
|
|
|
1121
|
-
return new Response(null, { status: 404 })
|
|
1186
|
+
return new Response(null, { status: 404 })
|
|
1122
1187
|
}
|
|
1123
1188
|
```
|
|
1124
1189
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -53,7 +53,7 @@ export default {
|
|
|
53
53
|
}`;
|
|
54
54
|
}
|
|
55
55
|
const PACKAGE_NAME = "@scayle/storefront-nuxt";
|
|
56
|
-
const PACKAGE_VERSION = "8.
|
|
56
|
+
const PACKAGE_VERSION = "8.17.0";
|
|
57
57
|
const logger = createConsola({
|
|
58
58
|
fancy: true,
|
|
59
59
|
formatOptions: {
|
|
@@ -137,6 +137,7 @@ async function nitroSetup(nitroConfig, config) {
|
|
|
137
137
|
});
|
|
138
138
|
nitroConfig.plugins = nitroConfig.plugins ?? [];
|
|
139
139
|
nitroConfig.plugins.push(resolve("./runtime/nitro/plugins/nitroLogger"));
|
|
140
|
+
nitroConfig.plugins.push(resolve("./runtime/nitro/plugins/redirectOnError"));
|
|
140
141
|
nitroConfig.plugins.push(
|
|
141
142
|
resolve("./runtime/nitro/plugins/nitroRuntimeStorageConfig")
|
|
142
143
|
);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Nitro plugin to handle redirecting on errors
|
|
3
|
+
*
|
|
4
|
+
* @param nitroApp The nitro app instance.
|
|
5
|
+
*
|
|
6
|
+
* @see https://nitro.build/guide/configuration#runtime-configuration
|
|
7
|
+
* @see https://nitro.build/guide/plugins
|
|
8
|
+
*/
|
|
9
|
+
declare const _default: import("nitropack").NitroAppPlugin;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineNitroPlugin } from "nitropack/runtime/plugin";
|
|
2
|
+
import { useRuntimeConfig } from "#imports";
|
|
3
|
+
import { useRedirects } from "../../server/middleware/redirects.js";
|
|
4
|
+
import { HttpStatusCode } from "@scayle/storefront-core";
|
|
5
|
+
import { getResponseStatus } from "h3";
|
|
6
|
+
export default defineNitroPlugin((nitroApp) => {
|
|
7
|
+
const config = useRuntimeConfig();
|
|
8
|
+
if (config.storefront.redirects?.enabled && config.storefront.redirects?.strategy === "on-missing") {
|
|
9
|
+
const originalErrorHandler = nitroApp.h3App.options.onError;
|
|
10
|
+
nitroApp.h3App.options.onError = async (error, event) => {
|
|
11
|
+
if (error.statusCode === HttpStatusCode.NOT_FOUND) {
|
|
12
|
+
await useRedirects(event);
|
|
13
|
+
}
|
|
14
|
+
if (originalErrorHandler) {
|
|
15
|
+
await originalErrorHandler(error, event);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
nitroApp.hooks.hook("beforeResponse", async (event) => {
|
|
19
|
+
if (getResponseStatus(event) === HttpStatusCode.NOT_FOUND) {
|
|
20
|
+
await useRedirects(event);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
@@ -202,7 +202,7 @@ export default defineEventHandler(async (event) => {
|
|
|
202
202
|
}
|
|
203
203
|
);
|
|
204
204
|
}
|
|
205
|
-
if ($storefrontConfig.redirects?.enabled && !path.startsWith(apiBasePath) && originalPath !== joinURL(config.app.baseURL, "/__nuxt_error")) {
|
|
205
|
+
if ($storefrontConfig.redirects?.enabled && (!$storefrontConfig.redirects?.strategy || $storefrontConfig.redirects?.strategy === "before-request") && !path.startsWith(apiBasePath) && originalPath !== joinURL(config.app.baseURL, "/__nuxt_error")) {
|
|
206
206
|
await tracer.startActiveSpan(
|
|
207
207
|
`storefront-nuxt.middleware/redirects`,
|
|
208
208
|
{},
|
|
@@ -4,12 +4,15 @@ import { type BuiltinDriverName } from 'unstorage';
|
|
|
4
4
|
export declare const RedirectsSchema: z.ZodObject<{
|
|
5
5
|
enabled: z.ZodBoolean;
|
|
6
6
|
queryParamWhitelist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
7
|
+
strategy: z.ZodOptional<z.ZodEnum<["before-request", "on-missing"]>>;
|
|
7
8
|
}, "strip", z.ZodTypeAny, {
|
|
8
9
|
enabled: boolean;
|
|
9
10
|
queryParamWhitelist?: string[] | undefined;
|
|
11
|
+
strategy?: "before-request" | "on-missing" | undefined;
|
|
10
12
|
}, {
|
|
11
13
|
enabled: boolean;
|
|
12
14
|
queryParamWhitelist?: string[] | undefined;
|
|
15
|
+
strategy?: "before-request" | "on-missing" | undefined;
|
|
13
16
|
}>;
|
|
14
17
|
declare const SessionSchema: z.ZodObject<{
|
|
15
18
|
/**
|
|
@@ -1063,12 +1066,15 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
|
|
|
1063
1066
|
redirects: z.ZodOptional<z.ZodObject<{
|
|
1064
1067
|
enabled: z.ZodBoolean;
|
|
1065
1068
|
queryParamWhitelist: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
1069
|
+
strategy: z.ZodOptional<z.ZodEnum<["before-request", "on-missing"]>>;
|
|
1066
1070
|
}, "strip", z.ZodTypeAny, {
|
|
1067
1071
|
enabled: boolean;
|
|
1068
1072
|
queryParamWhitelist?: string[] | undefined;
|
|
1073
|
+
strategy?: "before-request" | "on-missing" | undefined;
|
|
1069
1074
|
}, {
|
|
1070
1075
|
enabled: boolean;
|
|
1071
1076
|
queryParamWhitelist?: string[] | undefined;
|
|
1077
|
+
strategy?: "before-request" | "on-missing" | undefined;
|
|
1072
1078
|
}>>;
|
|
1073
1079
|
shops: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
1074
1080
|
idp: z.ZodOptional<z.ZodObject<{
|
|
@@ -1587,6 +1593,7 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
|
|
|
1587
1593
|
redirects?: {
|
|
1588
1594
|
enabled: boolean;
|
|
1589
1595
|
queryParamWhitelist?: string[] | undefined;
|
|
1596
|
+
strategy?: "before-request" | "on-missing" | undefined;
|
|
1590
1597
|
} | undefined;
|
|
1591
1598
|
}, {
|
|
1592
1599
|
shopSelector: "domain" | "path" | "path_or_default";
|
|
@@ -1671,6 +1678,7 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
|
|
|
1671
1678
|
redirects?: {
|
|
1672
1679
|
enabled: boolean;
|
|
1673
1680
|
queryParamWhitelist?: string[] | undefined;
|
|
1681
|
+
strategy?: "before-request" | "on-missing" | undefined;
|
|
1674
1682
|
} | undefined;
|
|
1675
1683
|
}>, z.ZodObject<{
|
|
1676
1684
|
session: z.ZodOptional<z.ZodObject<{
|
|
@@ -2259,6 +2267,7 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
|
|
|
2259
2267
|
redirects?: {
|
|
2260
2268
|
enabled: boolean;
|
|
2261
2269
|
queryParamWhitelist?: string[] | undefined;
|
|
2270
|
+
strategy?: "before-request" | "on-missing" | undefined;
|
|
2262
2271
|
} | undefined;
|
|
2263
2272
|
} & {
|
|
2264
2273
|
oauth: {
|
|
@@ -2432,6 +2441,7 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
|
|
|
2432
2441
|
redirects?: {
|
|
2433
2442
|
enabled: boolean;
|
|
2434
2443
|
queryParamWhitelist?: string[] | undefined;
|
|
2444
|
+
strategy?: "before-request" | "on-missing" | undefined;
|
|
2435
2445
|
} | undefined;
|
|
2436
2446
|
} & {
|
|
2437
2447
|
oauth: {
|
|
@@ -2,7 +2,8 @@ import { z } from "zod";
|
|
|
2
2
|
import { builtinDrivers } from "unstorage";
|
|
3
3
|
export const RedirectsSchema = z.object({
|
|
4
4
|
enabled: z.boolean(),
|
|
5
|
-
queryParamWhitelist: z.array(z.string()).optional()
|
|
5
|
+
queryParamWhitelist: z.array(z.string()).optional(),
|
|
6
|
+
strategy: z.enum(["before-request", "on-missing"]).optional()
|
|
6
7
|
});
|
|
7
8
|
const SessionSchema = z.object({
|
|
8
9
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "8.
|
|
4
|
+
"version": "8.17.0",
|
|
5
5
|
"description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
|
|
6
6
|
"author": "SCAYLE Commerce Engine",
|
|
7
7
|
"license": "MIT",
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"@opentelemetry/api": "^1.9.0",
|
|
83
83
|
"@scayle/h3-session": "0.6.0",
|
|
84
|
-
"@scayle/storefront-core": "8.
|
|
85
|
-
"@scayle/unstorage-compression-driver": "^0.2.
|
|
84
|
+
"@scayle/storefront-core": "8.17.0",
|
|
85
|
+
"@scayle/unstorage-compression-driver": "^0.2.5",
|
|
86
86
|
"@vercel/nft": "0.29.2",
|
|
87
87
|
"@vueuse/core": "13.0.0",
|
|
88
88
|
"consola": "^3.2.3",
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"@scayle/eslint-config-storefront": "4.5.0",
|
|
110
110
|
"@scayle/eslint-plugin-vue-composable": "0.2.1",
|
|
111
111
|
"@scayle/unstorage-scayle-kv-driver": "0.1.1",
|
|
112
|
-
"@types/node": "22.
|
|
112
|
+
"@types/node": "22.14.0",
|
|
113
113
|
"dprint": "0.49.1",
|
|
114
114
|
"eslint-formatter-gitlab": "5.1.0",
|
|
115
115
|
"eslint": "9.23.0",
|
|
@@ -117,7 +117,7 @@
|
|
|
117
117
|
"h3": "1.15.0",
|
|
118
118
|
"nitropack": "2.10.4",
|
|
119
119
|
"node-mocks-http": "1.16.2",
|
|
120
|
-
"nuxi": "3.24.
|
|
120
|
+
"nuxi": "3.24.1",
|
|
121
121
|
"nuxt": "3.15.4",
|
|
122
122
|
"publint": "0.2.12",
|
|
123
123
|
"typescript": "5.8.2",
|