@scayle/storefront-nuxt 8.15.0 → 8.16.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 +134 -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 +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,63 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 8.16.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [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.
|
|
8
|
+
|
|
9
|
+
To enable the new strategy, update your `nuxt.config.ts`.
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
export default defineNuxtConfig({
|
|
13
|
+
runtimeConfig: {
|
|
14
|
+
storefront: {
|
|
15
|
+
redirects: {
|
|
16
|
+
enabled: true,
|
|
17
|
+
strategy: 'on-missing',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
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.
|
|
25
|
+
|
|
26
|
+
1. No route found
|
|
27
|
+
|
|
28
|
+
If there is no matching route for the request's path, the framework will return a 404 response.
|
|
29
|
+
|
|
30
|
+
2. `Response` with 404 status
|
|
31
|
+
|
|
32
|
+
If the request handler returns a `Response` object with a `status` of 404, a 404 response will be returned to the client.
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
return new Response(null, { status: 404 })
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
3. Thrown H3Error with 404 status
|
|
39
|
+
|
|
40
|
+
If the request handler throws an H3Error with a `statusCode` 404, a 404 response will be returned to the client.
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import { createError } from 'h3'
|
|
44
|
+
throw createError({ statusCode: 404 })
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Patch Changes
|
|
48
|
+
|
|
49
|
+
**@scayle/storefront-core v8.16.0**
|
|
50
|
+
|
|
51
|
+
**Dependencies**
|
|
52
|
+
|
|
53
|
+
## 8.15.1
|
|
54
|
+
|
|
55
|
+
### Patch Changes
|
|
56
|
+
|
|
57
|
+
**@scayle/storefront-core v8.15.1**
|
|
58
|
+
|
|
59
|
+
**Dependencies**
|
|
60
|
+
|
|
3
61
|
## 8.15.0
|
|
4
62
|
|
|
5
63
|
### Patch Changes
|
|
@@ -425,28 +483,28 @@
|
|
|
425
483
|
**rpc-methods.ts**
|
|
426
484
|
|
|
427
485
|
```typescript
|
|
428
|
-
import type { RpcContext, RpcHandler } from
|
|
486
|
+
import type { RpcContext, RpcHandler } from '@scayle/storefront-nuxt'
|
|
429
487
|
|
|
430
488
|
export const foo: RpcHandler<string, number> = function testing(
|
|
431
489
|
param: string,
|
|
432
|
-
_: RpcContext
|
|
490
|
+
_: RpcContext,
|
|
433
491
|
) {
|
|
434
|
-
return param.length
|
|
435
|
-
}
|
|
492
|
+
return param.length
|
|
493
|
+
}
|
|
436
494
|
```
|
|
437
495
|
|
|
438
496
|
**module.ts**
|
|
439
497
|
|
|
440
498
|
```typescript
|
|
441
499
|
function setup() {
|
|
442
|
-
const resolver = createResolver(import.meta.url)
|
|
500
|
+
const resolver = createResolver(import.meta.url)
|
|
443
501
|
|
|
444
|
-
nuxt.hook(
|
|
502
|
+
nuxt.hook('storefront:custom-rpc:extend', (customRpcImports) => {
|
|
445
503
|
customRpcImports.push({
|
|
446
|
-
source: resolver.resolve(
|
|
447
|
-
names: [
|
|
448
|
-
})
|
|
449
|
-
})
|
|
504
|
+
source: resolver.resolve('./rpc-methods.ts'),
|
|
505
|
+
names: ['foo'],
|
|
506
|
+
})
|
|
507
|
+
})
|
|
450
508
|
}
|
|
451
509
|
```
|
|
452
510
|
|
|
@@ -668,23 +726,23 @@
|
|
|
668
726
|
storefront: {
|
|
669
727
|
// ...
|
|
670
728
|
redis: {
|
|
671
|
-
host:
|
|
729
|
+
host: 'localhost',
|
|
672
730
|
port: 6379,
|
|
673
|
-
prefix:
|
|
674
|
-
user:
|
|
675
|
-
password:
|
|
731
|
+
prefix: '',
|
|
732
|
+
user: '',
|
|
733
|
+
password: '',
|
|
676
734
|
sslTransit: false,
|
|
677
735
|
},
|
|
678
736
|
// ...
|
|
679
737
|
session: {
|
|
680
738
|
// ...
|
|
681
|
-
provider:
|
|
739
|
+
provider: 'redis',
|
|
682
740
|
},
|
|
683
741
|
},
|
|
684
742
|
// ...
|
|
685
743
|
},
|
|
686
744
|
// ...
|
|
687
|
-
})
|
|
745
|
+
})
|
|
688
746
|
```
|
|
689
747
|
|
|
690
748
|
- _Current Unified Storage Approach (`nuxt.config.ts`):_
|
|
@@ -698,13 +756,13 @@
|
|
|
698
756
|
// ...
|
|
699
757
|
storage: {
|
|
700
758
|
cache: {
|
|
701
|
-
driver:
|
|
702
|
-
host:
|
|
759
|
+
driver: 'redis',
|
|
760
|
+
host: 'localhost',
|
|
703
761
|
port: 6379,
|
|
704
762
|
},
|
|
705
763
|
session: {
|
|
706
|
-
driver:
|
|
707
|
-
host:
|
|
764
|
+
driver: 'redis',
|
|
765
|
+
host: 'localhost',
|
|
708
766
|
port: 6379,
|
|
709
767
|
},
|
|
710
768
|
// ...
|
|
@@ -714,7 +772,7 @@
|
|
|
714
772
|
// ...
|
|
715
773
|
},
|
|
716
774
|
// ...
|
|
717
|
-
})
|
|
775
|
+
})
|
|
718
776
|
```
|
|
719
777
|
|
|
720
778
|
- **\[💥 BREAKING\]** The composable `useSearch` has been replaced by `useStorefrontSearch`, consolidating and transitioning to SCAYLE Search v2.
|
|
@@ -781,9 +839,9 @@
|
|
|
781
839
|
|
|
782
840
|
```ts
|
|
783
841
|
const { activeFilters, applyFilters, resetFilterUrl, productConditions } =
|
|
784
|
-
useQueryFilterState()
|
|
842
|
+
useQueryFilterState()
|
|
785
843
|
|
|
786
|
-
applyFilters({ brand: 23, sale: true, maxPrice: 100, minPrice: 0 })
|
|
844
|
+
applyFilters({ brand: 23, sale: true, maxPrice: 100, minPrice: 0 })
|
|
787
845
|
```
|
|
788
846
|
|
|
789
847
|
- _Current Usage of `useFilter` and `useAppliedFilters`:_
|
|
@@ -796,20 +854,20 @@
|
|
|
796
854
|
resetFilters,
|
|
797
855
|
resetPriceFilter,
|
|
798
856
|
resetFilter,
|
|
799
|
-
} = useFilter()
|
|
857
|
+
} = useFilter()
|
|
800
858
|
|
|
801
|
-
applyPriceFilter([0, 100])
|
|
802
|
-
applyBooleanFilter(
|
|
803
|
-
applyAttributeFilter(
|
|
859
|
+
applyPriceFilter([0, 100])
|
|
860
|
+
applyBooleanFilter('sale', true)
|
|
861
|
+
applyAttributeFilter('brand', 23)
|
|
804
862
|
|
|
805
|
-
const route = useRoute()
|
|
863
|
+
const route = useRoute()
|
|
806
864
|
const {
|
|
807
865
|
appliedFilter,
|
|
808
866
|
appliedFiltersCount,
|
|
809
867
|
appliedAttributeValues,
|
|
810
868
|
appliedBooleanValues,
|
|
811
869
|
areFiltersApplied,
|
|
812
|
-
} = useAppliedFilters(route)
|
|
870
|
+
} = useAppliedFilters(route)
|
|
813
871
|
```
|
|
814
872
|
|
|
815
873
|
- **\[💥 BREAKING\]** The `getBadgeLabel` helper function has been removed, giving you more control over badge label display.
|
|
@@ -819,43 +877,43 @@
|
|
|
819
877
|
|
|
820
878
|
```ts
|
|
821
879
|
const BadgeLabel = {
|
|
822
|
-
NEW:
|
|
823
|
-
SOLD_OUT:
|
|
824
|
-
ONLINE_EXCLUSIVE:
|
|
825
|
-
SUSTAINABLE:
|
|
826
|
-
PREMIUM:
|
|
827
|
-
DEFAULT:
|
|
828
|
-
} as const
|
|
880
|
+
NEW: 'new',
|
|
881
|
+
SOLD_OUT: 'sold_out',
|
|
882
|
+
ONLINE_EXCLUSIVE: 'online_exclusive',
|
|
883
|
+
SUSTAINABLE: 'sustainable',
|
|
884
|
+
PREMIUM: 'premium',
|
|
885
|
+
DEFAULT: '',
|
|
886
|
+
} as const
|
|
829
887
|
|
|
830
888
|
type BadgeLabelParamsKeys =
|
|
831
|
-
|
|
|
832
|
-
|
|
|
833
|
-
|
|
|
834
|
-
|
|
|
835
|
-
|
|
|
836
|
-
type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean
|
|
889
|
+
| 'isNew'
|
|
890
|
+
| 'isSoldOut'
|
|
891
|
+
| 'isOnlineOnly'
|
|
892
|
+
| 'isSustainable'
|
|
893
|
+
| 'isPremium'
|
|
894
|
+
type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>
|
|
837
895
|
|
|
838
896
|
const getBadgeLabel = (params: BadgeLabelParams = {}): string => {
|
|
839
897
|
if (!params) {
|
|
840
|
-
return BadgeLabel.DEFAULT
|
|
898
|
+
return BadgeLabel.DEFAULT
|
|
841
899
|
}
|
|
842
900
|
const { isNew, isSoldOut, isOnlineOnly, isSustainable, isPremium } =
|
|
843
|
-
params
|
|
901
|
+
params
|
|
844
902
|
|
|
845
903
|
if (isNew) {
|
|
846
|
-
return BadgeLabel.NEW
|
|
904
|
+
return BadgeLabel.NEW
|
|
847
905
|
} else if (isSoldOut) {
|
|
848
|
-
return BadgeLabel.SOLD_OUT
|
|
906
|
+
return BadgeLabel.SOLD_OUT
|
|
849
907
|
} else if (isOnlineOnly) {
|
|
850
|
-
return BadgeLabel.ONLINE_EXCLUSIVE
|
|
908
|
+
return BadgeLabel.ONLINE_EXCLUSIVE
|
|
851
909
|
} else if (isSustainable) {
|
|
852
|
-
return BadgeLabel.SUSTAINABLE
|
|
910
|
+
return BadgeLabel.SUSTAINABLE
|
|
853
911
|
} else if (isPremium) {
|
|
854
|
-
return BadgeLabel.PREMIUM
|
|
912
|
+
return BadgeLabel.PREMIUM
|
|
855
913
|
} else {
|
|
856
|
-
return BadgeLabel.DEFAULT
|
|
914
|
+
return BadgeLabel.DEFAULT
|
|
857
915
|
}
|
|
858
|
-
}
|
|
916
|
+
}
|
|
859
917
|
```
|
|
860
918
|
|
|
861
919
|
- **\[💥 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.
|
|
@@ -879,7 +937,7 @@
|
|
|
879
937
|
// ...
|
|
880
938
|
},
|
|
881
939
|
// ...
|
|
882
|
-
})
|
|
940
|
+
})
|
|
883
941
|
```
|
|
884
942
|
|
|
885
943
|
- _Previous Environment Variables for Store Configuration:_
|
|
@@ -908,7 +966,7 @@
|
|
|
908
966
|
// ...
|
|
909
967
|
},
|
|
910
968
|
// ...
|
|
911
|
-
})
|
|
969
|
+
})
|
|
912
970
|
```
|
|
913
971
|
|
|
914
972
|
- _Current Environment Variables for Shops Configuration:_
|
|
@@ -928,8 +986,8 @@
|
|
|
928
986
|
```ts
|
|
929
987
|
useProduct({
|
|
930
988
|
// ...
|
|
931
|
-
key:
|
|
932
|
-
})
|
|
989
|
+
key: 'productKey',
|
|
990
|
+
})
|
|
933
991
|
```
|
|
934
992
|
|
|
935
993
|
- _Current `key` as dedicated composables argument:_
|
|
@@ -939,8 +997,8 @@
|
|
|
939
997
|
{
|
|
940
998
|
// ...
|
|
941
999
|
},
|
|
942
|
-
|
|
943
|
-
)
|
|
1000
|
+
'productKey',
|
|
1001
|
+
)
|
|
944
1002
|
```
|
|
945
1003
|
|
|
946
1004
|
- **\[💥 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.
|
|
@@ -957,27 +1015,27 @@
|
|
|
957
1015
|
- _Previous Usage of `handleIDPLoginCallback`:_
|
|
958
1016
|
|
|
959
1017
|
```ts
|
|
960
|
-
const { handleIDPLoginCallback } = await useIDP()
|
|
1018
|
+
const { handleIDPLoginCallback } = await useIDP()
|
|
961
1019
|
|
|
962
1020
|
watch(
|
|
963
1021
|
() => route.query,
|
|
964
1022
|
async (query) => {
|
|
965
1023
|
if (query.code && isString(query.code)) {
|
|
966
|
-
await handleIDPLoginCallback(query.code)
|
|
1024
|
+
await handleIDPLoginCallback(query.code)
|
|
967
1025
|
}
|
|
968
1026
|
},
|
|
969
|
-
{ immediate: true }
|
|
970
|
-
)
|
|
1027
|
+
{ immediate: true },
|
|
1028
|
+
)
|
|
971
1029
|
```
|
|
972
1030
|
|
|
973
1031
|
- _Current Usage of `loginIDP`:_
|
|
974
1032
|
|
|
975
1033
|
```ts
|
|
976
|
-
const { loginIDP } = useAuthentication(
|
|
1034
|
+
const { loginIDP } = useAuthentication('login')
|
|
977
1035
|
|
|
978
1036
|
onMounted(async () => {
|
|
979
|
-
await loginIDP(props.code)
|
|
980
|
-
})
|
|
1037
|
+
await loginIDP(props.code)
|
|
1038
|
+
})
|
|
981
1039
|
```
|
|
982
1040
|
|
|
983
1041
|
- **\[🧹 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.
|
|
@@ -987,17 +1045,17 @@
|
|
|
987
1045
|
- _Previous `useRpc` with `autoFetch`:_
|
|
988
1046
|
|
|
989
1047
|
```ts
|
|
990
|
-
useRpc(
|
|
1048
|
+
useRpc('rpcMethod', key, params, { autoFetch: true })
|
|
991
1049
|
|
|
992
|
-
useUser({ autoFetch: true })
|
|
1050
|
+
useUser({ autoFetch: true })
|
|
993
1051
|
```
|
|
994
1052
|
|
|
995
1053
|
- _Current `useRpc` with `immediate`:_
|
|
996
1054
|
|
|
997
1055
|
```ts
|
|
998
|
-
useRpc(
|
|
1056
|
+
useRpc('rpcMethod', key, params, { immediate: true })
|
|
999
1057
|
|
|
1000
|
-
useUser({ immediate: true })
|
|
1058
|
+
useUser({ immediate: true })
|
|
1001
1059
|
```
|
|
1002
1060
|
|
|
1003
1061
|
- **\[💥 BREAKING\]** The attribute `isCmsPreview` has been removed from `RpcContext`.
|
|
@@ -1017,18 +1075,18 @@
|
|
|
1017
1075
|
getSearchSuggestions,
|
|
1018
1076
|
fetching,
|
|
1019
1077
|
...searchData
|
|
1020
|
-
} = useStorefrontSearch(searchQuery, { key })
|
|
1078
|
+
} = useStorefrontSearch(searchQuery, { key })
|
|
1021
1079
|
|
|
1022
|
-
fetching.value
|
|
1080
|
+
fetching.value // true or false
|
|
1023
1081
|
```
|
|
1024
1082
|
|
|
1025
1083
|
- _Current `useStorefrontSearch` returning `status`:_
|
|
1026
1084
|
|
|
1027
1085
|
```ts
|
|
1028
1086
|
const { data, resolveSearch, getSearchSuggestions, status, ...searchData } =
|
|
1029
|
-
useStorefrontSearch(searchQuery, {}, key)
|
|
1087
|
+
useStorefrontSearch(searchQuery, {}, key)
|
|
1030
1088
|
|
|
1031
|
-
status.value
|
|
1089
|
+
status.value // 'idle', 'pending', 'error' or 'success'
|
|
1032
1090
|
```
|
|
1033
1091
|
|
|
1034
1092
|
- **\[💥 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.
|
|
@@ -1053,7 +1111,7 @@
|
|
|
1053
1111
|
// ...
|
|
1054
1112
|
},
|
|
1055
1113
|
// ...
|
|
1056
|
-
})
|
|
1114
|
+
})
|
|
1057
1115
|
```
|
|
1058
1116
|
|
|
1059
1117
|
- _Current `enableDefaultGetCachedDataOverride`in `nuxt.config.ts`:_
|
|
@@ -1078,7 +1136,7 @@
|
|
|
1078
1136
|
// ...
|
|
1079
1137
|
},
|
|
1080
1138
|
// ...
|
|
1081
|
-
})
|
|
1139
|
+
})
|
|
1082
1140
|
```
|
|
1083
1141
|
|
|
1084
1142
|
- **\[💥 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).
|
|
@@ -1100,7 +1158,7 @@
|
|
|
1100
1158
|
function myCustomRpc() {
|
|
1101
1159
|
// ...
|
|
1102
1160
|
|
|
1103
|
-
throw new BaseError(404)
|
|
1161
|
+
throw new BaseError(404)
|
|
1104
1162
|
}
|
|
1105
1163
|
```
|
|
1106
1164
|
|
|
@@ -1110,7 +1168,7 @@
|
|
|
1110
1168
|
function myCustomRpc() {
|
|
1111
1169
|
// ...
|
|
1112
1170
|
|
|
1113
|
-
return new Response(null, { status: 404 })
|
|
1171
|
+
return new Response(null, { status: 404 })
|
|
1114
1172
|
}
|
|
1115
1173
|
```
|
|
1116
1174
|
|
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.16.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.16.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,7 +81,7 @@
|
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"@opentelemetry/api": "^1.9.0",
|
|
83
83
|
"@scayle/h3-session": "0.6.0",
|
|
84
|
-
"@scayle/storefront-core": "8.
|
|
84
|
+
"@scayle/storefront-core": "8.16.0",
|
|
85
85
|
"@scayle/unstorage-compression-driver": "^0.2.4",
|
|
86
86
|
"@vercel/nft": "0.29.2",
|
|
87
87
|
"@vueuse/core": "13.0.0",
|
|
@@ -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",
|