@scayle/storefront-nuxt 8.15.1 → 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 +126 -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,55 @@
|
|
|
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
|
+
|
|
3
53
|
## 8.15.1
|
|
4
54
|
|
|
5
55
|
### Patch Changes
|
|
@@ -433,28 +483,28 @@
|
|
|
433
483
|
**rpc-methods.ts**
|
|
434
484
|
|
|
435
485
|
```typescript
|
|
436
|
-
import type { RpcContext, RpcHandler } from
|
|
486
|
+
import type { RpcContext, RpcHandler } from '@scayle/storefront-nuxt'
|
|
437
487
|
|
|
438
488
|
export const foo: RpcHandler<string, number> = function testing(
|
|
439
489
|
param: string,
|
|
440
|
-
_: RpcContext
|
|
490
|
+
_: RpcContext,
|
|
441
491
|
) {
|
|
442
|
-
return param.length
|
|
443
|
-
}
|
|
492
|
+
return param.length
|
|
493
|
+
}
|
|
444
494
|
```
|
|
445
495
|
|
|
446
496
|
**module.ts**
|
|
447
497
|
|
|
448
498
|
```typescript
|
|
449
499
|
function setup() {
|
|
450
|
-
const resolver = createResolver(import.meta.url)
|
|
500
|
+
const resolver = createResolver(import.meta.url)
|
|
451
501
|
|
|
452
|
-
nuxt.hook(
|
|
502
|
+
nuxt.hook('storefront:custom-rpc:extend', (customRpcImports) => {
|
|
453
503
|
customRpcImports.push({
|
|
454
|
-
source: resolver.resolve(
|
|
455
|
-
names: [
|
|
456
|
-
})
|
|
457
|
-
})
|
|
504
|
+
source: resolver.resolve('./rpc-methods.ts'),
|
|
505
|
+
names: ['foo'],
|
|
506
|
+
})
|
|
507
|
+
})
|
|
458
508
|
}
|
|
459
509
|
```
|
|
460
510
|
|
|
@@ -676,23 +726,23 @@
|
|
|
676
726
|
storefront: {
|
|
677
727
|
// ...
|
|
678
728
|
redis: {
|
|
679
|
-
host:
|
|
729
|
+
host: 'localhost',
|
|
680
730
|
port: 6379,
|
|
681
|
-
prefix:
|
|
682
|
-
user:
|
|
683
|
-
password:
|
|
731
|
+
prefix: '',
|
|
732
|
+
user: '',
|
|
733
|
+
password: '',
|
|
684
734
|
sslTransit: false,
|
|
685
735
|
},
|
|
686
736
|
// ...
|
|
687
737
|
session: {
|
|
688
738
|
// ...
|
|
689
|
-
provider:
|
|
739
|
+
provider: 'redis',
|
|
690
740
|
},
|
|
691
741
|
},
|
|
692
742
|
// ...
|
|
693
743
|
},
|
|
694
744
|
// ...
|
|
695
|
-
})
|
|
745
|
+
})
|
|
696
746
|
```
|
|
697
747
|
|
|
698
748
|
- _Current Unified Storage Approach (`nuxt.config.ts`):_
|
|
@@ -706,13 +756,13 @@
|
|
|
706
756
|
// ...
|
|
707
757
|
storage: {
|
|
708
758
|
cache: {
|
|
709
|
-
driver:
|
|
710
|
-
host:
|
|
759
|
+
driver: 'redis',
|
|
760
|
+
host: 'localhost',
|
|
711
761
|
port: 6379,
|
|
712
762
|
},
|
|
713
763
|
session: {
|
|
714
|
-
driver:
|
|
715
|
-
host:
|
|
764
|
+
driver: 'redis',
|
|
765
|
+
host: 'localhost',
|
|
716
766
|
port: 6379,
|
|
717
767
|
},
|
|
718
768
|
// ...
|
|
@@ -722,7 +772,7 @@
|
|
|
722
772
|
// ...
|
|
723
773
|
},
|
|
724
774
|
// ...
|
|
725
|
-
})
|
|
775
|
+
})
|
|
726
776
|
```
|
|
727
777
|
|
|
728
778
|
- **\[💥 BREAKING\]** The composable `useSearch` has been replaced by `useStorefrontSearch`, consolidating and transitioning to SCAYLE Search v2.
|
|
@@ -789,9 +839,9 @@
|
|
|
789
839
|
|
|
790
840
|
```ts
|
|
791
841
|
const { activeFilters, applyFilters, resetFilterUrl, productConditions } =
|
|
792
|
-
useQueryFilterState()
|
|
842
|
+
useQueryFilterState()
|
|
793
843
|
|
|
794
|
-
applyFilters({ brand: 23, sale: true, maxPrice: 100, minPrice: 0 })
|
|
844
|
+
applyFilters({ brand: 23, sale: true, maxPrice: 100, minPrice: 0 })
|
|
795
845
|
```
|
|
796
846
|
|
|
797
847
|
- _Current Usage of `useFilter` and `useAppliedFilters`:_
|
|
@@ -804,20 +854,20 @@
|
|
|
804
854
|
resetFilters,
|
|
805
855
|
resetPriceFilter,
|
|
806
856
|
resetFilter,
|
|
807
|
-
} = useFilter()
|
|
857
|
+
} = useFilter()
|
|
808
858
|
|
|
809
|
-
applyPriceFilter([0, 100])
|
|
810
|
-
applyBooleanFilter(
|
|
811
|
-
applyAttributeFilter(
|
|
859
|
+
applyPriceFilter([0, 100])
|
|
860
|
+
applyBooleanFilter('sale', true)
|
|
861
|
+
applyAttributeFilter('brand', 23)
|
|
812
862
|
|
|
813
|
-
const route = useRoute()
|
|
863
|
+
const route = useRoute()
|
|
814
864
|
const {
|
|
815
865
|
appliedFilter,
|
|
816
866
|
appliedFiltersCount,
|
|
817
867
|
appliedAttributeValues,
|
|
818
868
|
appliedBooleanValues,
|
|
819
869
|
areFiltersApplied,
|
|
820
|
-
} = useAppliedFilters(route)
|
|
870
|
+
} = useAppliedFilters(route)
|
|
821
871
|
```
|
|
822
872
|
|
|
823
873
|
- **\[💥 BREAKING\]** The `getBadgeLabel` helper function has been removed, giving you more control over badge label display.
|
|
@@ -827,43 +877,43 @@
|
|
|
827
877
|
|
|
828
878
|
```ts
|
|
829
879
|
const BadgeLabel = {
|
|
830
|
-
NEW:
|
|
831
|
-
SOLD_OUT:
|
|
832
|
-
ONLINE_EXCLUSIVE:
|
|
833
|
-
SUSTAINABLE:
|
|
834
|
-
PREMIUM:
|
|
835
|
-
DEFAULT:
|
|
836
|
-
} 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
|
|
837
887
|
|
|
838
888
|
type BadgeLabelParamsKeys =
|
|
839
|
-
|
|
|
840
|
-
|
|
|
841
|
-
|
|
|
842
|
-
|
|
|
843
|
-
|
|
|
844
|
-
type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean
|
|
889
|
+
| 'isNew'
|
|
890
|
+
| 'isSoldOut'
|
|
891
|
+
| 'isOnlineOnly'
|
|
892
|
+
| 'isSustainable'
|
|
893
|
+
| 'isPremium'
|
|
894
|
+
type BadgeLabelParams = Partial<Record<BadgeLabelParamsKeys, boolean>>
|
|
845
895
|
|
|
846
896
|
const getBadgeLabel = (params: BadgeLabelParams = {}): string => {
|
|
847
897
|
if (!params) {
|
|
848
|
-
return BadgeLabel.DEFAULT
|
|
898
|
+
return BadgeLabel.DEFAULT
|
|
849
899
|
}
|
|
850
900
|
const { isNew, isSoldOut, isOnlineOnly, isSustainable, isPremium } =
|
|
851
|
-
params
|
|
901
|
+
params
|
|
852
902
|
|
|
853
903
|
if (isNew) {
|
|
854
|
-
return BadgeLabel.NEW
|
|
904
|
+
return BadgeLabel.NEW
|
|
855
905
|
} else if (isSoldOut) {
|
|
856
|
-
return BadgeLabel.SOLD_OUT
|
|
906
|
+
return BadgeLabel.SOLD_OUT
|
|
857
907
|
} else if (isOnlineOnly) {
|
|
858
|
-
return BadgeLabel.ONLINE_EXCLUSIVE
|
|
908
|
+
return BadgeLabel.ONLINE_EXCLUSIVE
|
|
859
909
|
} else if (isSustainable) {
|
|
860
|
-
return BadgeLabel.SUSTAINABLE
|
|
910
|
+
return BadgeLabel.SUSTAINABLE
|
|
861
911
|
} else if (isPremium) {
|
|
862
|
-
return BadgeLabel.PREMIUM
|
|
912
|
+
return BadgeLabel.PREMIUM
|
|
863
913
|
} else {
|
|
864
|
-
return BadgeLabel.DEFAULT
|
|
914
|
+
return BadgeLabel.DEFAULT
|
|
865
915
|
}
|
|
866
|
-
}
|
|
916
|
+
}
|
|
867
917
|
```
|
|
868
918
|
|
|
869
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.
|
|
@@ -887,7 +937,7 @@
|
|
|
887
937
|
// ...
|
|
888
938
|
},
|
|
889
939
|
// ...
|
|
890
|
-
})
|
|
940
|
+
})
|
|
891
941
|
```
|
|
892
942
|
|
|
893
943
|
- _Previous Environment Variables for Store Configuration:_
|
|
@@ -916,7 +966,7 @@
|
|
|
916
966
|
// ...
|
|
917
967
|
},
|
|
918
968
|
// ...
|
|
919
|
-
})
|
|
969
|
+
})
|
|
920
970
|
```
|
|
921
971
|
|
|
922
972
|
- _Current Environment Variables for Shops Configuration:_
|
|
@@ -936,8 +986,8 @@
|
|
|
936
986
|
```ts
|
|
937
987
|
useProduct({
|
|
938
988
|
// ...
|
|
939
|
-
key:
|
|
940
|
-
})
|
|
989
|
+
key: 'productKey',
|
|
990
|
+
})
|
|
941
991
|
```
|
|
942
992
|
|
|
943
993
|
- _Current `key` as dedicated composables argument:_
|
|
@@ -947,8 +997,8 @@
|
|
|
947
997
|
{
|
|
948
998
|
// ...
|
|
949
999
|
},
|
|
950
|
-
|
|
951
|
-
)
|
|
1000
|
+
'productKey',
|
|
1001
|
+
)
|
|
952
1002
|
```
|
|
953
1003
|
|
|
954
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.
|
|
@@ -965,27 +1015,27 @@
|
|
|
965
1015
|
- _Previous Usage of `handleIDPLoginCallback`:_
|
|
966
1016
|
|
|
967
1017
|
```ts
|
|
968
|
-
const { handleIDPLoginCallback } = await useIDP()
|
|
1018
|
+
const { handleIDPLoginCallback } = await useIDP()
|
|
969
1019
|
|
|
970
1020
|
watch(
|
|
971
1021
|
() => route.query,
|
|
972
1022
|
async (query) => {
|
|
973
1023
|
if (query.code && isString(query.code)) {
|
|
974
|
-
await handleIDPLoginCallback(query.code)
|
|
1024
|
+
await handleIDPLoginCallback(query.code)
|
|
975
1025
|
}
|
|
976
1026
|
},
|
|
977
|
-
{ immediate: true }
|
|
978
|
-
)
|
|
1027
|
+
{ immediate: true },
|
|
1028
|
+
)
|
|
979
1029
|
```
|
|
980
1030
|
|
|
981
1031
|
- _Current Usage of `loginIDP`:_
|
|
982
1032
|
|
|
983
1033
|
```ts
|
|
984
|
-
const { loginIDP } = useAuthentication(
|
|
1034
|
+
const { loginIDP } = useAuthentication('login')
|
|
985
1035
|
|
|
986
1036
|
onMounted(async () => {
|
|
987
|
-
await loginIDP(props.code)
|
|
988
|
-
})
|
|
1037
|
+
await loginIDP(props.code)
|
|
1038
|
+
})
|
|
989
1039
|
```
|
|
990
1040
|
|
|
991
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.
|
|
@@ -995,17 +1045,17 @@
|
|
|
995
1045
|
- _Previous `useRpc` with `autoFetch`:_
|
|
996
1046
|
|
|
997
1047
|
```ts
|
|
998
|
-
useRpc(
|
|
1048
|
+
useRpc('rpcMethod', key, params, { autoFetch: true })
|
|
999
1049
|
|
|
1000
|
-
useUser({ autoFetch: true })
|
|
1050
|
+
useUser({ autoFetch: true })
|
|
1001
1051
|
```
|
|
1002
1052
|
|
|
1003
1053
|
- _Current `useRpc` with `immediate`:_
|
|
1004
1054
|
|
|
1005
1055
|
```ts
|
|
1006
|
-
useRpc(
|
|
1056
|
+
useRpc('rpcMethod', key, params, { immediate: true })
|
|
1007
1057
|
|
|
1008
|
-
useUser({ immediate: true })
|
|
1058
|
+
useUser({ immediate: true })
|
|
1009
1059
|
```
|
|
1010
1060
|
|
|
1011
1061
|
- **\[💥 BREAKING\]** The attribute `isCmsPreview` has been removed from `RpcContext`.
|
|
@@ -1025,18 +1075,18 @@
|
|
|
1025
1075
|
getSearchSuggestions,
|
|
1026
1076
|
fetching,
|
|
1027
1077
|
...searchData
|
|
1028
|
-
} = useStorefrontSearch(searchQuery, { key })
|
|
1078
|
+
} = useStorefrontSearch(searchQuery, { key })
|
|
1029
1079
|
|
|
1030
|
-
fetching.value
|
|
1080
|
+
fetching.value // true or false
|
|
1031
1081
|
```
|
|
1032
1082
|
|
|
1033
1083
|
- _Current `useStorefrontSearch` returning `status`:_
|
|
1034
1084
|
|
|
1035
1085
|
```ts
|
|
1036
1086
|
const { data, resolveSearch, getSearchSuggestions, status, ...searchData } =
|
|
1037
|
-
useStorefrontSearch(searchQuery, {}, key)
|
|
1087
|
+
useStorefrontSearch(searchQuery, {}, key)
|
|
1038
1088
|
|
|
1039
|
-
status.value
|
|
1089
|
+
status.value // 'idle', 'pending', 'error' or 'success'
|
|
1040
1090
|
```
|
|
1041
1091
|
|
|
1042
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.
|
|
@@ -1061,7 +1111,7 @@
|
|
|
1061
1111
|
// ...
|
|
1062
1112
|
},
|
|
1063
1113
|
// ...
|
|
1064
|
-
})
|
|
1114
|
+
})
|
|
1065
1115
|
```
|
|
1066
1116
|
|
|
1067
1117
|
- _Current `enableDefaultGetCachedDataOverride`in `nuxt.config.ts`:_
|
|
@@ -1086,7 +1136,7 @@
|
|
|
1086
1136
|
// ...
|
|
1087
1137
|
},
|
|
1088
1138
|
// ...
|
|
1089
|
-
})
|
|
1139
|
+
})
|
|
1090
1140
|
```
|
|
1091
1141
|
|
|
1092
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).
|
|
@@ -1108,7 +1158,7 @@
|
|
|
1108
1158
|
function myCustomRpc() {
|
|
1109
1159
|
// ...
|
|
1110
1160
|
|
|
1111
|
-
throw new BaseError(404)
|
|
1161
|
+
throw new BaseError(404)
|
|
1112
1162
|
}
|
|
1113
1163
|
```
|
|
1114
1164
|
|
|
@@ -1118,7 +1168,7 @@
|
|
|
1118
1168
|
function myCustomRpc() {
|
|
1119
1169
|
// ...
|
|
1120
1170
|
|
|
1121
|
-
return new Response(null, { status: 404 })
|
|
1171
|
+
return new Response(null, { status: 404 })
|
|
1122
1172
|
}
|
|
1123
1173
|
```
|
|
1124
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",
|