@dotcms/types 1.1.1 → 1.2.0-next.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.
package/README.md CHANGED
@@ -1,34 +1,51 @@
1
- # DotCMS Type Definition Library
1
+ # dotCMS Types Library
2
+
3
+ The `@dotcms/types` package contains TypeScript type definitions for the dotCMS ecosystem. Use it to enable type safety and an enhanced developer experience when working with dotCMS APIs and structured content.
2
4
 
3
5
  📦 [@dotcms/types on npm](https://www.npmjs.com/package/@dotcms/types)
4
6
  🛠️ [View source on GitHub](https://github.com/dotCMS/core/tree/main/core-web/libs/sdk/types)
5
7
 
6
- ## Installation
7
-
8
- ```bash
9
- npm install @dotcms/types@latest --save-dev
10
- ```
11
-
12
- ## Overview
13
-
14
- This package contains TypeScript type definitions for the dotCMS ecosystem. Use it to enable type safety and an enhanced developer experience when working with dotCMS APIs and structured content.
15
-
16
8
  ## Table of Contents
17
9
 
18
- - [Installation](#installation)
19
10
  - [Overview](#overview)
11
+ - [Installation](#installation)
20
12
  - [Commonly Used Types](#commonly-used-types)
21
13
  - [Type Hierarchy (Jump to Definitions)](#type-hierarchy-jump-to-definitions)
14
+ - [AI Search](#ai-search)
22
15
  - [dotCMS Content & Pages](#dotcms-content--pages)
23
16
  - [Universal Visual Editor (UVE)](#universal-visual-editor-uve)
24
17
  - [Block Editor](#block-editor)
25
18
  - [Client & HTTP](#client--http)
26
19
  - [Error Handling](#error-handling)
27
- - [Type Usage](#type-usage)
20
+ - [Usage Examples](#usage-examples)
28
21
  - [Error Type Checking](#error-type-checking)
29
- - [About](#about)
22
+ - [Support](#support)
23
+ - [Contributing](#contributing)
24
+ - [Licensing](#licensing)
30
25
  - [Changelog](#changelog)
31
26
 
27
+ ## Overview
28
+
29
+ ### When to Use It
30
+
31
+ - Building TypeScript applications with dotCMS
32
+ - Enabling type safety in your dotCMS integrations
33
+ - Getting better IDE autocomplete and error checking
34
+ - Working with dotCMS Client SDK or other SDK packages
35
+
36
+ ### Key Benefits
37
+
38
+ - **Type Safety**: Catch errors at compile time instead of runtime
39
+ - **IDE Support**: Rich autocomplete and inline documentation
40
+ - **Better Developer Experience**: Clear interfaces for all dotCMS data structures
41
+ - **Framework Agnostic**: Works with any TypeScript project
42
+
43
+ ## Installation
44
+
45
+ ```bash
46
+ npm install @dotcms/types@latest --save-dev
47
+ ```
48
+
32
49
  ## Commonly Used Types
33
50
 
34
51
  ```ts
@@ -41,12 +58,42 @@ import {
41
58
  DotHttpError,
42
59
  DotErrorPage,
43
60
  DotErrorContent,
44
- DotErrorNavigation
61
+ DotErrorNavigation,
62
+ DotErrorAISearch,
63
+ DotCMSAISearchParams,
64
+ DISTANCE_FUNCTIONS
45
65
  } from '@dotcms/types';
46
66
  ```
47
67
 
48
68
  ## Type Hierarchy (Jump to Definitions)
49
69
 
70
+ ### AI Search
71
+
72
+ > **⚠️ Experimental:** The AI Search types are experimental and may undergo breaking changes in future releases.
73
+
74
+ **AI Search Parameters:**
75
+
76
+ | Type | Description |
77
+ |------|-------------|
78
+ | [DotCMSAISearchParams](https://github.com/dotCMS/core/blob/main/core-web/libs/sdk/types/src/lib/ai/public.ts#L85) | Complete AI search parameters including query and AI config |
79
+ | [DotCMSAISearchQuery](https://github.com/dotCMS/core/blob/main/core-web/libs/sdk/types/src/lib/ai/public.ts#L9) | Query parameters (limit, offset, contentType, etc.) |
80
+ | [DotCMSAIConfig](https://github.com/dotCMS/core/blob/main/core-web/libs/sdk/types/src/lib/ai/public.ts#L50) | AI configuration (threshold, distanceFunction, responseLength) |
81
+ | [DISTANCE_FUNCTIONS](https://github.com/dotCMS/core/blob/main/core-web/libs/sdk/types/src/lib/ai/public.ts#L103) | Available distance functions for vector similarity |
82
+
83
+ **AI Search Response:**
84
+
85
+ | Type | Description |
86
+ |------|-------------|
87
+ | [DotCMSAISearchResponse](https://github.com/dotCMS/core/blob/main/core-web/libs/sdk/types/src/lib/ai/public.ts#L182) | AI search API response structure |
88
+ | [DotCMSAISearchContentletData](https://github.com/dotCMS/core/blob/main/core-web/libs/sdk/types/src/lib/ai/public.ts#L213) | Contentlet with AI match information |
89
+ | [DotCMSAISearchMatch](https://github.com/dotCMS/core/blob/main/core-web/libs/sdk/types/src/lib/ai/public.ts#L195) | Individual match with distance score and extracted text |
90
+
91
+ **AI Search Errors:**
92
+
93
+ | Type | Description |
94
+ |------|-------------|
95
+ | [DotErrorAISearch](https://github.com/dotCMS/core/blob/main/core-web/libs/sdk/types/src/lib/ai/public.ts#L136) | AI Search API specific error with prompt, indexName and params context |
96
+
50
97
  ### dotCMS Content & Pages
51
98
 
52
99
  **Page:**
@@ -150,8 +197,9 @@ import {
150
197
  | [DotErrorPage](https://github.com/dotCMS/core/blob/main/core-web/libs/sdk/types/src/lib/page/public.ts#L1253) | Page API errors with GraphQL context |
151
198
  | [DotErrorContent](https://github.com/dotCMS/core/blob/main/core-web/libs/sdk/types/src/lib/content/public.ts#L7) | Content API specific error handling |
152
199
  | [DotErrorNavigation](https://github.com/dotCMS/core/blob/main/core-web/libs/sdk/types/src/lib/nav/public.ts#L7) | Navigation API error handling |
200
+ | [DotErrorAISearch](https://github.com/dotCMS/core/blob/main/core-web/libs/sdk/types/src/lib/ai/public.ts#L136) | AI Search API error handling with prompt and params |
153
201
 
154
- ## Type Usage
202
+ ## Usage Examples
155
203
 
156
204
  ### Error Type Checking
157
205
 
@@ -160,7 +208,8 @@ import {
160
208
  DotHttpError,
161
209
  DotErrorPage,
162
210
  DotErrorContent,
163
- DotErrorNavigation
211
+ DotErrorNavigation,
212
+ DotErrorAISearch
164
213
  } from '@dotcms/types';
165
214
 
166
215
  // Type-safe error handling
@@ -179,24 +228,63 @@ if (error instanceof DotErrorContent) {
179
228
  // Content-specific error context
180
229
  console.error(`${error.operation} failed for ${error.contentType}`);
181
230
  }
231
+
232
+ if (error instanceof DotErrorAISearch) {
233
+ // AI Search-specific error context
234
+ console.error('AI Search failed for prompt:', error.prompt);
235
+ console.error('Index name:', error.indexName);
236
+ console.error('Search params:', error.params);
237
+ }
182
238
  ```
183
239
 
184
240
  > **Note**: For complete implementation examples and usage patterns, see the [@dotcms/client](../client/README.md) package documentation.
185
241
 
186
- ## About
242
+ ## Support
243
+
244
+ We offer multiple channels to get help with the dotCMS Types library:
245
+
246
+ - **GitHub Issues**: For bug reports and feature requests, please [open an issue](https://github.com/dotCMS/core/issues/new/choose) in the GitHub repository
247
+ - **Community Forum**: Join our [community discussions](https://community.dotcms.com/) to ask questions and share solutions
248
+ - **Stack Overflow**: Use the tag `dotcms-types` when posting questions
249
+ - **Enterprise Support**: Enterprise customers can access premium support through the [dotCMS Support Portal](https://helpdesk.dotcms.com/support/)
250
+
251
+ When reporting issues, please include:
187
252
 
188
- This package is maintained as part of the [dotCMS core repository](https://github.com/dotCMS/core).
253
+ - Package version you're using
254
+ - TypeScript version
255
+ - Minimal reproduction steps
256
+ - Expected vs. actual behavior
189
257
 
190
- ### Keywords
258
+ ## Contributing
191
259
 
192
- * dotcms
193
- * typescript
194
- * types
195
- * cms
196
- * content-management-system
260
+ GitHub pull requests are the preferred method to contribute code to dotCMS. We welcome contributions to the dotCMS Types library! If you'd like to contribute, please follow these steps:
261
+
262
+ 1. Fork the repository [dotCMS/core](https://github.com/dotCMS/core)
263
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
264
+ 3. Commit your changes (`git commit -m 'Add some amazing feature'`)
265
+ 4. Push to the branch (`git push origin feature/amazing-feature`)
266
+ 5. Open a Pull Request
267
+
268
+ Please ensure your code follows the existing style and includes appropriate tests.
197
269
 
198
270
  ## Changelog
199
271
 
272
+ ### [1.3.0]
273
+
274
+ #### ✨ Added - AI Search Types (Experimental)
275
+
276
+ > **⚠️ Experimental:** AI Search types are experimental and may undergo breaking changes in future releases.
277
+
278
+ **New AI Search Types:**
279
+ - `DotCMSAISearchParams` - Complete AI search parameters including query and AI config
280
+ - `DotCMSAISearchQuery` - Query parameters (limit, offset, contentType, etc.)
281
+ - `DotCMSAIConfig` - AI configuration (threshold, distanceFunction, responseLength)
282
+ - `DotCMSAISearchResponse<T>` - AI search API response structure
283
+ - `DotCMSAISearchContentletData<T>` - Contentlet with AI match information
284
+ - `DotCMSAISearchMatch` - Individual match with distance score and extracted text
285
+ - `DotErrorAISearch` - AI Search API specific error with prompt, indexName, and params context
286
+ - `DISTANCE_FUNCTIONS` - Available distance functions for vector similarity (cosine, L2, inner product, etc.)
287
+
200
288
  ### [1.1.1]
201
289
 
202
290
  #### Added
@@ -214,3 +302,9 @@ This package is maintained as part of the [dotCMS core repository](https://githu
214
302
  - Renamed `RequestOptions` to `DotRequestOptions` for better naming consistency
215
303
  - Renamed `DotCMSGraphQLPageResponse` to `DotGraphQLApiResponse` for clarity
216
304
  - Enhanced `DotCMSClientConfig` to support custom `httpClient` implementations
305
+
306
+ ## Licensing
307
+
308
+ dotCMS comes in multiple editions and as such is dual-licensed. The dotCMS Community Edition is licensed under the GPL 3.0 and is freely available for download, customization, and deployment for use within organizations of all stripes. dotCMS Enterprise Editions (EE) adds several enterprise features and is available via a supported, indemnified commercial license from dotCMS. For the differences between the editions, see [the feature page](http://www.dotcms.com/cms-platform/features).
309
+
310
+ This package is part of dotCMS's dual-licensed platform (GPL 3.0 for Community, commercial license for Enterprise).
package/index.cjs.js CHANGED
@@ -1,5 +1,12 @@
1
1
  'use strict';
2
2
 
3
+ const DotCMSEntityState = {
4
+ IDLE: 'IDLE',
5
+ LOADING: 'LOADING',
6
+ SUCCESS: 'SUCCESS',
7
+ ERROR: 'ERROR'
8
+ };
9
+
3
10
  /**
4
11
  * Development mode
5
12
  *
@@ -248,6 +255,11 @@ class DotHttpError extends Error {
248
255
  * ```
249
256
  */
250
257
  class BaseHttpClient {
258
+ // This is my proposal to add this method to the class. We will need to stream data on AI Gen/Chat
259
+ // abstract requestStream(
260
+ // url: string,
261
+ // options?: DotRequestOptions
262
+ // ): Promise<{ body: ReadableStream<BufferSource>; contentLength: number }>;
251
263
  /**
252
264
  * Creates a standardized HttpError from HTTP response details.
253
265
  * Handles parsing of error response body automatically.
@@ -356,8 +368,81 @@ class DotErrorNavigation extends Error {
356
368
  }
357
369
  }
358
370
 
371
+ /**
372
+ * The distance functions for the search results.
373
+ * @public
374
+ * @constant DISTANCE_FUNCTIONS
375
+ */
376
+ const DISTANCE_FUNCTIONS = {
377
+ /**
378
+ * The L2 distance function.
379
+ * @constant L2 - The L2 distance function.
380
+ */
381
+ L2: '<->',
382
+ /**
383
+ * The inner product distance function.
384
+ * @constant innerProduct - The inner product distance function.
385
+ */
386
+ innerProduct: '<#>',
387
+ cosine: '<=>',
388
+ /**
389
+ * The L1 distance function.
390
+ * @constant L1 - The L1 distance function.
391
+ */
392
+ L1: '<+>',
393
+ /**
394
+ * The hamming distance function.
395
+ * @constant hamming - The hamming distance function.
396
+ */
397
+ hamming: '<~>',
398
+ /**
399
+ * The jaccard distance function.
400
+ * @constant jaccard - The jaccard distance function.
401
+ */
402
+ jaccard: '<%>'
403
+ };
404
+ /**
405
+ * AI Search API specific error class
406
+ * Wraps HTTP errors and adds AI search-specific context including query information
407
+ */
408
+ class DotErrorAISearch extends Error {
409
+ constructor({
410
+ message,
411
+ httpError,
412
+ prompt,
413
+ params,
414
+ indexName
415
+ }) {
416
+ super(message);
417
+ this.name = 'DotCMAISearchError';
418
+ this.httpError = httpError;
419
+ this.prompt = prompt;
420
+ this.params = params;
421
+ this.indexName = indexName;
422
+ // Ensure proper prototype chain for instanceof checks
423
+ Object.setPrototypeOf(this, DotErrorAISearch.prototype);
424
+ }
425
+ /**
426
+ * Serializes the error to a plain object for logging or transmission
427
+ */
428
+ toJSON() {
429
+ return {
430
+ name: this.name,
431
+ message: this.message,
432
+ httpError: this.httpError?.toJSON(),
433
+ prompt: this.prompt,
434
+ params: this.params,
435
+ indexName: this.indexName,
436
+ stack: this.stack
437
+ };
438
+ }
439
+ }
440
+
359
441
  exports.BaseHttpClient = BaseHttpClient;
360
442
  exports.DEVELOPMENT_MODE = DEVELOPMENT_MODE;
443
+ exports.DISTANCE_FUNCTIONS = DISTANCE_FUNCTIONS;
444
+ exports.DotCMSEntityState = DotCMSEntityState;
445
+ exports.DotErrorAISearch = DotErrorAISearch;
361
446
  exports.DotErrorContent = DotErrorContent;
362
447
  exports.DotErrorNavigation = DotErrorNavigation;
363
448
  exports.DotErrorPage = DotErrorPage;
package/index.esm.js CHANGED
@@ -1,3 +1,10 @@
1
+ const DotCMSEntityState = {
2
+ IDLE: 'IDLE',
3
+ LOADING: 'LOADING',
4
+ SUCCESS: 'SUCCESS',
5
+ ERROR: 'ERROR'
6
+ };
7
+
1
8
  /**
2
9
  * Development mode
3
10
  *
@@ -246,6 +253,11 @@ class DotHttpError extends Error {
246
253
  * ```
247
254
  */
248
255
  class BaseHttpClient {
256
+ // This is my proposal to add this method to the class. We will need to stream data on AI Gen/Chat
257
+ // abstract requestStream(
258
+ // url: string,
259
+ // options?: DotRequestOptions
260
+ // ): Promise<{ body: ReadableStream<BufferSource>; contentLength: number }>;
249
261
  /**
250
262
  * Creates a standardized HttpError from HTTP response details.
251
263
  * Handles parsing of error response body automatically.
@@ -354,4 +366,74 @@ class DotErrorNavigation extends Error {
354
366
  }
355
367
  }
356
368
 
357
- export { BaseHttpClient, DEVELOPMENT_MODE, DotCMSUVEAction, DotErrorContent, DotErrorNavigation, DotErrorPage, DotHttpError, PRODUCTION_MODE, UVEEventType, UVE_MODE };
369
+ /**
370
+ * The distance functions for the search results.
371
+ * @public
372
+ * @constant DISTANCE_FUNCTIONS
373
+ */
374
+ const DISTANCE_FUNCTIONS = {
375
+ /**
376
+ * The L2 distance function.
377
+ * @constant L2 - The L2 distance function.
378
+ */
379
+ L2: '<->',
380
+ /**
381
+ * The inner product distance function.
382
+ * @constant innerProduct - The inner product distance function.
383
+ */
384
+ innerProduct: '<#>',
385
+ cosine: '<=>',
386
+ /**
387
+ * The L1 distance function.
388
+ * @constant L1 - The L1 distance function.
389
+ */
390
+ L1: '<+>',
391
+ /**
392
+ * The hamming distance function.
393
+ * @constant hamming - The hamming distance function.
394
+ */
395
+ hamming: '<~>',
396
+ /**
397
+ * The jaccard distance function.
398
+ * @constant jaccard - The jaccard distance function.
399
+ */
400
+ jaccard: '<%>'
401
+ };
402
+ /**
403
+ * AI Search API specific error class
404
+ * Wraps HTTP errors and adds AI search-specific context including query information
405
+ */
406
+ class DotErrorAISearch extends Error {
407
+ constructor({
408
+ message,
409
+ httpError,
410
+ prompt,
411
+ params,
412
+ indexName
413
+ }) {
414
+ super(message);
415
+ this.name = 'DotCMAISearchError';
416
+ this.httpError = httpError;
417
+ this.prompt = prompt;
418
+ this.params = params;
419
+ this.indexName = indexName;
420
+ // Ensure proper prototype chain for instanceof checks
421
+ Object.setPrototypeOf(this, DotErrorAISearch.prototype);
422
+ }
423
+ /**
424
+ * Serializes the error to a plain object for logging or transmission
425
+ */
426
+ toJSON() {
427
+ return {
428
+ name: this.name,
429
+ message: this.message,
430
+ httpError: this.httpError?.toJSON(),
431
+ prompt: this.prompt,
432
+ params: this.params,
433
+ indexName: this.indexName,
434
+ stack: this.stack
435
+ };
436
+ }
437
+ }
438
+
439
+ export { BaseHttpClient, DEVELOPMENT_MODE, DISTANCE_FUNCTIONS, DotCMSEntityState, DotCMSUVEAction, DotErrorAISearch, DotErrorContent, DotErrorNavigation, DotErrorPage, DotHttpError, PRODUCTION_MODE, UVEEventType, UVE_MODE };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/types",
3
- "version": "1.1.1",
3
+ "version": "1.2.0-next.10",
4
4
  "keywords": [
5
5
  "dotCMS",
6
6
  "CMS",
@@ -36,4 +36,4 @@
36
36
  "module": "./index.esm.js",
37
37
  "main": "./index.cjs.js",
38
38
  "types": "./index.esm.d.ts"
39
- }
39
+ }
package/src/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
1
  export * from './lib/components/block-editor-renderer/public';
2
+ export * from './lib/components/generic/public';
2
3
  export * from './lib/editor/public';
3
4
  export * from './lib/events/public';
4
5
  export * from './lib/page/public';
5
6
  export * from './lib/client/public';
6
7
  export * from './lib/content/public';
7
8
  export * from './lib/nav/public';
9
+ export * from './lib/ai/public';
package/src/internal.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './lib/components/block-editor-renderer/internal';
2
2
  export * from './lib/events/internal';
3
3
  export * from './lib/editor/internal';
4
+ export * from './lib/ai/internal';
@@ -0,0 +1,55 @@
1
+ import { DISTANCE_FUNCTIONS, DotCMSAISearchContentletData } from './public';
2
+ import { DotCMSBasicContentlet } from '../page/public';
3
+ /**
4
+ * The raw response from the AI search.
5
+ *
6
+ * @export
7
+ * @interface DotCMSAISearchRawResponse
8
+ */
9
+ export interface DotCMSAISearchRawResponse<T extends DotCMSBasicContentlet> {
10
+ /**
11
+ * The time to embeddings.
12
+ * @property {number} timeToEmbeddings - The time to embeddings.
13
+ */
14
+ timeToEmbeddings: number;
15
+ /**
16
+ * The total number of results.
17
+ * @property {number} total - The total number of results.
18
+ */
19
+ total: number;
20
+ /**
21
+ * The query that was used to search.
22
+ * @property {string} query - The query.
23
+ */
24
+ query: string;
25
+ /**
26
+ * The threshold that was used to calculate the distance.
27
+ * @property {number} threshold - The threshold.
28
+ */
29
+ threshold: number;
30
+ /**
31
+ * The operator that was used to calculate the distance.
32
+ * @property {(typeof DISTANCE_FUNCTIONS)[keyof typeof DISTANCE_FUNCTIONS]} operator - The operator.
33
+ */
34
+ operator: (typeof DISTANCE_FUNCTIONS)[keyof typeof DISTANCE_FUNCTIONS];
35
+ /**
36
+ * The offset of the results.
37
+ * @property {number} offset - The offset.
38
+ */
39
+ offset: number;
40
+ /**
41
+ * The limit of the results.
42
+ * @property {number} limit - The limit.
43
+ */
44
+ limit: number;
45
+ /**
46
+ * The count of the results.
47
+ * @property {number} count - The count.
48
+ */
49
+ count: number;
50
+ /**
51
+ * The dotCMS results.
52
+ * @property {DotCMSAISearchContentletData<T>[]} dotCMSResults - The dotCMS results.
53
+ */
54
+ dotCMSResults: DotCMSAISearchContentletData<T>[];
55
+ }
@@ -0,0 +1,198 @@
1
+ import { DotCMSAISearchRawResponse } from './internal';
2
+ import { DotHttpError } from '../client/public';
3
+ import { DotCMSBasicContentlet } from '../page/public';
4
+ /**
5
+ * Query parameters for AI search - defines what and where to search
6
+ * @public
7
+ * @interface DotCMSAISearchQuery
8
+ */
9
+ export interface DotCMSAISearchQuery {
10
+ /**
11
+ * The limit of the search results.
12
+ * @property {number} limit - The limit of the search results.
13
+ * @default 1000
14
+ */
15
+ limit?: number;
16
+ /**
17
+ * The offset of the search results.
18
+ * @property {number} offset - The offset of the search results.
19
+ * @default 0
20
+ */
21
+ offset?: number;
22
+ /**
23
+ * The site identifier.
24
+ * @property {string} siteId - The site identifier.
25
+ */
26
+ siteId?: string;
27
+ /**
28
+ * The content type you want to search for.
29
+ * @property {string} contentType - The content type you want to search for.
30
+ */
31
+ contentType?: string;
32
+ /**
33
+ * The language id to search in.
34
+ * @property {number | string} languageId - The language id to search in.
35
+ */
36
+ languageId?: number | string;
37
+ }
38
+ /**
39
+ * AI configuration parameters - controls how AI processes the results
40
+ * @public
41
+ * @interface DotCMSAIConfig
42
+ */
43
+ export interface DotCMSAIConfig {
44
+ /**
45
+ * The threshold for the search results.
46
+ * @property {number} threshold - The threshold for the search results.
47
+ * @default 0.5
48
+ */
49
+ threshold?: number;
50
+ /**
51
+ * The distance function for the search results.
52
+ * Possible values:
53
+ *
54
+ * - <-> - L2 distance
55
+ * - <#> - (negative) inner product
56
+ * - <=> - cosine distance
57
+ * - <+> - L1 distance
58
+ * - <~> - Hamming distance (binary vectors)
59
+ * - <%> - Jaccard distance (binary vectors)
60
+ * @default DISTANCE_FUNCTIONS.cosine
61
+ * @see {@link https://platform.openai.com/docs/guides/embeddings/which-distance-function-should-i-use#which-distance-function-should-i-use} - OpenAI documentation for the distance functions
62
+ * @property {string} distanceFunction - The distance function for the search results.
63
+ */
64
+ distanceFunction?: (typeof DISTANCE_FUNCTIONS)[keyof typeof DISTANCE_FUNCTIONS];
65
+ /**
66
+ * The length of the response.
67
+ * @property {number} responseLength - The length of the response.
68
+ * @default 1024
69
+ */
70
+ responseLength?: number;
71
+ }
72
+ /**
73
+ * Parameters for making an AI search request to DotCMS.
74
+ * @public
75
+ * @interface DotCMSAISearchParams
76
+ */
77
+ export interface DotCMSAISearchParams {
78
+ /**
79
+ * Query parameters defining what and where to search.
80
+ * @property {DotCMSAISearchQuery} query - The search query parameters.
81
+ */
82
+ query?: DotCMSAISearchQuery;
83
+ /**
84
+ * AI configuration parameters controlling how results are processed.
85
+ * @property {DotCMSAIConfig} config - The AI configuration parameters.
86
+ */
87
+ config?: DotCMSAIConfig;
88
+ }
89
+ /**
90
+ * The distance functions for the search results.
91
+ * @public
92
+ * @constant DISTANCE_FUNCTIONS
93
+ */
94
+ export declare const DISTANCE_FUNCTIONS: {
95
+ /**
96
+ * The L2 distance function.
97
+ * @constant L2 - The L2 distance function.
98
+ */
99
+ readonly L2: "<->";
100
+ /**
101
+ * The inner product distance function.
102
+ * @constant innerProduct - The inner product distance function.
103
+ */
104
+ readonly innerProduct: "<#>";
105
+ readonly cosine: "<=>";
106
+ /**
107
+ * The L1 distance function.
108
+ * @constant L1 - The L1 distance function.
109
+ */
110
+ readonly L1: "<+>";
111
+ /**
112
+ * The hamming distance function.
113
+ * @constant hamming - The hamming distance function.
114
+ */
115
+ readonly hamming: "<~>";
116
+ /**
117
+ * The jaccard distance function.
118
+ * @constant jaccard - The jaccard distance function.
119
+ */
120
+ readonly jaccard: "<%>";
121
+ };
122
+ /**
123
+ * AI Search API specific error class
124
+ * Wraps HTTP errors and adds AI search-specific context including query information
125
+ */
126
+ export declare class DotErrorAISearch extends Error {
127
+ readonly httpError?: DotHttpError;
128
+ readonly prompt?: string;
129
+ readonly params?: DotCMSAISearchParams;
130
+ readonly indexName?: string;
131
+ constructor({ message, httpError, prompt, params, indexName }: {
132
+ message: string;
133
+ httpError?: DotHttpError;
134
+ prompt?: string;
135
+ params?: DotCMSAISearchParams;
136
+ indexName?: string;
137
+ });
138
+ /**
139
+ * Serializes the error to a plain object for logging or transmission
140
+ */
141
+ toJSON(): {
142
+ name: string;
143
+ message: string;
144
+ httpError: {
145
+ name: string;
146
+ message: string;
147
+ status: number;
148
+ statusText: string;
149
+ data: unknown;
150
+ stack: string | undefined;
151
+ } | undefined;
152
+ prompt: string | undefined;
153
+ params: DotCMSAISearchParams | undefined;
154
+ indexName: string | undefined;
155
+ stack: string | undefined;
156
+ };
157
+ }
158
+ /**
159
+ * The response from the AI search.
160
+ * @public
161
+ * @interface DotCMSAISearchResponse
162
+ */
163
+ export interface DotCMSAISearchResponse<T extends DotCMSBasicContentlet> extends Omit<DotCMSAISearchRawResponse<T>, 'dotCMSResults'> {
164
+ /**
165
+ * The results from the AI search.
166
+ * @property {DotCMSAISearchContentletData<T>[]} results - The results from the AI search.
167
+ */
168
+ results: DotCMSAISearchContentletData<T>[];
169
+ }
170
+ /**
171
+ * The match from the AI search.
172
+ * @public
173
+ * @interface DotCMSAISearchMatch
174
+ */
175
+ export interface DotCMSAISearchMatch {
176
+ /**
177
+ * The distance from the AI search.
178
+ * @property {number} distance - The distance from the AI search.
179
+ */
180
+ distance: number;
181
+ /**
182
+ * The extracted text from the AI search.
183
+ * @property {string} extractedText - The extracted text from the AI search.
184
+ */
185
+ extractedText: string;
186
+ }
187
+ /**
188
+ * The contentlet data from the AI search.
189
+ * @public
190
+ * @interface DotCMSAISearchContentletData
191
+ */
192
+ export type DotCMSAISearchContentletData<T extends DotCMSBasicContentlet> = T & {
193
+ /**
194
+ * The matches from the AI search.
195
+ * @property {DotCMSAISearchMatch[]} matches - The matches from the AI search.
196
+ */
197
+ matches?: DotCMSAISearchMatch[];
198
+ };
@@ -9,7 +9,7 @@ export interface BlockEditorMark {
9
9
  attrs: Record<string, string>;
10
10
  }
11
11
  /**
12
- * Represents a Content Node used by the Block Editor
12
+ * Represents a Node in the Block Editor
13
13
  *
14
14
  * @export
15
15
  * @interface BlockEditorNode
@@ -26,13 +26,3 @@ export interface BlockEditorNode {
26
26
  /** Optional text content */
27
27
  text?: string;
28
28
  }
29
- /**
30
- * Represents a Block in the Block Editor
31
- *
32
- * @export
33
- * @interface BlockEditorContent
34
- */
35
- export interface BlockEditorContent {
36
- content?: BlockEditorNode[];
37
- type: string;
38
- }
@@ -0,0 +1,16 @@
1
+ export declare const DotCMSEntityState: {
2
+ readonly IDLE: "IDLE";
3
+ readonly LOADING: "LOADING";
4
+ readonly SUCCESS: "SUCCESS";
5
+ readonly ERROR: "ERROR";
6
+ };
7
+ export type DotCMSEntityStatus = {
8
+ state: typeof DotCMSEntityState.IDLE;
9
+ } | {
10
+ state: typeof DotCMSEntityState.LOADING;
11
+ } | {
12
+ state: typeof DotCMSEntityState.SUCCESS;
13
+ } | {
14
+ state: typeof DotCMSEntityState.ERROR;
15
+ error: Error;
16
+ };
@@ -100,4 +100,23 @@ export interface DotContentletAttributes {
100
100
  'data-dot-container': string;
101
101
  'data-dot-on-number-of-pages': string;
102
102
  }
103
+ /**
104
+ * Helper type to create analytics attribute names with the correct prefix
105
+ * @internal
106
+ */
107
+ type AnalyticsAttribute<T extends string> = `data-dot-analytics-${T}`;
108
+ /**
109
+ * Analytics attribute keys
110
+ * @internal
111
+ */
112
+ type AnalyticsAttributeKey = 'identifier' | 'inode' | 'basetype' | 'contenttype' | 'title';
113
+ /**
114
+ * Interface representing the analytics data attributes of a DotCMS contentlet.
115
+ * Guarantees all keys have the 'data-dot-analytics-' prefix.
116
+ * Includes a class for fast DOM selection.
117
+ * @interface DotAnalyticsAttributes
118
+ */
119
+ export type DotAnalyticsAttributes = {
120
+ [K in AnalyticsAttributeKey as AnalyticsAttribute<K>]: string;
121
+ };
103
122
  export {};