@@ -7,6 +7,15 @@ import {
77 RocketChatAssociationRecord ,
88} from "@rocket.chat/apps-engine/definition/metadata" ;
99
10+ /**
11+ * Persists UI data using the provided persistence handler.
12+ *
13+ * @template T - The type of the data being persisted.
14+ * @param {IPersistence } persistence - The persistence handler to use for data storage.
15+ * @param {string } id - The identifier for the data being persisted.
16+ * @param {T } data - The data to be persisted.
17+ * @returns {Promise<void> } - A promise that resolves when the data has been successfully persisted.
18+ */
1019export const persistUIData = async < T > (
1120 persistence : IPersistence ,
1221 id : string ,
@@ -19,6 +28,14 @@ export const persistUIData = async <T>(
1928 await persistence . updateByAssociation ( association , data as any , true ) ;
2029} ;
2130
31+ /**
32+ * Retrieves UI data from the persistence layer based on the provided ID.
33+ *
34+ * @template T - The type of the UI data to be retrieved.
35+ * @param {IPersistenceRead } persistenceRead - The persistence read instance used to retrieve data.
36+ * @param {string } id - The ID used to identify the UI data.
37+ * @returns {Promise<T | null> } - A promise that resolves to the retrieved UI data or null if not found.
38+ */
2239export const getUIData = async < T > (
2340 persistenceRead : IPersistenceRead ,
2441 id : string
@@ -33,6 +50,13 @@ export const getUIData = async <T>(
3350 return result && result . length ? ( result [ 0 ] as any ) : null ;
3451} ;
3552
53+ /**
54+ * Clears the UI data associated with a specific ID.
55+ *
56+ * @param {IPersistence } persistence - The persistence object used for data storage.
57+ * @param {string } id - The ID of the data to be cleared.
58+ * @returns {Promise<void> } - A promise that resolves when the UI data is cleared.
59+ */
3660export const clearUIData = async (
3761 persistence : IPersistence ,
3862 id : string
0 commit comments