backfarm 1.0.6 → 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.
- package/dist/{chunk-O76OK6Y7.js → chunk-237SVWEU.js} +2 -2
- package/dist/{chunk-EUWCMMGI.js → chunk-346ZYI6W.js} +2 -2
- package/dist/{chunk-RZ7XHAUV.js → chunk-5NVPS6PC.js} +2 -2
- package/dist/{chunk-2QNCQ5L5.js → chunk-AS7JRX2N.js} +3 -3
- package/dist/chunk-AS7JRX2N.js.map +1 -0
- package/dist/{chunk-22GJTNKR.js → chunk-AYXJEOSW.js} +5 -5
- package/dist/{chunk-452DWS46.js → chunk-DKFDGYXS.js} +2 -2
- package/dist/{chunk-UPP2FW3G.js → chunk-DWODHIWI.js} +24 -24
- package/dist/chunk-DWODHIWI.js.map +1 -0
- package/dist/{chunk-J3P6W53K.js → chunk-EKT74VDD.js} +3 -3
- package/dist/chunk-EKT74VDD.js.map +1 -0
- package/dist/{chunk-M7PVDT2D.js → chunk-GMQU3OAU.js} +2 -2
- package/dist/{chunk-6BNQOIVA.js → chunk-GWPLCPRW.js} +2 -2
- package/dist/{chunk-ZC6ZFZ2J.js → chunk-H3RM55WC.js} +2 -2
- package/dist/{chunk-U7BCM2WN.js → chunk-IM22RSF7.js} +2 -2
- package/dist/{chunk-5AJKFCEE.js → chunk-IT6LYD4L.js} +3 -3
- package/dist/chunk-IT6LYD4L.js.map +1 -0
- package/dist/{chunk-ZGOMCU4T.js → chunk-KYX4HMIY.js} +2 -2
- package/dist/{chunk-YA3MW2CJ.js → chunk-T4PLUOW3.js} +2 -2
- package/dist/{chunk-EEQ2SXDE.js → chunk-VFJV227G.js} +2 -2
- package/dist/{chunk-HV3IQJH3.js → chunk-W2KVW35Y.js} +3 -3
- package/dist/chunk-W2KVW35Y.js.map +1 -0
- package/dist/{chunk-O2ZDXQ2Z.js → chunk-XMWRNOBE.js} +2 -2
- package/dist/{chunk-HC4IDQP6.js → chunk-XPJKMJBD.js} +2 -2
- package/dist/engine/cloudBucket/r2Storage.js +1 -1
- package/dist/engine/mondoDb/mongoDB.js +1 -1
- package/dist/engine/server/server.js +19 -19
- package/dist/engine/sql/mySql.js +1 -1
- package/dist/engine/sql/pgSql.js +1 -1
- package/dist/utility/libs/index.js +19 -19
- package/dist/utility/libs/run-all.js +19 -19
- package/dist/utility/libs/run-node-server.js +19 -19
- package/dist/utility/utilis/cloud_storage/deleteFile.js +2 -2
- package/dist/utility/utilis/cloud_storage/deleteFiles.js +2 -2
- package/dist/utility/utilis/cloud_storage/downloadFile.js +2 -2
- package/dist/utility/utilis/cloud_storage/downloadFiles.js +2 -2
- package/dist/utility/utilis/cloud_storage/uploadFile.js +2 -2
- package/dist/utility/utilis/cloud_storage/uploadFiles.js +3 -3
- package/dist/utility/utilis/mongoDb/buldWrite.js +2 -2
- package/dist/utility/utilis/mongoDb/deleteDocument.js +2 -2
- package/dist/utility/utilis/mongoDb/insertField.js +2 -2
- package/dist/utility/utilis/mongoDb/insertFields.js +2 -2
- package/dist/utility/utilis/mongoDb/updateFiled.js +2 -2
- package/dist/utility/utilis/postgres/executeQuery.js +5 -5
- package/dist/utility/utilis/postgres/subSqlfiles/executeMySqlQuery.js +2 -2
- package/dist/utility/utilis/postgres/subSqlfiles/executePgQuery.js +2 -2
- package/dist/utility/utilis/server/app.js +19 -19
- package/dist/utility/utilis/server/server.js +19 -19
- package/package.json +1 -1
- package/dist/chunk-2QNCQ5L5.js.map +0 -1
- package/dist/chunk-5AJKFCEE.js.map +0 -1
- package/dist/chunk-HV3IQJH3.js.map +0 -1
- package/dist/chunk-J3P6W53K.js.map +0 -1
- package/dist/chunk-UPP2FW3G.js.map +0 -1
- /package/dist/{chunk-O76OK6Y7.js.map → chunk-237SVWEU.js.map} +0 -0
- /package/dist/{chunk-EUWCMMGI.js.map → chunk-346ZYI6W.js.map} +0 -0
- /package/dist/{chunk-RZ7XHAUV.js.map → chunk-5NVPS6PC.js.map} +0 -0
- /package/dist/{chunk-22GJTNKR.js.map → chunk-AYXJEOSW.js.map} +0 -0
- /package/dist/{chunk-452DWS46.js.map → chunk-DKFDGYXS.js.map} +0 -0
- /package/dist/{chunk-M7PVDT2D.js.map → chunk-GMQU3OAU.js.map} +0 -0
- /package/dist/{chunk-6BNQOIVA.js.map → chunk-GWPLCPRW.js.map} +0 -0
- /package/dist/{chunk-ZC6ZFZ2J.js.map → chunk-H3RM55WC.js.map} +0 -0
- /package/dist/{chunk-U7BCM2WN.js.map → chunk-IM22RSF7.js.map} +0 -0
- /package/dist/{chunk-ZGOMCU4T.js.map → chunk-KYX4HMIY.js.map} +0 -0
- /package/dist/{chunk-YA3MW2CJ.js.map → chunk-T4PLUOW3.js.map} +0 -0
- /package/dist/{chunk-EEQ2SXDE.js.map → chunk-VFJV227G.js.map} +0 -0
- /package/dist/{chunk-O2ZDXQ2Z.js.map → chunk-XMWRNOBE.js.map} +0 -0
- /package/dist/{chunk-HC4IDQP6.js.map → chunk-XPJKMJBD.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMongoServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-AS7JRX2N.js";
|
|
4
4
|
import {
|
|
5
5
|
__name
|
|
6
6
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -37,4 +37,4 @@ var mongoUpdateField = /* @__PURE__ */ __name(async (params) => {
|
|
|
37
37
|
export {
|
|
38
38
|
mongoUpdateField
|
|
39
39
|
};
|
|
40
|
-
//# sourceMappingURL=chunk-
|
|
40
|
+
//# sourceMappingURL=chunk-237SVWEU.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMongoServer
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-AS7JRX2N.js";
|
|
4
4
|
import {
|
|
5
5
|
__name
|
|
6
6
|
} from "./chunk-7QVYU63E.js";
|
|
@@ -32,4 +32,4 @@ var mongoInsertFields = /* @__PURE__ */ __name(async (params) => {
|
|
|
32
32
|
export {
|
|
33
33
|
mongoInsertFields
|
|
34
34
|
};
|
|
35
|
-
//# sourceMappingURL=chunk-
|
|
35
|
+
//# sourceMappingURL=chunk-346ZYI6W.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-ZC33GE2U.js";
|
|
7
7
|
import {
|
|
8
8
|
s3Client
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EKT74VDD.js";
|
|
10
10
|
import {
|
|
11
11
|
getFileExtension,
|
|
12
12
|
getInAppBucketDownloadPath
|
|
@@ -71,4 +71,4 @@ var downloadFile = /* @__PURE__ */ __name(async ({
|
|
|
71
71
|
export {
|
|
72
72
|
downloadFile
|
|
73
73
|
};
|
|
74
|
-
//# sourceMappingURL=chunk-
|
|
74
|
+
//# sourceMappingURL=chunk-5NVPS6PC.js.map
|
|
@@ -20,8 +20,8 @@ async function connectToMongo() {
|
|
|
20
20
|
if (!client) {
|
|
21
21
|
let options;
|
|
22
22
|
try {
|
|
23
|
-
const mongoConfigFileTs = path.join(process.cwd(), "src
|
|
24
|
-
const mongoConfigFileJs = path.join(process.cwd(), "src
|
|
23
|
+
const mongoConfigFileTs = path.join(process.cwd(), "src", "config", "mongo.config.ts");
|
|
24
|
+
const mongoConfigFileJs = path.join(process.cwd(), "src", "config", "mongo.config.js");
|
|
25
25
|
const { MONGO_CLIENT_OPTIONS } = await import(pathToFileURL(
|
|
26
26
|
await fileExistsAsync(mongoConfigFileJs) ? mongoConfigFileJs : mongoConfigFileTs
|
|
27
27
|
).href);
|
|
@@ -52,4 +52,4 @@ export {
|
|
|
52
52
|
connectToMongo,
|
|
53
53
|
getMongoServer
|
|
54
54
|
};
|
|
55
|
-
//# sourceMappingURL=chunk-
|
|
55
|
+
//# sourceMappingURL=chunk-AS7JRX2N.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/engine/mondoDb/mongoDB.ts"],"sourcesContent":["import { ENV } from \"../../utility/libs/env.js\";\nimport { MongoClient, type MongoClientOptions } from 'mongodb';\nimport path from \"node:path\"\nimport {pathToFileURL} from \"node:url\";\nimport {fileExistsAsync} from \"../../utility/utilis/general/file-operations.js\";\n\n\nconst uri = ENV.MONGO_SERVER_URL;\nlet client: MongoClient | null = null;\n\n\nasync function connectToMongo(): Promise<MongoClient|undefined> {\n if (!uri) return;\n try {\n if (!client) {\n\n let options: MongoClientOptions;\n\n try {\n const mongoConfigFileTs = path.join(process.cwd(), \"src\", \"config\", \"mongo.config.ts\");\n const mongoConfigFileJs = path.join(process.cwd(), \"src\", \"config\", \"mongo.config.js\");\n\n const { MONGO_CLIENT_OPTIONS } = await import(\n pathToFileURL(\n (await fileExistsAsync(mongoConfigFileJs)) ? mongoConfigFileJs : mongoConfigFileTs\n ).href\n );\n options = MONGO_CLIENT_OPTIONS || {};\n }\n catch (error) {\n options = {}\n }\n\n\n client = new MongoClient(uri, options);\n await client.connect();\n console.log(\"✅ Connected to MongoDB Cluster\");\n\n }\n return client;\n } catch (error) {\n console.error(\"❌ MongoDB Connection Error:\", error);\n throw error;\n }\n}\n\n\n\nfunction getMongoServer(): MongoClient {\n if (!client) {\n throw new Error(\"Call connectToMongo first!\");\n }\n return client;\n}\n\n\n\nexport { connectToMongo, getMongoServer };\n"],"mappings":";;;;;;;;;;;AACA,SAAS,mBAA4C;AACrD,OAAO,UAAU;AACjB,SAAQ,qBAAoB;AAI5B,IAAM,MAAM,IAAI;AAChB,IAAI,SAA6B;AAGjC,eAAe,iBAAiD;AAC9D,MAAI,CAAC,IAAK;AACV,MAAI;AACF,QAAI,CAAC,QAAQ;AAEX,UAAI;AAEJ,UAAI;AACF,cAAM,oBAAoB,KAAK,KAAK,QAAQ,IAAI,GAAG,OAAO,UAAU,iBAAiB;AACrF,cAAM,oBAAoB,KAAK,KAAK,QAAQ,IAAI,GAAG,OAAO,UAAU,iBAAiB;AAErF,cAAM,EAAE,qBAAqB,IAAI,MAAM,OACnC;AAAA,UACK,MAAM,gBAAgB,iBAAiB,IAAK,oBAAoB;AAAA,QACrE,EAAE;AAEN,kBAAU,wBAAwB,CAAC;AAAA,MACrC,SACO,OAAO;AACZ,kBAAU,CAAC;AAAA,MACb;AAGA,eAAS,IAAI,YAAY,KAAK,OAAO;AACrC,YAAM,OAAO,QAAQ;AACrB,cAAQ,IAAI,qCAAgC;AAAA,IAE9C;AACA,WAAO;AAAA,EACT,SAAS,OAAO;AACd,YAAQ,MAAM,oCAA+B,KAAK;AAClD,UAAM;AAAA,EACR;AACF;AAjCe;AAqCf,SAAS,iBAA8B;AACrC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,4BAA4B;AAAA,EAC9C;AACA,SAAO;AACT;AALS;","names":[]}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
executeMySqlQuery
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-IM22RSF7.js";
|
|
4
4
|
import {
|
|
5
5
|
executePgSqlQuery
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-H3RM55WC.js";
|
|
7
7
|
import {
|
|
8
8
|
isMySQL,
|
|
9
9
|
isPostgreSQL
|
|
10
10
|
} from "./chunk-O5ILFRFV.js";
|
|
11
11
|
import {
|
|
12
12
|
getMySqlPool
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-W2KVW35Y.js";
|
|
14
14
|
import {
|
|
15
15
|
getPgSqlPool
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-IT6LYD4L.js";
|
|
17
17
|
import {
|
|
18
18
|
ENV
|
|
19
19
|
} from "./chunk-LE2SDA4O.js";
|
|
@@ -44,4 +44,4 @@ export {
|
|
|
44
44
|
executeQuery,
|
|
45
45
|
getPool
|
|
46
46
|
};
|
|
47
|
-
//# sourceMappingURL=chunk-
|
|
47
|
+
//# sourceMappingURL=chunk-AYXJEOSW.js.map
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-ZC33GE2U.js";
|
|
7
7
|
import {
|
|
8
8
|
s3Client
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EKT74VDD.js";
|
|
10
10
|
import {
|
|
11
11
|
getFileExtension,
|
|
12
12
|
getInAppBucketDownloadPath
|
|
@@ -85,4 +85,4 @@ var downloadFiles = /* @__PURE__ */ __name(async ({
|
|
|
85
85
|
export {
|
|
86
86
|
downloadFiles
|
|
87
87
|
};
|
|
88
|
-
//# sourceMappingURL=chunk-
|
|
88
|
+
//# sourceMappingURL=chunk-DKFDGYXS.js.map
|
|
@@ -4,34 +4,34 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
upload_single
|
|
6
6
|
} from "./chunk-3DJ6GERS.js";
|
|
7
|
+
import {
|
|
8
|
+
executeQuery,
|
|
9
|
+
getPool
|
|
10
|
+
} from "./chunk-AYXJEOSW.js";
|
|
7
11
|
import {
|
|
8
12
|
mongoBulkWrite
|
|
9
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-VFJV227G.js";
|
|
10
14
|
import {
|
|
11
15
|
mongoDeleteDocument
|
|
12
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-GWPLCPRW.js";
|
|
13
17
|
import {
|
|
14
18
|
mongoInsertField
|
|
15
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-T4PLUOW3.js";
|
|
16
20
|
import {
|
|
17
21
|
mongoInsertFields
|
|
18
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-346ZYI6W.js";
|
|
19
23
|
import {
|
|
20
24
|
mongoUpdateField
|
|
21
|
-
} from "./chunk-
|
|
22
|
-
import {
|
|
23
|
-
executeQuery,
|
|
24
|
-
getPool
|
|
25
|
-
} from "./chunk-22GJTNKR.js";
|
|
25
|
+
} from "./chunk-237SVWEU.js";
|
|
26
26
|
import {
|
|
27
27
|
downloadFiles
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-DKFDGYXS.js";
|
|
29
29
|
import {
|
|
30
30
|
upload_files
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-XMWRNOBE.js";
|
|
32
32
|
import {
|
|
33
33
|
upload_file
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-KYX4HMIY.js";
|
|
35
35
|
import {
|
|
36
36
|
handleError
|
|
37
37
|
} from "./chunk-A7GR4LD2.js";
|
|
@@ -42,13 +42,13 @@ import {
|
|
|
42
42
|
} from "./chunk-O5ILFRFV.js";
|
|
43
43
|
import {
|
|
44
44
|
deleteFile
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-GMQU3OAU.js";
|
|
46
46
|
import {
|
|
47
47
|
deleteFiles
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-XPJKMJBD.js";
|
|
49
49
|
import {
|
|
50
50
|
downloadFile
|
|
51
|
-
} from "./chunk-
|
|
51
|
+
} from "./chunk-5NVPS6PC.js";
|
|
52
52
|
import {
|
|
53
53
|
generateUniqueValue
|
|
54
54
|
} from "./chunk-IZEPCXYK.js";
|
|
@@ -59,19 +59,19 @@ import {
|
|
|
59
59
|
} from "./chunk-ZC33GE2U.js";
|
|
60
60
|
import {
|
|
61
61
|
s3Client
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-EKT74VDD.js";
|
|
63
63
|
import {
|
|
64
64
|
connectToMongo
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-AS7JRX2N.js";
|
|
66
66
|
import {
|
|
67
67
|
MAX_BATCH_FILES
|
|
68
68
|
} from "./chunk-4L35JPDH.js";
|
|
69
69
|
import {
|
|
70
70
|
runMySqlScript
|
|
71
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-W2KVW35Y.js";
|
|
72
72
|
import {
|
|
73
73
|
runPgSqlScript
|
|
74
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-IT6LYD4L.js";
|
|
75
75
|
import {
|
|
76
76
|
buildPath,
|
|
77
77
|
fileExistsAsync,
|
|
@@ -237,11 +237,11 @@ var getServer2 = /* @__PURE__ */ __name(() => {
|
|
|
237
237
|
}, "getServer");
|
|
238
238
|
|
|
239
239
|
// src/engine/server/server.ts
|
|
240
|
-
var configPathTs = path.join(process.cwd(), "src
|
|
241
|
-
var configPathJs = path.join(process.cwd(), "src
|
|
240
|
+
var configPathTs = path.join(process.cwd(), "src", "config", "express.config.ts");
|
|
241
|
+
var configPathJs = path.join(process.cwd(), "src", "config", "express.config.js");
|
|
242
242
|
var EXPRESS_APP = express();
|
|
243
|
-
var apiPathTs = path.join(process.cwd(), "src
|
|
244
|
-
var apiPathJs = path.join(process.cwd(), "src
|
|
243
|
+
var apiPathTs = path.join(process.cwd(), "src", "apis", "apis.ts");
|
|
244
|
+
var apiPathJs = path.join(process.cwd(), "src", "apis", "apis.js");
|
|
245
245
|
var PORT = ENV.SERVER_PORT;
|
|
246
246
|
var SQL_URL = ENV.SQL_DB_URL;
|
|
247
247
|
var HTTP_SERVER = http.createServer(EXPRESS_APP);
|
|
@@ -333,4 +333,4 @@ export {
|
|
|
333
333
|
HTTP_SERVER,
|
|
334
334
|
startServer
|
|
335
335
|
};
|
|
336
|
-
//# sourceMappingURL=chunk-
|
|
336
|
+
//# sourceMappingURL=chunk-DWODHIWI.js.map
|
|
@@ -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;AAC1C,YAAY,UAAU;AACtB,OAAO,UAAU;AACjB,SAAS,qBAAqB;;;ACMvB,IAAM,YAAa,6BAAO;AAAC,SAAO;AAAW,GAA1B;;;ACuInB,IAAMA,cAAa,8BAAO,cAA2C;AACxE,SAAO,MAAM,WAAG,SAAS;AAC7B,GAF0B;AA0HnB,IAAMC,eAAc,8BAAO,eAA+C;AAC7E,SAAO,MAAM,YAAI,UAAU;AAC/B,GAF2B;AAkFpB,IAAMC,gBAAe,8BAAO,EAAC,KAAK,WAAU,MAAmD;AAClG,SAAO,MAAM,aAAK;AAAA,IACd;AAAA,IACA,GAAI,cAAc,EAAC,WAAsB;AAAA,EAC7C,CAAC;AACL,GAL4B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AAC;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"]}
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
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
|
|
10
|
-
var s3ConfigFileJs = path.join(process.cwd(), "src
|
|
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-
|
|
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":[]}
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-ZC33GE2U.js";
|
|
4
4
|
import {
|
|
5
5
|
s3Client
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-EKT74VDD.js";
|
|
7
7
|
import {
|
|
8
8
|
url_or_path
|
|
9
9
|
} from "./chunk-QW2GGDEG.js";
|
|
@@ -57,4 +57,4 @@ var deleteFile = /* @__PURE__ */ __name(async (item_file) => {
|
|
|
57
57
|
export {
|
|
58
58
|
deleteFile
|
|
59
59
|
};
|
|
60
|
-
//# sourceMappingURL=chunk-
|
|
60
|
+
//# sourceMappingURL=chunk-GMQU3OAU.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMongoServer
|
|
3
|
-
} from "./chunk-
|
|
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-
|
|
34
|
+
//# sourceMappingURL=chunk-GWPLCPRW.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getPgSqlPool
|
|
3
|
-
} from "./chunk-
|
|
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-
|
|
135
|
+
//# sourceMappingURL=chunk-H3RM55WC.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMySqlPool
|
|
3
|
-
} from "./chunk-
|
|
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-
|
|
148
|
+
//# sourceMappingURL=chunk-IM22RSF7.js.map
|
|
@@ -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
|
|
25
|
-
const mySqlConfigFileJs = path.join(process.cwd(), "src
|
|
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-
|
|
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;AACnD,MAAI,CAAC,MAAM;AAEP,QAAI;AAEJ,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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":[]}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-ZC33GE2U.js";
|
|
7
7
|
import {
|
|
8
8
|
s3Client
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EKT74VDD.js";
|
|
10
10
|
import {
|
|
11
11
|
buildPath,
|
|
12
12
|
getFileContentType,
|
|
@@ -69,4 +69,4 @@ var upload_file = /* @__PURE__ */ __name(async ({ file, path }) => {
|
|
|
69
69
|
export {
|
|
70
70
|
upload_file
|
|
71
71
|
};
|
|
72
|
-
//# sourceMappingURL=chunk-
|
|
72
|
+
//# sourceMappingURL=chunk-KYX4HMIY.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMongoServer
|
|
3
|
-
} from "./chunk-
|
|
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-
|
|
33
|
+
//# sourceMappingURL=chunk-T4PLUOW3.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMongoServer
|
|
3
|
-
} from "./chunk-
|
|
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-
|
|
32
|
+
//# sourceMappingURL=chunk-VFJV227G.js.map
|
|
@@ -20,8 +20,8 @@ async function getMySqlPool() {
|
|
|
20
20
|
if (!pool) {
|
|
21
21
|
let options;
|
|
22
22
|
try {
|
|
23
|
-
const mySqlConfigFileTs = path.join(process.cwd(), "src
|
|
24
|
-
const mySqlConfigFileJs = path.join(process.cwd(), "src
|
|
23
|
+
const mySqlConfigFileTs = path.join(process.cwd(), "src", "config", "mySql.config.ts");
|
|
24
|
+
const mySqlConfigFileJs = path.join(process.cwd(), "src", "config", "mySql.config.js");
|
|
25
25
|
const { MYSQL_POOL_OPTIONS } = await import(pathToFileURL(await fileExistsAsync(mySqlConfigFileJs) ? mySqlConfigFileJs : mySqlConfigFileTs).href);
|
|
26
26
|
options = MYSQL_POOL_OPTIONS || {};
|
|
27
27
|
if (!options.uri) options.uri = ENV.SQL_DB_URL;
|
|
@@ -92,4 +92,4 @@ export {
|
|
|
92
92
|
runMySqlScript,
|
|
93
93
|
closePool
|
|
94
94
|
};
|
|
95
|
-
//# sourceMappingURL=chunk-
|
|
95
|
+
//# sourceMappingURL=chunk-W2KVW35Y.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/engine/sql/mySql.ts"],"sourcesContent":["// mySql.ts\nimport mysql from 'mysql2/promise';\nimport dotenv from 'dotenv';\nimport fs from 'fs/promises';\nimport path from \"node:path\"\nimport {pathToFileURL} from \"node:url\";\nimport {ENV} from \"../../utility/libs/env.js\";\nimport {fileExistsAsync} from \"../../utility/utilis/general/file-operations.js\";\n\n\ndotenv.config();\nlet pool: mysql.Pool | null = null;\n\n\n\n\n\nexport async function getMySqlPool(): Promise<mysql.Pool> {\n if (!pool) {\n\n let options: mysql.PoolOptions;\n\n try {\n const mySqlConfigFileTs = path.join(process.cwd(), \"src\", \"config\", \"mySql.config.ts\");\n const mySqlConfigFileJs = path.join(process.cwd(), \"src\", \"config\", \"mySql.config.js\");\n const {MYSQL_POOL_OPTIONS} = await import(pathToFileURL(await fileExistsAsync(mySqlConfigFileJs) ? mySqlConfigFileJs : mySqlConfigFileTs).href);\n options = MYSQL_POOL_OPTIONS || {};\n if (!options.uri) options.uri = ENV.SQL_DB_URL\n }\n catch (error) {\n options = {};\n }\n\n pool = mysql.createPool(options);\n\n // Test connection on startup\n pool.getConnection()\n .then(conn => {\n console.log('✅ MySQL Database connected successfully');\n conn.release();\n })\n .catch(err => {\n console.error('❌ Failed to connect to MySQL:', err.message);\n process.exit(1);\n });\n\n // Connection event\n pool.on('connection', () => {\n console.log('🔌 New MySQL connection established');\n });\n\n // Acquire event (when connection is acquired from pool)\n pool.on('acquire', () => {\n console.log('📥 MySQL connection acquired');\n });\n\n // Enqueue event (when connection is queued)\n pool.on('enqueue', () => {\n console.log('⏳ MySQL connection queued');\n });\n\n // Release event (when connection is released back to pool)\n pool.on('release', () => {\n console.log('📤 MySQL connection released');\n });\n }\n\n return pool;\n}\n\n\n\n\nexport const runMySqlScript = 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\n const mySqlPool = await getMySqlPool();\n\n const connection = await mySqlPool.getConnection();\n\n try {\n for (const query of queries) {\n await mySqlPool.query(query);\n }\n console.log(\"✅ Database schema created successfully\");\n } finally {\n connection.release();\n }\n } catch (err) {\n console.error('❌ Failed to execute SQL script:', err);\n throw err;\n }\n};\n\n\n\n\n\n\n// Graceful shutdown\nexport const closePool = async () => {\n if (pool) {\n console.log('Closing database pool...');\n await pool.end();\n console.log('Database pool closed');\n }\n};\n\n\n\n\n// Handle process termination\nprocess.on('SIGINT', async () => {\n await closePool();\n process.exit(0);\n});\n\n\n\n\nprocess.on('SIGTERM', async () => {\n await closePool();\n process.exit(0);\n});\n"],"mappings":";;;;;;;;;;;AACA,OAAO,WAAW;AAClB,OAAO,YAAY;AACnB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAQ,qBAAoB;AAK5B,OAAO,OAAO;AACd,IAAI,OAA0B;AAM9B,eAAsB,eAAoC;AACtD,MAAI,CAAC,MAAM;AAEP,QAAI;AAEJ,QAAI;AACA,YAAM,oBAAoB,KAAK,KAAK,QAAQ,IAAI,GAAG,OAAO,UAAU,iBAAiB;AACrF,YAAM,oBAAoB,KAAK,KAAK,QAAQ,IAAI,GAAG,OAAO,UAAU,iBAAiB;AACrF,YAAM,EAAC,mBAAkB,IAAI,MAAM,OAAO,cAAc,MAAM,gBAAgB,iBAAiB,IAAI,oBAAoB,iBAAiB,EAAE;AAC1I,gBAAU,sBAAsB,CAAC;AACjC,UAAI,CAAC,QAAQ,IAAK,SAAQ,MAAM,IAAI;AAAA,IACxC,SACO,OAAO;AACV,gBAAU,CAAC;AAAA,IACf;AAEA,WAAO,MAAM,WAAW,OAAO;AAG/B,SAAK,cAAc,EACd,KAAK,UAAQ;AACV,cAAQ,IAAI,8CAAyC;AACrD,WAAK,QAAQ;AAAA,IACjB,CAAC,EACA,MAAM,SAAO;AACV,cAAQ,MAAM,sCAAiC,IAAI,OAAO;AAC1D,cAAQ,KAAK,CAAC;AAAA,IAClB,CAAC;AAGL,SAAK,GAAG,cAAc,MAAM;AACxB,cAAQ,IAAI,4CAAqC;AAAA,IACrD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