@dotcms/client 1.2.1 → 1.2.2-next.1
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/README.md +61 -0
- package/index.cjs.js +513 -223
- package/index.esm.js +513 -223
- package/package.json +5 -5
- package/src/lib/client/ai/ai-api.d.ts +1 -1
- package/src/lib/client/ai/search/search.d.ts +1 -1
- package/src/lib/client/ai/shared/types.d.ts +5 -4
- package/src/lib/client/base/builder/base-builder.d.ts +200 -0
- package/src/lib/client/content/builders/collection/collection.d.ts +27 -126
- package/src/lib/client/content/builders/raw-query/raw-query.builder.d.ts +75 -0
- package/src/lib/client/content/content-api.d.ts +85 -1
- package/src/lib/client/content/shared/types.d.ts +5 -4
- package/src/lib/client/navigation/navigation-api.d.ts +1 -1
- package/src/lib/client/page/page-api.d.ts +1 -1
- package/index.esm.d.ts +0 -1
- package/internal.esm.d.ts +0 -1
- /package/{index.cjs.d.ts → index.d.ts} +0 -0
- /package/{internal.cjs.d.ts → internal.d.ts} +0 -0
- /package/src/lib/client/base/{base-api.d.ts → api/base-api.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -32,6 +32,7 @@ The `@dotcms/client` is a powerful JavaScript/TypeScript SDK designed to simplif
|
|
|
32
32
|
- [How-to Guides](#how-to-guides)
|
|
33
33
|
- [How to Fetch Complete Pages](#how-to-fetch-complete-pages)
|
|
34
34
|
- [How to Query Content Collections](#how-to-query-content-collections)
|
|
35
|
+
- [How to Run Raw Lucene Content Queries](#how-to-run-raw-lucene-content-queries)
|
|
35
36
|
- [How to Use AI-Powered Search](#how-to-use-ai-powered-search)
|
|
36
37
|
- [How to Work with GraphQL](#how-to-work-with-graphql)
|
|
37
38
|
- [How to Use with TypeScript](#how-to-use-with-typescript)
|
|
@@ -41,6 +42,7 @@ The `@dotcms/client` is a powerful JavaScript/TypeScript SDK designed to simplif
|
|
|
41
42
|
- [HTTP Client Configuration](#http-client-configuration)
|
|
42
43
|
- [page.get() Method](#pageget-method)
|
|
43
44
|
- [content.getCollection() Method](#contentgetcollection-method)
|
|
45
|
+
- [content.query() Method](#contentquery-method)
|
|
44
46
|
- [ai.search() Method](#aisearch-method)
|
|
45
47
|
- [navigation.get() Method](#navigationget-method)
|
|
46
48
|
- [Error Handling](#error-handling)
|
|
@@ -218,6 +220,31 @@ const products = await client.content
|
|
|
218
220
|
.limit(10);
|
|
219
221
|
```
|
|
220
222
|
|
|
223
|
+
### How to Run Raw Lucene Content Queries
|
|
224
|
+
|
|
225
|
+
Use `client.content.query()` when you want to execute a **raw Lucene query string** (without the query-builder DSL), and you want full control over constraints like `contentType`, `live`, `languageId`, `conhost`, etc.
|
|
226
|
+
|
|
227
|
+
> [!NOTE]
|
|
228
|
+
> `content.query()` does **not** prefix fields with `contentType.` (unlike `getCollection()`), and it does **not** inject system constraints into your query string.
|
|
229
|
+
|
|
230
|
+
#### Basic Raw Query
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
const response = await client.content
|
|
234
|
+
.query('+contentType:Blog +title:"Hello World"')
|
|
235
|
+
.limit(10)
|
|
236
|
+
.page(1);
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
#### Setting Language (request body)
|
|
240
|
+
|
|
241
|
+
```typescript
|
|
242
|
+
const response = await client.content
|
|
243
|
+
.query('+contentType:Blog +title:"Hello World"')
|
|
244
|
+
.language(1) // sets languageId in the request body (does not alter the Lucene string)
|
|
245
|
+
.limit(10);
|
|
246
|
+
```
|
|
247
|
+
|
|
221
248
|
### How to Use AI-Powered Search
|
|
222
249
|
|
|
223
250
|
> [!WARNING]
|
|
@@ -770,6 +797,40 @@ getCollection<T = DotCMSBasicContentlet>(
|
|
|
770
797
|
const blogs = await client.content.getCollection('Blog').limit(10).page(1);
|
|
771
798
|
```
|
|
772
799
|
|
|
800
|
+
### content.query() Method
|
|
801
|
+
|
|
802
|
+
```typescript
|
|
803
|
+
query<T = DotCMSBasicContentlet>(
|
|
804
|
+
rawQuery: string
|
|
805
|
+
): RawQueryBuilder<T>
|
|
806
|
+
```
|
|
807
|
+
|
|
808
|
+
#### Parameters
|
|
809
|
+
|
|
810
|
+
| Parameter | Type | Required | Description |
|
|
811
|
+
| ---------- | -------- | -------- | ---------------------- |
|
|
812
|
+
| `rawQuery` | `string` | ✅ | Raw Lucene query string |
|
|
813
|
+
|
|
814
|
+
#### Builder Methods
|
|
815
|
+
|
|
816
|
+
| Method | Arguments | Description |
|
|
817
|
+
| ------------ | ------------------ | --------------------------------------------------------------------------- |
|
|
818
|
+
| `limit()` | `number` | Set number of items to return |
|
|
819
|
+
| `page()` | `number` | Set which page of results to fetch |
|
|
820
|
+
| `sortBy()` | `SortBy[]` | Sort by one or more fields |
|
|
821
|
+
| `render()` | - | Enable server-side rendering (velocity) for widgets in returned content |
|
|
822
|
+
| `depth()` | `number` | Set depth of related content |
|
|
823
|
+
| `language()` | `number \| string` | Set `languageId` in the request body (does not modify the raw Lucene string) |
|
|
824
|
+
|
|
825
|
+
#### Example
|
|
826
|
+
|
|
827
|
+
```typescript
|
|
828
|
+
const response = await client.content
|
|
829
|
+
.query('+contentType:Blog +title:"Hello World"')
|
|
830
|
+
.language(1)
|
|
831
|
+
.limit(10);
|
|
832
|
+
```
|
|
833
|
+
|
|
773
834
|
### ai.search() Method
|
|
774
835
|
|
|
775
836
|
> [!WARNING]
|