@dotcms/client 0.0.1-alpha.52 → 0.0.1-alpha.53
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 +21 -18
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dotCMS API Client - `@dotcms/client`
|
|
2
2
|
|
|
3
|
-
The `@dotcms/client` is a JavaScript/TypeScript library for interacting with a
|
|
3
|
+
The `@dotcms/client` is a JavaScript/TypeScript library for interacting with a dotCMS instance. It allows you to easily fetch pages, content, and navigation information in JSON format, as well as to make complex queries on content collections.
|
|
4
4
|
|
|
5
5
|
This client library provides a streamlined, promise-based interface to fetch pages and navigation API.
|
|
6
6
|
|
|
7
7
|
## Features
|
|
8
8
|
|
|
9
|
-
- Easy-to-use methods to interact with
|
|
10
|
-
- Support for custom actions to communicate with the
|
|
9
|
+
- Easy-to-use methods to interact with [dotCMS pages](https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas) and the [Navigation API](https://www.dotcms.com/docs/latest/navigation-rest-api).
|
|
10
|
+
- Support for custom actions to communicate with the dotCMS page editor.
|
|
11
11
|
- Comprehensive TypeScript typings for better development experience.
|
|
12
12
|
|
|
13
|
-
#
|
|
13
|
+
# dotCMS API Client
|
|
14
14
|
|
|
15
15
|
## Installation
|
|
16
16
|
|
|
@@ -42,7 +42,9 @@ import { DotCmsClient } from '@dotcms/client';
|
|
|
42
42
|
const { DotCmsClient } = require('@dotcms/client');
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
### Initialization
|
|
46
|
+
|
|
47
|
+
First, initialize the client with your dotCMS instance details.
|
|
46
48
|
|
|
47
49
|
```javascript
|
|
48
50
|
const client = DotCmsClient.init({
|
|
@@ -54,7 +56,7 @@ const client = DotCmsClient.init({
|
|
|
54
56
|
|
|
55
57
|
### Fetching a Page
|
|
56
58
|
|
|
57
|
-
You can retrieve the elements of any page in your
|
|
59
|
+
You can retrieve the elements of any page in your dotCMS system in JSON format using the `client.page.get()` method.
|
|
58
60
|
|
|
59
61
|
```javascript
|
|
60
62
|
const pageData = await client.page.get({
|
|
@@ -66,7 +68,7 @@ const pageData = await client.page.get({
|
|
|
66
68
|
|
|
67
69
|
### Fetching Navigation
|
|
68
70
|
|
|
69
|
-
Retrieve the
|
|
71
|
+
Retrieve the dotCMS file and folder tree to get information about the navigation structure.
|
|
70
72
|
|
|
71
73
|
```javascript
|
|
72
74
|
const navData = await client.nav.get({
|
|
@@ -78,7 +80,7 @@ const navData = await client.nav.get({
|
|
|
78
80
|
|
|
79
81
|
### Fetching a Collection of Content
|
|
80
82
|
|
|
81
|
-
The `getCollection` method allows you to fetch a collection of content items using a builder pattern for complex queries.
|
|
83
|
+
The `getCollection` method allows you to fetch a collection of content items (sometimes called "contentlets") using a builder pattern for complex queries.
|
|
82
84
|
|
|
83
85
|
#### Basic Usage
|
|
84
86
|
|
|
@@ -125,7 +127,7 @@ const languageFilteredResponse = await client.content
|
|
|
125
127
|
|
|
126
128
|
#### Using Complex Queries
|
|
127
129
|
|
|
128
|
-
You can build more complex queries using the query builder. For example, filter by author and `title`:
|
|
130
|
+
You can build more complex queries using the query builder. For example, filter by `author` and `title`:
|
|
129
131
|
|
|
130
132
|
```typescript
|
|
131
133
|
const complexQueryResponse = await client.content
|
|
@@ -206,26 +208,27 @@ Detailed documentation of the `@dotcms/client` methods, parameters, and types ca
|
|
|
206
208
|
|
|
207
209
|
### `DotCmsClient.init(config: ClientConfig): DotCmsClient`
|
|
208
210
|
|
|
209
|
-
Initializes the
|
|
211
|
+
Initializes the dotCMS client with the specified configuration.
|
|
210
212
|
|
|
211
213
|
### `DotCmsClient.page.get(options: PageApiOptions): Promise<unknown>`
|
|
212
214
|
|
|
213
|
-
Retrieves the specified page's elements from your
|
|
215
|
+
Retrieves the specified page's elements from your dotCMS system in JSON format.
|
|
214
216
|
|
|
215
217
|
### `DotCmsClient.nav.get(options: NavApiOptions): Promise<unknown>`
|
|
216
218
|
|
|
217
|
-
Retrieves information about the
|
|
219
|
+
Retrieves information about the dotCMS file and folder tree.
|
|
218
220
|
|
|
219
221
|
### `DotCmsClient.content.getCollection(contentType: string): CollectionBuilder<T>`
|
|
220
|
-
|
|
222
|
+
|
|
223
|
+
Creates a builder to filter and fetches a collection of content items for a specific content type.
|
|
221
224
|
|
|
222
225
|
#### Parameters
|
|
223
226
|
|
|
224
|
-
contentType (string): The content type to retrieve.
|
|
227
|
+
`contentType` (string): The content type to retrieve.
|
|
225
228
|
|
|
226
229
|
#### Returns
|
|
227
230
|
|
|
228
|
-
CollectionBuilder<T
|
|
231
|
+
`CollectionBuilder<T>`: A builder instance for chaining filters and executing the query.
|
|
229
232
|
|
|
230
233
|
## Contributing
|
|
231
234
|
|
|
@@ -241,7 +244,7 @@ If you need help or have any questions, please [open an issue](https://github.co
|
|
|
241
244
|
|
|
242
245
|
## Documentation
|
|
243
246
|
|
|
244
|
-
Always refer to the official [
|
|
247
|
+
Always refer to the official [dotCMS documentation](https://www.dotcms.com/docs/latest/) for comprehensive guides and API references.
|
|
245
248
|
|
|
246
249
|
## Getting Help
|
|
247
250
|
|
|
@@ -252,4 +255,4 @@ Always refer to the official [DotCMS documentation](https://www.dotcms.com/docs/
|
|
|
252
255
|
| Videos | [Helpful Videos](http://dotcms.com/videos/) |
|
|
253
256
|
| Forums/Listserv | [via Google Groups](https://groups.google.com/forum/#!forum/dotCMS) |
|
|
254
257
|
| Twitter | @dotCMS |
|
|
255
|
-
| Main Site | [dotCMS.com](https://dotcms.com/) |
|
|
258
|
+
| Main Site | [dotCMS.com](https://dotcms.com/) |
|