@dotcms/client 0.0.1-alpha.4 → 0.0.1-alpha.40
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/.eslintrc.json +18 -0
- package/README.md +17 -6
- package/jest.config.ts +15 -0
- package/package.json +5 -5
- package/project.json +72 -0
- package/src/index.ts +30 -0
- package/src/lib/client/content/builders/collection/collection.spec.ts +515 -0
- package/src/lib/client/content/builders/collection/collection.ts +416 -0
- package/src/lib/client/content/content-api.ts +139 -0
- package/src/lib/client/content/shared/const.ts +15 -0
- package/src/lib/client/content/shared/types.ts +155 -0
- package/src/lib/client/content/shared/utils.ts +28 -0
- package/src/lib/client/models/index.ts +19 -0
- package/src/lib/client/models/types.ts +14 -0
- package/src/lib/client/sdk-js-client.spec.ts +483 -0
- package/src/lib/client/sdk-js-client.ts +442 -0
- package/src/lib/editor/listeners/listeners.spec.ts +119 -0
- package/src/lib/editor/listeners/listeners.ts +223 -0
- package/src/lib/editor/models/client.model.ts +84 -0
- package/src/lib/editor/models/editor.model.ts +53 -0
- package/src/lib/editor/models/listeners.model.ts +50 -0
- package/src/lib/editor/sdk-editor-vtl.ts +31 -0
- package/src/lib/editor/sdk-editor.spec.ts +116 -0
- package/src/lib/editor/sdk-editor.ts +105 -0
- package/src/lib/editor/utils/editor.utils.spec.ts +206 -0
- package/src/lib/editor/utils/editor.utils.ts +258 -0
- package/src/lib/query-builder/lucene-syntax/Equals.ts +148 -0
- package/src/lib/query-builder/lucene-syntax/Field.ts +40 -0
- package/src/lib/query-builder/lucene-syntax/NotOperand.ts +34 -0
- package/src/lib/query-builder/lucene-syntax/Operand.ts +58 -0
- package/src/lib/query-builder/lucene-syntax/index.ts +4 -0
- package/src/lib/query-builder/sdk-query-builder.spec.ts +159 -0
- package/src/lib/query-builder/sdk-query-builder.ts +87 -0
- package/src/lib/query-builder/utils/index.ts +179 -0
- package/src/lib/utils/graphql/transforms.spec.ts +150 -0
- package/src/lib/utils/graphql/transforms.ts +99 -0
- package/src/lib/utils/index.ts +2 -0
- package/src/lib/utils/page/common-utils.spec.ts +37 -0
- package/src/lib/utils/page/common-utils.ts +64 -0
- package/tsconfig.json +22 -0
- package/tsconfig.lib.json +13 -0
- package/tsconfig.spec.json +9 -0
- package/src/index.d.ts +0 -2
- package/src/index.js +0 -3
- package/src/index.js.map +0 -1
- package/src/lib/postMessageToEditor.d.ts +0 -50
- package/src/lib/postMessageToEditor.js +0 -42
- package/src/lib/postMessageToEditor.js.map +0 -1
- package/src/lib/sdk-js-client.d.ts +0 -183
- package/src/lib/sdk-js-client.js +0 -145
- package/src/lib/sdk-js-client.js.map +0 -1
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
/**
|
|
3
|
+
* Represents the response from a GraphQL query for a page.
|
|
4
|
+
*
|
|
5
|
+
* @interface GraphQLPageResponse
|
|
6
|
+
* @property {Record<string, unknown>} page - The main page data.
|
|
7
|
+
* @property {unknown} [key: string] - Additional properties that may be included in the response.
|
|
8
|
+
*/
|
|
9
|
+
interface GraphQLPageResponse {
|
|
10
|
+
page: Record<string, unknown>;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Transforms a GraphQL Page response to a Page Entity.
|
|
16
|
+
*
|
|
17
|
+
* @param {GraphQLPageResponse} graphQLPageResponse - The GraphQL Page response object.
|
|
18
|
+
* @returns {object|null} The transformed Page Entity or null if the page is not present.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const pageEntity = graphqlToPageEntity(graphQLPageResponse);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export const graphqlToPageEntity = (graphQLPageResponse: GraphQLPageResponse) => {
|
|
26
|
+
const { page } = graphQLPageResponse;
|
|
27
|
+
|
|
28
|
+
// If there is no page, return null
|
|
29
|
+
if (!page) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const { layout, template, containers, urlContentMap, viewAs, site, _map, ...pageAsset } = page;
|
|
34
|
+
const data = (_map || {}) as Record<string, unknown>;
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
layout,
|
|
38
|
+
template,
|
|
39
|
+
viewAs,
|
|
40
|
+
urlContentMap,
|
|
41
|
+
site,
|
|
42
|
+
page: {
|
|
43
|
+
...data,
|
|
44
|
+
...pageAsset
|
|
45
|
+
},
|
|
46
|
+
containers: parseContainers(containers as [])
|
|
47
|
+
} as any;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Parses the containers from the GraphQL response.
|
|
52
|
+
*
|
|
53
|
+
* @param {Array<Record<string, unknown>>} [containers=[]] - The containers array from the GraphQL response.
|
|
54
|
+
* @returns {Record<string, unknown>} The parsed containers.
|
|
55
|
+
*/
|
|
56
|
+
const parseContainers = (containers: Record<string, unknown>[] = []) => {
|
|
57
|
+
return containers.reduce((acc: Record<string, unknown>, container: Record<string, unknown>) => {
|
|
58
|
+
const { path, identifier, containerStructures, containerContentlets, ...rest } = container;
|
|
59
|
+
|
|
60
|
+
const key = (path || identifier) as string;
|
|
61
|
+
|
|
62
|
+
acc[key] = {
|
|
63
|
+
containerStructures,
|
|
64
|
+
container: {
|
|
65
|
+
path,
|
|
66
|
+
identifier,
|
|
67
|
+
...rest
|
|
68
|
+
},
|
|
69
|
+
contentlets: parseContentletsToUuidMap(containerContentlets as [])
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
return acc;
|
|
73
|
+
}, {});
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Parses the contentlets from the GraphQL response.
|
|
78
|
+
*
|
|
79
|
+
* @param {Array<Record<string, unknown>>} containerContentlets - The contentlets array from the GraphQL response.
|
|
80
|
+
* @returns {Record<string, Array<Record<string, unknown>>>} The parsed contentlets mapped by UUID.
|
|
81
|
+
*/
|
|
82
|
+
const parseContentletsToUuidMap = (containerContentlets: Record<string, unknown>[] = []) => {
|
|
83
|
+
return containerContentlets.reduce((acc, containerContentlet) => {
|
|
84
|
+
const { uuid, contentlets } = containerContentlet as {
|
|
85
|
+
uuid: string;
|
|
86
|
+
contentlets: Record<string, unknown>[];
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// TODO: This is a temporary solution, we need to find a better way to handle this.
|
|
90
|
+
acc[uuid] = contentlets.map(({ _map = {}, ...rest }) => {
|
|
91
|
+
return {
|
|
92
|
+
...(_map as Record<string, unknown>),
|
|
93
|
+
...rest
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
return acc;
|
|
98
|
+
}, {});
|
|
99
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getPageRequestParams } from './common-utils';
|
|
2
|
+
|
|
3
|
+
describe('Common Utils', () => {
|
|
4
|
+
it('should return the correct Request Params', () => {
|
|
5
|
+
const pageRequestParams = getPageRequestParams({
|
|
6
|
+
path: 'test',
|
|
7
|
+
params: {
|
|
8
|
+
personaId: '123',
|
|
9
|
+
language_id: '1',
|
|
10
|
+
mode: 'LIVE',
|
|
11
|
+
variantName: 'default'
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
expect(pageRequestParams).toEqual({
|
|
16
|
+
path: 'test',
|
|
17
|
+
mode: 'LIVE',
|
|
18
|
+
language_id: '1',
|
|
19
|
+
variantName: 'default',
|
|
20
|
+
personaId: '123'
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
it('should return the correct Request Params with empty params', () => {
|
|
25
|
+
const pageRequestParams = getPageRequestParams({
|
|
26
|
+
path: 'test',
|
|
27
|
+
params: {
|
|
28
|
+
personaId: '',
|
|
29
|
+
language_id: '',
|
|
30
|
+
mode: '',
|
|
31
|
+
variantName: ''
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
expect(pageRequestParams).toEqual({ path: 'test' });
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { PageApiOptions } from '../../client/sdk-js-client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing the properties for page request parameters.
|
|
5
|
+
*
|
|
6
|
+
* @export
|
|
7
|
+
* @interface PageRequestParamsProps
|
|
8
|
+
*/
|
|
9
|
+
export interface PageRequestParamsProps {
|
|
10
|
+
/**
|
|
11
|
+
* The API endpoint path.
|
|
12
|
+
* @type {string}
|
|
13
|
+
*/
|
|
14
|
+
path: string;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The query parameters for the API request.
|
|
18
|
+
* Can be an object with key-value pairs or a URLSearchParams instance.
|
|
19
|
+
* @type {{ [key: string]: unknown } | URLSearchParams}
|
|
20
|
+
*/
|
|
21
|
+
params: { [key: string]: unknown } | URLSearchParams;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Generates the page request parameters to be used in the API call.
|
|
26
|
+
*
|
|
27
|
+
* @param {PageRequestParamsProps} PageRequestParamsProps - The properties for the page request.
|
|
28
|
+
* @returns {PageApiOptions} The options for the page API.
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const pageApiOptions = getPageRequestParams({ path: '/api/v1/page', params: queryParams });
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export const getPageRequestParams = ({
|
|
35
|
+
path = '',
|
|
36
|
+
params = {}
|
|
37
|
+
}: PageRequestParamsProps): PageApiOptions => {
|
|
38
|
+
const copiedParams: PageRequestParamsProps['params'] =
|
|
39
|
+
params instanceof URLSearchParams ? Object.fromEntries(params.entries()) : { ...params };
|
|
40
|
+
|
|
41
|
+
const finalParams: Record<string, unknown> = {};
|
|
42
|
+
const dotMarketingPersonaId = copiedParams['com.dotmarketing.persona.id'] || '';
|
|
43
|
+
|
|
44
|
+
if (copiedParams['mode']) {
|
|
45
|
+
finalParams['mode'] = copiedParams['mode'];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
if (copiedParams['language_id']) {
|
|
49
|
+
finalParams['language_id'] = copiedParams['language_id'];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (copiedParams['variantName']) {
|
|
53
|
+
finalParams['variantName'] = copiedParams['variantName'];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (copiedParams['personaId'] || dotMarketingPersonaId) {
|
|
57
|
+
finalParams['personaId'] = copiedParams['personaId'] || dotMarketingPersonaId;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
path,
|
|
62
|
+
...finalParams
|
|
63
|
+
};
|
|
64
|
+
};
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.base.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"forceConsistentCasingInFileNames": true,
|
|
6
|
+
"strict": true,
|
|
7
|
+
"noImplicitOverride": true,
|
|
8
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
9
|
+
"noImplicitReturns": true,
|
|
10
|
+
"noFallthroughCasesInSwitch": true
|
|
11
|
+
},
|
|
12
|
+
"files": [],
|
|
13
|
+
"include": [],
|
|
14
|
+
"references": [
|
|
15
|
+
{
|
|
16
|
+
"path": "./tsconfig.lib.json"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"path": "./tsconfig.spec.json"
|
|
20
|
+
}
|
|
21
|
+
]
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "./tsconfig.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "../../../dist/out-tsc",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"types": [""],
|
|
7
|
+
"target": "es2020",
|
|
8
|
+
"module": "es2020",
|
|
9
|
+
"moduleResolution": "node"
|
|
10
|
+
},
|
|
11
|
+
"include": ["src/**/*.ts"],
|
|
12
|
+
"exclude": ["jest.config.ts", "src/**/*.spec.ts", "src/**/*.test.ts"]
|
|
13
|
+
}
|
package/src/index.d.ts
DELETED
package/src/index.js
DELETED
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,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Actions send to the dotcms editor
|
|
3
|
-
*
|
|
4
|
-
* @export
|
|
5
|
-
* @enum {number}
|
|
6
|
-
*/
|
|
7
|
-
export declare enum CUSTOMER_ACTIONS {
|
|
8
|
-
/**
|
|
9
|
-
* Tell the dotcms editor that page change
|
|
10
|
-
*/
|
|
11
|
-
SET_URL = "set-url",
|
|
12
|
-
/**
|
|
13
|
-
* Send the element position of the rows, columnsm containers and contentlets
|
|
14
|
-
*/
|
|
15
|
-
SET_BOUNDS = "set-bounds",
|
|
16
|
-
/**
|
|
17
|
-
* Send the information of the hovered contentlet
|
|
18
|
-
*/
|
|
19
|
-
SET_CONTENTLET = "set-contentlet",
|
|
20
|
-
/**
|
|
21
|
-
* Tell the editor that the page is being scrolled
|
|
22
|
-
*/
|
|
23
|
-
IFRAME_SCROLL = "scroll",
|
|
24
|
-
/**
|
|
25
|
-
* Ping the editor to see if the page is inside the editor
|
|
26
|
-
*/
|
|
27
|
-
PING_EDITOR = "ping-editor",
|
|
28
|
-
CONTENT_CHANGE = "content-change",
|
|
29
|
-
NOOP = "noop"
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Post message props
|
|
33
|
-
*
|
|
34
|
-
* @export
|
|
35
|
-
* @template T
|
|
36
|
-
* @interface PostMessageProps
|
|
37
|
-
*/
|
|
38
|
-
type PostMessageProps<T> = {
|
|
39
|
-
action: CUSTOMER_ACTIONS;
|
|
40
|
-
payload?: T;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* Post message to dotcms page editor
|
|
44
|
-
*
|
|
45
|
-
* @export
|
|
46
|
-
* @template T
|
|
47
|
-
* @param {PostMessageProps<T>} message
|
|
48
|
-
*/
|
|
49
|
-
export declare function postMessageToEditor<T = unknown>(message: PostMessageProps<T>): void;
|
|
50
|
-
export {};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Actions send to the dotcms editor
|
|
3
|
-
*
|
|
4
|
-
* @export
|
|
5
|
-
* @enum {number}
|
|
6
|
-
*/
|
|
7
|
-
export var CUSTOMER_ACTIONS;
|
|
8
|
-
(function (CUSTOMER_ACTIONS) {
|
|
9
|
-
/**
|
|
10
|
-
* Tell the dotcms editor that page change
|
|
11
|
-
*/
|
|
12
|
-
CUSTOMER_ACTIONS["SET_URL"] = "set-url";
|
|
13
|
-
/**
|
|
14
|
-
* Send the element position of the rows, columnsm containers and contentlets
|
|
15
|
-
*/
|
|
16
|
-
CUSTOMER_ACTIONS["SET_BOUNDS"] = "set-bounds";
|
|
17
|
-
/**
|
|
18
|
-
* Send the information of the hovered contentlet
|
|
19
|
-
*/
|
|
20
|
-
CUSTOMER_ACTIONS["SET_CONTENTLET"] = "set-contentlet";
|
|
21
|
-
/**
|
|
22
|
-
* Tell the editor that the page is being scrolled
|
|
23
|
-
*/
|
|
24
|
-
CUSTOMER_ACTIONS["IFRAME_SCROLL"] = "scroll";
|
|
25
|
-
/**
|
|
26
|
-
* Ping the editor to see if the page is inside the editor
|
|
27
|
-
*/
|
|
28
|
-
CUSTOMER_ACTIONS["PING_EDITOR"] = "ping-editor";
|
|
29
|
-
CUSTOMER_ACTIONS["CONTENT_CHANGE"] = "content-change";
|
|
30
|
-
CUSTOMER_ACTIONS["NOOP"] = "noop";
|
|
31
|
-
})(CUSTOMER_ACTIONS || (CUSTOMER_ACTIONS = {}));
|
|
32
|
-
/**
|
|
33
|
-
* Post message to dotcms page editor
|
|
34
|
-
*
|
|
35
|
-
* @export
|
|
36
|
-
* @template T
|
|
37
|
-
* @param {PostMessageProps<T>} message
|
|
38
|
-
*/
|
|
39
|
-
export function postMessageToEditor(message) {
|
|
40
|
-
window.parent.postMessage(message, '*');
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=postMessageToEditor.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postMessageToEditor.js","sourceRoot":"","sources":["../../../../../../libs/sdk/client/src/lib/postMessageToEditor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAN,IAAY,gBAyBX;AAzBD,WAAY,gBAAgB;IACxB;;OAEG;IACH,uCAAmB,CAAA;IACnB;;OAEG;IACH,6CAAyB,CAAA;IACzB;;OAEG;IACH,qDAAiC,CAAA;IACjC;;OAEG;IACH,4CAAwB,CAAA;IACxB;;OAEG;IACH,+CAA2B,CAAA;IAE3B,qDAAiC,CAAA;IAEjC,iCAAa,CAAA;AACjB,CAAC,EAzBW,gBAAgB,KAAhB,gBAAgB,QAyB3B;AAcD;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAc,OAA4B;IACzE,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAC5C,CAAC"}
|
|
@@ -1,183 +0,0 @@
|
|
|
1
|
-
export interface ClientConfig {
|
|
2
|
-
/**
|
|
3
|
-
* The URL of the dotCMS instance.
|
|
4
|
-
*
|
|
5
|
-
* @description This is the URL of the dotCMS instance you want to interact with. Ensure to include the protocol (http or https).
|
|
6
|
-
* @example `https://demo.dotcms.com`
|
|
7
|
-
* @type {string}
|
|
8
|
-
* @required
|
|
9
|
-
*/
|
|
10
|
-
dotcmsUrl: string;
|
|
11
|
-
/**
|
|
12
|
-
* The id of the site you want to interact with.
|
|
13
|
-
*
|
|
14
|
-
* @description to get the site id, go to the site you want to interact with and copy the id from the History tab
|
|
15
|
-
*
|
|
16
|
-
* @type {string}
|
|
17
|
-
* @required
|
|
18
|
-
*/
|
|
19
|
-
siteId?: string;
|
|
20
|
-
/**
|
|
21
|
-
* The authentication token to use for the requests. If not provided, it will fallback to default site.
|
|
22
|
-
*
|
|
23
|
-
* @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
|
-
*
|
|
25
|
-
* @type {string}
|
|
26
|
-
* @required
|
|
27
|
-
*/
|
|
28
|
-
authToken: string;
|
|
29
|
-
/**
|
|
30
|
-
* Additional options to pass to the fetch request.
|
|
31
|
-
*
|
|
32
|
-
* @description These options will be used in the fetch request. Any option can be specified except for 'body' and 'method' which are omitted.
|
|
33
|
-
* @example `{ headers: { 'Content-Type': 'application/json' } }`
|
|
34
|
-
* @type {Omit<RequestInit, 'body' | 'method'>}
|
|
35
|
-
* @optional
|
|
36
|
-
*/
|
|
37
|
-
requestOptions?: Omit<RequestInit, 'body' | 'method'>;
|
|
38
|
-
}
|
|
39
|
-
type PageApiOptions = {
|
|
40
|
-
/**
|
|
41
|
-
* The path of the page you want to retrieve.
|
|
42
|
-
*
|
|
43
|
-
* @type {string}
|
|
44
|
-
*/
|
|
45
|
-
path: string;
|
|
46
|
-
/**
|
|
47
|
-
* The id of the site you want to interact with. If not provided, the one from the config will be used.
|
|
48
|
-
*
|
|
49
|
-
* @type {number}
|
|
50
|
-
*/
|
|
51
|
-
siteId?: string;
|
|
52
|
-
/**
|
|
53
|
-
* The language id of the page you want to retrieve. If not provided will use the default language of the site.
|
|
54
|
-
*
|
|
55
|
-
* @type {number}
|
|
56
|
-
*/
|
|
57
|
-
language_id?: number;
|
|
58
|
-
/**
|
|
59
|
-
* The id of the persona you want to retrieve the page for.
|
|
60
|
-
*
|
|
61
|
-
* @type {string}
|
|
62
|
-
*/
|
|
63
|
-
personaId?: string;
|
|
64
|
-
/**
|
|
65
|
-
* If you want to fire the rules set on the page
|
|
66
|
-
*
|
|
67
|
-
* @type {boolean}
|
|
68
|
-
*/
|
|
69
|
-
fireRules?: boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Allows access to related content via the Relationship fields of contentlets on a Page; 0 (default)
|
|
72
|
-
*
|
|
73
|
-
* @type {number}
|
|
74
|
-
*/
|
|
75
|
-
depth?: number;
|
|
76
|
-
};
|
|
77
|
-
type NavApiOptions = {
|
|
78
|
-
/**
|
|
79
|
-
* The root path to begin traversing the folder tree.
|
|
80
|
-
*
|
|
81
|
-
* @example
|
|
82
|
-
* `/api/v1/nav/` starts from the root of the site
|
|
83
|
-
* @example
|
|
84
|
-
* `/about-us` starts from the "About Us" folder
|
|
85
|
-
*
|
|
86
|
-
* @type {string}
|
|
87
|
-
*/
|
|
88
|
-
path: string;
|
|
89
|
-
/**
|
|
90
|
-
* The depth of the folder tree to return.
|
|
91
|
-
* @example
|
|
92
|
-
* `1` returns only the element specified in the path.
|
|
93
|
-
* @example
|
|
94
|
-
* `2` returns the element specified in the path, and if that element is a folder, returns all direct children of that folder.
|
|
95
|
-
* @example
|
|
96
|
-
* `3` returns all children and grandchildren of the element specified in the path.
|
|
97
|
-
*
|
|
98
|
-
* @type {number}
|
|
99
|
-
*/
|
|
100
|
-
depth?: number;
|
|
101
|
-
/**
|
|
102
|
-
* The language ID of content to return.
|
|
103
|
-
* @example
|
|
104
|
-
* `1` (or unspecified) returns content in the default language of the site.
|
|
105
|
-
*
|
|
106
|
-
* @link https://www.dotcms.com/docs/latest/system-language-properties#DefaultLanguage
|
|
107
|
-
* @link https://www.dotcms.com/docs/latest/adding-and-editing-languages#LanguageID
|
|
108
|
-
* @type {number}
|
|
109
|
-
*/
|
|
110
|
-
languageId?: number;
|
|
111
|
-
};
|
|
112
|
-
/**
|
|
113
|
-
* `DotCmsClient` is a TypeScript class that provides methods to interact with the DotCMS REST API.
|
|
114
|
-
* It requires a configuration object on instantiation, which includes the DotCMS URL, site ID, and authentication token.
|
|
115
|
-
*
|
|
116
|
-
* @class DotCmsClient
|
|
117
|
-
*
|
|
118
|
-
* @property {ClientConfig} config - The configuration object for the DotCMS client.
|
|
119
|
-
*
|
|
120
|
-
* @method constructor(config: ClientConfig) - Constructs a new instance of the DotCmsClient class.
|
|
121
|
-
*
|
|
122
|
-
* @method page.get(options: PageApiOptions): Promise<unknown> - Retrieves all the elements of any Page in your dotCMS system in JSON format.
|
|
123
|
-
*
|
|
124
|
-
* @method nav.get(options: NavApiOptions = { depth: 0, path: '/', languageId: 1 }): Promise<unknown> - Retrieves information about the dotCMS file and folder tree.
|
|
125
|
-
*
|
|
126
|
-
*/
|
|
127
|
-
export declare class DotCmsClient {
|
|
128
|
-
private config;
|
|
129
|
-
private requestOptions;
|
|
130
|
-
constructor(config?: ClientConfig);
|
|
131
|
-
page: {
|
|
132
|
-
/**
|
|
133
|
-
* `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.
|
|
134
|
-
* It takes a `PageApiOptions` object as a parameter and returns a Promise that resolves to the response from the DotCMS API.
|
|
135
|
-
*
|
|
136
|
-
* The Page API enables you to retrieve all the elements of any Page in your dotCMS system.
|
|
137
|
-
* The elements may be retrieved in JSON format.
|
|
138
|
-
*
|
|
139
|
-
* @link https://www.dotcms.com/docs/latest/page-rest-api-layout-as-a-service-laas
|
|
140
|
-
* @async
|
|
141
|
-
* @param {PageApiOptions} options - The options for the Page API call.
|
|
142
|
-
* @returns {Promise<unknown>} - A Promise that resolves to the response from the DotCMS API.
|
|
143
|
-
* @throws {Error} - Throws an error if the options are not valid.
|
|
144
|
-
*/
|
|
145
|
-
get: (options: PageApiOptions) => Promise<unknown>;
|
|
146
|
-
};
|
|
147
|
-
nav: {
|
|
148
|
-
/**
|
|
149
|
-
* `nav.get` is an asynchronous method of the `DotCmsClient` class that retrieves information about the dotCMS file and folder tree.
|
|
150
|
-
* It takes a `NavApiOptions` object as a parameter (with default values) and returns a Promise that resolves to the response from the DotCMS API.
|
|
151
|
-
*
|
|
152
|
-
* The navigation REST API enables you to retrieve information about the dotCMS file and folder tree through REST API calls.
|
|
153
|
-
* @link https://www.dotcms.com/docs/latest/navigation-rest-api
|
|
154
|
-
* @async
|
|
155
|
-
* @param {NavApiOptions} options - The options for the Nav API call. Defaults to `{ depth: 0, path: '/', languageId: 1 }`.
|
|
156
|
-
* @returns {Promise<unknown>} - A Promise that resolves to the response from the DotCMS API.
|
|
157
|
-
* @throws {Error} - Throws an error if the options are not valid.
|
|
158
|
-
*/
|
|
159
|
-
get: (options?: NavApiOptions) => Promise<unknown>;
|
|
160
|
-
};
|
|
161
|
-
private validatePageOptions;
|
|
162
|
-
private validateNavOptions;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* `dotcmsClient` is an object that provides a method to initialize the DotCMS SDK client.
|
|
166
|
-
* It has a single method `init` which takes a configuration object and returns an instance of the `DotCmsClient` class.
|
|
167
|
-
*
|
|
168
|
-
* @namespace dotcmsClient
|
|
169
|
-
*
|
|
170
|
-
* @method init(config: ClientConfig): DotCmsClient - Initializes the SDK client.
|
|
171
|
-
*/
|
|
172
|
-
export declare const dotcmsClient: {
|
|
173
|
-
/**
|
|
174
|
-
* `init` is a method of the `dotcmsClient` object that initializes the SDK client.
|
|
175
|
-
* It takes a configuration object as a parameter and returns an instance of the `DotCmsClient` class.
|
|
176
|
-
*
|
|
177
|
-
* @method init
|
|
178
|
-
* @param {ClientConfig} config - The configuration object for the DotCMS client.
|
|
179
|
-
* @returns {DotCmsClient} - An instance of the {@link DotCmsClient} class.
|
|
180
|
-
*/
|
|
181
|
-
init: (config: ClientConfig) => DotCmsClient;
|
|
182
|
-
};
|
|
183
|
-
export {};
|