@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.
- package/README.md +565 -153
- package/index.cjs.js +1418 -741
- package/index.esm.js +1418 -732
- package/internal.cjs.d.ts +1 -0
- package/internal.cjs.default.js +1 -0
- package/internal.cjs.js +85 -0
- package/internal.cjs.mjs +2 -0
- package/internal.esm.d.ts +1 -0
- package/internal.esm.js +83 -0
- package/package.json +14 -17
- package/src/index.d.ts +1 -8
- package/src/internal.d.ts +1 -0
- package/src/lib/client/client.d.ts +1 -29
- package/src/lib/client/content/builders/collection/collection.d.ts +1 -1
- package/src/lib/client/content/content-api.d.ts +3 -6
- package/src/lib/client/content/shared/types.d.ts +1 -42
- package/src/lib/client/navigation/navigation-api.d.ts +3 -20
- package/src/lib/client/page/page-api.d.ts +14 -84
- package/src/lib/utils/graphql/transforms.d.ts +2 -13
- package/src/lib/utils/index.d.ts +0 -1
- package/next.cjs.d.ts +0 -1
- package/next.cjs.default.js +0 -1
- package/next.cjs.js +0 -553
- package/next.cjs.mjs +0 -2
- package/next.esm.d.ts +0 -1
- package/next.esm.js +0 -551
- package/src/lib/client/models/types.d.ts +0 -516
- package/src/lib/deprecated/editor/listeners/listeners.d.ts +0 -45
- package/src/lib/deprecated/editor/models/client.model.d.ts +0 -111
- package/src/lib/deprecated/editor/models/editor.model.d.ts +0 -62
- package/src/lib/deprecated/editor/models/inline-event.model.d.ts +0 -9
- package/src/lib/deprecated/editor/models/listeners.model.d.ts +0 -55
- package/src/lib/deprecated/editor/sdk-editor-vtl.d.ts +0 -1
- package/src/lib/deprecated/editor/sdk-editor.d.ts +0 -92
- package/src/lib/deprecated/editor/utils/editor.utils.d.ts +0 -159
- package/src/lib/deprecated/editor/utils/traditional-vtl.utils.d.ts +0 -4
- package/src/lib/deprecated/sdk-js-client.d.ts +0 -276
- package/src/lib/utils/page/common-utils.d.ts +0 -33
- package/src/next.d.ts +0 -1
- package/src/types.d.ts +0 -2
- package/transforms.cjs.js +0 -1145
- package/transforms.esm.js +0 -1139
- package/types.cjs.d.ts +0 -1
- package/types.cjs.default.js +0 -1
- package/types.cjs.js +0 -2
- package/types.cjs.mjs +0 -2
- package/types.esm.d.ts +0 -1
- package/types.esm.js +0 -1
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @description Custom client parameters for fetching data.
|
|
3
|
-
*/
|
|
4
|
-
export type CustomClientParams = {
|
|
5
|
-
depth: string;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* @description Union type for fetch configurations.
|
|
9
|
-
* @typedef {GraphQLFetchConfig | PageAPIFetchConfig} DotCMSFetchConfig
|
|
10
|
-
*/
|
|
11
|
-
export type EditorConfig = {
|
|
12
|
-
params: CustomClientParams;
|
|
13
|
-
} | {
|
|
14
|
-
query: string;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Represents the configuration options for the DotCMS page editor.
|
|
18
|
-
* @export
|
|
19
|
-
* @interface DotCMSPageEditorConfig
|
|
20
|
-
*/
|
|
21
|
-
export interface DotCMSPageEditorConfig {
|
|
22
|
-
/**
|
|
23
|
-
* The pathname of the page being edited. Optional.
|
|
24
|
-
* @type {string}
|
|
25
|
-
*/
|
|
26
|
-
pathname: string;
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* @type {DotCMSFetchConfig}
|
|
30
|
-
* @memberof DotCMSPageEditorConfig
|
|
31
|
-
* @description The configuration custom params for data fetching on Edit Mode.
|
|
32
|
-
* @example <caption>Example with Custom GraphQL query</caption>
|
|
33
|
-
* const config: DotCMSPageEditorConfig = {
|
|
34
|
-
* editor: { query: 'query { ... }' }
|
|
35
|
-
* };
|
|
36
|
-
*
|
|
37
|
-
* @example <caption>Example usage with Custom Page API parameters</caption>
|
|
38
|
-
* const config: DotCMSPageEditorConfig = {
|
|
39
|
-
* editor: { params: { depth: '2' } }
|
|
40
|
-
* };
|
|
41
|
-
*/
|
|
42
|
-
editor?: EditorConfig;
|
|
43
|
-
/**
|
|
44
|
-
* The reload function to call when the page is reloaded.
|
|
45
|
-
* @deprecated In future implementation we will be listening for the changes from the editor to update the page state so reload will not be needed.
|
|
46
|
-
* @type {Function}
|
|
47
|
-
*/
|
|
48
|
-
onReload?: () => void;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Configuration for reordering a menu.
|
|
52
|
-
*/
|
|
53
|
-
export interface ReorderMenuConfig {
|
|
54
|
-
/**
|
|
55
|
-
* The starting level of the menu to be reordered.
|
|
56
|
-
*/
|
|
57
|
-
startLevel: number;
|
|
58
|
-
/**
|
|
59
|
-
* The depth of the menu levels to be reordered.
|
|
60
|
-
*/
|
|
61
|
-
depth: number;
|
|
62
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export type INLINE_EDITING_EVENT_KEY = 'BLOCK_EDITOR' | 'WYSIWYG';
|
|
2
|
-
export interface InlineEditorData {
|
|
3
|
-
inode: string;
|
|
4
|
-
language: number;
|
|
5
|
-
contentType: string;
|
|
6
|
-
fieldName: string;
|
|
7
|
-
content: Record<string, unknown>;
|
|
8
|
-
}
|
|
9
|
-
export type InlineEditEventData = InlineEditorData;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Actions received from the dotcms editor
|
|
3
|
-
*
|
|
4
|
-
* @export
|
|
5
|
-
* @enum {number}
|
|
6
|
-
*/
|
|
7
|
-
export declare enum NOTIFY_CLIENT {
|
|
8
|
-
/**
|
|
9
|
-
* Request to page to reload
|
|
10
|
-
*/
|
|
11
|
-
UVE_RELOAD_PAGE = "uve-reload-page",
|
|
12
|
-
/**
|
|
13
|
-
* Request the bounds for the elements
|
|
14
|
-
*/
|
|
15
|
-
UVE_REQUEST_BOUNDS = "uve-request-bounds",
|
|
16
|
-
/**
|
|
17
|
-
* Received pong from the editor
|
|
18
|
-
*/
|
|
19
|
-
UVE_EDITOR_PONG = "uve-editor-pong",
|
|
20
|
-
/**
|
|
21
|
-
* Received scroll event trigger from the editor
|
|
22
|
-
*/
|
|
23
|
-
UVE_SCROLL_INSIDE_IFRAME = "uve-scroll-inside-iframe",
|
|
24
|
-
/**
|
|
25
|
-
* Set the page data
|
|
26
|
-
*/
|
|
27
|
-
UVE_SET_PAGE_DATA = "uve-set-page-data",
|
|
28
|
-
/**
|
|
29
|
-
* Copy contentlet inline editing success
|
|
30
|
-
*/
|
|
31
|
-
UVE_COPY_CONTENTLET_INLINE_EDITING_SUCCESS = "uve-copy-contentlet-inline-editing-success"
|
|
32
|
-
}
|
|
33
|
-
type ListenerCallbackMessage = (event: MessageEvent) => void;
|
|
34
|
-
type ListenerCallbackPointer = (event: PointerEvent) => void;
|
|
35
|
-
/**
|
|
36
|
-
* Listener for the dotcms editor
|
|
37
|
-
*
|
|
38
|
-
* @interface DotCMSPageEditorListener
|
|
39
|
-
*/
|
|
40
|
-
interface DotCMSPageEditorListener {
|
|
41
|
-
type: 'listener';
|
|
42
|
-
event: string;
|
|
43
|
-
callback: ListenerCallbackMessage | ListenerCallbackPointer;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Observer for the dotcms editor
|
|
47
|
-
*
|
|
48
|
-
* @interface DotCMSPageEditorObserver
|
|
49
|
-
*/
|
|
50
|
-
interface DotCMSPageEditorObserver {
|
|
51
|
-
type: 'observer';
|
|
52
|
-
observer: MutationObserver;
|
|
53
|
-
}
|
|
54
|
-
export type DotCMSPageEditorSubscription = DotCMSPageEditorListener | DotCMSPageEditorObserver;
|
|
55
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { DotCMSPageEditorConfig, ReorderMenuConfig } from './models/editor.model';
|
|
2
|
-
import { INLINE_EDITING_EVENT_KEY, InlineEditEventData } from './models/inline-event.model';
|
|
3
|
-
import { Contentlet } from '../../client/content/shared/types';
|
|
4
|
-
/**
|
|
5
|
-
* Updates the navigation in the editor.
|
|
6
|
-
*
|
|
7
|
-
* @param {string} pathname - The pathname to update the navigation with.
|
|
8
|
-
* @memberof DotCMSPageEditor
|
|
9
|
-
* @example
|
|
10
|
-
* updateNavigation('/home'); // Sends a message to the editor to update the navigation to '/home'
|
|
11
|
-
*/
|
|
12
|
-
export declare function updateNavigation(pathname: string): void;
|
|
13
|
-
/**
|
|
14
|
-
* You can use this function to edit a contentlet in the editor.
|
|
15
|
-
*
|
|
16
|
-
* Calling this function inside the editor, will prompt the UVE to open a dialog to edit the contentlet.
|
|
17
|
-
*
|
|
18
|
-
* @export
|
|
19
|
-
* @template T
|
|
20
|
-
* @param {Contentlet<T>} contentlet - The contentlet to edit.
|
|
21
|
-
*/
|
|
22
|
-
export declare function editContentlet<T>(contentlet: Contentlet<T>): void;
|
|
23
|
-
/**
|
|
24
|
-
* Initializes the inline editing in the editor.
|
|
25
|
-
*
|
|
26
|
-
* @export
|
|
27
|
-
* @param {INLINE_EDITING_EVENT_KEY} type
|
|
28
|
-
* @param {InlineEditEventData} eventData
|
|
29
|
-
* @return {*}
|
|
30
|
-
*
|
|
31
|
-
* * @example
|
|
32
|
-
* ```html
|
|
33
|
-
* <div onclick="initInlineEditing('BLOCK_EDITOR', { inode, languageId, contentType, fieldName, content })">
|
|
34
|
-
* ${My Content}
|
|
35
|
-
* </div>
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare function initInlineEditing(type: INLINE_EDITING_EVENT_KEY, data?: InlineEditEventData): void;
|
|
39
|
-
export declare function reorderMenu(config?: ReorderMenuConfig): void;
|
|
40
|
-
/**
|
|
41
|
-
* @deprecated Use `getUVEState` function on {@link https://npmjs.com/package/@dotcms/uve|@dotcms/uve} instead, this function will be removed on future versions.
|
|
42
|
-
*
|
|
43
|
-
* Checks if the code is running inside the DotCMS Universal Visual Editor (UVE).
|
|
44
|
-
*
|
|
45
|
-
* The function checks three conditions:
|
|
46
|
-
* 1. If window is defined (for SSR environments)
|
|
47
|
-
* 2. If the page is not in preview mode
|
|
48
|
-
* 3. If the current window is embedded in a parent frame
|
|
49
|
-
*
|
|
50
|
-
* @returns {boolean} Returns true if running inside the UVE editor, false if running standalone or in preview mode
|
|
51
|
-
* @example
|
|
52
|
-
* ```ts
|
|
53
|
-
* // Check if code is running in editor before initializing editor-specific features
|
|
54
|
-
* if (isInsideEditor()) {
|
|
55
|
-
* initEditor(config);
|
|
56
|
-
* } else {
|
|
57
|
-
* initStandaloneMode();
|
|
58
|
-
* }
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
export declare function isInsideEditor(): boolean;
|
|
62
|
-
export declare function initDotUVE(): void;
|
|
63
|
-
/**
|
|
64
|
-
* Initializes the DotCMS page editor.
|
|
65
|
-
*
|
|
66
|
-
* @param {DotCMSPageEditorConfig} config - Optional configuration for the editor.
|
|
67
|
-
* @example
|
|
68
|
-
* ```ts
|
|
69
|
-
* const config = { pathname: '/home' };
|
|
70
|
-
* initEditor(config); // Initializes the editor with the provided configuration
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
export declare function initEditor(config: DotCMSPageEditorConfig): void;
|
|
74
|
-
/**
|
|
75
|
-
* Destroys the editor by removing event listeners and disconnecting observers.
|
|
76
|
-
*
|
|
77
|
-
* @example
|
|
78
|
-
* ```ts
|
|
79
|
-
* destroyEditor(); // Cleans up the editor by removing all event listeners and disconnecting observers
|
|
80
|
-
* ```
|
|
81
|
-
*/
|
|
82
|
-
export declare function destroyEditor(): void;
|
|
83
|
-
/**
|
|
84
|
-
* Adds a style class to empty contentlets.
|
|
85
|
-
*
|
|
86
|
-
* @export
|
|
87
|
-
* @example
|
|
88
|
-
* ```ts
|
|
89
|
-
* addClassToEmptyContentlets(); // Adds the 'empty-contentlet' class to all contentlets that have no height
|
|
90
|
-
* ```
|
|
91
|
-
*/
|
|
92
|
-
export declare function addClassToEmptyContentlets(): void;
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Bound information for a contentlet.
|
|
3
|
-
*
|
|
4
|
-
* @interface ContentletBound
|
|
5
|
-
* @property {number} x - The x-coordinate of the contentlet.
|
|
6
|
-
* @property {number} y - The y-coordinate of the contentlet.
|
|
7
|
-
* @property {number} width - The width of the contentlet.
|
|
8
|
-
* @property {number} height - The height of the contentlet.
|
|
9
|
-
* @property {string} payload - The payload data of the contentlet in JSON format.
|
|
10
|
-
*/
|
|
11
|
-
interface ContentletBound {
|
|
12
|
-
x: number;
|
|
13
|
-
y: number;
|
|
14
|
-
width: number;
|
|
15
|
-
height: number;
|
|
16
|
-
payload: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Bound information for a container.
|
|
20
|
-
*
|
|
21
|
-
* @interface ContainerBound
|
|
22
|
-
* @property {number} x - The x-coordinate of the container.
|
|
23
|
-
* @property {number} y - The y-coordinate of the container.
|
|
24
|
-
* @property {number} width - The width of the container.
|
|
25
|
-
* @property {number} height - The height of the container.
|
|
26
|
-
* @property {string} payload - The payload data of the container in JSON format.
|
|
27
|
-
* @property {ContentletBound[]} contentlets - An array of contentlets within the container.
|
|
28
|
-
*/
|
|
29
|
-
interface ContainerBound {
|
|
30
|
-
x: number;
|
|
31
|
-
y: number;
|
|
32
|
-
width: number;
|
|
33
|
-
height: number;
|
|
34
|
-
payload: string;
|
|
35
|
-
contentlets: ContentletBound[];
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Calculates the bounding information for each page element within the given containers.
|
|
39
|
-
*
|
|
40
|
-
* @export
|
|
41
|
-
* @param {HTMLDivElement[]} containers - An array of HTMLDivElement representing the containers.
|
|
42
|
-
* @return {ContainerBound[]} An array of objects containing the bounding information for each page element.
|
|
43
|
-
* @example
|
|
44
|
-
* ```ts
|
|
45
|
-
* const containers = document.querySelectorAll('.container');
|
|
46
|
-
* const bounds = getPageElementBound(containers);
|
|
47
|
-
* console.log(bounds);
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
export declare function getPageElementBound(containers: HTMLDivElement[]): ContainerBound[];
|
|
51
|
-
/**
|
|
52
|
-
* Calculates the bounding information for each contentlet inside a container.
|
|
53
|
-
*
|
|
54
|
-
* @export
|
|
55
|
-
* @param {DOMRect} containerRect - The bounding rectangle of the container.
|
|
56
|
-
* @param {HTMLDivElement[]} contentlets - An array of HTMLDivElement representing the contentlets.
|
|
57
|
-
* @return {ContentletBound[]} An array of objects containing the bounding information for each contentlet.
|
|
58
|
-
* @example
|
|
59
|
-
* ```ts
|
|
60
|
-
* const containerRect = container.getBoundingClientRect();
|
|
61
|
-
* const contentlets = container.querySelectorAll('.contentlet');
|
|
62
|
-
* const bounds = getContentletsBound(containerRect, contentlets);
|
|
63
|
-
* console.log(bounds); // Element bounds within the container
|
|
64
|
-
* ```
|
|
65
|
-
*/
|
|
66
|
-
export declare function getContentletsBound(containerRect: DOMRect, contentlets: HTMLDivElement[]): ContentletBound[];
|
|
67
|
-
/**
|
|
68
|
-
* Get container data from VTLS.
|
|
69
|
-
*
|
|
70
|
-
* @export
|
|
71
|
-
* @param {HTMLElement} container - The container element.
|
|
72
|
-
* @return {object} An object containing the container data.
|
|
73
|
-
* @example
|
|
74
|
-
* ```ts
|
|
75
|
-
* const container = document.querySelector('.container');
|
|
76
|
-
* const data = getContainerData(container);
|
|
77
|
-
* console.log(data);
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
export declare function getContainerData(container: HTMLElement): {
|
|
81
|
-
acceptTypes: string;
|
|
82
|
-
identifier: string;
|
|
83
|
-
maxContentlets: string;
|
|
84
|
-
uuid: string;
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Get the closest container data from the contentlet.
|
|
88
|
-
*
|
|
89
|
-
* @export
|
|
90
|
-
* @param {Element} element - The contentlet element.
|
|
91
|
-
* @return {object | null} An object containing the closest container data or null if no container is found.
|
|
92
|
-
* @example
|
|
93
|
-
* ```ts
|
|
94
|
-
* const contentlet = document.querySelector('.contentlet');
|
|
95
|
-
* const data = getClosestContainerData(contentlet);
|
|
96
|
-
* console.log(data);
|
|
97
|
-
* ```
|
|
98
|
-
*/
|
|
99
|
-
export declare function getClosestContainerData(element: Element): {
|
|
100
|
-
acceptTypes: string;
|
|
101
|
-
identifier: string;
|
|
102
|
-
maxContentlets: string;
|
|
103
|
-
uuid: string;
|
|
104
|
-
} | null;
|
|
105
|
-
/**
|
|
106
|
-
* Find the closest contentlet element based on HTMLElement.
|
|
107
|
-
*
|
|
108
|
-
* @export
|
|
109
|
-
* @param {HTMLElement | null} element - The starting element.
|
|
110
|
-
* @return {HTMLElement | null} The closest contentlet element or null if not found.
|
|
111
|
-
* @example
|
|
112
|
-
* const element = document.querySelector('.some-element');
|
|
113
|
-
* const contentlet = findDotElement(element);
|
|
114
|
-
* console.log(contentlet);
|
|
115
|
-
*/
|
|
116
|
-
export declare function findDotElement(element: HTMLElement | null): HTMLElement | null;
|
|
117
|
-
/**
|
|
118
|
-
* Find the closest VTL file element based on HTMLElement.
|
|
119
|
-
*
|
|
120
|
-
* @export
|
|
121
|
-
* @param {HTMLElement | null} element - The starting element.
|
|
122
|
-
* @return {HTMLElement | null} The closest VTL file element or null if not found.
|
|
123
|
-
* @example
|
|
124
|
-
* const element = document.querySelector('.some-element');
|
|
125
|
-
* const vtlFile = findDotVTLElement(element);
|
|
126
|
-
* console.log(vtlFile);
|
|
127
|
-
*/
|
|
128
|
-
export declare function findDotVTLElement(element: HTMLElement | null): HTMLElement | null;
|
|
129
|
-
/**
|
|
130
|
-
* Find VTL data within a target element.
|
|
131
|
-
*
|
|
132
|
-
* @export
|
|
133
|
-
* @param {HTMLElement} target - The target element to search within.
|
|
134
|
-
* @return {Array<{ inode: string, name: string }> | null} An array of objects containing VTL data or null if none found.
|
|
135
|
-
* @example
|
|
136
|
-
* ```ts
|
|
137
|
-
* const target = document.querySelector('.target-element');
|
|
138
|
-
* const vtlData = findVTLData(target);
|
|
139
|
-
* console.log(vtlData);
|
|
140
|
-
* ```
|
|
141
|
-
*/
|
|
142
|
-
export declare function findVTLData(target: HTMLElement): {
|
|
143
|
-
inode: string | undefined;
|
|
144
|
-
name: string | undefined;
|
|
145
|
-
}[] | null;
|
|
146
|
-
/**
|
|
147
|
-
* Check if the scroll position is at the bottom of the page.
|
|
148
|
-
*
|
|
149
|
-
* @export
|
|
150
|
-
* @return {boolean} True if the scroll position is at the bottom, otherwise false.
|
|
151
|
-
* @example
|
|
152
|
-
* ```ts
|
|
153
|
-
* if (scrollIsInBottom()) {
|
|
154
|
-
* console.log('Scrolled to the bottom');
|
|
155
|
-
* }
|
|
156
|
-
* ```
|
|
157
|
-
*/
|
|
158
|
-
export declare function scrollIsInBottom(): boolean;
|
|
159
|
-
export {};
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import { Content } from '../client/content/content-api';
|
|
2
|
-
export type ClientOptions = Omit<RequestInit, 'body' | 'method'>;
|
|
3
|
-
export interface ClientConfig {
|
|
4
|
-
/**
|
|
5
|
-
* The URL of the dotCMS instance.
|
|
6
|
-
*
|
|
7
|
-
* @description This is the URL of the dotCMS instance you want to interact with. Ensure to include the protocol (http or https).
|
|
8
|
-
* @example `https://demo.dotcms.com`
|
|
9
|
-
* @type {string}
|
|
10
|
-
* @required
|
|
11
|
-
*/
|
|
12
|
-
dotcmsUrl: string;
|
|
13
|
-
/**
|
|
14
|
-
* The id of the site you want to interact with. If not provided, it will use the default site.
|
|
15
|
-
*
|
|
16
|
-
* More information here: {@link https://www.dotcms.com/docs/latest/multi-site-management}
|
|
17
|
-
*
|
|
18
|
-
* @description To get the site id, go to the site you want to interact with and copy the id from the History tab.
|
|
19
|
-
* @type {string}
|
|
20
|
-
* @optional
|
|
21
|
-
*/
|
|
22
|
-
siteId?: string;
|
|
23
|
-
/**
|
|
24
|
-
* The authentication token to use for the requests.
|
|
25
|
-
*
|
|
26
|
-
* @description You can get the auth token from our UI {@link https://www.dotcms.com/docs/latest/rest-api-authentication#creating-an-api-token-in-the-ui}
|
|
27
|
-
* @type {string}
|
|
28
|
-
* @required
|
|
29
|
-
*/
|
|
30
|
-
authToken: string;
|
|
31
|
-
/**
|
|
32
|
-
* Additional options to pass to the fetch request.
|
|
33
|
-
*
|
|
34
|
-
* @description These options will be used in the fetch request. Any option can be specified except for 'body' and 'method' which are omitted.
|
|
35
|
-
* @example `{ headers: { 'Content-Type': 'application/json' } }`
|
|
36
|
-
* @type {ClientOptions}
|
|
37
|
-
* @optional
|
|
38
|
-
*/
|
|
39
|
-
requestOptions?: ClientOptions;
|
|
40
|
-
}
|
|
41
|
-
export type PageApiOptions = {
|
|
42
|
-
/**
|
|
43
|
-
* The path of the page you want to retrieve.
|
|
44
|
-
* @type {string}
|
|
45
|
-
*/
|
|
46
|
-
path: string;
|
|
47
|
-
/**
|
|
48
|
-
* The id of the site you want to interact with. If not provided, the one from the config will be used.
|
|
49
|
-
*
|
|
50
|
-
* More information here: {@link https://www.dotcms.com/docs/latest/multi-site-management}
|
|
51
|
-
* @type {string}
|
|
52
|
-
* @optional
|
|
53
|
-
*/
|
|
54
|
-
siteId?: string;
|
|
55
|
-
/**
|
|
56
|
-
* The mode of the page you want to retrieve. If not provided, will use the default mode of the site.
|
|
57
|
-
*
|
|
58
|
-
* More information here: {@link https://www.dotcms.com/docs/latest/page-viewing-modes}
|
|
59
|
-
* @type {string}
|
|
60
|
-
* @optional
|
|
61
|
-
*/
|
|
62
|
-
mode?: 'EDIT_MODE' | 'PREVIEW_MODE' | 'LIVE';
|
|
63
|
-
/**
|
|
64
|
-
* The language id of the page you want to retrieve. If not provided, will use the default language of the site.
|
|
65
|
-
* @type {number}
|
|
66
|
-
* @optional
|
|
67
|
-
*/
|
|
68
|
-
language_id?: number;
|
|
69
|
-
/**
|
|
70
|
-
* The id of the persona you want to retrieve the page for.
|
|
71
|
-
*
|
|
72
|
-
* More information here: {@link https://www.dotcms.com/docs/latest/personas}
|
|
73
|
-
* @type {string}
|
|
74
|
-
* @optional
|
|
75
|
-
*/
|
|
76
|
-
personaId?: string;
|
|
77
|
-
/**
|
|
78
|
-
* If you want to fire the rules set on the page.
|
|
79
|
-
*
|
|
80
|
-
* More information here: {@link https://www.dotcms.com/docs/latest/adding-rules-to-pages}
|
|
81
|
-
*
|
|
82
|
-
* @type {boolean}
|
|
83
|
-
* @optional
|
|
84
|
-
*/
|
|
85
|
-
fireRules?: boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Allows access to related content via the Relationship fields of contentlets on a Page; 0 (default).
|
|
88
|
-
* @type {number}
|
|
89
|
-
* @optional
|
|
90
|
-
*/
|
|
91
|
-
depth?: number;
|
|
92
|
-
};
|
|
93
|
-
type NavApiOptions = {
|
|
94
|
-
/**
|
|
95
|
-
* The root path to begin traversing the folder tree.
|
|
96
|
-
* @example
|
|
97
|
-
* `/api/v1/nav/` starts from the root of the site
|
|
98
|
-
* @example
|
|
99
|
-
* `/about-us` starts from the "About Us" folder
|
|
100
|
-
* @type {string}
|
|
101
|
-
*/
|
|
102
|
-
path: string;
|
|
103
|
-
/**
|
|
104
|
-
* The depth of the folder tree to return.
|
|
105
|
-
* @example
|
|
106
|
-
* `1` returns only the element specified in the path.
|
|
107
|
-
* @example
|
|
108
|
-
* `2` returns the element specified in the path, and if that element is a folder, returns all direct children of that folder.
|
|
109
|
-
* @example
|
|
110
|
-
* `3` returns all children and grandchildren of the element specified in the path.
|
|
111
|
-
* @type {number}
|
|
112
|
-
* @optional
|
|
113
|
-
*/
|
|
114
|
-
depth?: number;
|
|
115
|
-
/**
|
|
116
|
-
* The language ID of content to return.
|
|
117
|
-
* @example
|
|
118
|
-
* `1` (or unspecified) returns content in the default language of the site.
|
|
119
|
-
* @link https://www.dotcms.com/docs/latest/system-language-properties#DefaultLanguage
|
|
120
|
-
* @link https://www.dotcms.com/docs/latest/adding-and-editing-languages#LanguageID
|
|
121
|
-
* @type {number}
|
|
122
|
-
* @optional
|
|
123
|
-
*/
|
|
124
|
-
languageId?: number;
|
|
125
|
-
};
|
|
126
|
-
/**
|
|
127
|
-
* `DotCmsClient` is a TypeScript class that provides methods to interact with the DotCMS REST API.
|
|
128
|
-
* DotCMS is a hybrid-headless CMS and digital experience platform.
|
|
129
|
-
*
|
|
130
|
-
* @class DotCmsClient
|
|
131
|
-
* @property {ClientConfig} config - The configuration object for the DotCMS client.
|
|
132
|
-
* @property {Content} content - Provides methods to interact with content in DotCMS.
|
|
133
|
-
*
|
|
134
|
-
* @method constructor(config: ClientConfig) - Constructs a new instance of the DotCmsClient class.
|
|
135
|
-
*
|
|
136
|
-
* @method page.get(options: PageApiOptions): Promise<PageApiResponse> - Retrieves all the elements of any Page in your dotCMS system in JSON format.
|
|
137
|
-
* The Page API enables you to retrieve page information, layout, template, content blocks, and more.
|
|
138
|
-
* @see {@link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas}
|
|
139
|
-
*
|
|
140
|
-
* @method nav.get(options: NavApiOptions = { depth: 0, path: '/', languageId: 1 }): Promise<NavApiResponse> - Retrieves information about the dotCMS file and folder tree.
|
|
141
|
-
* The Navigation API allows you to fetch the site structure and menu items.
|
|
142
|
-
* @see {@link https://www.dotcms.com/docs/latest/navigation-rest-api}
|
|
143
|
-
*
|
|
144
|
-
* @method content.get(options: ContentApiOptions): Promise<ContentApiResponse> - Retrieves content items based on specified criteria.
|
|
145
|
-
* The Content API allows you to query and retrieve content by ID, inode, or using Lucene queries.
|
|
146
|
-
* @see {@link https://www.dotcms.com/docs/latest/content-api-retrieval-and-querying}
|
|
147
|
-
*
|
|
148
|
-
* @method editor.on(action: string, callbackFn: (payload: unknown) => void) - Allows you to react to actions issued by the Universal Visual Editor (UVE).
|
|
149
|
-
* @method editor.off(action: string) - Stops listening to an action issued by UVE.
|
|
150
|
-
*
|
|
151
|
-
* @static
|
|
152
|
-
* @method init(config: ClientConfig): DotCmsClient - Initializes and returns a DotCmsClient instance.
|
|
153
|
-
* @method dotcmsUrl: string - Retrieves the DotCMS URL from the instance configuration.
|
|
154
|
-
*
|
|
155
|
-
* @example <caption>Basic usage</caption>
|
|
156
|
-
* ```javascript
|
|
157
|
-
* const client = DotCmsClient.init({ dotcmsUrl: 'https://demo.dotcms.com', authToken: 'your-auth-token' });
|
|
158
|
-
*
|
|
159
|
-
* // Get a page
|
|
160
|
-
* client.page.get({ path: '/about-us' }).then(response => console.log(response));
|
|
161
|
-
*
|
|
162
|
-
* // Get navigation
|
|
163
|
-
* client.nav.get({ path: '/about-us', depth: 2 }).then(response => console.log(response));
|
|
164
|
-
*
|
|
165
|
-
* // Get content
|
|
166
|
-
* client.content.get({ query: '+contentType:Blog +languageId:1', limit: 10 }).then(response => console.log(response));
|
|
167
|
-
*
|
|
168
|
-
* // Listen to editor changes
|
|
169
|
-
* client.editor.on('changes', (payload) => console.log('Changes detected:', payload));
|
|
170
|
-
* ```
|
|
171
|
-
*/
|
|
172
|
-
export declare class DotCmsClient {
|
|
173
|
-
#private;
|
|
174
|
-
static instance: DotCmsClient;
|
|
175
|
-
dotcmsUrl?: string;
|
|
176
|
-
content: Content;
|
|
177
|
-
constructor(config?: ClientConfig);
|
|
178
|
-
page: {
|
|
179
|
-
/**
|
|
180
|
-
* `page.get` is an asynchronous method of the `DotCmsClient` class that retrieves all the elements of any Page in your dotCMS system in JSON format.
|
|
181
|
-
* It takes a `PageApiOptions` object as a parameter and returns a Promise that resolves to the response from the DotCMS API.
|
|
182
|
-
*
|
|
183
|
-
* The Page API enables you to retrieve all the elements of any Page in your dotCMS system.
|
|
184
|
-
* The elements may be retrieved in JSON format.
|
|
185
|
-
*
|
|
186
|
-
* @link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas
|
|
187
|
-
* @async
|
|
188
|
-
* @param {PageApiOptions} options - The options for the Page API call.
|
|
189
|
-
* @returns {Promise<unknown>} - A Promise that resolves to the response from the DotCMS API.
|
|
190
|
-
* @throws {Error} - Throws an error if the options are not valid.
|
|
191
|
-
* @example
|
|
192
|
-
* ```ts
|
|
193
|
-
* const client = new DotCmsClient({ dotcmsUrl: 'https://your.dotcms.com', authToken: 'your-auth-token', siteId: 'your-site-id' });
|
|
194
|
-
* client.page.get({ path: '/about-us' }).then(response => console.log(response));
|
|
195
|
-
* ```
|
|
196
|
-
*/
|
|
197
|
-
get: (options: PageApiOptions) => Promise<unknown>;
|
|
198
|
-
};
|
|
199
|
-
editor: {
|
|
200
|
-
/**
|
|
201
|
-
* `editor.on` is an asynchronous method of the `DotCmsClient` class that allows you to react to actions issued by the UVE.
|
|
202
|
-
*
|
|
203
|
-
* NOTE: This is being used by the development team - This logic is probably varied or moved to another function/object.
|
|
204
|
-
* @param {string} action - The name of the action emitted by UVE.
|
|
205
|
-
* @param {function} callbackFn - The function to execute when the UVE emits the action.
|
|
206
|
-
* @example
|
|
207
|
-
* ```ts
|
|
208
|
-
* client.editor.on('changes', (payload) => {
|
|
209
|
-
* console.log('Changes detected:', payload);
|
|
210
|
-
* });
|
|
211
|
-
* ```
|
|
212
|
-
*/
|
|
213
|
-
on: (action: string, callbackFn: (payload: unknown) => void) => void;
|
|
214
|
-
/**
|
|
215
|
-
* `editor.off` is a synchronous method of the `DotCmsClient` class that allows you to stop listening and reacting to an action issued by UVE.
|
|
216
|
-
*
|
|
217
|
-
* NOTE: This is being used by the development team - This logic is probably varied or moved to another function/object.
|
|
218
|
-
* @param {string} action - The name of the action to stop listening to.
|
|
219
|
-
* @example
|
|
220
|
-
* ```ts
|
|
221
|
-
* client.editor.off('changes');
|
|
222
|
-
* ```
|
|
223
|
-
*/
|
|
224
|
-
off: (action: string) => void;
|
|
225
|
-
};
|
|
226
|
-
nav: {
|
|
227
|
-
/**
|
|
228
|
-
* `nav.get` is an asynchronous method of the `DotCmsClient` class that retrieves information about the dotCMS file and folder tree.
|
|
229
|
-
* It takes a `NavApiOptions` object as a parameter (with default values) and returns a Promise that resolves to the response from the DotCMS API.
|
|
230
|
-
*
|
|
231
|
-
* The navigation REST API enables you to retrieve information about the dotCMS file and folder tree through REST API calls.
|
|
232
|
-
* @link https://www.dotcms.com/docs/latest/navigation-rest-api
|
|
233
|
-
* @async
|
|
234
|
-
* @param {NavApiOptions} options - The options for the Nav API call. Defaults to `{ depth: 0, path: '/', languageId: 1 }`.
|
|
235
|
-
* @returns {Promise<unknown>} - A Promise that resolves to the response from the DotCMS API.
|
|
236
|
-
* @throws {Error} - Throws an error if the options are not valid.
|
|
237
|
-
* @example
|
|
238
|
-
* ```ts
|
|
239
|
-
* const client = new DotCmsClient({ dotcmsUrl: 'https://your.dotcms.com', authToken: 'your-auth-token', siteId: 'your-site-id' }});
|
|
240
|
-
* client.nav.get({ path: '/about-us', depth: 2 }).then(response => console.log(response));
|
|
241
|
-
* ```
|
|
242
|
-
*/
|
|
243
|
-
get: (options?: NavApiOptions) => Promise<unknown>;
|
|
244
|
-
};
|
|
245
|
-
/**
|
|
246
|
-
* Initializes the DotCmsClient instance with the provided configuration.
|
|
247
|
-
* If an instance already exists, it returns the existing instance.
|
|
248
|
-
*
|
|
249
|
-
* @param {ClientConfig} config - The configuration object for the DotCMS client.
|
|
250
|
-
* @returns {DotCmsClient} - The initialized DotCmsClient instance.
|
|
251
|
-
* @example
|
|
252
|
-
* ```ts
|
|
253
|
-
* const client = DotCmsClient.init({ dotcmsUrl: 'https://demo.dotcms.com', authToken: 'your-auth-token' });
|
|
254
|
-
* ```
|
|
255
|
-
*/
|
|
256
|
-
static init(config: ClientConfig): DotCmsClient;
|
|
257
|
-
/**
|
|
258
|
-
* Retrieves the DotCMS URL from the instance configuration.
|
|
259
|
-
*
|
|
260
|
-
* @returns {string} - The DotCMS URL.
|
|
261
|
-
*/
|
|
262
|
-
static get dotcmsUrl(): string;
|
|
263
|
-
/**
|
|
264
|
-
* Throws an error if the path is not valid.
|
|
265
|
-
*
|
|
266
|
-
* @returns {string} - The authentication token.
|
|
267
|
-
*/
|
|
268
|
-
private validatePageOptions;
|
|
269
|
-
/**
|
|
270
|
-
* Throws an error if the path is not valid.
|
|
271
|
-
*
|
|
272
|
-
* @returns {string} - The authentication token.
|
|
273
|
-
*/
|
|
274
|
-
private validateNavOptions;
|
|
275
|
-
}
|
|
276
|
-
export {};
|