Source: types.js

// @ts-check

/**
 * Common type definitions for the application
 * Import these in your files with: import './types.js'
 */

/**
 * @typedef {Object} SessionData
 * @property {string} [root] - The root organization UUID
 * @property {string} [user] - The database member UUID
 * @property {string} [baseUser] - The base user UUID
 * @property {string} [loginOrga] - The login organization UUID from token
 * @property {string} [sysUser] - System user UID (often used as organization/system admin)
 * @property {any} [authUser] - Authenticated user from bearer token (groups, orgRoles, etc.)
 * @property {function(function(Error): void): void} save - Save session data
 * @property {function(function(Error): void): void} destroy - Destroy session
 * @property {function(): void} regenerate - Regenerate session ID
 * @property {function(): void} reload - Reload session data
 */

/**
 * @typedef {Object} ExpressRequest
 * @property {any} [params] - Route parameters
 * @property {any} [query] - Query string parameters  
 * @property {any} [body] - Request body
 * @property {string} [method] - HTTP method
 * @property {string} [url] - Request URL
 * @property {any} [headers] - Request headers
 * @property {any} [user] - Authenticated user object
 * @property {SessionData} [session] - Session data
 */

/**
 * @typedef {Object} ExpressRequestAuthorized
 * @property {any} [params] - Route parameters
 * @property {any} [query] - Query string parameters  
 * @property {any} [body] - Request body
 * @property {string} [method] - HTTP method
 * @property {string} [url] - Request URL
 * @property {any} [headers] - Request headers
 * @property {Object} [user] - Authenticated user object
 * @property {Object} session - Session data (guaranteed to exist for authorized requests)
 * @property {string} session.root - The root organization UUID
 * @property {string} session.user - The database member UUID
 * @property {string} [session.baseUser] - The base user UUID
 * @property {string} [session.loginOrga] - The login organization UUID from token
 * @property {any} [session.authUser] - Authenticated user from bearer token
 * @property {string} [session.sysUser] - System user UID (often used as organization/system admin)
 * @property {function(function(Error): void): void} session.save - Save session data
 * @property {function(function(Error): void): void} session.destroy - Destroy session
 */


/**
 * @typedef {Object} ExpressResponse
 * @property {function(number): ExpressResponse} status - Set status code
 * @property {function(any): ExpressResponse} json - Send JSON response
 * @property {function(any): ExpressResponse} send - Send response
* @property {function(string, any): ExpressResponse} set - Set header
 * @property {function(): ExpressResponse} end - End response
 */

/**
 * @typedef {Object} ServiceResult
 * @property {boolean} success - Whether the operation was successful
 * @property {any} [result] - Result data if successful
 * @property {any} [error] - Error message if unsuccessful
 * @property {string} [UIDaction] - Action UID for some operations
 */

/**
 * @typedef {Object} DatabaseQueryOptions
 * @property {boolean} [log] - Whether to log the query
 * @property {string[]} [cast] - Fields to cast to JSON
 * @property {boolean} [batch] - Whether this is a batch operation
 * @property {function(any, any): any} [group] - Grouping function for results
 */

/**
 * @typedef {Object} OrganizationData
 * @property {string} UID - Organization unique identifier
 * @property {string} name - Organization name
 * @property {any} [data] - Additional organization data
 */

/**
 * @typedef {Object} FilterData
 * @property {string} UID - Filter unique identifier
 * @property {string} Type - Filter type (include, exclude, intersect)
 * @property {any} Data - Filter configuration
 * @property {string} [SourceType] - Source type (group, list, etc.)
 * @property {string} [listUID] - Associated list UID
 */

/**
 * @typedef {'visible'|'changeable'|'include'|'exclude'|'intersect'} FilterAction
 */



/**
 * @typedef {Object} MemberData
 * @property {Buffer|string} UID - Member unique identifier
 * @property {Buffer|string} UIDBelongsTo - Parent object identifier
 * @property {string} Type - Object type
 * @property {any} Data - Member data
 * @property {string} [Title] - Optional title
 * @property {boolean} [new] - Whether this is a new entry
 */

/**
 * @typedef {function(ExpressRequest, ExpressResponse): Promise<void>} ControllerFunction
 */


/**
 * @typedef {Object} FilterOptions
 * @property {boolean} [virtual=false] - Whether this is a virtual operation (no permanent changes)
 * @property {any} [connection=null] - Database connection for transactions
 */

/**
 * @typedef {Object} treeAction - The action object containing details about the operation to be performed.
 * @param {string} treeAction.Type - The type of action to be performed. Supported types include:
 *                                'visible', 'changeable', 'include', 'exclude', 'intersect', 'listMember', 'list',
 *                                'function', 'functionV', 'family', 'familyB', 'familySync', 'listVisibility', 
 *                                'guest', 'ggroup', 'group', 'person', 'job', 'eventJob'.
 * @param {Buffer} treeAction.UIDObjectID - The unique identifier of the object being acted upon.
 * @param {Buffer} treeAction.UIDnewTarget - The unique identifier of the newtarget object.
 * Express@param {Buffer} treeAction.UIDoldTarget - The unique identifier of the oldtarget object.
 * @param {Buffer} treeAction.UIDBelongsTo - The unique identifier of the parent object, Member Object.
 * @param {Buffer} treeAction.UIDroot - The unique identifier of the organization.
 * @param {Buffer} treeAction.UIDuser - The unique identifier of the user requesting the action.
 * @param {number} treeAction.timestamp - The timestamp of the action, used for system time queries.
**/
export {}; // Make this a module