@dotcms/client 0.0.1-alpha.36 → 0.0.1-alpha.38

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.
@@ -1,7 +1,29 @@
1
1
  import { Equals, Field } from './lucene-syntax/index';
2
2
  /**
3
3
  * 'QueryBuilder' Is a Typescript class that provides the ability to build a query string using the Lucene syntax in a more readable way.
4
+ * @example
5
+ * ```ts
6
+ * const qb = new QueryBuilder();
7
+ * const query = qb
8
+ * .field('contentType')
9
+ * .equals('Blog')
10
+ * .field('conhost')
11
+ * .equals('my-super-cool-site')
12
+ * .build(); // Output: `+contentType:Blog +conhost:my-super-cool-site"`
13
+ * ```
4
14
  *
15
+ * @example
16
+ * ```ts
17
+ * const qb = new QueryBuilder();
18
+ * const query = qb
19
+ * .field('contentType')
20
+ * .equals('Blog')
21
+ * .field('title')
22
+ * .equals('Football')
23
+ * .excludeField('summary')
24
+ * .equals('Lionel Messi')
25
+ * .build(); // Output: `+contentType:Blog +title:Football -summary:"Lionel Messi"`
26
+ * ```
5
27
  * @export
6
28
  * @class QueryBuilder
7
29
  */
@@ -10,7 +32,11 @@ export declare class QueryBuilder {
10
32
  /**
11
33
  * This method appends to the query a field that should be included in the search.
12
34
  *
13
- * Ex: "+myField:"
35
+ * @example
36
+ * ```ts
37
+ * const qb = new QueryBuilder();
38
+ * qb.field("+myField: ", "myValue"); // Current query: "+myField: myValue"
39
+ * ```
14
40
  *
15
41
  * @param {string} field - The field that should be included in the search.
16
42
  * @return {*} {Field} - An instance of a Lucene Field. A field is a key used to search for a specific value in a document.
@@ -20,7 +46,11 @@ export declare class QueryBuilder {
20
46
  /**
21
47
  * This method appends to the query a field that should be excluded from the search.
22
48
  *
23
- * Ex: "-myField:"
49
+ * @example
50
+ * ```ts
51
+ * const qb = new QueryBuilder();
52
+ * qb.excludeField("myField").equals("myValue"); // Current query: "-myField: myValue"
53
+ * ```
24
54
  *
25
55
  * @param {string} field - The field that should be excluded from the search.
26
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.
@@ -32,7 +62,11 @@ export declare class QueryBuilder {
32
62
  * This raw query should end in Equals.
33
63
  * This method is useful when you want to append a complex query or an already written query to the query builder.
34
64
  *
35
- * Ex: "+myField: value AND (someOtherValue OR anotherValue)"
65
+ * @example
66
+ * ```ts
67
+ * const qb = new QueryBuilder();
68
+ * qb.raw("+myField: value AND (someOtherValue OR anotherValue)"); // Current query: "+myField: value AND (someOtherValue OR anotherValue)"
69
+ * ```
36
70
  *
37
71
  * @param {string} query - A raw query string.
38
72
  * @return {*} {Equals} - An instance of Equals. A term is a value used to search for a specific value in a document.
@@ -16,6 +16,11 @@ export declare enum OPERAND {
16
16
  /**
17
17
  * This function removes extra spaces from a string.
18
18
  *
19
+ * @example
20
+ * ```ts
21
+ * sanitizeQuery(" my query "); // Output: "my query"
22
+ * ```
23
+ *
19
24
  * @export
20
25
  * @param {string} str
21
26
  * @return {*} {string}
@@ -25,6 +30,12 @@ export declare function sanitizeQuery(str: string): string;
25
30
  * This function sanitizes a term by adding quotes if it contains spaces.
26
31
  * In lucene, a term with spaces should be enclosed in quotes.
27
32
  *
33
+ * @example
34
+ * ```ts
35
+ * sanitizePhrases(`my term`); // Output: `"my term"`
36
+ * sanitizePhrases(`myterm`); // Output: `myterm`
37
+ * ```
38
+ *
28
39
  * @export
29
40
  * @param {string} term
30
41
  * @return {*} {string}
@@ -34,6 +45,11 @@ export declare function sanitizePhrases(term: string): string;
34
45
  * This function builds a term to be used in a lucene query.
35
46
  * We need to sanitize the term before adding it to the query.
36
47
  *
48
+ * @example
49
+ * ```ts
50
+ * const equals = buildEquals("+myField: ", "myValue"); // Current query: "+myField: myValue"
51
+ * ```
52
+ *
37
53
  * @export
38
54
  * @param {string} query
39
55
  * @param {string} term
@@ -44,6 +60,12 @@ export declare function buildEquals(query: string, term: string): Equals;
44
60
  * This function builds a term to be used in a lucene query.
45
61
  * We need to sanitize the raw query before adding it to the query.
46
62
  *
63
+ * @example
64
+ * ```ts
65
+ * const query = "+myField: myValue";
66
+ * const field = buildRawEquals(query, "-myField2: myValue2"); // Current query: "+myField: myValue -myField2: myValue"
67
+ * ```
68
+ *
47
69
  * @export
48
70
  * @param {string} query
49
71
  * @param {string} raw
@@ -54,6 +76,11 @@ export declare function buildRawEquals(query: string, raw: string): Equals;
54
76
  * This function builds a field to be used in a lucene query.
55
77
  * We need to format the field before adding it to the query.
56
78
  *
79
+ * @example
80
+ * ```ts
81
+ * const field = buildField("+myField: ", "myValue"); // Current query: "+myField: myValue"
82
+ * ```
83
+ *
57
84
  * @export
58
85
  * @param {string} query
59
86
  * @param {string} field
@@ -64,6 +91,12 @@ export declare function buildField(query: string, field: string): Field;
64
91
  * This function builds an exclude field to be used in a lucene query.
65
92
  * We need to format the field before adding it to the query.
66
93
  *
94
+ * @example
95
+ * ```ts
96
+ * const query = "+myField: myValue";
97
+ * const field = buildExcludeField(query, "myField2"); // Current query: "+myField: myValue -myField2:"
98
+ * ```
99
+ *
67
100
  * @export
68
101
  * @param {string} query
69
102
  * @param {string} field
@@ -74,6 +107,18 @@ export declare function buildExcludeField(query: string, field: string): Field;
74
107
  * This function builds an operand to be used in a lucene query.
75
108
  * We need to format the operand before adding it to the query.
76
109
  *
110
+ * @example
111
+ * <caption>E.g. Using the AND operand</caption>
112
+ * ```ts
113
+ * const query = "+myField: myValue";
114
+ * const field = buildOperand(query, OPERAND.AND); // Current query: "+myField: myValue AND"
115
+ * ```
116
+ * @example
117
+ * <caption>E.g. Using the OR operand</caption>
118
+ * ```ts
119
+ * const query = "+myField: myValue";
120
+ * const field = buildOperand(query, OPERAND.OR); // Current query: "+myField: myValue OR"
121
+ * ```
77
122
  * @export
78
123
  * @param {string} query
79
124
  * @param {OPERAND} operand
@@ -84,6 +129,12 @@ export declare function buildOperand(query: string, operand: OPERAND): Operand;
84
129
  * This function builds a NOT operand to be used in a lucene query.
85
130
  * We need to format the operand before adding it to the query.
86
131
  *
132
+ * @example
133
+ * ```ts
134
+ * const query = "+myField: myValue";
135
+ * const field = buildNotOperand(query); // Current query: "+myField: myValue NOT"
136
+ * ```
137
+ *
87
138
  * @export
88
139
  * @param {string} query
89
140
  * @return {*} {NotOperand}
@@ -1,11 +1,24 @@
1
- export declare const graphqlToPageEntity: ({ page }: {
1
+ /**
2
+ * Represents the response from a GraphQL query for a page.
3
+ *
4
+ * @interface GraphQLPageResponse
5
+ * @property {Record<string, unknown>} page - The main page data.
6
+ * @property {unknown} [key: string] - Additional properties that may be included in the response.
7
+ */
8
+ interface GraphQLPageResponse {
2
9
  page: Record<string, unknown>;
3
- }) => {
4
- layout: unknown;
5
- template: unknown;
6
- viewAs: unknown;
7
- urlContentMap: unknown;
8
- site: unknown;
9
- page: any;
10
- containers: Record<string, unknown>;
11
- } | null;
10
+ [key: string]: unknown;
11
+ }
12
+ /**
13
+ * Transforms a GraphQL Page response to a Page Entity.
14
+ *
15
+ * @param {GraphQLPageResponse} graphQLPageResponse - The GraphQL Page response object.
16
+ * @returns {object|null} The transformed Page Entity or null if the page is not present.
17
+ *
18
+ * @example
19
+ * ```ts
20
+ * const pageEntity = graphqlToPageEntity(graphQLPageResponse);
21
+ * ```
22
+ */
23
+ export declare const graphqlToPageEntity: (graphQLPageResponse: GraphQLPageResponse) => any;
24
+ export {};
@@ -1,11 +1,33 @@
1
- interface PageRequestParamsProps {
1
+ import { PageApiOptions } from '../../client/sdk-js-client';
2
+ /**
3
+ * Interface representing the properties for page request parameters.
4
+ *
5
+ * @export
6
+ * @interface PageRequestParamsProps
7
+ */
8
+ export interface PageRequestParamsProps {
9
+ /**
10
+ * The API endpoint path.
11
+ * @type {string}
12
+ */
2
13
  path: string;
14
+ /**
15
+ * The query parameters for the API request.
16
+ * Can be an object with key-value pairs or a URLSearchParams instance.
17
+ * @type {{ [key: string]: unknown } | URLSearchParams}
18
+ */
3
19
  params: {
4
- [key: string]: any;
5
- } | undefined | URLSearchParams;
20
+ [key: string]: unknown;
21
+ } | URLSearchParams;
6
22
  }
7
- export declare const getPageRequestParams: ({ path, params }: PageRequestParamsProps) => {
8
- path: string;
9
- [key: string]: string | number;
10
- };
11
- export {};
23
+ /**
24
+ * Generates the page request parameters to be used in the API call.
25
+ *
26
+ * @param {PageRequestParamsProps} PageRequestParamsProps - The properties for the page request.
27
+ * @returns {PageApiOptions} The options for the page API.
28
+ * @example
29
+ * ```ts
30
+ * const pageApiOptions = getPageRequestParams({ path: '/api/v1/page', params: queryParams });
31
+ * ```
32
+ */
33
+ export declare const getPageRequestParams: ({ path, params }: PageRequestParamsProps) => PageApiOptions;