@dotcms/client 0.0.1-alpha.9 → 0.0.1-beta.10

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 (74) hide show
  1. package/README.md +166 -19
  2. package/index.cjs.d.ts +1 -0
  3. package/index.cjs.default.js +1 -0
  4. package/index.cjs.js +914 -0
  5. package/index.cjs.mjs +2 -0
  6. package/index.esm.d.ts +1 -0
  7. package/index.esm.js +903 -0
  8. package/next.cjs.d.ts +1 -0
  9. package/next.cjs.default.js +1 -0
  10. package/next.cjs.js +553 -0
  11. package/next.cjs.mjs +2 -0
  12. package/next.esm.d.ts +1 -0
  13. package/next.esm.js +551 -0
  14. package/package.json +59 -23
  15. package/src/index.d.ts +8 -0
  16. package/src/lib/client/client.d.ts +84 -0
  17. package/src/lib/client/content/builders/collection/collection.d.ts +226 -0
  18. package/src/lib/client/content/builders/query/lucene-syntax/Equals.d.ts +114 -0
  19. package/src/lib/client/content/builders/query/lucene-syntax/Field.d.ts +32 -0
  20. package/src/lib/client/content/builders/query/lucene-syntax/NotOperand.d.ts +26 -0
  21. package/src/lib/client/content/builders/query/lucene-syntax/Operand.d.ts +44 -0
  22. package/src/lib/client/content/builders/query/lucene-syntax/index.d.ts +4 -0
  23. package/src/lib/client/content/builders/query/query.d.ts +76 -0
  24. package/src/lib/client/content/builders/query/utils/index.d.ts +142 -0
  25. package/src/lib/client/content/content-api.d.ts +129 -0
  26. package/src/lib/client/content/shared/const.d.ts +13 -0
  27. package/src/lib/client/content/shared/types.d.ts +138 -0
  28. package/src/lib/client/content/shared/utils.d.ts +20 -0
  29. package/src/lib/client/models/index.d.ts +12 -0
  30. package/src/lib/client/models/types.d.ts +516 -0
  31. package/src/lib/client/navigation/navigation-api.d.ts +31 -0
  32. package/src/lib/client/page/page-api.d.ts +165 -0
  33. package/src/lib/client/page/utils.d.ts +41 -0
  34. package/src/lib/deprecated/editor/listeners/listeners.d.ts +45 -0
  35. package/src/lib/deprecated/editor/models/client.model.d.ts +111 -0
  36. package/src/lib/deprecated/editor/models/editor.model.d.ts +62 -0
  37. package/src/lib/deprecated/editor/models/inline-event.model.d.ts +9 -0
  38. package/src/lib/{editor/models/listeners.model.ts → deprecated/editor/models/listeners.model.d.ts} +17 -8
  39. package/src/lib/deprecated/editor/sdk-editor-vtl.d.ts +1 -0
  40. package/src/lib/deprecated/editor/sdk-editor.d.ts +92 -0
  41. package/src/lib/deprecated/editor/utils/editor.utils.d.ts +159 -0
  42. package/src/lib/deprecated/editor/utils/traditional-vtl.utils.d.ts +4 -0
  43. package/src/lib/deprecated/sdk-js-client.d.ts +276 -0
  44. package/src/lib/utils/graphql/transforms.d.ts +24 -0
  45. package/src/lib/utils/index.d.ts +2 -0
  46. package/src/lib/utils/page/common-utils.d.ts +33 -0
  47. package/src/next.d.ts +1 -0
  48. package/src/types.d.ts +2 -0
  49. package/transforms.cjs.js +1145 -0
  50. package/transforms.esm.js +1139 -0
  51. package/types.cjs.d.ts +1 -0
  52. package/types.cjs.default.js +1 -0
  53. package/types.cjs.js +2 -0
  54. package/types.cjs.mjs +2 -0
  55. package/types.esm.d.ts +1 -0
  56. package/types.esm.js +1 -0
  57. package/.eslintrc.json +0 -18
  58. package/jest.config.ts +0 -15
  59. package/project.json +0 -63
  60. package/src/index.ts +0 -4
  61. package/src/lib/client/sdk-js-client.spec.ts +0 -258
  62. package/src/lib/client/sdk-js-client.ts +0 -297
  63. package/src/lib/editor/listeners/listeners.spec.ts +0 -55
  64. package/src/lib/editor/listeners/listeners.ts +0 -200
  65. package/src/lib/editor/models/client.model.ts +0 -55
  66. package/src/lib/editor/models/editor.model.ts +0 -17
  67. package/src/lib/editor/sdk-editor-vtl.ts +0 -24
  68. package/src/lib/editor/sdk-editor.spec.ts +0 -95
  69. package/src/lib/editor/sdk-editor.ts +0 -70
  70. package/src/lib/editor/utils/editor.utils.spec.ts +0 -164
  71. package/src/lib/editor/utils/editor.utils.ts +0 -151
  72. package/tsconfig.json +0 -22
  73. package/tsconfig.lib.json +0 -10
  74. package/tsconfig.spec.json +0 -9
@@ -0,0 +1,84 @@
1
+ import { Content } from './content/content-api';
2
+ import { NavigationClient } from './navigation/navigation-api';
3
+ import { PageClient } from './page/page-api';
4
+ /**
5
+ * Options for configuring fetch requests, excluding body and method properties.
6
+ */
7
+ export type RequestOptions = Omit<RequestInit, 'body' | 'method'>;
8
+ /**
9
+ * Configuration options for the DotCMS client.
10
+ */
11
+ export interface DotCMSClientConfig {
12
+ /**
13
+ * The URL of the dotCMS instance.
14
+ * Ensure to include the protocol (http or https).
15
+ * @example `https://demo.dotcms.com`
16
+ */
17
+ dotcmsUrl: string;
18
+ /**
19
+ * The authentication token for requests.
20
+ * Obtainable from the dotCMS UI.
21
+ */
22
+ authToken: string;
23
+ /**
24
+ * The id of the site you want to interact with. Defaults to the default site if not provided.
25
+ */
26
+ siteId?: string;
27
+ /**
28
+ * Additional options for the fetch request.
29
+ * @example `{ headers: { 'Content-Type': 'application/json' } }`
30
+ */
31
+ requestOptions?: RequestOptions;
32
+ }
33
+ /**
34
+ * Client for interacting with the DotCMS REST API.
35
+ * Provides access to content, page, and navigation functionality.
36
+ */
37
+ declare class DotCMSClient {
38
+ private config;
39
+ private requestOptions;
40
+ /**
41
+ * Client for content-related operations.
42
+ */
43
+ content: Content;
44
+ /**
45
+ * Client for page-related operations.
46
+ */
47
+ page: PageClient;
48
+ /**
49
+ * Client for navigation-related operations.
50
+ */
51
+ nav: NavigationClient;
52
+ /**
53
+ * Creates a new DotCMS client instance.
54
+ *
55
+ * @param config - Configuration options for the client
56
+ * @throws Warning if dotcmsUrl is invalid or authToken is missing
57
+ */
58
+ constructor(config?: DotCMSClientConfig);
59
+ /**
60
+ * Creates request options with authentication headers.
61
+ *
62
+ * @param config - The client configuration
63
+ * @returns Request options with authorization headers
64
+ */
65
+ private createAuthenticatedRequestOptions;
66
+ }
67
+ /**
68
+ * Creates and returns a new DotCMS client instance.
69
+ *
70
+ * @param config - Configuration options for the client
71
+ * @returns A configured DotCMS client instance
72
+ * @example
73
+ * ```typescript
74
+ * const client = dotCMSCreateClient({
75
+ * dotcmsUrl: 'https://demo.dotcms.com',
76
+ * authToken: 'your-auth-token'
77
+ * });
78
+ *
79
+ * // Use the client to fetch content
80
+ * const pages = await client.page.get('/about-us');
81
+ * ```
82
+ */
83
+ export declare const createDotCMSClient: (clientConfig: DotCMSClientConfig) => DotCMSClient;
84
+ export {};
@@ -0,0 +1,226 @@
1
+ import { ClientOptions } from '../../../../deprecated/sdk-js-client';
2
+ import { GetCollectionResponse, BuildQuery, SortBy, GetCollectionError, OnFullfilled, OnRejected } from '../../shared/types';
3
+ /**
4
+ * Creates a Builder to filter and fetch content from the content API for a specific content type.
5
+ *
6
+ * @export
7
+ * @class CollectionBuilder
8
+ * @template T Represents the type of the content type to fetch. Defaults to unknown.
9
+ */
10
+ export declare class CollectionBuilder<T = unknown> {
11
+ #private;
12
+ /**
13
+ * Creates an instance of CollectionBuilder.
14
+ * @param {ClientOptions} requestOptions Options for the client request.
15
+ * @param {string} serverUrl The server URL.
16
+ * @param {string} contentType The content type to fetch.
17
+ * @memberof CollectionBuilder
18
+ */
19
+ constructor(requestOptions: ClientOptions, serverUrl: string, contentType: string);
20
+ /**
21
+ * Returns the sort query in the format: field order, field order, ...
22
+ *
23
+ * @readonly
24
+ * @private
25
+ * @memberof CollectionBuilder
26
+ */
27
+ private get sort();
28
+ /**
29
+ * Returns the offset for pagination.
30
+ *
31
+ * @readonly
32
+ * @private
33
+ * @memberof CollectionBuilder
34
+ */
35
+ private get offset();
36
+ /**
37
+ * Returns the full URL for the content API.
38
+ *
39
+ * @readonly
40
+ * @private
41
+ * @memberof CollectionBuilder
42
+ */
43
+ private get url();
44
+ /**
45
+ * Returns the current query built.
46
+ *
47
+ * @readonly
48
+ * @private
49
+ * @memberof CollectionBuilder
50
+ */
51
+ private get currentQuery();
52
+ /**
53
+ * Filters the content by the specified language ID.
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * const client = new DotCMSClient(config);
58
+ * const collectionBuilder = client.content.getCollection("Blog");
59
+ * collectionBuilder.language(1);
60
+ * ```
61
+ *
62
+ * @param {number | string} languageId The language ID to filter the content by.
63
+ * @return {CollectionBuilder} A CollectionBuilder instance.
64
+ * @memberof CollectionBuilder
65
+ */
66
+ language(languageId: number | string): this;
67
+ /**
68
+ * Setting this to true will server side render (using velocity) any widgets that are returned by the content query.
69
+ *
70
+ * More information here: {@link https://www.dotcms.com/docs/latest/content-api-retrieval-and-querying#ParamsOptional}
71
+ *
72
+ * @return {CollectionBuilder} A CollectionBuilder instance.
73
+ * @memberof CollectionBuilder
74
+ */
75
+ render(): this;
76
+ /**
77
+ * Sorts the content by the specified fields and orders.
78
+ *
79
+ * @example
80
+ * ```typescript
81
+ * const client = new DotCMSClient(config);
82
+ * const collectionBuilder = client.content.getCollection("Blog");
83
+ * const sortBy = [{ field: 'title', order: 'asc' }, { field: 'modDate', order: 'desc' }];
84
+ * collectionBuilder("Blog").sortBy(sortBy);
85
+ * ```
86
+ *
87
+ * @param {SortBy[]} sortBy Array of constraints to sort the content by.
88
+ * @return {CollectionBuilder} A CollectionBuilder instance.
89
+ * @memberof CollectionBuilder
90
+ */
91
+ sortBy(sortBy: SortBy[]): this;
92
+ /**
93
+ * Sets the maximum amount of content to fetch.
94
+ *
95
+ * @param {number} limit The maximum amount of content to fetch.
96
+ * @return {CollectionBuilder} A CollectionBuilder instance.
97
+ * @memberof CollectionBuilder
98
+ */
99
+ limit(limit: number): this;
100
+ /**
101
+ * Sets the page number to fetch.
102
+ *
103
+ * @param {number} page The page number to fetch.
104
+ * @return {CollectionBuilder} A CollectionBuilder instance.
105
+ * @memberof CollectionBuilder
106
+ */
107
+ page(page: number): this;
108
+ /**
109
+ * Filters the content by a Lucene query string.
110
+ *
111
+ * @param {string} query A Lucene query string.
112
+ * @return {CollectionBuilder} A CollectionBuilder instance.
113
+ * @memberof CollectionBuilder
114
+ */
115
+ query(query: string): this;
116
+ /**
117
+ * Filters the content by building a query using a QueryBuilder function.
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * const client = new DotCMSClient(config);
122
+ * const collectionBuilder = client.content.getCollection("Blog");
123
+ * collectionBuilder.query((queryBuilder) =>
124
+ * queryBuilder.field('title').equals('Hello World').or().equals('Hello World 2')
125
+ * );
126
+ * ```
127
+ *
128
+ * @param {BuildQuery} buildQuery A function that receives a QueryBuilder instance and returns a valid query.
129
+ * @return {CollectionBuilder} A CollectionBuilder instance.
130
+ * @memberof CollectionBuilder
131
+ */
132
+ query(buildQuery: BuildQuery): this;
133
+ /**
134
+ * Retrieves draft content.
135
+ * @example
136
+ * ```ts
137
+ * const client = new DotCMSClient(config);
138
+ * const collectionBuilder = client.content.getCollection("Blog");
139
+ * collectionBuilder
140
+ * .draft() // This will retrieve draft/working content
141
+ * .then((response) => // Your code here })
142
+ * .catch((error) => // Your code here })
143
+ * ```
144
+ *
145
+ * @return {CollectionBuilder} A CollectionBuilder instance.
146
+ * @memberof CollectionBuilder
147
+ */
148
+ draft(): this;
149
+ /**
150
+ * Filters the content by a variant ID for [Experiments](https://www.dotcms.com/docs/latest/experiments-and-a-b-testing)
151
+ *
152
+ * More information here: {@link https://www.dotcms.com/docs/latest/content-api-retrieval-and-querying#ParamsOptional}
153
+ *
154
+ * @example
155
+ * ```ts
156
+ * const client = new DotCMSClient(config);
157
+ * const collectionBuilder = client.content.getCollection("Blog");
158
+ * collectionBuilder
159
+ * .variant("YOUR_VARIANT_ID")
160
+ * .then((response) => // Your code here })
161
+ * .catch((error) => // Your code here })
162
+ * ```
163
+ *
164
+ * @param {string} variantId A string that represents a variant ID.
165
+ * @return {CollectionBuilder} A CollectionBuilder instance.
166
+ * @memberof CollectionBuilder
167
+ */
168
+ variant(variantId: string): this;
169
+ /**
170
+ * Sets the depth of the relationships of the content.
171
+ * Specifies the depth of related content to return in the results.
172
+ *
173
+ * More information here: {@link https://www.dotcms.com/docs/latest/content-api-retrieval-and-querying#ParamsOptional}
174
+ *
175
+ * @example
176
+ * ```ts
177
+ * const client = new DotCMSClient(config);
178
+ * const collectionBuilder = client.content.getCollection("Blog");
179
+ * collectionBuilder
180
+ * .depth(1)
181
+ * .then((response) => // Your code here })
182
+ * .catch((error) => // Your code here })
183
+ * ```
184
+ *
185
+ * @param {number} depth The depth of the relationships of the content.
186
+ * @return {CollectionBuilder} A CollectionBuilder instance.
187
+ * @memberof CollectionBuilder
188
+ */
189
+ depth(depth: number): this;
190
+ /**
191
+ * Executes the fetch and returns a promise that resolves to the content or rejects with an error.
192
+ *
193
+ * @example
194
+ * ```ts
195
+ * const client = new DotCMSClient(config);
196
+ * const collectionBuilder = client.content.getCollection("Blog");
197
+ * collectionBuilder
198
+ * .limit(10)
199
+ * .then((response) => // Your code here })
200
+ * .catch((error) => // Your code here })
201
+ * ```
202
+ *
203
+ * @param {OnFullfilled} [onfulfilled] A callback that is called when the fetch is successful.
204
+ * @param {OnRejected} [onrejected] A callback that is called when the fetch fails.
205
+ * @return {Promise<GetCollectionResponse<T> | GetCollectionError>} A promise that resolves to the content or rejects with an error.
206
+ * @memberof CollectionBuilder
207
+ */
208
+ then(onfulfilled?: OnFullfilled<T>, onrejected?: OnRejected): Promise<GetCollectionResponse<T> | GetCollectionError>;
209
+ /**
210
+ * Formats the response to the desired format.
211
+ *
212
+ * @private
213
+ * @param {GetCollectionRawResponse<T>} data The raw response data.
214
+ * @return {GetCollectionResponse<T>} The formatted response.
215
+ * @memberof CollectionBuilder
216
+ */
217
+ private formatResponse;
218
+ /**
219
+ * Calls the content API to fetch the content.
220
+ *
221
+ * @private
222
+ * @return {Promise<Response>} The fetch response.
223
+ * @memberof CollectionBuilder
224
+ */
225
+ private fetch;
226
+ }
@@ -0,0 +1,114 @@
1
+ import { Field } from './Field';
2
+ import { NotOperand } from './NotOperand';
3
+ import { Operand } from './Operand';
4
+ /**
5
+ * 'Equal' Is a Typescript class that provides the ability to use terms in the lucene query string.
6
+ * A term is a value used to search for a specific value in a document. It can be a word or a phrase.
7
+ *
8
+ * Ex: myValue or "My Value"
9
+ *
10
+ * @export
11
+ * @class Equal
12
+ */
13
+ export declare class Equals {
14
+ #private;
15
+ private query;
16
+ constructor(query: string);
17
+ /**
18
+ * This method appends to the query a term that should be excluded in the search.
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const equals = new Equals("+myField: myValue");
23
+ * equals.excludeField("myField2").equals("myValue2"); // Current query: "+myField: myValue -myField2: myValue2"
24
+ * ```
25
+ *
26
+ * @param {string} field - The field that should be excluded in the search.
27
+ * @return {*} {Field} - An instance of a Lucene Field. A field is a key used to search for a specific value in a document.
28
+ * @memberof Equal
29
+ */
30
+ excludeField(field: string): Field;
31
+ /**
32
+ * This method appends to the query a field that should be included in the search.
33
+ *
34
+ * @example
35
+ * ```ts
36
+ * const equals = new Equals("+myField: myValue");
37
+ * equals.field("myField2").equals("myValue2"); // Current query: "+myField: myValue +myField2: myValue2"
38
+ *```
39
+ * @param {string} field - The field that should be included in the search.
40
+ * @return {*} {Field} - An instance of a Lucene Field. A field is a key used to search for a specific value in a document.
41
+ * @memberof Equal
42
+ */
43
+ field(field: string): Field;
44
+ /**
45
+ * This method appends to the query an operand to use logic operators in the query.
46
+ *
47
+ * @example
48
+ * @example
49
+ * ```ts
50
+ * const equals = new Equals("+myField: myValue");
51
+ * equals.or().field("myField2").equals("myValue2"); // Current query: "+myField: myValue OR +myField2: myValue2"
52
+ * ```
53
+ *
54
+ * @return {*} {Operand} - An instance of a Lucene Operand. An operand is a logical operator used to combine terms or phrases in a query.
55
+ * @memberof Equal
56
+ */
57
+ or(): Operand;
58
+ /**
59
+ * This method appends to the query an operand to use logic operators in the query.
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * const equals = new Equals("+myField: myValue");
64
+ * equals.and().field("myField2").equals("myValue2"); // Current query: "+myField: myValue AND +myField2: myValue2"
65
+ * ```
66
+ *
67
+ * @return {*} {Operand} - An instance of a Lucene Operand. An operand is a logical operator used to combine terms or phrases in a query.
68
+ * @memberof Equal
69
+ */
70
+ and(): Operand;
71
+ /**
72
+ * This method appends to the query an operand to use logic operators in the query.
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * const equals = new Equals("+myField: myValue");
77
+ * equals.not().field("myField").equals("myValue2"); // Current query: "+myField: myValue NOT +myField: myValue2"
78
+ * ```
79
+ *
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.
81
+ * @memberof Equal
82
+ */
83
+ not(): NotOperand;
84
+ /**
85
+ * This method allows to pass a raw query string to the query builder.
86
+ * This raw query should end in a Lucene Equal.
87
+ * This method is useful when you want to append a complex query or an already written query to the query builder.
88
+ *
89
+ * @example
90
+ * ```ts
91
+ * // This builds the follow raw query "+myField: value AND (someOtherValue OR anotherValue)"
92
+ * const equals = new Equals("+myField: value");
93
+ * equals.raw("+myField2: value2"); // Current query: "+myField: value +myField2: anotherValue"
94
+ * ```
95
+ *
96
+ * @param {string} query - A raw query string.
97
+ * @return {*} {Equal} - An instance of a Lucene Equal. A term is a value used to search for a specific value in a document.
98
+ * @memberof QueryBuilder
99
+ */
100
+ raw(query: string): Equals;
101
+ /**
102
+ * This method returns the final query string.
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * const equals = new Equals("+myField: myValue");
107
+ * equals.field("myField2").equals("myValue2").build(); // Returns "+myField: myValue +myField2: myValue2"
108
+ * ```
109
+ *
110
+ * @return {*} {string} - The final query string.
111
+ * @memberof Equal
112
+ */
113
+ build(): string;
114
+ }
@@ -0,0 +1,32 @@
1
+ import { Equals } from './Equals';
2
+ /**
3
+ * The `Field` class is used to build a query with a specific field.
4
+ * A Lucene Field is a key used to search for a specific value in a document.
5
+ *
6
+ * @export
7
+ * @class Field
8
+ */
9
+ export declare class Field {
10
+ #private;
11
+ private query;
12
+ /**
13
+ * Creates an instance of the `Field` class.
14
+ *
15
+ * @param {string} query - The initial query string.
16
+ */
17
+ constructor(query: string);
18
+ /**
19
+ * Appends a term to the query that should be included in the search.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const field = new Field("+myField");
24
+ * field.equals("myValue");
25
+ * ```
26
+ *
27
+ * @param {string} term - The term that should be included in the search.
28
+ * @return {Equals} - An instance of `Equals`.
29
+ * @memberof Field
30
+ */
31
+ equals(term: string): Equals;
32
+ }
@@ -0,0 +1,26 @@
1
+ import { Equals } from './Equals';
2
+ /**
3
+ * 'NotOperand' Is a Typescript class that provides the ability to use the NOT operand in the lucene query string.
4
+ *
5
+ * @export
6
+ * @class NotOperand
7
+ */
8
+ export declare class NotOperand {
9
+ #private;
10
+ private query;
11
+ constructor(query: string);
12
+ /**
13
+ * This method appends to the query a term that should be included in the search.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const notOperand = new NotOperand("+myField");
18
+ * notOperand.equals("myValue");
19
+ * ```
20
+ *
21
+ * @param {string} term - The term that should be included in the search.
22
+ * @return {*} {Equals} - An instance of Equals.
23
+ * @memberof NotOperand
24
+ */
25
+ equals(term: string): Equals;
26
+ }
@@ -0,0 +1,44 @@
1
+ import { Equals } from './Equals';
2
+ import { Field } from './Field';
3
+ /**
4
+ * 'Operand' Is a Typescript class that provides the ability to use operands in the lucene query string.}
5
+ * An operand is a logical operator used to join two or more conditions in a query.
6
+ *
7
+ * @export
8
+ * @class Operand
9
+ */
10
+ export declare class Operand {
11
+ #private;
12
+ private query;
13
+ constructor(query: string);
14
+ /**
15
+ * This method appends to the query a term that should be excluded in the search.
16
+ *
17
+ * Ex: "-myValue"
18
+ *
19
+ * @param {string} field - The field that should be excluded in the search.
20
+ * @return {*} {Field} - An instance of a Lucene Field. A field is a key used to search for a specific value in a document.
21
+ * @memberof Operand
22
+ */
23
+ excludeField(field: string): Field;
24
+ /**
25
+ * This method appends to the query a field that should be included in the search.
26
+ *
27
+ * Ex: "+myField:"
28
+ *
29
+ * @param {string} field - The field that should be included in the search.
30
+ * @return {*} {Field} - An instance of a Lucene Field. A field is a key used to search for a specific value in a document.
31
+ * @memberof Operand
32
+ */
33
+ field(field: string): Field;
34
+ /**
35
+ * This method appends to the query a term that should be included in the search.
36
+ *
37
+ * Ex: myValue or "My value"
38
+ *
39
+ * @param {string} term - The term that should be included in the search.
40
+ * @return {*} {Equals} - An instance of Equals.
41
+ * @memberof Operand
42
+ */
43
+ equals(term: string): Equals;
44
+ }
@@ -0,0 +1,4 @@
1
+ export * from './Equals';
2
+ export * from './Field';
3
+ export * from './NotOperand';
4
+ export * from './Operand';
@@ -0,0 +1,76 @@
1
+ import { Equals, Field } from './lucene-syntax/index';
2
+ /**
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
+ * ```
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
+ * ```
27
+ * @export
28
+ * @class QueryBuilder
29
+ */
30
+ export declare class QueryBuilder {
31
+ #private;
32
+ /**
33
+ * This method appends to the query a field that should be included in the search.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * const qb = new QueryBuilder();
38
+ * qb.field("+myField: ", "myValue"); // Current query: "+myField: myValue"
39
+ * ```
40
+ *
41
+ * @param {string} field - The field that should be included in the search.
42
+ * @return {*} {Field} - An instance of a Lucene Field. A field is a key used to search for a specific value in a document.
43
+ * @memberof QueryBuilder
44
+ */
45
+ field(field: string): Field;
46
+ /**
47
+ * This method appends to the query a field that should be excluded from the search.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * const qb = new QueryBuilder();
52
+ * qb.excludeField("myField").equals("myValue"); // Current query: "-myField: myValue"
53
+ * ```
54
+ *
55
+ * @param {string} field - The field that should be excluded from the search.
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.
57
+ * @memberof QueryBuilder
58
+ */
59
+ excludeField(field: string): Field;
60
+ /**
61
+ * This method allows to pass a raw query string to the query builder.
62
+ * This raw query should end in Equals.
63
+ * This method is useful when you want to append a complex query or an already written query to the query builder.
64
+ *
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
+ * ```
70
+ *
71
+ * @param {string} query - A raw query string.
72
+ * @return {*} {Equals} - An instance of Equals. A term is a value used to search for a specific value in a document.
73
+ * @memberof QueryBuilder
74
+ */
75
+ raw(query: string): Equals;
76
+ }