UNPKG

@ckeditor/ckeditor5-ai

Version:

AI features for CKEditor 5.

162 lines (161 loc) 5.62 kB
/** * @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 { type AIReviewCheck } from './aireviewcheck.js'; import { AIReviewCheckResult } from './aireviewcheckresult.js'; import { type AIReviewModeChangeData, type AIDocumentData } from '../aireviewmodeediting.js'; import { type AIConnector } from '../../aicore/aiconnector.js'; import { AIReviewCheckResultChange } from './aireviewcheckresultchange.js'; declare const AIReviewCheckRun_base: { new (): import("ckeditor5/src/utils.js").Observable; prototype: import("ckeditor5/src/utils.js").Observable; }; /** * Represents a single review check run and its results. */ export declare abstract class AIReviewCheckRun extends /* #__PURE__ */ AIReviewCheckRun_base { /** * The status of the check run. */ status: AIReviewCheckRunStatus; /** * The check run ID. */ readonly id: string; /** * The call ID returned by the AI API when the check run is started. */ callId?: string; constructor(documentData: AIDocumentData, sourceCheck: AIReviewCheck, connector: AIConnector, params?: Array<string>, args?: Record<string, any>); /** * Returns the document data obtained at the time of the check run. */ get documentData(): AIDocumentData; /** * Returns the number of successfully processed results. */ get processedResultsCount(): number; /** * Returns the check title. */ get title(): string; /** * Returns the check subtitle. */ get subTitle(): string; /** * Returns the check ID. */ get reviewName(): string; /** * Whether the check run has any modifications (accepted or rejected changes). */ get hasModifications(): boolean; /** * Returns the current error that occurred during the check run, if any. */ get currentError(): Error | undefined; /** * Updates the document data used for the check run. It allows to rerun the same check with different data. */ updateDocumentData(documentData: AIDocumentData): void; /** * Starts the check run resulting in an API call. After the call is finished, the status * and list of changes are updated. */ start(): Promise<void>; /** * Restarts the check run by clearing previous results and starting a new run. */ restart(): Promise<void>; addResultChanges(resultId: string, changes: Array<AIReviewModeChangeData>): void; /** * Aborts the check run. */ abort(): void; isChangeActive(changeId: string): boolean; isAnyChangeActivated(): boolean; getActiveChanges(): Array<AIReviewCheckResultChange>; getChangeById(changeId: string): AIReviewCheckResultChange | undefined; markAllChangesAsAccepted(): void; markChangeAsAccepted(changeId: string): void; markChangeAsRejected(changeId: string): void; markChangeAsOutdated(changeId: string): void; markChangeAsPending(changeId: string): void; activateChange(changeId: string): void; deactivateChange(): void; forceReadyState(): void; /** * Sends the rating to an AI API for the review check run. * * If `changeId` is provided, the rating will be associated with that specific result, which * the change is a part of (since the result is splitted into multiple changes). The `resultId` * is used on the backend to track ratings for individual results. * If `changeId` is not provided, the rating will be send as general for the whole check run. * * The rating will not be send if: * - There is no `callId` (means the check run was not started or failed before getting the ID). * - There are no changes in the check run. * - The change with given `changeId` was already rated. * - The check run is not ready yet (still streaming), since we don't know the final number of changes * yet, which is required to send the rating. */ sendRating(changeId?: string): Promise<void>; } export type AIReviewCheckRunUpdatedEvent = { name: 'reviewCheckRunUpdated'; args: [ { status: AIReviewCheckRunStatus; run: AIReviewCheckRun; error?: Error; } ]; }; export type AIReviewCheckResultAddedEvent = { name: 'reviewCheckResultAdded'; args: [ { result: AIReviewCheckResult; source: AIReviewCheckRun; } ]; }; export type AIReviewCheckResultReadyEvent = { name: 'reviewCheckResultReady'; args: [ { changes: Array<AIReviewCheckResultChange>; result: AIReviewCheckResult; source: AIReviewCheckRun; } ]; }; export type AIReviewCheckResultChangeStatusUpdatedEvent = { name: 'reviewCheckResultChangeStatusUpdated'; args: [ { change: AIReviewCheckResultChange; status: AIReviewCheckResultChange['status']; } ]; }; export type AIReviewCheckResultChangeActivatedEvent = { name: 'reviewCheckResultActivated'; args: [ { change: AIReviewCheckResultChange; } ]; }; export type AIReviewCheckResultChangeDeactivatedEvent = { name: 'reviewCheckResultDeactivated'; args: [ { change: AIReviewCheckResultChange; } ]; }; export type AIReviewCheckRunStatus = 'initialized' | 'loading' | 'data' | 'ready' | 'error-chunk' | 'error-general' | 'aborted' | 'finished' | 'unmodified'; export {};