From 45a59776084fa4fa8349212269a97d6e9dab2c45 Mon Sep 17 00:00:00 2001 From: Rafael Araujo Lehmkuhl Date: Fri, 22 Nov 2024 13:26:42 -0300 Subject: [PATCH] cosmos: Add JSDocs for the global Cockpit APIs --- src/libs/cosmos.ts | 81 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 79 insertions(+), 2 deletions(-) diff --git a/src/libs/cosmos.ts b/src/libs/cosmos.ts index 41cc98050..ab113a515 100644 --- a/src/libs/cosmos.ts +++ b/src/libs/cosmos.ts @@ -82,26 +82,104 @@ declare global { sum(): number } - /* eslint-disable jsdoc/require-jsdoc */ + /** + * Extended Window interface with custom dedicated dedicated APIs. + */ interface Window { + /** + * Exposed Cockpit APIs + * E.g. data-lake, cockpit actions, etc. + */ cockpit: { // Data lake: + + /** + * The object that holds the data-lake variables data + */ cockpitActionVariableData: typeof cockpitActionVariableData + /** + * Get data from an specific data lake variable + * @param id - The id of the data to retrieve + * @returns The data or undefined if not available + */ getCockpitActionVariableData: typeof getCockpitActionVariableData + /** + * Listen to data changes on a specific data lake variable + * @param id - The id of the data to listen to + * @param listener - The listener callback + */ listenCockpitActionVariable: typeof listenCockpitActionVariable + /** + * Stop listening to data changes on a specific data lake variable + * @param id - The id of the data to stop listening to + */ unlistenCockpitActionVariable: typeof unlistenCockpitActionVariable + /** + * Get info about all variables in the data lake + * @returns Data lake data + */ getAllCockpitActionVariablesInfo: typeof getAllCockpitActionVariablesInfo + /** + * Get info about a specific variable in the data lake + * @param id - The id of the data to retrieve + * @returns The data info or undefined if not available + */ getCockpitActionVariableInfo: typeof getCockpitActionVariableInfo + /** + * Set the value of an specific data lake variable + * @param id - The id of the data to set + * @param value - The value to set + */ setCockpitActionVariableData: typeof setCockpitActionVariableData + /** + * Create a new variable in the data lake + * @param variable - The variable to create + * @param initialValue - The initial value for the variable + */ createCockpitActionVariable: typeof createCockpitActionVariable + /** + * Update information about an specific data lake variable + * @param variable - The variable to update + */ updateCockpitActionVariableInfo: typeof updateCockpitActionVariableInfo + /** + * Delete a variable from the data lake + * @param id - The id of the variable to delete + */ deleteCockpitActionVariable: typeof deleteCockpitActionVariable + // Cockpit actions: + + /** + * Get all available cockpit actions + * @returns Available cockpit actions + */ availableCockpitActions: typeof availableCockpitActions + /** + * Register a new cockpit action + * @param action - The action to register + */ registerNewAction: typeof registerNewAction + /** + * Delete a cockpit action + * @param id - The id of the action to delete + */ deleteAction: typeof deleteAction + /** + * Register a callback for a cockpit action + * @param action - The action to register the callback for + * @param callback - The callback to register + */ registerActionCallback: typeof registerActionCallback + /** + * Unregister a callback for a cockpit action + * @param id - The id of the action to unregister the callback for + */ unregisterActionCallback: typeof unregisterActionCallback + /** + * Execute the callback for a cockpit action + * @param id - The id of the action to execute the callback for + */ executeActionCallback: typeof executeActionCallback } /** @@ -115,7 +193,6 @@ declare global { getInfoOnSubnets: () => Promise } } - /* eslint-enable jsdoc/require-jsdoc */ } // Use global as window when running for browsers