@dotcms/client 0.0.1-alpha.36 → 0.0.1-alpha.38
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 +4 -4
- package/index.cjs.js +579 -116
- package/index.esm.js +579 -116
- package/package.json +1 -1
- package/src/lib/client/content/builders/collection/collection.d.ts +138 -60
- package/src/lib/client/content/content-api.d.ts +60 -9
- package/src/lib/client/content/shared/const.d.ts +10 -0
- package/src/lib/client/content/shared/types.d.ts +76 -0
- package/src/lib/client/content/shared/utils.d.ts +12 -4
- package/src/lib/client/models/index.d.ts +11 -0
- package/src/lib/client/models/types.d.ts +8 -0
- package/src/lib/client/sdk-js-client.d.ts +113 -30
- package/src/lib/editor/listeners/listeners.d.ts +5 -1
- package/src/lib/editor/sdk-editor.d.ts +28 -3
- package/src/lib/editor/utils/editor.utils.d.ts +88 -12
- package/src/lib/query-builder/lucene-syntax/Equals.d.ts +38 -7
- package/src/lib/query-builder/lucene-syntax/Field.d.ts +13 -4
- package/src/lib/query-builder/lucene-syntax/NotOperand.d.ts +5 -1
- package/src/lib/query-builder/sdk-query-builder.d.ts +37 -3
- package/src/lib/query-builder/utils/index.d.ts +51 -0
- package/src/lib/utils/graphql/transforms.d.ts +23 -10
- package/src/lib/utils/page/common-utils.d.ts +30 -8
|
@@ -11,19 +11,19 @@ export interface ClientConfig {
|
|
|
11
11
|
*/
|
|
12
12
|
dotcmsUrl: string;
|
|
13
13
|
/**
|
|
14
|
-
* The id of the site you want to interact with.
|
|
14
|
+
* The id of the site you want to interact with. If not provided, it will use the default site.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
16
|
+
* More information here: {@link https://www.dotcms.com/docs/latest/multi-site-management}
|
|
17
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.
|
|
18
19
|
* @type {string}
|
|
19
|
-
* @
|
|
20
|
+
* @optional
|
|
20
21
|
*/
|
|
21
22
|
siteId?: string;
|
|
22
23
|
/**
|
|
23
|
-
* The authentication token to use for the requests.
|
|
24
|
-
*
|
|
25
|
-
* @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}
|
|
24
|
+
* The authentication token to use for the requests.
|
|
26
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
27
|
* @type {string}
|
|
28
28
|
* @required
|
|
29
29
|
*/
|
|
@@ -38,59 +38,65 @@ export interface ClientConfig {
|
|
|
38
38
|
*/
|
|
39
39
|
requestOptions?: ClientOptions;
|
|
40
40
|
}
|
|
41
|
-
type PageApiOptions = {
|
|
41
|
+
export type PageApiOptions = {
|
|
42
42
|
/**
|
|
43
43
|
* The path of the page you want to retrieve.
|
|
44
|
-
*
|
|
45
44
|
* @type {string}
|
|
46
45
|
*/
|
|
47
46
|
path: string;
|
|
48
47
|
/**
|
|
49
48
|
* The id of the site you want to interact with. If not provided, the one from the config will be used.
|
|
50
49
|
*
|
|
51
|
-
* @
|
|
50
|
+
* More information here: {@link https://www.dotcms.com/docs/latest/multi-site-management}
|
|
51
|
+
* @type {string}
|
|
52
|
+
* @optional
|
|
52
53
|
*/
|
|
53
54
|
siteId?: string;
|
|
54
55
|
/**
|
|
55
|
-
* The mode of the page you want to retrieve. If not provided will use the default mode of the site.
|
|
56
|
+
* The mode of the page you want to retrieve. If not provided, will use the default mode of the site.
|
|
56
57
|
*
|
|
57
|
-
* @
|
|
58
|
+
* More information here: {@link https://www.dotcms.com/docs/latest/page-viewing-modes}
|
|
59
|
+
* @type {string}
|
|
60
|
+
* @optional
|
|
58
61
|
*/
|
|
59
|
-
mode?:
|
|
62
|
+
mode?: 'EDIT_MODE' | 'PREVIEW_MODE' | 'LIVE_MODE';
|
|
60
63
|
/**
|
|
61
|
-
* The language id of the page you want to retrieve. If not provided will use the default language of the site.
|
|
62
|
-
*
|
|
64
|
+
* The language id of the page you want to retrieve. If not provided, will use the default language of the site.
|
|
63
65
|
* @type {number}
|
|
66
|
+
* @optional
|
|
64
67
|
*/
|
|
65
68
|
language_id?: number;
|
|
66
69
|
/**
|
|
67
70
|
* The id of the persona you want to retrieve the page for.
|
|
68
71
|
*
|
|
72
|
+
* More information here: {@link https://www.dotcms.com/docs/latest/personas}
|
|
69
73
|
* @type {string}
|
|
74
|
+
* @optional
|
|
70
75
|
*/
|
|
71
76
|
personaId?: string;
|
|
72
77
|
/**
|
|
73
|
-
* If you want to fire the rules set on the page
|
|
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}
|
|
74
81
|
*
|
|
75
82
|
* @type {boolean}
|
|
83
|
+
* @optional
|
|
76
84
|
*/
|
|
77
85
|
fireRules?: boolean;
|
|
78
86
|
/**
|
|
79
|
-
* Allows access to related content via the Relationship fields of contentlets on a Page; 0 (default)
|
|
80
|
-
*
|
|
87
|
+
* Allows access to related content via the Relationship fields of contentlets on a Page; 0 (default).
|
|
81
88
|
* @type {number}
|
|
89
|
+
* @optional
|
|
82
90
|
*/
|
|
83
91
|
depth?: number;
|
|
84
92
|
};
|
|
85
93
|
type NavApiOptions = {
|
|
86
94
|
/**
|
|
87
95
|
* The root path to begin traversing the folder tree.
|
|
88
|
-
*
|
|
89
96
|
* @example
|
|
90
97
|
* `/api/v1/nav/` starts from the root of the site
|
|
91
98
|
* @example
|
|
92
99
|
* `/about-us` starts from the "About Us" folder
|
|
93
|
-
*
|
|
94
100
|
* @type {string}
|
|
95
101
|
*/
|
|
96
102
|
path: string;
|
|
@@ -102,35 +108,66 @@ type NavApiOptions = {
|
|
|
102
108
|
* `2` returns the element specified in the path, and if that element is a folder, returns all direct children of that folder.
|
|
103
109
|
* @example
|
|
104
110
|
* `3` returns all children and grandchildren of the element specified in the path.
|
|
105
|
-
*
|
|
106
111
|
* @type {number}
|
|
112
|
+
* @optional
|
|
107
113
|
*/
|
|
108
114
|
depth?: number;
|
|
109
115
|
/**
|
|
110
116
|
* The language ID of content to return.
|
|
111
117
|
* @example
|
|
112
118
|
* `1` (or unspecified) returns content in the default language of the site.
|
|
113
|
-
*
|
|
114
119
|
* @link https://www.dotcms.com/docs/latest/system-language-properties#DefaultLanguage
|
|
115
120
|
* @link https://www.dotcms.com/docs/latest/adding-and-editing-languages#LanguageID
|
|
116
121
|
* @type {number}
|
|
122
|
+
* @optional
|
|
117
123
|
*/
|
|
118
124
|
languageId?: number;
|
|
119
125
|
};
|
|
120
126
|
/**
|
|
121
127
|
* `DotCmsClient` is a TypeScript class that provides methods to interact with the DotCMS REST API.
|
|
122
|
-
*
|
|
128
|
+
* DotCMS is a hybrid-headless CMS and digital experience platform.
|
|
123
129
|
*
|
|
124
130
|
* @class DotCmsClient
|
|
125
|
-
*
|
|
126
131
|
* @property {ClientConfig} config - The configuration object for the DotCMS client.
|
|
132
|
+
* @property {Content} content - Provides methods to interact with content in DotCMS.
|
|
127
133
|
*
|
|
128
134
|
* @method constructor(config: ClientConfig) - Constructs a new instance of the DotCmsClient class.
|
|
129
135
|
*
|
|
130
|
-
* @method page.get(options: PageApiOptions): Promise<
|
|
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' });
|
|
131
158
|
*
|
|
132
|
-
*
|
|
159
|
+
* // Get a page
|
|
160
|
+
* client.page.get({ path: '/about-us' }).then(response => console.log(response));
|
|
133
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
|
+
* ```
|
|
134
171
|
*/
|
|
135
172
|
export declare class DotCmsClient {
|
|
136
173
|
#private;
|
|
@@ -151,6 +188,11 @@ export declare class DotCmsClient {
|
|
|
151
188
|
* @param {PageApiOptions} options - The options for the Page API call.
|
|
152
189
|
* @returns {Promise<unknown>} - A Promise that resolves to the response from the DotCMS API.
|
|
153
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
|
+
* ```
|
|
154
196
|
*/
|
|
155
197
|
get: (options: PageApiOptions) => Promise<unknown>;
|
|
156
198
|
};
|
|
@@ -159,15 +201,25 @@ export declare class DotCmsClient {
|
|
|
159
201
|
* `editor.on` is an asynchronous method of the `DotCmsClient` class that allows you to react to actions issued by the UVE.
|
|
160
202
|
*
|
|
161
203
|
* NOTE: This is being used by the development team - This logic is probably varied or moved to another function/object.
|
|
162
|
-
* @param action - The name of the
|
|
163
|
-
* @param callbackFn - The function to execute when the UVE emits the action
|
|
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
|
+
* ```
|
|
164
212
|
*/
|
|
165
213
|
on: (action: string, callbackFn: (payload: unknown) => void) => void;
|
|
166
214
|
/**
|
|
167
|
-
* `editor.off` is
|
|
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.
|
|
168
216
|
*
|
|
169
|
-
*
|
|
170
|
-
* @param action
|
|
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
|
+
* ```
|
|
171
223
|
*/
|
|
172
224
|
off: (action: string) => void;
|
|
173
225
|
};
|
|
@@ -182,12 +234,43 @@ export declare class DotCmsClient {
|
|
|
182
234
|
* @param {NavApiOptions} options - The options for the Nav API call. Defaults to `{ depth: 0, path: '/', languageId: 1 }`.
|
|
183
235
|
* @returns {Promise<unknown>} - A Promise that resolves to the response from the DotCMS API.
|
|
184
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
|
+
* ```
|
|
185
242
|
*/
|
|
186
243
|
get: (options?: NavApiOptions) => Promise<unknown>;
|
|
187
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
|
+
*/
|
|
188
256
|
static init(config: ClientConfig): DotCmsClient;
|
|
257
|
+
/**
|
|
258
|
+
* Retrieves the DotCMS URL from the instance configuration.
|
|
259
|
+
*
|
|
260
|
+
* @returns {string} - The DotCMS URL.
|
|
261
|
+
*/
|
|
189
262
|
static get dotcmsUrl(): string;
|
|
263
|
+
/**
|
|
264
|
+
* Throws an error if the path is not valid.
|
|
265
|
+
*
|
|
266
|
+
* @returns {string} - The authentication token.
|
|
267
|
+
*/
|
|
190
268
|
private validatePageOptions;
|
|
269
|
+
/**
|
|
270
|
+
* Throws an error if the path is not valid.
|
|
271
|
+
*
|
|
272
|
+
* @returns {string} - The authentication token.
|
|
273
|
+
*/
|
|
191
274
|
private validateNavOptions;
|
|
192
275
|
}
|
|
193
276
|
export {};
|
|
@@ -10,7 +10,7 @@ declare global {
|
|
|
10
10
|
*/
|
|
11
11
|
export declare const subscriptions: DotCMSPageEditorSubscription[];
|
|
12
12
|
/**
|
|
13
|
-
* Listens for editor messages and performs
|
|
13
|
+
* Listens for editor messages and performs corresponding actions based on the received message.
|
|
14
14
|
*
|
|
15
15
|
* @private
|
|
16
16
|
* @memberof DotCMSPageEditor
|
|
@@ -35,6 +35,10 @@ export declare function scrollHandler(): void;
|
|
|
35
35
|
* Restores the scroll position of the window when an iframe is loaded.
|
|
36
36
|
* Only used in VTL Pages.
|
|
37
37
|
* @export
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* preserveScrollOnIframe();
|
|
41
|
+
* ```
|
|
38
42
|
*/
|
|
39
43
|
export declare function preserveScrollOnIframe(): void;
|
|
40
44
|
/**
|
|
@@ -1,29 +1,54 @@
|
|
|
1
1
|
import { DotCMSPageEditorConfig } from './models/editor.model';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
3
|
* Updates the navigation in the editor.
|
|
4
|
+
*
|
|
5
5
|
* @param {string} pathname - The pathname to update the navigation with.
|
|
6
6
|
* @memberof DotCMSPageEditor
|
|
7
|
+
* @example
|
|
8
|
+
* updateNavigation('/home'); // Sends a message to the editor to update the navigation to '/home'
|
|
7
9
|
*/
|
|
8
10
|
export declare function updateNavigation(pathname: string): void;
|
|
9
11
|
/**
|
|
10
12
|
* Checks if the code is running inside an editor.
|
|
13
|
+
*
|
|
11
14
|
* @returns {boolean} Returns true if the code is running inside an editor, otherwise false.
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* if (isInsideEditor()) {
|
|
18
|
+
* console.log('Running inside the editor');
|
|
19
|
+
* } else {
|
|
20
|
+
* console.log('Running outside the editor');
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
12
23
|
*/
|
|
13
24
|
export declare function isInsideEditor(): boolean;
|
|
14
25
|
/**
|
|
15
26
|
* Initializes the DotCMS page editor.
|
|
16
27
|
*
|
|
17
|
-
* @param
|
|
28
|
+
* @param {DotCMSPageEditorConfig} config - Optional configuration for the editor.
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const config = { pathname: '/home' };
|
|
32
|
+
* initEditor(config); // Initializes the editor with the provided configuration
|
|
33
|
+
* ```
|
|
18
34
|
*/
|
|
19
35
|
export declare function initEditor(config: DotCMSPageEditorConfig): void;
|
|
20
36
|
/**
|
|
21
37
|
* Destroys the editor by removing event listeners and disconnecting observers.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* destroyEditor(); // Cleans up the editor by removing all event listeners and disconnecting observers
|
|
42
|
+
* ```
|
|
22
43
|
*/
|
|
23
44
|
export declare function destroyEditor(): void;
|
|
24
45
|
/**
|
|
25
|
-
* Adds a class to empty contentlets.
|
|
46
|
+
* Adds a style class to empty contentlets.
|
|
26
47
|
*
|
|
27
48
|
* @export
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* addClassToEmptyContentlets(); // Adds the 'empty-contentlet' class to all contentlets that have no height
|
|
52
|
+
* ```
|
|
28
53
|
*/
|
|
29
54
|
export declare function addClassToEmptyContentlets(): void;
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
* Bound information for a contentlet.
|
|
3
3
|
*
|
|
4
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.
|
|
5
10
|
*/
|
|
6
11
|
interface ContentletBound {
|
|
7
12
|
x: number;
|
|
@@ -14,6 +19,12 @@ interface ContentletBound {
|
|
|
14
19
|
* Bound information for a container.
|
|
15
20
|
*
|
|
16
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.
|
|
17
28
|
*/
|
|
18
29
|
interface ContainerBound {
|
|
19
30
|
x: number;
|
|
@@ -27,25 +38,44 @@ interface ContainerBound {
|
|
|
27
38
|
* Calculates the bounding information for each page element within the given containers.
|
|
28
39
|
*
|
|
29
40
|
* @export
|
|
30
|
-
* @param {HTMLDivElement[]} containers
|
|
31
|
-
* @return {
|
|
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
|
+
* ```
|
|
32
49
|
*/
|
|
33
50
|
export declare function getPageElementBound(containers: HTMLDivElement[]): ContainerBound[];
|
|
34
51
|
/**
|
|
35
|
-
*
|
|
52
|
+
* Calculates the bounding information for each contentlet inside a container.
|
|
36
53
|
*
|
|
37
54
|
* @export
|
|
38
|
-
* @param {DOMRect} containerRect
|
|
39
|
-
* @param {HTMLDivElement[]} contentlets
|
|
40
|
-
* @return {
|
|
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
|
+
* ```
|
|
41
65
|
*/
|
|
42
66
|
export declare function getContentletsBound(containerRect: DOMRect, contentlets: HTMLDivElement[]): ContentletBound[];
|
|
43
67
|
/**
|
|
44
68
|
* Get container data from VTLS.
|
|
45
69
|
*
|
|
46
70
|
* @export
|
|
47
|
-
* @param {HTMLElement} container
|
|
48
|
-
* @return {
|
|
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
|
+
* ```
|
|
49
79
|
*/
|
|
50
80
|
export declare function getContainerData(container: HTMLElement): {
|
|
51
81
|
acceptTypes: string;
|
|
@@ -57,8 +87,14 @@ export declare function getContainerData(container: HTMLElement): {
|
|
|
57
87
|
* Get the closest container data from the contentlet.
|
|
58
88
|
*
|
|
59
89
|
* @export
|
|
60
|
-
* @param {Element} element
|
|
61
|
-
* @return {
|
|
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
|
+
* ```
|
|
62
98
|
*/
|
|
63
99
|
export declare function getClosestContainerData(element: Element): {
|
|
64
100
|
acceptTypes: string;
|
|
@@ -70,14 +106,54 @@ export declare function getClosestContainerData(element: Element): {
|
|
|
70
106
|
* Find the closest contentlet element based on HTMLElement.
|
|
71
107
|
*
|
|
72
108
|
* @export
|
|
73
|
-
* @param {
|
|
74
|
-
* @return {
|
|
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);
|
|
75
115
|
*/
|
|
76
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
|
+
*/
|
|
77
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
|
+
*/
|
|
78
142
|
export declare function findVTLData(target: HTMLElement): {
|
|
79
143
|
inode: string | undefined;
|
|
80
144
|
name: string | undefined;
|
|
81
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
|
+
*/
|
|
82
158
|
export declare function scrollIsInBottom(): boolean;
|
|
83
159
|
export {};
|
|
@@ -17,7 +17,11 @@ export declare class Equals {
|
|
|
17
17
|
/**
|
|
18
18
|
* This method appends to the query a term that should be excluded in the search.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const equals = new Equals("+myField: myValue");
|
|
23
|
+
* equals.excludeField("myField2").equals("myValue2"); // Current query: "+myField: myValue -myField2: myValue2"
|
|
24
|
+
* ```
|
|
21
25
|
*
|
|
22
26
|
* @param {string} field - The field that should be excluded in the search.
|
|
23
27
|
* @return {*} {Field} - An instance of a Lucene Field. A field is a key used to search for a specific value in a document.
|
|
@@ -27,8 +31,11 @@ export declare class Equals {
|
|
|
27
31
|
/**
|
|
28
32
|
* This method appends to the query a field that should be included in the search.
|
|
29
33
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
34
|
+
* @example
|
|
35
|
+
* ```ts
|
|
36
|
+
* const equals = new Equals("+myField: myValue");
|
|
37
|
+
* equals.field("myField2").equals("myValue2"); // Current query: "+myField: myValue +myField2: myValue2"
|
|
38
|
+
*```
|
|
32
39
|
* @param {string} field - The field that should be included in the search.
|
|
33
40
|
* @return {*} {Field} - An instance of a Lucene Field. A field is a key used to search for a specific value in a document.
|
|
34
41
|
* @memberof Equal
|
|
@@ -37,7 +44,12 @@ export declare class Equals {
|
|
|
37
44
|
/**
|
|
38
45
|
* This method appends to the query an operand to use logic operators in the query.
|
|
39
46
|
*
|
|
40
|
-
*
|
|
47
|
+
* @example
|
|
48
|
+
* @example
|
|
49
|
+
* ```ts
|
|
50
|
+
* const equals = new Equals("+myField: myValue");
|
|
51
|
+
* equals.or().field("myField2").equals("myValue2"); // Current query: "+myField: myValue OR +myField2: myValue2"
|
|
52
|
+
* ```
|
|
41
53
|
*
|
|
42
54
|
* @return {*} {Operand} - An instance of a Lucene Operand. An operand is a logical operator used to combine terms or phrases in a query.
|
|
43
55
|
* @memberof Equal
|
|
@@ -46,7 +58,11 @@ export declare class Equals {
|
|
|
46
58
|
/**
|
|
47
59
|
* This method appends to the query an operand to use logic operators in the query.
|
|
48
60
|
*
|
|
49
|
-
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const equals = new Equals("+myField: myValue");
|
|
64
|
+
* equals.and().field("myField2").equals("myValue2"); // Current query: "+myField: myValue AND +myField2: myValue2"
|
|
65
|
+
* ```
|
|
50
66
|
*
|
|
51
67
|
* @return {*} {Operand} - An instance of a Lucene Operand. An operand is a logical operator used to combine terms or phrases in a query.
|
|
52
68
|
* @memberof Equal
|
|
@@ -55,7 +71,11 @@ export declare class Equals {
|
|
|
55
71
|
/**
|
|
56
72
|
* This method appends to the query an operand to use logic operators in the query.
|
|
57
73
|
*
|
|
58
|
-
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```ts
|
|
76
|
+
* const equals = new Equals("+myField: myValue");
|
|
77
|
+
* equals.not().field("myField").equals("myValue2"); // Current query: "+myField: myValue NOT +myField: myValue2"
|
|
78
|
+
* ```
|
|
59
79
|
*
|
|
60
80
|
* @return {*} {NotOperand} - An instance of a Lucene Not Operand. A not operand is a logical operator used to exclude terms or phrases in a query.
|
|
61
81
|
* @memberof Equal
|
|
@@ -66,7 +86,12 @@ export declare class Equals {
|
|
|
66
86
|
* This raw query should end in a Lucene Equal.
|
|
67
87
|
* This method is useful when you want to append a complex query or an already written query to the query builder.
|
|
68
88
|
*
|
|
69
|
-
*
|
|
89
|
+
* @example
|
|
90
|
+
* ```ts
|
|
91
|
+
* // This builds the follow raw query "+myField: value AND (someOtherValue OR anotherValue)"
|
|
92
|
+
* const equals = new Equals("+myField: value");
|
|
93
|
+
* equals.raw("+myField2: value2"); // Current query: "+myField: value +myField2: anotherValue"
|
|
94
|
+
* ```
|
|
70
95
|
*
|
|
71
96
|
* @param {string} query - A raw query string.
|
|
72
97
|
* @return {*} {Equal} - An instance of a Lucene Equal. A term is a value used to search for a specific value in a document.
|
|
@@ -76,6 +101,12 @@ export declare class Equals {
|
|
|
76
101
|
/**
|
|
77
102
|
* This method returns the final query string.
|
|
78
103
|
*
|
|
104
|
+
* @example
|
|
105
|
+
* ```ts
|
|
106
|
+
* const equals = new Equals("+myField: myValue");
|
|
107
|
+
* equals.field("myField2").equals("myValue2").build(); // Returns "+myField: myValue +myField2: myValue2"
|
|
108
|
+
* ```
|
|
109
|
+
*
|
|
79
110
|
* @return {*} {string} - The final query string.
|
|
80
111
|
* @memberof Equal
|
|
81
112
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Equals } from './Equals';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* The `Field` class is used to build a query with a specific field.
|
|
4
4
|
* A Lucene Field is a key used to search for a specific value in a document.
|
|
5
5
|
*
|
|
6
6
|
* @export
|
|
@@ -9,14 +9,23 @@ import { Equals } from './Equals';
|
|
|
9
9
|
export declare class Field {
|
|
10
10
|
#private;
|
|
11
11
|
private query;
|
|
12
|
+
/**
|
|
13
|
+
* Creates an instance of the `Field` class.
|
|
14
|
+
*
|
|
15
|
+
* @param {string} query - The initial query string.
|
|
16
|
+
*/
|
|
12
17
|
constructor(query: string);
|
|
13
18
|
/**
|
|
14
|
-
*
|
|
19
|
+
* Appends a term to the query that should be included in the search.
|
|
15
20
|
*
|
|
16
|
-
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const field = new Field("+myField");
|
|
24
|
+
* field.equals("myValue");
|
|
25
|
+
* ```
|
|
17
26
|
*
|
|
18
27
|
* @param {string} term - The term that should be included in the search.
|
|
19
|
-
* @return {
|
|
28
|
+
* @return {Equals} - An instance of `Equals`.
|
|
20
29
|
* @memberof Field
|
|
21
30
|
*/
|
|
22
31
|
equals(term: string): Equals;
|
|
@@ -12,7 +12,11 @@ export declare class NotOperand {
|
|
|
12
12
|
/**
|
|
13
13
|
* This method appends to the query a term that should be included in the search.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const notOperand = new NotOperand("+myField");
|
|
18
|
+
* notOperand.equals("myValue");
|
|
19
|
+
* ```
|
|
16
20
|
*
|
|
17
21
|
* @param {string} term - The term that should be included in the search.
|
|
18
22
|
* @return {*} {Equals} - An instance of Equals.
|