@dotcms/client 1.0.1 → 1.0.2

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.
Files changed (52) hide show
  1. package/dotcms-client-1.0.1.tgz +0 -0
  2. package/index.cjs.d.ts +1 -0
  3. package/index.cjs.default.js +1 -0
  4. package/index.cjs.js +1592 -0
  5. package/index.cjs.mjs +2 -0
  6. package/index.esm.d.ts +1 -0
  7. package/index.esm.js +1590 -0
  8. package/internal.cjs.d.ts +1 -0
  9. package/internal.cjs.default.js +1 -0
  10. package/internal.cjs.js +85 -0
  11. package/internal.cjs.mjs +2 -0
  12. package/internal.esm.d.ts +1 -0
  13. package/internal.esm.js +83 -0
  14. package/package.json +24 -7
  15. package/src/lib/client/client.d.ts +56 -0
  16. package/src/lib/client/content/builders/collection/{collection.ts → collection.d.ts} +19 -210
  17. package/src/lib/client/content/builders/query/lucene-syntax/{Equals.ts → Equals.d.ts} +11 -45
  18. package/src/lib/client/content/builders/query/lucene-syntax/{Field.ts → Field.d.ts} +5 -13
  19. package/src/lib/client/content/builders/query/lucene-syntax/{NotOperand.ts → NotOperand.d.ts} +5 -13
  20. package/src/lib/client/content/builders/query/lucene-syntax/{Operand.ts → Operand.d.ts} +7 -21
  21. package/src/lib/client/content/builders/query/{query.ts → query.d.ts} +5 -16
  22. package/src/lib/client/content/builders/query/utils/{index.ts → index.d.ts} +12 -49
  23. package/src/lib/client/content/{content-api.ts → content-api.d.ts} +4 -14
  24. package/src/lib/client/content/shared/{const.ts → const.d.ts} +3 -5
  25. package/src/lib/client/content/shared/{types.ts → types.d.ts} +2 -18
  26. package/src/lib/client/content/shared/{utils.ts → utils.d.ts} +1 -9
  27. package/src/lib/client/models/{index.ts → index.d.ts} +1 -8
  28. package/src/lib/client/navigation/navigation-api.d.ts +14 -0
  29. package/src/lib/client/page/page-api.d.ts +95 -0
  30. package/src/lib/client/page/utils.d.ts +41 -0
  31. package/src/lib/utils/graphql/transforms.d.ts +13 -0
  32. package/.eslintrc.json +0 -18
  33. package/jest.config.ts +0 -15
  34. package/project.json +0 -73
  35. package/src/lib/client/client.spec.ts +0 -147
  36. package/src/lib/client/client.ts +0 -125
  37. package/src/lib/client/content/builders/collection/collection.spec.ts +0 -514
  38. package/src/lib/client/content/builders/query/query.spec.ts +0 -159
  39. package/src/lib/client/navigation/navigation-api.spec.ts +0 -167
  40. package/src/lib/client/navigation/navigation-api.ts +0 -62
  41. package/src/lib/client/page/page-api.spec.ts +0 -359
  42. package/src/lib/client/page/page-api.ts +0 -197
  43. package/src/lib/client/page/utils.ts +0 -291
  44. package/src/lib/utils/graphql/transforms.spec.ts +0 -250
  45. package/src/lib/utils/graphql/transforms.ts +0 -128
  46. package/tsconfig.json +0 -22
  47. package/tsconfig.lib.json +0 -13
  48. package/tsconfig.spec.json +0 -9
  49. /package/src/{index.ts → index.d.ts} +0 -0
  50. /package/src/{internal.ts → internal.d.ts} +0 -0
  51. /package/src/lib/client/content/builders/query/lucene-syntax/{index.ts → index.d.ts} +0 -0
  52. /package/src/lib/utils/{index.ts → index.d.ts} +0 -0
@@ -1,17 +1,6 @@
1
1
  import { Field } from './Field';
2
2
  import { NotOperand } from './NotOperand';
3
3
  import { Operand } from './Operand';
4
-
5
- import {
6
- OPERAND,
7
- buildExcludeField,
8
- buildField,
9
- buildNotOperand,
10
- buildOperand,
11
- buildRawEquals,
12
- sanitizeQuery
13
- } from '../utils';
14
-
15
4
  /**
16
5
  * 'Equal' Is a Typescript class that provides the ability to use terms in the lucene query string.
17
6
  * A term is a value used to search for a specific value in a document. It can be a word or a phrase.
@@ -21,13 +10,10 @@ import {
21
10
  * @export
22
11
  * @class Equal
23
12
  */
24
- export class Equals {
25
- #query = '';
26
-
27
- constructor(private query: string) {
28
- this.#query = this.query;
29
- }
30
-
13
+ export declare class Equals {
14
+ #private;
15
+ private query;
16
+ constructor(query: string);
31
17
  /**
32
18
  * This method appends to the query a term that should be excluded in the search.
33
19
  *
@@ -41,10 +27,7 @@ export class Equals {
41
27
  * @return {*} {Field} - An instance of a Lucene Field. A field is a key used to search for a specific value in a document.
42
28
  * @memberof Equal
43
29
  */
44
- excludeField(field: string): Field {
45
- return buildExcludeField(this.#query, field);
46
- }
47
-
30
+ excludeField(field: string): Field;
48
31
  /**
49
32
  * This method appends to the query a field that should be included in the search.
50
33
  *
@@ -57,10 +40,7 @@ export class Equals {
57
40
  * @return {*} {Field} - An instance of a Lucene Field. A field is a key used to search for a specific value in a document.
58
41
  * @memberof Equal
59
42
  */
60
- field(field: string): Field {
61
- return buildField(this.#query, field);
62
- }
63
-
43
+ field(field: string): Field;
64
44
  /**
65
45
  * This method appends to the query an operand to use logic operators in the query.
66
46
  *
@@ -74,10 +54,7 @@ export class Equals {
74
54
  * @return {*} {Operand} - An instance of a Lucene Operand. An operand is a logical operator used to combine terms or phrases in a query.
75
55
  * @memberof Equal
76
56
  */
77
- or(): Operand {
78
- return buildOperand(this.#query, OPERAND.OR);
79
- }
80
-
57
+ or(): Operand;
81
58
  /**
82
59
  * This method appends to the query an operand to use logic operators in the query.
83
60
  *
@@ -90,10 +67,7 @@ export class Equals {
90
67
  * @return {*} {Operand} - An instance of a Lucene Operand. An operand is a logical operator used to combine terms or phrases in a query.
91
68
  * @memberof Equal
92
69
  */
93
- and(): Operand {
94
- return buildOperand(this.#query, OPERAND.AND);
95
- }
96
-
70
+ and(): Operand;
97
71
  /**
98
72
  * This method appends to the query an operand to use logic operators in the query.
99
73
  *
@@ -106,10 +80,7 @@ export class Equals {
106
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.
107
81
  * @memberof Equal
108
82
  */
109
- not(): NotOperand {
110
- return buildNotOperand(this.#query);
111
- }
112
-
83
+ not(): NotOperand;
113
84
  /**
114
85
  * This method allows to pass a raw query string to the query builder.
115
86
  * This raw query should end in a Lucene Equal.
@@ -126,10 +97,7 @@ export class Equals {
126
97
  * @return {*} {Equal} - An instance of a Lucene Equal. A term is a value used to search for a specific value in a document.
127
98
  * @memberof QueryBuilder
128
99
  */
129
- raw(query: string): Equals {
130
- return buildRawEquals(this.#query, query);
131
- }
132
-
100
+ raw(query: string): Equals;
133
101
  /**
134
102
  * This method returns the final query string.
135
103
  *
@@ -142,7 +110,5 @@ export class Equals {
142
110
  * @return {*} {string} - The final query string.
143
111
  * @memberof Equal
144
112
  */
145
- build(): string {
146
- return sanitizeQuery(this.#query);
147
- }
113
+ build(): string;
148
114
  }
@@ -1,7 +1,4 @@
1
1
  import { Equals } from './Equals';
2
-
3
- import { buildEquals } from '../utils';
4
-
5
2
  /**
6
3
  * The `Field` class is used to build a query with a specific field.
7
4
  * A Lucene Field is a key used to search for a specific value in a document.
@@ -9,18 +6,15 @@ import { buildEquals } from '../utils';
9
6
  * @export
10
7
  * @class Field
11
8
  */
12
- export class Field {
13
- #query = '';
14
-
9
+ export declare class Field {
10
+ #private;
11
+ private query;
15
12
  /**
16
13
  * Creates an instance of the `Field` class.
17
14
  *
18
15
  * @param {string} query - The initial query string.
19
16
  */
20
- constructor(private query: string) {
21
- this.#query = this.query;
22
- }
23
-
17
+ constructor(query: string);
24
18
  /**
25
19
  * Appends a term to the query that should be included in the search.
26
20
  *
@@ -34,7 +28,5 @@ export class Field {
34
28
  * @return {Equals} - An instance of `Equals`.
35
29
  * @memberof Field
36
30
  */
37
- equals(term: string): Equals {
38
- return buildEquals(this.#query, term);
39
- }
31
+ equals(term: string): Equals;
40
32
  }
@@ -1,20 +1,14 @@
1
1
  import { Equals } from './Equals';
2
-
3
- import { buildEquals } from '../utils';
4
-
5
2
  /**
6
3
  * 'NotOperand' Is a Typescript class that provides the ability to use the NOT operand in the lucene query string.
7
4
  *
8
5
  * @export
9
6
  * @class NotOperand
10
7
  */
11
- export class NotOperand {
12
- #query = '';
13
-
14
- constructor(private query: string) {
15
- this.#query = this.query;
16
- }
17
-
8
+ export declare class NotOperand {
9
+ #private;
10
+ private query;
11
+ constructor(query: string);
18
12
  /**
19
13
  * This method appends to the query a term that should be included in the search.
20
14
  *
@@ -28,7 +22,5 @@ export class NotOperand {
28
22
  * @return {*} {Equals} - An instance of Equals.
29
23
  * @memberof NotOperand
30
24
  */
31
- equals(term: string): Equals {
32
- return buildEquals(this.#query, term);
33
- }
25
+ equals(term: string): Equals;
34
26
  }
@@ -1,8 +1,5 @@
1
1
  import { Equals } from './Equals';
2
2
  import { Field } from './Field';
3
-
4
- import { buildExcludeField, buildField, buildEquals } from '../utils';
5
-
6
3
  /**
7
4
  * 'Operand' Is a Typescript class that provides the ability to use operands in the lucene query string.}
8
5
  * An operand is a logical operator used to join two or more conditions in a query.
@@ -10,13 +7,10 @@ import { buildExcludeField, buildField, buildEquals } from '../utils';
10
7
  * @export
11
8
  * @class Operand
12
9
  */
13
- export class Operand {
14
- #query = '';
15
-
16
- constructor(private query: string) {
17
- this.#query = this.query;
18
- }
19
-
10
+ export declare class Operand {
11
+ #private;
12
+ private query;
13
+ constructor(query: string);
20
14
  /**
21
15
  * This method appends to the query a term that should be excluded in the search.
22
16
  *
@@ -26,10 +20,7 @@ export class Operand {
26
20
  * @return {*} {Field} - An instance of a Lucene Field. A field is a key used to search for a specific value in a document.
27
21
  * @memberof Operand
28
22
  */
29
- excludeField(field: string): Field {
30
- return buildExcludeField(this.#query, field);
31
- }
32
-
23
+ excludeField(field: string): Field;
33
24
  /**
34
25
  * This method appends to the query a field that should be included in the search.
35
26
  *
@@ -39,10 +30,7 @@ export class Operand {
39
30
  * @return {*} {Field} - An instance of a Lucene Field. A field is a key used to search for a specific value in a document.
40
31
  * @memberof Operand
41
32
  */
42
- field(field: string): Field {
43
- return buildField(this.#query, field);
44
- }
45
-
33
+ field(field: string): Field;
46
34
  /**
47
35
  * This method appends to the query a term that should be included in the search.
48
36
  *
@@ -52,7 +40,5 @@ export class Operand {
52
40
  * @return {*} {Equals} - An instance of Equals.
53
41
  * @memberof Operand
54
42
  */
55
- equals(term: string): Equals {
56
- return buildEquals(this.#query, term);
57
- }
43
+ equals(term: string): Equals;
58
44
  }
@@ -1,6 +1,4 @@
1
1
  import { Equals, Field } from './lucene-syntax/index';
2
- import { buildExcludeField, buildField, buildRawEquals } from './utils';
3
-
4
2
  /**
5
3
  * 'QueryBuilder' Is a Typescript class that provides the ability to build a query string using the Lucene syntax in a more readable way.
6
4
  * @example
@@ -29,9 +27,8 @@ import { buildExcludeField, buildField, buildRawEquals } from './utils';
29
27
  * @export
30
28
  * @class QueryBuilder
31
29
  */
32
- export class QueryBuilder {
33
- #query = '';
34
-
30
+ export declare class QueryBuilder {
31
+ #private;
35
32
  /**
36
33
  * This method appends to the query a field that should be included in the search.
37
34
  *
@@ -45,10 +42,7 @@ export class QueryBuilder {
45
42
  * @return {*} {Field} - An instance of a Lucene Field. A field is a key used to search for a specific value in a document.
46
43
  * @memberof QueryBuilder
47
44
  */
48
- field(field: string): Field {
49
- return buildField(this.#query, field);
50
- }
51
-
45
+ field(field: string): Field;
52
46
  /**
53
47
  * This method appends to the query a field that should be excluded from the search.
54
48
  *
@@ -62,10 +56,7 @@ export class QueryBuilder {
62
56
  * @return {*} {Field} - An instance of a Lucene Exclude Field. An exclude field is a key used to exclude for a specific value in a document.
63
57
  * @memberof QueryBuilder
64
58
  */
65
- excludeField(field: string): Field {
66
- return buildExcludeField(this.#query, field);
67
- }
68
-
59
+ excludeField(field: string): Field;
69
60
  /**
70
61
  * This method allows to pass a raw query string to the query builder.
71
62
  * This raw query should end in Equals.
@@ -81,7 +72,5 @@ export class QueryBuilder {
81
72
  * @return {*} {Equals} - An instance of Equals. A term is a value used to search for a specific value in a document.
82
73
  * @memberof QueryBuilder
83
74
  */
84
- raw(query: string): Equals {
85
- return buildRawEquals(this.#query, query);
86
- }
75
+ raw(query: string): Equals;
87
76
  }
@@ -2,19 +2,17 @@ import { Equals } from '../lucene-syntax/Equals';
2
2
  import { Field } from '../lucene-syntax/Field';
3
3
  import { NotOperand } from '../lucene-syntax/NotOperand';
4
4
  import { Operand } from '../lucene-syntax/Operand';
5
-
6
5
  /**
7
6
  * Enum for common Operands
8
7
  *
9
8
  * @export
10
9
  * @enum {number}
11
10
  */
12
- export enum OPERAND {
13
- OR = 'OR',
14
- AND = 'AND',
15
- NOT = 'NOT'
11
+ export declare enum OPERAND {
12
+ OR = "OR",
13
+ AND = "AND",
14
+ NOT = "NOT"
16
15
  }
17
-
18
16
  /**
19
17
  * This function removes extra spaces from a string.
20
18
  *
@@ -27,10 +25,7 @@ export enum OPERAND {
27
25
  * @param {string} str
28
26
  * @return {*} {string}
29
27
  */
30
- export function sanitizeQuery(str: string): string {
31
- return str.replace(/\s{2,}/g, ' ').trim();
32
- }
33
-
28
+ export declare function sanitizeQuery(str: string): string;
34
29
  /**
35
30
  * This function sanitizes a term by adding quotes if it contains spaces.
36
31
  * In lucene, a term with spaces should be enclosed in quotes.
@@ -45,10 +40,7 @@ export function sanitizeQuery(str: string): string {
45
40
  * @param {string} term
46
41
  * @return {*} {string}
47
42
  */
48
- export function sanitizePhrases(term: string): string {
49
- return term.includes(' ') ? `'${term}'` : term;
50
- }
51
-
43
+ export declare function sanitizePhrases(term: string): string;
52
44
  /**
53
45
  * This function builds a term to be used in a lucene query.
54
46
  * We need to sanitize the term before adding it to the query.
@@ -63,12 +55,7 @@ export function sanitizePhrases(term: string): string {
63
55
  * @param {string} term
64
56
  * @return {*} {Equals}
65
57
  */
66
- export function buildEquals(query: string, term: string): Equals {
67
- const newQuery = query + sanitizePhrases(term);
68
-
69
- return new Equals(newQuery);
70
- }
71
-
58
+ export declare function buildEquals(query: string, term: string): Equals;
72
59
  /**
73
60
  * This function builds a term to be used in a lucene query.
74
61
  * We need to sanitize the raw query before adding it to the query.
@@ -84,12 +71,7 @@ export function buildEquals(query: string, term: string): Equals {
84
71
  * @param {string} raw
85
72
  * @return {*} {Equals}
86
73
  */
87
- export function buildRawEquals(query: string, raw: string): Equals {
88
- const newQuery = query + ` ${raw}`;
89
-
90
- return new Equals(sanitizeQuery(newQuery));
91
- }
92
-
74
+ export declare function buildRawEquals(query: string, raw: string): Equals;
93
75
  /**
94
76
  * This function builds a field to be used in a lucene query.
95
77
  * We need to format the field before adding it to the query.
@@ -104,12 +86,7 @@ export function buildRawEquals(query: string, raw: string): Equals {
104
86
  * @param {string} field
105
87
  * @return {*} {Field}
106
88
  */
107
- export function buildField(query: string, field: string): Field {
108
- const newQuery = query + ` +${field}:`;
109
-
110
- return new Field(newQuery);
111
- }
112
-
89
+ export declare function buildField(query: string, field: string): Field;
113
90
  /**
114
91
  * This function builds an exclude field to be used in a lucene query.
115
92
  * We need to format the field before adding it to the query.
@@ -125,12 +102,7 @@ export function buildField(query: string, field: string): Field {
125
102
  * @param {string} field
126
103
  * @return {*} {Field}
127
104
  */
128
- export function buildExcludeField(query: string, field: string): Field {
129
- const newQuery = query + ` -${field}:`;
130
-
131
- return new Field(newQuery);
132
- }
133
-
105
+ export declare function buildExcludeField(query: string, field: string): Field;
134
106
  /**
135
107
  * This function builds an operand to be used in a lucene query.
136
108
  * We need to format the operand before adding it to the query.
@@ -152,12 +124,7 @@ export function buildExcludeField(query: string, field: string): Field {
152
124
  * @param {OPERAND} operand
153
125
  * @return {*} {Operand}
154
126
  */
155
- export function buildOperand(query: string, operand: OPERAND): Operand {
156
- const newQuery = query + ` ${operand} `;
157
-
158
- return new Operand(newQuery);
159
- }
160
-
127
+ export declare function buildOperand(query: string, operand: OPERAND): Operand;
161
128
  /**
162
129
  * This function builds a NOT operand to be used in a lucene query.
163
130
  * We need to format the operand before adding it to the query.
@@ -172,8 +139,4 @@ export function buildOperand(query: string, operand: OPERAND): Operand {
172
139
  * @param {string} query
173
140
  * @return {*} {NotOperand}
174
141
  */
175
- export function buildNotOperand(query: string): NotOperand {
176
- const newQuery = query + ` ${OPERAND.NOT} `;
177
-
178
- return new NotOperand(newQuery);
179
- }
142
+ export declare function buildNotOperand(query: string): NotOperand;
@@ -1,7 +1,5 @@
1
1
  import { RequestOptions } from '@dotcms/types';
2
-
3
2
  import { CollectionBuilder } from './builders/collection/collection';
4
-
5
3
  /**
6
4
  * Creates a builder to filter and fetch a collection of content items.
7
5
  * @param contentType - The content type to retrieve.
@@ -51,20 +49,14 @@ import { CollectionBuilder } from './builders/collection/collection';
51
49
  * });
52
50
  * ```
53
51
  */
54
- export class Content {
55
- #requestOptions: RequestOptions;
56
- #serverUrl: string;
57
-
52
+ export declare class Content {
53
+ #private;
58
54
  /**
59
55
  * Creates an instance of Content.
60
56
  * @param {RequestOptions} requestOptions - The options for the client request.
61
57
  * @param {string} serverUrl - The server URL.
62
58
  */
63
- constructor(requestOptions: RequestOptions, serverUrl: string) {
64
- this.#requestOptions = requestOptions;
65
- this.#serverUrl = serverUrl;
66
- }
67
-
59
+ constructor(requestOptions: RequestOptions, serverUrl: string);
68
60
  /**
69
61
  * Takes a content type and returns a builder to filter and fetch the collection.
70
62
  * @param {string} contentType - The content type to get the collection.
@@ -130,7 +122,5 @@ export class Content {
130
122
  * ```
131
123
  *
132
124
  */
133
- getCollection<T = unknown>(contentType: string): CollectionBuilder<T> {
134
- return new CollectionBuilder<T>(this.#requestOptions, this.#serverUrl, contentType);
135
- }
125
+ getCollection<T = unknown>(contentType: string): CollectionBuilder<T>;
136
126
  }
@@ -1,15 +1,13 @@
1
1
  /**
2
2
  * Default variant identifier used in the application.
3
3
  */
4
- export const DEFAULT_VARIANT_ID = 'DEFAULT';
5
-
4
+ export declare const DEFAULT_VARIANT_ID = "DEFAULT";
6
5
  /**
7
6
  * Fields that should not be formatted when sanitizing the query.
8
7
  * These fields are essential for maintaining the integrity of the content type.
9
8
  */
10
- export const CONTENT_TYPE_MAIN_FIELDS: string[] = ['live', 'variant', 'contentType', 'languageId'];
11
-
9
+ export declare const CONTENT_TYPE_MAIN_FIELDS: string[];
12
10
  /**
13
11
  * URL endpoint for the content API search functionality.
14
12
  */
15
- export const CONTENT_API_URL = '/api/content/_search';
13
+ export declare const CONTENT_API_URL = "/api/content/_search";
@@ -1,8 +1,6 @@
1
1
  import { Contentlet } from '@dotcms/types';
2
-
3
2
  import { Equals } from '../builders/query/lucene-syntax';
4
3
  import { QueryBuilder } from '../builders/query/query';
5
-
6
4
  /**
7
5
  * Model to sort by fields.
8
6
  */
@@ -16,7 +14,6 @@ export type SortBy = {
16
14
  */
17
15
  order: 'asc' | 'desc';
18
16
  };
19
-
20
17
  /**
21
18
  * Callback to build a query.
22
19
  *
@@ -25,7 +22,6 @@ export type SortBy = {
25
22
  * @returns {Equals} The built query.
26
23
  */
27
24
  export type BuildQuery = (qb: QueryBuilder) => Equals;
28
-
29
25
  /**
30
26
  * Callback for a fulfilled promise.
31
27
  *
@@ -34,13 +30,7 @@ export type BuildQuery = (qb: QueryBuilder) => Equals;
34
30
  * @param {GetCollectionResponse<T>} value - The response value.
35
31
  * @returns {GetCollectionResponse<T> | PromiseLike<GetCollectionResponse<T>> | void} The processed response or a promise.
36
32
  */
37
- export type OnFullfilled<T> =
38
- | ((
39
- value: GetCollectionResponse<T>
40
- ) => GetCollectionResponse<T> | PromiseLike<GetCollectionResponse<T>> | void)
41
- | undefined
42
- | null;
43
-
33
+ export type OnFullfilled<T> = ((value: GetCollectionResponse<T>) => GetCollectionResponse<T> | PromiseLike<GetCollectionResponse<T>> | void) | undefined | null;
44
34
  /**
45
35
  * Callback for a rejected promise.
46
36
  *
@@ -48,11 +38,7 @@ export type OnFullfilled<T> =
48
38
  * @param {GetCollectionError} error - The error object.
49
39
  * @returns {GetCollectionError | PromiseLike<GetCollectionError> | void} The processed error or a promise.
50
40
  */
51
- export type OnRejected =
52
- | ((error: GetCollectionError) => GetCollectionError | PromiseLike<GetCollectionError> | void)
53
- | undefined
54
- | null;
55
-
41
+ export type OnRejected = ((error: GetCollectionError) => GetCollectionError | PromiseLike<GetCollectionError> | void) | undefined | null;
56
42
  /**
57
43
  * Response of the get collection method.
58
44
  *
@@ -80,7 +66,6 @@ export interface GetCollectionResponse<T> {
80
66
  */
81
67
  sortedBy?: SortBy[];
82
68
  }
83
-
84
69
  /**
85
70
  * Raw response of the get collection method.
86
71
  *
@@ -100,7 +85,6 @@ export interface GetCollectionRawResponse<T> {
100
85
  resultsSize: number;
101
86
  };
102
87
  }
103
-
104
88
  /**
105
89
  * Error object for the get collection method.
106
90
  */
@@ -1,5 +1,3 @@
1
- import { CONTENT_TYPE_MAIN_FIELDS } from './const';
2
-
3
1
  /**
4
2
  * @description
5
3
  * Sanitizes the query for the given content type.
@@ -19,10 +17,4 @@ import { CONTENT_TYPE_MAIN_FIELDS } from './const';
19
17
  * @param {string} contentType - The content type to be used for formatting the fields.
20
18
  * @returns {string} The sanitized query string.
21
19
  */
22
- export function sanitizeQueryForContentType(query: string, contentType: string): string {
23
- return query.replace(/\+([^+:]*?):/g, (original, field) => {
24
- return !CONTENT_TYPE_MAIN_FIELDS.includes(field) // Fields that are not content type fields
25
- ? `+${contentType}.${field}:` // Should have this format: +contentTypeVar.field:
26
- : original; // Return the field if it is a content type field
27
- });
28
- }
20
+ export declare function sanitizeQueryForContentType(query: string, contentType: string): string;
@@ -9,11 +9,4 @@
9
9
  * @property {string} 502 - Bad Gateway. Try again later.
10
10
  * @property {string} 503 - Service Unavailable. Try again later.
11
11
  */
12
- export const ErrorMessages: Record<number, string> = {
13
- 401: 'Unauthorized. Check the token and try again.',
14
- 403: 'Forbidden. Check the permissions and try again.',
15
- 404: 'Not Found. Check the URL and try again.',
16
- 500: 'Internal Server Error. Try again later.',
17
- 502: 'Bad Gateway. Try again later.',
18
- 503: 'Service Unavailable. Try again later.'
19
- };
12
+ export declare const ErrorMessages: Record<number, string>;
@@ -0,0 +1,14 @@
1
+ import { DotCMSClientConfig, DotCMSNavigationRequestParams, RequestOptions, DotCMSNavigationItem } from '@dotcms/types';
2
+ export declare class NavigationClient {
3
+ private requestOptions;
4
+ private BASE_URL;
5
+ constructor(config: DotCMSClientConfig, requestOptions: RequestOptions);
6
+ /**
7
+ * Retrieves information about the dotCMS file and folder tree.
8
+ * @param {NavigationApiOptions} options - The options for the Navigation API call. Defaults to `{ depth: 0, path: '/', languageId: 1 }`.
9
+ * @returns {Promise<DotCMSNavigationItem[]>} - A Promise that resolves to the response from the DotCMS API.
10
+ * @throws {Error} - Throws an error if the options are not valid.
11
+ */
12
+ get(path: string, params?: DotCMSNavigationRequestParams): Promise<DotCMSNavigationItem[]>;
13
+ private mapToBackendParams;
14
+ }