@simplito/privmx-webendpoint
Version:
PrivMX Web Endpoint library
171 lines (168 loc) • 7.21 kB
TypeScript
/*!
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 } 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<string>;
/**
* 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<void>;
/**
* Deletes a Store by given Store ID.
*
* @param {string} storeId ID of the Store to delete
*/
deleteStore(storeId: string): Promise<void>;
/**
* Gets a single Store by given Store ID.
*
* @param {string} storeId ID of the Store to get
* @returns {Store} struct containing information about the Store
*/
getStore(storeId: string): Promise<Store>;
/**
* Gets a list of Stores in given Context.
*
* @param {string} contextId ID of the Context to get the Stores from
* @param {PagingQuery} pagingQuery struct with list query parameters
* @returns {PagingList<Store>} struct containing list of Stores
*/
listStores(contextId: string, pagingQuery: PagingQuery): Promise<PagingList<Store>>;
/**
* 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
* @returns {number} handle to write data
*/
createFile(storeId: string, publicMeta: Uint8Array, privateMeta: Uint8Array, size: number): Promise<number>;
/**
* 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<number>;
/**
* 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<void>;
/**
* Writes a file data.
*
* @param {number} fileHandle handle to write file data
* @param {Uint8Array} dataChunk file data chunk
*/
writeToFile(fileHandle: number, dataChunk: Uint8Array): Promise<void>;
/**
* Deletes a file by given ID.
*
* @param {string} fileId ID of the file to delete
*/
deleteFile(fileId: string): Promise<void>;
/**
* Gets a single file by the given file ID.
*
* @param {string} fileId ID of the file to get
* @returns {File} struct containing information about the file
*/
getFile(fileId: string): Promise<File>;
/**
* Gets a list of files in given Store.
*
* @param {string} storeId ID of the Store to get files from
* @param {PagingQuery} pagingQuery struct with list query parameters
* @returns {PagingList<File>} struct containing list of files
*/
listFiles(storeId: string, pagingQuery: PagingQuery): Promise<PagingList<File>>;
/**
* 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<number>;
/**
* 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<Uint8Array>;
/**
* Moves read cursor.
*
* @param {string} fileHandle handle to write file data
* @param {number} position new cursor position
*/
seekInFile(fileHandle: number, position: number): Promise<void>;
/**
* Closes the file handle.
*
* @param {string} fileHandle handle to read/write file data
* @returns {string} ID of closed file
*/
closeFile(fileHandle: number): Promise<string>;
/**
* Subscribes for the Store module main events.
*/
subscribeForStoreEvents(): Promise<void>;
/**
* Unsubscribes from the Store module main events.
*/
unsubscribeFromStoreEvents(): Promise<void>;
/**
* Subscribes for events in given Store.
* @param {string} storeId ID of the Store to subscribe
*/
subscribeForFileEvents(storeId: string): Promise<void>;
/**
* Unsubscribes from events in given Store.
* @param {string} storeId ID of the Store to unsubscribe
*/
unsubscribeFromFileEvents(storeId: string): Promise<void>;
}