@dotcms/client 0.0.1-beta.9 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/README.md +565 -153
  2. package/index.cjs.js +1418 -741
  3. package/index.esm.js +1418 -732
  4. package/internal.cjs.d.ts +1 -0
  5. package/internal.cjs.default.js +1 -0
  6. package/internal.cjs.js +85 -0
  7. package/internal.cjs.mjs +2 -0
  8. package/internal.esm.d.ts +1 -0
  9. package/internal.esm.js +83 -0
  10. package/package.json +14 -17
  11. package/src/index.d.ts +1 -8
  12. package/src/internal.d.ts +1 -0
  13. package/src/lib/client/client.d.ts +1 -29
  14. package/src/lib/client/content/builders/collection/collection.d.ts +1 -1
  15. package/src/lib/client/content/content-api.d.ts +3 -6
  16. package/src/lib/client/content/shared/types.d.ts +1 -42
  17. package/src/lib/client/navigation/navigation-api.d.ts +3 -20
  18. package/src/lib/client/page/page-api.d.ts +14 -84
  19. package/src/lib/utils/graphql/transforms.d.ts +2 -13
  20. package/src/lib/utils/index.d.ts +0 -1
  21. package/next.cjs.d.ts +0 -1
  22. package/next.cjs.default.js +0 -1
  23. package/next.cjs.js +0 -553
  24. package/next.cjs.mjs +0 -2
  25. package/next.esm.d.ts +0 -1
  26. package/next.esm.js +0 -551
  27. package/src/lib/client/models/types.d.ts +0 -516
  28. package/src/lib/deprecated/editor/listeners/listeners.d.ts +0 -45
  29. package/src/lib/deprecated/editor/models/client.model.d.ts +0 -111
  30. package/src/lib/deprecated/editor/models/editor.model.d.ts +0 -62
  31. package/src/lib/deprecated/editor/models/inline-event.model.d.ts +0 -9
  32. package/src/lib/deprecated/editor/models/listeners.model.d.ts +0 -55
  33. package/src/lib/deprecated/editor/sdk-editor-vtl.d.ts +0 -1
  34. package/src/lib/deprecated/editor/sdk-editor.d.ts +0 -92
  35. package/src/lib/deprecated/editor/utils/editor.utils.d.ts +0 -159
  36. package/src/lib/deprecated/editor/utils/traditional-vtl.utils.d.ts +0 -4
  37. package/src/lib/deprecated/sdk-js-client.d.ts +0 -276
  38. package/src/lib/utils/page/common-utils.d.ts +0 -33
  39. package/src/next.d.ts +0 -1
  40. package/src/types.d.ts +0 -2
  41. package/transforms.cjs.js +0 -1145
  42. package/transforms.esm.js +0 -1139
  43. package/types.cjs.d.ts +0 -1
  44. package/types.cjs.default.js +0 -1
  45. package/types.cjs.js +0 -2
  46. package/types.cjs.mjs +0 -2
  47. package/types.esm.d.ts +0 -1
  48. package/types.esm.js +0 -1
@@ -0,0 +1 @@
1
+ export * from "./src/internal";
@@ -0,0 +1 @@
1
+ exports._default = require('./internal.cjs.js').default;
@@ -0,0 +1,85 @@
1
+ 'use strict';
2
+
3
+ /* eslint-disable @typescript-eslint/no-explicit-any */
4
+ /**
5
+ * Transforms a GraphQL Page response to a Page Entity.
6
+ *
7
+ * @param {GraphQLPageResponse} graphQLPageResponse - The GraphQL Page response object.
8
+ * @returns {object|null} The transformed Page Entity or null if the page is not present.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const pageEntity = graphqlToPageEntity(graphQLPageResponse);
13
+ * ```
14
+ */
15
+ const graphqlToPageEntity = (graphQLPageResponse) => {
16
+ const { page } = graphQLPageResponse;
17
+ // If there is no page, return null
18
+ if (!page) {
19
+ return null;
20
+ }
21
+ const { layout, template, containers, urlContentMap, viewAs, host, vanityUrl, runningExperimentId, _map, ...pageAsset } = page;
22
+ const data = (_map || {});
23
+ const typedPageAsset = pageAsset;
24
+ // To prevent type errors, we cast the urlContentMap to an object
25
+ const urlContentMapObject = urlContentMap;
26
+ // Extract the _map data from the urlContentMap object
27
+ const urlContentMapData = urlContentMapObject?.['_map'];
28
+ return {
29
+ layout,
30
+ template,
31
+ viewAs,
32
+ vanityUrl,
33
+ runningExperimentId,
34
+ site: host,
35
+ urlContentMap: urlContentMapData,
36
+ containers: parseContainers(containers),
37
+ page: {
38
+ ...data,
39
+ ...typedPageAsset
40
+ }
41
+ };
42
+ };
43
+ /**
44
+ * Parses the containers from the GraphQL response.
45
+ *
46
+ * @param {DotCMSGraphQLPageContainer[]} [containers=[]] - The containers array from the GraphQL response.
47
+ * @returns {DotCMSPageAssetContainers} The parsed containers.
48
+ */
49
+ const parseContainers = (containers = []) => {
50
+ return containers.reduce((acc, container) => {
51
+ const { path, identifier, containerStructures, containerContentlets, ...rest } = container;
52
+ const key = (path || identifier);
53
+ acc[key] = {
54
+ containerStructures,
55
+ container: {
56
+ path,
57
+ identifier,
58
+ ...rest
59
+ },
60
+ contentlets: parseContentletsToUuidMap(containerContentlets)
61
+ };
62
+ return acc;
63
+ }, {});
64
+ };
65
+ /**
66
+ * Parses the contentlets from the GraphQL response.
67
+ *
68
+ * @param {Array<Record<string, unknown>>} containerContentlets - The contentlets array from the GraphQL response.
69
+ * @returns {Record<string, Array<Record<string, unknown>>>} The parsed contentlets mapped by UUID.
70
+ */
71
+ const parseContentletsToUuidMap = (containerContentlets = []) => {
72
+ return containerContentlets.reduce((acc, containerContentlet) => {
73
+ const { uuid, contentlets } = containerContentlet;
74
+ // TODO: This is a temporary solution, we need to find a better way to handle this.
75
+ acc[uuid] = contentlets.map(({ _map = {}, ...rest }) => {
76
+ return {
77
+ ..._map,
78
+ ...rest
79
+ };
80
+ });
81
+ return acc;
82
+ }, {});
83
+ };
84
+
85
+ exports.graphqlToPageEntity = graphqlToPageEntity;
@@ -0,0 +1,2 @@
1
+ export * from './internal.cjs.js';
2
+ export { _default as default } from './internal.cjs.default.js';
@@ -0,0 +1 @@
1
+ export * from "./src/internal";
@@ -0,0 +1,83 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /**
3
+ * Transforms a GraphQL Page response to a Page Entity.
4
+ *
5
+ * @param {GraphQLPageResponse} graphQLPageResponse - The GraphQL Page response object.
6
+ * @returns {object|null} The transformed Page Entity or null if the page is not present.
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * const pageEntity = graphqlToPageEntity(graphQLPageResponse);
11
+ * ```
12
+ */
13
+ const graphqlToPageEntity = (graphQLPageResponse) => {
14
+ const { page } = graphQLPageResponse;
15
+ // If there is no page, return null
16
+ if (!page) {
17
+ return null;
18
+ }
19
+ const { layout, template, containers, urlContentMap, viewAs, host, vanityUrl, runningExperimentId, _map, ...pageAsset } = page;
20
+ const data = (_map || {});
21
+ const typedPageAsset = pageAsset;
22
+ // To prevent type errors, we cast the urlContentMap to an object
23
+ const urlContentMapObject = urlContentMap;
24
+ // Extract the _map data from the urlContentMap object
25
+ const urlContentMapData = urlContentMapObject?.['_map'];
26
+ return {
27
+ layout,
28
+ template,
29
+ viewAs,
30
+ vanityUrl,
31
+ runningExperimentId,
32
+ site: host,
33
+ urlContentMap: urlContentMapData,
34
+ containers: parseContainers(containers),
35
+ page: {
36
+ ...data,
37
+ ...typedPageAsset
38
+ }
39
+ };
40
+ };
41
+ /**
42
+ * Parses the containers from the GraphQL response.
43
+ *
44
+ * @param {DotCMSGraphQLPageContainer[]} [containers=[]] - The containers array from the GraphQL response.
45
+ * @returns {DotCMSPageAssetContainers} The parsed containers.
46
+ */
47
+ const parseContainers = (containers = []) => {
48
+ return containers.reduce((acc, container) => {
49
+ const { path, identifier, containerStructures, containerContentlets, ...rest } = container;
50
+ const key = (path || identifier);
51
+ acc[key] = {
52
+ containerStructures,
53
+ container: {
54
+ path,
55
+ identifier,
56
+ ...rest
57
+ },
58
+ contentlets: parseContentletsToUuidMap(containerContentlets)
59
+ };
60
+ return acc;
61
+ }, {});
62
+ };
63
+ /**
64
+ * Parses the contentlets from the GraphQL response.
65
+ *
66
+ * @param {Array<Record<string, unknown>>} containerContentlets - The contentlets array from the GraphQL response.
67
+ * @returns {Record<string, Array<Record<string, unknown>>>} The parsed contentlets mapped by UUID.
68
+ */
69
+ const parseContentletsToUuidMap = (containerContentlets = []) => {
70
+ return containerContentlets.reduce((acc, containerContentlet) => {
71
+ const { uuid, contentlets } = containerContentlet;
72
+ // TODO: This is a temporary solution, we need to find a better way to handle this.
73
+ acc[uuid] = contentlets.map(({ _map = {}, ...rest }) => {
74
+ return {
75
+ ..._map,
76
+ ...rest
77
+ };
78
+ });
79
+ return acc;
80
+ }, {});
81
+ };
82
+
83
+ export { graphqlToPageEntity };
package/package.json CHANGED
@@ -1,11 +1,17 @@
1
1
  {
2
2
  "name": "@dotcms/client",
3
- "version": "0.0.1-beta.9",
3
+ "version": "1.0.0",
4
4
  "description": "Official JavaScript library for interacting with DotCMS REST APIs.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/dotCMS/core.git#main"
8
8
  },
9
+ "dependencies": {
10
+ "consola": "^3.4.2"
11
+ },
12
+ "devDependencies": {
13
+ "@dotcms/types": "latest"
14
+ },
9
15
  "scripts": {
10
16
  "build": "nx run sdk-client:build:js; cd ../../../../dotCMS/src/main/webapp/html/js/editor-js; rm -rf src package.json *.esm.d.ts"
11
17
  },
@@ -24,17 +30,11 @@
24
30
  "import": "./index.cjs.mjs",
25
31
  "default": "./index.cjs.js"
26
32
  },
27
- "./next": {
28
- "module": "./next.esm.js",
29
- "types": "./next.esm.d.ts",
30
- "import": "./next.cjs.mjs",
31
- "default": "./next.cjs.js"
32
- },
33
- "./types": {
34
- "module": "./types.esm.js",
35
- "types": "./types.esm.d.ts",
36
- "import": "./types.cjs.mjs",
37
- "default": "./types.cjs.js"
33
+ "./internal": {
34
+ "module": "./internal.esm.js",
35
+ "types": "./internal.esm.d.ts",
36
+ "import": "./internal.cjs.mjs",
37
+ "default": "./internal.cjs.js"
38
38
  }
39
39
  },
40
40
  "typesVersions": {
@@ -42,11 +42,8 @@
42
42
  ".": [
43
43
  "./src/index.d.ts"
44
44
  ],
45
- "next": [
46
- "./src/next.d.ts"
47
- ],
48
- "types": [
49
- "./src/types.d.ts"
45
+ "internal": [
46
+ "./src/internal.d.ts"
50
47
  ]
51
48
  }
52
49
  },
package/src/index.d.ts CHANGED
@@ -1,8 +1 @@
1
- import { CLIENT_ACTIONS, postMessageToEditor } from './lib/deprecated/editor/models/client.model';
2
- import { CustomClientParams, DotCMSPageEditorConfig, EditorConfig } from './lib/deprecated/editor/models/editor.model';
3
- import { InlineEditorData, INLINE_EDITING_EVENT_KEY, InlineEditEventData } from './lib/deprecated/editor/models/inline-event.model';
4
- import { NOTIFY_CLIENT } from './lib/deprecated/editor/models/listeners.model';
5
- import { destroyEditor, editContentlet, reorderMenu, initEditor, isInsideEditor, updateNavigation, initInlineEditing } from './lib/deprecated/editor/sdk-editor';
6
- import { ClientConfig, DotCmsClient } from './lib/deprecated/sdk-js-client';
7
- import { getPageRequestParams, graphqlToPageEntity } from './lib/utils';
8
- export { destroyEditor, editContentlet, getPageRequestParams, graphqlToPageEntity, initEditor, initInlineEditing, isInsideEditor, postMessageToEditor, reorderMenu, updateNavigation, DotCmsClient, ClientConfig, CustomClientParams, DotCMSPageEditorConfig, EditorConfig, InlineEditEventData, InlineEditorData, CLIENT_ACTIONS, INLINE_EDITING_EVENT_KEY, NOTIFY_CLIENT };
1
+ export { createDotCMSClient } from './lib/client/client';
@@ -0,0 +1 @@
1
+ export { graphqlToPageEntity } from './lib/utils/graphql/transforms';
@@ -1,35 +1,7 @@
1
+ import { DotCMSClientConfig } from '@dotcms/types';
1
2
  import { Content } from './content/content-api';
2
3
  import { NavigationClient } from './navigation/navigation-api';
3
4
  import { PageClient } from './page/page-api';
4
- /**
5
- * Options for configuring fetch requests, excluding body and method properties.
6
- */
7
- export type RequestOptions = Omit<RequestInit, 'body' | 'method'>;
8
- /**
9
- * Configuration options for the DotCMS client.
10
- */
11
- export interface DotCMSClientConfig {
12
- /**
13
- * The URL of the dotCMS instance.
14
- * Ensure to include the protocol (http or https).
15
- * @example `https://demo.dotcms.com`
16
- */
17
- dotcmsUrl: string;
18
- /**
19
- * The authentication token for requests.
20
- * Obtainable from the dotCMS UI.
21
- */
22
- authToken: string;
23
- /**
24
- * The id of the site you want to interact with. Defaults to the default site if not provided.
25
- */
26
- siteId?: string;
27
- /**
28
- * Additional options for the fetch request.
29
- * @example `{ headers: { 'Content-Type': 'application/json' } }`
30
- */
31
- requestOptions?: RequestOptions;
32
- }
33
5
  /**
34
6
  * Client for interacting with the DotCMS REST API.
35
7
  * Provides access to content, page, and navigation functionality.
@@ -1,5 +1,5 @@
1
- import { ClientOptions } from '../../../../deprecated/sdk-js-client';
2
1
  import { GetCollectionResponse, BuildQuery, SortBy, GetCollectionError, OnFullfilled, OnRejected } from '../../shared/types';
2
+ export type ClientOptions = Omit<RequestInit, 'body' | 'method'>;
3
3
  /**
4
4
  * Creates a Builder to filter and fetch content from the content API for a specific content type.
5
5
  *
@@ -1,5 +1,5 @@
1
+ import { RequestOptions } from '@dotcms/types';
1
2
  import { CollectionBuilder } from './builders/collection/collection';
2
- import { ClientOptions } from '../../deprecated/sdk-js-client';
3
3
  /**
4
4
  * Creates a builder to filter and fetch a collection of content items.
5
5
  * @param contentType - The content type to retrieve.
@@ -15,7 +15,6 @@ import { ClientOptions } from '../../deprecated/sdk-js-client';
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 { ClientOptions } from '../../deprecated/sdk-js-client';
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 { ClientOptions } from '../../deprecated/sdk-js-client';
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);
@@ -56,10 +53,10 @@ export declare class Content {
56
53
  #private;
57
54
  /**
58
55
  * Creates an instance of Content.
59
- * @param {ClientOptions} requestOptions - The options for the client request.
56
+ * @param {RequestOptions} requestOptions - The options for the client request.
60
57
  * @param {string} serverUrl - The server URL.
61
58
  */
62
- constructor(requestOptions: ClientOptions, serverUrl: string);
59
+ constructor(requestOptions: RequestOptions, serverUrl: string);
63
60
  /**
64
61
  * Takes a content type and returns a builder to filter and fetch the collection.
65
62
  * @param {string} contentType - The content type to get the collection.
@@ -1,3 +1,4 @@
1
+ import { Contentlet } from '@dotcms/types';
1
2
  import { Equals } from '../builders/query/lucene-syntax';
2
3
  import { QueryBuilder } from '../builders/query/query';
3
4
  /**
@@ -21,48 +22,6 @@ export type SortBy = {
21
22
  * @returns {Equals} The built query.
22
23
  */
23
24
  export type BuildQuery = (qb: QueryBuilder) => Equals;
24
- /**
25
- * Main fields of a Contentlet (Inherited from the Content Type).
26
- */
27
- export interface ContentTypeMainFields {
28
- hostName: string;
29
- modDate: string;
30
- publishDate: string;
31
- title: string;
32
- baseType: string;
33
- inode: string;
34
- archived: boolean;
35
- ownerName: string;
36
- host: string;
37
- working: boolean;
38
- locked: boolean;
39
- stInode: string;
40
- contentType: string;
41
- live: boolean;
42
- owner: string;
43
- identifier: string;
44
- publishUserName: string;
45
- publishUser: string;
46
- languageId: number;
47
- creationDate: string;
48
- url: string;
49
- titleImage: string;
50
- modUserName: string;
51
- hasLiveVersion: boolean;
52
- folder: string;
53
- hasTitleImage: boolean;
54
- sortOrder: number;
55
- modUser: string;
56
- __icon__: string;
57
- contentTypeIcon: string;
58
- variant: string;
59
- }
60
- /**
61
- * The contentlet has the main fields and the custom fields of the content type.
62
- *
63
- * @template T - The custom fields of the content type.
64
- */
65
- export type Contentlet<T> = T & ContentTypeMainFields;
66
25
  /**
67
26
  * Callback for a fulfilled promise.
68
27
  *
@@ -1,20 +1,4 @@
1
- import { DotCMSClientConfig, RequestOptions } from '../client';
2
- interface NavRequestParams {
3
- /**
4
- * The depth of the folder tree to return.
5
- * @example
6
- * `1` returns only the element specified in the path.
7
- * `2` returns the element specified in the path, and if that element is a folder, returns all direct children of that folder.
8
- * `3` returns all children and grandchildren of the element specified in the path.
9
- */
10
- depth?: number;
11
- /**
12
- * The language ID of content to return.
13
- * @example
14
- * `1` (or unspecified) returns content in the default language of the site.
15
- */
16
- languageId?: number;
17
- }
1
+ import { DotCMSClientConfig, DotCMSNavigationRequestParams, RequestOptions, DotCMSNavigationItem } from '@dotcms/types';
18
2
  export declare class NavigationClient {
19
3
  private requestOptions;
20
4
  private BASE_URL;
@@ -22,10 +6,9 @@ export declare class NavigationClient {
22
6
  /**
23
7
  * Retrieves information about the dotCMS file and folder tree.
24
8
  * @param {NavigationApiOptions} options - The options for the Navigation API call. Defaults to `{ depth: 0, path: '/', languageId: 1 }`.
25
- * @returns {Promise<unknown>} - A Promise that resolves to the response from the DotCMS API.
9
+ * @returns {Promise<DotCMSNavigationItem[]>} - A Promise that resolves to the response from the DotCMS API.
26
10
  * @throws {Error} - Throws an error if the options are not valid.
27
11
  */
28
- get(path: string, params?: NavRequestParams): Promise<unknown>;
12
+ get(path: string, params?: DotCMSNavigationRequestParams): Promise<DotCMSNavigationItem[]>;
29
13
  private mapToBackendParams;
30
14
  }
31
- export {};
@@ -1,70 +1,9 @@
1
- import { DotCMSClientConfig, RequestOptions } from '../client';
2
- import { DotCMSGraphQLPageResponse, DotCMSPageAsset } from '../models/types';
3
- /**
4
- * The parameters for the Page API.
5
- * @public
6
- */
7
- export interface PageRequestParams {
8
- /**
9
- * The id of the site you want to interact with. Defaults to the one from the config if not provided.
10
- */
11
- siteId?: string;
12
- /**
13
- * The mode of the page you want to retrieve. Defaults to the site's default mode if not provided.
14
- */
15
- mode?: 'EDIT_MODE' | 'PREVIEW_MODE' | 'LIVE';
16
- /**
17
- * The language id of the page you want to retrieve. Defaults to the site's default language if not provided.
18
- */
19
- languageId?: number | string;
20
- /**
21
- * The id of the persona for which you want to retrieve the page.
22
- */
23
- personaId?: string;
24
- /**
25
- * Whether to fire the rules set on the page.
26
- */
27
- fireRules?: boolean | string;
28
- /**
29
- * Allows access to related content via the Relationship fields of contentlets on a Page; 0 (default).
30
- */
31
- depth?: 0 | 1 | 2 | 3 | '0' | '1' | '2' | '3';
32
- /**
33
- * The publish date of the page you want to retrieve.
34
- */
35
- publishDate?: string;
36
- /**
37
- * The variant name of the page you want to retrieve.
38
- */
39
- variantName?: string;
40
- }
41
- type StringifyParam<T> = T extends string | number | boolean ? string : never;
42
- type PageToBackendParamsMapping = {
43
- siteId: 'hostId';
44
- languageId: 'language_id';
45
- personaId: 'com.dotmarketing.persona.id';
46
- };
47
- /**
48
- * The private parameters for the Page API.
49
- * @internal
50
- */
51
- export type BackendPageParams = {
52
- [K in keyof PageRequestParams as K extends keyof PageToBackendParamsMapping ? PageToBackendParamsMapping[K] : K]?: StringifyParam<PageRequestParams[K]>;
53
- };
54
- export interface GraphQLPageOptions extends PageRequestParams {
55
- graphql: {
56
- page?: string;
57
- content?: Record<string, string>;
58
- variables?: Record<string, string>;
59
- fragments?: string[];
60
- };
61
- }
1
+ import { DotCMSClientConfig, DotCMSComposedPageResponse, DotCMSExtendedPageResponse, DotCMSPageResponse, DotCMSPageRequestParams, RequestOptions } from '@dotcms/types';
62
2
  /**
63
3
  * Client for interacting with the DotCMS Page API.
64
4
  * Provides methods to retrieve and manipulate pages.
65
5
  */
66
6
  export declare class PageClient {
67
- #private;
68
7
  /**
69
8
  * Request options including authorization headers.
70
9
  * @private
@@ -103,29 +42,22 @@ export declare class PageClient {
103
42
  */
104
43
  constructor(config: DotCMSClientConfig, requestOptions: RequestOptions);
105
44
  /**
106
- * Retrieves a page from DotCMS using either REST API or GraphQL.
107
- * This method is polymorphic and can handle both REST API and GraphQL requests based on the options provided.
45
+ * Retrieves a page from DotCMS using GraphQL.
108
46
  *
109
47
  * @param {string} url - The URL of the page to retrieve
110
- * @param {PageRequestParams | GraphQLPageOptions} [options] - Options for the request
111
- * @returns {Promise<DotCMSPageAsset | DotCMSGraphQLPageResponse>} A Promise that resolves to the page data
112
- *
113
- * @example Using REST API with options
114
- * ```typescript
115
- * const page = await pageClient.get('/about-us', {
116
- * mode: 'PREVIEW_MODE',
117
- * languageId: 1,
118
- * siteId: 'demo.dotcms.com'
119
- * });
120
- * ```
48
+ * @param {DotCMSPageRequestParams} [options] - Options for the request
49
+ * @template T - The type of the page and content, defaults to DotCMSBasicPage and Record<string, unknown> | unknown
50
+ * @returns {Promise<DotCMSComposedPageResponse<T>>} A Promise that resolves to the page data
121
51
  *
122
52
  * @example Using GraphQL
123
53
  * ```typescript
124
- * const page = await pageClient.get('/index', {
125
- * languageId: '1',
126
- * mode: 'LIVE',
127
- * graphql: {
128
- * page: `
54
+ * const page = await pageClient.get<{ page: MyPageWithBanners; content: { blogPosts: { blogTitle: string } } }>(
55
+ * '/index',
56
+ * {
57
+ * languageId: '1',
58
+ * mode: 'LIVE',
59
+ * graphql: {
60
+ * page: `
129
61
  * containers {
130
62
  * containerContentlets {
131
63
  * contentlets {
@@ -157,9 +89,7 @@ export declare class PageClient {
157
89
  * ]
158
90
  * }
159
91
  * });
160
- *```
92
+ * ```
161
93
  */
162
- get(url: string, options?: PageRequestParams): Promise<DotCMSPageAsset>;
163
- get(url: string, options?: GraphQLPageOptions): Promise<DotCMSGraphQLPageResponse>;
94
+ get<T extends DotCMSExtendedPageResponse = DotCMSPageResponse>(url: string, options?: DotCMSPageRequestParams): Promise<DotCMSComposedPageResponse<T>>;
164
95
  }
165
- export {};
@@ -1,14 +1,4 @@
1
- /**
2
- * Represents the response from a GraphQL query for a page.
3
- *
4
- * @interface GraphQLPageResponse
5
- * @property {Record<string, unknown>} page - The main page data.
6
- * @property {unknown} [key: string] - Additional properties that may be included in the response.
7
- */
8
- interface GraphQLPageResponse {
9
- page: Record<string, unknown>;
10
- [key: string]: unknown;
11
- }
1
+ import { DotCMSGraphQLPageResponse, DotCMSPageAsset } from '@dotcms/types';
12
2
  /**
13
3
  * Transforms a GraphQL Page response to a Page Entity.
14
4
  *
@@ -20,5 +10,4 @@ interface GraphQLPageResponse {
20
10
  * const pageEntity = graphqlToPageEntity(graphQLPageResponse);
21
11
  * ```
22
12
  */
23
- export declare const graphqlToPageEntity: (graphQLPageResponse: GraphQLPageResponse) => any;
24
- export {};
13
+ export declare const graphqlToPageEntity: (graphQLPageResponse: DotCMSGraphQLPageResponse) => DotCMSPageAsset | null;
@@ -1,2 +1 @@
1
1
  export * from './graphql/transforms';
2
- export * from './page/common-utils';
package/next.cjs.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from "./src/next";
@@ -1 +0,0 @@
1
- exports._default = require('./next.cjs.js').default;