@ckeditor/ckeditor5-ai
Version:
AI features for CKEditor 5.
115 lines (114 loc) • 3.62 kB
TypeScript
/**
* @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
*/
import { AIChatHistoryItem } from './aichathistoryitem.js';
import { type AIConnector, type AIConversationItem } from '../../aicore/aiconnector.js';
declare const AIChatHistoryConversations_base: {
new (): import("ckeditor5/src/utils.js").Emitter;
prototype: import("ckeditor5/src/utils.js").Emitter;
};
/**
* Represents the chat history conversations that manages a collection of history items.
*
* The history conversations provides methods to add, remove, update, and query history items.
* It emits events when the history changes, allowing UI components to react accordingly.
*/
export declare class AIChatHistoryConversations extends /* #__PURE__ */ AIChatHistoryConversations_base {
/**
* The collection of history items.
*/
items: Array<AIChatHistoryItem>;
/**
* @inheritDoc
*/
constructor({ connector, group }: {
connector: AIConnector;
group: string;
});
/**
* Initializes the history by loading conversations from the API.
*/
init(): Promise<void>;
/**
* Adds a new item to the history.
*/
addItem(item: AIChatHistoryItem): void;
/**
* Removes an item from the history by ID.
*/
removeItem(id: string): Promise<boolean>;
/**
* Gets an item by ID.
*/
getItem(id: string): AIChatHistoryItem | undefined;
/**
* Updates the title of an item.
*/
updateItemTitle(id: string, title: string): Promise<boolean>;
/**
* Updates the pinned status of an item.
*/
updateItemPinned(id: string, pinned: boolean): Promise<boolean>;
/**
* Loads items from conversation data.
*/
loadItems(conversationData: Array<AIConversationItem>): void;
/**
* Gets items with optional filtering by pinned status and date range.
*
* This method allows flexible querying of items with various combinations of filters.
* When date range is provided, it compares only dates (year, month, day) ignoring time components.
* By default, returns only non-pinned items.
*
* @param options.pinned Filter by pinned status. If true, returns only pinned items. If false, returns only non-pinned items.
* If undefined, returns only non-pinned items (default behavior).
* @param options.from Older date (inclusive, optional). If not provided, returns items older than 'to' date.
* Only date part is considered.
* @param options.to Newer date (inclusive). Only date part is considered.
*/
getItems(options?: {
pinned?: boolean;
from?: Date;
to?: Date;
}): Array<AIChatHistoryItem>;
}
export type AIChatHistoryConversationsItemRemovedEvent = {
name: 'itemRemoved';
args: [
{
itemId: string;
}
];
};
export type AIChatHistoryConversationsItemUpdatedEvent = {
name: 'itemUpdated';
args: [
{
itemId: string;
updates: {
title?: string;
pinned?: boolean;
};
}
];
};
export type AIChatHistoryConversationsItemsLoadedEvent = {
name: 'itemsLoaded';
args: [
{
items: Array<AIChatHistoryItem>;
}
];
};
export type AIChatHistoryConversationsErrorEvent = {
name: 'error';
args: [
{
error: Error;
operation: string;
itemId?: string;
}
];
};
export {};