@dotcms/client 0.0.1-alpha.34 → 0.0.1-alpha.36
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 +106 -32
- package/index.cjs.js +10 -9
- package/index.esm.js +10 -9
- package/package.json +1 -1
- package/src/lib/utils/page/common-utils.d.ts +2 -1
package/README.md
CHANGED
|
@@ -1,48 +1,122 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @dotcms/client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
`@dotcms/client` is the official dotCMS JavaScript library designed to simplify interactions with the DotCMS REST APIs.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
This client library provides a streamlined, promise-based interface to fetch pages and navigation API.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
| -------------------------------------------------------------------------------------------------- | ---- | ---------------------------- | ---------- | ----------------------------------------------------------- |
|
|
9
|
-
| [dotcms-ui](https://github.com/dotCMS/core-web/tree/master/apps/dotcms-ui) | app | `apps/dotcms-ui` | Angular | Main UI application |
|
|
10
|
-
| [dotcdn](https://github.com/dotCMS/core-web/tree/master/apps/dotcdn) | app | `apps/dotcdn` | Angular | App for the dotCDN plugin |
|
|
11
|
-
| [dotcms-block-editor](https://github.com/dotCMS/core-web/tree/master/apps/dotcms-block-editor) | app | `apps/dotcms-block-editor` | Angular | App to build de block-editor as a Web Component |
|
|
12
|
-
| [dotcms](https://github.com/dotCMS/core-web/tree/master/libs/dotcms) | lib | `libs/dotcms` | Typescript | JavaScript SDK for DotCMS API's |
|
|
13
|
-
| [dot-layout-grid](https://github.com/dotCMS/core-web/tree/master/libs/dot-layout-grid) | lib | `libs/dot-layout-grid` | Angular | Components for layout editor |
|
|
14
|
-
| [block-editor](https://github.com/dotCMS/core-web/tree/master/libs/block-editor) | lib | `libs/block-editor` | TitTap | Block editor components |
|
|
15
|
-
| [dot-rules](https://github.com/dotCMS/core-web/tree/master/libs/dot-rules) | lib | `libs/dot-rules` | Angular | Components and services for rules |
|
|
16
|
-
| [dotcms-field-elements](https://github.com/dotCMS/core-web/tree/master/libs/dotcms-field-elements) | lib | `libs/dotcms-field-elements` | Stenciljs | Web components for form builder (deprecated) |
|
|
17
|
-
| [dotcms-js](https://github.com/dotCMS/core-web/tree/master/libs/dotcms-js) | lib | `libs/dotcms-js` | Angular | Angular @injectables for DotCMS API |
|
|
18
|
-
| [dotcms-models](https://github.com/dotCMS/core-web/tree/master/libs/dotcms-models) | lib | `libs/dotcms-models` | Typescript | DotCMS interfaces and types |
|
|
19
|
-
| [dotcms-scss](https://github.com/dotCMS/core-web/tree/master/libs/dotcms-scss) | lib | `libs/dotcms-scss` | SCSS | SCSS shared files for theme Angular PrimeNG and Dijit Theme |
|
|
7
|
+
## Features
|
|
20
8
|
|
|
21
|
-
|
|
9
|
+
- Easy-to-use methods to interact with the [DotCMS Page](https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas) and [Navigation APIs](https://www.dotcms.com/docs/latest/navigation-rest-api).
|
|
10
|
+
- Support for custom actions to communicate with the DotCMS page editor.
|
|
11
|
+
- Comprehensive TypeScript typings for better development experience.
|
|
22
12
|
|
|
23
|
-
|
|
13
|
+
## Installation
|
|
24
14
|
|
|
25
|
-
|
|
15
|
+
Install the package via npm:
|
|
26
16
|
|
|
27
|
-
|
|
17
|
+
```bash
|
|
18
|
+
npm install @dotcms/client
|
|
19
|
+
```
|
|
28
20
|
|
|
29
|
-
|
|
21
|
+
Or using Yarn:
|
|
30
22
|
|
|
31
|
-
|
|
23
|
+
```bash
|
|
24
|
+
yarn add @dotcms/client
|
|
25
|
+
```
|
|
32
26
|
|
|
33
|
-
|
|
27
|
+
## Usage
|
|
34
28
|
|
|
35
|
-
|
|
36
|
-
- **dotcms-ui**: Run `nx build dotcms-ui`.
|
|
37
|
-
- **dotcms-block-editor**: Run `nx build dotcms-block-editor`.
|
|
38
|
-
- **dotcms-binary-field-builder**: Run `nx build dotcms-binary-field-builder`.
|
|
29
|
+
`@dotcms/client` supports both ES modules and CommonJS. You can import it using either syntax:
|
|
39
30
|
|
|
40
|
-
###
|
|
31
|
+
### ES Modules
|
|
41
32
|
|
|
42
|
-
|
|
33
|
+
```javascript
|
|
34
|
+
import { dotcmsClient } from '@dotcms/client';
|
|
35
|
+
```
|
|
43
36
|
|
|
44
|
-
|
|
37
|
+
### CommonJS
|
|
45
38
|
|
|
46
|
-
|
|
39
|
+
```javascript
|
|
40
|
+
const { dotcmsClient } = require('@dotcms/client');
|
|
41
|
+
```
|
|
47
42
|
|
|
48
|
-
|
|
43
|
+
First, initialize the client with your DotCMS instance details.
|
|
44
|
+
|
|
45
|
+
```javascript
|
|
46
|
+
const client = dotcmsClient.init({
|
|
47
|
+
dotcmsUrl: 'https://your-dotcms-instance.com',
|
|
48
|
+
authToken: 'your-auth-token',
|
|
49
|
+
siteId: 'your-site-id'
|
|
50
|
+
});
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Fetching a Page
|
|
54
|
+
|
|
55
|
+
Retrieve the elements of any page in your DotCMS system in JSON format.
|
|
56
|
+
|
|
57
|
+
```javascript
|
|
58
|
+
const pageData = await client.page.get({
|
|
59
|
+
path: '/your-page-path',
|
|
60
|
+
language_id: 1,
|
|
61
|
+
personaId: 'optional-persona-id'
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
console.log(pageData);
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Fetching Navigation
|
|
68
|
+
|
|
69
|
+
Retrieve information about the DotCMS file and folder tree.
|
|
70
|
+
|
|
71
|
+
```javascript
|
|
72
|
+
const navData = await client.nav.get({
|
|
73
|
+
path: '/',
|
|
74
|
+
depth: 2,
|
|
75
|
+
languageId: 1
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
console.log(navData);
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## API Reference
|
|
82
|
+
|
|
83
|
+
Detailed documentation of the `@dotcms/client` methods, parameters, and types can be found below:
|
|
84
|
+
|
|
85
|
+
### `dotcmsClient.init(config: ClientConfig): DotCmsClient`
|
|
86
|
+
|
|
87
|
+
Initializes the DotCMS client with the specified configuration.
|
|
88
|
+
|
|
89
|
+
### `DotCmsClient.page.get(options: PageApiOptions): Promise<unknown>`
|
|
90
|
+
|
|
91
|
+
Retrieves the specified page's elements from your DotCMS system in JSON format.
|
|
92
|
+
|
|
93
|
+
### `DotCmsClient.nav.get(options: NavApiOptions): Promise<unknown>`
|
|
94
|
+
|
|
95
|
+
Retrieves information about the DotCMS file and folder tree.
|
|
96
|
+
|
|
97
|
+
## Contributing
|
|
98
|
+
|
|
99
|
+
GitHub pull requests are the preferred method to contribute code to dotCMS. Before any pull requests can be accepted, an automated tool will ask you to agree to the [dotCMS Contributor's Agreement](https://gist.github.com/wezell/85ef45298c48494b90d92755b583acb3).
|
|
100
|
+
|
|
101
|
+
## Licensing
|
|
102
|
+
|
|
103
|
+
dotCMS comes in multiple editions and as such is dual licensed. The dotCMS Community Edition is licensed under the GPL 3.0 and is freely available for download, customization and deployment for use within organizations of all stripes. dotCMS Enterprise Editions (EE) adds a number of enterprise features and is available via a supported, indemnified commercial license from dotCMS. For the differences between the editions, see [the feature page](http://dotcms.com/cms-platform/features).
|
|
104
|
+
|
|
105
|
+
## Support
|
|
106
|
+
|
|
107
|
+
If you need help or have any questions, please [open an issue](https://github.com/dotCMS/core/issues/new/choose) in the GitHub repository.
|
|
108
|
+
|
|
109
|
+
## Documentation
|
|
110
|
+
|
|
111
|
+
Always refer to the official [DotCMS documentation](https://www.dotcms.com/docs/latest/) for comprehensive guides and API references.
|
|
112
|
+
|
|
113
|
+
## Getting Help
|
|
114
|
+
|
|
115
|
+
| Source | Location |
|
|
116
|
+
| --------------- | ------------------------------------------------------------------- |
|
|
117
|
+
| Installation | [Installation](https://dotcms.com/docs/latest/installation) |
|
|
118
|
+
| Documentation | [Documentation](https://dotcms.com/docs/latest/table-of-contents) |
|
|
119
|
+
| Videos | [Helpful Videos](http://dotcms.com/videos/) |
|
|
120
|
+
| Forums/Listserv | [via Google Groups](https://groups.google.com/forum/#!forum/dotCMS) |
|
|
121
|
+
| Twitter | @dotCMS |
|
|
122
|
+
| Main Site | [dotCMS.com](https://dotcms.com/) |
|
package/index.cjs.js
CHANGED
|
@@ -1459,19 +1459,20 @@ const parseContentletsToUuidMap = (containerContentlets) => {
|
|
|
1459
1459
|
};
|
|
1460
1460
|
|
|
1461
1461
|
const getPageRequestParams = ({ path = '', params = {} }) => {
|
|
1462
|
+
const copiedParams = params instanceof URLSearchParams ? Object.fromEntries(params.entries()) : { ...params };
|
|
1462
1463
|
const finalParams = {};
|
|
1463
|
-
const dotMarketingPersonaId =
|
|
1464
|
-
if (
|
|
1465
|
-
finalParams['mode'] =
|
|
1464
|
+
const dotMarketingPersonaId = copiedParams['com.dotmarketing.persona.id'] || '';
|
|
1465
|
+
if (copiedParams['mode']) {
|
|
1466
|
+
finalParams['mode'] = copiedParams['mode'];
|
|
1466
1467
|
}
|
|
1467
|
-
if (
|
|
1468
|
-
finalParams['language_id'] =
|
|
1468
|
+
if (copiedParams['language_id']) {
|
|
1469
|
+
finalParams['language_id'] = copiedParams['language_id'];
|
|
1469
1470
|
}
|
|
1470
|
-
if (
|
|
1471
|
-
finalParams['variantName'] =
|
|
1471
|
+
if (copiedParams['variantName']) {
|
|
1472
|
+
finalParams['variantName'] = copiedParams['variantName'];
|
|
1472
1473
|
}
|
|
1473
|
-
if (
|
|
1474
|
-
finalParams['personaId'] =
|
|
1474
|
+
if (copiedParams['personaId'] || dotMarketingPersonaId) {
|
|
1475
|
+
finalParams['personaId'] = copiedParams['personaId'] || dotMarketingPersonaId;
|
|
1475
1476
|
}
|
|
1476
1477
|
return {
|
|
1477
1478
|
path,
|
package/index.esm.js
CHANGED
|
@@ -1457,19 +1457,20 @@ const parseContentletsToUuidMap = (containerContentlets) => {
|
|
|
1457
1457
|
};
|
|
1458
1458
|
|
|
1459
1459
|
const getPageRequestParams = ({ path = '', params = {} }) => {
|
|
1460
|
+
const copiedParams = params instanceof URLSearchParams ? Object.fromEntries(params.entries()) : { ...params };
|
|
1460
1461
|
const finalParams = {};
|
|
1461
|
-
const dotMarketingPersonaId =
|
|
1462
|
-
if (
|
|
1463
|
-
finalParams['mode'] =
|
|
1462
|
+
const dotMarketingPersonaId = copiedParams['com.dotmarketing.persona.id'] || '';
|
|
1463
|
+
if (copiedParams['mode']) {
|
|
1464
|
+
finalParams['mode'] = copiedParams['mode'];
|
|
1464
1465
|
}
|
|
1465
|
-
if (
|
|
1466
|
-
finalParams['language_id'] =
|
|
1466
|
+
if (copiedParams['language_id']) {
|
|
1467
|
+
finalParams['language_id'] = copiedParams['language_id'];
|
|
1467
1468
|
}
|
|
1468
|
-
if (
|
|
1469
|
-
finalParams['variantName'] =
|
|
1469
|
+
if (copiedParams['variantName']) {
|
|
1470
|
+
finalParams['variantName'] = copiedParams['variantName'];
|
|
1470
1471
|
}
|
|
1471
|
-
if (
|
|
1472
|
-
finalParams['personaId'] =
|
|
1472
|
+
if (copiedParams['personaId'] || dotMarketingPersonaId) {
|
|
1473
|
+
finalParams['personaId'] = copiedParams['personaId'] || dotMarketingPersonaId;
|
|
1473
1474
|
}
|
|
1474
1475
|
return {
|
|
1475
1476
|
path,
|
package/package.json
CHANGED
|
@@ -2,9 +2,10 @@ interface PageRequestParamsProps {
|
|
|
2
2
|
path: string;
|
|
3
3
|
params: {
|
|
4
4
|
[key: string]: any;
|
|
5
|
-
} | undefined;
|
|
5
|
+
} | undefined | URLSearchParams;
|
|
6
6
|
}
|
|
7
7
|
export declare const getPageRequestParams: ({ path, params }: PageRequestParamsProps) => {
|
|
8
8
|
path: string;
|
|
9
|
+
[key: string]: string | number;
|
|
9
10
|
};
|
|
10
11
|
export {};
|