/** * Created by hubert on 8/06/17. */ import { OzoneClient } from 'ozone-typescript-client'; import { Item, UUID, FromOzone } from 'ozone-type'; import { SearchQuery } from 'ozone-search-helper'; import SearchIterator = OzoneClient.SearchIterator; import SearchResults = OzoneClient.SearchResults; /** * Function decorator decorator to be used to wait until * all other decorated function resolve. * This decorator is aimed to be used in class that implement StatefulOzone. * It's purpose is to wait others ozone call finish, before sending a next one. * */ export declare function lockRequest(): (target: StatefulOzone, propertyKey: string, descriptor: PropertyDescriptor) => void; export interface StatefulOzone { _currentRequest: Promise; } /** * `ozone-api-item` is low level es6 module to ozone api. * It provide CRUD operation and search in a given collection. * * * Example * ```javaScript * const ozoneApiSearch = new OzoneApiItem(); // return instance of OzoneApiItem located in the dom * const result = ozoneApiSearch.on('item').getOne('an-id'); * ``` * */ export declare class OzoneApiItem { /** * type of the ozone collection. * Default value is 'item' */ private collection; /** * set collection and return this to be chain by a query. * @param {string} collection * @return {OzoneApiItem} this */ on(collection: string): this; /** * Set ozone collection to query * @param {string} collection */ setCollection(collection: string): void; /** * Create or update a collection item. * @param data Item item to create. * @return {Promise} */ create(data: Partial): Promise | null>; /** * Create or update a collection item. * @param data Item item to update. * @return {Promise} */ update(data: Partial): Promise | null>; /** * get one collection item by uuid. * @param id * @return {Promise} */ getOne(id: UUID): Promise | null>; /** * delete one collection item by uuid. * @param id * @return {Promise} */ deleteOne(id: UUID): Promise; /** * get collection items from a list of id. * @param ids {Array} array of id to get * @return {Promise>} promise resole with an iterator of collection item */ bulkGet(ids: Array): Promise> | null>; /** * delete items from a list of id. * @param ids * @return {Promise>} promise resole with an array of deleted id */ bulkDelete(ids: Array): Promise | null>; /** * save an array of items * @param items * @return {Promise>} promise resole with an iterator of collection item */ bulkSave(items: Array>): Promise> | null>; /** * Submit ozone search query */ search(search: SearchQuery): Promise>; queryDelete(search: SearchQuery): Promise; } /** * Class helper to iterate on search result. * * Example: * ```javaScript * let searchQuery = new SearchQuery(); * searchQuery.quicksearch(''); * const searchGenerator = ozoneItemApi.search(searchQuery); * searchGenerator.next().then((searchResult)=>{ * searchResult.results.forEach((item)=>{ * this.push('items', item); * }) * }); * ``` */ export declare class SearchGenerator implements StatefulOzone { private searchIterator; _currentRequest: Promise; constructor(searchIterator: SearchIterator); /** * load next array of results * @return {Promise} */ next(): Promise>>; cancelRequest(): void; }