@sitecore-content-sdk/core 0.2.0-beta.6 → 0.2.0-beta.8
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/dist/cjs/client/sitecore-client.js +33 -11
- package/dist/cjs/config/define-config.js +5 -5
- package/dist/cjs/content/content-client.js +60 -3
- package/dist/cjs/content/taxonomies.js +78 -0
- package/dist/cjs/site/graphql-robots-service.js +2 -2
- package/dist/esm/client/sitecore-client.js +33 -11
- package/dist/esm/config/define-config.js +5 -5
- package/dist/esm/content/content-client.js +60 -3
- package/dist/esm/content/taxonomies.js +75 -0
- package/dist/esm/site/graphql-robots-service.js +2 -2
- package/package.json +16 -16
- 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 +7 -2
- package/types/content/content-client.d.ts +36 -3
- package/types/content/taxonomies.d.ts +125 -0
- package/types/site/graphql-robots-service.d.ts +2 -2
|
@@ -9,6 +9,7 @@ const layout_personalizer_1 = require("../personalize/layout-personalizer");
|
|
|
9
9
|
const site_1 = require("../site");
|
|
10
10
|
const utils_2 = require("./utils");
|
|
11
11
|
const native_fetcher_1 = require("../native-fetcher");
|
|
12
|
+
const graphql_robots_service_1 = require("../site/graphql-robots-service");
|
|
12
13
|
/**
|
|
13
14
|
* This is a generic content client that can be used by any framework.
|
|
14
15
|
* Use it to retrieve pages, preview data, dictionary and other data
|
|
@@ -19,16 +20,19 @@ class SitecoreClient {
|
|
|
19
20
|
* @param {SitecoreClientInit} initOptions initOptions for the client, containing site and Sitecore connection details
|
|
20
21
|
*/
|
|
21
22
|
constructor(initOptions) {
|
|
23
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
22
24
|
this.initOptions = initOptions;
|
|
23
25
|
this.clientFactory = this.getClientFactory();
|
|
24
|
-
this.siteResolver = this.getSiteResolver();
|
|
26
|
+
this.siteResolver = (_b = (_a = initOptions.custom) === null || _a === void 0 ? void 0 : _a.siteResolver) !== null && _b !== void 0 ? _b : this.getSiteResolver();
|
|
25
27
|
const baseServiceOptions = this.getBaseServiceOptions();
|
|
26
|
-
this.layoutService =
|
|
27
|
-
|
|
28
|
-
this.
|
|
29
|
-
|
|
28
|
+
this.layoutService =
|
|
29
|
+
(_d = (_c = initOptions.custom) === null || _c === void 0 ? void 0 : _c.layoutService) !== null && _d !== void 0 ? _d : this.getLayoutService(baseServiceOptions);
|
|
30
|
+
this.dictionaryService =
|
|
31
|
+
(_f = (_e = initOptions.custom) === null || _e === void 0 ? void 0 : _e.dictionaryService) !== null && _f !== void 0 ? _f : this.getDictionaryService(baseServiceOptions);
|
|
32
|
+
this.editingService = (_h = (_g = initOptions.custom) === null || _g === void 0 ? void 0 : _g.editingService) !== null && _h !== void 0 ? _h : this.getEditingService();
|
|
33
|
+
this.errorPagesService = (_k = (_j = initOptions.custom) === null || _j === void 0 ? void 0 : _j.errorPagesService) !== null && _k !== void 0 ? _k : this.getErrorPagesService();
|
|
34
|
+
this.sitePathService = (_m = (_l = initOptions.custom) === null || _l === void 0 ? void 0 : _l.sitePathService) !== null && _m !== void 0 ? _m : this.getSitePathService();
|
|
30
35
|
this.componentService = this.getComponentService();
|
|
31
|
-
this.sitePathService = this.getSitePathService();
|
|
32
36
|
}
|
|
33
37
|
/**
|
|
34
38
|
* Resolve site by hostname
|
|
@@ -59,7 +63,7 @@ class SitecoreClient {
|
|
|
59
63
|
* Get page details for a route, with layout and other details
|
|
60
64
|
* @param {string} path route path
|
|
61
65
|
* @param {PageOptions} [pageOptions] site, language and personalization variant details for route
|
|
62
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
66
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
63
67
|
* @returns {Page | null} page details
|
|
64
68
|
*/
|
|
65
69
|
async getPage(path, pageOptions, fetchOptions) {
|
|
@@ -115,7 +119,7 @@ class SitecoreClient {
|
|
|
115
119
|
/**
|
|
116
120
|
* Retrieves dictionary phrases for a given site and locale.
|
|
117
121
|
* @param {RouteOptions} routeOptions - Route options containing language and site name to load dictionary for
|
|
118
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
122
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
119
123
|
* @returns {DictionaryPhrases} A promise that resolves to the dictionary phrases.
|
|
120
124
|
*/
|
|
121
125
|
async getDictionary(routeOptions, fetchOptions) {
|
|
@@ -126,7 +130,7 @@ class SitecoreClient {
|
|
|
126
130
|
/**
|
|
127
131
|
* Retrieves error pages for a given site and locale.
|
|
128
132
|
* @param {RouteOptions} routeOptions - Route options containing language and site name to load error pages
|
|
129
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
133
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
130
134
|
* @returns {ErrorPages | null} A promise that resolves to the error pages or null if not found.
|
|
131
135
|
*/
|
|
132
136
|
async getErrorPages(routeOptions, fetchOptions) {
|
|
@@ -137,7 +141,7 @@ class SitecoreClient {
|
|
|
137
141
|
/**
|
|
138
142
|
* Retrieves preview page and layout details
|
|
139
143
|
* @param {EditingPreviewData | undefined} previewData - The editing preview data for metadata mode.
|
|
140
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
144
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
141
145
|
* @returns {Page} preview page details
|
|
142
146
|
*/
|
|
143
147
|
async getPreview(previewData, fetchOptions) {
|
|
@@ -171,7 +175,7 @@ class SitecoreClient {
|
|
|
171
175
|
/**
|
|
172
176
|
* Get design library page details for Design Library mode of your app
|
|
173
177
|
* @param {DesignLibraryRenderPreviewData} designLibData preview data set in 'library' mode of the app
|
|
174
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
178
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
175
179
|
* @returns {Page} preview page for Design Library
|
|
176
180
|
*/
|
|
177
181
|
async getDesignLibraryData(designLibData, fetchOptions) {
|
|
@@ -256,6 +260,18 @@ class SitecoreClient {
|
|
|
256
260
|
.join('')}
|
|
257
261
|
</sitemapindex>`;
|
|
258
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Retrieves the robots.txt content for a given site name.
|
|
265
|
+
* @param {string} siteName - The name of the site to retrieve the robots.txt for.
|
|
266
|
+
* @param {FetchOptions} [fetchOptions] - Optional fetch options.
|
|
267
|
+
* @returns {Promise<string | null>} A promise that resolves to the robots.txt content,
|
|
268
|
+
* or null if no content is found.
|
|
269
|
+
*/
|
|
270
|
+
async getRobots(siteName, fetchOptions) {
|
|
271
|
+
const robotsService = this.getRobotsService(siteName || this.initOptions.defaultSite);
|
|
272
|
+
const content = await robotsService.fetchRobots(fetchOptions);
|
|
273
|
+
return content || null;
|
|
274
|
+
}
|
|
259
275
|
/**
|
|
260
276
|
* Factory methods for creating dependencies
|
|
261
277
|
* Subclasses can override these to provide custom implementations.
|
|
@@ -266,6 +282,12 @@ class SitecoreClient {
|
|
|
266
282
|
siteName,
|
|
267
283
|
});
|
|
268
284
|
}
|
|
285
|
+
getRobotsService(siteName) {
|
|
286
|
+
return new graphql_robots_service_1.GraphQLRobotsService({
|
|
287
|
+
clientFactory: this.clientFactory,
|
|
288
|
+
siteName,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
269
291
|
getBaseServiceOptions() {
|
|
270
292
|
return {
|
|
271
293
|
defaultSite: this.initOptions.defaultSite,
|
|
@@ -10,9 +10,9 @@ const retries_1 = require("../retries");
|
|
|
10
10
|
const getFallbackConfig = () => ({
|
|
11
11
|
api: {
|
|
12
12
|
edge: {
|
|
13
|
-
contextId: '',
|
|
13
|
+
contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
|
|
14
14
|
clientContextId: '',
|
|
15
|
-
edgeUrl: constants_1.SITECORE_EDGE_URL_DEFAULT,
|
|
15
|
+
edgeUrl: process.env.SITECORE_EDGE_URL || constants_1.SITECORE_EDGE_URL_DEFAULT,
|
|
16
16
|
},
|
|
17
17
|
local: {
|
|
18
18
|
apiKey: '',
|
|
@@ -20,7 +20,7 @@ const getFallbackConfig = () => ({
|
|
|
20
20
|
path: '/sitecore/api/graph/edge',
|
|
21
21
|
},
|
|
22
22
|
},
|
|
23
|
-
editingSecret: 'editing-secret-missing',
|
|
23
|
+
editingSecret: process.env.JSS_EDITING_SECRET || 'editing-secret-missing',
|
|
24
24
|
retries: {
|
|
25
25
|
count: 3,
|
|
26
26
|
retryStrategy: new retries_1.DefaultRetryStrategy({
|
|
@@ -37,8 +37,8 @@ const getFallbackConfig = () => ({
|
|
|
37
37
|
},
|
|
38
38
|
personalize: {
|
|
39
39
|
enabled: process.env.NODE_ENV !== 'development',
|
|
40
|
-
edgeTimeout: 400,
|
|
41
|
-
cdpTimeout: 400,
|
|
40
|
+
edgeTimeout: parseInt(process.env.PERSONALIZE_MIDDLEWARE_EDGE_TIMEOUT, 10) || 400,
|
|
41
|
+
cdpTimeout: parseInt(process.env.PERSONALIZE_MIDDLEWARE_CDP_TIMEOUT, 10) || 400,
|
|
42
42
|
scope: '',
|
|
43
43
|
channel: 'WEB',
|
|
44
44
|
currency: 'USD',
|
|
@@ -8,6 +8,7 @@ const graphql_request_client_1 = require("../graphql-request-client");
|
|
|
8
8
|
const utils_1 = require("./utils");
|
|
9
9
|
const debug_1 = __importDefault(require("../debug"));
|
|
10
10
|
const locales_1 = require("./locales");
|
|
11
|
+
const taxonomies_1 = require("./taxonomies");
|
|
11
12
|
/**
|
|
12
13
|
* Class representing a client for interacting with the Content API.
|
|
13
14
|
*/
|
|
@@ -66,8 +67,7 @@ class ContentClient {
|
|
|
66
67
|
}
|
|
67
68
|
/**
|
|
68
69
|
* Retrieves the locale information for a given locale ID.
|
|
69
|
-
*
|
|
70
|
-
* @param id - The unique identifier of the locale item.
|
|
70
|
+
* @param {string} id - The unique identifier of the locale item.
|
|
71
71
|
* @returns A promise that resolves to the locale information associated with the specified locale ID.
|
|
72
72
|
*/
|
|
73
73
|
async getLocale(id) {
|
|
@@ -77,7 +77,6 @@ class ContentClient {
|
|
|
77
77
|
}
|
|
78
78
|
/**
|
|
79
79
|
* Retrieves all available locales from the content service.
|
|
80
|
-
*
|
|
81
80
|
* @returns A promise that resolves to an array of locales.
|
|
82
81
|
*/
|
|
83
82
|
async getLocales() {
|
|
@@ -85,5 +84,63 @@ class ContentClient {
|
|
|
85
84
|
const response = await this.get(locales_1.GET_LOCALES_QUERY);
|
|
86
85
|
return response.manyLocale;
|
|
87
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Retrieves all available taxonomies with optional pagination support.
|
|
89
|
+
* @param {object} [options] - Optional pagination options.
|
|
90
|
+
* @param {number} [options.pageSize] - Limits the number of taxonomies returned per page. Defaults to the API's default
|
|
91
|
+
* @param {string} [options.after] - Cursor for pagination; use the `cursor` returned from the previous call to fetch the next page.
|
|
92
|
+
* @returns A promise that resolves to an object containing taxonomies, their terms, and pagination info.
|
|
93
|
+
*/
|
|
94
|
+
async getTaxonomies(options) {
|
|
95
|
+
var _a, _b, _c, _d, _e;
|
|
96
|
+
debug_1.default.content('Getting taxonomies (pageSize: %s, after: %s)', (_a = options === null || options === void 0 ? void 0 : options.pageSize) !== null && _a !== void 0 ? _a : 'API Default', (_b = options === null || options === void 0 ? void 0 : options.after) !== null && _b !== void 0 ? _b : '');
|
|
97
|
+
const variables = {
|
|
98
|
+
pageSize: options === null || options === void 0 ? void 0 : options.pageSize,
|
|
99
|
+
after: (_c = options === null || options === void 0 ? void 0 : options.after) !== null && _c !== void 0 ? _c : '',
|
|
100
|
+
};
|
|
101
|
+
const response = await this.get(taxonomies_1.GET_TAXONOMIES_QUERY, variables);
|
|
102
|
+
const data = response === null || response === void 0 ? void 0 : response.manyTaxonomy;
|
|
103
|
+
return {
|
|
104
|
+
results: ((_d = data === null || data === void 0 ? void 0 : data.results) !== null && _d !== void 0 ? _d : []).map((taxonomy) => {
|
|
105
|
+
var _a, _b;
|
|
106
|
+
return ({
|
|
107
|
+
system: taxonomy.system,
|
|
108
|
+
terms: (_b = (_a = taxonomy.terms) === null || _a === void 0 ? void 0 : _a.results) !== null && _b !== void 0 ? _b : [],
|
|
109
|
+
});
|
|
110
|
+
}),
|
|
111
|
+
cursor: data === null || data === void 0 ? void 0 : data.cursor,
|
|
112
|
+
hasMore: (_e = data === null || data === void 0 ? void 0 : data.hasMore) !== null && _e !== void 0 ? _e : false,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Retrieves a taxonomy by its ID, with optional pagination support for its terms.
|
|
117
|
+
* @param {object} options - Options for fetching the taxonomy.
|
|
118
|
+
* @param {string} options.id - The unique identifier of the taxonomy.
|
|
119
|
+
* @param {object} [options.terms] - Optional pagination options for terms.
|
|
120
|
+
* @param {number} [options.terms.pageSize] - Optional. Limits the number of terms returned per page.
|
|
121
|
+
* @param {string} [options.terms.after] - Optional. Cursor for pagination. Used to fetch the next page of terms.
|
|
122
|
+
* @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.
|
|
123
|
+
*/
|
|
124
|
+
async getTaxonomy({ id, terms, }) {
|
|
125
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
126
|
+
debug_1.default.content('Getting taxonomy for id: %s (termsPageSize: %s, termsAfter: %s)', id, (_a = terms === null || terms === void 0 ? void 0 : terms.pageSize) !== null && _a !== void 0 ? _a : 'API Default', (_b = terms === null || terms === void 0 ? void 0 : terms.after) !== null && _b !== void 0 ? _b : '');
|
|
127
|
+
const variables = {
|
|
128
|
+
id,
|
|
129
|
+
termsPageSize: terms === null || terms === void 0 ? void 0 : terms.pageSize,
|
|
130
|
+
termsAfter: terms === null || terms === void 0 ? void 0 : terms.after,
|
|
131
|
+
};
|
|
132
|
+
const response = await this.get(taxonomies_1.GET_TAXONOMY_QUERY, variables);
|
|
133
|
+
const taxonomy = response === null || response === void 0 ? void 0 : response.taxonomy;
|
|
134
|
+
if (!taxonomy)
|
|
135
|
+
return null;
|
|
136
|
+
return {
|
|
137
|
+
system: taxonomy.system,
|
|
138
|
+
terms: {
|
|
139
|
+
results: (_d = (_c = taxonomy.terms) === null || _c === void 0 ? void 0 : _c.results) !== null && _d !== void 0 ? _d : [],
|
|
140
|
+
cursor: (_e = taxonomy.terms) === null || _e === void 0 ? void 0 : _e.cursor,
|
|
141
|
+
hasMore: (_g = (_f = taxonomy.terms) === null || _f === void 0 ? void 0 : _f.hasMore) !== null && _g !== void 0 ? _g : false,
|
|
142
|
+
},
|
|
143
|
+
};
|
|
144
|
+
}
|
|
88
145
|
}
|
|
89
146
|
exports.ContentClient = ContentClient;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GET_TAXONOMY_QUERY = exports.GET_TAXONOMIES_QUERY = void 0;
|
|
4
|
+
// --- GraphQL queries ---
|
|
5
|
+
/**
|
|
6
|
+
* GraphQL query to retrieve all taxonomies with optional pagination for taxonomies only.
|
|
7
|
+
*
|
|
8
|
+
* Variables:
|
|
9
|
+
* - pageSize: The number of taxonomies to retrieve per page.
|
|
10
|
+
* - after: The cursor for fetching the next page of taxonomies.
|
|
11
|
+
*/
|
|
12
|
+
exports.GET_TAXONOMIES_QUERY = `
|
|
13
|
+
query GetAllTaxonomies(
|
|
14
|
+
$pageSize: Int
|
|
15
|
+
$after: String
|
|
16
|
+
) {
|
|
17
|
+
manyTaxonomy(minimumPageSize: $pageSize, after: $after) {
|
|
18
|
+
cursor
|
|
19
|
+
hasMore
|
|
20
|
+
results {
|
|
21
|
+
terms {
|
|
22
|
+
cursor
|
|
23
|
+
hasMore
|
|
24
|
+
results {
|
|
25
|
+
id
|
|
26
|
+
name
|
|
27
|
+
label
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
system {
|
|
31
|
+
id
|
|
32
|
+
name
|
|
33
|
+
version
|
|
34
|
+
label
|
|
35
|
+
createdAt
|
|
36
|
+
createdBy
|
|
37
|
+
updatedAt
|
|
38
|
+
updatedBy
|
|
39
|
+
publishStatus
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
/**
|
|
46
|
+
* GraphQL query to retrieve a specific taxonomy by its ID, with optional pagination for its terms.
|
|
47
|
+
*
|
|
48
|
+
* Variables:
|
|
49
|
+
* - id: The unique ID of the taxonomy to retrieve.
|
|
50
|
+
* - termsPageSize: The number of terms to retrieve per page.
|
|
51
|
+
* - termsAfter: The cursor for fetching the next page of terms.
|
|
52
|
+
*/
|
|
53
|
+
exports.GET_TAXONOMY_QUERY = `
|
|
54
|
+
query GetTaxonomyById($id: ID!, $termsPageSize: Int, $termsAfter: String) {
|
|
55
|
+
taxonomy(id: $id) {
|
|
56
|
+
terms(minimumPageSize: $termsPageSize, after: $termsAfter) {
|
|
57
|
+
cursor
|
|
58
|
+
hasMore
|
|
59
|
+
results {
|
|
60
|
+
id
|
|
61
|
+
name
|
|
62
|
+
label
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
system {
|
|
66
|
+
id
|
|
67
|
+
name
|
|
68
|
+
version
|
|
69
|
+
label
|
|
70
|
+
createdAt
|
|
71
|
+
createdBy
|
|
72
|
+
updatedAt
|
|
73
|
+
updatedBy
|
|
74
|
+
publishStatus
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
`;
|
|
@@ -36,14 +36,14 @@ class GraphQLRobotsService {
|
|
|
36
36
|
* @returns text of robots.txt
|
|
37
37
|
* @throws {Error} if the siteName is empty.
|
|
38
38
|
*/
|
|
39
|
-
async fetchRobots() {
|
|
39
|
+
async fetchRobots(fetchOptions) {
|
|
40
40
|
const siteName = this.options.siteName;
|
|
41
41
|
if (!siteName) {
|
|
42
42
|
throw new Error(constants_1.siteNameError);
|
|
43
43
|
}
|
|
44
44
|
const robotsResult = this.graphQLClient.request(this.query, {
|
|
45
45
|
siteName,
|
|
46
|
-
});
|
|
46
|
+
}, fetchOptions);
|
|
47
47
|
try {
|
|
48
48
|
return robotsResult.then((result) => {
|
|
49
49
|
var _a, _b;
|
|
@@ -6,6 +6,7 @@ import { personalizeLayout } from '../personalize/layout-personalizer';
|
|
|
6
6
|
import { SiteResolver, GraphQLErrorPagesService, GraphQLSitePathService, GraphQLSitemapXmlService, } from '../site';
|
|
7
7
|
import { createGraphQLClientFactory } from './utils';
|
|
8
8
|
import { NativeDataFetcher } from '../native-fetcher';
|
|
9
|
+
import { GraphQLRobotsService } from '../site/graphql-robots-service';
|
|
9
10
|
/**
|
|
10
11
|
* This is a generic content client that can be used by any framework.
|
|
11
12
|
* Use it to retrieve pages, preview data, dictionary and other data
|
|
@@ -16,16 +17,19 @@ export class SitecoreClient {
|
|
|
16
17
|
* @param {SitecoreClientInit} initOptions initOptions for the client, containing site and Sitecore connection details
|
|
17
18
|
*/
|
|
18
19
|
constructor(initOptions) {
|
|
20
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
19
21
|
this.initOptions = initOptions;
|
|
20
22
|
this.clientFactory = this.getClientFactory();
|
|
21
|
-
this.siteResolver = this.getSiteResolver();
|
|
23
|
+
this.siteResolver = (_b = (_a = initOptions.custom) === null || _a === void 0 ? void 0 : _a.siteResolver) !== null && _b !== void 0 ? _b : this.getSiteResolver();
|
|
22
24
|
const baseServiceOptions = this.getBaseServiceOptions();
|
|
23
|
-
this.layoutService =
|
|
24
|
-
|
|
25
|
-
this.
|
|
26
|
-
|
|
25
|
+
this.layoutService =
|
|
26
|
+
(_d = (_c = initOptions.custom) === null || _c === void 0 ? void 0 : _c.layoutService) !== null && _d !== void 0 ? _d : this.getLayoutService(baseServiceOptions);
|
|
27
|
+
this.dictionaryService =
|
|
28
|
+
(_f = (_e = initOptions.custom) === null || _e === void 0 ? void 0 : _e.dictionaryService) !== null && _f !== void 0 ? _f : this.getDictionaryService(baseServiceOptions);
|
|
29
|
+
this.editingService = (_h = (_g = initOptions.custom) === null || _g === void 0 ? void 0 : _g.editingService) !== null && _h !== void 0 ? _h : this.getEditingService();
|
|
30
|
+
this.errorPagesService = (_k = (_j = initOptions.custom) === null || _j === void 0 ? void 0 : _j.errorPagesService) !== null && _k !== void 0 ? _k : this.getErrorPagesService();
|
|
31
|
+
this.sitePathService = (_m = (_l = initOptions.custom) === null || _l === void 0 ? void 0 : _l.sitePathService) !== null && _m !== void 0 ? _m : this.getSitePathService();
|
|
27
32
|
this.componentService = this.getComponentService();
|
|
28
|
-
this.sitePathService = this.getSitePathService();
|
|
29
33
|
}
|
|
30
34
|
/**
|
|
31
35
|
* Resolve site by hostname
|
|
@@ -56,7 +60,7 @@ export class SitecoreClient {
|
|
|
56
60
|
* Get page details for a route, with layout and other details
|
|
57
61
|
* @param {string} path route path
|
|
58
62
|
* @param {PageOptions} [pageOptions] site, language and personalization variant details for route
|
|
59
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
63
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
60
64
|
* @returns {Page | null} page details
|
|
61
65
|
*/
|
|
62
66
|
async getPage(path, pageOptions, fetchOptions) {
|
|
@@ -112,7 +116,7 @@ export class SitecoreClient {
|
|
|
112
116
|
/**
|
|
113
117
|
* Retrieves dictionary phrases for a given site and locale.
|
|
114
118
|
* @param {RouteOptions} routeOptions - Route options containing language and site name to load dictionary for
|
|
115
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
119
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
116
120
|
* @returns {DictionaryPhrases} A promise that resolves to the dictionary phrases.
|
|
117
121
|
*/
|
|
118
122
|
async getDictionary(routeOptions, fetchOptions) {
|
|
@@ -123,7 +127,7 @@ export class SitecoreClient {
|
|
|
123
127
|
/**
|
|
124
128
|
* Retrieves error pages for a given site and locale.
|
|
125
129
|
* @param {RouteOptions} routeOptions - Route options containing language and site name to load error pages
|
|
126
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
130
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
127
131
|
* @returns {ErrorPages | null} A promise that resolves to the error pages or null if not found.
|
|
128
132
|
*/
|
|
129
133
|
async getErrorPages(routeOptions, fetchOptions) {
|
|
@@ -134,7 +138,7 @@ export class SitecoreClient {
|
|
|
134
138
|
/**
|
|
135
139
|
* Retrieves preview page and layout details
|
|
136
140
|
* @param {EditingPreviewData | undefined} previewData - The editing preview data for metadata mode.
|
|
137
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
141
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
138
142
|
* @returns {Page} preview page details
|
|
139
143
|
*/
|
|
140
144
|
async getPreview(previewData, fetchOptions) {
|
|
@@ -168,7 +172,7 @@ export class SitecoreClient {
|
|
|
168
172
|
/**
|
|
169
173
|
* Get design library page details for Design Library mode of your app
|
|
170
174
|
* @param {DesignLibraryRenderPreviewData} designLibData preview data set in 'library' mode of the app
|
|
171
|
-
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
175
|
+
* @param {FetchOptions} [fetchOptions] Additional fetch fetch options to override GraphQL requests
|
|
172
176
|
* @returns {Page} preview page for Design Library
|
|
173
177
|
*/
|
|
174
178
|
async getDesignLibraryData(designLibData, fetchOptions) {
|
|
@@ -253,6 +257,18 @@ export class SitecoreClient {
|
|
|
253
257
|
.join('')}
|
|
254
258
|
</sitemapindex>`;
|
|
255
259
|
}
|
|
260
|
+
/**
|
|
261
|
+
* Retrieves the robots.txt content for a given site name.
|
|
262
|
+
* @param {string} siteName - The name of the site to retrieve the robots.txt for.
|
|
263
|
+
* @param {FetchOptions} [fetchOptions] - Optional fetch options.
|
|
264
|
+
* @returns {Promise<string | null>} A promise that resolves to the robots.txt content,
|
|
265
|
+
* or null if no content is found.
|
|
266
|
+
*/
|
|
267
|
+
async getRobots(siteName, fetchOptions) {
|
|
268
|
+
const robotsService = this.getRobotsService(siteName || this.initOptions.defaultSite);
|
|
269
|
+
const content = await robotsService.fetchRobots(fetchOptions);
|
|
270
|
+
return content || null;
|
|
271
|
+
}
|
|
256
272
|
/**
|
|
257
273
|
* Factory methods for creating dependencies
|
|
258
274
|
* Subclasses can override these to provide custom implementations.
|
|
@@ -263,6 +279,12 @@ export class SitecoreClient {
|
|
|
263
279
|
siteName,
|
|
264
280
|
});
|
|
265
281
|
}
|
|
282
|
+
getRobotsService(siteName) {
|
|
283
|
+
return new GraphQLRobotsService({
|
|
284
|
+
clientFactory: this.clientFactory,
|
|
285
|
+
siteName,
|
|
286
|
+
});
|
|
287
|
+
}
|
|
266
288
|
getBaseServiceOptions() {
|
|
267
289
|
return {
|
|
268
290
|
defaultSite: this.initOptions.defaultSite,
|
|
@@ -7,9 +7,9 @@ import { DefaultRetryStrategy } from '../retries';
|
|
|
7
7
|
export const getFallbackConfig = () => ({
|
|
8
8
|
api: {
|
|
9
9
|
edge: {
|
|
10
|
-
contextId: '',
|
|
10
|
+
contextId: process.env.SITECORE_EDGE_CONTEXT_ID || '',
|
|
11
11
|
clientContextId: '',
|
|
12
|
-
edgeUrl: SITECORE_EDGE_URL_DEFAULT,
|
|
12
|
+
edgeUrl: process.env.SITECORE_EDGE_URL || SITECORE_EDGE_URL_DEFAULT,
|
|
13
13
|
},
|
|
14
14
|
local: {
|
|
15
15
|
apiKey: '',
|
|
@@ -17,7 +17,7 @@ export const getFallbackConfig = () => ({
|
|
|
17
17
|
path: '/sitecore/api/graph/edge',
|
|
18
18
|
},
|
|
19
19
|
},
|
|
20
|
-
editingSecret: 'editing-secret-missing',
|
|
20
|
+
editingSecret: process.env.JSS_EDITING_SECRET || 'editing-secret-missing',
|
|
21
21
|
retries: {
|
|
22
22
|
count: 3,
|
|
23
23
|
retryStrategy: new DefaultRetryStrategy({
|
|
@@ -34,8 +34,8 @@ export const getFallbackConfig = () => ({
|
|
|
34
34
|
},
|
|
35
35
|
personalize: {
|
|
36
36
|
enabled: process.env.NODE_ENV !== 'development',
|
|
37
|
-
edgeTimeout: 400,
|
|
38
|
-
cdpTimeout: 400,
|
|
37
|
+
edgeTimeout: parseInt(process.env.PERSONALIZE_MIDDLEWARE_EDGE_TIMEOUT, 10) || 400,
|
|
38
|
+
cdpTimeout: parseInt(process.env.PERSONALIZE_MIDDLEWARE_CDP_TIMEOUT, 10) || 400,
|
|
39
39
|
scope: '',
|
|
40
40
|
channel: 'WEB',
|
|
41
41
|
currency: 'USD',
|
|
@@ -2,6 +2,7 @@ import { GraphQLRequestClient } from '../graphql-request-client';
|
|
|
2
2
|
import { getContentUrl } from './utils';
|
|
3
3
|
import debug from '../debug';
|
|
4
4
|
import { GET_LOCALE_QUERY, GET_LOCALES_QUERY, } from './locales';
|
|
5
|
+
import { GET_TAXONOMY_QUERY, GET_TAXONOMIES_QUERY, } from './taxonomies';
|
|
5
6
|
/**
|
|
6
7
|
* Class representing a client for interacting with the Content API.
|
|
7
8
|
*/
|
|
@@ -60,8 +61,7 @@ export class ContentClient {
|
|
|
60
61
|
}
|
|
61
62
|
/**
|
|
62
63
|
* Retrieves the locale information for a given locale ID.
|
|
63
|
-
*
|
|
64
|
-
* @param id - The unique identifier of the locale item.
|
|
64
|
+
* @param {string} id - The unique identifier of the locale item.
|
|
65
65
|
* @returns A promise that resolves to the locale information associated with the specified locale ID.
|
|
66
66
|
*/
|
|
67
67
|
async getLocale(id) {
|
|
@@ -71,7 +71,6 @@ export class ContentClient {
|
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
73
|
* Retrieves all available locales from the content service.
|
|
74
|
-
*
|
|
75
74
|
* @returns A promise that resolves to an array of locales.
|
|
76
75
|
*/
|
|
77
76
|
async getLocales() {
|
|
@@ -79,4 +78,62 @@ export class ContentClient {
|
|
|
79
78
|
const response = await this.get(GET_LOCALES_QUERY);
|
|
80
79
|
return response.manyLocale;
|
|
81
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Retrieves all available taxonomies with optional pagination support.
|
|
83
|
+
* @param {object} [options] - Optional pagination options.
|
|
84
|
+
* @param {number} [options.pageSize] - Limits the number of taxonomies returned per page. Defaults to the API's default
|
|
85
|
+
* @param {string} [options.after] - Cursor for pagination; use the `cursor` returned from the previous call to fetch the next page.
|
|
86
|
+
* @returns A promise that resolves to an object containing taxonomies, their terms, and pagination info.
|
|
87
|
+
*/
|
|
88
|
+
async getTaxonomies(options) {
|
|
89
|
+
var _a, _b, _c, _d, _e;
|
|
90
|
+
debug.content('Getting taxonomies (pageSize: %s, after: %s)', (_a = options === null || options === void 0 ? void 0 : options.pageSize) !== null && _a !== void 0 ? _a : 'API Default', (_b = options === null || options === void 0 ? void 0 : options.after) !== null && _b !== void 0 ? _b : '');
|
|
91
|
+
const variables = {
|
|
92
|
+
pageSize: options === null || options === void 0 ? void 0 : options.pageSize,
|
|
93
|
+
after: (_c = options === null || options === void 0 ? void 0 : options.after) !== null && _c !== void 0 ? _c : '',
|
|
94
|
+
};
|
|
95
|
+
const response = await this.get(GET_TAXONOMIES_QUERY, variables);
|
|
96
|
+
const data = response === null || response === void 0 ? void 0 : response.manyTaxonomy;
|
|
97
|
+
return {
|
|
98
|
+
results: ((_d = data === null || data === void 0 ? void 0 : data.results) !== null && _d !== void 0 ? _d : []).map((taxonomy) => {
|
|
99
|
+
var _a, _b;
|
|
100
|
+
return ({
|
|
101
|
+
system: taxonomy.system,
|
|
102
|
+
terms: (_b = (_a = taxonomy.terms) === null || _a === void 0 ? void 0 : _a.results) !== null && _b !== void 0 ? _b : [],
|
|
103
|
+
});
|
|
104
|
+
}),
|
|
105
|
+
cursor: data === null || data === void 0 ? void 0 : data.cursor,
|
|
106
|
+
hasMore: (_e = data === null || data === void 0 ? void 0 : data.hasMore) !== null && _e !== void 0 ? _e : false,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Retrieves a taxonomy by its ID, with optional pagination support for its terms.
|
|
111
|
+
* @param {object} options - Options for fetching the taxonomy.
|
|
112
|
+
* @param {string} options.id - The unique identifier of the taxonomy.
|
|
113
|
+
* @param {object} [options.terms] - Optional pagination options for terms.
|
|
114
|
+
* @param {number} [options.terms.pageSize] - Optional. Limits the number of terms returned per page.
|
|
115
|
+
* @param {string} [options.terms.after] - Optional. Cursor for pagination. Used to fetch the next page of terms.
|
|
116
|
+
* @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.
|
|
117
|
+
*/
|
|
118
|
+
async getTaxonomy({ id, terms, }) {
|
|
119
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
120
|
+
debug.content('Getting taxonomy for id: %s (termsPageSize: %s, termsAfter: %s)', id, (_a = terms === null || terms === void 0 ? void 0 : terms.pageSize) !== null && _a !== void 0 ? _a : 'API Default', (_b = terms === null || terms === void 0 ? void 0 : terms.after) !== null && _b !== void 0 ? _b : '');
|
|
121
|
+
const variables = {
|
|
122
|
+
id,
|
|
123
|
+
termsPageSize: terms === null || terms === void 0 ? void 0 : terms.pageSize,
|
|
124
|
+
termsAfter: terms === null || terms === void 0 ? void 0 : terms.after,
|
|
125
|
+
};
|
|
126
|
+
const response = await this.get(GET_TAXONOMY_QUERY, variables);
|
|
127
|
+
const taxonomy = response === null || response === void 0 ? void 0 : response.taxonomy;
|
|
128
|
+
if (!taxonomy)
|
|
129
|
+
return null;
|
|
130
|
+
return {
|
|
131
|
+
system: taxonomy.system,
|
|
132
|
+
terms: {
|
|
133
|
+
results: (_d = (_c = taxonomy.terms) === null || _c === void 0 ? void 0 : _c.results) !== null && _d !== void 0 ? _d : [],
|
|
134
|
+
cursor: (_e = taxonomy.terms) === null || _e === void 0 ? void 0 : _e.cursor,
|
|
135
|
+
hasMore: (_g = (_f = taxonomy.terms) === null || _f === void 0 ? void 0 : _f.hasMore) !== null && _g !== void 0 ? _g : false,
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
82
139
|
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// --- GraphQL queries ---
|
|
2
|
+
/**
|
|
3
|
+
* GraphQL query to retrieve all taxonomies with optional pagination for taxonomies only.
|
|
4
|
+
*
|
|
5
|
+
* Variables:
|
|
6
|
+
* - pageSize: The number of taxonomies to retrieve per page.
|
|
7
|
+
* - after: The cursor for fetching the next page of taxonomies.
|
|
8
|
+
*/
|
|
9
|
+
export const GET_TAXONOMIES_QUERY = `
|
|
10
|
+
query GetAllTaxonomies(
|
|
11
|
+
$pageSize: Int
|
|
12
|
+
$after: String
|
|
13
|
+
) {
|
|
14
|
+
manyTaxonomy(minimumPageSize: $pageSize, after: $after) {
|
|
15
|
+
cursor
|
|
16
|
+
hasMore
|
|
17
|
+
results {
|
|
18
|
+
terms {
|
|
19
|
+
cursor
|
|
20
|
+
hasMore
|
|
21
|
+
results {
|
|
22
|
+
id
|
|
23
|
+
name
|
|
24
|
+
label
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
system {
|
|
28
|
+
id
|
|
29
|
+
name
|
|
30
|
+
version
|
|
31
|
+
label
|
|
32
|
+
createdAt
|
|
33
|
+
createdBy
|
|
34
|
+
updatedAt
|
|
35
|
+
updatedBy
|
|
36
|
+
publishStatus
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
`;
|
|
42
|
+
/**
|
|
43
|
+
* GraphQL query to retrieve a specific taxonomy by its ID, with optional pagination for its terms.
|
|
44
|
+
*
|
|
45
|
+
* Variables:
|
|
46
|
+
* - id: The unique ID of the taxonomy to retrieve.
|
|
47
|
+
* - termsPageSize: The number of terms to retrieve per page.
|
|
48
|
+
* - termsAfter: The cursor for fetching the next page of terms.
|
|
49
|
+
*/
|
|
50
|
+
export const GET_TAXONOMY_QUERY = `
|
|
51
|
+
query GetTaxonomyById($id: ID!, $termsPageSize: Int, $termsAfter: String) {
|
|
52
|
+
taxonomy(id: $id) {
|
|
53
|
+
terms(minimumPageSize: $termsPageSize, after: $termsAfter) {
|
|
54
|
+
cursor
|
|
55
|
+
hasMore
|
|
56
|
+
results {
|
|
57
|
+
id
|
|
58
|
+
name
|
|
59
|
+
label
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
system {
|
|
63
|
+
id
|
|
64
|
+
name
|
|
65
|
+
version
|
|
66
|
+
label
|
|
67
|
+
createdAt
|
|
68
|
+
createdBy
|
|
69
|
+
updatedAt
|
|
70
|
+
updatedBy
|
|
71
|
+
publishStatus
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
`;
|
|
@@ -30,14 +30,14 @@ export class GraphQLRobotsService {
|
|
|
30
30
|
* @returns text of robots.txt
|
|
31
31
|
* @throws {Error} if the siteName is empty.
|
|
32
32
|
*/
|
|
33
|
-
async fetchRobots() {
|
|
33
|
+
async fetchRobots(fetchOptions) {
|
|
34
34
|
const siteName = this.options.siteName;
|
|
35
35
|
if (!siteName) {
|
|
36
36
|
throw new Error(siteNameError);
|
|
37
37
|
}
|
|
38
38
|
const robotsResult = this.graphQLClient.request(this.query, {
|
|
39
39
|
siteName,
|
|
40
|
-
});
|
|
40
|
+
}, fetchOptions);
|
|
41
41
|
try {
|
|
42
42
|
return robotsResult.then((result) => {
|
|
43
43
|
var _a, _b;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sitecore-content-sdk/core",
|
|
3
|
-
"version": "0.2.0-beta.
|
|
3
|
+
"version": "0.2.0-beta.8",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -34,42 +34,42 @@
|
|
|
34
34
|
"url": "https://github.com/sitecore/content-sdk/issues"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@sitecore-cloudsdk/events": "^0.5.
|
|
38
|
-
"@types/chai": "^5.
|
|
37
|
+
"@sitecore-cloudsdk/events": "^0.5.1",
|
|
38
|
+
"@types/chai": "^5.2.2",
|
|
39
39
|
"@types/chai-spies": "^1.0.6",
|
|
40
40
|
"@types/chai-string": "^1.4.5",
|
|
41
41
|
"@types/debug": "^4.1.12",
|
|
42
42
|
"@types/jsdom": "^21.1.7",
|
|
43
43
|
"@types/memory-cache": "^0.2.6",
|
|
44
|
-
"@types/mocha": "^10.0.
|
|
45
|
-
"@types/node": "^22.
|
|
44
|
+
"@types/mocha": "^10.0.10",
|
|
45
|
+
"@types/node": "^22.15.14",
|
|
46
46
|
"@types/proxyquire": "^1.3.31",
|
|
47
|
-
"@types/sinon": "^17.0.
|
|
47
|
+
"@types/sinon": "^17.0.4",
|
|
48
48
|
"@types/sinon-chai": "^4.0.0",
|
|
49
49
|
"@types/url-parse": "1.4.11",
|
|
50
|
-
"chai": "^4.
|
|
50
|
+
"chai": "^4.4.1",
|
|
51
51
|
"chai-spies": "^1.1.0",
|
|
52
|
-
"chai-string": "^1.
|
|
52
|
+
"chai-string": "^1.6.0",
|
|
53
53
|
"del-cli": "^6.0.0",
|
|
54
54
|
"eslint": "^8.56.0",
|
|
55
|
-
"eslint-plugin-jsdoc": "
|
|
56
|
-
"jsdom": "^26.
|
|
57
|
-
"mocha": "^11.
|
|
55
|
+
"eslint-plugin-jsdoc": "50.6.11",
|
|
56
|
+
"jsdom": "^26.1.0",
|
|
57
|
+
"mocha": "^11.2.2",
|
|
58
58
|
"nock": "14.0.0-beta.7",
|
|
59
59
|
"nyc": "^17.1.0",
|
|
60
60
|
"proxyquire": "^2.1.3",
|
|
61
61
|
"sinon": "^20.0.0",
|
|
62
62
|
"tslib": "^2.8.1",
|
|
63
|
-
"tsx": "^4.19.
|
|
64
|
-
"typescript": "~5.
|
|
63
|
+
"tsx": "^4.19.4",
|
|
64
|
+
"typescript": "~5.8.3"
|
|
65
65
|
},
|
|
66
66
|
"peerDependencies": {
|
|
67
|
-
"@sitecore-cloudsdk/events": "^0.5.
|
|
67
|
+
"@sitecore-cloudsdk/events": "^0.5.1"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
70
|
"chalk": "^4.1.2",
|
|
71
71
|
"debug": "^4.4.0",
|
|
72
|
-
"graphql": "^16.
|
|
72
|
+
"graphql": "^16.11.0",
|
|
73
73
|
"graphql-request": "^6.1.0",
|
|
74
74
|
"memory-cache": "^0.2.0",
|
|
75
75
|
"sinon-chai": "^4.0.0",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
},
|
|
78
78
|
"description": "",
|
|
79
79
|
"types": "types/index.d.ts",
|
|
80
|
-
"gitHead": "
|
|
80
|
+
"gitHead": "78f049f5e1c70964d441948e15359337c7098d55",
|
|
81
81
|
"files": [
|
|
82
82
|
"dist",
|
|
83
83
|
"types",
|
package/types/client/index.d.ts
CHANGED
|
@@ -4,4 +4,4 @@ export { RetryStrategy, PageInfo, FetchOptions } from '../models';
|
|
|
4
4
|
export { getEdgeProxyContentUrl, getEdgeProxyFormsUrl } from './graphql-edge-proxy';
|
|
5
5
|
export { SitecoreClient, Page, PageOptions, SitemapXmlOptions } from './sitecore-client';
|
|
6
6
|
export { SitecoreClientInit } from './models';
|
|
7
|
-
export { createGraphQLClientFactory } from './utils';
|
|
7
|
+
export { createGraphQLClientFactory, GraphQLClientOptions } from './utils';
|
package/types/client/models.d.ts
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
import { SitecoreConfig } from '../config';
|
|
2
|
-
import {
|
|
2
|
+
import { GraphQLEditingService } from '../editing/graphql-editing-service';
|
|
3
|
+
import { RestComponentLayoutService } from '../editing/rest-component-layout-service';
|
|
4
|
+
import { GraphQLDictionaryService } from '../i18n/graphql-dictionary-service';
|
|
5
|
+
import { GraphQLLayoutService } from '../layout/graphql-layout-service';
|
|
6
|
+
import { GraphQLErrorPagesService, GraphQLSitePathService, SiteInfo, SiteResolver } from '../site';
|
|
7
|
+
/**
|
|
8
|
+
* Init options for Sitecore Client that allows you to override services too
|
|
9
|
+
*/
|
|
3
10
|
export type SitecoreClientInit = Omit<SitecoreConfig, 'multisite' | 'redirects' | 'personalize'> & {
|
|
4
11
|
sites: SiteInfo[];
|
|
12
|
+
custom?: {
|
|
13
|
+
layoutService?: GraphQLLayoutService;
|
|
14
|
+
dictionaryService?: GraphQLDictionaryService;
|
|
15
|
+
siteResolver?: SiteResolver;
|
|
16
|
+
editingService?: GraphQLEditingService;
|
|
17
|
+
errorPagesService?: GraphQLErrorPagesService;
|
|
18
|
+
componentService?: RestComponentLayoutService;
|
|
19
|
+
sitePathService?: GraphQLSitePathService;
|
|
20
|
+
};
|
|
5
21
|
};
|
|
@@ -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
|
/**
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { DocumentNode } from 'graphql';
|
|
2
2
|
import { GraphQLRequestClient } from '../graphql-request-client';
|
|
3
3
|
import { FetchOptions } from '../models';
|
|
4
|
+
import { Taxonomy } from './taxonomies';
|
|
4
5
|
/**
|
|
5
6
|
* Interface representing the options for the ContentClient.
|
|
6
7
|
*/
|
|
@@ -45,15 +46,47 @@ export declare class ContentClient {
|
|
|
45
46
|
get<T>(query: string | DocumentNode, variables?: Record<string, unknown>, options?: FetchOptions): Promise<T>;
|
|
46
47
|
/**
|
|
47
48
|
* Retrieves the locale information for a given locale ID.
|
|
48
|
-
*
|
|
49
|
-
* @param id - The unique identifier of the locale item.
|
|
49
|
+
* @param {string} id - The unique identifier of the locale item.
|
|
50
50
|
* @returns A promise that resolves to the locale information associated with the specified locale ID.
|
|
51
51
|
*/
|
|
52
52
|
getLocale(id: string): Promise<import("./locales").Locale | null>;
|
|
53
53
|
/**
|
|
54
54
|
* Retrieves all available locales from the content service.
|
|
55
|
-
*
|
|
56
55
|
* @returns A promise that resolves to an array of locales.
|
|
57
56
|
*/
|
|
58
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>;
|
|
59
92
|
}
|
|
@@ -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";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { GraphQLClient } from '../client';
|
|
1
|
+
import { FetchOptions, GraphQLClient } from '../client';
|
|
2
2
|
import { GraphQLRequestClientFactory } from '../graphql-request-client';
|
|
3
3
|
export type GraphQLRobotsServiceConfig = {
|
|
4
4
|
/**
|
|
@@ -38,7 +38,7 @@ export declare class GraphQLRobotsService {
|
|
|
38
38
|
* @returns text of robots.txt
|
|
39
39
|
* @throws {Error} if the siteName is empty.
|
|
40
40
|
*/
|
|
41
|
-
fetchRobots(): Promise<string>;
|
|
41
|
+
fetchRobots(fetchOptions?: FetchOptions): Promise<string>;
|
|
42
42
|
/**
|
|
43
43
|
* Gets a GraphQL client that can make requests to the API. Uses graphql-request as the default
|
|
44
44
|
* library for fetching graphql data (@see GraphQLRequestClient). Override this method if you
|