@dotcms/types 1.2.0 → 1.2.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 +58 -2
- package/index.cjs.js +89 -0
- package/index.esm.js +87 -1
- package/package.json +1 -1
- package/src/index.d.ts +2 -0
- package/src/internal.d.ts +1 -0
- package/src/lib/ai/internal.d.ts +55 -0
- package/src/lib/ai/public.d.ts +198 -0
- package/src/lib/components/generic/public.d.ts +16 -0
- package/src/lib/editor/public.d.ts +4 -0
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@ The `@dotcms/types` package contains TypeScript type definitions for the dotCMS
|
|
|
11
11
|
- [Installation](#installation)
|
|
12
12
|
- [Commonly Used Types](#commonly-used-types)
|
|
13
13
|
- [Type Hierarchy (Jump to Definitions)](#type-hierarchy-jump-to-definitions)
|
|
14
|
+
- [AI Search](#ai-search)
|
|
14
15
|
- [dotCMS Content & Pages](#dotcms-content--pages)
|
|
15
16
|
- [Universal Visual Editor (UVE)](#universal-visual-editor-uve)
|
|
16
17
|
- [Block Editor](#block-editor)
|
|
@@ -57,12 +58,42 @@ import {
|
|
|
57
58
|
DotHttpError,
|
|
58
59
|
DotErrorPage,
|
|
59
60
|
DotErrorContent,
|
|
60
|
-
DotErrorNavigation
|
|
61
|
+
DotErrorNavigation,
|
|
62
|
+
DotErrorAISearch,
|
|
63
|
+
DotCMSAISearchParams,
|
|
64
|
+
DISTANCE_FUNCTIONS
|
|
61
65
|
} from '@dotcms/types';
|
|
62
66
|
```
|
|
63
67
|
|
|
64
68
|
## Type Hierarchy (Jump to Definitions)
|
|
65
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
|
+
|
|
66
97
|
### dotCMS Content & Pages
|
|
67
98
|
|
|
68
99
|
**Page:**
|
|
@@ -166,6 +197,7 @@ import {
|
|
|
166
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 |
|
|
167
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 |
|
|
168
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 |
|
|
169
201
|
|
|
170
202
|
## Usage Examples
|
|
171
203
|
|
|
@@ -176,7 +208,8 @@ import {
|
|
|
176
208
|
DotHttpError,
|
|
177
209
|
DotErrorPage,
|
|
178
210
|
DotErrorContent,
|
|
179
|
-
DotErrorNavigation
|
|
211
|
+
DotErrorNavigation,
|
|
212
|
+
DotErrorAISearch
|
|
180
213
|
} from '@dotcms/types';
|
|
181
214
|
|
|
182
215
|
// Type-safe error handling
|
|
@@ -195,6 +228,13 @@ if (error instanceof DotErrorContent) {
|
|
|
195
228
|
// Content-specific error context
|
|
196
229
|
console.error(`${error.operation} failed for ${error.contentType}`);
|
|
197
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
|
+
}
|
|
198
238
|
```
|
|
199
239
|
|
|
200
240
|
> **Note**: For complete implementation examples and usage patterns, see the [@dotcms/client](../client/README.md) package documentation.
|
|
@@ -229,6 +269,22 @@ Please ensure your code follows the existing style and includes appropriate test
|
|
|
229
269
|
|
|
230
270
|
## Changelog
|
|
231
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
|
+
|
|
232
288
|
### [1.1.1]
|
|
233
289
|
|
|
234
290
|
#### Added
|
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
|
*
|
|
@@ -89,6 +96,10 @@ exports.DotCMSUVEAction = void 0;
|
|
|
89
96
|
* Tell the editor to edit a contentlet
|
|
90
97
|
*/
|
|
91
98
|
DotCMSUVEAction["EDIT_CONTENTLET"] = "edit-contentlet";
|
|
99
|
+
/**
|
|
100
|
+
* Tell the editor to register style schemas
|
|
101
|
+
*/
|
|
102
|
+
DotCMSUVEAction["REGISTER_STYLE_SCHEMAS"] = "register-style-schemas";
|
|
92
103
|
/**
|
|
93
104
|
* Tell the editor to do nothing
|
|
94
105
|
*/
|
|
@@ -248,6 +259,11 @@ class DotHttpError extends Error {
|
|
|
248
259
|
* ```
|
|
249
260
|
*/
|
|
250
261
|
class BaseHttpClient {
|
|
262
|
+
// This is my proposal to add this method to the class. We will need to stream data on AI Gen/Chat
|
|
263
|
+
// abstract requestStream(
|
|
264
|
+
// url: string,
|
|
265
|
+
// options?: DotRequestOptions
|
|
266
|
+
// ): Promise<{ body: ReadableStream<BufferSource>; contentLength: number }>;
|
|
251
267
|
/**
|
|
252
268
|
* Creates a standardized HttpError from HTTP response details.
|
|
253
269
|
* Handles parsing of error response body automatically.
|
|
@@ -356,8 +372,81 @@ class DotErrorNavigation extends Error {
|
|
|
356
372
|
}
|
|
357
373
|
}
|
|
358
374
|
|
|
375
|
+
/**
|
|
376
|
+
* The distance functions for the search results.
|
|
377
|
+
* @public
|
|
378
|
+
* @constant DISTANCE_FUNCTIONS
|
|
379
|
+
*/
|
|
380
|
+
const DISTANCE_FUNCTIONS = {
|
|
381
|
+
/**
|
|
382
|
+
* The L2 distance function.
|
|
383
|
+
* @constant L2 - The L2 distance function.
|
|
384
|
+
*/
|
|
385
|
+
L2: '<->',
|
|
386
|
+
/**
|
|
387
|
+
* The inner product distance function.
|
|
388
|
+
* @constant innerProduct - The inner product distance function.
|
|
389
|
+
*/
|
|
390
|
+
innerProduct: '<#>',
|
|
391
|
+
cosine: '<=>',
|
|
392
|
+
/**
|
|
393
|
+
* The L1 distance function.
|
|
394
|
+
* @constant L1 - The L1 distance function.
|
|
395
|
+
*/
|
|
396
|
+
L1: '<+>',
|
|
397
|
+
/**
|
|
398
|
+
* The hamming distance function.
|
|
399
|
+
* @constant hamming - The hamming distance function.
|
|
400
|
+
*/
|
|
401
|
+
hamming: '<~>',
|
|
402
|
+
/**
|
|
403
|
+
* The jaccard distance function.
|
|
404
|
+
* @constant jaccard - The jaccard distance function.
|
|
405
|
+
*/
|
|
406
|
+
jaccard: '<%>'
|
|
407
|
+
};
|
|
408
|
+
/**
|
|
409
|
+
* AI Search API specific error class
|
|
410
|
+
* Wraps HTTP errors and adds AI search-specific context including query information
|
|
411
|
+
*/
|
|
412
|
+
class DotErrorAISearch extends Error {
|
|
413
|
+
constructor({
|
|
414
|
+
message,
|
|
415
|
+
httpError,
|
|
416
|
+
prompt,
|
|
417
|
+
params,
|
|
418
|
+
indexName
|
|
419
|
+
}) {
|
|
420
|
+
super(message);
|
|
421
|
+
this.name = 'DotCMAISearchError';
|
|
422
|
+
this.httpError = httpError;
|
|
423
|
+
this.prompt = prompt;
|
|
424
|
+
this.params = params;
|
|
425
|
+
this.indexName = indexName;
|
|
426
|
+
// Ensure proper prototype chain for instanceof checks
|
|
427
|
+
Object.setPrototypeOf(this, DotErrorAISearch.prototype);
|
|
428
|
+
}
|
|
429
|
+
/**
|
|
430
|
+
* Serializes the error to a plain object for logging or transmission
|
|
431
|
+
*/
|
|
432
|
+
toJSON() {
|
|
433
|
+
return {
|
|
434
|
+
name: this.name,
|
|
435
|
+
message: this.message,
|
|
436
|
+
httpError: this.httpError?.toJSON(),
|
|
437
|
+
prompt: this.prompt,
|
|
438
|
+
params: this.params,
|
|
439
|
+
indexName: this.indexName,
|
|
440
|
+
stack: this.stack
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
|
|
359
445
|
exports.BaseHttpClient = BaseHttpClient;
|
|
360
446
|
exports.DEVELOPMENT_MODE = DEVELOPMENT_MODE;
|
|
447
|
+
exports.DISTANCE_FUNCTIONS = DISTANCE_FUNCTIONS;
|
|
448
|
+
exports.DotCMSEntityState = DotCMSEntityState;
|
|
449
|
+
exports.DotErrorAISearch = DotErrorAISearch;
|
|
361
450
|
exports.DotErrorContent = DotErrorContent;
|
|
362
451
|
exports.DotErrorNavigation = DotErrorNavigation;
|
|
363
452
|
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
|
*
|
|
@@ -87,6 +94,10 @@ var DotCMSUVEAction;
|
|
|
87
94
|
* Tell the editor to edit a contentlet
|
|
88
95
|
*/
|
|
89
96
|
DotCMSUVEAction["EDIT_CONTENTLET"] = "edit-contentlet";
|
|
97
|
+
/**
|
|
98
|
+
* Tell the editor to register style schemas
|
|
99
|
+
*/
|
|
100
|
+
DotCMSUVEAction["REGISTER_STYLE_SCHEMAS"] = "register-style-schemas";
|
|
90
101
|
/**
|
|
91
102
|
* Tell the editor to do nothing
|
|
92
103
|
*/
|
|
@@ -246,6 +257,11 @@ class DotHttpError extends Error {
|
|
|
246
257
|
* ```
|
|
247
258
|
*/
|
|
248
259
|
class BaseHttpClient {
|
|
260
|
+
// This is my proposal to add this method to the class. We will need to stream data on AI Gen/Chat
|
|
261
|
+
// abstract requestStream(
|
|
262
|
+
// url: string,
|
|
263
|
+
// options?: DotRequestOptions
|
|
264
|
+
// ): Promise<{ body: ReadableStream<BufferSource>; contentLength: number }>;
|
|
249
265
|
/**
|
|
250
266
|
* Creates a standardized HttpError from HTTP response details.
|
|
251
267
|
* Handles parsing of error response body automatically.
|
|
@@ -354,4 +370,74 @@ class DotErrorNavigation extends Error {
|
|
|
354
370
|
}
|
|
355
371
|
}
|
|
356
372
|
|
|
357
|
-
|
|
373
|
+
/**
|
|
374
|
+
* The distance functions for the search results.
|
|
375
|
+
* @public
|
|
376
|
+
* @constant DISTANCE_FUNCTIONS
|
|
377
|
+
*/
|
|
378
|
+
const DISTANCE_FUNCTIONS = {
|
|
379
|
+
/**
|
|
380
|
+
* The L2 distance function.
|
|
381
|
+
* @constant L2 - The L2 distance function.
|
|
382
|
+
*/
|
|
383
|
+
L2: '<->',
|
|
384
|
+
/**
|
|
385
|
+
* The inner product distance function.
|
|
386
|
+
* @constant innerProduct - The inner product distance function.
|
|
387
|
+
*/
|
|
388
|
+
innerProduct: '<#>',
|
|
389
|
+
cosine: '<=>',
|
|
390
|
+
/**
|
|
391
|
+
* The L1 distance function.
|
|
392
|
+
* @constant L1 - The L1 distance function.
|
|
393
|
+
*/
|
|
394
|
+
L1: '<+>',
|
|
395
|
+
/**
|
|
396
|
+
* The hamming distance function.
|
|
397
|
+
* @constant hamming - The hamming distance function.
|
|
398
|
+
*/
|
|
399
|
+
hamming: '<~>',
|
|
400
|
+
/**
|
|
401
|
+
* The jaccard distance function.
|
|
402
|
+
* @constant jaccard - The jaccard distance function.
|
|
403
|
+
*/
|
|
404
|
+
jaccard: '<%>'
|
|
405
|
+
};
|
|
406
|
+
/**
|
|
407
|
+
* AI Search API specific error class
|
|
408
|
+
* Wraps HTTP errors and adds AI search-specific context including query information
|
|
409
|
+
*/
|
|
410
|
+
class DotErrorAISearch extends Error {
|
|
411
|
+
constructor({
|
|
412
|
+
message,
|
|
413
|
+
httpError,
|
|
414
|
+
prompt,
|
|
415
|
+
params,
|
|
416
|
+
indexName
|
|
417
|
+
}) {
|
|
418
|
+
super(message);
|
|
419
|
+
this.name = 'DotCMAISearchError';
|
|
420
|
+
this.httpError = httpError;
|
|
421
|
+
this.prompt = prompt;
|
|
422
|
+
this.params = params;
|
|
423
|
+
this.indexName = indexName;
|
|
424
|
+
// Ensure proper prototype chain for instanceof checks
|
|
425
|
+
Object.setPrototypeOf(this, DotErrorAISearch.prototype);
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Serializes the error to a plain object for logging or transmission
|
|
429
|
+
*/
|
|
430
|
+
toJSON() {
|
|
431
|
+
return {
|
|
432
|
+
name: this.name,
|
|
433
|
+
message: this.message,
|
|
434
|
+
httpError: this.httpError?.toJSON(),
|
|
435
|
+
prompt: this.prompt,
|
|
436
|
+
params: this.params,
|
|
437
|
+
indexName: this.indexName,
|
|
438
|
+
stack: this.stack
|
|
439
|
+
};
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export { BaseHttpClient, DEVELOPMENT_MODE, DISTANCE_FUNCTIONS, DotCMSEntityState, DotCMSUVEAction, DotErrorAISearch, DotErrorContent, DotErrorNavigation, DotErrorPage, DotHttpError, PRODUCTION_MODE, UVEEventType, UVE_MODE };
|
package/package.json
CHANGED
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
|
@@ -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
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -138,6 +138,10 @@ export declare enum DotCMSUVEAction {
|
|
|
138
138
|
* Tell the editor to edit a contentlet
|
|
139
139
|
*/
|
|
140
140
|
EDIT_CONTENTLET = "edit-contentlet",
|
|
141
|
+
/**
|
|
142
|
+
* Tell the editor to register style schemas
|
|
143
|
+
*/
|
|
144
|
+
REGISTER_STYLE_SCHEMAS = "register-style-schemas",
|
|
141
145
|
/**
|
|
142
146
|
* Tell the editor to do nothing
|
|
143
147
|
*/
|