@dotcms/client 0.0.1-alpha.31 → 0.0.1-alpha.32
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/index.cjs.d.ts +1 -0
- package/index.cjs.default.js +1 -0
- package/index.cjs.js +1480 -0
- package/index.cjs.mjs +2 -0
- package/index.esm.d.ts +1 -0
- package/index.esm.js +1471 -0
- package/package.json +13 -5
- package/src/index.d.ts +6 -6
- package/README.md +0 -110
- package/src/index.js +0 -7
- package/src/index.js.map +0 -1
- package/src/lib/client/content/builders/collection/collection.js +0 -264
- package/src/lib/client/content/builders/collection/collection.js.map +0 -1
- package/src/lib/client/content/content-api.js +0 -87
- package/src/lib/client/content/content-api.js.map +0 -1
- package/src/lib/client/content/shared/const.js +0 -5
- package/src/lib/client/content/shared/const.js.map +0 -1
- package/src/lib/client/content/shared/types.js +0 -2
- package/src/lib/client/content/shared/types.js.map +0 -1
- package/src/lib/client/content/shared/utils.js +0 -20
- package/src/lib/client/content/shared/utils.js.map +0 -1
- package/src/lib/client/models/index.js +0 -9
- package/src/lib/client/models/index.js.map +0 -1
- package/src/lib/client/models/types.js +0 -2
- package/src/lib/client/models/types.js.map +0 -1
- package/src/lib/client/sdk-js-client.js +0 -194
- package/src/lib/client/sdk-js-client.js.map +0 -1
- package/src/lib/editor/listeners/listeners.js +0 -180
- package/src/lib/editor/listeners/listeners.js.map +0 -1
- package/src/lib/editor/models/client.model.js +0 -73
- package/src/lib/editor/models/client.model.js.map +0 -1
- package/src/lib/editor/models/editor.model.js +0 -2
- package/src/lib/editor/models/editor.model.js.map +0 -1
- package/src/lib/editor/models/listeners.model.js +0 -26
- package/src/lib/editor/models/listeners.model.js.map +0 -1
- package/src/lib/editor/sdk-editor-vtl.js +0 -20
- package/src/lib/editor/sdk-editor-vtl.js.map +0 -1
- package/src/lib/editor/sdk-editor.js +0 -65
- package/src/lib/editor/sdk-editor.js.map +0 -1
- package/src/lib/editor/utils/editor.utils.js +0 -134
- package/src/lib/editor/utils/editor.utils.js.map +0 -1
- package/src/lib/query-builder/lucene-syntax/Equals.js +0 -101
- package/src/lib/query-builder/lucene-syntax/Equals.js.map +0 -1
- package/src/lib/query-builder/lucene-syntax/Field.js +0 -31
- package/src/lib/query-builder/lucene-syntax/Field.js.map +0 -1
- package/src/lib/query-builder/lucene-syntax/NotOperand.js +0 -30
- package/src/lib/query-builder/lucene-syntax/NotOperand.js.map +0 -1
- package/src/lib/query-builder/lucene-syntax/Operand.js +0 -55
- package/src/lib/query-builder/lucene-syntax/Operand.js.map +0 -1
- package/src/lib/query-builder/lucene-syntax/index.js +0 -5
- package/src/lib/query-builder/lucene-syntax/index.js.map +0 -1
- package/src/lib/query-builder/sdk-query-builder.js +0 -54
- package/src/lib/query-builder/sdk-query-builder.js.map +0 -1
- package/src/lib/query-builder/utils/index.js +0 -115
- package/src/lib/query-builder/utils/index.js.map +0 -1
- package/src/lib/utils/graphql/transforms.js +0 -52
- package/src/lib/utils/graphql/transforms.js.map +0 -1
- package/src/lib/utils/index.js +0 -3
- package/src/lib/utils/index.js.map +0 -1
- package/src/lib/utils/page/common-utils.js +0 -12
- package/src/lib/utils/page/common-utils.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dotcms/client",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
4
|
-
"type": "module",
|
|
3
|
+
"version": "0.0.1-alpha.32",
|
|
5
4
|
"description": "Official JavaScript library for interacting with DotCMS REST APIs.",
|
|
6
5
|
"repository": {
|
|
7
6
|
"type": "git",
|
|
@@ -23,7 +22,16 @@
|
|
|
23
22
|
"url": "https://github.com/dotCMS/core/issues"
|
|
24
23
|
},
|
|
25
24
|
"homepage": "https://github.com/dotCMS/core/tree/master/core-web/libs/sdk/client/README.md",
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
"exports": {
|
|
26
|
+
"./package.json": "./package.json",
|
|
27
|
+
".": {
|
|
28
|
+
"module": "./index.esm.js",
|
|
29
|
+
"types": "./index.esm.d.ts",
|
|
30
|
+
"import": "./index.cjs.mjs",
|
|
31
|
+
"default": "./index.cjs.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"module": "./index.esm.js",
|
|
35
|
+
"main": "./index.cjs.js",
|
|
36
|
+
"types": "./index.esm.d.ts"
|
|
29
37
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export
|
|
1
|
+
import { ClientConfig, DotCmsClient } from './lib/client/sdk-js-client';
|
|
2
|
+
import { CUSTOMER_ACTIONS, postMessageToEditor } from './lib/editor/models/client.model';
|
|
3
|
+
import { CustomClientParams, DotCMSPageEditorConfig, EditorConfig } from './lib/editor/models/editor.model';
|
|
4
|
+
import { destroyEditor, initEditor, isInsideEditor, updateNavigation } from './lib/editor/sdk-editor';
|
|
5
|
+
import { getPageRequestParams, graphqlToPageEntity } from './lib/utils';
|
|
6
|
+
export { graphqlToPageEntity, getPageRequestParams, isInsideEditor, DotCmsClient, DotCMSPageEditorConfig, CUSTOMER_ACTIONS, CustomClientParams, postMessageToEditor, EditorConfig, initEditor, updateNavigation, destroyEditor, ClientConfig };
|
package/README.md
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
# @dotcms/client
|
|
2
|
-
|
|
3
|
-
`@dotcms/client` is the official dotCMS JavaScript library designed to simplify interactions with the DotCMS REST APIs.
|
|
4
|
-
|
|
5
|
-
This client library provides a streamlined, promise-based interface to fetch pages and navigation API.
|
|
6
|
-
|
|
7
|
-
## Features
|
|
8
|
-
|
|
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.
|
|
12
|
-
|
|
13
|
-
## Installation
|
|
14
|
-
|
|
15
|
-
Install the package via npm:
|
|
16
|
-
|
|
17
|
-
```bash
|
|
18
|
-
npm install @dotcms/client
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Or using Yarn:
|
|
22
|
-
|
|
23
|
-
```bash
|
|
24
|
-
yarn add @dotcms/client
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
## Usage
|
|
28
|
-
|
|
29
|
-
First, initialize the client with your DotCMS instance details.
|
|
30
|
-
|
|
31
|
-
```javascript
|
|
32
|
-
import { dotcmsClient } from '@dotcms/client';
|
|
33
|
-
|
|
34
|
-
const client = dotcmsClient.init({
|
|
35
|
-
dotcmsUrl: 'https://your-dotcms-instance.com',
|
|
36
|
-
authToken: 'your-auth-token',
|
|
37
|
-
siteId: 'your-site-id'
|
|
38
|
-
});
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
### Fetching a Page
|
|
42
|
-
|
|
43
|
-
Retrieve the elements of any page in your DotCMS system in JSON format.
|
|
44
|
-
|
|
45
|
-
```javascript
|
|
46
|
-
const pageData = await client.page.get({
|
|
47
|
-
path: '/your-page-path',
|
|
48
|
-
language_id: 1,
|
|
49
|
-
personaId: 'optional-persona-id'
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
console.log(pageData);
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
### Fetching Navigation
|
|
56
|
-
|
|
57
|
-
Retrieve information about the DotCMS file and folder tree.
|
|
58
|
-
|
|
59
|
-
```javascript
|
|
60
|
-
const navData = await client.nav.get({
|
|
61
|
-
path: '/',
|
|
62
|
-
depth: 2,
|
|
63
|
-
languageId: 1
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
console.log(navData);
|
|
67
|
-
```
|
|
68
|
-
|
|
69
|
-
## API Reference
|
|
70
|
-
|
|
71
|
-
Detailed documentation of the `@dotcms/client` methods, parameters, and types can be found below:
|
|
72
|
-
|
|
73
|
-
### `dotcmsClient.init(config: ClientConfig): DotCmsClient`
|
|
74
|
-
|
|
75
|
-
Initializes the DotCMS client with the specified configuration.
|
|
76
|
-
|
|
77
|
-
### `DotCmsClient.page.get(options: PageApiOptions): Promise<unknown>`
|
|
78
|
-
|
|
79
|
-
Retrieves the specified page's elements from your DotCMS system in JSON format.
|
|
80
|
-
|
|
81
|
-
### `DotCmsClient.nav.get(options: NavApiOptions): Promise<unknown>`
|
|
82
|
-
|
|
83
|
-
Retrieves information about the DotCMS file and folder tree.
|
|
84
|
-
|
|
85
|
-
## Contributing
|
|
86
|
-
|
|
87
|
-
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).
|
|
88
|
-
|
|
89
|
-
## Licensing
|
|
90
|
-
|
|
91
|
-
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).
|
|
92
|
-
|
|
93
|
-
## Support
|
|
94
|
-
|
|
95
|
-
If you need help or have any questions, please [open an issue](https://github.com/dotCMS/core/issues/new/choose) in the GitHub repository.
|
|
96
|
-
|
|
97
|
-
## Documentation
|
|
98
|
-
|
|
99
|
-
Always refer to the official [DotCMS documentation](https://www.dotcms.com/docs/latest/) for comprehensive guides and API references.
|
|
100
|
-
|
|
101
|
-
## Getting Help
|
|
102
|
-
|
|
103
|
-
| Source | Location |
|
|
104
|
-
| --------------- | ------------------------------------------------------------------- |
|
|
105
|
-
| Installation | [Installation](https://dotcms.com/docs/latest/installation) |
|
|
106
|
-
| Documentation | [Documentation](https://dotcms.com/docs/latest/table-of-contents) |
|
|
107
|
-
| Videos | [Helpful Videos](http://dotcms.com/videos/) |
|
|
108
|
-
| Forums/Listserv | [via Google Groups](https://groups.google.com/forum/#!forum/dotCMS) |
|
|
109
|
-
| Twitter | @dotCMS |
|
|
110
|
-
| Main Site | [dotCMS.com](https://dotcms.com/) |
|
package/src/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export * from './lib/client/sdk-js-client';
|
|
2
|
-
export * from './lib/editor/sdk-editor';
|
|
3
|
-
export * from './lib/editor/models/editor.model';
|
|
4
|
-
export * from './lib/editor/models/client.model';
|
|
5
|
-
export * from './lib/query-builder/sdk-query-builder';
|
|
6
|
-
export * from './lib/utils';
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/sdk/client/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AACjD,cAAc,uCAAuC,CAAC;AACtD,cAAc,aAAa,CAAC"}
|
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
var _CollectionBuilder_page, _CollectionBuilder_limit, _CollectionBuilder_depth, _CollectionBuilder_render, _CollectionBuilder_sortBy, _CollectionBuilder_contentType, _CollectionBuilder_defaultQuery, _CollectionBuilder_query, _CollectionBuilder_rawQuery, _CollectionBuilder_languageId, _CollectionBuilder_draft, _CollectionBuilder_serverUrl, _CollectionBuilder_requestOptions;
|
|
2
|
-
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
|
-
import { Equals } from '../../../../query-builder/lucene-syntax';
|
|
4
|
-
import { QueryBuilder } from '../../../../query-builder/sdk-query-builder';
|
|
5
|
-
import { CONTENT_API_URL } from '../../shared/const';
|
|
6
|
-
import { sanitizeQueryForContentType } from '../../shared/utils';
|
|
7
|
-
/**
|
|
8
|
-
* Creates a Builder to filter and fetch content from the content API for an specific content type
|
|
9
|
-
*
|
|
10
|
-
* @export
|
|
11
|
-
* @class CollectionBuilder
|
|
12
|
-
* @template T Represents the type of the content type to fetch. Defaults to unknown
|
|
13
|
-
*/
|
|
14
|
-
export class CollectionBuilder {
|
|
15
|
-
constructor(requestOptions, serverUrl, contentType) {
|
|
16
|
-
_CollectionBuilder_page.set(this, 1);
|
|
17
|
-
_CollectionBuilder_limit.set(this, 10);
|
|
18
|
-
_CollectionBuilder_depth.set(this, 0);
|
|
19
|
-
_CollectionBuilder_render.set(this, false);
|
|
20
|
-
_CollectionBuilder_sortBy.set(this, void 0);
|
|
21
|
-
_CollectionBuilder_contentType.set(this, void 0);
|
|
22
|
-
_CollectionBuilder_defaultQuery.set(this, void 0);
|
|
23
|
-
_CollectionBuilder_query.set(this, void 0);
|
|
24
|
-
_CollectionBuilder_rawQuery.set(this, void 0);
|
|
25
|
-
_CollectionBuilder_languageId.set(this, 1);
|
|
26
|
-
_CollectionBuilder_draft.set(this, false);
|
|
27
|
-
_CollectionBuilder_serverUrl.set(this, void 0);
|
|
28
|
-
_CollectionBuilder_requestOptions.set(this, void 0);
|
|
29
|
-
__classPrivateFieldSet(this, _CollectionBuilder_requestOptions, requestOptions, "f");
|
|
30
|
-
__classPrivateFieldSet(this, _CollectionBuilder_serverUrl, serverUrl, "f");
|
|
31
|
-
__classPrivateFieldSet(this, _CollectionBuilder_contentType, contentType, "f");
|
|
32
|
-
// We need to build the default query with the contentType field
|
|
33
|
-
__classPrivateFieldSet(this, _CollectionBuilder_defaultQuery, new QueryBuilder().field('contentType').equals(__classPrivateFieldGet(this, _CollectionBuilder_contentType, "f")), "f");
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* This method returns the sort query in this format: field order, field order, ...
|
|
37
|
-
*
|
|
38
|
-
* @readonly
|
|
39
|
-
* @private
|
|
40
|
-
* @memberof CollectionBuilder
|
|
41
|
-
*/
|
|
42
|
-
get sort() {
|
|
43
|
-
return __classPrivateFieldGet(this, _CollectionBuilder_sortBy, "f")?.map((sort) => `${sort.field} ${sort.order}`).join(',');
|
|
44
|
-
}
|
|
45
|
-
get offset() {
|
|
46
|
-
// This could end in an empty response
|
|
47
|
-
return __classPrivateFieldGet(this, _CollectionBuilder_limit, "f") * (__classPrivateFieldGet(this, _CollectionBuilder_page, "f") - 1);
|
|
48
|
-
}
|
|
49
|
-
get url() {
|
|
50
|
-
return `${__classPrivateFieldGet(this, _CollectionBuilder_serverUrl, "f")}${CONTENT_API_URL}`;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* This method returns the current query built
|
|
54
|
-
*
|
|
55
|
-
* @readonly
|
|
56
|
-
* @private
|
|
57
|
-
* @memberof CollectionBuilder
|
|
58
|
-
*/
|
|
59
|
-
get currentQuery() {
|
|
60
|
-
return __classPrivateFieldGet(this, _CollectionBuilder_query, "f") ?? __classPrivateFieldGet(this, _CollectionBuilder_defaultQuery, "f");
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Takes a language id and filters the content by that language.
|
|
64
|
-
*
|
|
65
|
-
* The language id defaults to 1
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* @param {number | string} languageId The language id to filter the content by
|
|
69
|
-
* @return {CollectionBuilder} CollectionBuilder - A CollectionBuilder instance
|
|
70
|
-
* @memberof CollectionBuilder
|
|
71
|
-
*/
|
|
72
|
-
language(languageId) {
|
|
73
|
-
__classPrivateFieldSet(this, _CollectionBuilder_languageId, languageId, "f");
|
|
74
|
-
return this;
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* The retrieved content will have the rendered HTML
|
|
78
|
-
*
|
|
79
|
-
* @return {CollectionBuilder} CollectionBuilder - A CollectionBuilder instance
|
|
80
|
-
* @memberof CollectionBuilder
|
|
81
|
-
*/
|
|
82
|
-
render() {
|
|
83
|
-
__classPrivateFieldSet(this, _CollectionBuilder_render, true, "f");
|
|
84
|
-
return this;
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Takes an array of constrains to sort the content by field an specific order
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* ```javascript
|
|
91
|
-
* // This will sort the content by title in ascending order
|
|
92
|
-
* // and by modDate in descending order
|
|
93
|
-
* const sortBy = [{ field: 'title', order: 'asc' }, { field: 'modDate', order: 'desc' }]
|
|
94
|
-
*
|
|
95
|
-
* client.content.getCollection("Blog").sortBy(sortBy)
|
|
96
|
-
*```
|
|
97
|
-
*
|
|
98
|
-
* @param {SortBy[]} sortBy Array of constrains to sort the content by
|
|
99
|
-
* @return {CollectionBuilder} CollectionBuilder - A CollectionBuilder instance
|
|
100
|
-
* @memberof CollectionBuilder
|
|
101
|
-
*/
|
|
102
|
-
sortBy(sortBy) {
|
|
103
|
-
__classPrivateFieldSet(this, _CollectionBuilder_sortBy, sortBy, "f");
|
|
104
|
-
return this;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Takes a number that represents the max amount of content to fetch
|
|
108
|
-
*
|
|
109
|
-
* `limit` is set to 10 by default
|
|
110
|
-
*
|
|
111
|
-
* @param {number} limit The max amount of content to fetch
|
|
112
|
-
* @return {CollectionBuilder} CollectionBuilder - A CollectionBuilder instance
|
|
113
|
-
* @memberof CollectionBuilder
|
|
114
|
-
*/
|
|
115
|
-
limit(limit) {
|
|
116
|
-
__classPrivateFieldSet(this, _CollectionBuilder_limit, limit, "f");
|
|
117
|
-
return this;
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Takes a number that represents the page to fetch
|
|
121
|
-
*
|
|
122
|
-
* @param {number} page The page to fetch
|
|
123
|
-
* @return {CollectionBuilder} CollectionBuilder - A CollectionBuilder instance
|
|
124
|
-
* @memberof CollectionBuilder
|
|
125
|
-
*/
|
|
126
|
-
page(page) {
|
|
127
|
-
__classPrivateFieldSet(this, _CollectionBuilder_page, page, "f");
|
|
128
|
-
return this;
|
|
129
|
-
}
|
|
130
|
-
query(arg) {
|
|
131
|
-
if (typeof arg === 'string') {
|
|
132
|
-
__classPrivateFieldSet(this, _CollectionBuilder_rawQuery, arg, "f");
|
|
133
|
-
return this;
|
|
134
|
-
}
|
|
135
|
-
if (typeof arg !== 'function') {
|
|
136
|
-
throw new Error(`Parameter for query method should be a buildQuery function or a string.\nExample:\nclient.content.getCollection('Activity').query((queryBuilder) => queryBuilder.field('title').equals('Hello World'))\nor\nclient.content.getCollection('Activity').query('+Activity.title:"Hello World"') \nSee documentation for more information.`);
|
|
137
|
-
}
|
|
138
|
-
const builtQuery = arg(new QueryBuilder());
|
|
139
|
-
// This can be use in Javascript so we cannot rely on the type checking
|
|
140
|
-
if (builtQuery instanceof Equals) {
|
|
141
|
-
__classPrivateFieldSet(this, _CollectionBuilder_query, builtQuery.raw(this.currentQuery.build()), "f");
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
throw new Error('Provided query is not valid. A query should end in an equals method call.\nExample:\n(queryBuilder) => queryBuilder.field("title").equals("Hello World")\nSee documentation for more information.');
|
|
145
|
-
}
|
|
146
|
-
return this;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* The retrieved content will be draft content
|
|
150
|
-
*
|
|
151
|
-
* The default value is false to fetch content that is not on draft
|
|
152
|
-
*
|
|
153
|
-
* @return {CollectionBuilder} CollectionBuilder - A CollectionBuilder instance
|
|
154
|
-
* @memberof CollectionBuilder
|
|
155
|
-
*/
|
|
156
|
-
draft() {
|
|
157
|
-
__classPrivateFieldSet(this, _CollectionBuilder_draft, true, "f");
|
|
158
|
-
return this;
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Takes a string that represents a variant ID of content created with the {@link https://www.dotcms.com/docs/latest/experiments-and-a-b-testing A/B Testing} feature
|
|
162
|
-
*
|
|
163
|
-
* `variantId` defaults to "DEFAULT" to fetch content that is not part of an A/B test
|
|
164
|
-
*
|
|
165
|
-
* @param {string} variantId A string that represents a variant ID
|
|
166
|
-
* @return {CollectionBuilder} CollectionBuilder - A CollectionBuilder instance
|
|
167
|
-
* @memberof CollectionBuilder
|
|
168
|
-
*/
|
|
169
|
-
variant(variantId) {
|
|
170
|
-
__classPrivateFieldSet(this, _CollectionBuilder_query, this.currentQuery.field('variant').equals(variantId), "f");
|
|
171
|
-
return this;
|
|
172
|
-
}
|
|
173
|
-
/**
|
|
174
|
-
* Takes a number that represents the depth of the relationships of a content
|
|
175
|
-
*
|
|
176
|
-
* The `depth` is set to 0 by default and the max supported value is 3.
|
|
177
|
-
*
|
|
178
|
-
* @param {number} depth The depth of the relationships of a content
|
|
179
|
-
* @return {CollectionBuilder} CollectionBuilder - A CollectionBuilder instance
|
|
180
|
-
* @memberof CollectionBuilder
|
|
181
|
-
*/
|
|
182
|
-
depth(depth) {
|
|
183
|
-
if (depth < 0 || depth > 3) {
|
|
184
|
-
throw new Error('Depth value must be between 0 and 3');
|
|
185
|
-
}
|
|
186
|
-
__classPrivateFieldSet(this, _CollectionBuilder_depth, depth, "f");
|
|
187
|
-
return this;
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* Executes the fetch and returns a promise that resolves to the content or rejects to an error
|
|
191
|
-
*
|
|
192
|
-
* @param {OnFullfilled} [onfulfilled] A callback that is called when the fetch is successful
|
|
193
|
-
* @param {OnRejected} [onrejected] A callback that is called when the fetch fails
|
|
194
|
-
* @return {Promise<GetCollectionResponse<T> | GetCollectionError>} A promise that resolves to the content or rejects to an error
|
|
195
|
-
* @memberof CollectionBuilder
|
|
196
|
-
*/
|
|
197
|
-
then(onfulfilled, onrejected) {
|
|
198
|
-
return this.fetch().then(async (response) => {
|
|
199
|
-
const data = await response.json();
|
|
200
|
-
if (response.ok) {
|
|
201
|
-
const formattedResponse = this.formatResponse(data);
|
|
202
|
-
const finalResponse = typeof onfulfilled === 'function'
|
|
203
|
-
? onfulfilled(formattedResponse)
|
|
204
|
-
: formattedResponse;
|
|
205
|
-
return finalResponse;
|
|
206
|
-
}
|
|
207
|
-
else {
|
|
208
|
-
// Fetch does not reject on server errors, so we only have to bubble up the error as a normal fetch
|
|
209
|
-
return {
|
|
210
|
-
status: response.status,
|
|
211
|
-
...data
|
|
212
|
-
};
|
|
213
|
-
}
|
|
214
|
-
}, onrejected);
|
|
215
|
-
}
|
|
216
|
-
// Formats the response to the desired format
|
|
217
|
-
formatResponse(data) {
|
|
218
|
-
const contentlets = data.entity.jsonObjectView.contentlets;
|
|
219
|
-
const total = data.entity.resultsSize;
|
|
220
|
-
const mappedResponse = {
|
|
221
|
-
contentlets,
|
|
222
|
-
total,
|
|
223
|
-
page: __classPrivateFieldGet(this, _CollectionBuilder_page, "f"),
|
|
224
|
-
size: contentlets.length
|
|
225
|
-
};
|
|
226
|
-
return __classPrivateFieldGet(this, _CollectionBuilder_sortBy, "f")
|
|
227
|
-
? {
|
|
228
|
-
...mappedResponse,
|
|
229
|
-
sortedBy: __classPrivateFieldGet(this, _CollectionBuilder_sortBy, "f")
|
|
230
|
-
}
|
|
231
|
-
: mappedResponse;
|
|
232
|
-
}
|
|
233
|
-
// Calls the content API to fetch the content
|
|
234
|
-
fetch() {
|
|
235
|
-
const finalQuery = this.currentQuery
|
|
236
|
-
.field('languageId')
|
|
237
|
-
.equals(__classPrivateFieldGet(this, _CollectionBuilder_languageId, "f").toString())
|
|
238
|
-
.field('live')
|
|
239
|
-
.equals((!__classPrivateFieldGet(this, _CollectionBuilder_draft, "f")).toString())
|
|
240
|
-
.build();
|
|
241
|
-
const sanitizedQuery = sanitizeQueryForContentType(finalQuery, __classPrivateFieldGet(this, _CollectionBuilder_contentType, "f"));
|
|
242
|
-
const query = __classPrivateFieldGet(this, _CollectionBuilder_rawQuery, "f") ? `${sanitizedQuery} ${__classPrivateFieldGet(this, _CollectionBuilder_rawQuery, "f")}` : sanitizedQuery;
|
|
243
|
-
return fetch(this.url, {
|
|
244
|
-
...__classPrivateFieldGet(this, _CollectionBuilder_requestOptions, "f"),
|
|
245
|
-
method: 'POST',
|
|
246
|
-
headers: {
|
|
247
|
-
...__classPrivateFieldGet(this, _CollectionBuilder_requestOptions, "f").headers,
|
|
248
|
-
'Content-Type': 'application/json'
|
|
249
|
-
},
|
|
250
|
-
body: JSON.stringify({
|
|
251
|
-
query,
|
|
252
|
-
render: __classPrivateFieldGet(this, _CollectionBuilder_render, "f"),
|
|
253
|
-
sort: this.sort,
|
|
254
|
-
limit: __classPrivateFieldGet(this, _CollectionBuilder_limit, "f"),
|
|
255
|
-
offset: this.offset,
|
|
256
|
-
depth: __classPrivateFieldGet(this, _CollectionBuilder_depth, "f")
|
|
257
|
-
//userId: This exist but we currently don't use it
|
|
258
|
-
//allCategoriesInfo: This exist but we currently don't use it
|
|
259
|
-
})
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
_CollectionBuilder_page = new WeakMap(), _CollectionBuilder_limit = new WeakMap(), _CollectionBuilder_depth = new WeakMap(), _CollectionBuilder_render = new WeakMap(), _CollectionBuilder_sortBy = new WeakMap(), _CollectionBuilder_contentType = new WeakMap(), _CollectionBuilder_defaultQuery = new WeakMap(), _CollectionBuilder_query = new WeakMap(), _CollectionBuilder_rawQuery = new WeakMap(), _CollectionBuilder_languageId = new WeakMap(), _CollectionBuilder_draft = new WeakMap(), _CollectionBuilder_serverUrl = new WeakMap(), _CollectionBuilder_requestOptions = new WeakMap();
|
|
264
|
-
//# sourceMappingURL=collection.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../../../../../../../../../../libs/sdk/client/src/lib/client/content/builders/collection/collection.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,yCAAyC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,6CAA6C,CAAC;AAE3E,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAUrD,OAAO,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAC;AAEjE;;;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IAAI,CAAC,IAAI;gBACf,KAAK,EAAE,uBAAA,IAAI,gCAAO;gBAClB,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,KAAK,EAAE,uBAAA,IAAI,gCAAO;gBAClB,kDAAkD;gBAClD,6DAA6D;aAChE,CAAC;SACL,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
var _Content_requestOptions, _Content_serverUrl;
|
|
2
|
-
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
|
-
import { CollectionBuilder } from './builders/collection/collection';
|
|
4
|
-
/**
|
|
5
|
-
* Content classs exposes the content api methods
|
|
6
|
-
*
|
|
7
|
-
* @export
|
|
8
|
-
* @class Content
|
|
9
|
-
*/
|
|
10
|
-
export class Content {
|
|
11
|
-
constructor(requestOptions, serverUrl) {
|
|
12
|
-
_Content_requestOptions.set(this, void 0);
|
|
13
|
-
_Content_serverUrl.set(this, void 0);
|
|
14
|
-
__classPrivateFieldSet(this, _Content_requestOptions, requestOptions, "f");
|
|
15
|
-
__classPrivateFieldSet(this, _Content_serverUrl, serverUrl, "f");
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Takes a content type and returns a builder to filter and fetch the collection
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* ```javascript
|
|
22
|
-
* // Using await and async
|
|
23
|
-
* const collectionResponse = await client.content
|
|
24
|
-
* .getCollection('Blog')
|
|
25
|
-
* .limit(10)
|
|
26
|
-
* .page(2)
|
|
27
|
-
* .sortBy([{ field: 'title', order: 'asc' }])
|
|
28
|
-
* .query((queryBuilder) => queryBuilder.field('author').equals('John Doe'))
|
|
29
|
-
* .depth(1);
|
|
30
|
-
* ```
|
|
31
|
-
* @example
|
|
32
|
-
* ```javascript
|
|
33
|
-
* // Using then and catch
|
|
34
|
-
* client.content
|
|
35
|
-
* .getCollection('Blog')
|
|
36
|
-
* .limit(10)
|
|
37
|
-
* .page(2)
|
|
38
|
-
* .sortBy([{ field: 'title', order: 'asc' }])
|
|
39
|
-
* .query((queryBuilder) => queryBuilder.field('author').equals('John Doe'))
|
|
40
|
-
* .depth(1)
|
|
41
|
-
* .then((response) => {
|
|
42
|
-
* console.log(response.contentlets);
|
|
43
|
-
* })
|
|
44
|
-
* .catch((error) => {
|
|
45
|
-
* console.error(error);
|
|
46
|
-
* });
|
|
47
|
-
* ```
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* // Using an specific type for your content
|
|
51
|
-
*
|
|
52
|
-
* type Blog = {
|
|
53
|
-
* summary: string;
|
|
54
|
-
* author: string;
|
|
55
|
-
* title: string;
|
|
56
|
-
* };
|
|
57
|
-
*
|
|
58
|
-
* client.content
|
|
59
|
-
* .getCollection<Blog>('Blog')
|
|
60
|
-
* .limit(10)
|
|
61
|
-
* .page(2)
|
|
62
|
-
* .sortBy([{ field: 'title', order: 'asc' }])
|
|
63
|
-
* .query((queryBuilder) => queryBuilder.field('author').equals('John Doe'))
|
|
64
|
-
* .depth(1)
|
|
65
|
-
* .then((response) => {
|
|
66
|
-
* response.contentlets.forEach((blog) => {
|
|
67
|
-
* console.log(blog.title);
|
|
68
|
-
* console.log(blog.author);
|
|
69
|
-
* console.log(blog.summary);
|
|
70
|
-
* });
|
|
71
|
-
* })
|
|
72
|
-
* .catch((error) => {
|
|
73
|
-
* console.error(error);
|
|
74
|
-
* });
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
|
-
* @param {string} contentType The content type to get the collection
|
|
78
|
-
* @return {CollectionBuilder} CollectionBuilder to filter and fetch the collection
|
|
79
|
-
* @template T Represents the type of the content type to fetch. Defaults to unknown
|
|
80
|
-
* @memberof Content
|
|
81
|
-
*/
|
|
82
|
-
getCollection(contentType) {
|
|
83
|
-
return new CollectionBuilder(__classPrivateFieldGet(this, _Content_requestOptions, "f"), __classPrivateFieldGet(this, _Content_serverUrl, "f"), contentType);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
_Content_requestOptions = new WeakMap(), _Content_serverUrl = new WeakMap();
|
|
87
|
-
//# sourceMappingURL=content-api.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"content-api.js","sourceRoot":"","sources":["../../../../../../../../libs/sdk/client/src/lib/client/content/content-api.ts"],"names":[],"mappings":";;AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAIrE;;;;;GAKG;AACH,MAAM,OAAO,OAAO;IAIhB,YAAY,cAA6B,EAAE,SAAiB;QAH5D,0CAA+B;QAC/B,qCAAmB;QAGf,uBAAA,IAAI,2BAAmB,cAAc,MAAA,CAAC;QACtC,uBAAA,IAAI,sBAAc,SAAS,MAAA,CAAC;IAChC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgEG;IACH,aAAa,CAAc,WAAmB;QAC1C,OAAO,IAAI,iBAAiB,CAAI,uBAAA,IAAI,+BAAgB,EAAE,uBAAA,IAAI,0BAAW,EAAE,WAAW,CAAC,CAAC;IACxF,CAAC;CACJ"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export const DEFAULT_VARIANT_ID = 'DEFAULT';
|
|
2
|
-
// Fields that we don't want to format when sanitizing the query
|
|
3
|
-
export const CONTENT_TYPE_MAIN_FIELDS = ['live', 'variant', 'contentType', 'languageId'];
|
|
4
|
-
export const CONTENT_API_URL = '/api/content/_search';
|
|
5
|
-
//# sourceMappingURL=const.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"const.js","sourceRoot":"","sources":["../../../../../../../../../libs/sdk/client/src/lib/client/content/shared/const.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,kBAAkB,GAAG,SAAS,CAAC;AAE5C,gEAAgE;AAChE,MAAM,CAAC,MAAM,wBAAwB,GAAa,CAAC,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,YAAY,CAAC,CAAC;AAEnG,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../../libs/sdk/client/src/lib/client/content/shared/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { CONTENT_TYPE_MAIN_FIELDS } from './const';
|
|
2
|
-
/**
|
|
3
|
-
* Sanitizes the query for the given content type.
|
|
4
|
-
* It replaces the fields that are not contentType fields with the correct format.
|
|
5
|
-
* Example: +field: -> +contentTypeVar.field:
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* @export
|
|
9
|
-
* @param {string} query
|
|
10
|
-
* @param {string} contentType
|
|
11
|
-
* @return {*} {string}
|
|
12
|
-
*/
|
|
13
|
-
export function sanitizeQueryForContentType(query, contentType) {
|
|
14
|
-
return query.replace(/\+([^+:]*?):/g, (original, field) => {
|
|
15
|
-
return !CONTENT_TYPE_MAIN_FIELDS.includes(field) // Fields that are not contentType fields
|
|
16
|
-
? `+${contentType}.${field}:` // Should have this format: +contentTypeVar.field:
|
|
17
|
-
: original; // Return the field if it is a contentType field
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../../../../../../libs/sdk/client/src/lib/client/content/shared/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,SAAS,CAAC;AAEnD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,2BAA2B,CAAC,KAAa,EAAE,WAAmB;IAC1E,OAAO,KAAK,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC,QAAQ,EAAE,KAAK,EAAE,EAAE;QACtD,OAAO,CAAC,wBAAwB,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,yCAAyC;YACtF,CAAC,CAAC,IAAI,WAAW,IAAI,KAAK,GAAG,CAAC,kDAAkD;YAChF,CAAC,CAAC,QAAQ,CAAC,CAAC,gDAAgD;IACpE,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export const ErrorMessages = {
|
|
2
|
-
401: 'Unauthorized. Check the token and try again.',
|
|
3
|
-
403: 'Forbidden. Check the permissions and try again.',
|
|
4
|
-
404: 'Not Found. Check the URL and try again.',
|
|
5
|
-
500: 'Internal Server Error. Try again later.',
|
|
6
|
-
502: 'Bad Gateway. Try again later.',
|
|
7
|
-
503: 'Service Unavailable. Try again later.'
|
|
8
|
-
};
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../libs/sdk/client/src/lib/client/models/index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAA2B;IACjD,GAAG,EAAE,8CAA8C;IACnD,GAAG,EAAE,iDAAiD;IACtD,GAAG,EAAE,yCAAyC;IAC9C,GAAG,EAAE,yCAAyC;IAC9C,GAAG,EAAE,+BAA+B;IACpC,GAAG,EAAE,uCAAuC;CAC/C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../libs/sdk/client/src/lib/client/models/types.ts"],"names":[],"mappings":""}
|