@simplito/privmx-webendpoint
Version:
PrivMX Web Endpoint library
125 lines (122 loc) • 5.67 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 { ThreadApiNative } from "../api/ThreadApiNative";
import { PagingQuery, PagingList, UserWithPubKey, Thread, Message, ContainerPolicy } from "../Types";
export declare class ThreadApi extends BaseApi {
protected native: ThreadApiNative;
constructor(native: ThreadApiNative, ptr: number);
/**
* Creates a new Thread in given Context.
*
* @param {string} contextId ID of the Context to create the Thread in
* @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created Thread
* @param {UserWithPubKey[]} managers array of UserWithPubKey structs which indicates who will have access (and management rights) to
* the created Thread
* @param {Uint8Array} publicMeta public (unencrypted) metadata
* @param {Uint8Array} privateMeta private (encrypted) metadata
* @param {ContainerPolicy} policies Thread's policies
* @returns {string} ID of the created Thread
*/
createThread(contextId: string, users: UserWithPubKey[], managers: UserWithPubKey[], publicMeta: Uint8Array, privateMeta: Uint8Array, policies?: ContainerPolicy): Promise<string>;
/**
* Updates an existing Thread.
*
* @param {string} threadId ID of the Thread to update
* @param {UserWithPubKey[]} users array of UserWithPubKey structs which indicates who will have access to the created Thread
* @param {UserWithPubKey[]} managers array of UserWithPubKey structs which indicates who will have access (and management rights) to
* the created Thread
* @param {Uint8Array} publicMeta public (unencrypted) metadata
* @param {Uint8Array} privateMeta private (encrypted) metadata
* @param {number} version current version of the updated Thread
* @param {boolean} force force update (without checking version)
* @param {boolean} forceGenerateNewKey force to regenerate a key for the Thread
* @param {ContainerPolicy} policies Thread's policies
*/
updateThread(threadId: string, users: UserWithPubKey[], managers: UserWithPubKey[], publicMeta: Uint8Array, privateMeta: Uint8Array, version: number, force: boolean, forceGenerateNewKey: boolean, policies?: ContainerPolicy): Promise<void>;
/**
* Deletes a Thread by given Thread ID.
*
* @param {string} threadId ID of the Thread to delete
*/
deleteThread(threadId: string): Promise<void>;
/**
* Gets a Thread by given Thread ID.
*
* @param {string} threadId ID of Thread to get
* @returns {Thread} struct containing info about the Thread
*/
getThread(threadId: string): Promise<Thread>;
/**
* Gets a list of Threads in given Context.
*
* @param {string} contextId ID of the Context to get the Threads from
* @param {PagingQuery} pagingQuery struct with list query parameters
* @returns {PagingList<Thread>} struct containing a list of Threads
*/
listThreads(contextId: string, pagingQuery: PagingQuery): Promise<PagingList<Thread>>;
/**
* Gets a message by given message ID.
*
* @param {string} messageId ID of the message to get
* @returns {Message} struct containing the message
*/
getMessage(messageId: string): Promise<Message>;
/**
* Gets a list of messages from a Thread.
*
* @param {string} threadId ID of the Thread to list messages from
* @param {PagingQuery} pagingQuery struct with list query parameters
* @returns {PagingList<Message>} struct containing a list of messages
*/
listMessages(threadId: string, pagingQuery: PagingQuery): Promise<PagingList<Message>>;
/**
* Sends a message in a Thread.
*
* @param {string} threadId ID of the Thread to send message to
* @param {Uint8Array} publicMeta public message metadata
* @param {Uint8Array} privateMeta private message metadata
* @param {Uint8Array} data content of the message
* @returns {string} ID of the new message
*/
sendMessage(threadId: string, publicMeta: Uint8Array, privateMeta: Uint8Array, data: Uint8Array): Promise<string>;
/**
* Deletes a message by given message ID.
*
* @param {string} messageId ID of the message to delete
*/
deleteMessage(messageId: string): Promise<void>;
/**
* Update message in a Thread.
*
* @param {string} messageId ID of the message to update
* @param {Uint8Array} publicMeta public message metadata
* @param {Uint8Array} privateMeta private message metadata
* @param {Uint8Array} data content of the message
*/
updateMessage(messageId: string, publicMeta: Uint8Array, privateMeta: Uint8Array, data: Uint8Array): Promise<void>;
/**
* Subscribes for the Thread module main events.
*/
subscribeForThreadEvents(): Promise<void>;
/**
* Unsubscribes from the Thread module main events.
*/
unsubscribeFromThreadEvents(): Promise<void>;
/**
* Subscribes for events in given Thread.
* @param {string} threadId ID of the Thread to subscribe
*/
subscribeForMessageEvents(threadId: string): Promise<void>;
/**
* Unsubscribes from events in given Thread.
* @param {string} threadId ID of the Thread to unsubscribe
*/
unsubscribeFromMessageEvents(threadId: string): Promise<void>;
}