import CustomEvent from './CustomEvent.js';
/**
 * A base class to use with context providers.
 */
export class ContextEvent extends CustomEvent {
    /**
     * @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, detail) {
        super(type, {
            bubbles: true,
            composed: true,
            cancelable: true,
            detail: {
                result: undefined,
                ...detail,
            },
        });
    }
}
/**
 * An event to be used to read a state from a context provider.
 */
export class ContextReadEvent extends ContextEvent {
    /**
     * @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, key, parent) {
        super(type, { key, parent });
    }
}
/**
 * An event to be used to read a list of object from the API store.
 */
export class ContextReadBulkEvent extends ContextEvent {
    /**
     * @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, keys, parent) {
        super(type, { keys, parent });
    }
}
/**
 * An event to be used to delete a state in the context provider.
 */
export class ContextDeleteEvent extends ContextEvent {
    /**
     * 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, key, parent) {
        super(type, { key, parent });
    }
}
/**
 * An event to be used to delete a number of entities in the context provider.
 */
export class ContextDeleteBulkEvent extends ContextEvent {
    /**
     * 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, keys, parent) {
        super(type, { keys, parent });
    }
}
/**
 * An event dispatched to the context store to restore previously deleted items.
 */
export class ContextRestoreEvent extends ContextEvent {
    /**
     * 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, records) {
        super(type, { records });
    }
}
/**
 * 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 class ContextStateDeleteEvent extends CustomEvent {
    /**
     * @param type The type of the event to dispatch.
     * @param record The delete record.
     */
    constructor(type, record) {
        super(type, {
            bubbles: true,
            composed: true,
            cancelable: false,
            detail: record,
        });
    }
}
/**
 * An event dispatched when a context store object has been updated.
 */
export class ContextStateUpdateEvent extends CustomEvent {
    /**
     * @param type The type of the event to dispatch.
     * @param record The delete record.
     */
    constructor(type, record) {
        super(type, {
            bubbles: true,
            composed: true,
            cancelable: false,
            detail: record,
        });
    }
}
/**
 * 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 class ContextUpdateEvent extends ContextEvent {
}
/**
 * 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 class ContextUpdateBulkEvent extends ContextEvent {
}
export class ContextListEvent extends ContextEvent {
    /**
     * @param type The type of the event
     * @param opts Query options.
     */
    constructor(type, opts = {}) {
        super(type, opts);
    }
}
/**
 * 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 class ContextQueryEvent extends ContextEvent {
}
//# sourceMappingURL=BaseEvents.js.map