import { Core, DataInsert } from '@minddrop/core'; import { TypedResourceApi, TypedResourceDocumentFilters } from '@minddrop/resources'; import { BaseCreateDropData, Drop, DropMap, DropTypeData, BaseUpdateDropData, DropBaseData } from './Drop.types'; import { DropTypeConfig, RegisteredDropTypeConfig, DropTypeConfigOptions } from './DropTypeConfig.types'; import { AddDropEvent, AddDropEventCallback, CreateDropEvent, CreateDropEventCallback, DeleteDropEvent, DeleteDropEventCallback, LoadDropsEvent, LoadDropsEventCallback, PermanentlyDeleteDropEvent, PermanentlyDeleteDropEventCallback, RegisterDropTypeEvent, RegisterDropTypeEventCallback, RemoveDropEvent, RemoveDropEventCallback, RestoreDropEvent, RestoreDropEventCallback, SetDropEventCallback, SetDropEventData, UnregisterDropTypeEvent, UnregisterDropTypeEventCallback, UpdateDropEvent, UpdateDropEventCallback } from './DropEvents.types'; export interface DropsApi extends TypedResourceApi { /** * Retrieves one or more drops by ID. * * If provided a single ID string, returns the drop. * * If provided an array of IDs, returns a `{ [id]: Drop }` map of the corresponding drops. * Drops can be filtered by passing in DropFilters. Filtering is not supported when getting a single drop. * * @param ids - An array of drop IDs to retrieve. * @param filters - Filters to filter to the drops by, only supported when getting multiple drops. * @returns The requested drop(s). */ get(dropId: string): Drop; get(dropIds: string[], filters?: TypedResourceDocumentFilters): DropMap>; /** * Retrieves all drops from the drops store as a `{ [id]: Drop }` map. * Drops can be filtered by passing in DropFilters. * * @param filters - Filters to filter to the drops by. * @returns A `{ [id]: Drop }` map. */ getAll(filters?: TypedResourceDocumentFilters): DropMap>; /** * Returns the `DropTypeConfig` for a given drop type. * * @param type - The drop type for which to retrieve the config. */ getTypeConfig(type: string): RegisteredDropTypeConfig; /** * Returns all registered `DropTypeConfig`s. * * @returns An array of drop type configs. */ getAllTypeConfigs(): RegisteredDropTypeConfig[]; /** * Returns the `DataInsert` from which a drop was created, * or `null` if the drop was not created from a data insert * or the data insert is no longer in memory. * * @param dropId - The ID of the drop from which to retrieve the data insert. * @returns A data insert object or null. */ getDataInsert(dropId: string): DataInsert | null; /** * Filters drops by type, active, and deleted states. * If no filters are set, returns active drops. * If deleted filters is `true`, active drops are not * included unless specifically set to `true`. * * @param drops - The drops to filter. * @param filters The filters by which to filter the drops. * @returns The filtered drops. */ filter(drops: DropMap, filters: TypedResourceDocumentFilters): DropMap>; /** * Registers a new drop type and dispatches a `drops:drop:register` * event. * * @param core - A MindDrop core instance. * @param config - The configartion of the drop type to register. */ register(core: Core, config: DropTypeConfig): void; /** * Unregisters a drop type and dispatches a `drops:drop:unregister` event. * * @param core - A MindDrop core instance. * @param type - The type of drop to unregister. */ unregister(core: Core, config: DropTypeConfig): void; /** * Creates a new drop and dispatches a `drops:drop:create` event. * * @param core - A MindDrop core instance. * @param type - The type of drop to create. * @param data - The default drop property values. * @returns The newly created drop. * * @throws ResourceTypeNotRegisteredError * Thrown if the drop type is not registered. * * @throws ResourceValidationError * Thrown if the drop data is invalid. */ create(core: Core, type: string, data?: BaseCreateDropData & TTypeCreateData): Drop; /** * Creates drops of the appropriate type given a `DataInsert` object * and an array of `DropTypeConfig` objects. Returns a promise resolving * to a `{ [id]: Drop }` map of the created drops. Dispatches a * `drops:create` event for each created drop. * * @param core - A MindDrop core instance. * @param data - The data from which to create the drops. * @param configs - The drop configs from which to create the drops. */ createFromDataInsert(core: Core, dataInsert: DataInsert, configs: DropTypeConfig[]): DropMap; /** * Duplicates the given drops by creating new drops * with the same data. * * @param core - A MindDrop core instance. * @param dropIds - The IDs of the drops to duplicate. * @returns The new drops. */ duplicate(core: Core, dropIds: string[]): DropMap>; /** * Updates a drop and dispatches a `drops:drop:update` event. * * @param core - A MindDrop core instance. * @param id - The ID of the drop to update. * @param data - The changes to apply to the drop. * @returns The updated drop. */ update(core: Core, id: string, data: BaseUpdateDropData & TTypeUpdateData): Drop; /** * Soft deletes a drop and dispatches a `drops:drop:delete` event. * * Soft deleted drops can be restored using the `restore` * method. * * @param core - A MindDrop core instance. * @param dropId - The ID of the drop to delete. * @returns The deleted drop. */ delete(core: Core, dropId: string): Drop; /** * Restores a deleted drop and dispatches a * `drops:restore` event and a `drops:update` event. * * @param core A MindDrop core instance. * @param dropId The ID of the drop to restore. * @returns The restored drop. */ restore(core: Core, dropId: string): Drop; /** * Permanently deletes a drop and dispatches a * `drops:delete-permanently` event. * * @param core A MindDrop core instance. * @param dropId The ID of the drop to delete permanently. * @returns The deleted drop. */ deletePermanently(core: Core, dropId: string): Drop; addEventListener(core: Core, type: RegisterDropTypeEvent, callback: RegisterDropTypeEventCallback): void; addEventListener(core: Core, type: UnregisterDropTypeEvent, callback: UnregisterDropTypeEventCallback): void; addEventListener(core: Core, type: CreateDropEvent, callback: CreateDropEventCallback): void; addEventListener(core: Core, type: UpdateDropEvent, callback: UpdateDropEventCallback): void; addEventListener(core: Core, type: DeleteDropEvent, callback: DeleteDropEventCallback): void; addEventListener(core: Core, type: RestoreDropEvent, callback: RestoreDropEventCallback): void; addEventListener(core: Core, type: PermanentlyDeleteDropEvent, callback: PermanentlyDeleteDropEventCallback): void; addEventListener(core: Core, type: LoadDropsEvent, callback: LoadDropsEventCallback): void; addEventListener(core: Core, type: AddDropEvent, callback: AddDropEventCallback): void; addEventListener(core: Core, type: SetDropEventData, callback: SetDropEventCallback): void; addEventListener(core: Core, type: RemoveDropEvent, callback: RemoveDropEventCallback): void; removeEventListener(core: Core, type: RegisterDropTypeEvent, callback: RegisterDropTypeEventCallback): void; removeEventListener(core: Core, type: UnregisterDropTypeEvent, callback: UnregisterDropTypeEventCallback): void; removeEventListener(core: Core, type: CreateDropEvent, callback: CreateDropEventCallback): void; removeEventListener(core: Core, type: UpdateDropEvent, callback: UpdateDropEventCallback): void; removeEventListener(core: Core, type: DeleteDropEvent, callback: DeleteDropEventCallback): void; removeEventListener(core: Core, type: RestoreDropEvent, callback: RestoreDropEventCallback): void; removeEventListener(core: Core, type: PermanentlyDeleteDropEvent, callback: PermanentlyDeleteDropEventCallback): void; removeEventListener(core: Core, type: LoadDropsEvent, callback: LoadDropsEventCallback): void; removeEventListener(core: Core, type: AddDropEvent, callback: AddDropEventCallback): void; removeEventListener(core: Core, type: SetDropEventData, callback: SetDropEventCallback): void; removeEventListener(core: Core, type: RemoveDropEvent, callback: RemoveDropEventCallback): void; } //# sourceMappingURL=DropsApi.types.d.ts.map