@vue-storefront/next 1.0.2 → 1.1.1-rc.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,31 @@
1
1
  # Change log
2
2
 
3
+ ## 1.1.0
4
+
5
+ - **[ADDED]** `middlewareModule` to `createSdk` params.
6
+
7
+ ```diff [sdk.config.ts]
8
+ - import { UnifiedApiExtension } from "storefront-middleware/types"
9
+ + import { UnifiedEndpoints } from "storefront-middleware/types"
10
+
11
+ export const { getSdk } = createSdk(
12
+ options,
13
+ - ({ buildModule, middlewareUrl, getRequestHeaders }) => ({
14
+ - commerce: buildModule(unifiedModule<UnifiedApiExtension>, {
15
+ - apiUrl: `${middlewareUrl}/commerce`,
16
+ - requestOptions: {
17
+ - headers: getRequestHeaders,
18
+ + ({ buildModule, middlewareModule, middlewareUrl, getRequestHeaders }) => ({
19
+ + commerce: buildModule(middlewareModule<UnifiedEndpoints>, {
20
+ + apiUrl: `${middlewareUrl}/commerce`,
21
+ + defaultRequestConfig: {
22
+ + headers: getRequestHeaders(),
23
+ },
24
+ }),
25
+ })
26
+ );
27
+ ```
28
+
3
29
  ## 1.0.2
4
30
 
5
31
  - **[FIXED]** Multi-store URL calculation, now working correctly in the browser.
package/dist/client.d.mts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SDKApi } from '@vue-storefront/sdk';
2
2
  import React from 'react';
3
- import { S as SdkProviderProps } from './types-m9jwrtV3.mjs';
3
+ import { b as SdkProviderProps } from './types-pLNAZ_nM.mjs';
4
4
 
5
5
  /**
6
6
  * Creates a new SDK context. This function is dedicated for the client-side usage.
package/dist/client.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { SDKApi } from '@vue-storefront/sdk';
2
2
  import React from 'react';
3
- import { S as SdkProviderProps } from './types-m9jwrtV3.js';
3
+ import { b as SdkProviderProps } from './types-pLNAZ_nM.js';
4
4
 
5
5
  /**
6
6
  * Creates a new SDK context. This function is dedicated for the client-side usage.
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
- import { C as Config, a as CreateSdkReturn } from './types-m9jwrtV3.mjs';
1
+ import { C as Config, a as CreateSdkReturn } from './types-pLNAZ_nM.mjs';
2
+ export { D as DynamicContext, G as GetSdkContext, b as SdkProviderProps, S as StaticContext } from './types-pLNAZ_nM.mjs';
2
3
  import '@vue-storefront/sdk';
3
4
  import 'react';
4
5
 
@@ -34,13 +35,9 @@ interface CreateSdkOptions {
34
35
  * @returns An object containing the `getSdk` function.
35
36
  * @example
36
37
  * ```tsx
37
- * import {
38
- * contentfulModule,
39
- * ContentfulModuleType,
40
- * } from "@vsf-enterprise/contentful-sdk";
41
- * import { unifiedModule } from "@vsf-enterprise/unified-sdk";
38
+ * import { contentfulModule } from "@vsf-enterprise/contentful-sdk";
42
39
  * import { CreateSdkOptions, createSdk } from "@vue-storefront/next";
43
- * import type { UnifiedApiExtension } from "../storefront-middleware/middleware.config";
40
+ * import type { UnifiedApiEndpoints } from "../storefront-middleware/types";
44
41
  *
45
42
  * const options: CreateSdkOptions = {
46
43
  * middleware: {
@@ -50,14 +47,14 @@ interface CreateSdkOptions {
50
47
  *
51
48
  * export const { getSdk, createSdkContext } = createSdk(
52
49
  * options,
53
- * ({ buildModule, middlewareUrl, getRequestHeaders }) => ({
54
- * unified: buildModule(unifiedModule<UnifiedApiExtension>, {
50
+ * ({ buildModule, middlewareModule, middlewareUrl, getRequestHeaders }) => ({
51
+ * unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
55
52
  * apiUrl: middlewareUrl + "/commerce",
56
- * requestOptions: {
57
- * headers: getRequestHeaders,
53
+ * defaultRequestConfig: {
54
+ * headers: getRequestHeaders(),
58
55
  * },
59
56
  * }),
60
- * contentful: buildModule<ContentfulModuleType>(contentfulModule, {
57
+ * contentful: buildModule(contentfulModule, {
61
58
  * apiUrl: middlewareUrl + "/cntf",
62
59
  * }),
63
60
  * }),
@@ -66,4 +63,4 @@ interface CreateSdkOptions {
66
63
  */
67
64
  declare function createSdk<TConfig extends Record<string, any>>(options: CreateSdkOptions, configDefinition: Config<TConfig>): CreateSdkReturn<TConfig>;
68
65
 
69
- export { type CreateSdkOptions, createSdk };
66
+ export { Config, type CreateSdkOptions, CreateSdkReturn, createSdk };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { C as Config, a as CreateSdkReturn } from './types-m9jwrtV3.js';
1
+ import { C as Config, a as CreateSdkReturn } from './types-pLNAZ_nM.js';
2
+ export { D as DynamicContext, G as GetSdkContext, b as SdkProviderProps, S as StaticContext } from './types-pLNAZ_nM.js';
2
3
  import '@vue-storefront/sdk';
3
4
  import 'react';
4
5
 
@@ -34,13 +35,9 @@ interface CreateSdkOptions {
34
35
  * @returns An object containing the `getSdk` function.
35
36
  * @example
36
37
  * ```tsx
37
- * import {
38
- * contentfulModule,
39
- * ContentfulModuleType,
40
- * } from "@vsf-enterprise/contentful-sdk";
41
- * import { unifiedModule } from "@vsf-enterprise/unified-sdk";
38
+ * import { contentfulModule } from "@vsf-enterprise/contentful-sdk";
42
39
  * import { CreateSdkOptions, createSdk } from "@vue-storefront/next";
43
- * import type { UnifiedApiExtension } from "../storefront-middleware/middleware.config";
40
+ * import type { UnifiedApiEndpoints } from "../storefront-middleware/types";
44
41
  *
45
42
  * const options: CreateSdkOptions = {
46
43
  * middleware: {
@@ -50,14 +47,14 @@ interface CreateSdkOptions {
50
47
  *
51
48
  * export const { getSdk, createSdkContext } = createSdk(
52
49
  * options,
53
- * ({ buildModule, middlewareUrl, getRequestHeaders }) => ({
54
- * unified: buildModule(unifiedModule<UnifiedApiExtension>, {
50
+ * ({ buildModule, middlewareModule, middlewareUrl, getRequestHeaders }) => ({
51
+ * unified: buildModule(middlewareModule<UnifiedApiEndpoints>, {
55
52
  * apiUrl: middlewareUrl + "/commerce",
56
- * requestOptions: {
57
- * headers: getRequestHeaders,
53
+ * defaultRequestConfig: {
54
+ * headers: getRequestHeaders(),
58
55
  * },
59
56
  * }),
60
- * contentful: buildModule<ContentfulModuleType>(contentfulModule, {
57
+ * contentful: buildModule(contentfulModule, {
61
58
  * apiUrl: middlewareUrl + "/cntf",
62
59
  * }),
63
60
  * }),
@@ -66,4 +63,4 @@ interface CreateSdkOptions {
66
63
  */
67
64
  declare function createSdk<TConfig extends Record<string, any>>(options: CreateSdkOptions, configDefinition: Config<TConfig>): CreateSdkReturn<TConfig>;
68
65
 
69
- export { type CreateSdkOptions, createSdk };
66
+ export { Config, type CreateSdkOptions, CreateSdkReturn, createSdk };
package/dist/index.js CHANGED
@@ -111,6 +111,7 @@ function createSdk(options, configDefinition) {
111
111
  });
112
112
  const resolvedConfig = configDefinition({
113
113
  buildModule: import_sdk.buildModule,
114
+ middlewareModule: import_sdk.middlewareModule,
114
115
  getRequestHeaders,
115
116
  middlewareUrl
116
117
  });
package/dist/index.mjs CHANGED
@@ -42,7 +42,7 @@ function composeMiddlewareUrl({
42
42
  }
43
43
 
44
44
  // src/sdk/index.tsx
45
- import { buildModule, initSDK } from "@vue-storefront/sdk";
45
+ import { buildModule, initSDK, middlewareModule } from "@vue-storefront/sdk";
46
46
 
47
47
  // src/sdk/helpers/resolveDynamicContext.ts
48
48
  var BLACKLISTED_HEADERS = /* @__PURE__ */ new Set(["host"]);
@@ -74,6 +74,7 @@ function createSdk(options, configDefinition) {
74
74
  });
75
75
  const resolvedConfig = configDefinition({
76
76
  buildModule,
77
+ middlewareModule,
77
78
  getRequestHeaders,
78
79
  middlewareUrl
79
80
  });
@@ -1,4 +1,4 @@
1
- import { SDKApi, buildModule } from '@vue-storefront/sdk';
1
+ import { buildModule, middlewareModule, SDKApi } from '@vue-storefront/sdk';
2
2
  import { ReactNode } from 'react';
3
3
 
4
4
  type GetSdkContext = {
@@ -12,6 +12,7 @@ type DynamicContext = {
12
12
  };
13
13
  type StaticContext = {
14
14
  buildModule: typeof buildModule;
15
+ middlewareModule: typeof middlewareModule;
15
16
  middlewareUrl: string;
16
17
  };
17
18
  type InjectedContext = DynamicContext & StaticContext;
@@ -66,4 +67,4 @@ interface CreateSdkReturn<TConfig extends Record<string, any>> {
66
67
  getSdk: (dynamicContext?: GetSdkContext) => SDKApi<TConfig>;
67
68
  }
68
69
 
69
- export type { Config as C, SdkProviderProps as S, CreateSdkReturn as a };
70
+ export type { Config as C, DynamicContext as D, GetSdkContext as G, StaticContext as S, CreateSdkReturn as a, SdkProviderProps as b };
@@ -1,4 +1,4 @@
1
- import { SDKApi, buildModule } from '@vue-storefront/sdk';
1
+ import { buildModule, middlewareModule, SDKApi } from '@vue-storefront/sdk';
2
2
  import { ReactNode } from 'react';
3
3
 
4
4
  type GetSdkContext = {
@@ -12,6 +12,7 @@ type DynamicContext = {
12
12
  };
13
13
  type StaticContext = {
14
14
  buildModule: typeof buildModule;
15
+ middlewareModule: typeof middlewareModule;
15
16
  middlewareUrl: string;
16
17
  };
17
18
  type InjectedContext = DynamicContext & StaticContext;
@@ -66,4 +67,4 @@ interface CreateSdkReturn<TConfig extends Record<string, any>> {
66
67
  getSdk: (dynamicContext?: GetSdkContext) => SDKApi<TConfig>;
67
68
  }
68
69
 
69
- export type { Config as C, SdkProviderProps as S, CreateSdkReturn as a };
70
+ export type { Config as C, DynamicContext as D, GetSdkContext as G, StaticContext as S, CreateSdkReturn as a, SdkProviderProps as b };
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@vue-storefront/next",
3
3
  "description": "Vue Storefront dedicated features for Next.js",
4
4
  "license": "MIT",
5
- "version": "1.0.2",
5
+ "version": "1.1.1-rc.0",
6
6
  "exports": {
7
7
  ".": {
8
8
  "import": "./dist/index.mjs",
@@ -36,14 +36,14 @@
36
36
  "dev:pages-router": "cd __tests__/apps/pages-router && yarn dev",
37
37
  "dev:middleware": "cd ../../shared/src/__tests__/middleware && yarn dev",
38
38
  "lint": "eslint . --ext .ts",
39
- "test:app-router": "start-server-and-test dev:middleware localhost:4000/test_integration/success dev:app-router localhost:3000 \"yarn test:e2e\"",
40
- "test:pages-router": "start-server-and-test dev:middleware localhost:4000/test_integration/success dev:pages-router localhost:3000 \"yarn test:e2e\"",
39
+ "test:app-router": "start-server-and-test dev:middleware localhost:4000/test_integration/getSuccess dev:app-router localhost:3000 \"yarn test:e2e\"",
40
+ "test:pages-router": "start-server-and-test dev:middleware localhost:4000/test_integration/getSuccess dev:pages-router localhost:3000 \"yarn test:e2e\"",
41
41
  "test": "yarn test:app-router && yarn test:pages-router",
42
42
  "test:e2e": "cd ../../shared/ && yarn test:e2e",
43
43
  "test:unit": "vitest run"
44
44
  },
45
45
  "dependencies": {
46
- "@vue-storefront/sdk": "^1.0.0"
46
+ "@vue-storefront/sdk": "^1.4.0"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/react": "^18.2.31",