backfarm 1.0.5 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/{chunk-E2NNDV4O.js → chunk-237SVWEU.js} +2 -2
  2. package/dist/chunk-237SVWEU.js.map +1 -0
  3. package/dist/{chunk-RIBTACPE.js → chunk-346ZYI6W.js} +2 -2
  4. package/dist/chunk-346ZYI6W.js.map +1 -0
  5. package/dist/{chunk-ES6AHESH.js → chunk-3DJ6GERS.js} +3 -3
  6. package/dist/chunk-3DJ6GERS.js.map +1 -0
  7. package/dist/{chunk-UWIMSKL5.js → chunk-4L35JPDH.js} +2 -2
  8. package/dist/chunk-4L35JPDH.js.map +1 -0
  9. package/dist/{chunk-MKS3GPZY.js → chunk-5NVPS6PC.js} +6 -6
  10. package/dist/chunk-5NVPS6PC.js.map +1 -0
  11. package/dist/{chunk-P5XJG7OG.js → chunk-A7GR4LD2.js} +1 -1
  12. package/dist/chunk-A7GR4LD2.js.map +1 -0
  13. package/dist/{chunk-ECIP24BN.js → chunk-AS7JRX2N.js} +5 -5
  14. package/dist/chunk-AS7JRX2N.js.map +1 -0
  15. package/dist/{chunk-P4FWSZ43.js → chunk-AYXJEOSW.js} +7 -7
  16. package/dist/chunk-AYXJEOSW.js.map +1 -0
  17. package/dist/{chunk-O42S6QIG.js → chunk-DKFDGYXS.js} +6 -6
  18. package/dist/chunk-DKFDGYXS.js.map +1 -0
  19. package/dist/{chunk-QS4MDB5H.js → chunk-DWODHIWI.js} +41 -41
  20. package/dist/chunk-DWODHIWI.js.map +1 -0
  21. package/dist/{chunk-IAQMTSGP.js → chunk-EKT74VDD.js} +4 -4
  22. package/dist/chunk-EKT74VDD.js.map +1 -0
  23. package/dist/{chunk-OHDZYSL3.js → chunk-GMQU3OAU.js} +5 -5
  24. package/dist/chunk-GMQU3OAU.js.map +1 -0
  25. package/dist/{chunk-M2C6HHRK.js → chunk-GWPLCPRW.js} +2 -2
  26. package/dist/chunk-GWPLCPRW.js.map +1 -0
  27. package/dist/{chunk-QUZPQJRE.js → chunk-H3RM55WC.js} +2 -2
  28. package/dist/chunk-H3RM55WC.js.map +1 -0
  29. package/dist/{chunk-DRLEV7OW.js → chunk-IM22RSF7.js} +2 -2
  30. package/dist/chunk-IM22RSF7.js.map +1 -0
  31. package/dist/{chunk-SOZL76ZM.js → chunk-IT6LYD4L.js} +5 -5
  32. package/dist/chunk-IT6LYD4L.js.map +1 -0
  33. package/dist/{chunk-3IO4NPP3.js → chunk-IZEPCXYK.js} +1 -1
  34. package/dist/chunk-IZEPCXYK.js.map +1 -0
  35. package/dist/{chunk-WLJV5O6C.js → chunk-KYX4HMIY.js} +6 -6
  36. package/dist/chunk-KYX4HMIY.js.map +1 -0
  37. package/dist/{chunk-EWQYVPOL.js → chunk-LE2SDA4O.js} +1 -1
  38. package/dist/chunk-LE2SDA4O.js.map +1 -0
  39. package/dist/{chunk-T4KN3FCF.js → chunk-O5ILFRFV.js} +2 -2
  40. package/dist/chunk-O5ILFRFV.js.map +1 -0
  41. package/dist/{chunk-CBTP2HOO.js → chunk-QW2GGDEG.js} +2 -2
  42. package/dist/chunk-QW2GGDEG.js.map +1 -0
  43. package/dist/{chunk-LW246RDT.js → chunk-T4PLUOW3.js} +2 -2
  44. package/dist/chunk-T4PLUOW3.js.map +1 -0
  45. package/dist/{chunk-LNFYUCA3.js → chunk-VFJV227G.js} +2 -2
  46. package/dist/chunk-VFJV227G.js.map +1 -0
  47. package/dist/{chunk-2RFTNIPS.js → chunk-W2KVW35Y.js} +5 -5
  48. package/dist/chunk-W2KVW35Y.js.map +1 -0
  49. package/dist/{chunk-FNFFY5LD.js → chunk-XMWRNOBE.js} +2 -2
  50. package/dist/chunk-XMWRNOBE.js.map +1 -0
  51. package/dist/{chunk-ATY3REI3.js → chunk-XPJKMJBD.js} +5 -5
  52. package/dist/chunk-XPJKMJBD.js.map +1 -0
  53. package/dist/{chunk-QBBF6LZZ.js → chunk-ZC33GE2U.js} +2 -2
  54. package/dist/chunk-ZC33GE2U.js.map +1 -0
  55. package/dist/{chunk-CPECHQJJ.js → chunk-ZTTB4NMA.js} +3 -3
  56. package/dist/chunk-ZTTB4NMA.js.map +1 -0
  57. package/dist/engine/cloudBucket/r2Storage.js +3 -3
  58. package/dist/engine/mondoDb/mongoDB.js +3 -3
  59. package/dist/engine/multer/multer_configs.js +2 -2
  60. package/dist/engine/server/server.js +28 -28
  61. package/dist/engine/sql/mySql.js +3 -3
  62. package/dist/engine/sql/pgSql.js +3 -3
  63. package/dist/utility/libs/env.js +1 -1
  64. package/dist/utility/libs/index.js +28 -28
  65. package/dist/utility/libs/run-all.js +28 -28
  66. package/dist/utility/libs/run-bucket.js.map +1 -1
  67. package/dist/utility/libs/run-node-server.js +28 -28
  68. package/dist/utility/libs/run-node-server.js.map +1 -1
  69. package/dist/utility/libs/types.js +1 -1
  70. package/dist/utility/libs/types.js.map +1 -1
  71. package/dist/utility/utilis/cloud_storage/deleteFile.js +5 -5
  72. package/dist/utility/utilis/cloud_storage/deleteFiles.js +5 -5
  73. package/dist/utility/utilis/cloud_storage/downloadFile.js +6 -6
  74. package/dist/utility/utilis/cloud_storage/downloadFiles.js +6 -6
  75. package/dist/utility/utilis/cloud_storage/uploadFile.js +6 -6
  76. package/dist/utility/utilis/cloud_storage/uploadFiles.js +7 -7
  77. package/dist/utility/utilis/general/error_handler.js +1 -1
  78. package/dist/utility/utilis/general/file-operations.js +2 -2
  79. package/dist/utility/utilis/general/sqlDb.js.js +2 -2
  80. package/dist/utility/utilis/general/uuids.js +1 -1
  81. package/dist/utility/utilis/general/web.js +2 -2
  82. package/dist/utility/utilis/mongoDb/buldWrite.js +4 -4
  83. package/dist/utility/utilis/mongoDb/deleteDocument.js +4 -4
  84. package/dist/utility/utilis/mongoDb/insertField.js +4 -4
  85. package/dist/utility/utilis/mongoDb/insertFields.js +4 -4
  86. package/dist/utility/utilis/mongoDb/updateFiled.js +4 -4
  87. package/dist/utility/utilis/multer/upload_batch.js +3 -3
  88. package/dist/utility/utilis/multer/upload_single.js +3 -3
  89. package/dist/utility/utilis/postgres/executeQuery.js +8 -8
  90. package/dist/utility/utilis/postgres/subSqlfiles/executeMySqlQuery.js +4 -4
  91. package/dist/utility/utilis/postgres/subSqlfiles/executePgQuery.js +4 -4
  92. package/dist/utility/utilis/server/app.js +28 -28
  93. package/dist/utility/utilis/server/server.js +28 -28
  94. package/package.json +55 -55
  95. package/dist/chunk-2RFTNIPS.js.map +0 -1
  96. package/dist/chunk-3IO4NPP3.js.map +0 -1
  97. package/dist/chunk-ATY3REI3.js.map +0 -1
  98. package/dist/chunk-CBTP2HOO.js.map +0 -1
  99. package/dist/chunk-CPECHQJJ.js.map +0 -1
  100. package/dist/chunk-DRLEV7OW.js.map +0 -1
  101. package/dist/chunk-E2NNDV4O.js.map +0 -1
  102. package/dist/chunk-ECIP24BN.js.map +0 -1
  103. package/dist/chunk-ES6AHESH.js.map +0 -1
  104. package/dist/chunk-EWQYVPOL.js.map +0 -1
  105. package/dist/chunk-FNFFY5LD.js.map +0 -1
  106. package/dist/chunk-IAQMTSGP.js.map +0 -1
  107. package/dist/chunk-LNFYUCA3.js.map +0 -1
  108. package/dist/chunk-LW246RDT.js.map +0 -1
  109. package/dist/chunk-M2C6HHRK.js.map +0 -1
  110. package/dist/chunk-MKS3GPZY.js.map +0 -1
  111. package/dist/chunk-O42S6QIG.js.map +0 -1
  112. package/dist/chunk-OHDZYSL3.js.map +0 -1
  113. package/dist/chunk-P4FWSZ43.js.map +0 -1
  114. package/dist/chunk-P5XJG7OG.js.map +0 -1
  115. package/dist/chunk-QBBF6LZZ.js.map +0 -1
  116. package/dist/chunk-QS4MDB5H.js.map +0 -1
  117. package/dist/chunk-QUZPQJRE.js.map +0 -1
  118. package/dist/chunk-RIBTACPE.js.map +0 -1
  119. package/dist/chunk-SOZL76ZM.js.map +0 -1
  120. package/dist/chunk-T4KN3FCF.js.map +0 -1
  121. package/dist/chunk-UWIMSKL5.js.map +0 -1
  122. package/dist/chunk-WLJV5O6C.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/engine/server/server.ts","../src/utility/utilis/server/server.ts","../src/utility/libs/index.ts","../src/utility/utilis/server/app.ts"],"sourcesContent":["import express, { type Application } from 'express';\nimport * as http from \"node:http\";\nimport path from \"node:path\";\nimport { pathToFileURL } from \"node:url\";\n\nimport type { ApisInterface } from \"../../utility/libs/types.js\";\nimport { fileExistsAsync } from \"../../utility/libs/index.js\";\nimport { ENV } from \"../../utility/libs/env.js\";\n\nimport { connectToMongo } from \"../mondoDb/mongoDB.js\";\nimport { runPgSqlScript } from \"../sql/pgSql.js\";\nimport { runMySqlScript } from \"../sql/mySql.js\";\nimport { isMySQL, isPostgreSQL } from \"../../utility/utilis/general/sqlDb.js.js\";\nimport { handleError } from \"../../utility/utilis/general/error_handler.js\";\n\n\n\n// DECLARATION // ==================================================================================================\n\nconst configPathTs = path.join(process.cwd(), \"src\", \"config\", \"express.config.ts\");\nconst configPathJs = path.join(process.cwd(), \"src\", \"config\", \"express.config.js\");\nconst EXPRESS_APP: Application = express();\nconst apiPathTs = path.join(process.cwd(), \"src\", \"apis\", \"apis.ts\");\nconst apiPathJs = path.join(process.cwd(), \"src\", \"apis\", \"apis.js\");\nconst PORT = ENV.SERVER_PORT;\nconst SQL_URL = ENV.SQL_DB_URL;\nconst HTTP_SERVER = http.createServer(EXPRESS_APP);\n\n\n\n\n\nconst startServer = async () => {\n try {\n\n // DATABASES // ============================================================================================\n\n if (isPostgreSQL(SQL_URL)) {\n await runPgSqlScript();\n }\n if (isMySQL(SQL_URL)) {\n await runMySqlScript();\n }\n\n await connectToMongo();\n\n // EXPRESS // ===============================================================================================\n\n const { express_configurations } = await import(pathToFileURL(await fileExistsAsync(configPathJs) ? configPathJs : configPathTs).href);\n express_configurations(EXPRESS_APP);\n\n // API // ===================================================================================================\n\n const { APIS } = await import(pathToFileURL(await fileExistsAsync(apiPathJs) ? apiPathJs : apiPathTs).href);\n APIS.forEach((api: ApisInterface) => {\n if ('get' in api) {\n const middleware = api.get.middleware\n ? (Array.isArray(api.get.middleware) ? api.get.middleware : [api.get.middleware])\n : [];\n EXPRESS_APP.get(api.get.endpoint, ...middleware, api.get.callable);\n }\n\n if ('post' in api) {\n const middleware = api.post.middleware\n ? (Array.isArray(api.post.middleware) ? api.post.middleware : [api.post.middleware])\n : [];\n EXPRESS_APP.post(api.post.endpoint, ...middleware, api.post.callable);\n }\n\n if ('put' in api) {\n const middleware = api.put.middleware\n ? (Array.isArray(api.put.middleware) ? api.put.middleware : [api.put.middleware])\n : [];\n EXPRESS_APP.put(api.put.endpoint, ...middleware, api.put.callable);\n }\n\n if ('delete' in api) {\n const middleware = api.delete.middleware\n ? (Array.isArray(api.delete.middleware) ? api.delete.middleware : [api.delete.middleware])\n : [];\n EXPRESS_APP.delete(api.delete.endpoint, ...middleware, api.delete.callable);\n }\n\n if ('patch' in api) {\n const middleware = api.patch.middleware\n ? (Array.isArray(api.patch.middleware) ? api.patch.middleware : [api.patch.middleware])\n : [];\n EXPRESS_APP.patch(api.patch.endpoint, ...middleware, api.patch.callable);\n }\n });\n\n // SERVER // ================================================================================================\n\n HTTP_SERVER.listen(PORT, () => {\n console.log(`Server running on port ${PORT}`);\n });\n\n }\n catch (err) {\n handleError(err);\n }\n};\n\n\n\n\n\n\n\n\n\n\n\n\nexport {\n EXPRESS_APP, HTTP_SERVER, startServer\n}\n","import {HTTP_SERVER} from \"../../../engine/server/server.js\";\n\n\n\n\n\n\n\n\nexport const getServer = () => {return HTTP_SERVER}\n","import type {\n BulkWriteInterface,\n CustomErrorTemplate, DeleteDocuments,\n DeleteFile,\n DeleteFiles, DownloadablePath,\n DownloadedFile,\n DownloadFileParams,\n DownloadFilesParams, FilesUploadedResponseData, GenerateIdOptions, InsertManyInterface, InsertOneInterface,\n QueryItems,\n UpdateDocument,\n UploadFileInput, UploadFilesInput, URLOptions\n} from \"./interface.js\";\nimport {deleteFile as df} from \"../utilis/cloud_storage/deleteFile.js\";\nimport {deleteFiles as dfs} from \"../utilis/cloud_storage/deleteFiles.js\";\nimport {downloadFile as dwnF} from \"../utilis/cloud_storage/downloadFile.js\";\nimport {downloadFiles as dwnFs} from \"../utilis/cloud_storage/downloadFiles.js\";\nimport {upload_file as upF} from \"../utilis/cloud_storage/uploadFile.js\";\nimport {upload_files as upFs} from \"../utilis/cloud_storage/uploadFiles.js\";\n\n\nimport {s3Client as sss} from \"../../engine/cloudBucket/r2Storage.js\";\nimport type {S3Client} from \"@aws-sdk/client-s3\";\nimport type {\n CustomBulkWriteResult,\n CustomDeleteResult,\n CustomInsertManyResult,\n CustomInsertOneResult,\n CustomUpdateResult,\n DatabaseType,\n FileUploadedResponseData,\n PathOptions,\n ResponseInterface\n} from \"./types.js\";\nimport {handleError as he} from \"../utilis/general/error_handler.js\";\nimport {fileExistsAsync as fea, fileExistsSync as fes} from \"../utilis/general/file-operations.js\";\nimport {getFileExtension as gfe} from \"../utilis/general/file-operations.js\";\nimport {url_or_path as uop} from \"../utilis/general/file-operations.js\";\nimport {toUint8Array as tu8a} from \"../utilis/general/file-operations.js\";\nimport {buildPath as bp} from \"../utilis/general/file-operations.js\";\nimport {getFileContentType as gfct} from \"../utilis/general/file-operations.js\";\nimport {getInAppBucketDownloadPath as giabdp} from \"../utilis/general/file-operations.js\";\nimport {detectSQLDatabase as dsd, isMySQL as ims, isPostgreSQL as ips} from \"../utilis/general/sqlDb.js.js\";\nimport {generateUniqueValue as guv} from \"../utilis/general/uuids.js\";\nimport {buildURL as bu} from \"../utilis/general/web.js\";\nimport {getKeyFromUrl as gkfu} from \"../utilis/general/web.js\";\nimport {responseToClient as rtc} from \"../utilis/general/web.js\";\nimport {mongoBulkWrite as mbw} from \"../utilis/mongoDb/buldWrite.js\";\nimport {mongoDeleteDocument as mdd} from \"../utilis/mongoDb/deleteDocument.js\";\nimport {mongoInsertField as miof} from \"../utilis/mongoDb/insertField.js\";\nimport {mongoInsertFields as mimf} from \"../utilis/mongoDb/insertFields.js\";\nimport {mongoUpdateField as muf} from \"../utilis/mongoDb/updateFiled.js\";\nimport {ENV} from \"./env.js\";\nimport {MAX_BATCH_FILES} from \"../../engine/multer/multer_configs.js\";\nimport {upload_batch as ub} from \"../utilis/multer/upload_batch.js\";\nimport {upload_single as us} from \"../utilis/multer/upload_single.js\";\nimport {executeQuery as eq} from \"../utilis/postgres/executeQuery.js\";\nimport {getPool as gp} from \"../utilis/postgres/executeQuery.js\";\nimport {getApp as ga} from \"../utilis/server/app.js\";\nimport {getServer as gs} from \"../utilis/server/server.js\";\n\n\n\n\n\n\n\n\n\n\n// ===============================================================================================================================================================================================================================//\n\n// CLOUD STORAGE\n\n/**\n * Deletes a file from either remote object storage or the local filesystem.\n *\n * The function determines whether the provided file reference is a URL or\n * a local filesystem path using `url_or_path()`.\n *\n * For remote URLs, the corresponding object key is extracted from the URL\n * and the object is deleted from the configured bucket using the S3-compatible\n * storage client.\n *\n * For local paths, the function first checks whether the file exists and\n * removes it using the asynchronous filesystem API. If the local file does\n * not exist, the operation is still considered successful.\n *\n * Errors encountered during either remote or local deletion are caught and\n * returned as part of the result instead of being thrown.\n *\n * @param item_file - Full URL of the remote file or local filesystem path\n * of the file to delete.\n *\n * @returns A promise resolving to a `DeleteFile` result containing the\n * original file URL/path, the deletion status, and the error when the\n * operation fails.\n *\n * @example\n * // Delete a file stored in the remote bucket.\n * const result = await deleteFile(\n * 'https://storage.example.com/my-bucket/uploads/profile.jpg'\n * );\n *\n * // Returns:\n * // {\n * // status: true,\n * // url_or_path:\n * // 'https://storage.example.com/my-bucket/uploads/profile.jpg'\n * // }\n *\n * @example\n * // Delete a locally stored file.\n * const result = await deleteFile(\n * './uploads/profile.jpg'\n * );\n *\n * // Returns:\n * // {\n * // status: true,\n * // url_or_path: './uploads/profile.jpg'\n * // }\n *\n * @example\n * // A local file that does not exist is treated as successfully deleted.\n * const result = await deleteFile(\n * './uploads/missing-file.jpg'\n * );\n *\n * // Returns:\n * // {\n * // status: true,\n * // url_or_path: './uploads/missing-file.jpg'\n * // }\n *\n * @example\n * // Handle the deletion result.\n * const result = await deleteFile(filePath);\n *\n * if (result.status) {\n * console.log('File deleted successfully:', result.url_or_path);\n * } else {\n * console.error('Failed to delete file:', result.error);\n * }\n */\nexport const deleteFile = async (item_file: string): Promise<DeleteFile> => {\n return await df(item_file);\n}\n\n\n\n/**\n * Deletes multiple files from either remote object storage or the local\n * filesystem.\n *\n * Each file is automatically classified as either a remote URL or a local\n * filesystem path using `url_or_path()`. Remote files are deleted from the\n * configured S3-compatible bucket, while local files are removed from the\n * filesystem.\n *\n * The function is designed to be idempotent for local files: if a local\n * file does not exist, that file is still reported as successfully deleted.\n *\n * Duplicate file references are removed before processing to prevent the\n * same file from being deleted more than once.\n *\n * Files are processed in batches of up to 50 items at a time to limit\n * concurrent filesystem and object-storage operations. Each batch is\n * processed concurrently, while subsequent batches wait for the previous\n * batch to complete.\n *\n * Individual deletion failures do not stop the remaining files from being\n * processed. Every file receives its own result describing whether the\n * deletion succeeded or failed.\n *\n * @param item_files - Array of remote file URLs or local filesystem paths\n * to delete.\n *\n * @returns A promise resolving to a `DeleteFiles` object containing the\n * deletion result for each unique file.\n *\n * @example\n * // Delete multiple remote files.\n * const result = await deleteFiles([\n * 'https://storage.example.com/my-bucket/uploads/image1.jpg',\n * 'https://storage.example.com/my-bucket/uploads/image2.jpg',\n * 'https://storage.example.com/my-bucket/uploads/document.pdf',\n * ]);\n *\n * // Returns:\n * // {\n * // items: [\n * // {\n * // url_or_path: 'https://storage.example.com/my-bucket/uploads/image1.jpg',\n * // status: true\n * // },\n * // {\n * // url_or_path: 'https://storage.example.com/my-bucket/uploads/image2.jpg',\n * // status: true\n * // },\n * {\n * url_or_path: 'https://storage.example.com/my-bucket/uploads/document.pdf',\n * status: true\n * }\n * ]\n * // }\n *\n * @example\n * // Delete multiple local files.\n * const result = await deleteFiles([\n * './uploads/image1.jpg',\n * './uploads/image2.jpg',\n * './uploads/document.pdf',\n * ]);\n *\n * @example\n * // Remote URLs and local paths can be mixed in the same request.\n * const result = await deleteFiles([\n * 'https://storage.example.com/my-bucket/uploads/avatar.jpg',\n * './uploads/temp-file.pdf',\n * ]);\n *\n * @example\n * // Duplicate file references are automatically removed.\n * const result = await deleteFiles([\n * './uploads/image.jpg',\n * './uploads/image.jpg',\n * './uploads/document.pdf',\n * ]);\n *\n * // The image is processed only once.\n *\n * @example\n * // Individual failures are returned without stopping other deletions.\n * const result = await deleteFiles([\n * './uploads/existing.jpg',\n * './uploads/missing.jpg',\n * 'invalid-file-reference',\n * ]);\n *\n * // Example result:\n * // {\n * // items: [\n * // {\n * // url_or_path: './uploads/existing.jpg',\n * status: true\n * },\n * {\n * url_or_path: './uploads/missing.jpg',\n * status: true\n * },\n * {\n * url_or_path: 'invalid-file-reference',\n * status: false\n * }\n * ]\n * // }\n *\n * @example\n * // An empty array returns immediately without performing any operations.\n * const result = await deleteFiles([]);\n *\n * // Returns:\n * // {\n * // items: []\n * // }\n */\nexport const deleteFiles = async (item_files: string[]): Promise<DeleteFiles> => {\n return await dfs(item_files)\n}\n\n\n\n/**\n * Downloads a file from the configured S3-compatible object storage and\n * saves it to the application's local in-app bucket.\n *\n * The object key is extracted from the provided file URL using\n * `getKeyFromUrl()`. The file is then retrieved from the configured bucket\n * using `GetObjectCommand`.\n *\n * A unique file name is generated while preserving the original file\n * extension. The resulting file is stored under the path specified by\n * `outputPath`, with `ENV.IN_APP_BUCKET` automatically used as the root\n * directory.\n *\n * The required directory structure is created automatically if it does not\n * already exist. The downloaded object is streamed directly to the local\n * filesystem rather than loading the entire file into memory.\n *\n * @param params - Parameters required to download the file.\n * @param params.url - Full URL of the file stored in the S3-compatible\n * object storage.\n * @param params.outputPath - Optional array of directory segments where\n * the downloaded file should be stored inside the in-app bucket.\n *\n * @returns A promise resolving to a `DownloadedFile` containing the original\n * URL, the local file path when successful, and an error when the operation\n * fails.\n *\n * @example\n * // Download a file into the default in-app bucket directory.\n * const result = await downloadFile({\n * url: 'https://storage.example.com/my-bucket/uploads/profile.jpg',\n * });\n *\n * // Example result:\n * // {\n * // status: true,\n * // url: 'https://storage.example.com/my-bucket/uploads/profile.jpg',\n * path: 'in_app_bucket/a8f91c2e4b7d91f2.jpg'\n * // }\n *\n * @example\n * // Download a file into a specific directory.\n * const result = await downloadFile({\n * url: 'https://storage.example.com/my-bucket/documents/report.pdf',\n * outputPath: ['temporary_files', 'documents'],\n * });\n *\n * // Example result:\n * // {\n * // status: true,\n * // url: 'https://storage.example.com/my-bucket/documents/report.pdf',\n * path: 'in_app_bucket/temporary_files/documents/b71d92ac31f04e21.pdf'\n * // }\n *\n * @example\n * // Handle a failed download.\n * const result = await downloadFile({\n * url: 'https://storage.example.com/my-bucket/missing.jpg',\n * outputPath: ['temporary_files'],\n * });\n *\n * if (!result.status) {\n * console.error('Download failed:', result.error);\n * }\n *\n * @example\n * // The downloaded file keeps the original extension while receiving\n * // a newly generated unique file name.\n * const result = await downloadFile({\n * url: 'https://storage.example.com/my-bucket/images/avatar.png',\n * outputPath: ['images'],\n * });\n *\n * // The resulting file will have a structure similar to:\n * // in_app_bucket/images/<unique-id>.png\n */\nexport const downloadFile = async ({url, outputPath}: DownloadFileParams): Promise<DownloadedFile> => {\n return await dwnF({\n url: url,\n ...(outputPath && {outputPath: outputPath}),\n })\n}\n\n\n\n/**\n * Downloads multiple files from the configured S3-compatible object storage\n * and saves them to the local in-app bucket.\n *\n * Each file is downloaded independently and processed concurrently. The\n * object key for each file is extracted from its URL using `getKeyFromUrl()`,\n * and the file is streamed directly to the local filesystem.\n *\n * A unique file name is generated for every downloaded file while preserving\n * its original file extension. The target directory is created automatically\n * when it does not already exist.\n *\n * A global output path can be provided for all files, or each file can define\n * its own output path. These two options cannot be used together.\n *\n * Unlike a batch operation that stops when one file fails, each download is\n * handled independently. A failure for one file does not prevent the\n * remaining files from being downloaded.\n *\n * @param params - Parameters containing the files to download and an\n * optional common output path.\n * @param params.files - Array of file download configurations. Each file\n * contains its remote URL and may optionally specify its own output path.\n * @param params.globalPath - Optional common output path used for every file.\n * Cannot be used when any individual file specifies `outputPath`.\n *\n * @returns A promise resolving to an array of `DownloadedFile` results.\n * Each result represents the success or failure of its corresponding\n * download.\n *\n * @example\n * // Download multiple files into the default in-app bucket directory.\n * const results = await downloadFiles({\n * files: [\n * {\n * url: 'https://storage.example.com/my-bucket/images/profile.jpg',\n * },\n * {\n * url: 'https://storage.example.com/my-bucket/documents/report.pdf',\n * },\n * ],\n * });\n *\n * @example\n * // Download multiple files into the same directory.\n * const results = await downloadFiles({\n * files: [\n * {\n * url: 'https://storage.example.com/my-bucket/images/profile.jpg',\n * },\n * {\n * url: 'https://storage.example.com/my-bucket/images/banner.png',\n * },\n * ],\n * globalPath: 'temporary_files',\n * });\n *\n * // Resulting paths will be similar to:\n * // in_app_bucket/temporary_files/<unique-id>.jpg\n * // in_app_bucket/temporary_files/<unique-id>.png\n *\n * @example\n * // Each file can have its own output directory.\n * const results = await downloadFiles({\n * files: [\n * {\n * url: 'https://storage.example.com/my-bucket/images/profile.jpg',\n * outputPath: ['users', 'images'],\n * },\n * {\n * url: 'https://storage.example.com/my-bucket/documents/report.pdf',\n * outputPath: ['users', 'documents'],\n * },\n * ],\n * });\n *\n * @example\n * // Check the result of each download independently.\n * const results = await downloadFiles({\n * files: [\n * {\n * url: 'https://storage.example.com/my-bucket/image1.jpg',\n * },\n * {\n * url: 'https://storage.example.com/my-bucket/image2.jpg',\n * },\n * ],\n * globalPath: 'downloads',\n * });\n *\n * results.forEach((result) => {\n * if (result.status) {\n * console.log('Downloaded:', result.path);\n * } else {\n * console.error('Download failed:', result.url, result.error);\n * }\n * });\n *\n * @example\n * // Invalid: globalPath and individual outputPath cannot be used together.\n * const results = await downloadFiles({\n * files: [\n * {\n * url: 'https://storage.example.com/my-bucket/image.jpg',\n * outputPath: ['images'],\n * },\n * ],\n * globalPath: 'downloads',\n * });\n *\n * // Throws:\n * // Error: Conflict: Cannot specify both 'globalPath' and\n * // 'individual outputPath' on files.\n */\nexport const downloadFiles = async ({files, globalPath,}: DownloadFilesParams): Promise<DownloadedFile[]> => {\n return await dwnFs({\n files: files,\n ...(globalPath && {globalPath: globalPath}),\n })\n}\n\n\n\nexport const upload_file = async ({ file, path }: UploadFileInput): Promise<FileUploadedResponseData> => {\n return await upF({ file: file, path: path })\n}\n\n\n\n/**\n * Uploads multiple files to the configured S3-compatible storage bucket\n * concurrently with a configurable concurrency limit.\n *\n * Each file is uploaded using the `upload_file` function. A global path can\n * be applied to all files, or each file can specify its own individual path,\n * but both options cannot be used at the same time.\n *\n * Failed uploads are collected separately from successful uploads, allowing\n * the caller to inspect the result of every individual file without stopping\n * the entire batch operation.\n *\n * @param params - Configuration options for the batch upload.\n * @param params.files - The files to upload along with their optional paths.\n * @param params.globalPath - An optional path applied to all files that do\n * not specify an individual path.\n * @param params.concurrency - The maximum number of files uploaded\n * concurrently. Defaults to `5`.\n * @returns A promise resolving to a `FilesUploadedResponseData` containing\n * separate arrays of successfully uploaded and failed files.\n * @throws {Error} If both `globalPath` and an individual file `path` are\n * provided.\n *\n * @example\n * const result = await upload_files({\n * files: [\n * { file: file1 },\n * { file: file2 },\n * { file: file3 },\n * ],\n * globalPath: ['temporary_files'],\n * concurrency: 5,\n * });\n *\n * console.log('Successful uploads:', result.successFiles);\n * console.log('Failed uploads:', result.failedFiles);\n *\n * @example\n * const result = await upload_files({\n * files: [\n * {\n * file: file1,\n * path: ['documents', 'reports'],\n * },\n * {\n * file: file2,\n * path: ['documents', 'images'],\n * },\n * ],\n * concurrency: 10,\n * });\n *\n * @example\n * // This throws because globalPath and an individual path cannot be used together.\n * const result = await upload_files({\n * files: [\n * {\n * file: file1,\n * path: ['documents'],\n * },\n * ],\n * globalPath: ['temporary_files'],\n * });\n */\nexport const upload_files = async ({files, globalPath, concurrency = 5}: UploadFilesInput): Promise<FilesUploadedResponseData> => {\n return await upFs({\n files: files,\n ...(globalPath && {globalPath: globalPath}),\n concurrency: concurrency,\n })\n}\n\n\n\n/**\n * Returns the configured S3-compatible storage client.\n *\n * This function provides access to the shared `S3Client` instance configured\n * by the application's cloud storage engine. The client can be used for\n * operations such as uploading, downloading, deleting, and managing objects\n * in an S3-compatible storage service.\n *\n * The function returns the existing client instance rather than creating a\n * new client, allowing the application to reuse the same connection\n * configuration across storage operations.\n *\n * @returns A promise resolving to the configured `S3Client` instance.\n *\n * @example\n * // Get the configured S3 client.\n * const s3Client = await getS3Client();\n *\n * // Use the client for an S3 operation.\n * const result = await s3Client.send(\n * new GetObjectCommand({\n * Bucket: ENV.BUCKET_NAME,\n * Key: 'temporary_files/example.jpg',\n * })\n * );\n *\n * @example\n * // The same configured client can be reused for multiple operations.\n * const s3Client = await getS3Client();\n *\n * await s3Client.send(uploadCommand);\n * await s3Client.send(downloadCommand);\n * await s3Client.send(deleteCommand);\n */\nexport const getS3Client = async (): Promise<S3Client> => {\n return sss;\n}\n\n\n\n\n// ===============================================================================================================================================================================================================================//\n\n// GENERAL\n\n/**\n * Normalizes and logs an error with optional contextual information.\n *\n * Formats the error for both terminal and browser environments, displaying\n * its type, message, timestamp, context, stack trace, and raw error object.\n * The normalized error is returned after being logged.\n *\n * @param err - The unknown error value to normalize and handle.\n * @param context - Optional context describing where the error occurred.\n * @returns The normalized error as a `CustomErrorTemplate`.\n *\n * @example\n * const error = handleError(error, 'File Upload');\n * // Logs the normalized error and returns a CustomErrorTemplate.\n *\n * @example\n * try {\n * await upload_file(file);\n * } catch (error) {\n * handleError(error, 'MinIO Upload');\n * }\n */\nexport function handleError(err: unknown, context?: string): CustomErrorTemplate {\n\n return he(err, context);\n\n}\n\n\n\n/**\n * Asynchronously checks whether a file or path exists and is accessible.\n *\n * The function uses the filesystem access check to determine whether the\n * specified path can be accessed. It resolves to `true` when the path is\n * accessible and `false` when the access check fails.\n *\n * Any filesystem error is handled internally, so the function does not\n * throw when the file or directory does not exist.\n *\n * @param filePath - The filesystem path to check.\n *\n * @returns A promise resolving to `true` if the path exists and is\n * accessible, otherwise `false`.\n *\n * @example\n * // Check whether a file exists.\n * const exists = await fileExistsAsync('./uploads/profile.jpg');\n *\n * if (exists) {\n * console.log('File exists.');\n * }\n *\n * @example\n * // Use the result before reading a file.\n * const filePath = './uploads/document.pdf';\n *\n * if (await fileExistsAsync(filePath)) {\n * const file = await fs.readFile(filePath);\n * console.log('File loaded successfully.');\n * }\n *\n * @example\n * // A missing file returns false instead of throwing an error.\n * const exists = await fileExistsAsync('./uploads/missing.jpg');\n *\n * // Returns:\n * // false\n */\nexport async function fileExistsAsync(filePath: string): Promise<boolean> {\n return await fea(filePath);\n}\n\n\n\n/**\n * Synchronously checks whether a file or filesystem path exists and is\n * accessible.\n *\n * The function uses Node.js's synchronous filesystem access check to\n * determine whether the specified path can be accessed. It returns `true`\n * when the path is accessible and `false` when the access check fails.\n *\n * Any filesystem error is handled internally, so the function does not\n * throw when the file or directory does not exist.\n *\n * @param filePath - The filesystem path to check.\n *\n * @returns `true` if the path exists and is accessible; otherwise `false`.\n *\n * @example\n * // Check whether a file exists.\n * const exists = fileExistsSync('./uploads/profile.jpg');\n *\n * if (exists) {\n * console.log('File exists.');\n * }\n *\n * @example\n * // Check before performing a synchronous file operation.\n * const filePath = './uploads/document.pdf';\n *\n * if (fileExistsSync(filePath)) {\n * const file = fsSync.readFileSync(filePath);\n * console.log('File loaded successfully.');\n * }\n *\n * @example\n * // A missing file returns false instead of throwing an error.\n * const exists = fileExistsSync('./uploads/missing.jpg');\n *\n * // Returns:\n * // false\n */\nexport function fileExistsSync(filePath: string): boolean {\n return fes(filePath);\n}\n\n\n\n/**\n * Extracts the file extension from a supported file input.\n *\n * Supports Express Multer files, Web API `File` objects, raw `Buffer` values,\n * and file paths or URLs. For URLs and paths, query parameters and hash\n * fragments are ignored when determining the extension.\n *\n * @param input - The file, buffer, path, or URL from which to extract the extension.\n * @returns The file extension without the leading dot, converted to lowercase.\n * Returns an empty string if no extension can be determined.\n *\n * @example\n * const extension = getFileExtension('https://example.com/files/image.PNG');\n * // Returns: \"png\"\n *\n * @example\n * const extension = getFileExtension(req.file);\n * // Returns: \"pdf\"\n *\n * @example\n * const extension = getFileExtension('documents/report.pdf?download=true');\n * // Returns: \"pdf\"\n *\n * @example\n * const extension = getFileExtension(buffer);\n * // Returns: \"\"\n */\nexport function getFileExtension(input: Express.Multer.File | File | Buffer | string): string {\n return gfe(input);\n}\n\n\n\n/**\n * Determines whether the provided value is a URL or a local/server based file path.\n *\n * If the value is a valid HTTP/HTTPS URL, the configured URL environment\n * value is returned. Otherwise, the configured local path environment value\n * is returned.\n *\n * @param val - The URL or local file path to evaluate.\n * @returns The configured URL or local path based on the input type.\n *\n * @example\n * const basePath = url_or_path('https://example.com/file.png');\n * // Returns ENV.URL\n *\n * @example\n * const basePath = url_or_path('/uploads/file.png');\n * // Returns ENV.PATH\n */\nexport const url_or_path = (val: string): 'url' | 'path' => {\n return uop(val);\n}\n\n\n\n/**\n * Safely normalizes Buffer, Express.Multer.File, Web File, or File Path into Uint8Array\n */\nexport async function toUint8Array(file: Express.Multer.File | File | Buffer | string): Promise<Uint8Array> {\n return await tu8a(file);\n}\n\n\n\n/**\n * Builds a normalized file path from the provided path components.\n *\n * Combines the path prefix, path segments, path postfix, and file name,\n * while removing empty values and normalizing redundant slashes.\n *\n * If `fileName` is a Web API `File` object, its `name` property is used.\n *\n * @param options - The path components used to construct the final path.\n * @param options.path_prefix - An optional prefix to prepend to the path.\n * @param options.path - An array of path segments.\n * @param options.path_postfix - An optional postfix to append before the file name.\n * @param options.fileName - The file name or a Web API `File` object.\n * @returns A normalized path with components separated by a single slash.\n *\n * @example\n * const filePath = buildPath({\n * path_prefix: 'uploads',\n * path: ['documents', 'reports'],\n * fileName: 'report.pdf',\n * });\n * // Returns: \"uploads/documents/reports/report.pdf\"\n *\n * @example\n * const filePath = buildPath({\n * path: ['documents//', '/reports/'],\n * fileName: 'report.pdf',\n * });\n * // Returns: \"documents/reports/report.pdf\"\n */\nexport function buildPath(options: PathOptions): string {\n return bp(options);\n}\n\n\n\n/**\n * Determines the MIME content type of a file from its available metadata\n * or, when given a file path or URL, from its file extension.\n *\n * Supports Express Multer files, Web API `File` objects, raw `Buffer` values,\n * and file paths or URLs.\n *\n * @param file - The file, buffer, path, or URL whose content type should be determined.\n * @returns A promise resolving to the detected MIME content type.\n *\n * @example\n * const contentType = await getFileContentType(req.file);\n * // Returns something like: \"image/jpeg\"\n *\n * @example\n * const contentType = await getFileContentType('/uploads/document.pdf');\n * // Returns: \"application/pdf\"\n *\n * @example\n * const contentType = await getFileContentType(buffer);\n * // Returns: \"application/octet-stream\"\n */\nexport const getFileContentType = async (file: Express.Multer.File | File | Buffer | string): Promise<string> => {\n return await gfct(file);\n}\n\n\n\n/**\n * Builds the download path for a file stored in the application's\n * in-app bucket.\n *\n * The configured `ENV.IN_APP_BUCKET` value is automatically used as the\n * path prefix. If the bucket name is already present in the supplied\n * segments, it is removed first to prevent the bucket name from being\n * duplicated in the resulting path.\n *\n * The function supports an optional file name or file-like input. When a\n * `File` or `Express.Multer.File` is provided, the underlying file name is\n * resolved by `buildPath()`.\n *\n * @param options - Options used to construct the in-app bucket path.\n * @param options.segments - Optional path segments representing directories\n * within the in-app bucket.\n * @param options.fileName - Optional file to append to the generated path.\n * Supports `Express.Multer.File`, Web API `File`, `Buffer`, or a string\n * path/file name.\n *\n * @returns A normalized path beginning with `ENV.IN_APP_BUCKET`.\n *\n * @example\n * // Build a path for a file inside the in-app bucket.\n * const path = getInAppBucketDownloadPath({\n * segments: ['temporary_files', 'images'],\n * fileName: 'profile.jpg',\n * });\n *\n * // Returns:\n * // <IN_APP_BUCKET>/temporary_files/images/profile.jpg\n *\n * @example\n * // The bucket name is automatically removed if it is already\n * // included in the provided segments.\n * const path = getInAppBucketDownloadPath({\n * segments: [\n * ENV.IN_APP_BUCKET,\n * 'temporary_files',\n * 'images',\n * ],\n * fileName: 'profile.jpg',\n * });\n *\n * // Returns:\n * // <IN_APP_BUCKET>/temporary_files/images/profile.jpg\n *\n * @example\n * // A Multer file can be supplied directly.\n * const path = getInAppBucketDownloadPath({\n * segments: ['temporary_files'],\n * fileName: req.file,\n * });\n *\n * @example\n * // A path can be generated without a file name.\n * const path = getInAppBucketDownloadPath({\n * segments: ['temporary_files', 'images'],\n * });\n *\n * // Returns:\n * // <IN_APP_BUCKET>/temporary_files/images\n */\nexport function getInAppBucketDownloadPath({segments = [], fileName}: DownloadablePath = {}): string {\n return giabdp({\n segments: segments,\n ...(fileName && {fileName: fileName})\n })\n}\n\n\n\n/**\n * Detects the SQL database type from a database connection URL.\n *\n * The function supports MySQL and PostgreSQL connection URL schemes,\n * including common driver-specific variants such as `mysql2`,\n * `mysql+pymysql`, `postgresql+psycopg2`, and `postgresql+asyncpg`.\n *\n * If the connection string does not contain a recognized protocol, the\n * function attempts to identify the database using keywords in the\n * connection string or the default database ports:\n *\n * - MySQL: `3306`\n * - PostgreSQL: `5432`\n *\n * Invalid URLs are also checked as raw connection strings before an error\n * is thrown. This allows common connection strings without a protocol to\n * still be detected.\n *\n * @param url - The SQL database connection URL or connection string.\n * @returns `ENV.MY_SQL` for MySQL connections or `ENV.POSTGRES_SQL` for\n * PostgreSQL connections.\n * @throws {Error} If the URL is invalid or the database type cannot be\n * identified as MySQL or PostgreSQL.\n *\n * @example\n * // Detect PostgreSQL from a standard connection URL.\n * const database = detectSQLDatabase(\n * 'postgresql://user:password@localhost:5432/my_database'\n * );\n *\n * // Returns: ENV.POSTGRES_SQL\n *\n * @example\n * // Detect MySQL from a standard connection URL.\n * const database = detectSQLDatabase(\n * 'mysql://user:password@localhost:3306/my_database'\n * );\n *\n * // Returns: ENV.MY_SQL\n *\n * @example\n * // Driver-specific PostgreSQL URLs are also supported.\n * const database = detectSQLDatabase(\n * 'postgresql+psycopg2://user:password@localhost:5432/my_database'\n * );\n *\n * // Returns: ENV.POSTGRES_SQL\n *\n * @example\n * // A connection string without a recognized protocol can be detected\n * // using the default PostgreSQL port.\n * const database = detectSQLDatabase(\n * 'localhost:5432/my_database'\n * );\n *\n * // Returns: ENV.POSTGRES_SQL\n *\n * @example\n * // Throws when the database type cannot be determined.\n * const database = detectSQLDatabase(\n * 'mongodb://localhost:27017/my_database'\n * );\n *\n * // Error: Unsupported or unrecognized database type.\n */\nexport function detectSQLDatabase(url: string): DatabaseType {\n return dsd(url);\n}\n\n\n\n/**\n * Determines whether a database connection URL represents a MySQL database.\n *\n * This function delegates database detection to `detectSQLDatabase()` and\n * compares the detected database type with the configured MySQL database\n * identifier.\n *\n * Any error encountered while parsing or detecting the database type is\n * handled internally, and the function returns `false` instead of throwing.\n * This makes the function safe to use when validating or conditionally\n * selecting a database implementation.\n *\n * @param url - The SQL database connection URL or connection string.\n * @returns `true` if the URL represents a MySQL database; otherwise `false`.\n *\n * @example\n * // Standard MySQL connection URL.\n * const result = isMySQL(\n * 'mysql://user:password@localhost:3306/my_database'\n * );\n *\n * // Returns: true\n *\n * @example\n * // PostgreSQL URL.\n * const result = isMySQL(\n * 'postgresql://user:password@localhost:5432/my_database'\n * );\n *\n * // Returns: false\n *\n * @example\n * // Invalid or unsupported connection URL.\n * const result = isMySQL('invalid-database-url');\n *\n * // Returns: false instead of throwing an error.\n */\nexport function isMySQL(url: string): boolean {\n return ims(url)\n}\n\n\n\n/**\n * Determines whether a database connection URL represents a PostgreSQL\n * database.\n *\n * This function delegates database detection to `detectSQLDatabase()` and\n * compares the detected database type with the configured PostgreSQL\n * identifier.\n *\n * Any error encountered while parsing or detecting the database type is\n * handled internally, causing the function to return `false` instead of\n * throwing. This makes the function safe to use when conditionally selecting\n * PostgreSQL-specific database logic.\n *\n * @param url - The SQL database connection URL or connection string.\n * @returns `true` if the URL represents a PostgreSQL database; otherwise\n * `false`.\n *\n * @example\n * // Standard PostgreSQL connection URL.\n * const result = isPostgreSQL(\n * 'postgresql://user:password@localhost:5432/my_database'\n * );\n *\n * // Returns: true\n *\n * @example\n * // MySQL connection URL.\n * const result = isPostgreSQL(\n * 'mysql://user:password@localhost:3306/my_database'\n * );\n *\n * // Returns: false\n *\n * @example\n * // Invalid or unsupported connection URL.\n * const result = isPostgreSQL('invalid-database-url');\n *\n * // Returns: false instead of throwing an error.\n */\nexport function isPostgreSQL(url: string): boolean {\n return ips(url)\n}\n\n\n\n/**\n * Generates one or more cryptographically secure unique values.\n *\n * Values can be generated using hexadecimal characters or a custom\n * alphanumeric character set. Optional timestamps and prefixes can be\n * included in the generated values.\n *\n * When `count` is provided, multiple unique values are returned as an array.\n * Otherwise, a single string is returned.\n *\n * @param length - The length of the randomly generated portion of each value.\n * @param options - Optional configuration for generating the value(s).\n * @param options.useHex - Whether to generate the random portion using hexadecimal characters.\n * @param options.includeTimestamp - Whether to prepend a hexadecimal timestamp.\n * @param options.prefix - An optional prefix to prepend to the generated value.\n * @param options.count - The number of values to generate. If omitted, one value is returned.\n * @returns A single unique string when `count` is not provided, or an array of unique strings when `count` is specified.\n * @throws {Error} If `length` or `count` is less than or equal to zero.\n *\n * @example\n * const id = generateUniqueValue(16);\n * // Returns: \"aZ7_kP2mQ9xL3nBc\"\n *\n * @example\n * const id = generateUniqueValue(16, {\n * useHex: true,\n * prefix: 'file',\n * });\n * // Returns: \"file-7f3a9c12d84e...\"\n *\n * @example\n * const id = generateUniqueValue(12, {\n * includeTimestamp: true,\n * });\n * // Returns: \"198a7f3c12a-7Kx9mP...\"\n *\n * @example\n * const ids = generateUniqueValue(10, {\n * count: 5,\n * prefix: 'file',\n * });\n * // Returns: [\"file-...\", \"file-...\", \"file-...\", \"file-...\", \"file-...\"]\n */\nexport function generateUniqueValue(length: number, options?: GenerateIdOptions): string;\nexport function generateUniqueValue(length: number, options: GenerateIdOptions & { count: number }): string[];\nexport function generateUniqueValue(length: number, options?: GenerateIdOptions & { count?: number }): string | string[] {\n return guv(length, options);\n}\n\n\n\n/**\n * Builds a normalized URL or path from an optional endpoint, path segments,\n * and file name.\n *\n * The function safely combines all provided segments while removing empty\n * values and normalizing slashes between segments. If the endpoint contains\n * an HTTP or HTTPS protocol, the protocol is preserved separately so that\n * slash normalization does not alter it.\n *\n * A `File` object can also be provided as `fileName`; in that case, its\n * original file name is extracted automatically.\n *\n * @param options - Options used to construct the URL.\n * @param options.end_point - Optional base URL or endpoint. Supports\n * `http://` and `https://` protocols.\n * @param options.path - Optional array of path segments to append to the\n * endpoint.\n * @param options.fileName - Optional file name or Web API `File` object.\n *\n * @returns A normalized URL/path containing the provided endpoint, path\n * segments, and file name. Returns an empty string when no valid segments\n * are provided.\n *\n * @example\n * // Build a URL from an endpoint, path, and file name.\n * const url = buildURL({\n * end_point: 'https://storage.example.com',\n * path: ['uploads', 'images'],\n * fileName: 'profile.jpg',\n * });\n *\n * // Returns:\n * // https://storage.example.com/uploads/images/profile.jpg\n *\n * @example\n * // Extra slashes are automatically normalized.\n * const url = buildURL({\n * end_point: 'https://storage.example.com/',\n * path: ['/uploads/', '/images//'],\n * fileName: '/profile.jpg',\n * });\n *\n * // Returns:\n * // https://storage.example.com/uploads/images/profile.jpg\n *\n * @example\n * // A File object can be used as the file name.\n * const url = buildURL({\n * end_point: 'https://storage.example.com',\n * path: ['uploads'],\n * fileName: file,\n * });\n *\n * // If file.name is \"document.pdf\":\n * // https://storage.example.com/uploads/document.pdf\n *\n * @example\n * // The function can also build a path without a URL endpoint.\n * const path = buildURL({\n * path: ['uploads', 'documents'],\n * fileName: 'report.pdf',\n * });\n *\n * // Returns:\n * // uploads/documents/report.pdf\n *\n * @example\n * // Empty or undefined segments are ignored.\n * const url = buildURL({\n * end_point: 'https://storage.example.com/',\n * path: ['', 'uploads', '', 'documents'],\n * fileName: 'report.pdf',\n * });\n *\n * // Returns:\n * // https://storage.example.com/uploads/documents/report.pdf\n *\n * @example\n * // Returns an empty string when no usable values are provided.\n * const url = buildURL({});\n *\n * // Returns:\n * // ''\n */\nexport function buildURL({end_point, path = [], fileName}: URLOptions): string {\n return bu({\n ...(end_point && {end_point: end_point}),\n path: path,\n ...(fileName && {fileName: fileName}),\n })\n\n}\n\n\n\n/**\n * Extracts the object key/path from a full public file URL.\n *\n * This function is intended for files stored in the configured bucket.\n * It parses the URL, extracts the pathname, removes the configured bucket\n * name when it appears as the first path segment, and decodes any\n * URL-encoded characters in the resulting object key.\n *\n * For example, a URL such as:\n *\n * `https://storage.example.com/my-bucket/uploads/images/profile%20photo.jpg`\n *\n * will produce:\n *\n * `uploads/images/profile photo.jpg`\n *\n * @param url - The full public URL of the stored file.\n * @returns The decoded object key/path without the bucket name.\n *\n * @throws {TypeError} If the provided value is not a valid URL.\n *\n * @example\n * // Extract the object key from a bucket URL.\n * const key = getKeyFromUrl(\n * 'https://storage.example.com/my-bucket/uploads/profile.jpg'\n * );\n *\n * // Returns:\n * // 'uploads/profile.jpg'\n *\n * @example\n * // URL-encoded characters are decoded automatically.\n * const key = getKeyFromUrl(\n * 'https://storage.example.com/my-bucket/uploads/profile%20photo.jpg'\n * );\n *\n * // Returns:\n * // 'uploads/profile photo.jpg'\n *\n * @example\n * // Nested directories are preserved.\n * const key = getKeyFromUrl(\n * 'https://storage.example.com/my-bucket/users/123/avatar/image.png'\n * );\n *\n * // Returns:\n * // 'users/123/avatar/image.png'\n */\nexport const getKeyFromUrl = (url: string): string => {\n return gkfu(url)\n}\n\n\n\n/**\n * Sends a standardized API response to the client.\n *\n * This function provides a consistent response structure for both successful\n * and failed requests. The `success` property acts as the discriminator\n * between the two response types.\n *\n * For successful responses, the function returns the supplied status,\n * message, data, and metadata. For failed responses, it returns the supplied\n * status, message, error information, and metadata.\n *\n * A response timestamp is automatically generated when one is not already\n * provided through `meta.timestamp`.\n *\n * @param response - Express `Response` object used to send the HTTP response.\n * @param success - Indicates whether the request was successful.\n * @param status - HTTP status code returned to the client.\n * @param message - Optional human-readable response message.\n * @param data - Optional data returned by a successful operation.\n * @param error - Error information returned when the operation fails.\n * @param meta - Optional response metadata such as request ID, timestamp,\n * pagination information, or other request-related information.\n *\n * @returns The Express response containing the standardized API payload.\n *\n * @example\n * // Successful response.\n * return response_to_client({\n * response: res,\n * success: true,\n * status: 200,\n * message: 'User fetched successfully.',\n * data: user,\n * });\n *\n * @example\n * // Successful response with pagination metadata.\n * return response_to_client({\n * response: res,\n * success: true,\n * status: 200,\n * message: 'Users fetched successfully.',\n * data: users,\n * meta: {\n * timestamp: new Date().toISOString(),\n * requestId: 'req_123456',\n * page: 1,\n * limit: 20,\n * totalItems: 100,\n * totalPages: 5,\n * },\n * });\n *\n * @example\n * // Error response.\n * return response_to_client({\n * response: res,\n * success: false,\n * status: 404,\n * message: 'File not found.',\n * error: {\n * code: 'FILE_NOT_FOUND',\n * path: '/files/profile.jpg',\n * },\n * });\n *\n * @example\n * // Validation error with structured details.\n * return response_to_client({\n * response: res,\n * success: false,\n * status: 400,\n * message: 'Validation failed.',\n * error: {\n * code: 'VALIDATION_ERROR',\n * details: [\n * {\n * field: 'email',\n * message: 'Invalid email address.',\n * },\n * {\n * field: 'password',\n * message: 'Password is required.',\n * },\n * ],\n * },\n * });\n *\n * @example\n * // Error response with a request ID for tracing.\n * return response_to_client({\n * response: res,\n * success: false,\n * status: 500,\n * message: 'Internal server error.',\n * error: {\n * code: 'INTERNAL_SERVER_ERROR',\n * },\n * meta: {\n * timestamp: new Date().toISOString(),\n * requestId: 'req_abc123',\n * },\n * });\n */\nexport const responseToClient = ({response, ...payload}: ResponseInterface)=> {\n return rtc({\n response: response,\n ...payload\n })\n}\n\n\n\n\n\n\n\n\n\n// ===============================================================================================================================================================================================================================//\n\n// MONGO_DB\n\n/**\n * Executes multiple write operations against a MongoDB collection in a single\n * bulk operation.\n *\n * The function connects to the specified database and collection, executes\n * the provided bulk write operations, and returns a standardized result\n * indicating whether the operation succeeded or failed.\n *\n * @param params - Configuration and operations required for the bulk write.\n * @param params.dbName - The name of the MongoDB database.\n * @param params.collectionName - The name of the collection to modify.\n * @param params.writable - An array of MongoDB bulk write operations to execute.\n * @param params.options - Optional MongoDB bulk write configuration.\n * @returns A promise resolving to a `CustomBulkWriteResult` containing either\n * the `BulkWriteResult` on success or an `Error` on failure.\n *\n * @example\n * const result = await bulkWrite({\n * dbName: 'my_database',\n * collectionName: 'users',\n * writable: [\n * {\n * insertOne: {\n * document: {\n * name: 'John',\n * email: 'john@example.com',\n * },\n * },\n * },\n * {\n * updateOne: {\n * filter: { name: 'Jane' },\n * update: { $set: { active: true } },\n * },\n * },\n * ],\n * });\n *\n * if (result.status) {\n * console.log(result.result);\n * } else {\n * console.error(result.error);\n * }\n */\nexport const mongoBulkWrite = async (params: BulkWriteInterface): Promise<CustomBulkWriteResult> => {\n return await mbw(params)\n}\n\n\n\n/**\n * Deletes one or more documents from a MongoDB collection.\n *\n * By default, the function deletes a single document matching the provided\n * query. When `deleteMany` is set to `true`, all documents matching the query\n * are deleted.\n *\n * @param params - Configuration options for the delete operation.\n * @param params.dbName - The name of the MongoDB database.\n * @param params.collection - The name of the collection to delete from.\n * @param params.query - The MongoDB filter used to identify the documents.\n * @param params.deleteMany - Whether to delete all matching documents instead\n * of only the first matching document. Defaults to `false`.\n * @param params.options - Optional MongoDB delete operation options.\n * @returns A promise resolving to a `CustomDeleteResult` containing the\n * `DeleteResult` and number of deleted documents on success, or an `Error`\n * on failure.\n *\n * @example\n * const result = await deleteDocument({\n * dbName: 'my_database',\n * collection: 'users',\n * query: {\n * email: 'john@example.com',\n * },\n * });\n *\n * if (result.status) {\n * console.log(`Deleted ${result.deletedCount} document(s)`);\n * } else {\n * console.error(result.error);\n * }\n *\n * @example\n * const result = await deleteDocument({\n * dbName: 'my_database',\n * collection: 'users',\n * query: {\n * active: false,\n * },\n * deleteMany: true,\n * });\n *\n * // Deletes all inactive users matching the query.\n */\nexport const mongoDeleteDocument = async (params: DeleteDocuments): Promise<CustomDeleteResult> => {\n return await mdd(params)\n}\n\n\n\n/**\n * Inserts a single document into a MongoDB collection.\n *\n * The document is inserted into the specified database and collection using\n * the provided MongoDB insertion options. The generic type `T` allows the\n * inserted document and resulting operation to remain type-safe.\n *\n * @param params - Configuration options for the insert operation.\n * @param params.dbName - The name of the MongoDB database.\n * @param params.collectionName - The name of the collection to insert into.\n * @param params.field - The document to insert.\n * @param params.options - Optional MongoDB insert operation options.\n * @returns A promise resolving to a `CustomInsertOneResult<T>` containing the\n * `InsertOneResult` on success or an `Error` on failure.\n *\n * @example\n * const result = await insertOneField({\n * dbName: 'my_database',\n * collectionName: 'users',\n * field: {\n * name: 'John Doe',\n * email: 'john@example.com',\n * },\n * });\n *\n * if (result.status) {\n * console.log('Inserted ID:', result.result.insertedId);\n * } else {\n * console.error(result.error);\n * }\n */\nexport const mongoInsertField = async <T>(params: InsertOneInterface<T>): Promise<CustomInsertOneResult<T>> => {\n return await miof(params);\n}\n\n\n\n/**\n * Inserts multiple documents into a MongoDB collection.\n *\n * The documents are inserted into the specified database and collection\n * using the provided MongoDB insertion options. The generic type `T`\n * ensures that the inserted documents and resulting operation remain\n * type-safe.\n *\n * @param params - Configuration options for the bulk insert operation.\n * @param params.dbName - The name of the MongoDB database.\n * @param params.collectionName - The name of the collection to insert into.\n * @param params.fields - An array of documents to insert.\n * @param params.options - Optional MongoDB bulk write options.\n * @returns A promise resolving to a `CustomInsertManyResult<T>` containing\n * the `InsertManyResult` and number of inserted documents on success, or\n * an `Error` on failure.\n *\n * @example\n * const result = await insertManyFields({\n * dbName: 'my_database',\n * collectionName: 'users',\n * fields: [\n * {\n * name: 'John Doe',\n * email: 'john@example.com',\n * },\n * {\n * name: 'Jane Doe',\n * email: 'jane@example.com',\n * },\n * ],\n * });\n *\n * if (result.status) {\n * console.log(`Inserted ${result.insertedCount} documents`);\n * } else {\n * console.error(result.error);\n * }\n */\nexport const mongoInsertFields = async <T>(params: InsertManyInterface<T>): Promise<CustomInsertManyResult<T>> => {\n return await mimf(params);\n}\n\n\n\n\n/**\n * Updates one or more documents in a MongoDB collection.\n *\n * By default, the function updates a single document matching the provided\n * query. When `updateMany` is set to `true`, all documents matching the query\n * are updated.\n *\n * @param params - Configuration options for the update operation.\n * @param params.dbName - The name of the MongoDB database.\n * @param params.collectionName - The name of the collection to update.\n * @param params.query - The MongoDB filter used to identify the documents.\n * @param params.updatable - The update operations or update pipeline to apply\n * to the matching documents.\n * @param params.updateMany - Whether to update all matching documents instead\n * of only the first matching document. Defaults to `false`.\n * @param params.options - Optional MongoDB update operation options.\n * @returns A promise resolving to a `CustomUpdateResult` containing the\n * `UpdateResult` on success or an `Error` on failure.\n *\n * @example\n * const result = await updateField({\n * dbName: 'my_database',\n * collectionName: 'users',\n * query: {\n * email: 'john@example.com',\n * },\n * updatable: {\n * $set: {\n * active: true,\n * },\n * },\n * });\n *\n * if (result.status) {\n * console.log('User updated successfully');\n * } else {\n * console.error(result.error);\n * }\n *\n * @example\n * const result = await updateField({\n * dbName: 'my_database',\n * collectionName: 'users',\n * query: {\n * active: false,\n * },\n * updatable: {\n * $set: {\n * status: 'inactive',\n * },\n * },\n * updateMany: true,\n * });\n *\n * // Updates all users matching the query.\n */\nexport const mongoUpdateField = async (params: UpdateDocument): Promise<CustomUpdateResult> => {\n return await muf(params)\n}\n\n\n\n\n\n\n\n\n\n// ===============================================================================================================================================================================================================================//\n\n// MULTER\n\n/**\n * Creates Multer middleware for handling multiple file uploads from a\n * single form field.\n *\n * The middleware accepts multiple files using the specified field name and\n * limits the maximum number of uploaded files to the provided count.\n *\n * If no field name is supplied, `ENV.FILES` is used as the default field\n * name. Likewise, `MAX_BATCH_FILES` is used as the default maximum number\n * of files.\n *\n * @param fieldName - Name of the multipart/form-data field containing the\n * uploaded files.\n * @param maxCount - Maximum number of files that can be uploaded in a\n * single request.\n *\n * @returns Multer middleware configured to process an array of uploaded\n * files.\n *\n * @example\n * // Use the default field name and maximum file count.\n * router.post('/upload', upload_batch(), uploadBatchFilesApi);\n *\n * @example\n * // Accept up to 10 files from the \"files\" field.\n * router.post(\n * '/upload',\n * upload_batch('files', 10),\n * uploadBatchFilesApi\n * );\n *\n * @example\n * // Use a custom field name with the configured maximum file count.\n * router.post(\n * '/images',\n * upload_batch('images'),\n * uploadBatchFilesApi\n * );\n */\nexport const upload_batch = (fieldName: string = ENV.FILES, maxCount: number = MAX_BATCH_FILES) => {\n return ub(fieldName, maxCount)\n}\n\n\n\n/**\n * Creates Multer middleware for handling a single file upload.\n *\n * The middleware expects one uploaded file from the specified\n * `multipart/form-data` field and makes the uploaded file available through\n * `req.file`.\n *\n * If no field name is provided, `ENV.FILE` is used as the default field name.\n *\n * @param fieldName - Name of the multipart/form-data field containing the\n * uploaded file.\n *\n * @returns Multer middleware configured to process a single uploaded file.\n *\n * @example\n * // Use the default field name.\n * router.post(\n * '/upload',\n * upload_single(),\n * uploadSingleFileApi\n * );\n *\n * @example\n * // Accept a single file from the \"file\" field.\n * router.post(\n * '/upload',\n * upload_single('file'),\n * uploadSingleFileApi\n * );\n *\n * @example\n * // Use a custom field name.\n * router.post(\n * '/profile-picture',\n * upload_single('profilePicture'),\n * uploadSingleFileApi\n * );\n *\n * // The uploaded file will be available as:\n * // req.file\n */\nexport const upload_single = (fieldName: string = ENV.FILE) => {\n return us(fieldName)\n}\n\n\n\n\n\n\n\n\n\n\n\n\n// ===============================================================================================================================================================================================================================//\n\n// POSTGRES\n\n/**\n * Executes one or more SQL queries using the database configured through\n * the `SQL_DB_URL` environment variable.\n *\n * The function automatically detects whether the configured database is\n * PostgreSQL or MySQL and delegates execution to the appropriate database\n * implementation.\n *\n * Supports structured CRUD operations (`insert_one`, `insert_many`, `select`,\n * `update`, and `delete`) as well as custom raw SQL queries.\n *\n * Parameterized conditions and raw queries are supported. The placeholder\n * syntax must match the configured database engine:\n *\n * - MySQL uses `?` placeholders.\n * - PostgreSQL uses `$1`, `$2`, `$3`, etc.\n *\n * The corresponding values are supplied through `conditionalParams` for\n * structured CRUD operations or `params` for raw SQL queries.\n *\n * @param query - The SQL operations to execute.\n * @param query.crud - Optional array of structured CRUD operations.\n * @param query.custom - Optional raw SQL query or array of raw SQL queries.\n *\n * @returns A promise resolving to the result returned by the PostgreSQL or\n * MySQL query executor. If the configured `SQL_DB_URL` does not represent a\n * supported database, an `Error` is returned.\n *\n * @example\n * // Insert a user.\n * //\n * // This operation is database-independent because the values are passed\n * // as an object and the underlying executor generates the appropriate SQL.\n * await executeQuery({\n * crud: [\n * {\n * insert_one: {\n * table: CONSTANTS.USER_INFOS,\n * item: {\n * [CONSTANTS.USER_PRIMARY_ID]: generateUniqueValue(32),\n * [CONSTANTS.USER_NAME]: 'Divyanshu',\n * [CONSTANTS.USER_EMAIL]: 'div@example.com',\n * [CONSTANTS.USER_GENDER]: CONSTANTS.GENDER_TYPE.MALE,\n * },\n * },\n * },\n * ],\n * });\n *\n * @example\n * // Select a user by email.\n * //\n * // MySQL:\n * // condition: 'user_email = ?'\n * //\n * // PostgreSQL:\n * // condition: 'user_email = $1'\n * //\n * // The value is supplied separately through conditionalParams.\n * await executeQuery({\n * crud: [\n * {\n * select: {\n * table: CONSTANTS.USER_INFOS,\n * columns: [\n * CONSTANTS.USER_PRIMARY_ID,\n * CONSTANTS.USER_NAME,\n * CONSTANTS.USER_EMAIL,\n * ],\n * condition: 'user_email = ?',\n * conditionalParams: ['div@example.com'],\n * },\n * },\n * ],\n * });\n *\n * @example\n * // Update a user's information.\n * //\n * // MySQL:\n * // condition: 'user_primary_id = ?'\n * //\n * // PostgreSQL:\n * // condition: 'user_primary_id = $1'\n * await executeQuery({\n * crud: [\n * {\n * update: {\n * table: CONSTANTS.USER_INFOS,\n * item: {\n * [CONSTANTS.USER_NAME]: 'Div',\n * [CONSTANTS.USER_PHONE_NUMBER]: '+1234567890',\n * },\n * condition: 'user_primary_id = ?',\n * conditionalParams: [\n * '550e8400-e29b-41d4-a716-446655440000',\n * ],\n * },\n * },\n * ],\n * });\n *\n * @example\n * // Delete a user.\n * //\n * // Replace `?` with `$1` when using PostgreSQL.\n * await executeQuery({\n * crud: [\n * {\n * delete: {\n * table: CONSTANTS.USER_INFOS,\n * condition: 'user_primary_id = ?',\n * conditionalParams: [\n * '550e8400-e29b-41d4-a716-446655440000',\n * ],\n * },\n * },\n * ],\n * });\n *\n * @example\n * // Execute a raw SQL query.\n * //\n * // MySQL:\n * // query: 'SELECT * FROM user_infos WHERE user_email = ?'\n * //\n * // PostgreSQL:\n * // query: 'SELECT * FROM user_infos WHERE user_email = $1'\n * await executeQuery({\n * custom: {\n * query: 'SELECT * FROM user_infos WHERE user_email = ?',\n * params: ['div@example.com'],\n * },\n * });\n *\n * @example\n * // Execute multiple operations in one call.\n * //\n * // The underlying executor handles the operations according to the\n * // configured database engine.\n * await executeQuery({\n * crud: [\n * {\n * insert_one: {\n * table: CONSTANTS.USER_INFOS,\n * item: {\n * [CONSTANTS.USER_PRIMARY_ID]: generateUniqueValue(32),\n * [CONSTANTS.USER_NAME]: 'Alice',\n * [CONSTANTS.USER_EMAIL]: 'alice@example.com',\n * },\n * },\n * },\n * {\n * update: {\n * table: CONSTANTS.USER_INFOS,\n * item: {\n * status: 'active',\n * },\n * condition: 'user_email = ?',\n * conditionalParams: ['alice@example.com'],\n * },\n * },\n * ],\n * });\n */\nexport const executeQuery = async (query: QueryItems) => {\n return await eq(query);\n}\n\n\n\n/**\n * Returns the connection pool for the SQL database configured through\n * the `SQL_DB_URL` environment variable.\n *\n * The database type is detected automatically from the connection URL.\n * If the URL represents a PostgreSQL database, the PostgreSQL connection\n * pool is returned. If it represents a MySQL database, the MySQL connection\n * pool is returned.\n *\n * This function acts as the database-agnostic entry point for obtaining\n * the application's SQL connection pool. Callers do not need to know\n * whether the application is currently using PostgreSQL or MySQL.\n *\n * The underlying pool is created lazily and reused across subsequent\n * calls through `getPgSqlPool()` or `getMySqlPool()`.\n *\n * @returns A promise resolving to the PostgreSQL or MySQL connection pool,\n * depending on the configured `SQL_DB_URL`. Returns `undefined` if the\n * configured database URL does not match a supported SQL database.\n *\n * @example\n * // Get the configured SQL connection pool.\n * const pool = await getPool();\n *\n * if (!pool) {\n * throw new Error('Unsupported SQL database configuration.');\n * }\n *\n * @example\n * // The same function works regardless of whether the application\n * // is configured to use PostgreSQL or MySQL.\n * const pool = await getPool();\n *\n * if (pool) {\n * // Use the returned pool with the appropriate database layer.\n * console.log('Database pool is ready.');\n * }\n */\nexport const getPool = async () => {\n return await gp();\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n// ===============================================================================================================================================================================================================================//\n\n// SERVER\n\n/**\n * Returns the application's configured Express instance.\n *\n * This function provides access to the shared Express application created\n * by the application entry point. It returns the existing instance rather\n * than creating a new Express application.\n *\n * The returned instance can be used to configure middleware, routes,\n * error handlers, and other Express application settings.\n *\n * @returns The shared Express `Application` instance.\n *\n * @example\n * // Get the Express application instance.\n * const app = getApp();\n *\n * // Register a route.\n * app.get('/health', (req, res) => {\n * res.json({ status: 'ok' });\n * });\n *\n * @example\n * // Use the shared application when configuring middleware.\n * const app = getApp();\n *\n * app.use(express.json());\n *\n * @example\n * // Export the configured application for use by a server entry point.\n * const app = getApp();\n *\n * app.listen(PORT, () => {\n * console.log(`Server running on port ${PORT}`);\n * });\n */\nexport const getApp = () => {\n return ga();\n}\n\n\n\n/**\n * Returns the application's underlying HTTP server.\n *\n * This function provides access to the shared Node.js HTTP server created\n * using the configured Express application. The same server instance is\n * returned each time instead of creating a new server.\n *\n * The HTTP server can be used for operations that require access to the\n * underlying Node.js server, such as attaching WebSocket servers or\n * handling\n * low-level HTTP server events.\n *\n * @returns The shared Node.js `http.Server` instance.\n *\n * @example\n * // Attach a WebSocket server to the HTTP server.\n * const server = getServer();\n *\n * const wsServer = new WebSocket.Server({\n * server,\n * });\n *\n * @example\n * // Listen for server-level errors.\n * const server = getServer();\n *\n * server.on('error', (error) => {\n * console.error('HTTP server error:', error);\n * });\n */\nexport const getServer = () => {return gs()}\n\n\n\n\n\n\n\n\n","import {EXPRESS_APP} from \"../../../engine/server/server.js\";\n\n\nexport const getApp = () => {\n return EXPRESS_APP;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,aAAmC;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AI,UAAU,GAAG,YAAY,IAAI,IAAI,QAAQ;AAAA,MACrE;AAEA,UAAI,YAAY,KAAK;AACjB,cAAM,aAAa,IAAI,OAAO,aACvB,MAAM,QAAQ,IAAI,OAAO,UAAU,IAAI,IAAI,OAAO,aAAa,CAAC,IAAI,OAAO,UAAU,IACtF,CAAC;AACP,oBAAY,OAAO,IAAI,OAAO,UAAU,GAAG,YAAY,IAAI,OAAO,QAAQ;AAAA,MAC9E;AAEA,UAAI,WAAW,KAAK;AAChB,cAAM,aAAa,IAAI,MAAM,aACtB,MAAM,QAAQ,IAAI,MAAM,UAAU,IAAI,IAAI,MAAM,aAAa,CAAC,IAAI,MAAM,UAAU,IACnF,CAAC;AACP,oBAAY,MAAM,IAAI,MAAM,UAAU,GAAG,YAAY,IAAI,MAAM,QAAQ;AAAA,MAC3E;AAAA,IACJ,CAAC;AAID,gBAAY,OAAO,MAAM,MAAM;AAC3B,cAAQ,IAAI,0BAA0B,IAAI,EAAE;AAAA,IAChD,CAAC;AAAA,EAEL,SACO,KAAK;AACR,gBAAY,GAAG;AAAA,EACnB;AACJ,GArEoB;;;AG7Bb,IAAM,SAAS,6BAAM;AACxB,SAAO;AACX,GAFsB;","names":["deleteFile","deleteFiles","downloadFile","downloadFiles","upload_file","path","upload_files","handleError","fileExistsAsync","fileExistsSync","getFileExtension","url_or_path","toUint8Array","buildPath","getFileContentType","getInAppBucketDownloadPath","detectSQLDatabase","isMySQL","isPostgreSQL","generateUniqueValue","buildURL","getKeyFromUrl","responseToClient","mongoBulkWrite","mongoDeleteDocument","mongoInsertField","mongoInsertFields","mongoUpdateField","upload_batch","upload_single","executeQuery","getPool","getApp","getServer","fileExistsAsync"]}
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  fileExistsAsync
3
- } from "./chunk-CBTP2HOO.js";
3
+ } from "./chunk-QW2GGDEG.js";
4
4
 
5
5
  // src/engine/cloudBucket/r2Storage.ts
6
6
  import { S3Client } from "@aws-sdk/client-s3";
7
7
  import path from "path";
8
8
  import { pathToFileURL } from "url";
9
- var s3ConfigFileTs = path.join(process.cwd(), "src/config/s3bucket.config.ts");
10
- var s3ConfigFileJs = path.join(process.cwd(), "src/config/s3bucket.config.js");
9
+ var s3ConfigFileTs = path.join(process.cwd(), "src", "config", "s3bucket.config.ts");
10
+ var s3ConfigFileJs = path.join(process.cwd(), "src", "config", "s3bucket.config.js");
11
11
  var { S3_BUCKET_CONFIG } = await import(pathToFileURL(
12
12
  await fileExistsAsync(s3ConfigFileJs) ? s3ConfigFileJs : s3ConfigFileTs
13
13
  ).href);
@@ -16,4 +16,4 @@ var s3Client = new S3Client(S3_BUCKET_CONFIG);
16
16
  export {
17
17
  s3Client
18
18
  };
19
- //# sourceMappingURL=chunk-IAQMTSGP.js.map
19
+ //# sourceMappingURL=chunk-EKT74VDD.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/engine/cloudBucket/r2Storage.ts"],"sourcesContent":["import { S3Client } from '@aws-sdk/client-s3';\nimport path from \"node:path\";\nimport {pathToFileURL} from \"node:url\";\nimport {fileExistsAsync} from \"../../utility/utilis/general/file-operations.js\";\n\n\n\n\n\nconst s3ConfigFileTs = path.join(process.cwd(), \"src\", \"config\", \"s3bucket.config.ts\");\nconst s3ConfigFileJs = path.join(process.cwd(), \"src\", \"config\", \"s3bucket.config.js\");\n\nconst { S3_BUCKET_CONFIG } = await import(\n pathToFileURL(\n (await fileExistsAsync(s3ConfigFileJs)) ? s3ConfigFileJs : s3ConfigFileTs\n ).href\n );\n\n\nexport const s3Client: S3Client = new S3Client(S3_BUCKET_CONFIG);\n"],"mappings":";;;;;AAAA,SAAS,gBAAgB;AACzB,OAAO,UAAU;AACjB,SAAQ,qBAAoB;AAO5B,IAAM,iBAAiB,KAAK,KAAK,QAAQ,IAAI,GAAG,OAAO,UAAU,oBAAoB;AACrF,IAAM,iBAAiB,KAAK,KAAK,QAAQ,IAAI,GAAG,OAAO,UAAU,oBAAoB;AAErF,IAAM,EAAE,iBAAiB,IAAI,MAAM,OAC/B;AAAA,EACK,MAAM,gBAAgB,cAAc,IAAK,iBAAiB;AAC/D,EAAE;AAIC,IAAM,WAAqB,IAAI,SAAS,gBAAgB;","names":[]}
@@ -1,15 +1,15 @@
1
1
  import {
2
2
  getKeyFromUrl
3
- } from "./chunk-QBBF6LZZ.js";
3
+ } from "./chunk-ZC33GE2U.js";
4
4
  import {
5
5
  s3Client
6
- } from "./chunk-IAQMTSGP.js";
6
+ } from "./chunk-EKT74VDD.js";
7
7
  import {
8
8
  url_or_path
9
- } from "./chunk-CBTP2HOO.js";
9
+ } from "./chunk-QW2GGDEG.js";
10
10
  import {
11
11
  ENV
12
- } from "./chunk-EWQYVPOL.js";
12
+ } from "./chunk-LE2SDA4O.js";
13
13
  import {
14
14
  __name
15
15
  } from "./chunk-7QVYU63E.js";
@@ -57,4 +57,4 @@ var deleteFile = /* @__PURE__ */ __name(async (item_file) => {
57
57
  export {
58
58
  deleteFile
59
59
  };
60
- //# sourceMappingURL=chunk-OHDZYSL3.js.map
60
+ //# sourceMappingURL=chunk-GMQU3OAU.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utility/utilis/cloud_storage/deleteFile.ts"],"sourcesContent":["import {ENV} from \"../../libs/env.js\";\nimport {url_or_path} from \"../general/file-operations.js\";\nimport {getKeyFromUrl} from \"../general/web.js\";\nimport {DeleteObjectCommand} from \"@aws-sdk/client-s3\";\nimport * as fs from \"node:fs\";\nimport type {DeleteFile} from \"../../libs/interface.js\";\nimport {s3Client} from \"../../../engine/cloudBucket/r2Storage.js\";\n\n\n\n\nexport const deleteFile = async (item_file: string): Promise<DeleteFile> => {\n try {\n const fileType = url_or_path(item_file);\n\n if (fileType === ENV.URL) {\n // Extract the MinIO object key from the full public URL\n const key = getKeyFromUrl(item_file);\n\n const command = new DeleteObjectCommand({\n Bucket: ENV.BUCKET_NAME,\n Key: key,\n });\n\n await s3Client.send(command);\n return {\n status: true,\n url_or_path: item_file,\n }\n }\n\n if (fileType === ENV.PATH) {\n // Check if file exists locally before unlinking\n if (fs.existsSync(item_file)) {\n await fs.promises.unlink(item_file);\n }\n return {\n status: true,\n url_or_path: item_file,\n }\n }\n\n return {\n url_or_path: item_file,\n status: false,\n }\n } catch (error) {\n return {\n status: false,\n url_or_path: item_file,\n error: error,\n }\n }\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAGA,SAAQ,2BAA0B;AAClC,YAAY,QAAQ;AAOb,IAAM,aAAa,8BAAO,cAA2C;AACxE,MAAI;AACA,UAAM,WAAW,YAAY,SAAS;AAEtC,QAAI,aAAa,IAAI,KAAK;AAEtB,YAAM,MAAM,cAAc,SAAS;AAEnC,YAAM,UAAU,IAAI,oBAAoB;AAAA,QACpC,QAAQ,IAAI;AAAA,QACZ,KAAK;AAAA,MACT,CAAC;AAED,YAAM,SAAS,KAAK,OAAO;AAC3B,aAAO;AAAA,QACH,QAAQ;AAAA,QACR,aAAa;AAAA,MACjB;AAAA,IACJ;AAEA,QAAI,aAAa,IAAI,MAAM;AAEvB,UAAO,cAAW,SAAS,GAAG;AAC1B,cAAS,YAAS,OAAO,SAAS;AAAA,MACtC;AACA,aAAO;AAAA,QACH,QAAQ;AAAA,QACR,aAAa;AAAA,MACjB;AAAA,IACJ;AAEA,WAAO;AAAA,MACH,aAAa;AAAA,MACb,QAAQ;AAAA,IACZ;AAAA,EACJ,SAAS,OAAO;AACZ,WAAO;AAAA,MACH,QAAQ;AAAA,MACR,aAAa;AAAA,MACb;AAAA,IACJ;AAAA,EACJ;AACJ,GA1C0B;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getMongoServer
3
- } from "./chunk-ECIP24BN.js";
3
+ } from "./chunk-AS7JRX2N.js";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-7QVYU63E.js";
@@ -31,4 +31,4 @@ var mongoDeleteDocument = /* @__PURE__ */ __name(async (params) => {
31
31
  export {
32
32
  mongoDeleteDocument
33
33
  };
34
- //# sourceMappingURL=chunk-M2C6HHRK.js.map
34
+ //# sourceMappingURL=chunk-GWPLCPRW.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utility/utilis/mongoDb/deleteDocument.ts"],"sourcesContent":["import { getMongoServer } from \"../../../engine/mondoDb/mongoDB.js\";\nimport type {CustomDeleteResult} from \"../../libs/types.js\";\nimport type {DeleteDocuments} from \"../../libs/interface.js\";\n\n\n\n\n\n\n\nexport const mongoDeleteDocument = async (\n params: DeleteDocuments\n): Promise<CustomDeleteResult> => {\n\n\n const { dbName, collection, query, deleteMany = false, options } = params;\n\n try {\n const col = getMongoServer().db(dbName).collection(collection);\n\n const result = deleteMany\n ? await col.deleteMany(query, options)\n : await col.deleteOne(query, options);\n\n return {\n status: true,\n result,\n deletedCount: result.deletedCount,\n error: null,\n };\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n\n return {\n status: false,\n result: null,\n deletedCount: 0,\n error,\n };\n }\n};\n"],"mappings":";;;;;;;;AAUO,IAAM,sBAAsB,8BAC/B,WAC8B;AAG9B,QAAM,EAAE,QAAQ,YAAY,OAAO,aAAa,OAAO,QAAQ,IAAI;AAEnE,MAAI;AACA,UAAM,MAAM,eAAe,EAAE,GAAG,MAAM,EAAE,WAAW,UAAU;AAE7D,UAAM,SAAS,aACT,MAAM,IAAI,WAAW,OAAO,OAAO,IACnC,MAAM,IAAI,UAAU,OAAO,OAAO;AAExC,WAAO;AAAA,MACH,QAAQ;AAAA,MACR;AAAA,MACA,cAAc,OAAO;AAAA,MACrB,OAAO;AAAA,IACX;AAAA,EACJ,SAAS,KAAK;AACV,UAAM,QAAQ,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,CAAC;AAEhE,WAAO;AAAA,MACH,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,cAAc;AAAA,MACd;AAAA,IACJ;AAAA,EACJ;AACJ,GA9BmC;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getPgSqlPool
3
- } from "./chunk-SOZL76ZM.js";
3
+ } from "./chunk-IT6LYD4L.js";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-7QVYU63E.js";
@@ -132,4 +132,4 @@ export {
132
132
  executePgSqlQuery,
133
133
  executeCustom
134
134
  };
135
- //# sourceMappingURL=chunk-QUZPQJRE.js.map
135
+ //# sourceMappingURL=chunk-H3RM55WC.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utility/utilis/postgres/subSqlfiles/executePgQuery.ts"],"sourcesContent":["import type {PoolClient} from \"pg\";\nimport type {QueryItems} from \"../../../libs/interface.js\";\nimport type {SqlQuery, SqlRawQuery} from \"../../../libs/types.js\";\nimport {getPgSqlPool} from \"../../../../engine/sql/pgSql.js\";\n\n\n\n\n\nexport const executePgSqlQuery = async (query: QueryItems) => {\n let client: PoolClient | null = null;\n let results: any[] = [];\n\n try {\n // Check if we need a transaction (multiple queries or mix of crud and custom)\n const needsTransaction = (query.crud && query.crud?.length > 1) ||\n (query.crud && query.custom) ||\n (query.crud && query.crud?.length === 0);\n\n if (needsTransaction) {\n client = await (await getPgSqlPool()).connect();\n await client.query('BEGIN');\n }\n\n // Execute CRUD queries\n if (query.crud && query.crud.length > 0) {\n const crudResults = await executeCrud(query.crud, client);\n results = results.concat(crudResults);\n }\n\n // Execute custom query\n if (query.custom && !Array.isArray(query.custom)) {\n const customResult = await executeCustom(query.custom, client);\n results.push(customResult);\n }\n\n if (Array.isArray(query.custom) && query.custom.length) {\n const customResult = await executeCustom(query.custom, client);\n results.push(customResult);\n }\n\n // Commit transaction if we started one\n if (client) {\n await client.query('COMMIT');\n }\n\n return results;\n\n } catch (error) {\n // Rollback if we have a client (meaning we started a transaction)\n if (client) {\n await client.query('ROLLBACK');\n }\n throw error;\n }\n finally {\n // Release client if we acquired one\n if (client) {\n client.release();\n }\n }\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nconst executeCrud = async (queries: SqlQuery[], poolClient?: PoolClient | null): Promise<any[]> => {\n const results: any[] = [];\n const pool = poolClient || await getPgSqlPool();\n\n try {\n for (const query of queries) {\n let sql: string = '';\n let params: any[] = [];\n\n if ('insert_one' in query) {\n const {item, table} = query.insert_one;\n\n const columns = Object.keys(item);\n const values = Object.values(item);\n\n const placeholders = values.map((_, i) => `$${i + 1}`).join(', ');\n sql = `INSERT INTO ${table} (${columns.join(', ')}) VALUES (${placeholders}) RETURNING *`;\n params = values;\n }\n\n\n if ('insert_many' in query) {\n const { item, table } = query.insert_many;\n\n if (item.length > 0) {\n // 1. Extract column names from the first object\n const columns = Object.keys(item[0] || {});\n\n // 2. Generate multi-row parameter placeholders: ($1, $2), ($3, $4)\n const placeholders = item.map((row, rowIndex) => {\n const rowPlaceholders = columns.map((_, colIndex) =>\n `$${rowIndex * columns.length + colIndex + 1}`\n );\n return `(${rowPlaceholders.join(', ')})`;\n }).join(', ');\n\n // 3. Construct parameterized SQL statement\n sql = `INSERT INTO ${table} (${columns.join(', ')}) VALUES ${placeholders} RETURNING *`;\n\n // 4. Flatten all row values into a single array using Object.values()\n params = item.flatMap(row => Object.values(row));\n }\n }\n\n\n else if ('update' in query) {\n const {item, table, condition, conditionalParams = []} = query.update;\n\n const columns = Object.keys(item);\n const values = Object.values(item);\n\n // const columns = item.map(({ colName }) => colName);\n // const values = item.map(({ colValue }) => colValue);\n\n const setClause = columns.map((col, i) => `${col} = $${i + 1}`).join(', ');\n const paramOffset = values.length;\n const conditionWithParams = condition.replace(/\\$\\d+/g, (match) => {\n const num = parseInt(match.substring(1));\n return `$${num + paramOffset}`;\n });\n sql = `UPDATE ${table} SET ${setClause} WHERE ${conditionWithParams} RETURNING *`;\n params = [...values, ...conditionalParams];\n }\n\n\n else if ('select' in query) {\n const {columns = ['*'], table, condition, conditionalParams = []} = query.select;\n const selectColumns = columns.join(', ');\n sql = `SELECT ${selectColumns} FROM ${table}`;\n if (condition) {\n sql += ` WHERE ${condition}`;\n params = conditionalParams;\n }\n }\n\n\n else if ('delete' in query) {\n const {table, condition, conditionalParams = []} = query.delete;\n sql = `DELETE FROM ${table} WHERE ${condition} RETURNING *`;\n params = conditionalParams;\n }\n\n const result = await pool.query(sql, params);\n results.push(result.rows);\n }\n\n return results;\n\n } catch (error) {\n throw error;\n }\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nexport const executeCustom = async (\n customQuery: SqlRawQuery | SqlRawQuery[],\n poolClient?: PoolClient | null\n): Promise<any[]> => {\n const pool = poolClient || await getPgSqlPool();\n\n try {\n // If an array of raw queries was passed\n if (Array.isArray(customQuery)) {\n const results: any[] = [];\n for (const item of customQuery) {\n const { query: sql, params = [] } = item;\n if (sql) {\n const result = await pool.query(sql, params);\n results.push(result.rows);\n }\n }\n return results;\n }\n\n // If a single raw query object was passed\n const { query: sql, params = [] } = customQuery;\n if (!sql) {\n throw new Error(\"Custom query missing required 'query' string property.\");\n }\n\n const result = await pool.query(sql, params);\n return result.rows;\n\n } catch (error) {\n throw error;\n }\n};\n"],"mappings":";;;;;;;;AASO,IAAM,oBAAoB,8BAAO,UAAsB;AAC1D,MAAI,SAA4B;AAChC,MAAI,UAAiB,CAAC;AAEtB,MAAI;AAEA,UAAM,mBAAoB,MAAM,QAAQ,MAAM,MAAM,SAAS,KACxD,MAAM,QAAQ,MAAM,UACpB,MAAM,QAAQ,MAAM,MAAM,WAAW;AAE1C,QAAI,kBAAkB;AAClB,eAAS,OAAO,MAAM,aAAa,GAAG,QAAQ;AAC9C,YAAM,OAAO,MAAM,OAAO;AAAA,IAC9B;AAGA,QAAI,MAAM,QAAQ,MAAM,KAAK,SAAS,GAAG;AACrC,YAAM,cAAc,MAAM,YAAY,MAAM,MAAM,MAAM;AACxD,gBAAU,QAAQ,OAAO,WAAW;AAAA,IACxC;AAGA,QAAI,MAAM,UAAU,CAAC,MAAM,QAAQ,MAAM,MAAM,GAAG;AAC9C,YAAM,eAAe,MAAM,cAAc,MAAM,QAAQ,MAAM;AAC7D,cAA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AEA,YAAM,SAAS,MAAM,KAAK,MAAM,KAAK,MAAM;AAC3C,cAAQ,KAAK,OAAO,IAAI;AAAA,IAC5B;AAEA,WAAO;AAAA,EAEX,SAAS,OAAO;AACZ,UAAM;AAAA,EACV;AACJ,GA3FoB;AAkHb,IAAM,gBAAgB,8BACzB,aACA,eACiB;AACjB,QAAM,OAAO,cAAc,MAAM,aAAa;AAE9C,MAAI;AAEA,QAAI,MAAM,QAAQ,WAAW,GAAG;AAC5B,YAAM,UAAiB,CAAC;AACxB,iBAAW,QAAQ,aAAa;AAC5B,cAAM,EAAE,OAAOA,MAAK,QAAAC,UAAS,CAAC,EAAE,IAAI;AACpC,YAAID,MAAK;AACL,gBAAME,UAAS,MAAM,KAAK,MAAMF,MAAKC,OAAM;AAC3C,kBAAQ,KAAKC,QAAO,IAAI;AAAA,QAC5B;AAAA,MACJ;AACA,aAAO;AAAA,IACX;AAGA,UAAM,EAAE,OAAO,KAAK,SAAS,CAAC,EAAE,IAAI;AACpC,QAAI,CAAC,KAAK;AACN,YAAM,IAAI,MAAM,wDAAwD;AAAA,IAC5E;AAEA,UAAM,SAAS,MAAM,KAAK,MAAM,KAAK,MAAM;AAC3C,WAAO,OAAO;AAAA,EAElB,SAAS,OAAO;AACZ,UAAM;AAAA,EACV;AACJ,GAhC6B;","names":["sql","params","result"]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getMySqlPool
3
- } from "./chunk-2RFTNIPS.js";
3
+ } from "./chunk-W2KVW35Y.js";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-7QVYU63E.js";
@@ -145,4 +145,4 @@ var executeCustom = /* @__PURE__ */ __name(async (customQuery, poolClient) => {
145
145
  export {
146
146
  executeMySqlQuery
147
147
  };
148
- //# sourceMappingURL=chunk-DRLEV7OW.js.map
148
+ //# sourceMappingURL=chunk-IM22RSF7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utility/utilis/postgres/subSqlfiles/executeMySqlQuery.ts"],"sourcesContent":["import type {PoolConnection} from \"mysql2/promise\";\nimport type {QueryItems} from \"../../../libs/interface.js\";\nimport {getMySqlPool} from \"../../../../engine/sql/mySql.js\";\nimport type {SqlQuery, SqlRawQuery} from \"../../../libs/types.js\";\n\n\nexport const executeMySqlQuery = async (query: QueryItems) => {\n let client: PoolConnection | null = null;\n let results: any[] = [];\n\n try {\n // Check if we need a transaction (multiple queries or mix of crud and custom)\n const needsTransaction = (query.crud && query.crud?.length > 1) ||\n (query.crud && query.custom) ||\n (query.crud && query.crud?.length === 0);\n\n if (needsTransaction) {\n client = await (await getMySqlPool()).getConnection();\n await client.beginTransaction();\n }\n\n // Execute CRUD queries\n if (query.crud && query.crud.length > 0) {\n const crudResults = await executeCrud(query.crud, client);\n results = results.concat(crudResults);\n }\n\n // Execute custom query\n if (query.custom && !Array.isArray(query.custom)) {\n const customResult = await executeCustom(query.custom, client);\n results.push(customResult);\n }\n\n if (Array.isArray(query.custom) && query.custom.length) {\n const customResult = await executeCustom(query.custom, client);\n results.push(customResult);\n }\n\n // Commit transaction if we started one\n if (client) {\n await client.commit();\n }\n\n return results;\n\n } catch (error) {\n // Rollback if we have a client (meaning we started a transaction)\n if (client) {\n await client.rollback();\n }\n throw error;\n }\n finally {\n // Release client if we acquired one\n if (client) {\n client.release();\n }\n }\n}\n\n\n\n\n\n\n\n\n\n\n\n\nconst executeCrud = async (queries: SqlQuery[], poolClient?: PoolConnection | null): Promise<any[]> => {\n const results: any[] = [];\n const pool = poolClient || await getMySqlPool();\n\n try {\n for (const query of queries) {\n let sql: string = '';\n let params: any[] = [];\n\n if ('insert_one' in query) {\n const { item, table } = query.insert_one;\n const columns = Object.keys(item);\n const values = Object.values(item);\n\n const placeholders = values.map(() => '?').join(', ');\n sql = `INSERT INTO ${table} (${columns.join(', ')}) VALUES (${placeholders})`;\n params = values;\n\n const result = pool.query(sql, params);\n const insertId = (result as any)[0]?.insertId;\n\n if (insertId) {\n const [rows] = await (await pool).query(`SELECT * FROM ${table} WHERE id = ?`, [insertId]);\n results.push(rows);\n } else {\n results.push([]);\n }\n continue;\n }\n\n if ('insert_many' in query) {\n const { item, table } = query.insert_many;\n\n if (item.length > 0) {\n\n const columns = Object.keys(item[0] || {});\n const placeholders = item.map(() => `(${columns.map(() => '?').join(', ')})`).join(', ');\n sql = `INSERT INTO ${table} (${columns.join(', ')}) VALUES ${placeholders}`;\n params = item.flatMap(row => Object.values(row));\n\n const result = await pool.query(sql, params);\n const insertId = (result as any)[0]?.insertId;\n\n if (insertId) {\n const [rows] = await pool.query(`SELECT * FROM ${table} WHERE id >= ? ORDER BY id LIMIT ?`, [insertId, item.length]);\n results.push(rows);\n } else {\n results.push([]);\n }\n }\n\n }\n\n else if ('update' in query) {\n const { item, table, condition, conditionalParams = [] } = query.update;\n\n const columns = Object.keys(item);\n const values = Object.values(item);\n\n const setClause = columns.map(col => `${col} = ?`).join(', ');\n sql = `UPDATE ${table} SET ${setClause} WHERE ${condition}`;\n params = [...values, ...conditionalParams];\n\n await (await pool).query(sql, params);\n\n // Get updated rows\n const selectSql = `SELECT * FROM ${table} WHERE ${condition}`;\n const [rows] = await pool.query(selectSql, conditionalParams);\n results.push(rows);\n\n }\n\n else if ('select' in query) {\n const { columns = ['*'], table, condition, conditionalParams = [] } = query.select;\n const selectColumns = columns.join(', ');\n sql = `SELECT ${selectColumns} FROM ${table}`;\n if (condition) {\n sql += ` WHERE ${condition}`;\n params = conditionalParams;\n }\n const [rows] = await pool.query(sql, params);\n results.push(rows);\n\n }\n\n else if ('delete' in query) {\n const { table, condition, conditionalParams = [] } = query.delete;\n\n // Get deleted rows before deleting\n const selectSql = `SELECT * FROM ${table} WHERE ${condition}`;\n const [rows] = await pool.query(selectSql, conditionalParams);\n\n sql = `DELETE FROM ${table} WHERE ${condition}`;\n params = conditionalParams;\n await pool.query(sql, params);\n results.push(rows);\n\n }\n }\n\n return results;\n\n } catch (error) {\n throw error;\n }\n}\n\n\n\n\n\n\n\n\n\n\n\nconst executeCustom = async (\n customQuery: SqlRawQuery | SqlRawQuery[],\n poolClient?: PoolConnection | null\n): Promise<any[]> => {\n const pool = poolClient || await getMySqlPool();\n\n try {\n // If an array of raw queries was passed\n if (Array.isArray(customQuery)) {\n const results: any[] = [];\n for (const item of customQuery) {\n const { query: sql, params = [] } = item;\n if (sql) {\n const [rows] = await pool.query(sql, params);\n results.push(rows);\n }\n }\n return results;\n }\n\n // If a single raw query object was passed\n const { query: sql, params = [] } = customQuery;\n if (!sql) {\n throw new Error(\"Custom query missing required 'query' string property.\");\n }\n\n return await pool.query(sql, params);\n\n } catch (error) {\n throw error;\n }\n};\n"],"mappings":";;;;;;;;AAMO,IAAM,oBAAoB,8BAAO,UAAsB;AAC1D,MAAI,SAAgC;AACpC,MAAI,UAAiB,CAAC;AAEtB,MAAI;AAEA,UAAM,mBAAoB,MAAM,QAAQ,MAAM,MAAM,SAAS,KACxD,MAAM,QAAQ,MAAM,UACpB,MAAM,QAAQ,MAAM,MAAM,WAAW;AAE1C,QAAI,kBAAkB;AAClB,eAAS,OAAO,MAAM,aAAa,GAAG,cAAc;AACpD,YAAM,OAAO,iBAAiB;AAAA,IAClC;AAGA,QAAI,MAAM,QAAQ,MAAM,KAAK,SAAS,GAAG;AACrC,YAAM,cAAc,MAAM,YAAY,MAAM,MAAM,MAAM;AACxD,gBAAU,QAAQ,OAAO,WAAW;AAAA,IACxC;AAGA,QAAI,MAAM,UAAU,CAAC,MAAM,QAAQ,MAAM,MAAM,GAAG;AAC9C,YAAM,eAAe,MAAM,cAAc,MAAM,QAAQ,MAAM;AAC7D,cAAQ,KAAK,YAAY;AAAA,IAC7B;AAEA,QAAI,MAAM,QAAQ,MAAM,MAAM,KAAK,MAAM,OAAO,QAAQ;AACpD,YAAM,eAAe,MAAM,cAAc,MAAM,QAAQ,MAAM;AAC7D,cAAQ,KAAK,YAAY;AAAA,IAC7B;AAGA,QAAI,QAAQ;AACR,YAAM,OAAO,OAAO;AAAA,IACxB;AAEA,WAAO;AAAA,EAEX,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- } from "./chunk-EWQYVPOL.js";
6
+ } from "./chunk-LE2SDA4O.js";
7
7
  import {
8
8
  __name
9
9
  } from "./chunk-7QVYU63E.js";
@@ -21,8 +21,8 @@ async function getPgSqlPool() {
21
21
  if (!pool) {
22
22
  let options;
23
23
  try {
24
- const mySqlConfigFileTs = path.join(process.cwd(), "src/config/pgSql.config.ts");
25
- const mySqlConfigFileJs = path.join(process.cwd(), "src/config/pgSql.config.js");
24
+ const mySqlConfigFileTs = path.join(process.cwd(), "src", "config", "pgSql.config.ts");
25
+ const mySqlConfigFileJs = path.join(process.cwd(), "src", "config", "pgSql.config.js");
26
26
  const { PGSQL_POOL_OPTIONS } = await import(pathToFileURL(await fileExistsAsync(mySqlConfigFileJs) ? mySqlConfigFileJs : mySqlConfigFileTs).href);
27
27
  options = PGSQL_POOL_OPTIONS || {};
28
28
  options.connectionString = ENV.SQL_DB_URL;
@@ -92,4 +92,4 @@ export {
92
92
  runPgSqlScript,
93
93
  closePgPool
94
94
  };
95
- //# sourceMappingURL=chunk-SOZL76ZM.js.map
95
+ //# sourceMappingURL=chunk-IT6LYD4L.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/engine/sql/pgSql.ts"],"sourcesContent":["// pgSql.ts\nimport pg from 'pg';\nimport dotenv from 'dotenv';\nimport {ENV} from \"../../utility/libs/env.js\";\nimport fs from 'fs/promises';\nimport path from \"node:path\";\nimport {pathToFileURL} from \"node:url\";\nimport {fileExistsAsync} from \"../../utility/utilis/general/file-operations.js\";\n\ndotenv.config();\n\nconst { Pool } = pg;\n\nlet pool: pg.Pool | null = null;\n\nexport async function getPgSqlPool(): Promise<pg.Pool> {\n if (!pool) {\n\n let options: pg.PoolConfig;\n\n try {\n const mySqlConfigFileTs = path.join(process.cwd(), \"src\", \"config\", \"pgSql.config.ts\");\n const mySqlConfigFileJs = path.join(process.cwd(), \"src\", \"config\", \"pgSql.config.js\");\n const {PGSQL_POOL_OPTIONS} = await import(pathToFileURL(await fileExistsAsync(mySqlConfigFileJs) ? mySqlConfigFileJs : mySqlConfigFileTs).href);\n options = PGSQL_POOL_OPTIONS || {};\n options.connectionString = ENV.SQL_DB_URL\n }\n catch (error) {\n options = {};\n }\n\n pool = new Pool(options);\n\n // Test connection on startup\n pool.connect()\n .then(client => {\n console.log('✅ PostgreSQL Database connected successfully');\n client.release();\n })\n .catch(err => {\n console.error('❌ Failed to connect to PostgreSQL:', err.message);\n process.exit(1);\n });\n\n pool.on('connect', () => {\n console.log('🔌 New PostgreSQL connection established');\n });\n\n pool.on('error', (err: Error) => {\n console.error('❌ Unexpected PostgreSQL error:', err.message);\n });\n }\n\n return pool;\n}\n\nexport const runPgSqlScript = async () => {\n try {\n const fileQuery = await fs.readFile('db.sql', 'utf8');\n\n // Split queries for multiple statements\n const queries = fileQuery\n .split(';')\n .map(q => q.trim())\n .filter(q => q.length > 0);\n\n const client = await (await getPgSqlPool()).connect();\n\n try {\n // Run all queries in a transaction\n await client.query('BEGIN');\n\n for (const query of queries) {\n await client.query(query);\n }\n\n await client.query('COMMIT');\n console.log(\"✅ Database schema created successfully\");\n } catch (err) {\n await client.query('ROLLBACK');\n throw err;\n } finally {\n client.release();\n }\n } catch (err) {\n console.error('❌ Failed to execute SQL script:', err);\n throw err;\n }\n};\n\n// Graceful shutdown\nexport const closePgPool = async () => {\n if (pool) {\n console.log('🔄 Closing PostgreSQL pool...');\n await pool.end();\n pool = null;\n console.log('✅ PostgreSQL pool closed');\n }\n};\n\n// Handle process termination\nprocess.on('SIGINT', async () => {\n await closePgPool();\n process.exit(0);\n});\n\nprocess.on('SIGTERM', async () => {\n await closePgPool();\n process.exit(0);\n});\n"],"mappings":";;;;;;;;;;;AACA,OAAO,QAAQ;AACf,OAAO,YAAY;AAEnB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAQ,qBAAoB;AAG5B,OAAO,OAAO;AAEd,IAAM,EAAE,KAAK,IAAI;AAEjB,IAAI,OAAuB;AAE3B,eAAsB,eAAiC;AACn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AC3B,cAAQ,IAAI,6CAAwC;AAAA,IACxD,SAAS,KAAK;AACV,YAAM,OAAO,MAAM,UAAU;AAC7B,YAAM;AAAA,IACV,UAAE;AACE,aAAO,QAAQ;AAAA,IACnB;AAAA,EACJ,SAAS,KAAK;AACV,YAAQ,MAAM,wCAAmC,GAAG;AACpD,UAAM;AAAA,EACV;AACJ,GAhC8B;AAmCvB,IAAM,cAAc,mCAAY;AACnC,MAAI,MAAM;AACN,YAAQ,IAAI,sCAA+B;AAC3C,UAAM,KAAK,IAAI;AACf,WAAO;AACP,YAAQ,IAAI,+BAA0B;AAAA,EAC1C;AACJ,GAP2B;AAU3B,QAAQ,GAAG,UAAU,YAAY;AAC7B,QAAM,YAAY;AAClB,UAAQ,KAAK,CAAC;AAClB,CAAC;AAED,QAAQ,GAAG,WAAW,YAAY;AAC9B,QAAM,YAAY;AAClB,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":[]}
@@ -59,4 +59,4 @@ __name(generateUniqueValue, "generateUniqueValue");
59
59
  export {
60
60
  generateUniqueValue
61
61
  };
62
- //# sourceMappingURL=chunk-3IO4NPP3.js.map
62
+ //# sourceMappingURL=chunk-IZEPCXYK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utility/utilis/general/uuids.ts"],"sourcesContent":["import crypto from 'crypto';\nimport { getRandomValues } from 'node:crypto';\nimport type {GenerateIdOptions} from \"../../libs/interface.js\";\n\n\n\n\nexport function generateUniqueValue(length: number, options?: GenerateIdOptions): string;\nexport function generateUniqueValue(length: number, options: GenerateIdOptions & { count: number }): string[];\nexport function generateUniqueValue(\n length: number,\n options?: GenerateIdOptions & { count?: number }\n): string | string[] {\n if (length <= 0) {\n throw new Error('Length must be greater than 0');\n }\n\n const count = options?.count ?? 1;\n if (count <= 0) {\n throw new Error('Count must be greater than 0');\n }\n\n const generateSingleId = (): string => {\n let id = '';\n\n if (options?.useHex) {\n // 1 byte = 2 hex chars. We use Math.ceil and slice to ensure exact requested length.\n id = crypto.randomBytes(Math.ceil(length / 2)).toString('hex').slice(0, length);\n } else {\n // Allowed characters: A-Z, a-z, 0-9, and _ (63 total characters)\n const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_';\n const alphabetLength = alphabet.length; // 63\n\n // 63 is less than 64 (2^6), so 6 bits can represent 0-62.\n // Using a bitmask (63) avoids modulo bias for uniform randomness.\n const mask = (2 << (31 - Math.clz32((alphabetLength - 1) | 1))) - 1;\n const step = Math.ceil((1.6 * mask * length) / alphabetLength);\n\n const getBaseId = (): string => {\n let baseId = '';\n while (true) {\n const bytes = new Uint8Array(step);\n getRandomValues(bytes);\n\n for (const byteValue of bytes) {\n const byte = byteValue & mask;\n if (byte < alphabetLength) {\n baseId += alphabet[byte];\n if (baseId.length === length) {\n return baseId;\n }\n }\n }\n }\n };\n id = getBaseId();\n }\n\n // Apply formatting (Timestamp first, then Prefix)\n if (options?.includeTimestamp) {\n const timestamp = Date.now().toString(16);\n id = `${timestamp}-${id}`;\n }\n\n if (options?.prefix) {\n id = `${options.prefix}-${id}`;\n }\n\n return id;\n };\n\n // Return an array if count is explicitly requested, otherwise return a single string\n if (options?.count !== undefined) {\n return Array.from({ length: count }, () => generateSingleId());\n }\n\n return generateSingleId();\n}\n"],"mappings":";;;;;AAAA,OAAO,YAAY;AACnB,SAAS,uBAAuB;AAQzB,SAAS,oBACZ,QACA,SACiB;AACnB,MAAI,UAAU,GAAG;AACf,UAAM,IAAI,MAAM,+BAA+B;AAAA,EACjD;AAEA,QAAM,QAAQ,SAAS,SAAS;AAChC,MAAI,SAAS,GAAG;AACd,UAAM,IAAI,MAAM,8BAA8B;AAAA,EAChD;AAEA,QAAM,mBAAmB,6BAAc;AACrC,QAAI,KAAK;AAET,QAAI,SAAS,QAAQ;AAEnB,WAAK,OAAO,YAAY,KAAK,KAAK,SAAS,CAAC,CAAC,EAAE,SAAS,KAAK,EAAE,MAAM,GAAG,MAAM;AAAA,IAChF,OAAO;AAEL,YAAM,WAAW;AACjB,YAAM,iBAAiB,SAAS;AAIhC,YAAM,QAAQ,KAAM,KAAK,KAAK,MAAO,iBAAiB,IAAK,CAAC,KAAM;AAClE,YAAM,OAAO,KAAK,KAAM,MAAM,OAAO,SAAU,cAAc;AAE7D,YAAM,YAAY,6BAAc;AAC9B,YAAI,SAAS;AACb,eAAO,MAAM;AACX,gBAAM,QAAQ,IAAI,WAAW,IAAI;AACjC,0BAAgB,KAAK;AAErB,qBAAW,aAAa,OAAO;AAC7B,kBAAM,OAAO,YAAY;AACzB,gBAAI,OAAO,gBAAgB;AACzB,wBAAU,SAAS,IAAI;AACvB,kBAAI,OAAO,WAAW,QAAQ;AAC5B,uBAAO;AAAA,cACT;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF,GAhBkB;AAiBlB,WAAK,UAAU;AAAA,IACjB;AAGA,QAAI,SAAS,kBAAkB;AAC7B,YAAM,YAAY,KAAK,IAAI,EAAE,SAAS,EAAE;AACxC,WAAK,GAAG,SAAS,IAAI,EAAE;AAAA,IACzB;AAEA,QAAI,SAAS,QAAQ;AACnB,WAAK,GAAG,QAAQ,MAAM,IAAI,EAAE;AAAA,IAC9B;AAEA,WAAO;AAAA,EACT,GA/CyB;AAkDzB,MAAI,SAAS,UAAU,QAAW;AAChC,WAAO,MAAM,KAAK,EAAE,QAAQ,MAAM,GAAG,MAAM,iBAAiB,CAAC;AAAA,EAC/D;AAEA,SAAO,iBAAiB;AAC1B;AApEgB;","names":[]}
@@ -1,21 +1,21 @@
1
1
  import {
2
2
  generateUniqueValue
3
- } from "./chunk-3IO4NPP3.js";
3
+ } from "./chunk-IZEPCXYK.js";
4
4
  import {
5
5
  buildURL
6
- } from "./chunk-QBBF6LZZ.js";
6
+ } from "./chunk-ZC33GE2U.js";
7
7
  import {
8
8
  s3Client
9
- } from "./chunk-IAQMTSGP.js";
9
+ } from "./chunk-EKT74VDD.js";
10
10
  import {
11
11
  buildPath,
12
12
  getFileContentType,
13
13
  getFileExtension,
14
14
  toUint8Array
15
- } from "./chunk-CBTP2HOO.js";
15
+ } from "./chunk-QW2GGDEG.js";
16
16
  import {
17
17
  ENV
18
- } from "./chunk-EWQYVPOL.js";
18
+ } from "./chunk-LE2SDA4O.js";
19
19
  import {
20
20
  __name
21
21
  } from "./chunk-7QVYU63E.js";
@@ -69,4 +69,4 @@ var upload_file = /* @__PURE__ */ __name(async ({ file, path }) => {
69
69
  export {
70
70
  upload_file
71
71
  };
72
- //# sourceMappingURL=chunk-WLJV5O6C.js.map
72
+ //# sourceMappingURL=chunk-KYX4HMIY.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utility/utilis/cloud_storage/uploadFile.ts"],"sourcesContent":["import {ENV} from \"../../libs/env.js\";\nimport type {UploadFileInput} from \"../../libs/interface.js\";\nimport {PutObjectCommand} from \"@aws-sdk/client-s3\";\nimport {buildPath, getFileContentType, getFileExtension, toUint8Array} from \"../general/file-operations.js\";\nimport {buildURL} from \"../general/web.js\";\nimport {generateUniqueValue} from \"../general/uuids.js\";\nimport {s3Client} from \"../../../engine/cloudBucket/r2Storage.js\";\nimport type {FileUploadedResponseData, PathOptions} from \"../../libs/types.js\";\n\n\n\n\n\n\n/**\n * Uploads a single file to the configured S3-compatible storage bucket.\n *\n * The function accepts a Multer file, Web API `File`, raw `Buffer`, or file\n * path/URL. A unique file name is generated while preserving the original\n * file extension. The file is then converted to a byte array, its content\n * type is detected, and it is uploaded to the configured bucket.\n *\n * On successful upload, the function returns the generated storage path and\n * public URL along with the original file data when applicable. If the upload\n * fails, it returns the encountered error and the original file data when\n * available.\n *\n * @param params - The file and optional storage path used for the upload.\n * @param params.file - The file, buffer, or file path/URL to upload.\n * @param params.path - Optional array of path segments under which the file\n * should be stored.\n * @returns A promise resolving to a `FileUploadedResponseData` containing\n * either the uploaded file information or the encountered error.\n *\n * @example\n * const result = await upload_file({\n * file: req.file,\n * path: ['temporary_files'],\n * });\n *\n * if ('error' in result) {\n * console.error('Upload failed:', result.error);\n * } else {\n * console.log('File uploaded:', result.url);\n * }\n *\n * @example\n * const result = await upload_file({\n * file: buffer,\n * path: ['documents', 'reports'],\n * });\n *\n * if (!result.error) {\n * console.log('Uploaded to:', result.path);\n * }\n */\nexport const upload_file = async ({ file, path }: UploadFileInput): Promise<FileUploadedResponseData> => {\n // 1. Inspect input type\n const isMulterFile = file && typeof file === 'object' && 'buffer' in file && 'originalname' in file;\n const multerFile = isMulterFile ? (file as Express.Multer.File) : undefined;\n const rawBuffer = Buffer.isBuffer(file) ? file : undefined;\n const rawFile = (typeof File !== 'undefined' && file instanceof File) ? file : undefined;\n const filePath = typeof file === 'string' ? file : undefined;\n\n try {\n const baseFileName = generateUniqueValue(16);\n const fileExtension = getFileExtension(file);\n\n const fileName: string = fileExtension ? `${baseFileName}.${fileExtension}` : baseFileName;\n\n const body: PathOptions = { fileName };\n if (path && path.length) {\n body.segments = path;\n }\n\n const finalFileName = buildPath(body);\n const fileBuffer = await toUint8Array(file);\n const contentType = await getFileContentType(file);\n\n await s3Client.send(new PutObjectCommand({\n Bucket: ENV.BUCKET_NAME,\n Key: finalFileName,\n Body: fileBuffer,\n ContentType: contentType\n }));\n\n const generatedUrl = buildURL({\n path: [ENV.BUCKET_END_POINT as string, ENV.BUCKET_NAME as string, finalFileName]\n });\n\n // 2. Build success object omitting undefined keys\n return {\n path: filePath || finalFileName,\n url: generatedUrl,\n ...(rawFile && {file: rawFile}),\n ...(rawBuffer && {buffer: rawBuffer}),\n ...(multerFile && {multerFile: multerFile}),\n };\n\n } catch (error: any | unknown | Error) {\n // 3. Build error object omitting undefined keys\n return {\n error: error,\n ...(filePath && {path: filePath}),\n ...(rawFile && {file: rawFile}),\n ...(rawBuffer && {buffer: rawBuffer}),\n ...(multerFile && {multerFile: multerFile}),\n };\n }\n};\n\n\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAEA,SAAQ,wBAAuB;AAsDxB,IAAM,cAAc,8BAAO,EAAE,MAAM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I,cAAc,EAAC,WAAsB;AAAA,IAC7C;AAAA,EACJ;AACJ,GArD2B;","names":[]}
@@ -27,4 +27,4 @@ var ENV = {
27
27
  export {
28
28
  ENV
29
29
  };
30
- //# sourceMappingURL=chunk-EWQYVPOL.js.map
30
+ //# sourceMappingURL=chunk-LE2SDA4O.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utility/libs/env.ts"],"sourcesContent":["import { configDotenv } from 'dotenv';\nconfigDotenv();\n\n\nexport const ENV = {\n\n FILE: \"file\",\n FILES: \"files\",\n\n SERVER_PORT: process.env.SERVER_PORT as string,\n\n CURRENT_ENVIRONMENT: process.env.CURRENT_ENVIRONMENT as string,\n ENV_TYPE_LOCAL: process.env.ENV_TYPE_LOCAL as string,\n ENV_TYPE_PRODUCTION: process.env.ENV_TYPE_PRODUCTION as string,\n\n SQL_DB_URL: process.env.SQL_DB_URL as string,\n MONGO_SERVER_URL: process.env.MONGO_DB_URL as string,\n\n IN_APP_BUCKET: process.env.IN_APP_BUCKET as string,\n BUCKET_NAME: process.env.BUCKET_NAME as string,\n BUCKET_END_POINT: process.env.BUCKET_END_POINT as string,\n BUCKET_ACCESS_KEY_ID: process.env.BACKEND_ACCESS_KEY as string,\n BUCKET_SECRET_KEY_ID: process.env.BACKEND_SECRET_KEY as string,\n\n URL: \"url\",\n PATH: 'path',\n\n MY_SQL: 'mysql',\n POSTGRES_SQL: 'postgresql',\n\n MAX_BATCH_FILES: process.env.MAX_BATCH_FILES as string,\n MAX_FILE_SIZE_IN_MB: process.env.MAX_FILE_SIZE_IN_MB as string,\n MAX_FIELD_SIZE_IN_MB: process.env.MAX_FIELD_SIZE_IN_MB as string,\n\n\n}\n"],"mappings":";AAAA,SAAS,oBAAoB;AAC7B,aAAa;AAGN,IAAM,MAAM;AAAA,EAEf,MAAM;AAAA,EACN,OAAO;AAAA,EAEP,aAAa,QAAQ,IAAI;AAAA,EAEzB,qBAAqB,QAAQ,IAAI;AAAA,EACjC,gBAAgB,QAAQ,IAAI;AAAA,EAC5B,qBAAqB,QAAQ,IAAI;AAAA,EAEjC,YAAY,QAAQ,IAAI;AAAA,EACxB,kBAAkB,QAAQ,IAAI;AAAA,EAE9B,eAAe,QAAQ,IAAI;AAAA,EAC3B,aAAa,QAAQ,IAAI;AAAA,EACzB,kBAAkB,QAAQ,IAAI;AAAA,EAC9B,sBAAsB,QAAQ,IAAI;AAAA,EAClC,sBAAsB,QAAQ,IAAI;AAAA,EAElC,KAAK;AAAA,EACL,MAAM;AAAA,EAEN,QAAQ;AAAA,EACR,cAAc;AAAA,EAEd,iBAAiB,QAAQ,IAAI;AAAA,EAC7B,qBAAqB,QAAQ,IAAI;AAAA,EACjC,sBAAsB,QAAQ,IAAI;AAGtC;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ENV
3
- } from "./chunk-EWQYVPOL.js";
3
+ } from "./chunk-LE2SDA4O.js";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-7QVYU63E.js";
@@ -87,4 +87,4 @@ export {
87
87
  isMySQL,
88
88
  isPostgreSQL
89
89
  };
90
- //# sourceMappingURL=chunk-T4KN3FCF.js.map
90
+ //# sourceMappingURL=chunk-O5ILFRFV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utility/utilis/general/sqlDb.js.ts"],"sourcesContent":["// constants.ts or at top of file\nimport type {DatabaseType} from \"../../libs/types.js\";\nimport { URL } from 'url';\nimport {ENV} from \"../../libs/env.js\";\n\n\n\nexport function detectSQLDatabase(url: string): DatabaseType {\n try {\n // Parse the URL\n const parsedUrl = new URL(url);\n const scheme = parsedUrl.protocol.replace(':', '').toLowerCase();\n\n // MySQL schemes\n const mysqlSchemes = [\n 'mysql',\n 'mysql+pymysql',\n 'mysql+mysqldb',\n 'mysql+mysqlconnector',\n 'mysql2',\n 'mysql+mysql2'\n ];\n\n // PostgreSQL schemes\n const postgresSchemes = [\n 'postgresql',\n 'postgres',\n 'postgresql+psycopg2',\n 'postgres+psycopg2',\n 'postgresql+pg8000',\n 'postgres+pg8000',\n 'postgresql+asyncpg',\n 'postgresql+pg',\n 'postgres+pg'\n ];\n\n // Check for MySQL\n if (mysqlSchemes.includes(scheme)) {\n return ENV.MY_SQL;\n }\n\n // Check for PostgreSQL\n if (postgresSchemes.includes(scheme)) {\n return ENV.POSTGRES_SQL;\n }\n\n // If it's a generic URL without protocol, try to detect from connection string\n // This handles cases like \"localhost:5432/mydb\" or \"127.0.0.1:3306/mydb\"\n if (scheme === '' && !parsedUrl.protocol) {\n // Try parsing as a generic connection string\n const connectionString = url.toLowerCase();\n if (connectionString.includes('mysql') ||\n connectionString.includes('my-sql') ||\n parsedUrl.port === '3306') {\n return ENV.MY_SQL;\n }\n if (connectionString.includes('postgres') ||\n connectionString.includes('postgre') ||\n parsedUrl.port === '5432') {\n return ENV.POSTGRES_SQL;\n }\n }\n\n // If we reach here, we couldn't detect the database type\n throw new Error(\n `Unsupported or unrecognized database type. URL: ${url}. ` +\n `Detected scheme: ${scheme || 'none'}`\n );\n\n } catch (error) {\n if (error instanceof Error && error.message.includes('Invalid URL')) {\n // Try to detect from raw connection string without protocol\n const lowerUrl = url.toLowerCase();\n if (lowerUrl.includes('mysql') || lowerUrl.includes('my-sql')) {\n return ENV.MY_SQL;\n }\n if (lowerUrl.includes('postgres') || lowerUrl.includes('postgre')) {\n return ENV.POSTGRES_SQL;\n }\n // Check ports as fallback\n if (url.includes(':3306')) return ENV.MY_SQL;\n if (url.includes(':5432')) return ENV.POSTGRES_SQL;\n\n throw new Error(`Invalid URL format: ${url}`);\n }\n throw error;\n }\n}\n\n\n\n\n\n\nexport function isMySQL(url: string): boolean {\n try {\n return detectSQLDatabase(url) === ENV.MY_SQL;\n } catch {\n return false;\n }\n}\n\n\n\n\n\n\n\nexport function isPostgreSQL(url: string): boolean {\n try {\n return detectSQLDatabase(url) === ENV.POSTGRES_SQL;\n } catch {\n return false;\n }\n}\n"],"mappings":";;;;;;;;AAEA,SAAS,WAAW;AAKb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tC,UAAI,IAAI,SAAS,OAAO,EAAG,QAAO,IAAI;AAEtC,YAAM,IAAI,MAAM,uBAAuB,GAAG,EAAE;AAAA,IAChD;AACA,UAAM;AAAA,EACV;AACJ;AAhFgB;AAuFT,SAAS,QAAQ,KAAsB;AAC1C,MAAI;AACA,WAAO,kBAAkB,GAAG,MAAM,IAAI;AAAA,EAC1C,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ;AANgB;AAcT,SAAS,aAAa,KAAsB;AAC/C,MAAI;AACA,WAAO,kBAAkB,GAAG,MAAM,IAAI;AAAA,EAC1C,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ;AANgB;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  ENV
3
- } from "./chunk-EWQYVPOL.js";
3
+ } from "./chunk-LE2SDA4O.js";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-7QVYU63E.js";
@@ -153,4 +153,4 @@ export {
153
153
  url_or_path,
154
154
  toUint8Array
155
155
  };
156
- //# sourceMappingURL=chunk-CBTP2HOO.js.map
156
+ //# sourceMappingURL=chunk-QW2GGDEG.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utility/utilis/general/file-operations.ts"],"sourcesContent":["import mime from \"mime-types\";\nimport {ENV} from \"../../libs/env.js\";\nimport {readFile} from \"node:fs/promises\";\nimport fs from \"fs/promises\";\nimport fsSync from \"fs\";\nimport type {PathOptions} from \"../../libs/types.js\";\nimport type {DownloadablePath} from \"../../libs/interface.js\";\n\n\n\n\n\n\n\n\nexport async function fileExistsAsync(filePath: string): Promise<boolean> {\n try {\n await fs.access(filePath);\n return true; // File exists and is accessible\n } catch {\n return false; // File does not exist\n }\n}\n\n\n\n\n\n\nexport function fileExistsSync(filePath: string): boolean {\n try {\n fsSync.accessSync(filePath);\n return true;\n } catch {\n return false;\n }\n}\n\n\n\n\n\n\nexport function getFileExtension(input: Express.Multer.File | File | Buffer | string): string {\n // 1. If it's a raw Buffer, it has no file name/extension metadata\n if (Buffer.isBuffer(input)) {\n return '';\n }\n\n // 2. Extract the filename string based on the input type\n let filename = '';\n\n if (typeof input === 'string') {\n filename = input;\n }\n else if ('originalname' in input && input.originalname) {\n // Express.Multer.File\n filename = input.originalname;\n }\n else if ('name' in input && input.name) {\n // Web API File\n filename = input.name;\n }\n\n if (!filename) {\n return '';\n }\n\n // 3. Remove URL query parameters or hashes (if a URL/path string is passed)\n const cleanFilename = filename.split(/[?#]/)[0] as string;\n\n // 4. Extract the last segment after the final dot\n const match = cleanFilename.match(/\\.([^./\\\\]+)$/);\n\n return match?.[1]?.toLowerCase() ?? '';\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nexport function buildPath(options: PathOptions): string {\n // If a complete path is directly provided\n if (\"path\" in options) {\n return options.path\n .replace(/^\\/+|\\/+$/g, '')\n .replace(/\\/+/g, '/');\n }\n\n const {\n path_prefix,\n segments = [],\n path_postfix,\n fileName,\n } = options;\n\n let resolvedFileName = '';\n\n if (typeof fileName === 'string') {\n resolvedFileName = fileName;\n } else if (Buffer.isBuffer(fileName)) {\n resolvedFileName = fileName.toString();\n } else if (fileName) {\n // Browser File\n if ('name' in fileName) {\n resolvedFileName = fileName.name;\n }\n // Express.Multer.File\n else if ('originalname' in fileName) {\n resolvedFileName = fileName.originalname;\n }\n }\n\n const allSegments = [\n path_prefix,\n ...segments,\n path_postfix,\n resolvedFileName,\n ];\n\n return allSegments\n .filter(\n (segment): segment is string =>\n Boolean(segment && segment.trim())\n )\n .map((segment) =>\n segment\n .replace(/^\\/+|\\/+$/g, '')\n .replace(/\\/+/g, '/')\n )\n .filter((segment) => segment.length > 0)\n .join('/');\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nexport function getInAppBucketDownloadPath(\n {\n segments = [],\n fileName,\n }: DownloadablePath = {}\n): string {\n const cleanedSegments = segments.filter(\n (segment) => segment !== ENV.IN_APP_BUCKET\n );\n\n return buildPath({\n path_prefix: ENV.IN_APP_BUCKET,\n segments: cleanedSegments,\n ...(fileName && {fileName: fileName}),\n });\n}\n\n\n\n\n\n\n\n\n\n\n\nexport const getFileContentType = async (\n file: Express.Multer.File | File | Buffer | string\n): Promise<string> => {\n // 1. Raw Buffer: Buffers don't carry MIME metadata, so default to octet-stream\n if (Buffer.isBuffer(file)) {\n return 'application/octet-stream';\n }\n\n // 2. String path or URL: Look up MIME type based on extension/filename\n if (typeof file === 'string') {\n const detectedType = mime.lookup(file);\n return detectedType || 'application/octet-stream';\n }\n\n // 3. Express.Multer.File: Has 'mimetype' property\n if ('mimetype' in file && file.mimetype) {\n return file.mimetype;\n }\n\n // 4. Web API File: Has 'type' property\n if ('type' in file && file.type) {\n return file.type;\n }\n\n // 5. Fallback if object has no recognizable MIME type\n return 'application/octet-stream';\n};\n\n\n\n\n\n\n\n\n\n\n\n\nexport const url_or_path = (val: string): 'url' | 'path' => {\n try {\n const parsed = new URL(val);\n if (parsed.protocol === \"http:\" || parsed.protocol === \"https:\") {\n return 'url';\n }\n } catch {\n // If new URL() throws, it is a local path\n }\n return 'path';\n};\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nexport async function toUint8Array(file: Express.Multer.File | File | Buffer | string): Promise<Uint8Array> {\n if (typeof file === \"string\") {\n // File path on disk\n return await readFile(file);\n }\n\n if (Buffer.isBuffer(file)) {\n // Raw Node.js Buffer\n return new Uint8Array(file);\n }\n\n if (\"buffer\" in file && Buffer.isBuffer(file.buffer)) {\n // Express.Multer.File (Memory storage)\n return new Uint8Array(file.buffer);\n }\n\n if (\"path\" in file && typeof file.path === \"string\") {\n // Express.Multer.File (Disk storage)\n return await readFile(file.path);\n }\n\n if (\"arrayBuffer\" in file && typeof file.arrayBuffer === \"function\") {\n // Web API File / Blob\n return new Uint8Array(await file.arrayBuffer());\n }\n\n throw new Error(\"Unable to parse file input into a valid binary buffer.\");\n}\n\n\n\n\n\n"],"mappings":";;;;;;;;AAAA,OAAO,UAAU;AAEjB,SAAQ,gBAAe;AACvB,OAAO,QAAQ;AACf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;AACxG,MAAI,OAAO,SAAS,UAAU;AAE1B,WAAO,MAAM,SAAS,IAAI;AAAA,EAC9B;AAEA,MAAI,OAAO,SAAS,IAAI,GAAG;AAEvB,WAAO,IAAI,WAAW,IAAI;AAAA,EAC9B;AAEA,MAAI,YAAY,QAAQ,OAAO,SAAS,KAAK,MAAM,GAAG;AAElD,WAAO,IAAI,WAAW,KAAK,MAAM;AAAA,EACrC;AAEA,MAAI,UAAU,QAAQ,OAAO,KAAK,SAAS,UAAU;AAEjD,WAAO,MAAM,SAAS,KAAK,IAAI;AAAA,EACnC;AAEA,MAAI,iBAAiB,QAAQ,OAAO,KAAK,gBAAgB,YAAY;AAEjE,WAAO,IAAI,WAAW,MAAM,KAAK,YAAY,CAAC;AAAA,EAClD;AAEA,QAAM,IAAI,MAAM,wDAAwD;AAC5E;AA3BsB;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getMongoServer
3
- } from "./chunk-ECIP24BN.js";
3
+ } from "./chunk-AS7JRX2N.js";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-7QVYU63E.js";
@@ -30,4 +30,4 @@ var mongoInsertField = /* @__PURE__ */ __name(async (params) => {
30
30
  export {
31
31
  mongoInsertField
32
32
  };
33
- //# sourceMappingURL=chunk-LW246RDT.js.map
33
+ //# sourceMappingURL=chunk-T4PLUOW3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/utility/utilis/mongoDb/insertField.ts"],"sourcesContent":["import {getMongoServer} from \"../../../engine/mondoDb/mongoDB.js\";\nimport type {CustomInsertOneResult} from \"../../libs/types.js\";\nimport type {InsertOneInterface} from \"../../libs/interface.js\";\nimport type {Document } from \"mongodb\";\n\n\n\nexport const mongoInsertField = async <T>(\n params: InsertOneInterface<T>\n): Promise<CustomInsertOneResult<T>> => {\n const { dbName, collectionName, field, options } = params;\n\n try {\n const db = getMongoServer().db(dbName);\n const collection = db.collection<T & Document>(collectionName);\n\n const result = await collection.insertOne(field, options);\n\n return {\n status: true,\n result,\n error: null,\n };\n } catch (err) {\n const error = err instanceof Error ? err : new Error(String(err));\n return {\n status: false,\n result: null,\n error,\n };\n }\n};\n"],"mappings":";;;;;;;;AAOO,IAAM,mBAAmB,8BAC5B,WACoC;AACpC,QAAM,EAAE,QAAQ,gBAAgB,OAAO,QAAQ,IAAI;AAEnD,MAAI;AACA,UAAM,KAAK,eAAe,EAAE,GAAG,MAAM;AACrC,UAAM,aAAa,GAAG,WAAyB,cAAc;AAE7D,UAAM,SAAS,MAAM,WAAW,UAAU,OAAO,OAAO;AAExD,WAAO;AAAA,MACH,QAAQ;AAAA,MACR;AAAA,MACA,OAAO;AAAA,IACX;AAAA,EACJ,SAAS,KAAK;AACV,UAAM,QAAQ,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,CAAC;AAChE,WAAO;AAAA,MACH,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR;AAAA,IACJ;AAAA,EACJ;AACJ,GAxBgC;","names":[]}
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getMongoServer
3
- } from "./chunk-ECIP24BN.js";
3
+ } from "./chunk-AS7JRX2N.js";
4
4
  import {
5
5
  __name
6
6
  } from "./chunk-7QVYU63E.js";
@@ -29,4 +29,4 @@ var mongoBulkWrite = /* @__PURE__ */ __name(async (params) => {
29
29
  export {
30
30
  mongoBulkWrite
31
31
  };
32
- //# sourceMappingURL=chunk-LNFYUCA3.js.map
32
+ //# sourceMappingURL=chunk-VFJV227G.js.map