/*! 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 { StoreApiNative } from "../api/StoreApiNative"; import { PagingQuery, PagingList, UserWithPubKey, Store, File, ContainerPolicy, StoreEventSelectorType, StoreEventType } from "../Types"; export declare class StoreApi extends BaseApi { private native; constructor(native: StoreApiNative, ptr: number); /** * Creates a new Store in given Context. * * @param {string} contextId ID of the Context to create the Store in * @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created Store * @param {UserWithPubKey[]} managers array of UserWithPubKey structs which indicates who will have access (and management rights) to the * created Store * @param {Uint8Array} publicMeta public (unencrypted) metadata * @param {Uint8Array} privateMeta private (encrypted) metadata * @param {ContainerPolicy} policies Store's policies * @returns {string} created Store ID */ createStore(contextId: string, users: UserWithPubKey[], managers: UserWithPubKey[], publicMeta: Uint8Array, privateMeta: Uint8Array, policies?: ContainerPolicy): Promise; /** * Updates an existing Store. * * @param {string} storeId ID of the Store to update * @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created Store * @param {UserWithPubKey[]} managers array of UserWithPubKey structs which indicates who will have access (and management rights) to the * created Store * @param {Uint8Array} publicMeta public (unencrypted) metadata * @param {Uint8Array} privateMeta private (encrypted) metadata * @param {number} version current version of the updated Store * @param {boolean} force force update (without checking version) * @param {boolean} forceGenerateNewKey force to regenerate a key for the Store * @param {ContainerPolicy} policies Store's policies */ updateStore(storeId: string, users: UserWithPubKey[], managers: UserWithPubKey[], publicMeta: Uint8Array, privateMeta: Uint8Array, version: number, force: boolean, forceGenerateNewKey: boolean, policies?: ContainerPolicy): Promise; /** * Deletes a Store by given Store ID. * * @param {string} storeId ID of the Store to delete */ deleteStore(storeId: string): Promise; /** * Gets a single Store by given Store ID. * * @param {string} storeId ID of the Store to get * @returns {Store} containing information about the Store */ getStore(storeId: string): Promise; /** * Gets a list of Stores in given Context. * * @param {string} contextId ID of the Context to get the Stores from * @param {PagingQuery} pagingQuery with list query parameters * @returns {PagingList} containing list of Stores */ listStores(contextId: string, pagingQuery: PagingQuery): Promise>; /** * Creates a new file in a Store. * * @param {string} storeId ID of the Store to create the file in * @param {Uint8Array} publicMeta public file metadata * @param {Uint8Array} privateMeta private file metadata * @param {number} size size of the file * @param {boolean} [randomWriteSupport] enable random write support for file * @returns {number} handle to write data */ createFile(storeId: string, publicMeta: Uint8Array, privateMeta: Uint8Array, size: number, randomWriteSupport?: boolean): Promise; /** * Update an existing file in a Store. * * @param {string} fileId ID of the file to update * @param {Uint8Array} publicMeta public file metadata * @param {Uint8Array} privateMeta private file metadata * @param {number} size size of the file * @returns {number} handle to write file data */ updateFile(fileId: string, publicMeta: Uint8Array, privateMeta: Uint8Array, size: number): Promise; /** * Update metadata of an existing file in a Store. * * @param {string} fileId ID of the file to update * @param {Uint8Array} publicMeta public file metadata * @param {Uint8Array} privateMeta private file metadata */ updateFileMeta(fileId: string, publicMeta: Uint8Array, privateMeta: Uint8Array): Promise; /** * Writes a file data. * * @param {number} fileHandle handle to write file data * @param {Uint8Array} dataChunk file data chunk * @param {boolean} [truncate] truncate the file from: current pos + dataChunk size */ writeToFile(fileHandle: number, dataChunk: Uint8Array, truncate?: boolean): Promise; /** * Deletes a file by given ID. * * @param {string} fileId ID of the file to delete */ deleteFile(fileId: string): Promise; /** * Gets a single file by the given file ID. * * @param {string} fileId ID of the file to get * @returns {File} containing information about the file */ getFile(fileId: string): Promise; /** * Gets a list of files in given Store. * * @param {string} storeId ID of the Store to get files from * @param {PagingQuery} pagingQuery with list query parameters * @returns {PagingList} containing list of files */ listFiles(storeId: string, pagingQuery: PagingQuery): Promise>; /** * Opens a file to read. * * @param {string} fileId ID of the file to read * @returns {number} handle to read file data */ openFile(fileId: string): Promise; /** * Reads file data. * Single read call moves the files's cursor position by declared length or set it at the end of the file. * * @param {string} fileHandle handle to write file data * @param {number} length size of data to read * @returns {Uint8Array} array buffer with file data chunk */ readFromFile(fileHandle: number, length: number): Promise; /** * Moves read cursor. * * @param {string} fileHandle handle to write file data * @param {number} position new cursor position */ seekInFile(fileHandle: number, position: number): Promise; /** * Closes the file handle. * * @param {string} fileHandle handle to read/write file data * @returns {string} ID of closed file */ closeFile(fileHandle: number): Promise; /** * Synchronize file handle data with newest data on server * * @param {number} fileHandle handle to read/write file data */ syncFile(fileHandle: number): Promise; /** * Subscribe for the Store 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 Store 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: StoreEventType, selectorType: StoreEventSelectorType, selectorId: string): Promise; }