@sitecore-jss/sitecore-jss-nextjs 21.6.0-canary.4 → 21.6.0-canary.41

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 (46) hide show
  1. package/README.md +1 -4
  2. package/context.d.ts +1 -0
  3. package/context.js +1 -0
  4. package/dist/cjs/context/context.js +68 -0
  5. package/dist/cjs/context/index.js +5 -0
  6. package/dist/cjs/editing/constants.js +6 -0
  7. package/dist/cjs/editing/editing-data-middleware.js +2 -2
  8. package/dist/cjs/editing/editing-data-service.js +15 -7
  9. package/dist/cjs/editing/editing-render-middleware.js +31 -8
  10. package/dist/cjs/graphql/index.js +6 -0
  11. package/dist/cjs/index.js +11 -5
  12. package/dist/cjs/middleware/personalize-middleware.js +42 -33
  13. package/dist/cjs/middleware/redirects-middleware.js +6 -3
  14. package/dist/cjs/services/base-graphql-sitemap-service.js +8 -0
  15. package/dist/cjs/utils/utils.js +6 -18
  16. package/dist/esm/context/context.js +64 -0
  17. package/dist/esm/context/index.js +1 -0
  18. package/dist/esm/editing/constants.js +3 -0
  19. package/dist/esm/editing/editing-data-middleware.js +1 -1
  20. package/dist/esm/editing/editing-data-service.js +13 -5
  21. package/dist/esm/editing/editing-render-middleware.js +31 -8
  22. package/dist/esm/graphql/index.js +1 -0
  23. package/dist/esm/index.js +9 -3
  24. package/dist/esm/middleware/personalize-middleware.js +43 -34
  25. package/dist/esm/middleware/redirects-middleware.js +6 -3
  26. package/dist/esm/services/base-graphql-sitemap-service.js +9 -1
  27. package/dist/esm/utils/utils.js +6 -15
  28. package/graphql.d.ts +1 -0
  29. package/graphql.js +1 -0
  30. package/package.json +10 -10
  31. package/types/ComponentBuilder.d.ts +1 -0
  32. package/types/components/ComponentPropsContext.d.ts +1 -0
  33. package/types/components/Link.d.ts +1 -0
  34. package/types/components/NextImage.d.ts +1 -0
  35. package/types/components/Placeholder.d.ts +1 -0
  36. package/types/context/context.d.ts +113 -0
  37. package/types/context/index.d.ts +1 -0
  38. package/types/editing/constants.d.ts +3 -0
  39. package/types/editing/editing-data-service.d.ts +12 -4
  40. package/types/editing/editing-render-middleware.d.ts +10 -0
  41. package/types/graphql/index.d.ts +1 -0
  42. package/types/index.d.ts +7 -3
  43. package/types/middleware/personalize-middleware.d.ts +20 -15
  44. package/types/services/base-graphql-sitemap-service.d.ts +10 -3
  45. package/types/sharedTypes/module-factory.d.ts +1 -0
  46. package/types/utils/utils.d.ts +1 -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.
@@ -55,6 +55,16 @@ export declare class EditingRenderMiddleware {
55
55
  * @returns route handler
56
56
  */
57
57
  getHandler(): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
58
+ /**
59
+ * Gets query parameters that should be passed along to subsequent requests
60
+ * @param query Object of query parameters from incoming URL
61
+ * @returns Object of approved query parameters
62
+ */
63
+ protected getQueryParamsForPropagation: (query: Partial<{
64
+ [key: string]: string | string[];
65
+ }>) => {
66
+ [key: string]: string;
67
+ };
58
68
  private handler;
59
69
  /**
60
70
  * Default page URL resolution.
@@ -0,0 +1 @@
1
+ export { GraphQLRequestClient, GraphQLRequestClientFactory, GraphQLRequestClientFactoryConfig, getEdgeProxyContentUrl, } from '@sitecore-jss/sitecore-jss/graphql';
package/types/index.d.ts CHANGED
@@ -1,15 +1,18 @@
1
1
  export { constants, HttpDataFetcher, HttpResponse, AxiosResponse, AxiosDataFetcher, AxiosDataFetcherConfig, NativeDataFetcher, NativeDataFetcherConfig, HTMLLink, enableDebug, debug, } from '@sitecore-jss/sitecore-jss';
2
+ import { GraphQLRequestClient as GraphQLRequestClientDep } from './graphql';
2
3
  import { resolveUrl as resolveUrlDep } from '@sitecore-jss/sitecore-jss/utils';
3
4
  /** @deprecated use import from '@sitecore-jss/sitecore-jss-nextjs/utils' instead */
4
5
  declare const isEditorActive: () => boolean, resetEditorChromes: () => void, resolveUrl: typeof resolveUrlDep, tryParseEnvValue: <T>(envValue: string | undefined, defaultValue: T) => T, handleEditorFastRefresh: (forceReload?: boolean) => void, getPublicUrl: () => string;
6
+ /** @deprecated use import from '@sitecore-jss/sitecore-jss-nextjs/graphql' instead */
7
+ declare const GraphQLRequestClient: typeof GraphQLRequestClientDep;
8
+ export { GraphQLRequestClient };
5
9
  export { handleEditorFastRefresh, getPublicUrl };
6
10
  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';
11
+ 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
12
  export { mediaApi } from '@sitecore-jss/sitecore-jss/media';
9
13
  export { trackingApi, TrackingRequestOptions, CampaignInstance, GoalInstance, OutcomeInstance, EventInstance, PageViewInstance, } from '@sitecore-jss/sitecore-jss/tracking';
10
14
  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';
15
+ export { personalizeLayout, getPersonalizedRewrite, getPersonalizedRewriteData, normalizePersonalizedRewrite, CdpHelper, } from '@sitecore-jss/sitecore-jss/personalize';
13
16
  export { ComponentPropsCollection, ComponentPropsError, GetStaticComponentProps, GetServerSideComponentProps, } from './sharedTypes/component-props';
14
17
  export { ModuleFactory, Module } from './sharedTypes/module-factory';
15
18
  export { ComponentPropsService } from './services/component-props-service';
@@ -29,4 +32,5 @@ import * as BYOCWrapper from './components/BYOCWrapper';
29
32
  export { FEaaSWrapper };
30
33
  export { BYOCWrapper };
31
34
  export { ComponentBuilder, ComponentBuilderConfig } from './ComponentBuilder';
35
+ export { Context, ContextConfig, SDK } from './context';
32
36
  export { ComponentFactory, Image, ImageField, ImageFieldValue, ImageProps, LinkField, LinkFieldValue, Text, TextField, DateField, EditFrame, FEaaSComponent, FEaaSComponentProps, FEaaSComponentParams, fetchFEaaSComponentServerProps, BYOCComponentParams, BYOCComponent, BYOCComponentProps, 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';
@@ -1,17 +1,16 @@
1
1
  import { NextResponse, NextRequest } from 'next/server';
2
- import { GraphQLPersonalizeServiceConfig } from '@sitecore-jss/sitecore-jss/personalize';
3
- import { SiteInfo } from '@sitecore-jss/sitecore-jss/site';
2
+ import { GraphQLPersonalizeServiceConfig, PersonalizeInfo } from '@sitecore-jss/sitecore-jss/personalize';
4
3
  import { MiddlewareBase, MiddlewareBaseConfig } from './middleware';
5
- import { EngageServer } from '@sitecore/engage';
6
4
  export type CdpServiceConfig = {
7
5
  /**
8
- * Your Sitecore CDP API endpoint
6
+ * Your Sitecore Edge Platform endpoint
7
+ * Default is https://edge-platform.sitecorecloud.io
9
8
  */
10
- endpoint: string;
9
+ sitecoreEdgeUrl?: string;
11
10
  /**
12
- * The client key to use for authentication
11
+ * Your unified Sitecore Edge Context Id
13
12
  */
14
- clientKey: string;
13
+ sitecoreEdgeContextId: string;
15
14
  /**
16
15
  * The Sitecore CDP channel to use for events. Uses 'WEB' by default.
17
16
  */
@@ -34,13 +33,6 @@ export type PersonalizeMiddlewareConfig = MiddlewareBaseConfig & {
34
33
  * Configuration for your Sitecore CDP endpoint
35
34
  */
36
35
  cdpConfig: CdpServiceConfig;
37
- /**
38
- * function to resolve point of sale for a site
39
- * @param {Siteinfo} site to get info from
40
- * @param {string} language to get info for
41
- * @returns point of sale value for site/language combination
42
- */
43
- getPointOfSale?: (site: SiteInfo, language: string) => string;
44
36
  };
45
37
  /**
46
38
  * Object model of Experience Context data
@@ -70,7 +62,20 @@ export declare class PersonalizeMiddleware extends MiddlewareBase {
70
62
  * @returns middleware handler
71
63
  */
72
64
  getHandler(): (req: NextRequest, res?: NextResponse) => Promise<NextResponse>;
73
- protected initializeEngageServer(site: SiteInfo, language: string): EngageServer;
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
+ }>;
74
79
  protected getExperienceParams(req: NextRequest): ExperienceParams;
75
80
  protected excludeRoute(pathname: string): boolean | undefined;
76
81
  private handler;
@@ -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";
@@ -68,17 +68,24 @@ export type RouteListQueryResult = {
68
68
  export interface BaseGraphQLSitemapServiceConfig extends Omit<SiteRouteQueryVariables, 'language' | 'siteName'> {
69
69
  /**
70
70
  * Your Graphql endpoint
71
+ * @deprecated use @param clientFactory property instead
71
72
  */
72
- endpoint: string;
73
+ endpoint?: string;
73
74
  /**
74
75
  * The API key to use for authentication.
76
+ * @deprecated use @param clientFactory property instead
75
77
  */
76
- apiKey: string;
78
+ apiKey?: string;
77
79
  /**
78
80
  * A flag for whether to include personalized routes in service output - only works on XM Cloud
79
81
  * turned off by default
80
82
  */
81
83
  includePersonalizedRoutes?: boolean;
84
+ /**
85
+ * A GraphQL Request Client Factory is a function that accepts configuration and returns an instance of a GraphQLRequestClient.
86
+ * This factory function is used to create and configure GraphQL clients for making GraphQL API requests.
87
+ */
88
+ clientFactory?: GraphQLRequestClientFactory;
82
89
  }
83
90
  /**
84
91
  * Object model of a site page item.
@@ -1,3 +1,4 @@
1
+ /// <reference types="@types/react" />
1
2
  import { ComponentType } from 'react';
2
3
  import { GetServerSideComponentProps, GetStaticComponentProps } from './component-props';
3
4
  /**
@@ -5,6 +5,7 @@
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
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 = ''
8
9
  */
9
10
  export declare const getPublicUrl: () => string;
10
11
  /**