@dotcms/types 0.0.1-beta.28 → 0.0.1-beta.30
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/package.json +1 -1
- package/src/index.d.ts +1 -0
- package/src/lib/client/public.d.ts +96 -0
- package/src/lib/editor/public.d.ts +2 -2
- package/src/lib/page/public.d.ts +32 -22
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The parameters for the Page API.
|
|
3
|
+
* @public
|
|
4
|
+
*/
|
|
5
|
+
export interface DotCMSPageRequestParams {
|
|
6
|
+
/**
|
|
7
|
+
* The id of the site you want to interact with. Defaults to the one from the config if not provided.
|
|
8
|
+
*/
|
|
9
|
+
siteId?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The mode of the page you want to retrieve. Defaults to the site's default mode if not provided.
|
|
12
|
+
*/
|
|
13
|
+
mode?: 'EDIT_MODE' | 'PREVIEW_MODE' | 'LIVE';
|
|
14
|
+
/**
|
|
15
|
+
* The language id of the page you want to retrieve. Defaults to the site's default language if not provided.
|
|
16
|
+
*/
|
|
17
|
+
languageId?: number | string;
|
|
18
|
+
/**
|
|
19
|
+
* The id of the persona for which you want to retrieve the page.
|
|
20
|
+
*/
|
|
21
|
+
personaId?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Whether to fire the rules set on the page.
|
|
24
|
+
*/
|
|
25
|
+
fireRules?: boolean | string;
|
|
26
|
+
/**
|
|
27
|
+
* Allows access to related content via the Relationship fields of contentlets on a Page; 0 (default).
|
|
28
|
+
*/
|
|
29
|
+
depth?: 0 | 1 | 2 | 3 | '0' | '1' | '2' | '3';
|
|
30
|
+
/**
|
|
31
|
+
* The publish date of the page you want to retrieve.
|
|
32
|
+
*/
|
|
33
|
+
publishDate?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The variant name of the page you want to retrieve.
|
|
36
|
+
*/
|
|
37
|
+
variantName?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The GraphQL options for the page.
|
|
40
|
+
*/
|
|
41
|
+
graphql?: {
|
|
42
|
+
page?: string;
|
|
43
|
+
content?: Record<string, string>;
|
|
44
|
+
variables?: Record<string, string>;
|
|
45
|
+
fragments?: string[];
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Options for configuring fetch requests, excluding body and method properties.
|
|
50
|
+
*/
|
|
51
|
+
export type RequestOptions = Omit<RequestInit, 'body' | 'method'>;
|
|
52
|
+
/**
|
|
53
|
+
* Configuration options for the DotCMS client.
|
|
54
|
+
*/
|
|
55
|
+
export interface DotCMSClientConfig {
|
|
56
|
+
/**
|
|
57
|
+
* The URL of the dotCMS instance.
|
|
58
|
+
* Ensure to include the protocol (http or https).
|
|
59
|
+
* @example `https://demo.dotcms.com`
|
|
60
|
+
*/
|
|
61
|
+
dotcmsUrl: string;
|
|
62
|
+
/**
|
|
63
|
+
* The authentication token for requests.
|
|
64
|
+
* Obtainable from the dotCMS UI.
|
|
65
|
+
*/
|
|
66
|
+
authToken: string;
|
|
67
|
+
/**
|
|
68
|
+
* The id of the site you want to interact with. Defaults to the default site if not provided.
|
|
69
|
+
*/
|
|
70
|
+
siteId?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Additional options for the fetch request.
|
|
73
|
+
* @example `{ headers: { 'Content-Type': 'application/json' } }`
|
|
74
|
+
*/
|
|
75
|
+
requestOptions?: RequestOptions;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* The parameters for the Navigation API.
|
|
79
|
+
* @public
|
|
80
|
+
*/
|
|
81
|
+
export interface DotCMSNavigationRequestParams {
|
|
82
|
+
/**
|
|
83
|
+
* The depth of the folder tree to return.
|
|
84
|
+
* @example
|
|
85
|
+
* `1` returns only the element specified in the path.
|
|
86
|
+
* `2` returns the element specified in the path, and if that element is a folder, returns all direct children of that folder.
|
|
87
|
+
* `3` returns all children and grandchildren of the element specified in the path.
|
|
88
|
+
*/
|
|
89
|
+
depth?: number;
|
|
90
|
+
/**
|
|
91
|
+
* The language ID of content to return.
|
|
92
|
+
* @example
|
|
93
|
+
* `1` (or unspecified) returns content in the default language of the site.
|
|
94
|
+
*/
|
|
95
|
+
languageId?: number;
|
|
96
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DotCMSContainerBound } from './internal';
|
|
2
|
-
import { DotCMSBasicContentlet,
|
|
2
|
+
import { DotCMSBasicContentlet, DotCMSPageResponse } from '../page/public';
|
|
3
3
|
/**
|
|
4
4
|
* Development mode
|
|
5
5
|
*
|
|
@@ -179,7 +179,7 @@ export declare enum UVEEventType {
|
|
|
179
179
|
* Type definitions for each event's payload
|
|
180
180
|
*/
|
|
181
181
|
export type UVEEventPayloadMap = {
|
|
182
|
-
[UVEEventType.CONTENT_CHANGES]:
|
|
182
|
+
[UVEEventType.CONTENT_CHANGES]: DotCMSPageResponse;
|
|
183
183
|
[UVEEventType.PAGE_RELOAD]: undefined;
|
|
184
184
|
[UVEEventType.REQUEST_BOUNDS]: DotCMSContainerBound[];
|
|
185
185
|
[UVEEventType.IFRAME_SCROLL]: 'up' | 'down';
|
package/src/lib/page/public.d.ts
CHANGED
|
@@ -987,9 +987,9 @@ interface DotCMSSiteField {
|
|
|
987
987
|
versionType: string;
|
|
988
988
|
}
|
|
989
989
|
/**
|
|
990
|
-
* Represents a basic page object
|
|
990
|
+
* Represents a basic page object from the GraphQL API
|
|
991
991
|
*
|
|
992
|
-
* @interface
|
|
992
|
+
* @interface DotCMSGraphQLPage
|
|
993
993
|
* @property {string} publishDate - The date the page was published
|
|
994
994
|
* @property {string} type - The type of the page
|
|
995
995
|
* @property {boolean} httpsRequired - Whether HTTPS is required to access the page
|
|
@@ -1032,14 +1032,14 @@ interface DotCMSSiteField {
|
|
|
1032
1032
|
* @property {string} conLanguage.languageCode - Language code
|
|
1033
1033
|
* @property {Object} template - Template information
|
|
1034
1034
|
* @property {boolean} template.drawed - Whether template is drawn
|
|
1035
|
-
* @property {
|
|
1035
|
+
* @property {DotCMSPageContainer[]} containers - Array of containers on the page
|
|
1036
1036
|
* @property {DotCMSLayout} layout - Layout configuration
|
|
1037
1037
|
* @property {DotCMSViewAs} viewAs - View configuration
|
|
1038
|
-
* @property {
|
|
1038
|
+
* @property {DotCMSURLContentMap} urlContentMap - URL to content mapping
|
|
1039
1039
|
* @property {DotCMSSite} site - Site information
|
|
1040
1040
|
* @property {Record<string, unknown>} _map - Additional mapping data
|
|
1041
1041
|
*/
|
|
1042
|
-
export interface
|
|
1042
|
+
export interface DotCMSGraphQLPage {
|
|
1043
1043
|
publishDate: string;
|
|
1044
1044
|
type: string;
|
|
1045
1045
|
httpsRequired: boolean;
|
|
@@ -1081,10 +1081,8 @@ export interface DotCMSBasicGraphQLPage {
|
|
|
1081
1081
|
language: string;
|
|
1082
1082
|
languageCode: string;
|
|
1083
1083
|
};
|
|
1084
|
-
template:
|
|
1085
|
-
|
|
1086
|
-
};
|
|
1087
|
-
containers: DotCMSPageGraphQLContainer[];
|
|
1084
|
+
template: Partial<DotCMSTemplate>;
|
|
1085
|
+
containers: DotCMSGraphQLPageContainer[];
|
|
1088
1086
|
layout: DotCMSLayout;
|
|
1089
1087
|
viewAs: DotCMSViewAs;
|
|
1090
1088
|
urlContentMap: Record<string, unknown>;
|
|
@@ -1092,16 +1090,16 @@ export interface DotCMSBasicGraphQLPage {
|
|
|
1092
1090
|
_map: Record<string, unknown>;
|
|
1093
1091
|
}
|
|
1094
1092
|
/**
|
|
1095
|
-
* Represents a container in a
|
|
1093
|
+
* Represents a container in a page
|
|
1096
1094
|
*
|
|
1097
|
-
* @interface
|
|
1095
|
+
* @interface DotCMSGraphQLPageContainer
|
|
1098
1096
|
* @property {string} path - The path/location of the container in the page
|
|
1099
1097
|
* @property {string} identifier - Unique identifier for the container
|
|
1100
1098
|
* @property {number} [maxContentlets] - Optional maximum number of content items allowed in container
|
|
1101
1099
|
* @property {DotCMSContainerStructure[]} containerStructures - Array of content type structures allowed in container
|
|
1102
1100
|
* @property {DotCMSPageContainerContentlets[]} containerContentlets - Array of content items in container
|
|
1103
1101
|
*/
|
|
1104
|
-
export interface
|
|
1102
|
+
export interface DotCMSGraphQLPageContainer {
|
|
1105
1103
|
path: string;
|
|
1106
1104
|
identifier: string;
|
|
1107
1105
|
maxContentlets?: number;
|
|
@@ -1127,14 +1125,11 @@ export interface DotCMSGraphQLError {
|
|
|
1127
1125
|
};
|
|
1128
1126
|
}
|
|
1129
1127
|
/**
|
|
1130
|
-
* Represents the complete response from a
|
|
1131
|
-
*
|
|
1132
|
-
* @template TContent - The type of the content data
|
|
1133
|
-
* @template TNav - The type of the navigation data
|
|
1128
|
+
* Represents the complete response from a page query from the GraphQL API
|
|
1134
1129
|
*/
|
|
1135
|
-
export interface DotCMSGraphQLPageResponse
|
|
1136
|
-
page:
|
|
1137
|
-
content?:
|
|
1130
|
+
export interface DotCMSGraphQLPageResponse {
|
|
1131
|
+
page: DotCMSGraphQLPage;
|
|
1132
|
+
content?: Record<string, unknown> | unknown;
|
|
1138
1133
|
errors?: DotCMSGraphQLError;
|
|
1139
1134
|
graphql: {
|
|
1140
1135
|
query: string;
|
|
@@ -1142,8 +1137,23 @@ export interface DotCMSGraphQLPageResponse<TContent = Record<string, any>> {
|
|
|
1142
1137
|
};
|
|
1143
1138
|
}
|
|
1144
1139
|
/**
|
|
1145
|
-
*
|
|
1146
|
-
* @interface DotCMSEditablePage
|
|
1140
|
+
* Represents the complete response from a page query
|
|
1147
1141
|
*/
|
|
1148
|
-
export
|
|
1142
|
+
export interface DotCMSPageResponse {
|
|
1143
|
+
pageAsset: DotCMSPageAsset;
|
|
1144
|
+
content?: Record<string, unknown> | unknown;
|
|
1145
|
+
errors?: DotCMSGraphQLError;
|
|
1146
|
+
graphql: {
|
|
1147
|
+
query: string;
|
|
1148
|
+
variables: Record<string, unknown>;
|
|
1149
|
+
};
|
|
1150
|
+
}
|
|
1151
|
+
export type DotCMSExtendedPageResponse = Partial<Pick<DotCMSPageResponse, 'pageAsset' | 'content'>>;
|
|
1152
|
+
export type DotCMSComposedPageAsset<T extends DotCMSExtendedPageResponse> = T['pageAsset'] extends DotCMSPageResponse['pageAsset'] ? DotCMSPageResponse['pageAsset'] & T['pageAsset'] : DotCMSPageResponse['pageAsset'];
|
|
1153
|
+
export type DotCMSComposedContent<T extends Pick<DotCMSPageResponse, 'content'>> = T['content'] extends undefined ? DotCMSPageResponse['content'] : T['content'];
|
|
1154
|
+
export type DotCMSComposedPageResponse<T extends DotCMSExtendedPageResponse> = Omit<DotCMSPageResponse, 'pageAsset' | 'content'> & {
|
|
1155
|
+
pageAsset: DotCMSComposedPageAsset<T>;
|
|
1156
|
+
content?: DotCMSComposedContent<T>;
|
|
1157
|
+
};
|
|
1158
|
+
export type DotCMSClientPageGetResponse<T extends DotCMSExtendedPageResponse> = Promise<DotCMSComposedPageResponse<T>>;
|
|
1149
1159
|
export {};
|