@dotcms/react 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/react",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "peerDependencies": {
5
5
  "react": ">=18",
6
6
  "react-dom": ">=18"
package/src/index.d.ts CHANGED
@@ -5,3 +5,5 @@ export { useEditableDotCMSPage } from './lib/next/hooks/useEditableDotCMSPage';
5
5
  export { DotCMSEditableText } from './lib/next/components/DotCMSEditableText/DotCMSEditableText';
6
6
  export { DotCMSBlockEditorRenderer, BlockEditorRendererProps, CustomRenderer, CustomRendererProps } from './lib/next/components/DotCMSBlockEditorRenderer/DotCMSBlockEditorRenderer';
7
7
  export { DotCMSLayoutBodyProps } from './lib/next/components/DotCMSLayoutBody/DotCMSLayoutBody';
8
+ export { useAISearch } from './lib/next/hooks/useAISearch';
9
+ export type { DotCMSAISearchValue, DotCMSAISearchProps } from './lib/next/shared/types';
@@ -0,0 +1,30 @@
1
+ import { DotCMSBasicContentlet } from '@dotcms/types';
2
+ import { DotCMSAISearchProps, DotCMSAISearchValue } from '../shared/types';
3
+ /**
4
+ * Hook to search for contentlets using AI.
5
+ * @template T - The type of the contentlet.
6
+ * @param client - The client to use for the search.
7
+ * @param indexName - The name of the index to search in.
8
+ * @param params - The parameters for the search.
9
+ * @returns The search results.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const { results, status, search, reset } = useAISearch<BlogPost>({
14
+ * client: dotCMSClient,
15
+ * indexName: 'blog-search-index',
16
+ * params: {
17
+ * query: {
18
+ * limit: 10,
19
+ * offset: 0,
20
+ * contentType: 'Blog'
21
+ * },
22
+ * config: {
23
+ * threshold: 0.5,
24
+ * responseLength: 1024
25
+ * }
26
+ * }
27
+ * });
28
+ * ```
29
+ */
30
+ export declare const useAISearch: <T extends DotCMSBasicContentlet>({ client, indexName, params }: DotCMSAISearchProps) => DotCMSAISearchValue<T>;
@@ -0,0 +1,24 @@
1
+ import { createDotCMSClient } from '@dotcms/client';
2
+ import { DotCMSAISearchContentletData, DotCMSAISearchParams, DotCMSAISearchResponse, DotCMSBasicContentlet, DotCMSEntityStatus } from '@dotcms/types';
3
+ /**
4
+ * Return type of the AI Search context
5
+ * @interface DotCMSAISearchContextValue
6
+ * @template T - The content type extending DotCMSBasicContentlet
7
+ */
8
+ export interface DotCMSAISearchValue<T extends DotCMSBasicContentlet> {
9
+ response: DotCMSAISearchResponse<T> | null;
10
+ results: DotCMSAISearchContentletData<T>[];
11
+ status: DotCMSEntityStatus;
12
+ search: (prompt: string) => Promise<void>;
13
+ reset: () => void;
14
+ }
15
+ /**
16
+ * Props for the DotCMSAISearchProvider
17
+ * @interface DotCMSAISearchProviderProps
18
+ * @template T - The content type extending DotCMSBasicContentlet
19
+ */
20
+ export interface DotCMSAISearchProps {
21
+ client: ReturnType<typeof createDotCMSClient>;
22
+ indexName: string;
23
+ params: DotCMSAISearchParams;
24
+ }