""" AUTHOR: Khushal P Soonderji DATE: Thursday, 20th Feb., 2025. OBJECTIVE: To give a general response structure to anything happening inside a function. REFERENCES: N/A DOWNLOADS: N/A """ # ***************************************************************************************************************** # ***** **** # *** IMPORT *** # ***** **** # ***************************************************************************************************************** # To make sibling directories accessible for imports: import sys sys.path.append(".") sys.path.append("..") # For making data behaviour_models: from pydantic import BaseModel, Field from typing import Any # To work with MongoDB: from bson.objectid import ObjectId # ***************************************************************************************************************** # ***** **** # *** MACROS / ONE-TIME INIT *** # ***** **** # ***************************************************************************************************************** # --- Nothing Yet # ***************************************************************************************************************** # ***** **** # *** VARIABLES *** # ***** **** # ***************************************************************************************************************** # --- Nothing Yet # ***************************************************************************************************************** # ***** **** # *** FUNCTIONS *** # ***** **** # ***************************************************************************************************************** class FunctionCallResponse(BaseModel): success: bool = Field( description = "Whether, or not, the objective of the function was achieved.", frozen = False, default = False ) message: str = Field( description = "A brief message to indicate what happened in the process of executing the function.", frozen = False, default = "ERR: Message NOT captured." ) exception: Exception = Field( description = "Any exception that occurred in the process of execution.", frozen = False, default = None ) data: Any = Field( description = "Any data to be returned from the function that would be useful outside.", frozen = False, default = None ) key: ObjectId = Field( description = "the expendable reference to this auth; expose this to the ui", frozen = True, default_factory = lambda: ObjectId() ) # ┏┓ ┏• # ┃ ┏┓┏┓╋┓┏┓ # ┗┛┗┛┛┗┛┗┗┫ # ┛ class Config: extra = "forbid" arbitrary_types_allowed = True def model_dump(self, *args, **kwargs): return super().model_dump(*args, by_alias = True, **kwargs) # ┓┏ ┓• ┓ • # ┃┃┏┓┃┓┏┫┏┓╋┓┏┓┏┓ # ┗┛┗┻┗┗┗┻┗┻┗┗┗┛┛┗ pass # ***************************************************************************************************************** # ***** **** # *** MAIN PROGRAM *** # ***** **** # ***************************************************************************************************************** if __name__ == "__main__": pass