import type { Operation } from '@api-client/json/patch/types.js';
import CustomEvent from './CustomEvent.js';
/**
 * Base event detail definition for the events that returns a `result`
 * property on the `detail` object
 */
export interface ContextEventDetailWithResult<T> {
    /**
     * This property is set by the context provider, a promise resolved when the operation finish
     * with the corresponding result.
     */
    result?: Promise<T | undefined> | undefined;
}
/**
 * A base class to use with context providers.
 */
export declare class ContextEvent<S extends object, R> extends CustomEvent<S & ContextEventDetailWithResult<R>> {
    /**
     * @param type The event type
     * @param detail The optional detail object. It adds object's properties to the `detail` with the `result` property.
     */
    constructor(type: string, detail: S);
}
export interface ContextReadEventDetail {
    /**
     * The key of the state object to read.
     */
    key: string;
    /**
     * Optional parent, when needed.
     */
    parent?: string;
}
/**
 * An event to be used to read a state from a context provider.
 */
export declare class ContextReadEvent<T> extends ContextEvent<ContextReadEventDetail, T | null | undefined> {
    /**
     * @param type The type of the event
     * @param key The domain key of the object to read
     * @param parent Optional parent, when needed.
     */
    constructor(type: string, key: string, parent?: string);
}
export interface ContextReadBulkEventDetail {
    /**
     * The list of keys to read.
     */
    keys: string[];
    /**
     * Optional parent, when needed.
     */
    parent?: string;
}
/**
 * An event to be used to read a list of object from the API store.
 */
export declare class ContextReadBulkEvent<T> extends ContextEvent<ContextReadBulkEventDetail, IBulkOperationResult<T | null | undefined>> {
    /**
     * @param type The type of the event
     * @param keys The list of domain keys to read. These must be of the same domain type.
     */
    constructor(type: string, keys: string[], parent?: string);
}
/**
 * A general purpose change record.
 * Set on the `detail` object of the `CustomEvent` when a change occurs in the context store.
 */
export interface ContextChangeRecord<T> {
    /**
     * The data kind of the changed item.
     * May not be present when this is used with the old architecture.
     */
    kind?: string;
    /**
     * The key of the changed context state object.
     */
    key: string;
    /**
     * The updated context state object.
     */
    item?: T;
    /**
     * Optionally, when relevant, the key of the parent of the changed object.
     */
    parent?: string;
    /**
     * The parent organization.
     */
    organization?: string;
}
export interface ContextDeleteEventDetail {
    /**
     * The key of the domain object to remove.
     */
    key: string;
    /**
     * The key of the parent object, if applicable.
     */
    parent?: string;
    /**
     * The parent organization.
     */
    organization?: string;
}
export interface ContextDeleteBulkEventDetail {
    /**
     * The list of keys of the domain object to remove.
     */
    keys: string[];
    /**
     * The key of the parent object, if applicable.
     */
    parent?: string;
    /**
     * The parent organization.
     */
    organization?: string;
}
/**
 * An event to be used to delete a state in the context provider.
 */
export declare class ContextDeleteEvent extends ContextEvent<ContextDeleteEventDetail, ContextDeleteRecord> {
    /**
     * An event to be used to delete a state in the context provider.
     * @param type The type of the event to dispatch.
     * @param key The key of the object to delete
     * @param parent The key of the parent object, if applicable.
     */
    constructor(type: string, key: string, parent?: string);
}
/**
 * Describes a result of the batch delete operation.
 */
export interface IBulkOperationResult<T> {
    /**
     * The ordered list of delete result for each item.
     *
     * The batch operation does not return specific errors. Use the direct delete operation
     * for the detailed error.
     */
    items: (T | undefined | null)[];
}
/**
 * An event to be used to delete a number of entities in the context provider.
 */
export declare class ContextDeleteBulkEvent extends ContextEvent<ContextDeleteBulkEventDetail, IBulkOperationResult<ContextDeleteRecord>> {
    /**
     * An event to be used to delete a number of entities in the context provider.
     * @param type The type of the event to dispatch.
     * @param keys The list of ids of the domain object to remove.
     * @param parent The key of the parent object, if applicable.
     */
    constructor(type: string, keys: string[], parent?: string);
}
export interface ContextDeleteRecord {
    /**
     * The data kind of the deleted item.
     * May not be present when this is used with the old architecture.
     */
    kind?: string;
    /**
     * The key of the removed object.
     */
    key: string;
    /**
     * The key of the parent object, if applicable.
     */
    parent?: string;
}
/**
 * An event dispatched to the context store to restore previously deleted items.
 */
export declare class ContextRestoreEvent<T> extends ContextEvent<{
    records: ContextDeleteRecord[];
}, IBulkOperationResult<ContextChangeRecord<T>>> {
    /**
     * An event dispatched to the context store to restore previously deleted items.
     *
     * The result of the event is the list of `ContextChangeRecord` for the restored items.
     *
     * @param type The type of the event.
     * @param records The records of previously deleted items.
     */
    constructor(type: string, records: ContextDeleteRecord[]);
}
/**
 * An event dispatched when a context store object has been deleted.
 * In general a single context store uses the same event to dispatch the change record.
 * For example the `data-store` dispatches the `x` event and the change record has the
 * `kind` property that is used to recognize the type of the data object.
 */
export declare class ContextStateDeleteEvent extends CustomEvent<ContextDeleteRecord> {
    /**
     * @param type The type of the event to dispatch.
     * @param record The delete record.
     */
    constructor(type: string, record: ContextDeleteRecord);
}
/**
 * An event dispatched when a context store object has been updated.
 */
export declare class ContextStateUpdateEvent<T> extends CustomEvent<ContextChangeRecord<T>> {
    /**
     * @param type The type of the event to dispatch.
     * @param record The delete record.
     */
    constructor(type: string, record: ContextChangeRecord<T>);
}
export interface ContextUpdateEventDetail<T> {
    /**
     * The context store object to be updated by the context provider.
     */
    item: T;
    /**
     * The key of the parent object, if applicable.
     */
    parent?: string;
}
export interface ContextUpdateBulkEventDetail<T = unknown> {
    /**
     * The list of context store objects to be updated by the context provider.
     */
    items: T[];
    /**
     * The key of the parent object, if applicable.
     */
    parent?: string;
}
/**
 * An event that is dispatched to update the entire object in the store.
 * This is equivalent to PUT operation in REST HTTP.
 *
 * @template T The object that is being updated.
 * @template U The object that is returned by the context store after updating. By default it is the `T`.
 */
export declare class ContextUpdateEvent<T extends object, U = T> extends ContextEvent<ContextUpdateEventDetail<T>, ContextChangeRecord<U>> {
}
/**
 * An event that is dispatched to update a list of objects in the store.
 * This is equivalent to PUT operation in REST HTTP.
 *
 * If there's a parent, this event only allows to update entities in bulk for the same parent.
 *
 * @template T The object that is being updated.
 * @template U The object that is returned by the context store after updating. By default it is the `T`.
 */
export declare class ContextUpdateBulkEvent<T extends object, U = T> extends ContextEvent<ContextUpdateBulkEventDetail<T>, IBulkOperationResult<ContextChangeRecord<U>>> {
}
/**
 * Data store query result object.
 */
export interface ContextListResult<T> {
    /**
     * The cursor to use with the next query. It has the list state encoded in it.
     */
    cursor?: string;
    /**
     * The list of items in the response.
     * May be empty array when there was no more results.
     */
    items: T[];
}
/**
 * Defines the type of comparison or operation to be performed on a field.
 * - eq: Equal
 * - neq: Not Equal
 * - gt: Greater Than
 * - lt: Less Than
 * - gte: Greater Than or Equal
 * - lte: Less Than or Equal
 * - con: String contains substring / Array contains element
 * - start: String starts with
 * - end: String ends with
 * - in: Value is one of the elements in the provided array
 * - nin: Value is not one of the elements in the provided array
 */
export type FilterOperator = 'eq' | 'neq' | 'gt' | 'lt' | 'gte' | 'lte' | 'con' | 'start' | 'end' | 'in' | 'nin';
/**
 * Represents a single filter condition applied to a field.
 */
export interface AtomicFilter {
    field: string;
    operator: FilterOperator;
    value?: unknown;
}
/**
 * Represents a group of filters combined with a logical operator.
 * This allows for nesting and complex query construction.
 */
export interface FilterGroup {
    op: 'AND' | 'OR';
    filters: (AtomicFilter | FilterGroup)[];
}
/**
 * Represents a filter that can be either a single atomic condition
 * or a group of conditions. This is the type to be used in ContextListOptions.
 */
export type QueryFilter = AtomicFilter | FilterGroup;
/**
 * Base query options for the data store.
 */
export interface ContextListOptions {
    /**
     * The number of results per the page.
     */
    limit?: number;
    /**
     * Page cursor to use with the query. This is returned by the API.
     */
    cursor?: string;
    /**
     * The name of the field to order then results.
     */
    sort?: string;
    /**
     * The order of the results. This is used when the `sort` property is set.
     * It can be `asc` or `desc`.
     */
    order?: 'asc' | 'desc';
    /**
     * Used when synchronizing data in the local store with the data stored in the net-store.
     * The timestamp when the last synchronization was performed. The resulting array will contain only items that
     * have been updated since that date.
     */
    since?: number;
    /**
     * Optional parent identifier for hierarchical queries.
     * Some specific list operations might use this directly.
     */
    parent?: string;
    /**
     * Optional organization identifier.
     * Some specific list operations might use this directly if not part of the main path.
     */
    oid?: string;
    /**
     * Optional user id to filter results by the user
     */
    uid?: string;
    /**
     * A structured filter object for advanced querying.
     */
    filter?: QueryFilter;
}
export declare class ContextListEvent<T> extends ContextEvent<ContextListOptions, ContextListResult<T>> {
    /**
     * @param type The type of the event
     * @param opts Query options.
     */
    constructor(type: string, opts?: ContextListOptions);
}
export interface IQueryDetail {
    /**
     * The query term. All values are always passed as string. Context store must parse value if it requires other types.
     */
    term: string;
    /**
     * If the context store supports it, the tags to use with the query function to limit the results.
     */
    tags?: string[];
    /**
     * General purpose type to be defined by the context store.
     * Allows to specify the type of the query to perform.
     */
    type?: string;
    /**
     * General purpose keyword to be defined by the context store.
     * The purpose is to instruct the context store to perform detailed search.
     * Usually this means longer search time but more accurate results.
     */
    detailed?: boolean;
}
export interface IQueryResponse<T = unknown> {
    /**
     * An ordered list of results.
     */
    items: IQueryResult<T>[];
}
export interface IQueryResult<T = unknown> {
    /**
     * The document.
     */
    doc: T;
    /**
     * The list of indexes where this document was found.
     */
    index: string[];
}
/**
 * An event dispatched to the context store to perform a query operation.
 * If the context store supports the query operation, it should use the definition
 * of `IQueryDetail` to perform the query.
 * The result is the list of objects ordered by the store from the most relevant items to the least.
 *
 * The implementation should not assume pagination and return enough results
 * for the user to find what they were looking for
 * or to redefine the query. Suggested limit is `50` which in many cases is equivalent of 2 pages of results.
 */
export declare class ContextQueryEvent<T = unknown> extends ContextEvent<IQueryDetail, IQueryResponse<T>> {
}
/**
 * Query options to list history for a request in a project.
 * The user has to have access to the parent user organization to read / create / delete the history.
 */
export interface IHistoryRequestListOptions extends ContextListOptions {
    type: 'request';
    /**
     * The key of the parent organization.
     */
    organization: string;
    /**
     * The id of the project that contains the request.
     */
    project: string;
    /**
     * The id of the request.
     */
    id: string;
    /**
     * Whether to limit the list of results to the history that belongs to the current user.
     */
    user?: boolean;
}
/**
 * Listing options for the HTTP history.
 */
export type HistoryListOptions = IHistoryRequestListOptions;
export interface IProjectExecutionListOptions extends ContextListOptions {
    /**
     * The key of the parent organization.
     */
    organization: string;
    /**
     * The id of the parent project
     */
    project: string;
    /**
     * The key of the application that made the records.
     * This is optional and will returns results for the project made in all apps.
     */
    app?: string;
    /**
     * The key of the parent folder, if any.
     * Note, when this is not provided the endpoint only returns list of logs
     * created for the project.
     */
    parent?: string;
    /**
     * The user id that made that project run. Optional.
     */
    user?: string;
}
/**
 * @deprecated Use `PatchInfo` instead
 */
export interface IPatchBase {
    /**
     * Auto generated by the client sending the PATCH.
     */
    id: string;
    /**
     * The application id that generated the patch.
     * This is a string that is assigned to each application in the suite.
     * External applications need to use a constant string for their apps.
     */
    app: string;
    /**
     * The version of the application that generated the patch.
     * This can and will be used to handle potential differences between suite applications.
     */
    appVersion: string;
    /**
     * The patch generated by the client.
     */
    patch: unknown;
    /**
     * The current timestamp.
     */
    timestamp: number;
}
/**
 * An interface describing a schema to be sent to the server
 * when making a patch of a file.
 * @deprecated Use `MediaPatchInfo` instead
 */
export interface IPatchInfo extends IPatchBase {
    /**
     * The patch generated by the client.
     */
    patch: Operation[];
}
/**
 * A schema sent by the store server in a response to the patch request.
 * It contains an information about the applied patch, the reverse operation associated with it,
 * application information, and the generated by the client patch id.
 * @deprecated Use `MediaPatchRevision` instead
 */
export interface IPatchRevision extends IPatchInfo {
    /**
     * The patch to apply to the object to revert the changes.
     */
    revert: Operation[];
}
//# sourceMappingURL=BaseEvents.d.ts.map