@sitecore-content-sdk/core 0.2.0-beta.2 → 0.2.0-beta.21
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/content.d.ts +1 -0
- package/content.js +1 -0
- package/dist/cjs/client/graphql-edge-proxy.js +3 -3
- package/dist/cjs/client/sitecore-client.js +34 -17
- package/dist/cjs/config/define-config.js +6 -5
- package/dist/cjs/constants.js +12 -1
- package/dist/cjs/content/content-client.js +148 -0
- package/dist/cjs/content/index.js +13 -0
- package/dist/cjs/content/locales.js +32 -0
- package/dist/cjs/content/taxonomies.js +78 -0
- package/dist/cjs/content/utils.js +16 -0
- package/dist/cjs/debug.js +1 -0
- package/dist/cjs/editing/design-library.js +2 -1
- package/dist/cjs/editing/rest-component-layout-service.js +26 -45
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/layout/content-styles.js +2 -1
- package/dist/cjs/layout/themes.js +2 -1
- package/dist/cjs/site/graphql-robots-service.js +3 -2
- package/dist/cjs/tools/auth/encryption.js +141 -0
- package/dist/cjs/tools/auth/fetcher.js +34 -0
- package/dist/cjs/tools/auth/flow.js +123 -0
- package/dist/cjs/tools/auth/index.js +27 -0
- package/dist/cjs/tools/auth/models.js +2 -0
- package/dist/cjs/tools/auth/renewal.js +130 -0
- package/dist/cjs/tools/auth/tenant-state.js +110 -0
- package/dist/cjs/tools/auth/tenant-store.js +250 -0
- package/dist/cjs/tools/index.js +26 -1
- package/dist/cjs/utils/normalize-url.js +5 -0
- package/dist/cjs/utils/utils.js +5 -3
- package/dist/esm/client/graphql-edge-proxy.js +1 -1
- package/dist/esm/client/sitecore-client.js +34 -17
- package/dist/esm/config/define-config.js +6 -5
- package/dist/esm/constants.js +11 -0
- package/dist/esm/content/content-client.js +141 -0
- package/dist/esm/content/index.js +4 -0
- package/dist/esm/content/locales.js +29 -0
- package/dist/esm/content/taxonomies.js +75 -0
- package/dist/esm/content/utils.js +13 -0
- package/dist/esm/debug.js +1 -0
- package/dist/esm/editing/design-library.js +2 -1
- package/dist/esm/editing/rest-component-layout-service.js +23 -45
- package/dist/esm/index.js +2 -0
- package/dist/esm/layout/content-styles.js +2 -1
- package/dist/esm/layout/themes.js +2 -1
- package/dist/esm/site/graphql-robots-service.js +3 -2
- package/dist/esm/tools/auth/encryption.js +101 -0
- package/dist/esm/tools/auth/fetcher.js +31 -0
- package/dist/esm/tools/auth/flow.js +118 -0
- package/dist/esm/tools/auth/index.js +5 -0
- package/dist/esm/tools/auth/models.js +1 -0
- package/dist/esm/tools/auth/renewal.js +124 -0
- package/dist/esm/tools/auth/tenant-state.js +73 -0
- package/dist/esm/tools/auth/tenant-store.js +213 -0
- package/dist/esm/tools/index.js +3 -0
- package/dist/esm/utils/normalize-url.js +1 -0
- package/dist/esm/utils/utils.js +5 -3
- package/package.json +19 -18
- package/types/client/index.d.ts +1 -1
- package/types/client/models.d.ts +17 -1
- package/types/client/sitecore-client.d.ts +50 -22
- package/types/config/index.d.ts +1 -1
- package/types/config/models.d.ts +12 -2
- package/types/constants.d.ts +10 -0
- package/types/content/content-client.d.ts +92 -0
- package/types/content/index.d.ts +4 -0
- package/types/content/locales.d.ts +38 -0
- package/types/content/taxonomies.d.ts +125 -0
- package/types/content/utils.d.ts +15 -0
- package/types/debug.d.ts +1 -0
- package/types/editing/rest-component-layout-service.d.ts +23 -58
- package/types/index.d.ts +2 -0
- package/types/native-fetcher.d.ts +0 -7
- package/types/site/graphql-robots-service.d.ts +3 -2
- package/types/tools/auth/encryption.d.ts +34 -0
- package/types/tools/auth/fetcher.d.ts +13 -0
- package/types/tools/auth/flow.d.ts +40 -0
- package/types/tools/auth/index.d.ts +5 -0
- package/types/tools/auth/models.d.ts +233 -0
- package/types/tools/auth/renewal.d.ts +36 -0
- package/types/tools/auth/tenant-state.d.ts +21 -0
- package/types/tools/auth/tenant-store.d.ts +63 -0
- package/types/tools/index.d.ts +3 -0
- package/types/utils/normalize-url.d.ts +1 -0
- package/dist/cjs/data-fetcher.js +0 -22
- package/dist/esm/data-fetcher.js +0 -17
- package/form.d.ts +0 -1
- package/form.js +0 -1
- package/types/data-fetcher.d.ts +0 -34
|
@@ -6,6 +6,7 @@ import { HTMLLink, FetchOptions, StaticPath, RetryStrategy } from '../models';
|
|
|
6
6
|
import { PersonalizedRewriteData } from '../personalize/utils';
|
|
7
7
|
import { ErrorPages, SiteInfo, SiteResolver, GraphQLErrorPagesService, GraphQLSitePathService, GraphQLSitemapXmlService } from '../site';
|
|
8
8
|
import { SitecoreClientInit } from './models';
|
|
9
|
+
import { GraphQLRobotsService } from '../site/graphql-robots-service';
|
|
9
10
|
/**
|
|
10
11
|
* Represent a Page model returned from Edge endpoint
|
|
11
12
|
*/
|
|
@@ -39,6 +40,15 @@ export type SitemapXmlOptions = {
|
|
|
39
40
|
/** The site name to resolve the sitemap for */
|
|
40
41
|
siteName?: string;
|
|
41
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* Options for fetching robots.txt content.
|
|
45
|
+
*/
|
|
46
|
+
export type RobotsOptions = {
|
|
47
|
+
/**
|
|
48
|
+
* The name of the site for which to fetch robots.txt content.
|
|
49
|
+
*/
|
|
50
|
+
siteName: string;
|
|
51
|
+
};
|
|
42
52
|
/**
|
|
43
53
|
* Contract for the Sitecore Client implementations
|
|
44
54
|
*/
|
|
@@ -53,33 +63,34 @@ export interface BaseSitecoreClient {
|
|
|
53
63
|
* Retrieves page layoutData and returns page details like language, layoutData and site info for current request
|
|
54
64
|
* @param {string} path current request path
|
|
55
65
|
* @param {PageOptions} pageOptions additional overrides like language, site name and personalization variants
|
|
56
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
66
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
57
67
|
* @returns {Page | null} page details when page layout is found and null when not
|
|
58
68
|
*/
|
|
59
69
|
getPage(path: string | string[], pageOptions?: PageOptions, fetchOptions?: FetchOptions): Promise<Page | null>;
|
|
60
70
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* @param {
|
|
64
|
-
* @
|
|
71
|
+
* Retrieves the robots.txt content for a given site name.
|
|
72
|
+
* @param {string} siteName - The name of the site for which to fetch robots.txt content.
|
|
73
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
74
|
+
* @returns {Promise<string>} A promise that resolves to the robots.txt content.
|
|
65
75
|
*/
|
|
76
|
+
getRobots(siteName: string, fetchOptions?: FetchOptions): Promise<string | null>;
|
|
66
77
|
getDictionary(routeOptions?: Partial<RouteOptions>, fetchOptions?: FetchOptions): Promise<DictionaryPhrases>;
|
|
67
78
|
/**
|
|
68
79
|
* Get error pages configured by SXA for a given site and locale
|
|
69
80
|
* @param {RouteOptions} [routeOptions] language and site to load error pages for
|
|
70
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
81
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
71
82
|
*/
|
|
72
83
|
getErrorPages(routeOptions?: RouteOptions, fetchOptions?: FetchOptions): Promise<ErrorPages | null>;
|
|
73
84
|
/**
|
|
74
85
|
* Get preview layout details based on details from EditingPreviewData input
|
|
75
86
|
* @param {EditingPreviewData | undefined} previewData preview details like route, site, language etc used to retrieve preview page and layout
|
|
76
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
87
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
77
88
|
*/
|
|
78
89
|
getPreview(previewData: EditingPreviewData | undefined, fetchOptions?: FetchOptions): Promise<Page | null>;
|
|
79
90
|
/**
|
|
80
91
|
* Get route paths for all pages in the site. Can be used for static site generation.
|
|
81
92
|
* @param {string[]} [languages] languages to fetch routes in
|
|
82
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
93
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
83
94
|
*/
|
|
84
95
|
getPagePaths(languages?: string[], fetchOptions?: FetchOptions): Promise<StaticPath[]>;
|
|
85
96
|
/**
|
|
@@ -97,9 +108,17 @@ export interface BaseSitecoreClient {
|
|
|
97
108
|
/**
|
|
98
109
|
* Retrieves sitemap XML content - either a specific sitemap or the index of all sitemaps.
|
|
99
110
|
* @param { SitemapRequestConfig} reqOptions - Configuration for sitemap retrieval
|
|
111
|
+
* @param {FetchOptions} [fetchOptions] - Additional fetchOptions Additional fetch options to override GraphQL requests
|
|
100
112
|
* @returns {Promise<string>} Promise resolving to the sitemap XML content as string
|
|
101
113
|
*/
|
|
102
|
-
getSiteMap(reqOptions: SitemapXmlOptions): Promise<string>;
|
|
114
|
+
getSiteMap(reqOptions: SitemapXmlOptions, fetchOptions?: FetchOptions): Promise<string>;
|
|
115
|
+
/**
|
|
116
|
+
* Retrieves the robots.txt content for a given site name.
|
|
117
|
+
* @param {string} siteName - The name of the site for which to fetch robots.txt content.
|
|
118
|
+
* @param {FetchOptions} fetchOptions Additional fetch options to override GraphQL requests
|
|
119
|
+
* @returns {Promise<string>} A promise that resolves to the robots.txt content.
|
|
120
|
+
*/
|
|
121
|
+
getRobots(siteName: string, fetchOptions?: FetchOptions): Promise<string | null>;
|
|
103
122
|
}
|
|
104
123
|
export interface BaseServiceOptions {
|
|
105
124
|
defaultSite: string;
|
|
@@ -144,7 +163,7 @@ export declare class SitecoreClient implements BaseSitecoreClient {
|
|
|
144
163
|
* Get page details for a route, with layout and other details
|
|
145
164
|
* @param {string} path route path
|
|
146
165
|
* @param {PageOptions} [pageOptions] site, language and personalization variant details for route
|
|
147
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
166
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
148
167
|
* @returns {Page | null} page details
|
|
149
168
|
*/
|
|
150
169
|
getPage(path: string | string[], pageOptions?: PageOptions, fetchOptions?: FetchOptions): Promise<Page | null>;
|
|
@@ -163,28 +182,28 @@ export declare class SitecoreClient implements BaseSitecoreClient {
|
|
|
163
182
|
/**
|
|
164
183
|
* Retrieves dictionary phrases for a given site and locale.
|
|
165
184
|
* @param {RouteOptions} routeOptions - Route options containing language and site name to load dictionary for
|
|
166
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
185
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
167
186
|
* @returns {DictionaryPhrases} A promise that resolves to the dictionary phrases.
|
|
168
187
|
*/
|
|
169
188
|
getDictionary(routeOptions?: Partial<RouteOptions>, fetchOptions?: FetchOptions): Promise<DictionaryPhrases>;
|
|
170
189
|
/**
|
|
171
190
|
* Retrieves error pages for a given site and locale.
|
|
172
191
|
* @param {RouteOptions} routeOptions - Route options containing language and site name to load error pages
|
|
173
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
192
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
174
193
|
* @returns {ErrorPages | null} A promise that resolves to the error pages or null if not found.
|
|
175
194
|
*/
|
|
176
195
|
getErrorPages(routeOptions?: RouteOptions, fetchOptions?: FetchOptions): Promise<ErrorPages | null>;
|
|
177
196
|
/**
|
|
178
197
|
* Retrieves preview page and layout details
|
|
179
198
|
* @param {EditingPreviewData | undefined} previewData - The editing preview data for metadata mode.
|
|
180
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
199
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
181
200
|
* @returns {Page} preview page details
|
|
182
201
|
*/
|
|
183
202
|
getPreview(previewData: EditingPreviewData | undefined, fetchOptions?: FetchOptions): Promise<Page | null>;
|
|
184
203
|
/**
|
|
185
204
|
* Get design library page details for Design Library mode of your app
|
|
186
205
|
* @param {DesignLibraryRenderPreviewData} designLibData preview data set in 'library' mode of the app
|
|
187
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
206
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
188
207
|
* @returns {Page} preview page for Design Library
|
|
189
208
|
*/
|
|
190
209
|
getDesignLibraryData(designLibData: DesignLibraryRenderPreviewData, fetchOptions?: FetchOptions): Promise<Page>;
|
|
@@ -203,18 +222,27 @@ export declare class SitecoreClient implements BaseSitecoreClient {
|
|
|
203
222
|
* @throws {Error} Throws 'REDIRECT_404' if requested sitemap is not found
|
|
204
223
|
*/
|
|
205
224
|
getSiteMap(reqOptions: SitemapXmlOptions, fetchOptions?: FetchOptions): Promise<string>;
|
|
225
|
+
/**
|
|
226
|
+
* Retrieves the robots.txt content for a given site name.
|
|
227
|
+
* @param {string} siteName - The name of the site to retrieve the robots.txt for.
|
|
228
|
+
* @param {FetchOptions} [fetchOptions] - Optional fetch options.
|
|
229
|
+
* @returns {Promise<string | null>} A promise that resolves to the robots.txt content,
|
|
230
|
+
* or null if no content is found.
|
|
231
|
+
*/
|
|
232
|
+
getRobots(siteName: string, fetchOptions?: FetchOptions): Promise<string | null>;
|
|
206
233
|
/**
|
|
207
234
|
* Factory methods for creating dependencies
|
|
208
235
|
* Subclasses can override these to provide custom implementations.
|
|
209
236
|
*/
|
|
210
237
|
protected getGraphqlSitemapXMLService(siteName: string): GraphQLSitemapXmlService;
|
|
238
|
+
protected getRobotsService(siteName: string): GraphQLRobotsService;
|
|
211
239
|
protected getBaseServiceOptions(): BaseServiceOptions;
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
240
|
+
private getClientFactory;
|
|
241
|
+
private getSiteResolver;
|
|
242
|
+
private getLayoutService;
|
|
243
|
+
private getDictionaryService;
|
|
244
|
+
private getEditingService;
|
|
245
|
+
private getErrorPagesService;
|
|
246
|
+
private getComponentService;
|
|
247
|
+
private getSitePathService;
|
|
220
248
|
}
|
package/types/config/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { SitecoreConfig, SitecoreConfigInput, SitecoreCliConfig, SitecoreCliConfigInput, ScaffoldTemplate, ComponentTemplateType, } from './models';
|
|
1
|
+
export { SitecoreConfig, SitecoreConfigInput, SitecoreCliConfig, SitecoreCliConfigInput, ScaffoldTemplate, ComponentTemplateType, DeepRequired, } from './models';
|
|
2
2
|
export { defineConfig } from './define-config';
|
|
3
3
|
export { defineCliConfig } from './define-cli-config';
|
package/types/config/models.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export type SitecoreConfigInput = {
|
|
|
13
13
|
* API settings required to connect to Sitecore.
|
|
14
14
|
* Both edge and local set can be specified as JSS app will use API Key for component library
|
|
15
15
|
*/
|
|
16
|
-
api
|
|
16
|
+
api?: {
|
|
17
17
|
/**
|
|
18
18
|
* Edge endpoint credentials for Sitecore connection. Will be used to connect to SaaS XMCloud instance
|
|
19
19
|
*/
|
|
@@ -55,7 +55,7 @@ export type SitecoreConfigInput = {
|
|
|
55
55
|
* The default and fallback locale for your site.
|
|
56
56
|
* Ensure it aligns with the framework-specific settings used in your application.
|
|
57
57
|
*/
|
|
58
|
-
defaultLanguage
|
|
58
|
+
defaultLanguage?: string;
|
|
59
59
|
/**
|
|
60
60
|
* Your default site name. When using the multisite feature this variable defines the fallback site.
|
|
61
61
|
* @default empty string
|
|
@@ -63,6 +63,7 @@ export type SitecoreConfigInput = {
|
|
|
63
63
|
defaultSite?: string;
|
|
64
64
|
/**
|
|
65
65
|
* Editing secret required to support Sitecore editing and preview functionality.
|
|
66
|
+
* by default set by the JSS_EDITING_SECRET environment variable
|
|
66
67
|
*/
|
|
67
68
|
editingSecret?: string;
|
|
68
69
|
/**
|
|
@@ -132,10 +133,14 @@ export type SitecoreConfigInput = {
|
|
|
132
133
|
enabled?: boolean;
|
|
133
134
|
/**
|
|
134
135
|
* Configuration for your Sitecore Experience Edge endpoint
|
|
136
|
+
* by default set by the PERSONALIZE_MIDDLEWARE_EDGE_TIMEOUT environment variable
|
|
137
|
+
* if not set, will use the default value of 400ms
|
|
135
138
|
*/
|
|
136
139
|
edgeTimeout?: number;
|
|
137
140
|
/**
|
|
138
141
|
* Configuration for your Sitecore CDP endpoint
|
|
142
|
+
* by default set by the PERSONALIZE_MIDDLEWARE_CDP_TIMEOUT environment variable
|
|
143
|
+
* if not set, will use the default value of 400ms
|
|
139
144
|
*/
|
|
140
145
|
cdpTimeout?: number;
|
|
141
146
|
/**
|
|
@@ -166,6 +171,11 @@ export type SitecoreConfigInput = {
|
|
|
166
171
|
*/
|
|
167
172
|
locales?: string[];
|
|
168
173
|
};
|
|
174
|
+
/**
|
|
175
|
+
* Opt-out setting for code generation feature
|
|
176
|
+
* Disables code extraction procedure
|
|
177
|
+
*/
|
|
178
|
+
disableCodeGeneration?: boolean;
|
|
169
179
|
};
|
|
170
180
|
/**
|
|
171
181
|
* Final sitecore config type used at runtime
|
package/types/constants.d.ts
CHANGED
|
@@ -5,3 +5,13 @@ export declare enum SitecoreTemplateId {
|
|
|
5
5
|
export declare const siteNameError = "The siteName cannot be empty";
|
|
6
6
|
export declare const SITECORE_EDGE_URL_DEFAULT = "https://edge-platform.sitecorecloud.io";
|
|
7
7
|
export declare const HIDDEN_RENDERING_NAME = "Hidden Rendering";
|
|
8
|
+
export declare const DEFAULT_SITECORE_AUTH_DOMAIN = "https://auth.sitecorecloud.io";
|
|
9
|
+
export declare const DEFAULT_SITECORE_AUTH_AUDIENCE = "https://api.sitecorecloud.io";
|
|
10
|
+
export declare const DEFAULT_SITECORE_AUTH_BASE_URL = "https://edge-platform.sitecorecloud.io/cs/api";
|
|
11
|
+
export declare const CLAIMS = "https://auth.sitecorecloud.io/claims";
|
|
12
|
+
export declare const CLIENT_GRANT_TYPE = "client_credentials";
|
|
13
|
+
export declare const DEVICE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
14
|
+
export declare const REFRESH_GRANT_TYPE = "refresh_token";
|
|
15
|
+
export declare const SCOPE = "openid profile email offline_access";
|
|
16
|
+
export declare const TIMEOUT = 600;
|
|
17
|
+
export declare const DEFAULT_INTERVAL = 10;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { DocumentNode } from 'graphql';
|
|
2
|
+
import { GraphQLRequestClient } from '../graphql-request-client';
|
|
3
|
+
import { FetchOptions } from '../models';
|
|
4
|
+
import { Taxonomy } from './taxonomies';
|
|
5
|
+
/**
|
|
6
|
+
* Interface representing the options for the ContentClient.
|
|
7
|
+
*/
|
|
8
|
+
export interface ContentClientOptions {
|
|
9
|
+
/** The base URL for the Content API. */
|
|
10
|
+
url?: string;
|
|
11
|
+
/** The tenant name. */
|
|
12
|
+
tenant: string;
|
|
13
|
+
/** The environment name. */
|
|
14
|
+
environment: string;
|
|
15
|
+
/** Indicates if preview mode is enabled. */
|
|
16
|
+
preview?: boolean;
|
|
17
|
+
/** The authentication token. */
|
|
18
|
+
token: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Class representing a client for interacting with the Content API.
|
|
22
|
+
*/
|
|
23
|
+
export declare class ContentClient {
|
|
24
|
+
endpoint: string;
|
|
25
|
+
graphqlClient: GraphQLRequestClient;
|
|
26
|
+
constructor({ url, tenant, environment, preview, token }: ContentClientOptions);
|
|
27
|
+
/**
|
|
28
|
+
* Factory method for creating a ContentClient instance. This method allows you to create a client with the values populated from environment variables or provided as arguments.
|
|
29
|
+
* @param {Partial<ContentClientOptions>} [options] - client configuration options
|
|
30
|
+
* @param {string} [options.url] - Content base graphql endpoint url. If not provided, it will be read from the SITECORE_CS_URL environment variable. Otherwise, it defaults to https://cs-graphqlapi-staging.sitecore-staging.cloud.
|
|
31
|
+
* @param {string} [options.tenant] - Tenant name. If not provided, it will be read from the SITECORE_CS_TENANT environment variable
|
|
32
|
+
* @param {string} [options.environment] - Environment name. If not provided, it will be read from the SITECORE_CS_ENVIRONMENT environment variable. Otherwise, it defaults to 'main'
|
|
33
|
+
* @param {boolean} [options.preview] - Indicates if preview mode is enabled. If not provided, it will be read from the SITECORE_CS_PREVIEW environment variable. Otherwise, it defaults to false
|
|
34
|
+
* @param {string} [options.token] - Token for authentication. If not provided, it will be read from the SITECORE_CS_TOKEN environment variable.
|
|
35
|
+
* @returns {ContentClient} ContentClient instance
|
|
36
|
+
* @throws {Error} If tenant or token is not provided
|
|
37
|
+
*/
|
|
38
|
+
static createClient({ url, tenant, environment, preview, token, }?: Partial<ContentClientOptions>): ContentClient;
|
|
39
|
+
/**
|
|
40
|
+
* Execute graphql request
|
|
41
|
+
* @param {string | DocumentNode} query graphql query
|
|
42
|
+
* @param {object} variables variables for the query
|
|
43
|
+
* @param {FetchOptions} options options for configuring the request
|
|
44
|
+
* @returns {T} response data
|
|
45
|
+
*/
|
|
46
|
+
get<T>(query: string | DocumentNode, variables?: Record<string, unknown>, options?: FetchOptions): Promise<T>;
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves the locale information for a given locale ID.
|
|
49
|
+
* @param {string} id - The unique identifier of the locale item.
|
|
50
|
+
* @returns A promise that resolves to the locale information associated with the specified locale ID.
|
|
51
|
+
*/
|
|
52
|
+
getLocale(id: string): Promise<import("./locales").Locale | null>;
|
|
53
|
+
/**
|
|
54
|
+
* Retrieves all available locales from the content service.
|
|
55
|
+
* @returns A promise that resolves to an array of locales.
|
|
56
|
+
*/
|
|
57
|
+
getLocales(): Promise<import("./locales").Locale[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Retrieves all available taxonomies with optional pagination support.
|
|
60
|
+
* @param {object} [options] - Optional pagination options.
|
|
61
|
+
* @param {number} [options.pageSize] - Limits the number of taxonomies returned per page. Defaults to the API's default
|
|
62
|
+
* @param {string} [options.after] - Cursor for pagination; use the `cursor` returned from the previous call to fetch the next page.
|
|
63
|
+
* @returns A promise that resolves to an object containing taxonomies, their terms, and pagination info.
|
|
64
|
+
*/
|
|
65
|
+
getTaxonomies(options?: {
|
|
66
|
+
pageSize?: number;
|
|
67
|
+
after?: string;
|
|
68
|
+
}): Promise<{
|
|
69
|
+
results: {
|
|
70
|
+
system: import("./taxonomies").TaxonomySystem;
|
|
71
|
+
terms: import("./taxonomies").Term[];
|
|
72
|
+
}[];
|
|
73
|
+
cursor: string | undefined;
|
|
74
|
+
hasMore: boolean;
|
|
75
|
+
}>;
|
|
76
|
+
/**
|
|
77
|
+
* Retrieves a taxonomy by its ID, with optional pagination support for its terms.
|
|
78
|
+
* @param {object} options - Options for fetching the taxonomy.
|
|
79
|
+
* @param {string} options.id - The unique identifier of the taxonomy.
|
|
80
|
+
* @param {object} [options.terms] - Optional pagination options for terms.
|
|
81
|
+
* @param {number} [options.terms.pageSize] - Optional. Limits the number of terms returned per page.
|
|
82
|
+
* @param {string} [options.terms.after] - Optional. Cursor for pagination. Used to fetch the next page of terms.
|
|
83
|
+
* @returns A promise that resolves to the taxonomy object, including pagination metadata (`hasMore`, `cursor`) for its terms. Returns `null` if the taxonomy is not found.
|
|
84
|
+
*/
|
|
85
|
+
getTaxonomy({ id, terms, }: {
|
|
86
|
+
id: string;
|
|
87
|
+
terms?: {
|
|
88
|
+
pageSize?: number;
|
|
89
|
+
after?: string;
|
|
90
|
+
};
|
|
91
|
+
}): Promise<Taxonomy | null>;
|
|
92
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { ContentClient, ContentClientOptions } from './content-client';
|
|
2
|
+
export { GET_LOCALE_QUERY, GET_LOCALES_QUERY, LocaleQueryResponse, LocalesQueryResponse, Locale, } from './locales';
|
|
3
|
+
export { GET_TAXONOMY_QUERY, GET_TAXONOMIES_QUERY, TaxonomyQueryResponse, TaxonomiesQueryResponse, Taxonomy, TaxonomySystem, Term, } from './taxonomies';
|
|
4
|
+
export { getContentUrl } from './utils';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents the locale entity.
|
|
3
|
+
*/
|
|
4
|
+
export type Locale = {
|
|
5
|
+
/** The unique identifier of the locale. */
|
|
6
|
+
id: string;
|
|
7
|
+
/** The label of the locale. */
|
|
8
|
+
label: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A locale item included in a locale query response.
|
|
12
|
+
*/
|
|
13
|
+
export type LocaleItem = {
|
|
14
|
+
system: Locale;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Represents the response structure for a query that retrieves a single locale.
|
|
18
|
+
*/
|
|
19
|
+
export interface LocaleQueryResponse {
|
|
20
|
+
locale: LocaleItem | null;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Represents the response structure for a query that retrieves multiple locales.
|
|
24
|
+
*/
|
|
25
|
+
export interface LocalesQueryResponse {
|
|
26
|
+
manyLocale: LocaleItem[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* GraphQL query to retrieve a specific locale by its ID.
|
|
30
|
+
*
|
|
31
|
+
* Variables:
|
|
32
|
+
* - id: The ID of the locale to retrieve.
|
|
33
|
+
*/
|
|
34
|
+
export declare const GET_LOCALE_QUERY = "\n query GetLocaleById($id: ID!) {\n locale(id: $id) {\n system {\n id\n label\n }\n }\n }\n";
|
|
35
|
+
/**
|
|
36
|
+
* GraphQL query to retrieve all available locales.
|
|
37
|
+
*/
|
|
38
|
+
export declare const GET_LOCALES_QUERY = "\n query GetAllLocales {\n manyLocale {\n system {\n id\n label\n }\n }\n }\n";
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a term within a taxonomy.
|
|
3
|
+
*/
|
|
4
|
+
export type Term = {
|
|
5
|
+
/** The unique identifier of the term. */
|
|
6
|
+
id: string;
|
|
7
|
+
/** The internal name of the term. */
|
|
8
|
+
name: string;
|
|
9
|
+
/** The display label of the term. */
|
|
10
|
+
label: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Represents a list of terms within a taxonomy.
|
|
14
|
+
* In getTaxonomies, terms are always returned as a full list (no pagination).
|
|
15
|
+
* In getTaxonomy, terms may be paginated.
|
|
16
|
+
*/
|
|
17
|
+
export interface TermList {
|
|
18
|
+
/** The list of terms in the current (or full) page. */
|
|
19
|
+
results: Term[];
|
|
20
|
+
/** The cursor to fetch the next page of terms, if available. (Used only in getTaxonomy) */
|
|
21
|
+
cursor?: string | null;
|
|
22
|
+
/** Indicates whether more terms are available after the current page. (Used only in getTaxonomy) */
|
|
23
|
+
hasMore: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Represents the system metadata of a taxonomy.
|
|
27
|
+
*/
|
|
28
|
+
export type TaxonomySystem = {
|
|
29
|
+
/** The unique identifier of the taxonomy. */
|
|
30
|
+
id: string;
|
|
31
|
+
/** The internal name of the taxonomy. */
|
|
32
|
+
name: string;
|
|
33
|
+
/** The version of the taxonomy. */
|
|
34
|
+
version: number;
|
|
35
|
+
/** The display label of the taxonomy. */
|
|
36
|
+
label: string;
|
|
37
|
+
/** The timestamp when the taxonomy was created (ISO 8601 format). */
|
|
38
|
+
createdAt: string;
|
|
39
|
+
/** The user ID who created the taxonomy. */
|
|
40
|
+
createdBy: string;
|
|
41
|
+
/** The timestamp when the taxonomy was last updated (ISO 8601 format). */
|
|
42
|
+
updatedAt: string;
|
|
43
|
+
/** The user ID who last updated the taxonomy. */
|
|
44
|
+
updatedBy: string;
|
|
45
|
+
/** The publish status of the taxonomy (e.g., PREVIEW, PUBLISHED). */
|
|
46
|
+
publishStatus: string;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Represents a taxonomy with its associated terms.
|
|
50
|
+
* Terms are paginated only in single-taxonomy queries (getTaxonomy).
|
|
51
|
+
*/
|
|
52
|
+
export type Taxonomy = {
|
|
53
|
+
/** The list of terms within the taxonomy. */
|
|
54
|
+
terms: TermList;
|
|
55
|
+
/** The system metadata of the taxonomy. */
|
|
56
|
+
system: TaxonomySystem;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Represents the response structure for a query that retrieves a specific taxonomy by ID.
|
|
60
|
+
*/
|
|
61
|
+
export interface TaxonomyQueryResponse {
|
|
62
|
+
/** The retrieved taxonomy. */
|
|
63
|
+
taxonomy: {
|
|
64
|
+
/** The system metadata of the taxonomy. */
|
|
65
|
+
system: TaxonomySystem;
|
|
66
|
+
/** The terms for the taxonomy (may be paginated). */
|
|
67
|
+
terms: {
|
|
68
|
+
results: Term[];
|
|
69
|
+
cursor?: string | null;
|
|
70
|
+
hasMore: boolean;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Represents the response structure for a query that retrieves multiple taxonomies.
|
|
76
|
+
*/
|
|
77
|
+
export interface TaxonomiesQueryResponse {
|
|
78
|
+
/** The list of retrieved taxonomies, with pagination metadata. */
|
|
79
|
+
manyTaxonomy: {
|
|
80
|
+
/** The list of taxonomies in the current page. */
|
|
81
|
+
results: {
|
|
82
|
+
/** The terms associated with the taxonomy (always the full list, not paginated). */
|
|
83
|
+
terms: {
|
|
84
|
+
results: Term[];
|
|
85
|
+
cursor?: string | null;
|
|
86
|
+
hasMore: boolean;
|
|
87
|
+
};
|
|
88
|
+
/** The system metadata of the taxonomy. */
|
|
89
|
+
system: TaxonomySystem;
|
|
90
|
+
}[];
|
|
91
|
+
/** The cursor for fetching the next page of taxonomies, if available. */
|
|
92
|
+
cursor?: string;
|
|
93
|
+
/** Indicates whether more taxonomies are available after the current page. */
|
|
94
|
+
hasMore: boolean;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Represents a paginated list of content items (generic for various types, e.g., Taxonomy).
|
|
99
|
+
* Note: This type does not include any stateful fetchNext/fetchMore helpers. Pagination is stateless.
|
|
100
|
+
*/
|
|
101
|
+
export interface ContentItemList<T> {
|
|
102
|
+
/** The list of content items in the current page. */
|
|
103
|
+
results: T[];
|
|
104
|
+
/** The cursor for fetching the next page of items, if available. */
|
|
105
|
+
cursor?: string;
|
|
106
|
+
/** Indicates whether more items are available after the current page. */
|
|
107
|
+
hasMore: boolean;
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* GraphQL query to retrieve all taxonomies with optional pagination for taxonomies only.
|
|
111
|
+
*
|
|
112
|
+
* Variables:
|
|
113
|
+
* - pageSize: The number of taxonomies to retrieve per page.
|
|
114
|
+
* - after: The cursor for fetching the next page of taxonomies.
|
|
115
|
+
*/
|
|
116
|
+
export declare const GET_TAXONOMIES_QUERY = "\n query GetAllTaxonomies(\n $pageSize: Int\n $after: String\n ) {\n manyTaxonomy(minimumPageSize: $pageSize, after: $after) {\n cursor\n hasMore\n results {\n terms {\n cursor\n hasMore\n results {\n id\n name\n label\n }\n }\n system {\n id\n name\n version\n label\n createdAt\n createdBy\n updatedAt\n updatedBy\n publishStatus\n }\n }\n }\n }\n";
|
|
117
|
+
/**
|
|
118
|
+
* GraphQL query to retrieve a specific taxonomy by its ID, with optional pagination for its terms.
|
|
119
|
+
*
|
|
120
|
+
* Variables:
|
|
121
|
+
* - id: The unique ID of the taxonomy to retrieve.
|
|
122
|
+
* - termsPageSize: The number of terms to retrieve per page.
|
|
123
|
+
* - termsAfter: The cursor for fetching the next page of terms.
|
|
124
|
+
*/
|
|
125
|
+
export declare const GET_TAXONOMY_QUERY = "\n query GetTaxonomyById($id: ID!, $termsPageSize: Int, $termsAfter: String) {\n taxonomy(id: $id) {\n terms(minimumPageSize: $termsPageSize, after: $termsAfter) {\n cursor\n hasMore\n results {\n id\n name\n label\n }\n }\n system {\n id\n name\n version\n label\n createdAt\n createdBy\n updatedAt\n updatedBy\n publishStatus\n }\n }\n }\n";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the Content graphql endpoint url
|
|
3
|
+
* @param {object} params Parameters
|
|
4
|
+
* @param {string} [params.url] Content base graphql endpoint url
|
|
5
|
+
* @param {string} params.tenant Tenant name
|
|
6
|
+
* @param {string} params.environment Environment name
|
|
7
|
+
* @param {boolean} params.preview Indicates if preview mode is enabled
|
|
8
|
+
* @returns {string} Content graphql endpoint url
|
|
9
|
+
*/
|
|
10
|
+
export declare function getContentUrl({ url, tenant, environment, preview, }: {
|
|
11
|
+
url?: string;
|
|
12
|
+
tenant: string;
|
|
13
|
+
environment: string;
|
|
14
|
+
preview: boolean;
|
|
15
|
+
}): string;
|
package/types/debug.d.ts
CHANGED
|
@@ -1,41 +1,4 @@
|
|
|
1
|
-
import { LayoutServiceData
|
|
2
|
-
import { IncomingMessage, ServerResponse } from 'http';
|
|
3
|
-
import { HttpDataFetcher } from '../data-fetcher';
|
|
4
|
-
/**
|
|
5
|
-
* Data fetcher resolver in order to provide custom data fetcher
|
|
6
|
-
* @param {IncomingMessage} [req] Request instance
|
|
7
|
-
* @param {ServerResponse} [res] Response instance
|
|
8
|
-
*/
|
|
9
|
-
export type DataFetcherResolver = <T>(req?: IncomingMessage, res?: ServerResponse) => HttpDataFetcher<T>;
|
|
10
|
-
export type RestLayoutServiceConfig = {
|
|
11
|
-
/**
|
|
12
|
-
* Your Sitecore instance hostname that is the backend for JSS
|
|
13
|
-
*/
|
|
14
|
-
apiHost: string;
|
|
15
|
-
/**
|
|
16
|
-
* The Sitecore SSC API key your app uses
|
|
17
|
-
*/
|
|
18
|
-
apiKey: string;
|
|
19
|
-
/**
|
|
20
|
-
* The JSS application name
|
|
21
|
-
*/
|
|
22
|
-
siteName: string;
|
|
23
|
-
/**
|
|
24
|
-
* Enables/disables analytics tracking for the Layout Service invocation (default is true).
|
|
25
|
-
* More than likely, this would be set to false for SSG/hybrid implementations, and the
|
|
26
|
-
* JSS tracker would instead be used on the client-side
|
|
27
|
-
* @default true
|
|
28
|
-
*/
|
|
29
|
-
tracking?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Function that handles fetching API data
|
|
32
|
-
*/
|
|
33
|
-
dataFetcherResolver?: DataFetcherResolver;
|
|
34
|
-
/**
|
|
35
|
-
* Layout Service "named" configuration
|
|
36
|
-
*/
|
|
37
|
-
configurationName?: string;
|
|
38
|
-
};
|
|
1
|
+
import { LayoutServiceData } from '../layout/models';
|
|
39
2
|
/**
|
|
40
3
|
* Params for requesting component data from service in Design Library mode
|
|
41
4
|
*/
|
|
@@ -66,35 +29,37 @@ export interface ComponentLayoutRequestParams {
|
|
|
66
29
|
*/
|
|
67
30
|
version?: string;
|
|
68
31
|
/**
|
|
69
|
-
*
|
|
32
|
+
* site name to be used as context for rendering the component
|
|
70
33
|
*/
|
|
71
|
-
|
|
34
|
+
siteName: string;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Config for the RestComponentLayoutService
|
|
38
|
+
*/
|
|
39
|
+
export interface RestComponentLayoutServiceConfig {
|
|
72
40
|
/**
|
|
73
|
-
*
|
|
41
|
+
* A unified identifier used to connect and retrieve data from XM Cloud instance
|
|
74
42
|
*/
|
|
75
|
-
|
|
43
|
+
contextId: string;
|
|
44
|
+
/**
|
|
45
|
+
* XM Cloud endpoint that the app will communicate and retrieve data from
|
|
46
|
+
* @default https://edge-platform.sitecorecloud.io
|
|
47
|
+
*/
|
|
48
|
+
edgeUrl?: string;
|
|
76
49
|
}
|
|
77
50
|
/**
|
|
78
|
-
* REST service that enables
|
|
79
|
-
* Makes a request to /sitecore/api/layout/component in 'library' mode in Pages.
|
|
51
|
+
* REST service that enables design Library functionality
|
|
80
52
|
* Returns layoutData for one single rendered component
|
|
81
53
|
*/
|
|
82
54
|
export declare class RestComponentLayoutService {
|
|
83
55
|
private config;
|
|
84
|
-
constructor(config:
|
|
85
|
-
fetchComponentData(params: ComponentLayoutRequestParams
|
|
86
|
-
protected
|
|
87
|
-
/**
|
|
88
|
-
* Resolves layout service url
|
|
89
|
-
* @param {string} apiType which layout service API to call ('render' or 'placeholder')
|
|
90
|
-
* @returns the layout service url
|
|
91
|
-
*/
|
|
92
|
-
protected resolveLayoutServiceUrl(apiType: string): string;
|
|
56
|
+
constructor(config: RestComponentLayoutServiceConfig);
|
|
57
|
+
fetchComponentData(params: ComponentLayoutRequestParams): Promise<LayoutServiceData>;
|
|
58
|
+
protected getComponentFetchParams(params: ComponentLayoutRequestParams): any;
|
|
93
59
|
/**
|
|
94
|
-
*
|
|
95
|
-
* @param {
|
|
96
|
-
* @returns
|
|
60
|
+
* Get the fetch URL for the partial layout data endpoint
|
|
61
|
+
* @param {ComponentLayoutRequestParams} params - The parameters for the request
|
|
62
|
+
* @returns {string} The fetch URL for the component data
|
|
97
63
|
*/
|
|
98
|
-
|
|
99
|
-
protected getComponentFetchParams(params: ComponentLayoutRequestParams): any;
|
|
64
|
+
private getFetchUrl;
|
|
100
65
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as constants from './constants';
|
|
2
|
+
import * as form from './form';
|
|
2
3
|
export { default as debug, Debugger, enableDebug } from './debug';
|
|
3
4
|
export { GraphQLClient, GraphQLRequestClient, GraphQLRequestClientConfig, GraphQLRequestClientFactory, GraphQLRequestClientFactoryConfig, } from './graphql-request-client';
|
|
4
5
|
export { DefaultRetryStrategy } from './retries';
|
|
@@ -7,4 +8,5 @@ export { ClientError } from 'graphql-request';
|
|
|
7
8
|
export { NativeDataFetcher, NativeDataFetcherConfig, NativeDataFetcherError, NativeDataFetcherResponse, } from './native-fetcher';
|
|
8
9
|
export { HTMLLink, RetryStrategy, GenericGraphQLClientError, StaticPath } from './models';
|
|
9
10
|
export { constants };
|
|
11
|
+
export { form };
|
|
10
12
|
export { defineConfig } from './config';
|
|
@@ -33,13 +33,6 @@ export interface NativeDataFetcherResponse<T> {
|
|
|
33
33
|
export type NativeDataFetcherError = Error & {
|
|
34
34
|
response: NativeDataFetcherResponse<unknown>;
|
|
35
35
|
};
|
|
36
|
-
/**
|
|
37
|
-
* A function that fetches data from a given URL and returns a `NativeDataFetcherResponse`.
|
|
38
|
-
* @param {string} url The URL to request (can include query string parameters).
|
|
39
|
-
* @param {unknown} [data] Optional data to send with the request (e.g., for POST or PUT requests).
|
|
40
|
-
* @returns {Promise<NativeDataFetcherResponse<T>>} A promise that resolves to a `NativeDataFetcherResponse<T>`,
|
|
41
|
-
*/
|
|
42
|
-
export type NativeDataFetcherFunction<T> = (url: string, data?: RequestInit) => Promise<NativeDataFetcherResponse<T>>;
|
|
43
36
|
export type NativeDataFetcherConfig = NativeDataFetcherOptions & RequestInit;
|
|
44
37
|
export declare class NativeDataFetcher {
|
|
45
38
|
protected config: NativeDataFetcherConfig;
|