@sitecore-jss/sitecore-jss-nextjs 21.6.0-canary.8 → 21.6.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.
@@ -0,0 +1,116 @@
1
+ import { LayoutServicePageState } from '@sitecore-jss/sitecore-jss-react';
2
+ /**
3
+ * Software Development Kit (SDK) instance
4
+ */
5
+ export type SDK<SDKType = unknown> = {
6
+ /**
7
+ * The Software Development Kit (SDK) library instance
8
+ */
9
+ sdk: SDKType;
10
+ /**
11
+ * Initializes the Software Development Kit (SDK)
12
+ */
13
+ init: (props: InitSDKProps) => Promise<void>;
14
+ };
15
+ /**
16
+ * Software Development Kits (SDKs) to be initialized
17
+ */
18
+ type SDKModulesType = Record<string, SDK>;
19
+ /**
20
+ * Properties that are passed to the Context.
21
+ */
22
+ export interface ContextInitProps {
23
+ /**
24
+ * Your Sitecore site name
25
+ */
26
+ siteName?: string;
27
+ /**
28
+ * Sitecore page state (normal, preview, edit)
29
+ */
30
+ pageState?: LayoutServicePageState;
31
+ }
32
+ /**
33
+ * Configuration that is passed to the Context.
34
+ */
35
+ export interface ContextConfig<SDKModules extends SDKModulesType> {
36
+ /**
37
+ * Your Sitecore Edge URL
38
+ */
39
+ sitecoreEdgeUrl: string;
40
+ /**
41
+ * Your Sitecore Edge Context ID
42
+ */
43
+ sitecoreEdgeContextId: string;
44
+ /**
45
+ * Your Sitecore site name
46
+ */
47
+ siteName: string;
48
+ /**
49
+ * Software Development Kits (SDKs) to be initialized
50
+ */
51
+ sdks: {
52
+ [module in keyof SDKModules]: SDKModules[module];
53
+ };
54
+ }
55
+ /**
56
+ * Properties that are passed to the Software Development Kit (SDK) initialization function.
57
+ */
58
+ type InitSDKProps = Omit<ContextConfig<SDKModulesType>, 'sdks'>;
59
+ /**
60
+ * Context instance that is used to initialize the application Context and associated Software Development Kits (SDKs).
61
+ */
62
+ export declare class Context<SDKModules extends SDKModulesType> {
63
+ protected props: ContextConfig<SDKModules>;
64
+ /**
65
+ * Indicates whether the Context and SDK(s) have been initialized
66
+ */
67
+ isInitialized: boolean;
68
+ /**
69
+ * The Sitecore Edge URL
70
+ */
71
+ readonly sitecoreEdgeUrl: string;
72
+ /**
73
+ * The Sitecore Edge Context ID
74
+ */
75
+ readonly sitecoreEdgeContextId: string;
76
+ /**
77
+ * The Sitecore site name
78
+ */
79
+ siteName: string;
80
+ /**
81
+ * Sitecore page state (normal, preview, edit)
82
+ */
83
+ pageState: LayoutServicePageState;
84
+ /**
85
+ * Software Development Kits (SDKs) to be initialized
86
+ */
87
+ readonly sdks: {
88
+ [module in keyof SDKModules]?: SDKModules[module]['sdk'];
89
+ };
90
+ /**
91
+ * Promises for the SDKs
92
+ */
93
+ protected sdkPromises: {
94
+ [module in keyof SDKModules]?: Promise<SDKModules[module]['sdk']>;
95
+ };
96
+ protected sdkErrors: {
97
+ [module in keyof SDKModules]?: string;
98
+ };
99
+ constructor(props: ContextConfig<SDKModules>);
100
+ init(props?: ContextInitProps): void;
101
+ /**
102
+ * Retrieves the Software Development Kit (SDK) instance, ensuring it is initialized before returning
103
+ *
104
+ * @param {string} name SDK name
105
+ * @returns initialized SDK
106
+ */
107
+ getSDK: <T extends keyof SDKModules>(name: T) => Promise<SDKModules[T]["sdk"]>;
108
+ /**
109
+ * Initializes the Software Development Kit (SDK)
110
+ *
111
+ * @param {T} name SDK name
112
+ * @returns {void}
113
+ */
114
+ protected initSDK<T extends keyof SDKModules>(name: T): void;
115
+ }
116
+ export {};
@@ -0,0 +1 @@
1
+ export { Context, ContextConfig, SDK } from './context';
@@ -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(hostName: string, 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.
@@ -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
  /**