/*! PrivMX Web Endpoint. Copyright © 2024 Simplito sp. z o.o. This file is part of the PrivMX Platform (https://privmx.dev). This software is Licensed under the PrivMX Free License. See the License for the specific language governing permissions and limitations under the License. */ import { BaseApi } from "./BaseApi"; import { KvdbApiNative } from "../api/KvdbApiNative"; import { PagingQuery, PagingList, UserWithPubKey, Kvdb, ContainerPolicy, KvdbEntry, DeleteEntriesResult, KvdbEventSelectorType, KvdbEventType } from "../Types"; export declare class KvdbApi extends BaseApi { protected native: KvdbApiNative; constructor(native: KvdbApiNative, ptr: number); /** * Creates a new KVDB in given Context. * * @param {string} contextId ID of the Context to create the KVDB in * @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created KVDB * @param {UserWithPubKey[]} managers array of UserWithPubKey structs which indicates who will have access (and management rights) to * the created KVDB * @param {Uint8Array} publicMeta public (unencrypted) metadata * @param {Uint8Array} privateMeta private (encrypted) metadata * @param {ContainerPolicy} policies KVDB's policies * @returns {string} ID of the created KVDB */ createKvdb(contextId: string, users: UserWithPubKey[], managers: UserWithPubKey[], publicMeta: Uint8Array, privateMeta: Uint8Array, policies?: ContainerPolicy): Promise; /** * Updates an existing KVDB. * * @param {string} kvdbId ID of the KVDB to update * @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created KVDB * @param {UserWithPubKey[]} managers array of UserWithPubKey structs which indicates who will have access (and management rights) to * the created KVDB * @param {Uint8Array} publicMeta public (unencrypted) metadata * @param {Uint8Array} privateMeta private (encrypted) metadata * @param {number} version current version of the updated KVDB * @param {boolean} force force update (without checking version) * @param {boolean} forceGenerateNewKey force to regenerate a key for the KVDB * @param {ContainerPolicy} policies KVDB's policies */ updateKvdb(kvdbId: string, users: UserWithPubKey[], managers: UserWithPubKey[], publicMeta: Uint8Array, privateMeta: Uint8Array, version: number, force: boolean, forceGenerateNewKey: boolean, policies?: ContainerPolicy): Promise; /** * Deletes a KVDB by given KVDB ID. * * @param {string} kvdbId ID of the KVDB to delete */ deleteKvdb(kvdbId: string): Promise; /** * Gets a KVDB by given KVDB ID. * * @param {string} kvdbId ID of KVDB to get * @returns {Kvdb} containing info about the KVDB */ getKvdb(kvdbId: string): Promise; /** * Gets a list of Kvdbs in given Context. * * @param {string} contextId ID of the Context to get the Kvdbs from * @param {PagingQuery} pagingQuery with list query parameters * @returns {PagingList} containing a list of Kvdbs */ listKvdbs(contextId: string, pagingQuery: PagingQuery): Promise>; /** * Gets a KVDB entry by given KVDB entry key and KVDB ID. * * @param {string} kvdbId KVDB ID of the KVDB entry to get * @param {string} key key of the KVDB entry to get * @returns {KvdbEntry} containing the KVDB entry */ getEntry(kvdbId: string, key: string): Promise; /** * Check whether the KVDB entry exists. * * @param {string} kvdbId KVDB ID of the KVDB entry to check * @param {string} key key of the KVDB entry to check * @returns {boolean} 'true' if the KVDB has an entry with given key, 'false' otherwise */ hasEntry(kvdbId: string, key: string): Promise; /** * Gets a list of KVDB entries keys from a KVDB. * * @param {string} kvdbId ID of the KVDB to list KVDB entries from * @param {PagingQuery} pagingQuery with list query parameters * @returns {PagingList} containing a list of KVDB entries */ listEntriesKeys(kvdbId: string, pagingQuery: PagingQuery): Promise>; /** * Gets a list of KVDB entries from a KVDB. * * @param {string} kvdbId ID of the KVDB to list KVDB entries from * @param {PagingQuery} pagingQuery with list query parameters * @returns {PagingList} containing a list of KVDB entries */ listEntries(kvdbId: string, pagingQuery: PagingQuery): Promise>; /** * Sets a KVDB entry in the given KVDB. * @param {string} kvdbId ID of the KVDB to set the entry to * @param {string} key KVDB entry key * @param {Uint8Array} publicMeta public KVDB entry metadata * @param {Uint8Array} privateMeta private KVDB entry metadata * @param {Uint8Array} data content of the KVDB entry * @param {number} [version] KVDB entry version (when updating the entry) * @returns {string} ID of the KVDB entry */ setEntry(kvdbId: string, key: string, publicMeta: Uint8Array, privateMeta: Uint8Array, data: Uint8Array, version?: number): Promise; /** * Deletes a KVDB entry by given KVDB entry ID. * * @param {string} kvdbId KVDB ID of the KVDB entry to delete * @param {string} key key of the KVDB entry to delete */ deleteEntry(kvdbId: string, key: string): Promise; /** * Deletes KVDB entries by given KVDB IDs and the list of entry keys. * * @param {string} kvdbId ID of the KVDB database to delete from * @param {string[]} keys keys of the KVDB entries to delete * @returns {Map} map with the statuses of deletion for every key */ deleteEntries(kvdbId: string, keys: string[]): Promise; /** * Subscribe for the KVDB events on the given subscription query. * * @param {string[]} subscriptionQueries list of queries * @return list of subscriptionIds in maching order to subscriptionQueries */ subscribeFor(subscriptionQueries: string[]): Promise; /** * Unsubscribe from events for the given subscriptionId. * @param {string[]} subscriptionIds list of subscriptionId */ unsubscribeFrom(subscriptionIds: string[]): Promise; /** * Generate subscription Query for the KVDB events. * @param {EventType} eventType type of event which you listen for * @param {EventSelectorType} selectorType scope on which you listen for events * @param {string} selectorId ID of the selector */ buildSubscriptionQuery(eventType: KvdbEventType, selectorType: KvdbEventSelectorType, selectorId: string): Promise; /** * Generate subscription Query for the KVDB events for single KvdbEntry. * @param {EventType} eventType type of event which you listen for * @param {string} kvdbId ID of the KVDB * @param {string} kvdbEntryKey Key of Kvdb Entry */ buildSubscriptionQueryForSelectedEntry(eventType: KvdbEventType, kvdbId: string, kvdbEntryKey: string): Promise; }