@scayle/storefront-nuxt 8.2.1 → 8.3.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @scayle/storefront-nuxt
2
2
 
3
+ ## 8.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Complete removal of shop-prefixed API endpoints. In version 8.0.0, support for shop-prefixed API endpoints was dropped. However, not all the code was removed until now.
8
+
3
9
  ## 8.2.1
4
10
 
5
11
  ### Patch Changes
package/dist/module.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
- "version": "8.2.1",
3
+ "version": "8.3.0",
4
4
  "configKey": "storefront",
5
5
  "compatibility": {
6
6
  "nuxt": "^3.9.0"
package/dist/module.mjs CHANGED
@@ -4,7 +4,7 @@ import { defu } from 'defu';
4
4
  import { genImport, genSafeVariableName } from 'knitwork';
5
5
  import { builtinDrivers } from 'unstorage';
6
6
  import { createConsola } from 'consola';
7
- import { convertShopsToList, getApiBasePath } from '../dist/runtime/server/middleware/bootstrap-utils.js';
7
+ import { getApiBasePath } from '../dist/runtime/server/middleware/bootstrap-utils.js';
8
8
 
9
9
  function stringToBoolean(value, defaultValue = false) {
10
10
  return value ? value.toLowerCase() === "true" : defaultValue;
@@ -45,7 +45,7 @@ export default {
45
45
  }`;
46
46
  }
47
47
  const PACKAGE_NAME = "@scayle/storefront-nuxt";
48
- const PACKAGE_VERSION = "8.2.1";
48
+ const PACKAGE_VERSION = "8.3.0";
49
49
  const logger = createConsola({
50
50
  fancy: true,
51
51
  formatOptions: {
@@ -129,7 +129,7 @@ const module = defineNuxtModule({
129
129
  middleware: true,
130
130
  handler: resolve("./runtime/server/middleware/bootstrap")
131
131
  });
132
- const apiBasePath = nuxt.options.runtimeConfig.storefront.apiBasePath || "/api";
132
+ const apiBasePath = getApiBasePath(options, "/");
133
133
  const rpcMethodNames = new Set(Object.keys(rpcMethods));
134
134
  const overridenRPCMethodNames = new Set(options.rpcMethodOverrides);
135
135
  for (const rpcMethodName of options.rpcMethodNames ?? []) {
@@ -154,47 +154,23 @@ Specified RPC which were supposed to be overriden but are not. This indicates an
154
154
  Missing RPC Overrides: ${Array.from(overridenRPCMethodNames).map((name) => `'${name}'`).join(", ")}
155
155
  `);
156
156
  }
157
- function addRPCServerHandlers(base) {
158
- rpcMethodNames.forEach((methodName) => {
159
- addServerHandler({
160
- route: `${base}/rpc/${methodName}`,
161
- handler: resolve("./runtime/api/rpcHandler"),
162
- method: "post"
163
- });
164
- });
165
- }
166
- function addCacheServerHandlers(base) {
157
+ rpcMethodNames.forEach((methodName) => {
167
158
  addServerHandler({
168
- route: `${base}/purge/all`,
169
- handler: resolve("./runtime/api/purgeAll"),
159
+ route: `${apiBasePath}/rpc/${methodName}`,
160
+ handler: resolve("./runtime/api/rpcHandler"),
170
161
  method: "post"
171
162
  });
172
- addServerHandler({
173
- route: `${base}/purge/tags`,
174
- handler: resolve("./runtime/api/purgeTags"),
175
- method: "post"
176
- });
177
- }
178
- const shops = convertShopsToList(
179
- nuxt.options.runtimeConfig.storefront.shops ?? {}
180
- );
181
- const shopSelector = nuxt.options.runtimeConfig.storefront.shopSelector;
182
- if (shopSelector === "path" || shopSelector === "path_or_default") {
183
- shops.forEach((shop) => {
184
- const base = getApiBasePath(
185
- nuxt.options.runtimeConfig.storefront,
186
- shop,
187
- // Nuxt/Nitro automatically adds `NUXT_APP_BASE_URL` to the path when registering the handler, so we don't need to pass it here.
188
- // https://github.com/unjs/nitro/blob/011280178d59fa863b90d63f89f29beb47b520b7/src/runtime/internal/app.ts#L149C13-L149C27
189
- "/"
190
- );
191
- addCacheServerHandlers(base);
192
- addRPCServerHandlers(base);
193
- });
194
- } else {
195
- addCacheServerHandlers(apiBasePath);
196
- addRPCServerHandlers(apiBasePath);
197
- }
163
+ });
164
+ addServerHandler({
165
+ route: `${apiBasePath}/purge/all`,
166
+ handler: resolve("./runtime/api/purgeAll"),
167
+ method: "post"
168
+ });
169
+ addServerHandler({
170
+ route: `${apiBasePath}/purge/tags`,
171
+ handler: resolve("./runtime/api/purgeTags"),
172
+ method: "post"
173
+ });
198
174
  addServerHandler({
199
175
  route: `${apiBasePath}/up`,
200
176
  handler: resolve("./runtime/api/up")
@@ -8,7 +8,7 @@ type BootstrapPath = {
8
8
  export declare function getBootstrapPath(event: H3Event): BootstrapPath;
9
9
  export declare const getShopByPath: (event: H3Event, shops: ShopConfig[], appBasePath: string) => ShopConfig | undefined;
10
10
  export declare const convertShopsToList: (shops: ShopConfig[] | ShopConfigIndexed) => ShopConfig[];
11
- export declare function getApiBasePath(storefrontConfig: ModuleBaseOptions, shop: ShopConfig, baseUrl: string): string;
11
+ export declare function getApiBasePath(storefrontConfig: ModuleBaseOptions, baseUrl: string): string;
12
12
  export declare function getCurrentShopConfigForRequest(event: H3Event, storefrontConfig: Pick<ModuleBaseOptions, 'shops' | 'shopSelector'>, runtimeConfig: NitroRuntimeConfigApp): ShopConfig | undefined;
13
13
  export declare function getPublicShopData(data: ShopConfig, currentShopId: number, apiBasePath: string, publicShopData?: (keyof ShopConfig)[]): PublicShopConfig & {
14
14
  isActive: boolean;
@@ -31,19 +31,8 @@ export const convertShopsToList = (shops) => {
31
31
  }
32
32
  return Object.values(shops);
33
33
  };
34
- export function getApiBasePath(storefrontConfig, shop, baseUrl) {
35
- const path = Array.isArray(shop.path) ? shop.path[0] : shop.path;
36
- const apiPath = shop.apiBasePath || storefrontConfig.apiBasePath || "/api";
37
- if (storefrontConfig.shopSelector === "path") {
38
- const pathElements = [path, apiPath].filter(Boolean);
39
- return joinURL(baseUrl, ...pathElements);
40
- } else if (storefrontConfig.shopSelector === "path_or_default") {
41
- if (shop.isDefault) {
42
- return joinURL(baseUrl, apiPath);
43
- }
44
- const pathElements = [path, apiPath].filter(Boolean);
45
- return joinURL(baseUrl, ...pathElements);
46
- }
34
+ export function getApiBasePath(storefrontConfig, baseUrl) {
35
+ const apiPath = storefrontConfig.apiBasePath || "/api";
47
36
  return joinURL(baseUrl, apiPath);
48
37
  }
49
38
  export function getCurrentShopConfigForRequest(event, storefrontConfig, runtimeConfig) {
@@ -175,7 +175,6 @@ export default defineEventHandler(async (event) => {
175
175
  }
176
176
  const apiBasePath = getApiBasePath(
177
177
  $storefrontConfig,
178
- $shopConfig,
179
178
  config.app.baseURL
180
179
  );
181
180
  if (!event.context.$rpcContext) {
@@ -140,7 +140,6 @@ declare const ShopConfigSchema: z.ZodObject<{
140
140
  }>>;
141
141
  shopId: z.ZodNumber;
142
142
  path: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
143
- apiBasePath: z.ZodOptional<z.ZodString>;
144
143
  domain: z.ZodOptional<z.ZodString>;
145
144
  locale: z.ZodString;
146
145
  auth: z.ZodObject<{
@@ -376,7 +375,6 @@ declare const ShopConfigSchema: z.ZodObject<{
376
375
  idpRedirectURL: string;
377
376
  } | undefined;
378
377
  path?: string | string[] | undefined;
379
- apiBasePath?: string | undefined;
380
378
  appKeys?: {
381
379
  wishlistKey: string;
382
380
  basketKey: string;
@@ -444,7 +442,6 @@ declare const ShopConfigSchema: z.ZodObject<{
444
442
  idpRedirectURL: string;
445
443
  } | undefined;
446
444
  path?: string | string[] | undefined;
447
- apiBasePath?: string | undefined;
448
445
  appKeys?: {
449
446
  wishlistKey: string;
450
447
  basketKey: string;
@@ -756,7 +753,6 @@ declare const StorefrontConfigSchema: z.ZodObject<{
756
753
  idpRedirectURL: string;
757
754
  } | undefined;
758
755
  internalAccessHeader?: string | undefined;
759
- apiBasePath?: string | undefined;
760
756
  session?: {
761
757
  domain?: string | undefined;
762
758
  sameSite?: "lax" | "strict" | "none" | undefined;
@@ -797,6 +793,7 @@ declare const StorefrontConfigSchema: z.ZodObject<{
797
793
  tls?: boolean | undefined;
798
794
  } | undefined;
799
795
  } | undefined;
796
+ apiBasePath?: string | undefined;
800
797
  publicShopData?: string[] | undefined;
801
798
  legacy?: {
802
799
  enableSessionMigration?: boolean | undefined;
@@ -822,7 +819,6 @@ declare const StorefrontConfigSchema: z.ZodObject<{
822
819
  idpRedirectURL: string;
823
820
  } | undefined;
824
821
  internalAccessHeader?: string | undefined;
825
- apiBasePath?: string | undefined;
826
822
  session?: {
827
823
  domain?: string | undefined;
828
824
  sameSite?: "lax" | "strict" | "none" | undefined;
@@ -863,6 +859,7 @@ declare const StorefrontConfigSchema: z.ZodObject<{
863
859
  tls?: boolean | undefined;
864
860
  } | undefined;
865
861
  } | undefined;
862
+ apiBasePath?: string | undefined;
866
863
  publicShopData?: string[] | undefined;
867
864
  legacy?: {
868
865
  enableSessionMigration?: boolean | undefined;
@@ -933,7 +930,6 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
933
930
  }>>;
934
931
  shopId: z.ZodNumber;
935
932
  path: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodArray<z.ZodString, "many">]>>;
936
- apiBasePath: z.ZodOptional<z.ZodString>;
937
933
  domain: z.ZodOptional<z.ZodString>;
938
934
  locale: z.ZodString;
939
935
  auth: z.ZodObject<{
@@ -1169,7 +1165,6 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
1169
1165
  idpRedirectURL: string;
1170
1166
  } | undefined;
1171
1167
  path?: string | string[] | undefined;
1172
- apiBasePath?: string | undefined;
1173
1168
  appKeys?: {
1174
1169
  wishlistKey: string;
1175
1170
  basketKey: string;
@@ -1237,7 +1232,6 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
1237
1232
  idpRedirectURL: string;
1238
1233
  } | undefined;
1239
1234
  path?: string | string[] | undefined;
1240
- apiBasePath?: string | undefined;
1241
1235
  appKeys?: {
1242
1236
  wishlistKey: string;
1243
1237
  basketKey: string;
@@ -1308,7 +1302,6 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
1308
1302
  idpRedirectURL: string;
1309
1303
  } | undefined;
1310
1304
  path?: string | string[] | undefined;
1311
- apiBasePath?: string | undefined;
1312
1305
  appKeys?: {
1313
1306
  wishlistKey: string;
1314
1307
  basketKey: string;
@@ -1383,7 +1376,6 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
1383
1376
  idpRedirectURL: string;
1384
1377
  } | undefined;
1385
1378
  path?: string | string[] | undefined;
1386
- apiBasePath?: string | undefined;
1387
1379
  appKeys?: {
1388
1380
  wishlistKey: string;
1389
1381
  basketKey: string;
@@ -1697,7 +1689,6 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
1697
1689
  idpRedirectURL: string;
1698
1690
  } | undefined;
1699
1691
  internalAccessHeader?: string | undefined;
1700
- apiBasePath?: string | undefined;
1701
1692
  session?: {
1702
1693
  domain?: string | undefined;
1703
1694
  sameSite?: "lax" | "strict" | "none" | undefined;
@@ -1738,6 +1729,7 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
1738
1729
  tls?: boolean | undefined;
1739
1730
  } | undefined;
1740
1731
  } | undefined;
1732
+ apiBasePath?: string | undefined;
1741
1733
  publicShopData?: string[] | undefined;
1742
1734
  legacy?: {
1743
1735
  enableSessionMigration?: boolean | undefined;
@@ -1763,7 +1755,6 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
1763
1755
  idpRedirectURL: string;
1764
1756
  } | undefined;
1765
1757
  internalAccessHeader?: string | undefined;
1766
- apiBasePath?: string | undefined;
1767
1758
  session?: {
1768
1759
  domain?: string | undefined;
1769
1760
  sameSite?: "lax" | "strict" | "none" | undefined;
@@ -1804,6 +1795,7 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
1804
1795
  tls?: boolean | undefined;
1805
1796
  } | undefined;
1806
1797
  } | undefined;
1798
+ apiBasePath?: string | undefined;
1807
1799
  publicShopData?: string[] | undefined;
1808
1800
  legacy?: {
1809
1801
  enableSessionMigration?: boolean | undefined;
@@ -1892,7 +1884,6 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
1892
1884
  idpRedirectURL: string;
1893
1885
  } | undefined;
1894
1886
  path?: string | string[] | undefined;
1895
- apiBasePath?: string | undefined;
1896
1887
  appKeys?: {
1897
1888
  wishlistKey: string;
1898
1889
  basketKey: string;
@@ -1964,7 +1955,6 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
1964
1955
  idpRedirectURL: string;
1965
1956
  } | undefined;
1966
1957
  internalAccessHeader?: string | undefined;
1967
- apiBasePath?: string | undefined;
1968
1958
  session?: {
1969
1959
  domain?: string | undefined;
1970
1960
  sameSite?: "lax" | "strict" | "none" | undefined;
@@ -2005,6 +1995,7 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
2005
1995
  tls?: boolean | undefined;
2006
1996
  } | undefined;
2007
1997
  } | undefined;
1998
+ apiBasePath?: string | undefined;
2008
1999
  publicShopData?: string[] | undefined;
2009
2000
  legacy?: {
2010
2001
  enableSessionMigration?: boolean | undefined;
@@ -2046,7 +2037,6 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
2046
2037
  idpRedirectURL: string;
2047
2038
  } | undefined;
2048
2039
  path?: string | string[] | undefined;
2049
- apiBasePath?: string | undefined;
2050
2040
  appKeys?: {
2051
2041
  wishlistKey: string;
2052
2042
  basketKey: string;
@@ -2118,7 +2108,6 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
2118
2108
  idpRedirectURL: string;
2119
2109
  } | undefined;
2120
2110
  internalAccessHeader?: string | undefined;
2121
- apiBasePath?: string | undefined;
2122
2111
  session?: {
2123
2112
  domain?: string | undefined;
2124
2113
  sameSite?: "lax" | "strict" | "none" | undefined;
@@ -2159,6 +2148,7 @@ export declare const RuntimeConfigSchema: z.ZodObject<{
2159
2148
  tls?: boolean | undefined;
2160
2149
  } | undefined;
2161
2150
  } | undefined;
2151
+ apiBasePath?: string | undefined;
2162
2152
  publicShopData?: string[] | undefined;
2163
2153
  legacy?: {
2164
2154
  enableSessionMigration?: boolean | undefined;
@@ -79,7 +79,6 @@ const ShopConfigSchema = z.object({
79
79
  idp: IdpSchema.optional(),
80
80
  shopId: z.number(),
81
81
  path: z.string().or(z.array(z.string())).optional(),
82
- apiBasePath: z.string().optional(),
83
82
  domain: z.string().optional(),
84
83
  locale: z.string(),
85
84
  auth: z.object({
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@scayle/storefront-nuxt",
3
3
  "type": "module",
4
- "version": "8.2.1",
4
+ "version": "8.3.0",
5
5
  "description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
6
6
  "author": "SCAYLE Commerce Engine",
7
7
  "license": "MIT",