@sitecore-jss/sitecore-jss-nextjs 22.0.0-canary.38 → 22.0.0-canary.42

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.
Files changed (90) hide show
  1. package/README.md +5 -3
  2. package/context.d.ts +1 -0
  3. package/context.js +1 -0
  4. package/dist/cjs/ComponentBuilder.js +63 -0
  5. package/dist/cjs/components/BYOCWrapper.js +47 -0
  6. package/dist/cjs/components/FEaaSWrapper.js +49 -0
  7. package/dist/cjs/components/NextImage.js +2 -10
  8. package/dist/cjs/components/RichText.js +10 -10
  9. package/dist/cjs/context/context.js +83 -0
  10. package/dist/cjs/context/index.js +5 -0
  11. package/dist/cjs/editing/constants.js +6 -0
  12. package/dist/cjs/editing/editing-config-middleware.js +49 -0
  13. package/dist/cjs/editing/editing-data-middleware.js +2 -2
  14. package/dist/cjs/editing/editing-data-service.js +15 -7
  15. package/dist/cjs/editing/editing-render-middleware.js +24 -10
  16. package/dist/cjs/editing/feaas-render-middleware.js +87 -0
  17. package/dist/cjs/editing/index.js +7 -1
  18. package/dist/cjs/editing/render-middleware.js +27 -0
  19. package/dist/cjs/editing/vercel-editing-data-cache.js +48 -0
  20. package/dist/cjs/graphql/index.js +7 -0
  21. package/dist/cjs/index.js +37 -25
  22. package/dist/cjs/middleware/index.js +3 -1
  23. package/dist/cjs/middleware/middleware.js +18 -2
  24. package/dist/cjs/middleware/multisite-middleware.js +14 -8
  25. package/dist/cjs/middleware/personalize-middleware.js +62 -56
  26. package/dist/cjs/middleware/redirects-middleware.js +48 -25
  27. package/dist/cjs/services/base-graphql-sitemap-service.js +7 -6
  28. package/dist/cjs/services/component-props-service.js +6 -6
  29. package/dist/cjs/utils/utils.js +7 -16
  30. package/dist/esm/ComponentBuilder.js +59 -0
  31. package/dist/esm/components/BYOCWrapper.js +42 -0
  32. package/dist/esm/components/FEaaSWrapper.js +44 -0
  33. package/dist/esm/components/NextImage.js +1 -8
  34. package/dist/esm/components/RichText.js +10 -10
  35. package/dist/esm/context/context.js +79 -0
  36. package/dist/esm/context/index.js +1 -0
  37. package/dist/esm/editing/constants.js +3 -0
  38. package/dist/esm/editing/editing-config-middleware.js +45 -0
  39. package/dist/esm/editing/editing-data-middleware.js +1 -1
  40. package/dist/esm/editing/editing-data-service.js +13 -5
  41. package/dist/esm/editing/editing-render-middleware.js +24 -10
  42. package/dist/esm/editing/feaas-render-middleware.js +83 -0
  43. package/dist/esm/editing/index.js +3 -0
  44. package/dist/esm/editing/render-middleware.js +23 -0
  45. package/dist/esm/editing/vercel-editing-data-cache.js +44 -0
  46. package/dist/esm/graphql/index.js +1 -0
  47. package/dist/esm/index.js +10 -20
  48. package/dist/esm/middleware/index.js +1 -0
  49. package/dist/esm/middleware/middleware.js +18 -2
  50. package/dist/esm/middleware/multisite-middleware.js +14 -8
  51. package/dist/esm/middleware/personalize-middleware.js +65 -59
  52. package/dist/esm/middleware/redirects-middleware.js +48 -25
  53. package/dist/esm/services/base-graphql-sitemap-service.js +7 -6
  54. package/dist/esm/services/component-props-service.js +6 -6
  55. package/dist/esm/utils/utils.js +7 -13
  56. package/graphql.d.ts +1 -0
  57. package/graphql.js +1 -0
  58. package/package.json +15 -12
  59. package/types/ComponentBuilder.d.ts +61 -0
  60. package/types/components/BYOCWrapper.d.ts +19 -0
  61. package/types/components/ComponentPropsContext.d.ts +1 -0
  62. package/types/components/FEaaSWrapper.d.ts +21 -0
  63. package/types/components/Link.d.ts +2 -1
  64. package/types/components/NextImage.d.ts +3 -3
  65. package/types/components/Placeholder.d.ts +3 -1
  66. package/types/components/RichText.d.ts +6 -0
  67. package/types/context/context.d.ts +116 -0
  68. package/types/context/index.d.ts +1 -0
  69. package/types/editing/constants.d.ts +3 -0
  70. package/types/editing/editing-config-middleware.d.ts +29 -0
  71. package/types/editing/editing-data-service.d.ts +12 -4
  72. package/types/editing/editing-render-middleware.d.ts +2 -1
  73. package/types/editing/feaas-render-middleware.d.ts +32 -0
  74. package/types/editing/index.d.ts +3 -0
  75. package/types/editing/render-middleware.d.ts +15 -0
  76. package/types/editing/vercel-editing-data-cache.d.ts +19 -0
  77. package/types/graphql/index.d.ts +1 -0
  78. package/types/index.d.ts +12 -12
  79. package/types/middleware/index.d.ts +1 -0
  80. package/types/middleware/middleware.d.ts +8 -0
  81. package/types/middleware/multisite-middleware.d.ts +15 -0
  82. package/types/middleware/personalize-middleware.d.ts +53 -14
  83. package/types/services/base-graphql-sitemap-service.d.ts +7 -10
  84. package/types/services/component-props-service.d.ts +2 -2
  85. package/types/sharedTypes/component-props.d.ts +5 -1
  86. package/types/sharedTypes/module-factory.d.ts +33 -0
  87. package/types/utils/utils.d.ts +2 -0
  88. package/types/sharedTypes/component-module.d.ts +0 -13
  89. /package/dist/cjs/sharedTypes/{component-module.js → module-factory.js} +0 -0
  90. /package/dist/esm/sharedTypes/{component-module.js → module-factory.js} +0 -0
@@ -2,13 +2,15 @@ import { AxiosDataFetcher } from '@sitecore-jss/sitecore-jss';
2
2
  import { EditingData } from './editing-data';
3
3
  import { EditingDataCache } from './editing-data-cache';
4
4
  import { PreviewData } from 'next';
5
- export declare const QUERY_PARAM_EDITING_SECRET = "secret";
6
5
  /**
7
6
  * Data for Next.js Preview (Editing) mode
8
7
  */
9
8
  export interface EditingPreviewData {
10
9
  key: string;
11
10
  serverUrl?: string;
11
+ params?: {
12
+ [key: string]: string;
13
+ };
12
14
  }
13
15
  /**
14
16
  * Defines an editing data service implementation
@@ -20,7 +22,9 @@ export interface EditingDataService {
20
22
  * @param {string} serverUrl The server url e.g. which can be used for further API requests
21
23
  * @returns The {@link EditingPreviewData} containing the information to use for retrieval
22
24
  */
23
- setEditingData(data: EditingData, serverUrl: string): Promise<EditingPreviewData>;
25
+ setEditingData(data: EditingData, serverUrl: string, params?: {
26
+ [key: string]: string;
27
+ }): Promise<EditingPreviewData>;
24
28
  /**
25
29
  * Retrieves Sitecore editor payload data
26
30
  * @param {PreviewData} previewData Editing preview data containing the information to use for retrieval
@@ -107,14 +111,18 @@ export declare class ServerlessEditingDataService implements EditingDataService
107
111
  * @param {string} serverUrl The server url to use for subsequent data API requests
108
112
  * @returns {Promise} The {@link EditingPreviewData} containing the generated key and serverUrl to use for retrieval
109
113
  */
110
- setEditingData(data: EditingData, serverUrl: string): Promise<EditingPreviewData>;
114
+ setEditingData(data: EditingData, serverUrl: string, params?: {
115
+ [key: string]: string;
116
+ }): Promise<EditingPreviewData>;
111
117
  /**
112
118
  * Retrieves Sitecore editor payload data by key
113
119
  * @param {PreviewData} previewData Editing preview data containing the key and serverUrl to use for retrieval
114
120
  * @returns {Promise} The {@link EditingData}
115
121
  */
116
122
  getEditingData(previewData: PreviewData): Promise<EditingData | undefined>;
117
- protected getUrl(serverUrl: string, key: string): string;
123
+ protected getUrl(serverUrl: string, key: string, params?: {
124
+ [key: string]: string;
125
+ }): string;
118
126
  }
119
127
  /**
120
128
  * The `EditingDataService` default instance.
@@ -2,6 +2,7 @@ import { NextApiRequest, NextApiResponse } from 'next';
2
2
  import { AxiosDataFetcher } from '@sitecore-jss/sitecore-jss';
3
3
  import { EditingData } from './editing-data';
4
4
  import { EditingDataService } from './editing-data-service';
5
+ import { RenderMiddlewareBase } from './render-middleware';
5
6
  export interface EditingRenderMiddlewareConfig {
6
7
  /**
7
8
  * The `AxiosDataFetcher` instance to use for API requests.
@@ -41,7 +42,7 @@ export interface EditingRenderMiddlewareConfig {
41
42
  * Middleware / handler for use in the editing render Next.js API route (e.g. '/api/editing/render')
42
43
  * which is required for Sitecore editing support.
43
44
  */
44
- export declare class EditingRenderMiddleware {
45
+ export declare class EditingRenderMiddleware extends RenderMiddlewareBase {
45
46
  private editingDataService;
46
47
  private dataFetcher;
47
48
  private resolvePageUrl;
@@ -0,0 +1,32 @@
1
+ import { NextApiRequest, NextApiResponse } from 'next';
2
+ import { RenderMiddlewareBase } from './render-middleware';
3
+ /**
4
+ * Configuration for `FEAASRenderMiddleware`.
5
+ */
6
+ export interface FEAASRenderMiddlewareConfig {
7
+ /**
8
+ * Defines FEAAS page route to render.
9
+ * This may be necessary for certain custom Next.js routing configurations.
10
+ * @default /feaas/render
11
+ */
12
+ pageUrl?: string;
13
+ }
14
+ /**
15
+ * Middleware / handler for use in the feaas render Next.js API route (e.g. '/api/editing/feaas/render')
16
+ * which is required for Sitecore editing support.
17
+ */
18
+ export declare class FEAASRenderMiddleware extends RenderMiddlewareBase {
19
+ protected config?: FEAASRenderMiddlewareConfig | undefined;
20
+ private pageUrl;
21
+ private defaultPageUrl;
22
+ /**
23
+ * @param {EditingRenderMiddlewareConfig} [config] Editing render middleware config
24
+ */
25
+ constructor(config?: FEAASRenderMiddlewareConfig | undefined);
26
+ /**
27
+ * Gets the Next.js API route handler
28
+ * @returns route handler
29
+ */
30
+ getHandler(): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
31
+ private handler;
32
+ }
@@ -3,3 +3,6 @@ export { EditingDataCache, EditingDataDiskCache } from './editing-data-cache';
3
3
  export { EditingDataMiddleware, EditingDataMiddlewareConfig } from './editing-data-middleware';
4
4
  export { EditingRenderMiddleware, EditingRenderMiddlewareConfig, } from './editing-render-middleware';
5
5
  export { EditingPreviewData, EditingDataService, BasicEditingDataService, BasicEditingDataServiceConfig, ServerlessEditingDataService, ServerlessEditingDataServiceConfig, editingDataService, } from './editing-data-service';
6
+ export { VercelEditingDataCache } from './vercel-editing-data-cache';
7
+ export { FEAASRenderMiddleware, FEAASRenderMiddlewareConfig } from './feaas-render-middleware';
8
+ export { EditingConfigMiddleware, EditingConfigMiddlewareConfig, } from './editing-config-middleware';
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Base class for middleware that handles pages and components rendering in Sitecore Editors.
3
+ */
4
+ export declare abstract class RenderMiddlewareBase {
5
+ /**
6
+ * Gets query parameters that should be passed along to subsequent requests (e.g. for deployment protection bypass)
7
+ * @param {Object} query Object of query parameters from incoming URL
8
+ * @returns Object of approved query parameters
9
+ */
10
+ protected getQueryParamsForPropagation: (query: Partial<{
11
+ [key: string]: string | string[];
12
+ }>) => {
13
+ [key: string]: string;
14
+ };
15
+ }
@@ -0,0 +1,19 @@
1
+ import { VercelKV } from '@vercel/kv';
2
+ import { EditingDataCache } from './editing-data-cache';
3
+ import { EditingData } from './editing-data';
4
+ /**
5
+ * Implementation of editing cache for Vercel deployments
6
+ * Uses Vercel KV database and client to store data
7
+ * Set TTL for cache data in constructor (default: 60 seconds)
8
+ */
9
+ export declare class VercelEditingDataCache implements EditingDataCache {
10
+ protected redisCache: VercelKV;
11
+ private defaultTtl;
12
+ /**
13
+ * @param {string} redisUrl KV endpoint URL. Usually stored in process.env.KV_REST_API_URL
14
+ * @param {string} redisToken KV endpoint tokem. Usually stored in process.env.KV_REST_API_TOKEN
15
+ */
16
+ constructor(redisUrl: string | undefined, redisToken: string | undefined);
17
+ set(key: string, editingData: EditingData): Promise<void>;
18
+ get(key: string): Promise<EditingData | undefined>;
19
+ }
@@ -0,0 +1 @@
1
+ export { GraphQLClientError, RetryStrategy, DefaultRetryStrategy, GraphQLRequestClient, GraphQLRequestClientFactory, GraphQLRequestClientFactoryConfig, getEdgeProxyContentUrl, } from '@sitecore-jss/sitecore-jss/graphql';
package/types/index.d.ts CHANGED
@@ -1,17 +1,11 @@
1
- export { constants, HttpDataFetcher, HttpResponse, AxiosResponse, AxiosDataFetcher, AxiosDataFetcherConfig, NativeDataFetcher, NativeDataFetcherConfig, HTMLLink, enableDebug, } from '@sitecore-jss/sitecore-jss';
2
- import { resolveUrl as resolveUrlDep } from '@sitecore-jss/sitecore-jss/utils';
3
- /** @deprecated use import from '@sitecore-jss/sitecore-jss-nextjs/utils' instead */
4
- declare const isEditorActive: () => boolean, resetEditorChromes: () => void, resolveUrl: typeof resolveUrlDep, tryParseEnvValue: <T>(envValue: string | undefined, defaultValue: T) => T, handleEditorFastRefresh: (forceReload?: boolean) => void, getPublicUrl: () => string;
5
- export { handleEditorFastRefresh, getPublicUrl };
6
- export { isEditorActive, resetEditorChromes, resolveUrl, tryParseEnvValue };
7
- export { LayoutService, LayoutServiceData, LayoutServicePageState, LayoutServiceContext, LayoutServiceContextData, GraphQLLayoutService, GraphQLLayoutServiceConfig, RestLayoutService, RestLayoutServiceConfig, PlaceholderData, PlaceholdersData, RouteData, Field, Item, HtmlElementRendering, getChildPlaceholder, getFieldValue, ComponentRendering, ComponentFields, ComponentParams, RenderingType, EDITING_COMPONENT_PLACEHOLDER, EDITING_COMPONENT_ID, } from '@sitecore-jss/sitecore-jss/layout';
1
+ export { constants, HttpDataFetcher, HttpResponse, AxiosResponse, AxiosDataFetcher, AxiosDataFetcherConfig, NativeDataFetcher, NativeDataFetcherConfig, HTMLLink, enableDebug, debug, } from '@sitecore-jss/sitecore-jss';
2
+ export { LayoutService, LayoutServiceData, LayoutServicePageState, LayoutServiceContext, LayoutServiceContextData, GraphQLLayoutService, GraphQLLayoutServiceConfig, RestLayoutService, RestLayoutServiceConfig, PlaceholderData, PlaceholdersData, RouteData, Field, Item, HtmlElementRendering, getChildPlaceholder, getFieldValue, ComponentRendering, ComponentFields, ComponentParams, RenderingType, EDITING_COMPONENT_PLACEHOLDER, EDITING_COMPONENT_ID, getContentStylesheetLink, } from '@sitecore-jss/sitecore-jss/layout';
8
3
  export { mediaApi } from '@sitecore-jss/sitecore-jss/media';
9
4
  export { trackingApi, TrackingRequestOptions, CampaignInstance, GoalInstance, OutcomeInstance, EventInstance, PageViewInstance, } from '@sitecore-jss/sitecore-jss/tracking';
10
5
  export { DictionaryPhrases, DictionaryService, GraphQLDictionaryService, GraphQLDictionaryServiceConfig, RestDictionaryService, RestDictionaryServiceConfig, } from '@sitecore-jss/sitecore-jss/i18n';
11
- export { personalizeLayout, getPersonalizedRewrite, getPersonalizedRewriteData, normalizePersonalizedRewrite, CdpHelper, PosResolver, } from '@sitecore-jss/sitecore-jss/personalize';
12
- export { GraphQLRequestClient } from '@sitecore-jss/sitecore-jss';
13
- export { ComponentPropsCollection, GetStaticComponentProps, GetServerSideComponentProps, } from './sharedTypes/component-props';
14
- export { ComponentModule } from './sharedTypes/component-module';
6
+ export { personalizeLayout, getPersonalizedRewrite, getPersonalizedRewriteData, normalizePersonalizedRewrite, CdpHelper, } from '@sitecore-jss/sitecore-jss/personalize';
7
+ export { ComponentPropsCollection, ComponentPropsError, GetStaticComponentProps, GetServerSideComponentProps, } from './sharedTypes/component-props';
8
+ export { ModuleFactory, Module } from './sharedTypes/module-factory';
15
9
  export { ComponentPropsService } from './services/component-props-service';
16
10
  export { DisconnectedSitemapService } from './services/disconnected-sitemap-service';
17
11
  export { GraphQLSitemapService, GraphQLSitemapServiceConfig, } from './services/graphql-sitemap-service';
@@ -24,4 +18,10 @@ export { RichText, RichTextProps } from './components/RichText';
24
18
  export { Placeholder } from './components/Placeholder';
25
19
  export { EditingComponentPlaceholder } from './components/EditingComponentPlaceholder';
26
20
  export { NextImage } from './components/NextImage';
27
- export { ComponentFactory, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, EditFrame, FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, getFEAASLibraryStylesheetLinks, File, FileField, RichTextField, VisitorIdentification, PlaceholderComponentProps, SitecoreContext, SitecoreContextState, SitecoreContextValue, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, ImageSizeParameters, ComponentConsumerProps, WithSitecoreContextOptions, WithSitecoreContextProps, } from '@sitecore-jss/sitecore-jss-react';
21
+ import * as FEaaSWrapper from './components/FEaaSWrapper';
22
+ import * as BYOCWrapper from './components/BYOCWrapper';
23
+ export { FEaaSWrapper };
24
+ export { BYOCWrapper };
25
+ export { ComponentBuilder, ComponentBuilderConfig } from './ComponentBuilder';
26
+ export { Context, ContextConfig, SDK } from './context';
27
+ export { ComponentFactory, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, EditFrame, FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, BYOCComponentParams, BYOCComponent, BYOCComponentProps, getComponentLibraryStylesheetLinks, File, FileField, RichTextField, VisitorIdentification, PlaceholderComponentProps, SitecoreContext, SitecoreContextState, SitecoreContextValue, SitecoreContextReactContext, withSitecoreContext, useSitecoreContext, withEditorChromes, withPlaceholder, withDatasourceCheck, ImageSizeParameters, ComponentConsumerProps, WithSitecoreContextOptions, WithSitecoreContextProps, } from '@sitecore-jss/sitecore-jss-react';
@@ -1,3 +1,4 @@
1
+ export { debug } from '@sitecore-jss/sitecore-jss';
1
2
  export { RedirectsMiddleware, RedirectsMiddlewareConfig } from './redirects-middleware';
2
3
  export { PersonalizeMiddleware, PersonalizeMiddlewareConfig } from './personalize-middleware';
3
4
  export { MultisiteMiddleware, MultisiteMiddlewareConfig } from './multisite-middleware';
@@ -28,6 +28,7 @@ export type MiddlewareBaseConfig = {
28
28
  export declare abstract class MiddlewareBase {
29
29
  protected config: MiddlewareBaseConfig;
30
30
  protected SITE_SYMBOL: string;
31
+ protected REWRITE_HEADER_NAME: string;
31
32
  protected defaultHostname: string;
32
33
  constructor(config: MiddlewareBaseConfig);
33
34
  /**
@@ -65,4 +66,11 @@ export declare abstract class MiddlewareBase {
65
66
  * @returns {SiteInfo} site information
66
67
  */
67
68
  protected getSite(req: NextRequest, res?: NextResponse): SiteInfo;
69
+ /**
70
+ * Create a rewrite response
71
+ * @param {string} rewritePath the destionation path
72
+ * @param {NextRequest} req the current request
73
+ * @param {NextResponse} res the current response
74
+ */
75
+ protected rewrite(rewritePath: string, req: NextRequest, res: NextResponse): NextResponse;
68
76
  }
@@ -1,5 +1,19 @@
1
1
  import { NextResponse, NextRequest } from 'next/server';
2
2
  import { MiddlewareBase, MiddlewareBaseConfig } from './middleware';
3
+ export type CookieAttributes = {
4
+ /**
5
+ * the Secure attribute of the site cookie
6
+ */
7
+ secure: boolean;
8
+ /**
9
+ * the HttpOnly attribute of the site cookie
10
+ */
11
+ httpOnly: boolean;
12
+ /**
13
+ * the SameSite attribute of the site cookie
14
+ */
15
+ sameSite?: true | false | 'lax' | 'strict' | 'none' | undefined;
16
+ };
3
17
  export type MultisiteMiddlewareConfig = Omit<MiddlewareBaseConfig, 'disabled'> & {
4
18
  /**
5
19
  * Function used to determine if site should be resolved from sc_site cookie when present
@@ -20,5 +34,6 @@ export declare class MultisiteMiddleware extends MiddlewareBase {
20
34
  * @returns middleware handler
21
35
  */
22
36
  getHandler(): (req: NextRequest, res?: NextResponse) => Promise<NextResponse>;
37
+ protected excludeRoute(pathname: string): boolean | undefined;
23
38
  private handler;
24
39
  }
@@ -1,7 +1,29 @@
1
1
  import { NextResponse, NextRequest } from 'next/server';
2
- import { GraphQLPersonalizeServiceConfig, CdpServiceConfig, ExperienceParams } from '@sitecore-jss/sitecore-jss/personalize';
2
+ import { GraphQLPersonalizeServiceConfig, PersonalizeInfo } from '@sitecore-jss/sitecore-jss/personalize';
3
3
  import { MiddlewareBase, MiddlewareBaseConfig } from './middleware';
4
- import { SiteInfo } from '@sitecore-jss/sitecore-jss/site';
4
+ export type CdpServiceConfig = {
5
+ /**
6
+ * Your Sitecore Edge Platform endpoint
7
+ * Default is https://edge-platform.sitecorecloud.io
8
+ */
9
+ sitecoreEdgeUrl?: string;
10
+ /**
11
+ * Your unified Sitecore Edge Context Id
12
+ */
13
+ sitecoreEdgeContextId: string;
14
+ /**
15
+ * The Sitecore CDP channel to use for events. Uses 'WEB' by default.
16
+ */
17
+ channel?: string;
18
+ /**
19
+ * Currency for CDP request. Uses 'USA' as default.
20
+ */
21
+ currency?: string;
22
+ /**
23
+ * Timeout (ms) for CDP request. Default is 400.
24
+ */
25
+ timeout?: number;
26
+ };
5
27
  export type PersonalizeMiddlewareConfig = MiddlewareBaseConfig & {
6
28
  /**
7
29
  * Configuration for your Sitecore Experience Edge endpoint
@@ -10,14 +32,20 @@ export type PersonalizeMiddlewareConfig = MiddlewareBaseConfig & {
10
32
  /**
11
33
  * Configuration for your Sitecore CDP endpoint
12
34
  */
13
- cdpConfig: Omit<CdpServiceConfig, 'dataFetcherResolver'>;
14
- /**
15
- * function to resolve point of sale for a site
16
- * @param {Siteinfo} site to get info from
17
- * @param {string} language to get info for
18
- * @returns point of sale value for site/language combination
19
- */
20
- getPointOfSale?: (site: SiteInfo, language: string) => string;
35
+ cdpConfig: CdpServiceConfig;
36
+ };
37
+ /**
38
+ * Object model of Experience Context data
39
+ */
40
+ export type ExperienceParams = {
41
+ referrer: string;
42
+ utm: {
43
+ [key: string]: string | undefined;
44
+ campaign: string | undefined;
45
+ source: string | undefined;
46
+ medium: string | undefined;
47
+ content: string | undefined;
48
+ };
21
49
  };
22
50
  /**
23
51
  * Middleware / handler to support Sitecore Personalize
@@ -25,7 +53,6 @@ export type PersonalizeMiddlewareConfig = MiddlewareBaseConfig & {
25
53
  export declare class PersonalizeMiddleware extends MiddlewareBase {
26
54
  protected config: PersonalizeMiddlewareConfig;
27
55
  private personalizeService;
28
- private cdpService;
29
56
  /**
30
57
  * @param {PersonalizeMiddlewareConfig} [config] Personalize middleware config
31
58
  */
@@ -35,9 +62,21 @@ export declare class PersonalizeMiddleware extends MiddlewareBase {
35
62
  * @returns middleware handler
36
63
  */
37
64
  getHandler(): (req: NextRequest, res?: NextResponse) => Promise<NextResponse>;
38
- protected get browserIdCookieName(): string;
39
- protected getBrowserId(req: NextRequest): string | undefined;
40
- protected setBrowserId(res: NextResponse, browserId: string): void;
65
+ protected initPersonalizeServer({ hostname, siteName, request, response, }: {
66
+ hostname: string;
67
+ siteName: string;
68
+ request: NextRequest;
69
+ response: NextResponse;
70
+ }): Promise<void>;
71
+ protected personalize({ params, personalizeInfo, language, timeout, }: {
72
+ personalizeInfo: PersonalizeInfo;
73
+ params: ExperienceParams;
74
+ language: string;
75
+ timeout?: number;
76
+ }, request: NextRequest): Promise<{
77
+ variantId: string;
78
+ }>;
41
79
  protected getExperienceParams(req: NextRequest): ExperienceParams;
80
+ protected excludeRoute(pathname: string): boolean | undefined;
42
81
  private handler;
43
82
  }
@@ -1,4 +1,4 @@
1
- import { GraphQLClient, PageInfo } from '@sitecore-jss/sitecore-jss/graphql';
1
+ import { GraphQLClient, GraphQLRequestClientFactory, PageInfo } from '@sitecore-jss/sitecore-jss/graphql';
2
2
  /** @private */
3
3
  export declare const languageError = "The list of languages cannot be empty";
4
4
  export declare const siteError = "The service needs a site name";
@@ -30,7 +30,7 @@ interface SiteRouteQueryVariables {
30
30
  /** common variable for all GraphQL queries
31
31
  * it will be used for every type of query to regulate result batch size
32
32
  * Optional. How many result items to fetch in each GraphQL call. This is needed for pagination.
33
- * @default 10
33
+ * @default 100
34
34
  */
35
35
  pageSize?: number;
36
36
  }
@@ -66,19 +66,16 @@ export type RouteListQueryResult = {
66
66
  * Configuration options for @see GraphQLSitemapService instances
67
67
  */
68
68
  export interface BaseGraphQLSitemapServiceConfig extends Omit<SiteRouteQueryVariables, 'language' | 'siteName'> {
69
- /**
70
- * Your Graphql endpoint
71
- */
72
- endpoint: string;
73
- /**
74
- * The API key to use for authentication.
75
- */
76
- apiKey: string;
77
69
  /**
78
70
  * A flag for whether to include personalized routes in service output - only works on XM Cloud
79
71
  * turned off by default
80
72
  */
81
73
  includePersonalizedRoutes?: boolean;
74
+ /**
75
+ * A GraphQL Request Client Factory is a function that accepts configuration and returns an instance of a GraphQLRequestClient.
76
+ * This factory function is used to create and configure GraphQL clients for making GraphQL API requests.
77
+ */
78
+ clientFactory: GraphQLRequestClientFactory;
82
79
  }
83
80
  /**
84
81
  * Object model of a site page item.
@@ -1,11 +1,11 @@
1
1
  import { GetServerSidePropsContext, GetStaticPropsContext } from 'next';
2
2
  import { LayoutServiceData, ComponentRendering, PlaceholdersData } from '@sitecore-jss/sitecore-jss/layout';
3
3
  import { ComponentPropsCollection, ComponentPropsFetchFunction } from '../sharedTypes/component-props';
4
- import { ComponentModule } from '../sharedTypes/component-module';
4
+ import { ModuleFactory } from '../sharedTypes/module-factory';
5
5
  export type FetchComponentPropsArguments<NextContext> = {
6
6
  layoutData: LayoutServiceData;
7
7
  context: NextContext;
8
- componentModule: ComponentModule;
8
+ moduleFactory: ModuleFactory;
9
9
  };
10
10
  export type ComponentPropsRequest<NextContext> = {
11
11
  fetch: ComponentPropsFetchFunction<NextContext>;
@@ -1,10 +1,14 @@
1
1
  import { GetServerSidePropsContext, GetStaticPropsContext } from 'next';
2
2
  import { ComponentRendering, LayoutServiceData } from '@sitecore-jss/sitecore-jss/layout';
3
+ export type ComponentPropsError = {
4
+ error: string;
5
+ componentName: string;
6
+ };
3
7
  /**
4
8
  * Shape of component props storage
5
9
  */
6
10
  export type ComponentPropsCollection = {
7
- [componentUid: string]: unknown;
11
+ [componentUid: string]: unknown | ComponentPropsError;
8
12
  };
9
13
  /**
10
14
  * Type of side effect function which could be invoked on component level (getStaticProps/getServerSideProps)
@@ -0,0 +1,33 @@
1
+ /// <reference types="@types/react" />
2
+ import { ComponentType } from 'react';
3
+ import { GetServerSideComponentProps, GetStaticComponentProps } from './component-props';
4
+ /**
5
+ * Represents a module (file)
6
+ */
7
+ export type Module = {
8
+ /**
9
+ * Default SXA export
10
+ */
11
+ Default?: ComponentType;
12
+ /**
13
+ * Default Next.js export
14
+ */
15
+ default?: ComponentType;
16
+ /**
17
+ * function for component level data fetching in SSR mode
18
+ */
19
+ getServerSideProps?: GetServerSideComponentProps;
20
+ /**
21
+ * function for component level data fetching in SSG mode
22
+ */
23
+ getStaticProps?: GetStaticComponentProps;
24
+ } & {
25
+ /**
26
+ * Custom exports
27
+ */
28
+ [key: string]: ComponentType;
29
+ };
30
+ /**
31
+ * Represents a module factory
32
+ */
33
+ export type ModuleFactory = (componentName: string) => Module | Promise<Module> | null;
@@ -4,6 +4,8 @@
4
4
  * This is set to http://localhost:3000 by default.
5
5
  * VERCEL_URL is provided by Vercel in case if we are in Preview deployment (deployment based on the custom branch),
6
6
  * preview deployment has unique url, we don't know exact url.
7
+ * Similarly, DEPLOY_URL is provided by Netlify and would give us the deploy URL
8
+ * In production non-editing environments it is desirable to use relative urls, so in that case set PUBLIC_URL = ''
7
9
  */
8
10
  export declare const getPublicUrl: () => string;
9
11
  /**
@@ -1,13 +0,0 @@
1
- /// <reference types="react" />
2
- import { GetServerSideComponentProps, GetStaticComponentProps } from './component-props';
3
- export type Module = {
4
- default: React.Component;
5
- getServerSideProps?: GetServerSideComponentProps;
6
- getStaticProps?: GetStaticComponentProps;
7
- };
8
- /**
9
- * @returns `undefined` module not found
10
- * @returns `Module` regular module
11
- * @returns `Promise<Module>` when module should be lazy loaded
12
- */
13
- export type ComponentModule = (componentName: string) => Module | Promise<Module> | undefined;