update types

This commit is contained in:
Benjamin Toby
2024-10-11 10:26:00 +01:00
parent d9b9076bb2
commit 11a4c1f4d9
8 changed files with 104 additions and 94 deletions
+2 -27
View File
@@ -18,31 +18,6 @@ const localAddUser = require("../engine/user/add-user");
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* @typedef {object} SuccessUserObject
* @property {number} id
* @property {string} first_name
* @property {string} last_name
* @property {string} email
*/
/**
* @typedef {object} FunctionReturn
* @property {boolean} success - Did the function run successfully?
* @property {SuccessUserObject | null} [payload] - Payload
* @property {string} [msg]
* @property {any} [sqlResult]
*/
/**
* @typedef {object} UserDataPayload
* @property {string} first_name - First Name *Required
* @property {string} last_name - Last Name *Required
* @property {string} email - Email *Required
* @property {string} password - Password *Required
* @property {string?} username - Username (Optional)
*/
/**
* Add User to Database
* ==============================================================================
@@ -51,11 +26,11 @@ const localAddUser = require("../engine/user/add-user");
* @param {object} props - Single object passed
* @param {string} props.key - FULL ACCESS API Key
* @param {string} props.database - Database Name
* @param {UserDataPayload} props.payload - User Data Payload
* @param {import("../types/user.td").UserDataPayload} props.payload - User Data Payload
* @param {string} props.encryptionKey
* @param {string} [props.encryptionSalt]
*
* @returns { Promise<FunctionReturn> }
* @returns { Promise<import("../types/user.td").AddUserFunctionReturn> }
*/
async function addUser({
key,
+1 -18
View File
@@ -14,23 +14,6 @@ const getLocalUser = require("../engine/user/get-user");
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* @typedef {object} FunctionReturn
* @property {boolean} success - Did the function run successfully?
* @property {{
* id: number,
* first_name: string,
* last_name: string,
* username: string,
* email: string,
* phone: string,
* social_id: [string],
* image: string,
* image_thumbnail: string,
* verification_status: [number=0],
* }} payload - Payload
*/
/**
* ==============================================================================
* Main Function
@@ -43,7 +26,7 @@ const getLocalUser = require("../engine/user/get-user");
* @param {number} params.userId - user id
* @param {string[]} [params.fields] - fields to select
*
* @returns { Promise<FunctionReturn>}
* @returns { Promise<import("../types/user.td").GetUserFunctionReturn>}
*/
async function getUser({ key, userId, database, fields }) {
/**
+1 -10
View File
@@ -21,15 +21,6 @@ const localReauthUser = require("../engine/user/reauth-user");
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* @typedef {object} FunctionReturn
* @property {boolean} success - Did the function run successfully?
* @property {import("../types/user.td").DATASQUIREL_LoggedInUser | null} payload - Payload
* @property {string} [msg] - Response Message
* @property {number} [userId] - user ID
* @property {string} [token] - new Token
*/
/**
* ==============================================================================
* Main Function
@@ -47,7 +38,7 @@ const localReauthUser = require("../engine/user/reauth-user");
* @param {string[]} [params.additionalFields] - Additional Fields to be added to the user object
* @param {string} [params.token] - access token to use instead of getting from cookie header
*
* @returns { Promise<FunctionReturn> }
* @returns { Promise<import("../types/user.td").ReauthUserFunctionReturn> }
*/
async function reauthUser({
key,
+1 -7
View File
@@ -18,12 +18,6 @@ const localUpdateUser = require("../engine/user/update-user");
/** ****************************************************************************** */
/** ****************************************************************************** */
/**
* @typedef {object} FunctionReturn
* @property {boolean} success - Did the function run successfully?
* @property {(Object[]|string)} [payload=[]] - Payload
*/
/**
* ==============================================================================
* Main Function
@@ -35,7 +29,7 @@ const localUpdateUser = require("../engine/user/update-user");
* @param {String} params.database - Target Database
* @param {{ id: number } & Object.<string, *>} params.payload - User Object: ID is required
*
* @returns { Promise<FunctionReturn>}
* @returns { Promise<import("../types/user.td").UpdateUserFunctionReturn>}
*/
async function updateUser({ key, payload, database }) {
/**