@dotcms/client 0.0.1-beta.34 → 0.0.1-beta.35
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/next.cjs.js +71 -69
- package/next.esm.js +72 -70
- package/package.json +1 -1
- package/src/lib/client/content/content-api.d.ts +0 -3
- package/src/lib/client/page/page-api.d.ts +0 -1
- package/src/lib/utils/graphql/transforms.d.ts +2 -2
- package/transforms.cjs.js +12 -12
- package/transforms.esm.js +12 -12
package/next.cjs.js
CHANGED
|
@@ -126,9 +126,22 @@ const buildPageQuery = ({ page, fragments, additionalQueries }) => {
|
|
|
126
126
|
canEdit
|
|
127
127
|
canLock
|
|
128
128
|
canRead
|
|
129
|
+
runningExperimentId
|
|
129
130
|
urlContentMap {
|
|
130
131
|
_map
|
|
131
132
|
}
|
|
133
|
+
host {
|
|
134
|
+
identifier
|
|
135
|
+
hostName
|
|
136
|
+
googleMap
|
|
137
|
+
archived
|
|
138
|
+
contentType
|
|
139
|
+
}
|
|
140
|
+
vanityUrl {
|
|
141
|
+
action
|
|
142
|
+
forwardTo
|
|
143
|
+
uri
|
|
144
|
+
}
|
|
132
145
|
conLanguage {
|
|
133
146
|
id
|
|
134
147
|
language
|
|
@@ -136,6 +149,9 @@ const buildPageQuery = ({ page, fragments, additionalQueries }) => {
|
|
|
136
149
|
}
|
|
137
150
|
template {
|
|
138
151
|
drawed
|
|
152
|
+
anonymous
|
|
153
|
+
theme
|
|
154
|
+
identifier
|
|
139
155
|
}
|
|
140
156
|
containers {
|
|
141
157
|
path
|
|
@@ -276,7 +292,6 @@ async function fetchGraphQL({ baseURL, body, headers }) {
|
|
|
276
292
|
return await response.json();
|
|
277
293
|
}
|
|
278
294
|
|
|
279
|
-
var _PageClient_instances, _PageClient_getPageFromGraphQL;
|
|
280
295
|
/**
|
|
281
296
|
* Client for interacting with the DotCMS Page API.
|
|
282
297
|
* Provides methods to retrieve and manipulate pages.
|
|
@@ -304,7 +319,6 @@ class PageClient {
|
|
|
304
319
|
* ```
|
|
305
320
|
*/
|
|
306
321
|
constructor(config, requestOptions) {
|
|
307
|
-
_PageClient_instances.add(this);
|
|
308
322
|
this.requestOptions = requestOptions;
|
|
309
323
|
this.siteId = config.siteId || '';
|
|
310
324
|
this.dotcmsUrl = config.dotcmsUrl;
|
|
@@ -359,78 +373,66 @@ class PageClient {
|
|
|
359
373
|
* });
|
|
360
374
|
* ```
|
|
361
375
|
*/
|
|
362
|
-
get(url, options) {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
*
|
|
371
|
-
* @private
|
|
372
|
-
* @param {string} url - The URL of the page to retrieve
|
|
373
|
-
* @param {DotCMSPageRequestParams} [options] - Options including languageId, mode, and GraphQL parameters
|
|
374
|
-
* @returns {Promise<DotCMSComposedPageResponse<T>>} A Promise that resolves to the page data
|
|
375
|
-
*/
|
|
376
|
-
async function _PageClient_getPageFromGraphQL(url, options) {
|
|
377
|
-
const { languageId = '1', mode = 'LIVE', siteId = this.siteId, fireRules = false, personaId, publishDate, graphql = {} } = options || {};
|
|
378
|
-
const { page, content = {}, variables, fragments } = graphql;
|
|
379
|
-
const contentQuery = buildQuery(content);
|
|
380
|
-
const completeQuery = buildPageQuery({
|
|
381
|
-
page,
|
|
382
|
-
fragments,
|
|
383
|
-
additionalQueries: contentQuery
|
|
384
|
-
});
|
|
385
|
-
const requestVariables = {
|
|
386
|
-
url,
|
|
387
|
-
mode,
|
|
388
|
-
languageId,
|
|
389
|
-
personaId,
|
|
390
|
-
fireRules,
|
|
391
|
-
publishDate,
|
|
392
|
-
siteId,
|
|
393
|
-
...variables
|
|
394
|
-
};
|
|
395
|
-
const requestHeaders = this.requestOptions.headers;
|
|
396
|
-
const requestBody = JSON.stringify({ query: completeQuery, variables: requestVariables });
|
|
397
|
-
try {
|
|
398
|
-
const { data, errors } = await fetchGraphQL({
|
|
399
|
-
baseURL: this.dotcmsUrl,
|
|
400
|
-
body: requestBody,
|
|
401
|
-
headers: requestHeaders
|
|
376
|
+
async get(url, options) {
|
|
377
|
+
const { languageId = '1', mode = 'LIVE', siteId = this.siteId, fireRules = false, personaId, publishDate, graphql = {} } = options || {};
|
|
378
|
+
const { page, content = {}, variables, fragments } = graphql;
|
|
379
|
+
const contentQuery = buildQuery(content);
|
|
380
|
+
const completeQuery = buildPageQuery({
|
|
381
|
+
page,
|
|
382
|
+
fragments,
|
|
383
|
+
additionalQueries: contentQuery
|
|
402
384
|
});
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
385
|
+
const requestVariables = {
|
|
386
|
+
// The url is expected to have a leading slash to comply on VanityURL Matching, some frameworks like Angular will not add the leading slash
|
|
387
|
+
url: url.startsWith('/') ? url : `/${url}`,
|
|
388
|
+
mode,
|
|
389
|
+
languageId,
|
|
390
|
+
personaId,
|
|
391
|
+
fireRules,
|
|
392
|
+
publishDate,
|
|
393
|
+
siteId,
|
|
394
|
+
...variables
|
|
395
|
+
};
|
|
396
|
+
const requestHeaders = this.requestOptions.headers;
|
|
397
|
+
const requestBody = JSON.stringify({ query: completeQuery, variables: requestVariables });
|
|
398
|
+
try {
|
|
399
|
+
const { data, errors } = await fetchGraphQL({
|
|
400
|
+
baseURL: this.dotcmsUrl,
|
|
401
|
+
body: requestBody,
|
|
402
|
+
headers: requestHeaders
|
|
406
403
|
});
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
}
|
|
412
|
-
const contentResponse = mapResponseData(data, Object.keys(content));
|
|
413
|
-
return {
|
|
414
|
-
pageAsset: pageResponse,
|
|
415
|
-
content: contentResponse,
|
|
416
|
-
graphql: {
|
|
417
|
-
query: completeQuery,
|
|
418
|
-
variables: requestVariables
|
|
404
|
+
if (errors) {
|
|
405
|
+
errors.forEach((error) => {
|
|
406
|
+
throw new Error(error.message);
|
|
407
|
+
});
|
|
419
408
|
}
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
const errorMessage = {
|
|
424
|
-
error,
|
|
425
|
-
message: 'Failed to retrieve page data',
|
|
426
|
-
graphql: {
|
|
427
|
-
query: completeQuery,
|
|
428
|
-
variables: requestVariables
|
|
409
|
+
const pageResponse = transforms.graphqlToPageEntity(data);
|
|
410
|
+
if (!pageResponse) {
|
|
411
|
+
throw new Error('No page data found');
|
|
429
412
|
}
|
|
430
|
-
|
|
431
|
-
|
|
413
|
+
const contentResponse = mapResponseData(data, Object.keys(content));
|
|
414
|
+
return {
|
|
415
|
+
pageAsset: pageResponse,
|
|
416
|
+
content: contentResponse,
|
|
417
|
+
graphql: {
|
|
418
|
+
query: completeQuery,
|
|
419
|
+
variables: requestVariables
|
|
420
|
+
}
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
catch (error) {
|
|
424
|
+
const errorMessage = {
|
|
425
|
+
error,
|
|
426
|
+
message: 'Failed to retrieve page data',
|
|
427
|
+
graphql: {
|
|
428
|
+
query: completeQuery,
|
|
429
|
+
variables: requestVariables
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
throw errorMessage;
|
|
433
|
+
}
|
|
432
434
|
}
|
|
433
|
-
}
|
|
435
|
+
}
|
|
434
436
|
|
|
435
437
|
/**
|
|
436
438
|
* Parses a string into a URL object.
|
package/next.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as ErrorMessages,
|
|
1
|
+
import { E as ErrorMessages, g as graphqlToPageEntity, C as Content } from './transforms.esm.js';
|
|
2
2
|
|
|
3
3
|
class NavigationClient {
|
|
4
4
|
constructor(config, requestOptions) {
|
|
@@ -124,9 +124,22 @@ const buildPageQuery = ({ page, fragments, additionalQueries }) => {
|
|
|
124
124
|
canEdit
|
|
125
125
|
canLock
|
|
126
126
|
canRead
|
|
127
|
+
runningExperimentId
|
|
127
128
|
urlContentMap {
|
|
128
129
|
_map
|
|
129
130
|
}
|
|
131
|
+
host {
|
|
132
|
+
identifier
|
|
133
|
+
hostName
|
|
134
|
+
googleMap
|
|
135
|
+
archived
|
|
136
|
+
contentType
|
|
137
|
+
}
|
|
138
|
+
vanityUrl {
|
|
139
|
+
action
|
|
140
|
+
forwardTo
|
|
141
|
+
uri
|
|
142
|
+
}
|
|
130
143
|
conLanguage {
|
|
131
144
|
id
|
|
132
145
|
language
|
|
@@ -134,6 +147,9 @@ const buildPageQuery = ({ page, fragments, additionalQueries }) => {
|
|
|
134
147
|
}
|
|
135
148
|
template {
|
|
136
149
|
drawed
|
|
150
|
+
anonymous
|
|
151
|
+
theme
|
|
152
|
+
identifier
|
|
137
153
|
}
|
|
138
154
|
containers {
|
|
139
155
|
path
|
|
@@ -274,7 +290,6 @@ async function fetchGraphQL({ baseURL, body, headers }) {
|
|
|
274
290
|
return await response.json();
|
|
275
291
|
}
|
|
276
292
|
|
|
277
|
-
var _PageClient_instances, _PageClient_getPageFromGraphQL;
|
|
278
293
|
/**
|
|
279
294
|
* Client for interacting with the DotCMS Page API.
|
|
280
295
|
* Provides methods to retrieve and manipulate pages.
|
|
@@ -302,7 +317,6 @@ class PageClient {
|
|
|
302
317
|
* ```
|
|
303
318
|
*/
|
|
304
319
|
constructor(config, requestOptions) {
|
|
305
|
-
_PageClient_instances.add(this);
|
|
306
320
|
this.requestOptions = requestOptions;
|
|
307
321
|
this.siteId = config.siteId || '';
|
|
308
322
|
this.dotcmsUrl = config.dotcmsUrl;
|
|
@@ -357,78 +371,66 @@ class PageClient {
|
|
|
357
371
|
* });
|
|
358
372
|
* ```
|
|
359
373
|
*/
|
|
360
|
-
get(url, options) {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
*
|
|
369
|
-
* @private
|
|
370
|
-
* @param {string} url - The URL of the page to retrieve
|
|
371
|
-
* @param {DotCMSPageRequestParams} [options] - Options including languageId, mode, and GraphQL parameters
|
|
372
|
-
* @returns {Promise<DotCMSComposedPageResponse<T>>} A Promise that resolves to the page data
|
|
373
|
-
*/
|
|
374
|
-
async function _PageClient_getPageFromGraphQL(url, options) {
|
|
375
|
-
const { languageId = '1', mode = 'LIVE', siteId = this.siteId, fireRules = false, personaId, publishDate, graphql = {} } = options || {};
|
|
376
|
-
const { page, content = {}, variables, fragments } = graphql;
|
|
377
|
-
const contentQuery = buildQuery(content);
|
|
378
|
-
const completeQuery = buildPageQuery({
|
|
379
|
-
page,
|
|
380
|
-
fragments,
|
|
381
|
-
additionalQueries: contentQuery
|
|
382
|
-
});
|
|
383
|
-
const requestVariables = {
|
|
384
|
-
url,
|
|
385
|
-
mode,
|
|
386
|
-
languageId,
|
|
387
|
-
personaId,
|
|
388
|
-
fireRules,
|
|
389
|
-
publishDate,
|
|
390
|
-
siteId,
|
|
391
|
-
...variables
|
|
392
|
-
};
|
|
393
|
-
const requestHeaders = this.requestOptions.headers;
|
|
394
|
-
const requestBody = JSON.stringify({ query: completeQuery, variables: requestVariables });
|
|
395
|
-
try {
|
|
396
|
-
const { data, errors } = await fetchGraphQL({
|
|
397
|
-
baseURL: this.dotcmsUrl,
|
|
398
|
-
body: requestBody,
|
|
399
|
-
headers: requestHeaders
|
|
374
|
+
async get(url, options) {
|
|
375
|
+
const { languageId = '1', mode = 'LIVE', siteId = this.siteId, fireRules = false, personaId, publishDate, graphql = {} } = options || {};
|
|
376
|
+
const { page, content = {}, variables, fragments } = graphql;
|
|
377
|
+
const contentQuery = buildQuery(content);
|
|
378
|
+
const completeQuery = buildPageQuery({
|
|
379
|
+
page,
|
|
380
|
+
fragments,
|
|
381
|
+
additionalQueries: contentQuery
|
|
400
382
|
});
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
383
|
+
const requestVariables = {
|
|
384
|
+
// The url is expected to have a leading slash to comply on VanityURL Matching, some frameworks like Angular will not add the leading slash
|
|
385
|
+
url: url.startsWith('/') ? url : `/${url}`,
|
|
386
|
+
mode,
|
|
387
|
+
languageId,
|
|
388
|
+
personaId,
|
|
389
|
+
fireRules,
|
|
390
|
+
publishDate,
|
|
391
|
+
siteId,
|
|
392
|
+
...variables
|
|
393
|
+
};
|
|
394
|
+
const requestHeaders = this.requestOptions.headers;
|
|
395
|
+
const requestBody = JSON.stringify({ query: completeQuery, variables: requestVariables });
|
|
396
|
+
try {
|
|
397
|
+
const { data, errors } = await fetchGraphQL({
|
|
398
|
+
baseURL: this.dotcmsUrl,
|
|
399
|
+
body: requestBody,
|
|
400
|
+
headers: requestHeaders
|
|
404
401
|
});
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
}
|
|
410
|
-
const contentResponse = mapResponseData(data, Object.keys(content));
|
|
411
|
-
return {
|
|
412
|
-
pageAsset: pageResponse,
|
|
413
|
-
content: contentResponse,
|
|
414
|
-
graphql: {
|
|
415
|
-
query: completeQuery,
|
|
416
|
-
variables: requestVariables
|
|
402
|
+
if (errors) {
|
|
403
|
+
errors.forEach((error) => {
|
|
404
|
+
throw new Error(error.message);
|
|
405
|
+
});
|
|
417
406
|
}
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
const errorMessage = {
|
|
422
|
-
error,
|
|
423
|
-
message: 'Failed to retrieve page data',
|
|
424
|
-
graphql: {
|
|
425
|
-
query: completeQuery,
|
|
426
|
-
variables: requestVariables
|
|
407
|
+
const pageResponse = graphqlToPageEntity(data);
|
|
408
|
+
if (!pageResponse) {
|
|
409
|
+
throw new Error('No page data found');
|
|
427
410
|
}
|
|
428
|
-
|
|
429
|
-
|
|
411
|
+
const contentResponse = mapResponseData(data, Object.keys(content));
|
|
412
|
+
return {
|
|
413
|
+
pageAsset: pageResponse,
|
|
414
|
+
content: contentResponse,
|
|
415
|
+
graphql: {
|
|
416
|
+
query: completeQuery,
|
|
417
|
+
variables: requestVariables
|
|
418
|
+
}
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
catch (error) {
|
|
422
|
+
const errorMessage = {
|
|
423
|
+
error,
|
|
424
|
+
message: 'Failed to retrieve page data',
|
|
425
|
+
graphql: {
|
|
426
|
+
query: completeQuery,
|
|
427
|
+
variables: requestVariables
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
throw errorMessage;
|
|
431
|
+
}
|
|
430
432
|
}
|
|
431
|
-
}
|
|
433
|
+
}
|
|
432
434
|
|
|
433
435
|
/**
|
|
434
436
|
* Parses a string into a URL object.
|
package/package.json
CHANGED
|
@@ -15,7 +15,6 @@ import { CollectionBuilder } from './builders/collection/collection';
|
|
|
15
15
|
* .sortBy([{ field: 'title', order: 'asc' }])
|
|
16
16
|
* .query(q => q.field('author').equals('John Doe'))
|
|
17
17
|
* .depth(1)
|
|
18
|
-
* .fetch();
|
|
19
18
|
*
|
|
20
19
|
* console.log(response.contentlets);
|
|
21
20
|
* ```
|
|
@@ -29,7 +28,6 @@ import { CollectionBuilder } from './builders/collection/collection';
|
|
|
29
28
|
* .sortBy([{ field: 'title', order: 'asc' }])
|
|
30
29
|
* .query(q => q.field('author').equals('John Doe'))
|
|
31
30
|
* .depth(1)
|
|
32
|
-
* .fetch()
|
|
33
31
|
* .then(response => console.log(response.contentlets))
|
|
34
32
|
* .catch(error => console.error(error));
|
|
35
33
|
* ```
|
|
@@ -45,7 +43,6 @@ import { CollectionBuilder } from './builders/collection/collection';
|
|
|
45
43
|
* const posts = await client.content
|
|
46
44
|
* .getCollection<BlogPost>('Blog')
|
|
47
45
|
* .limit(10)
|
|
48
|
-
* .fetch();
|
|
49
46
|
*
|
|
50
47
|
* posts.contentlets.forEach(post => {
|
|
51
48
|
* console.log(post.title, post.author, post.summary);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DotCMSGraphQLPageResponse } from '@dotcms/types';
|
|
1
|
+
import { DotCMSGraphQLPageResponse, DotCMSPageAsset } from '@dotcms/types';
|
|
2
2
|
/**
|
|
3
3
|
* Transforms a GraphQL Page response to a Page Entity.
|
|
4
4
|
*
|
|
@@ -10,4 +10,4 @@ import { DotCMSGraphQLPageResponse } from '@dotcms/types';
|
|
|
10
10
|
* const pageEntity = graphqlToPageEntity(graphQLPageResponse);
|
|
11
11
|
* ```
|
|
12
12
|
*/
|
|
13
|
-
export declare const graphqlToPageEntity: (graphQLPageResponse: DotCMSGraphQLPageResponse) =>
|
|
13
|
+
export declare const graphqlToPageEntity: (graphQLPageResponse: DotCMSGraphQLPageResponse) => DotCMSPageAsset | null;
|
package/transforms.cjs.js
CHANGED
|
@@ -924,7 +924,6 @@ var _Content_requestOptions, _Content_serverUrl;
|
|
|
924
924
|
* .sortBy([{ field: 'title', order: 'asc' }])
|
|
925
925
|
* .query(q => q.field('author').equals('John Doe'))
|
|
926
926
|
* .depth(1)
|
|
927
|
-
* .fetch();
|
|
928
927
|
*
|
|
929
928
|
* console.log(response.contentlets);
|
|
930
929
|
* ```
|
|
@@ -938,7 +937,6 @@ var _Content_requestOptions, _Content_serverUrl;
|
|
|
938
937
|
* .sortBy([{ field: 'title', order: 'asc' }])
|
|
939
938
|
* .query(q => q.field('author').equals('John Doe'))
|
|
940
939
|
* .depth(1)
|
|
941
|
-
* .fetch()
|
|
942
940
|
* .then(response => console.log(response.contentlets))
|
|
943
941
|
* .catch(error => console.error(error));
|
|
944
942
|
* ```
|
|
@@ -954,7 +952,6 @@ var _Content_requestOptions, _Content_serverUrl;
|
|
|
954
952
|
* const posts = await client.content
|
|
955
953
|
* .getCollection<BlogPost>('Blog')
|
|
956
954
|
* .limit(10)
|
|
957
|
-
* .fetch();
|
|
958
955
|
*
|
|
959
956
|
* posts.contentlets.forEach(post => {
|
|
960
957
|
* console.log(post.title, post.author, post.summary);
|
|
@@ -1082,8 +1079,9 @@ const graphqlToPageEntity = (graphQLPageResponse) => {
|
|
|
1082
1079
|
if (!page) {
|
|
1083
1080
|
return null;
|
|
1084
1081
|
}
|
|
1085
|
-
const { layout, template, containers, urlContentMap, viewAs,
|
|
1082
|
+
const { layout, template, containers, urlContentMap, viewAs, host, vanityUrl, runningExperimentId, _map, ...pageAsset } = page;
|
|
1086
1083
|
const data = (_map || {});
|
|
1084
|
+
const typedPageAsset = pageAsset;
|
|
1087
1085
|
// To prevent type errors, we cast the urlContentMap to an object
|
|
1088
1086
|
const urlContentMapObject = urlContentMap;
|
|
1089
1087
|
// Extract the _map data from the urlContentMap object
|
|
@@ -1092,20 +1090,22 @@ const graphqlToPageEntity = (graphQLPageResponse) => {
|
|
|
1092
1090
|
layout,
|
|
1093
1091
|
template,
|
|
1094
1092
|
viewAs,
|
|
1095
|
-
|
|
1093
|
+
vanityUrl,
|
|
1094
|
+
runningExperimentId,
|
|
1095
|
+
site: host,
|
|
1096
|
+
urlContentMap: urlContentMapData,
|
|
1097
|
+
containers: parseContainers(containers),
|
|
1096
1098
|
page: {
|
|
1097
1099
|
...data,
|
|
1098
|
-
...
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
urlContentMap: urlContentMapData
|
|
1102
|
-
}; // NOTE: This is a rabbit hole and we have to fix this, not in this PR tho.
|
|
1100
|
+
...typedPageAsset
|
|
1101
|
+
}
|
|
1102
|
+
};
|
|
1103
1103
|
};
|
|
1104
1104
|
/**
|
|
1105
1105
|
* Parses the containers from the GraphQL response.
|
|
1106
1106
|
*
|
|
1107
|
-
* @param {
|
|
1108
|
-
* @returns {
|
|
1107
|
+
* @param {DotCMSGraphQLPageContainer[]} [containers=[]] - The containers array from the GraphQL response.
|
|
1108
|
+
* @returns {DotCMSPageAssetContainers} The parsed containers.
|
|
1109
1109
|
*/
|
|
1110
1110
|
const parseContainers = (containers = []) => {
|
|
1111
1111
|
return containers.reduce((acc, container) => {
|
package/transforms.esm.js
CHANGED
|
@@ -922,7 +922,6 @@ var _Content_requestOptions, _Content_serverUrl;
|
|
|
922
922
|
* .sortBy([{ field: 'title', order: 'asc' }])
|
|
923
923
|
* .query(q => q.field('author').equals('John Doe'))
|
|
924
924
|
* .depth(1)
|
|
925
|
-
* .fetch();
|
|
926
925
|
*
|
|
927
926
|
* console.log(response.contentlets);
|
|
928
927
|
* ```
|
|
@@ -936,7 +935,6 @@ var _Content_requestOptions, _Content_serverUrl;
|
|
|
936
935
|
* .sortBy([{ field: 'title', order: 'asc' }])
|
|
937
936
|
* .query(q => q.field('author').equals('John Doe'))
|
|
938
937
|
* .depth(1)
|
|
939
|
-
* .fetch()
|
|
940
938
|
* .then(response => console.log(response.contentlets))
|
|
941
939
|
* .catch(error => console.error(error));
|
|
942
940
|
* ```
|
|
@@ -952,7 +950,6 @@ var _Content_requestOptions, _Content_serverUrl;
|
|
|
952
950
|
* const posts = await client.content
|
|
953
951
|
* .getCollection<BlogPost>('Blog')
|
|
954
952
|
* .limit(10)
|
|
955
|
-
* .fetch();
|
|
956
953
|
*
|
|
957
954
|
* posts.contentlets.forEach(post => {
|
|
958
955
|
* console.log(post.title, post.author, post.summary);
|
|
@@ -1080,8 +1077,9 @@ const graphqlToPageEntity = (graphQLPageResponse) => {
|
|
|
1080
1077
|
if (!page) {
|
|
1081
1078
|
return null;
|
|
1082
1079
|
}
|
|
1083
|
-
const { layout, template, containers, urlContentMap, viewAs,
|
|
1080
|
+
const { layout, template, containers, urlContentMap, viewAs, host, vanityUrl, runningExperimentId, _map, ...pageAsset } = page;
|
|
1084
1081
|
const data = (_map || {});
|
|
1082
|
+
const typedPageAsset = pageAsset;
|
|
1085
1083
|
// To prevent type errors, we cast the urlContentMap to an object
|
|
1086
1084
|
const urlContentMapObject = urlContentMap;
|
|
1087
1085
|
// Extract the _map data from the urlContentMap object
|
|
@@ -1090,20 +1088,22 @@ const graphqlToPageEntity = (graphQLPageResponse) => {
|
|
|
1090
1088
|
layout,
|
|
1091
1089
|
template,
|
|
1092
1090
|
viewAs,
|
|
1093
|
-
|
|
1091
|
+
vanityUrl,
|
|
1092
|
+
runningExperimentId,
|
|
1093
|
+
site: host,
|
|
1094
|
+
urlContentMap: urlContentMapData,
|
|
1095
|
+
containers: parseContainers(containers),
|
|
1094
1096
|
page: {
|
|
1095
1097
|
...data,
|
|
1096
|
-
...
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
urlContentMap: urlContentMapData
|
|
1100
|
-
}; // NOTE: This is a rabbit hole and we have to fix this, not in this PR tho.
|
|
1098
|
+
...typedPageAsset
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
1101
|
};
|
|
1102
1102
|
/**
|
|
1103
1103
|
* Parses the containers from the GraphQL response.
|
|
1104
1104
|
*
|
|
1105
|
-
* @param {
|
|
1106
|
-
* @returns {
|
|
1105
|
+
* @param {DotCMSGraphQLPageContainer[]} [containers=[]] - The containers array from the GraphQL response.
|
|
1106
|
+
* @returns {DotCMSPageAssetContainers} The parsed containers.
|
|
1107
1107
|
*/
|
|
1108
1108
|
const parseContainers = (containers = []) => {
|
|
1109
1109
|
return containers.reduce((acc, container) => {
|