@sitecore-content-sdk/nextjs 0.1.0-beta.37 → 0.1.0-beta.38

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.
@@ -20,14 +20,21 @@ class SitecoreNextjsClient extends client_1.SitecoreClient {
20
20
  this.initOptions = initOptions;
21
21
  this.componentPropsService = this.getComponentPropsService();
22
22
  }
23
- // since path rewrite we rely on is only working in nextjs
23
+ /**
24
+ * Resolves site based on the provided path
25
+ * @param {string | string[]} path path to resolve site from
26
+ * @returns resolved site, or default site info if not found
27
+ */
24
28
  resolveSiteFromPath(path) {
25
29
  const resolvedPath = super.parsePath(path);
26
30
  // Get site name (from path rewritten in middleware)
27
31
  const siteData = (0, site_1.getSiteRewriteData)(resolvedPath, this.initOptions.defaultSite);
28
32
  // Resolve site by name
29
- const site = this.siteResolver.getByName(siteData.siteName);
30
- return site;
33
+ return (this.siteResolver.getByName(siteData.siteName) || {
34
+ name: siteData.siteName,
35
+ hostName: '',
36
+ language: '',
37
+ });
31
38
  }
32
39
  /**
33
40
  * Normalizes a nextjs path that could have been rewritten
@@ -44,10 +51,11 @@ class SitecoreNextjsClient extends client_1.SitecoreClient {
44
51
  getPage: { get: () => super.getPage }
45
52
  });
46
53
  return __awaiter(this, void 0, void 0, function* () {
54
+ var _a;
47
55
  const resolvedPath = this.parsePath(path);
48
56
  // Get variant(s) for personalization (from path), must ensure path is of type string
49
57
  const personalizeData = pageOptions.personalize || (0, personalize_1.getPersonalizedRewriteData)(_super.parsePath.call(this, path));
50
- const site = pageOptions.site || this.resolveSiteFromPath(path).name;
58
+ const site = pageOptions.site || ((_a = this.resolveSiteFromPath(path)) === null || _a === void 0 ? void 0 : _a.name);
51
59
  const page = yield _super.getPage.call(this, resolvedPath, {
52
60
  locale: pageOptions.locale,
53
61
  site,
@@ -11,12 +11,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.EditingRenderMiddleware = exports.isDesignLibraryPreviewData = void 0;
13
13
  const core_1 = require("@sitecore-content-sdk/core");
14
- const layout_1 = require("@sitecore-content-sdk/core/layout");
15
14
  const editing_1 = require("@sitecore-content-sdk/core/editing");
15
+ const layout_1 = require("@sitecore-content-sdk/core/layout");
16
16
  const utils_1 = require("../utils/utils");
17
17
  const render_middleware_1 = require("./render-middleware");
18
18
  const utils_2 = require("@sitecore-content-sdk/core/utils");
19
19
  const personalize_1 = require("@sitecore-content-sdk/core/personalize");
20
+ const site_1 = require("@sitecore-content-sdk/core/site");
20
21
  /**
21
22
  * Type guard for Design Library mode
22
23
  * @param {object} data preview data to check
@@ -103,7 +104,6 @@ class EditingRenderMiddleware extends render_middleware_1.RenderMiddlewareBase {
103
104
  renderingId: query.sc_renderingId,
104
105
  language: query.sc_lang,
105
106
  site: query.sc_site,
106
- pageState: layout_1.LayoutServicePageState.Normal,
107
107
  mode: 'library',
108
108
  dataSourceId: query.sc_datasourceId,
109
109
  version: query.sc_version,
@@ -119,7 +119,7 @@ class EditingRenderMiddleware extends render_middleware_1.RenderMiddlewareBase {
119
119
  // for sc_variantId we may employ multiple variants (page-layout + component level)
120
120
  variantIds: ((_c = query.sc_variant) === null || _c === void 0 ? void 0 : _c.split(',')) || [personalize_1.DEFAULT_VARIANT],
121
121
  version: query.sc_version,
122
- pageState: query.mode,
122
+ mode: query.mode,
123
123
  layoutKind: query.sc_layoutKind,
124
124
  },
125
125
  // Cache the preview data for 3 seconds to ensure the page is rendered with the correct preview data not the cached one
@@ -147,6 +147,12 @@ class EditingRenderMiddleware extends render_middleware_1.RenderMiddlewareBase {
147
147
  }
148
148
  return cookie;
149
149
  });
150
+ // Set Preview mode identifier cookie, if the page is rendered in Sitecore Preview mode
151
+ if (mode === layout_1.LayoutServicePageState.Preview) {
152
+ const previewSite = `${site_1.SITE_KEY}=${query.sc_site}; Path=/; HttpOnly; SameSite=None; Secure`;
153
+ const previewCookie = `${editing_1.PREVIEW_KEY}=true; Path=/; HttpOnly; SameSite=None; Secure`;
154
+ modifiedCookies.push(previewSite, previewCookie);
155
+ }
150
156
  res.setHeader('Set-Cookie', modifiedCookies);
151
157
  }
152
158
  const route = ((_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.resolvePageUrl) === null || _e === void 0 ? void 0 : _e.call(_d, query.route)) || query.route;
@@ -27,7 +27,6 @@ class MiddlewareBase extends Middleware {
27
27
  constructor(config) {
28
28
  super();
29
29
  this.config = config;
30
- this.SITE_SYMBOL = 'sc_site';
31
30
  this.siteResolver = new site_1.SiteResolver(config.sites);
32
31
  this.defaultHostname = config.defaultHostname || 'localhost';
33
32
  }
@@ -86,18 +85,27 @@ class MiddlewareBase extends Middleware {
86
85
  return (_a = req.headers.get('host')) === null || _a === void 0 ? void 0 : _a.split(':')[0];
87
86
  }
88
87
  /**
89
- * Get site information.
90
- * Can not be used in **Preview** mode, since site will not be resolved
88
+ * Get site information. If site name is stored in cookie, use it, otherwise resolve by hostname
89
+ * - If site can't be resolved by site name cookie use default site info based on provided parameters
90
+ * - If site can't be resolved by hostname throw an error
91
91
  * @param {NextRequest} req request
92
92
  * @param {NextResponse} [res] response
93
93
  * @returns {SiteInfo} site information
94
94
  */
95
95
  getSite(req, res) {
96
96
  var _a;
97
- const siteNameCookie = (_a = res === null || res === void 0 ? void 0 : res.cookies.get(this.SITE_SYMBOL)) === null || _a === void 0 ? void 0 : _a.value;
98
- if (siteNameCookie)
99
- return this.siteResolver.getByName(siteNameCookie);
97
+ const siteNameCookie = (_a = res === null || res === void 0 ? void 0 : res.cookies.get(site_1.SITE_KEY)) === null || _a === void 0 ? void 0 : _a.value;
100
98
  const hostname = this.getHostHeader(req) || this.defaultHostname;
99
+ if (siteNameCookie) {
100
+ // Usually we should be able to resolve site by cookie
101
+ // in case of Sitecore Preview mode, there can be a case that new site was created
102
+ // but it's not present in the sitemap, so we fallback to default site info
103
+ return (this.siteResolver.getByName(siteNameCookie) || {
104
+ name: siteNameCookie,
105
+ language: this.getLanguage(req),
106
+ hostName: '*',
107
+ });
108
+ }
101
109
  return this.siteResolver.getByHost(hostname);
102
110
  }
103
111
  /**
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ /* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
2
3
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
4
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
5
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -13,6 +14,7 @@ exports.MultisiteMiddleware = void 0;
13
14
  const site_1 = require("@sitecore-content-sdk/core/site");
14
15
  const core_1 = require("@sitecore-content-sdk/core");
15
16
  const middleware_1 = require("./middleware");
17
+ const editing_1 = require("@sitecore-content-sdk/core/editing");
16
18
  /**
17
19
  * Middleware / handler for multisite support
18
20
  */
@@ -24,7 +26,7 @@ class MultisiteMiddleware extends middleware_1.MiddlewareBase {
24
26
  super(config);
25
27
  this.config = config;
26
28
  this.handle = (req, res) => __awaiter(this, void 0, void 0, function* () {
27
- var _a;
29
+ var _a, _b, _c;
28
30
  if (!this.config.enabled) {
29
31
  core_1.debug.multisite('skipped (multisite middleware is disabled globally)');
30
32
  return res;
@@ -47,12 +49,21 @@ class MultisiteMiddleware extends middleware_1.MiddlewareBase {
47
49
  core_1.debug.multisite('skipped (preview)');
48
50
  return res;
49
51
  }
50
- // Site name can be forced by query string parameter or cookie
51
- const siteName = req.nextUrl.searchParams.get(this.SITE_SYMBOL) ||
52
- (this.config.useCookieResolution &&
53
- this.config.useCookieResolution(req) &&
54
- ((_a = req.cookies.get(this.SITE_SYMBOL)) === null || _a === void 0 ? void 0 : _a.value)) ||
55
- this.siteResolver.getByHost(hostname).name;
52
+ let siteName;
53
+ const isSitecorePreview = (_a = req.cookies.get(editing_1.PREVIEW_KEY)) === null || _a === void 0 ? void 0 : _a.value;
54
+ if (isSitecorePreview) {
55
+ // This cookie is required to be set in the Sitecore Preview mode
56
+ siteName = (_b = req.cookies.get(site_1.SITE_KEY)) === null || _b === void 0 ? void 0 : _b.value;
57
+ }
58
+ else {
59
+ // Site name can be forced by query string parameter or cookie
60
+ siteName =
61
+ req.nextUrl.searchParams.get(site_1.SITE_KEY) ||
62
+ (this.config.useCookieResolution &&
63
+ this.config.useCookieResolution(req) &&
64
+ ((_c = req.cookies.get(site_1.SITE_KEY)) === null || _c === void 0 ? void 0 : _c.value)) ||
65
+ this.siteResolver.getByHost(hostname).name;
66
+ }
56
67
  // Rewrite to site specific path
57
68
  const rewritePath = (0, site_1.getSiteRewrite)(pathname, {
58
69
  siteName,
@@ -65,7 +76,7 @@ class MultisiteMiddleware extends middleware_1.MiddlewareBase {
65
76
  sameSite: 'none',
66
77
  };
67
78
  // Share site name with the following executed middlewares
68
- response.cookies.set(this.SITE_SYMBOL, siteName, defaultCookieAttributes);
79
+ response.cookies.set(site_1.SITE_KEY, siteName, defaultCookieAttributes);
69
80
  core_1.debug.multisite('multisite middleware end in %dms: %o', Date.now() - startTimestamp, {
70
81
  rewritePath,
71
82
  siteName,
@@ -17,14 +17,21 @@ export class SitecoreNextjsClient extends SitecoreClient {
17
17
  this.initOptions = initOptions;
18
18
  this.componentPropsService = this.getComponentPropsService();
19
19
  }
20
- // since path rewrite we rely on is only working in nextjs
20
+ /**
21
+ * Resolves site based on the provided path
22
+ * @param {string | string[]} path path to resolve site from
23
+ * @returns resolved site, or default site info if not found
24
+ */
21
25
  resolveSiteFromPath(path) {
22
26
  const resolvedPath = super.parsePath(path);
23
27
  // Get site name (from path rewritten in middleware)
24
28
  const siteData = getSiteRewriteData(resolvedPath, this.initOptions.defaultSite);
25
29
  // Resolve site by name
26
- const site = this.siteResolver.getByName(siteData.siteName);
27
- return site;
30
+ return (this.siteResolver.getByName(siteData.siteName) || {
31
+ name: siteData.siteName,
32
+ hostName: '',
33
+ language: '',
34
+ });
28
35
  }
29
36
  /**
30
37
  * Normalizes a nextjs path that could have been rewritten
@@ -41,10 +48,11 @@ export class SitecoreNextjsClient extends SitecoreClient {
41
48
  getPage: { get: () => super.getPage }
42
49
  });
43
50
  return __awaiter(this, void 0, void 0, function* () {
51
+ var _a;
44
52
  const resolvedPath = this.parsePath(path);
45
53
  // Get variant(s) for personalization (from path), must ensure path is of type string
46
54
  const personalizeData = pageOptions.personalize || getPersonalizedRewriteData(_super.parsePath.call(this, path));
47
- const site = pageOptions.site || this.resolveSiteFromPath(path).name;
55
+ const site = pageOptions.site || ((_a = this.resolveSiteFromPath(path)) === null || _a === void 0 ? void 0 : _a.name);
48
56
  const page = yield _super.getPage.call(this, resolvedPath, {
49
57
  locale: pageOptions.locale,
50
58
  site,
@@ -8,12 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { debug } from '@sitecore-content-sdk/core';
11
+ import { QUERY_PARAM_EDITING_SECRET, EDITING_ALLOWED_ORIGINS, PREVIEW_KEY, } from '@sitecore-content-sdk/core/editing';
11
12
  import { LayoutServicePageState } from '@sitecore-content-sdk/core/layout';
12
- import { QUERY_PARAM_EDITING_SECRET, EDITING_ALLOWED_ORIGINS, } from '@sitecore-content-sdk/core/editing';
13
13
  import { getJssEditingSecret } from '../utils/utils';
14
14
  import { RenderMiddlewareBase } from './render-middleware';
15
15
  import { enforceCors, getAllowedOriginsFromEnv } from '@sitecore-content-sdk/core/utils';
16
16
  import { DEFAULT_VARIANT } from '@sitecore-content-sdk/core/personalize';
17
+ import { SITE_KEY } from '@sitecore-content-sdk/core/site';
17
18
  /**
18
19
  * Type guard for Design Library mode
19
20
  * @param {object} data preview data to check
@@ -99,7 +100,6 @@ export class EditingRenderMiddleware extends RenderMiddlewareBase {
99
100
  renderingId: query.sc_renderingId,
100
101
  language: query.sc_lang,
101
102
  site: query.sc_site,
102
- pageState: LayoutServicePageState.Normal,
103
103
  mode: 'library',
104
104
  dataSourceId: query.sc_datasourceId,
105
105
  version: query.sc_version,
@@ -115,7 +115,7 @@ export class EditingRenderMiddleware extends RenderMiddlewareBase {
115
115
  // for sc_variantId we may employ multiple variants (page-layout + component level)
116
116
  variantIds: ((_c = query.sc_variant) === null || _c === void 0 ? void 0 : _c.split(',')) || [DEFAULT_VARIANT],
117
117
  version: query.sc_version,
118
- pageState: query.mode,
118
+ mode: query.mode,
119
119
  layoutKind: query.sc_layoutKind,
120
120
  },
121
121
  // Cache the preview data for 3 seconds to ensure the page is rendered with the correct preview data not the cached one
@@ -143,6 +143,12 @@ export class EditingRenderMiddleware extends RenderMiddlewareBase {
143
143
  }
144
144
  return cookie;
145
145
  });
146
+ // Set Preview mode identifier cookie, if the page is rendered in Sitecore Preview mode
147
+ if (mode === LayoutServicePageState.Preview) {
148
+ const previewSite = `${SITE_KEY}=${query.sc_site}; Path=/; HttpOnly; SameSite=None; Secure`;
149
+ const previewCookie = `${PREVIEW_KEY}=true; Path=/; HttpOnly; SameSite=None; Secure`;
150
+ modifiedCookies.push(previewSite, previewCookie);
151
+ }
146
152
  res.setHeader('Set-Cookie', modifiedCookies);
147
153
  }
148
154
  const route = ((_e = (_d = this.config) === null || _d === void 0 ? void 0 : _d.resolvePageUrl) === null || _e === void 0 ? void 0 : _e.call(_d, query.route)) || query.route;
@@ -7,7 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { SiteResolver } from '@sitecore-content-sdk/core/site';
10
+ import { SITE_KEY, SiteResolver } from '@sitecore-content-sdk/core/site';
11
11
  import { debug } from '@sitecore-content-sdk/core';
12
12
  import { NextResponse } from 'next/server';
13
13
  export const REWRITE_HEADER_NAME = 'x-sc-rewrite';
@@ -23,7 +23,6 @@ export class MiddlewareBase extends Middleware {
23
23
  constructor(config) {
24
24
  super();
25
25
  this.config = config;
26
- this.SITE_SYMBOL = 'sc_site';
27
26
  this.siteResolver = new SiteResolver(config.sites);
28
27
  this.defaultHostname = config.defaultHostname || 'localhost';
29
28
  }
@@ -82,18 +81,27 @@ export class MiddlewareBase extends Middleware {
82
81
  return (_a = req.headers.get('host')) === null || _a === void 0 ? void 0 : _a.split(':')[0];
83
82
  }
84
83
  /**
85
- * Get site information.
86
- * Can not be used in **Preview** mode, since site will not be resolved
84
+ * Get site information. If site name is stored in cookie, use it, otherwise resolve by hostname
85
+ * - If site can't be resolved by site name cookie use default site info based on provided parameters
86
+ * - If site can't be resolved by hostname throw an error
87
87
  * @param {NextRequest} req request
88
88
  * @param {NextResponse} [res] response
89
89
  * @returns {SiteInfo} site information
90
90
  */
91
91
  getSite(req, res) {
92
92
  var _a;
93
- const siteNameCookie = (_a = res === null || res === void 0 ? void 0 : res.cookies.get(this.SITE_SYMBOL)) === null || _a === void 0 ? void 0 : _a.value;
94
- if (siteNameCookie)
95
- return this.siteResolver.getByName(siteNameCookie);
93
+ const siteNameCookie = (_a = res === null || res === void 0 ? void 0 : res.cookies.get(SITE_KEY)) === null || _a === void 0 ? void 0 : _a.value;
96
94
  const hostname = this.getHostHeader(req) || this.defaultHostname;
95
+ if (siteNameCookie) {
96
+ // Usually we should be able to resolve site by cookie
97
+ // in case of Sitecore Preview mode, there can be a case that new site was created
98
+ // but it's not present in the sitemap, so we fallback to default site info
99
+ return (this.siteResolver.getByName(siteNameCookie) || {
100
+ name: siteNameCookie,
101
+ language: this.getLanguage(req),
102
+ hostName: '*',
103
+ });
104
+ }
97
105
  return this.siteResolver.getByHost(hostname);
98
106
  }
99
107
  /**
@@ -1,3 +1,4 @@
1
+ /* eslint-disable @typescript-eslint/no-non-null-asserted-optional-chain */
1
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -7,9 +8,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
9
  });
9
10
  };
10
- import { getSiteRewrite } from '@sitecore-content-sdk/core/site';
11
+ import { getSiteRewrite, SITE_KEY } from '@sitecore-content-sdk/core/site';
11
12
  import { debug } from '@sitecore-content-sdk/core';
12
13
  import { MiddlewareBase } from './middleware';
14
+ import { PREVIEW_KEY } from '@sitecore-content-sdk/core/editing';
13
15
  /**
14
16
  * Middleware / handler for multisite support
15
17
  */
@@ -21,7 +23,7 @@ export class MultisiteMiddleware extends MiddlewareBase {
21
23
  super(config);
22
24
  this.config = config;
23
25
  this.handle = (req, res) => __awaiter(this, void 0, void 0, function* () {
24
- var _a;
26
+ var _a, _b, _c;
25
27
  if (!this.config.enabled) {
26
28
  debug.multisite('skipped (multisite middleware is disabled globally)');
27
29
  return res;
@@ -44,12 +46,21 @@ export class MultisiteMiddleware extends MiddlewareBase {
44
46
  debug.multisite('skipped (preview)');
45
47
  return res;
46
48
  }
47
- // Site name can be forced by query string parameter or cookie
48
- const siteName = req.nextUrl.searchParams.get(this.SITE_SYMBOL) ||
49
- (this.config.useCookieResolution &&
50
- this.config.useCookieResolution(req) &&
51
- ((_a = req.cookies.get(this.SITE_SYMBOL)) === null || _a === void 0 ? void 0 : _a.value)) ||
52
- this.siteResolver.getByHost(hostname).name;
49
+ let siteName;
50
+ const isSitecorePreview = (_a = req.cookies.get(PREVIEW_KEY)) === null || _a === void 0 ? void 0 : _a.value;
51
+ if (isSitecorePreview) {
52
+ // This cookie is required to be set in the Sitecore Preview mode
53
+ siteName = (_b = req.cookies.get(SITE_KEY)) === null || _b === void 0 ? void 0 : _b.value;
54
+ }
55
+ else {
56
+ // Site name can be forced by query string parameter or cookie
57
+ siteName =
58
+ req.nextUrl.searchParams.get(SITE_KEY) ||
59
+ (this.config.useCookieResolution &&
60
+ this.config.useCookieResolution(req) &&
61
+ ((_c = req.cookies.get(SITE_KEY)) === null || _c === void 0 ? void 0 : _c.value)) ||
62
+ this.siteResolver.getByHost(hostname).name;
63
+ }
53
64
  // Rewrite to site specific path
54
65
  const rewritePath = getSiteRewrite(pathname, {
55
66
  siteName,
@@ -62,7 +73,7 @@ export class MultisiteMiddleware extends MiddlewareBase {
62
73
  sameSite: 'none',
63
74
  };
64
75
  // Share site name with the following executed middlewares
65
- response.cookies.set(this.SITE_SYMBOL, siteName, defaultCookieAttributes);
76
+ response.cookies.set(SITE_KEY, siteName, defaultCookieAttributes);
66
77
  debug.multisite('multisite middleware end in %dms: %o', Date.now() - startTimestamp, {
67
78
  rewritePath,
68
79
  siteName,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sitecore-content-sdk/nextjs",
3
- "version": "0.1.0-beta.37",
3
+ "version": "0.1.0-beta.38",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "sideEffects": false,
@@ -75,8 +75,8 @@
75
75
  },
76
76
  "dependencies": {
77
77
  "@babel/parser": "^7.26.10",
78
- "@sitecore-content-sdk/core": "0.1.0-beta.37",
79
- "@sitecore-content-sdk/react": "0.1.0-beta.37",
78
+ "@sitecore-content-sdk/core": "0.1.0-beta.38",
79
+ "@sitecore-content-sdk/react": "0.1.0-beta.38",
80
80
  "@vercel/kv": "^3.0.0",
81
81
  "prop-types": "^15.8.1",
82
82
  "recast": "^0.23.11",
@@ -85,7 +85,7 @@
85
85
  },
86
86
  "description": "",
87
87
  "types": "types/index.d.ts",
88
- "gitHead": "a2ec7a7854734141e897689e5aa12156cd15a87c",
88
+ "gitHead": "0309249c0004a7eb8d9c8a371b1fe6550ed3051d",
89
89
  "files": [
90
90
  "dist",
91
91
  "types",
@@ -3,7 +3,6 @@ import { ComponentPropsCollection, NextjsJssComponent } from '../sharedTypes/com
3
3
  import { GetServerSidePropsContext, GetStaticPropsContext, PreviewData } from 'next';
4
4
  import { LayoutServiceData } from '@sitecore-content-sdk/core/layout';
5
5
  import { ComponentPropsService } from '../services/component-props-service';
6
- import { SiteInfo } from '../site';
7
6
  import { ComponentMap } from '@sitecore-content-sdk/react';
8
7
  export type NextjsPage = Page & {
9
8
  componentProps?: ComponentPropsCollection;
@@ -13,7 +12,12 @@ export declare class SitecoreNextjsClient extends SitecoreClient {
13
12
  protected initOptions: SitecoreClientInit;
14
13
  protected componentPropsService: ComponentPropsService;
15
14
  constructor(initOptions: SitecoreClientInit);
16
- resolveSiteFromPath(path: string | string[]): SiteInfo;
15
+ /**
16
+ * Resolves site based on the provided path
17
+ * @param {string | string[]} path path to resolve site from
18
+ * @returns resolved site, or default site info if not found
19
+ */
20
+ resolveSiteFromPath(path: string | string[]): import("@sitecore-content-sdk/core/site").SiteInfo;
17
21
  /**
18
22
  * Normalizes a nextjs path that could have been rewritten
19
23
  * @param {string | string[]} path nextjs path
@@ -40,7 +40,6 @@ export declare abstract class Middleware {
40
40
  */
41
41
  export declare abstract class MiddlewareBase extends Middleware {
42
42
  protected config: MiddlewareBaseConfig;
43
- protected SITE_SYMBOL: string;
44
43
  protected defaultHostname: string;
45
44
  protected siteResolver: SiteResolver;
46
45
  constructor(config: MiddlewareBaseConfig);
@@ -78,8 +77,9 @@ export declare abstract class MiddlewareBase extends Middleware {
78
77
  */
79
78
  protected getHostHeader(req: NextRequest): string | undefined;
80
79
  /**
81
- * Get site information.
82
- * Can not be used in **Preview** mode, since site will not be resolved
80
+ * Get site information. If site name is stored in cookie, use it, otherwise resolve by hostname
81
+ * - If site can't be resolved by site name cookie use default site info based on provided parameters
82
+ * - If site can't be resolved by hostname throw an error
83
83
  * @param {NextRequest} req request
84
84
  * @param {NextResponse} [res] response
85
85
  * @returns {SiteInfo} site information