backfarm 1.0.2 → 1.0.4
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-MEQAHLW6.js → chunk-D7A4TEXY.js} +2 -2
- package/dist/{chunk-PRKZ33FU.js → chunk-ICFMWIIJ.js} +10 -18
- package/dist/chunk-ICFMWIIJ.js.map +1 -0
- package/dist/{chunk-W2745SOE.js → chunk-NIOLLLJJ.js} +11 -5
- package/dist/chunk-NIOLLLJJ.js.map +1 -0
- package/dist/{chunk-HZ4GLSOO.js → chunk-QVTKG7FD.js} +11 -7
- package/dist/chunk-QVTKG7FD.js.map +1 -0
- package/dist/{chunk-BMPUYKJJ.js → chunk-TP3K7DMH.js} +2 -2
- package/dist/{chunk-NMNAPTVV.js → chunk-VFF4YFA3.js} +7 -3
- package/dist/chunk-VFF4YFA3.js.map +1 -0
- package/dist/{chunk-FMCW72HO.js → chunk-W3W3X2OE.js} +12 -1
- package/dist/chunk-W3W3X2OE.js.map +1 -0
- package/dist/{chunk-EB35KLDE.js → chunk-XBJ3SJ26.js} +9 -3
- package/dist/chunk-XBJ3SJ26.js.map +1 -0
- package/dist/chunk-YTBSGKGF.js +19 -0
- package/dist/chunk-YTBSGKGF.js.map +1 -0
- package/dist/{chunk-TCG3UB2T.js → chunk-YWFCWT6R.js} +1 -1
- package/dist/chunk-YWFCWT6R.js.map +1 -0
- package/dist/{chunk-UPVDNR2J.js → chunk-ZMDJ45KH.js} +5 -5
- package/dist/engine/cloudBucket/r2Storage.js +3 -1
- package/dist/engine/mondoDb/mongoDB.js +2 -1
- package/dist/engine/script/run-all.js +1 -1
- package/dist/engine/server/app.js +3 -1
- package/dist/engine/server/server.js +7 -6
- package/dist/engine/sql/mySql.js +2 -1
- package/dist/engine/sql/pgSql.js +2 -1
- package/dist/utility/script/run-all.js +1 -1
- package/dist/utility/utilis/cloud_storage/deleteFile.js +4 -4
- package/dist/utility/utilis/cloud_storage/deleteFiles.js +4 -4
- package/dist/utility/utilis/cloud_storage/downloadFile.js +4 -4
- package/dist/utility/utilis/cloud_storage/downloadFiles.js +4 -4
- package/dist/utility/utilis/cloud_storage/s3Client.js +3 -1
- package/dist/utility/utilis/cloud_storage/s3Client.js.map +1 -1
- package/dist/utility/utilis/cloud_storage/uploadFile.js +3 -3
- package/dist/utility/utilis/cloud_storage/uploadFiles.js +3 -3
- package/dist/utility/utilis/general/file-operations.d.ts +2 -1
- package/dist/utility/utilis/general/file-operations.js +3 -1
- package/dist/utility/utilis/mongoDb/buldWrite.js +2 -1
- package/dist/utility/utilis/mongoDb/buldWrite.js.map +1 -1
- package/dist/utility/utilis/mongoDb/deleteDocument.js +2 -1
- package/dist/utility/utilis/mongoDb/deleteDocument.js.map +1 -1
- package/dist/utility/utilis/mongoDb/insertField.js +2 -1
- package/dist/utility/utilis/mongoDb/insertField.js.map +1 -1
- package/dist/utility/utilis/mongoDb/insertFields.js +2 -1
- package/dist/utility/utilis/mongoDb/insertFields.js.map +1 -1
- package/dist/utility/utilis/mongoDb/updateFiled.js +2 -1
- package/dist/utility/utilis/mongoDb/updateFiled.js.map +1 -1
- package/dist/utility/utilis/postgres/executeQuery.js +5 -4
- package/dist/utility/utilis/postgres/executeQuery.js.map +1 -1
- package/dist/utility/utilis/postgres/subSqlfiles/executeMySqlQuery.js +3 -2
- package/dist/utility/utilis/postgres/subSqlfiles/executePgQuery.js +3 -2
- package/dist/utility/utilis/server/app.js +3 -1
- package/dist/utility/utilis/server/app.js.map +1 -1
- package/dist/utility/utilis/server/server.js +7 -6
- package/dist/utility/utilis/server/server.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-3AP6JARL.js +0 -12
- package/dist/chunk-3AP6JARL.js.map +0 -1
- package/dist/chunk-EB35KLDE.js.map +0 -1
- package/dist/chunk-FMCW72HO.js.map +0 -1
- package/dist/chunk-HZ4GLSOO.js.map +0 -1
- package/dist/chunk-NMNAPTVV.js.map +0 -1
- package/dist/chunk-PRKZ33FU.js.map +0 -1
- package/dist/chunk-TCG3UB2T.js.map +0 -1
- package/dist/chunk-W2745SOE.js.map +0 -1
- /package/dist/{chunk-MEQAHLW6.js.map → chunk-D7A4TEXY.js.map} +0 -0
- /package/dist/{chunk-BMPUYKJJ.js.map → chunk-TP3K7DMH.js.map} +0 -0
- /package/dist/{chunk-UPVDNR2J.js.map → chunk-ZMDJ45KH.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getPgSqlPool
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VFF4YFA3.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-D7A4TEXY.js.map
|
|
@@ -1,33 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
handleError
|
|
3
|
-
} from "./chunk-P5XJG7OG.js";
|
|
4
1
|
import {
|
|
5
2
|
isMySQL,
|
|
6
3
|
isPostgreSQL
|
|
7
4
|
} from "./chunk-MNSQSU7T.js";
|
|
5
|
+
import {
|
|
6
|
+
handleError
|
|
7
|
+
} from "./chunk-P5XJG7OG.js";
|
|
8
|
+
import {
|
|
9
|
+
app_default
|
|
10
|
+
} from "./chunk-NIOLLLJJ.js";
|
|
8
11
|
import {
|
|
9
12
|
runMySqlScript
|
|
10
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-QVTKG7FD.js";
|
|
11
14
|
import {
|
|
12
15
|
runPgSqlScript
|
|
13
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-VFF4YFA3.js";
|
|
14
17
|
import {
|
|
15
18
|
connectToMongo
|
|
16
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-XBJ3SJ26.js";
|
|
17
20
|
import {
|
|
18
21
|
ENV
|
|
19
22
|
} from "./chunk-EWQYVPOL.js";
|
|
20
|
-
import {
|
|
21
|
-
app_default
|
|
22
|
-
} from "./chunk-W2745SOE.js";
|
|
23
23
|
import {
|
|
24
24
|
__name
|
|
25
25
|
} from "./chunk-7QVYU63E.js";
|
|
26
26
|
|
|
27
27
|
// src/engine/server/server.ts
|
|
28
28
|
import * as http from "http";
|
|
29
|
-
import path from "path";
|
|
30
|
-
import { pathToFileURL } from "url";
|
|
31
29
|
var PORT = ENV.SERVER_PORT;
|
|
32
30
|
var SQL_URL = ENV.SQL_DB_URL;
|
|
33
31
|
var HTTP_SERVER = http.createServer(app_default);
|
|
@@ -40,12 +38,6 @@ var startServer = /* @__PURE__ */ __name(async () => {
|
|
|
40
38
|
await runMySqlScript();
|
|
41
39
|
}
|
|
42
40
|
await connectToMongo();
|
|
43
|
-
try {
|
|
44
|
-
const functionPath = path.join(process.cwd(), "src/app/services/test.services.js");
|
|
45
|
-
const { testFunctions } = await import(pathToFileURL(functionPath).href);
|
|
46
|
-
testFunctions();
|
|
47
|
-
} catch {
|
|
48
|
-
}
|
|
49
41
|
HTTP_SERVER.listen(PORT, () => {
|
|
50
42
|
console.log(`Server running on port ${PORT}`);
|
|
51
43
|
});
|
|
@@ -58,4 +50,4 @@ export {
|
|
|
58
50
|
HTTP_SERVER,
|
|
59
51
|
startServer
|
|
60
52
|
};
|
|
61
|
-
//# sourceMappingURL=chunk-
|
|
53
|
+
//# sourceMappingURL=chunk-ICFMWIIJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/engine/server/server.ts"],"sourcesContent":["import app from \"./app.js\";\r\nimport {connectToMongo} from \"../mondoDb/mongoDB.js\";\r\nimport {ENV} from \"../../utility/libs/env.js\";\r\nimport {runPgSqlScript} from \"../sql/pgSql.js\";\r\nimport {handleError} from \"../../utility/utilis/general/error_handler.js\";\r\nimport {isMySQL, isPostgreSQL} from \"../../utility/utilis/general/sqlDb.js.js\";\r\nimport {runMySqlScript} from \"../sql/mySql.js\";\r\nimport * as http from \"node:http\";\r\n\r\n\r\n\r\n\r\n\r\nconst PORT = ENV.SERVER_PORT;\r\nconst SQL_URL = ENV.SQL_DB_URL;\r\nexport const HTTP_SERVER = http.createServer(app);\r\n\r\n\r\n\r\n\r\n\r\nexport const startServer = async () => {\r\n try {\r\n\r\n if (isPostgreSQL(SQL_URL)) {\r\n await runPgSqlScript()\r\n }\r\n if (isMySQL(SQL_URL)) {\r\n await runMySqlScript()\r\n }\r\n\r\n await connectToMongo();\r\n\r\n\r\n HTTP_SERVER.listen(PORT, () => {\r\n console.log(`Server running on port ${PORT}`);\r\n });\r\n }\r\n catch(err) {\r\n handleError(err)\r\n }\r\n\r\n};\r\n\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,YAAY,UAAU;AAMtB,IAAM,OAAO,IAAI;AACjB,IAAM,UAAU,IAAI;AACb,IAAM,cAAmB,kBAAa,WAAG;AAMzC,IAAM,cAAc,mCAAY;AACnC,MAAI;AAEA,QAAI,aAAa,OAAO,GAAG;AACvB,YAAM,eAAe;AAAA,IACzB;AACA,QAAI,QAAQ,OAAO,GAAG;AAClB,YAAM,eAAe;AAAA,IACzB;AAEA,UAAM,eAAe;AAGrB,gBAAY,OAAO,MAAM,MAAM;AAC3B,cAAQ,IAAI,0BAA0B,IAAI,EAAE;AAAA,IAChD,CAAC;AAAA,EACL,SACM,KAAK;AACP,gBAAY,GAAG;AAAA,EACnB;AAEJ,GArB2B;","names":[]}
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fileExistsAsync
|
|
3
|
+
} from "./chunk-W3W3X2OE.js";
|
|
4
|
+
|
|
1
5
|
// src/engine/server/app.ts
|
|
2
6
|
import express from "express";
|
|
3
7
|
import path from "path";
|
|
4
8
|
import { pathToFileURL } from "url";
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var { APIS } = await import(pathToFileURL(
|
|
8
|
-
var
|
|
9
|
+
var apiPathTs = path.join(process.cwd(), "src/apis/apis.ts");
|
|
10
|
+
var apiPathJs = path.join(process.cwd(), "src/apis/apis.js");
|
|
11
|
+
var { APIS } = await import(pathToFileURL(await fileExistsAsync(apiPathJs) ? apiPathJs : apiPathTs).href);
|
|
12
|
+
var configPathTs = path.join(process.cwd(), "src/config/express.config.ts");
|
|
13
|
+
var configPathJs = path.join(process.cwd(), "src/config/express.config.js");
|
|
14
|
+
var { express_configurations } = await import(pathToFileURL(await fileExistsAsync(configPathJs) ? configPathJs : configPathTs).href);
|
|
9
15
|
var app = express();
|
|
10
16
|
express_configurations(app);
|
|
11
17
|
var app_default = app;
|
|
@@ -35,4 +41,4 @@ APIS.forEach((api) => {
|
|
|
35
41
|
export {
|
|
36
42
|
app_default
|
|
37
43
|
};
|
|
38
|
-
//# sourceMappingURL=chunk-
|
|
44
|
+
//# sourceMappingURL=chunk-NIOLLLJJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/engine/server/app.ts"],"sourcesContent":["import express, {type Application } from 'express';\r\nimport type {ApisInterface} from \"../../utility/libs/types.js\";\r\nimport path from \"node:path\";\r\nimport { pathToFileURL } from \"node:url\";\r\nimport {fileExistsAsync} from \"../../utility/utilis/general/file-operations.js\";\r\n\r\nconst apiPathTs = path.join(process.cwd(), \"src/apis/apis.ts\");\r\nconst apiPathJs = path.join(process.cwd(), \"src/apis/apis.js\");\r\n\r\nconst { APIS } = await import(pathToFileURL(await fileExistsAsync(apiPathJs) ? apiPathJs : apiPathTs).href);\r\n\r\nconst configPathTs = path.join(process.cwd(), \"src/config/express.config.ts\");\r\nconst configPathJs = path.join(process.cwd(), \"src/config/express.config.js\");\r\nconst {express_configurations} = await import(pathToFileURL(await fileExistsAsync(configPathJs) ? configPathJs : configPathTs).href);\r\n\r\n\r\nconst app: Application = express();\r\nexpress_configurations(app)\r\n\r\n\r\nexport default app;\r\n\r\n\r\n\r\n\r\n\r\n// ======================== APIS ======================== //\r\n\r\n\r\n\r\n\r\n\r\n\r\nAPIS.forEach((api: ApisInterface) => {\r\n if ('get' in api) {\r\n const middleware = api.get.middleware\r\n ? (Array.isArray(api.get.middleware) ? api.get.middleware : [api.get.middleware])\r\n : [];\r\n app.get(api.get.endpoint, ...middleware, api.get.callable);\r\n }\r\n\r\n if ('post' in api) {\r\n const middleware = api.post.middleware\r\n ? (Array.isArray(api.post.middleware) ? api.post.middleware : [api.post.middleware])\r\n : [];\r\n app.post(api.post.endpoint, ...middleware, api.post.callable);\r\n }\r\n\r\n if ('put' in api) {\r\n const middleware = api.put.middleware\r\n ? (Array.isArray(api.put.middleware) ? api.put.middleware : [api.put.middleware])\r\n : [];\r\n app.put(api.put.endpoint, ...middleware, api.put.callable);\r\n }\r\n\r\n if ('delete' in api) {\r\n const middleware = api.delete.middleware\r\n ? (Array.isArray(api.delete.middleware) ? api.delete.middleware : [api.delete.middleware])\r\n : [];\r\n app.delete(api.delete.endpoint, ...middleware, api.delete.callable);\r\n }\r\n\r\n if ('patch' in api) {\r\n const middleware = api.patch.middleware\r\n ? (Array.isArray(api.patch.middleware) ? api.patch.middleware : [api.patch.middleware])\r\n : [];\r\n app.patch(api.patch.endpoint, ...middleware, api.patch.callable);\r\n }\r\n})\r\n\r\n\r\n\r\n\r\n"],"mappings":";;;;;AAAA,OAAO,aAAkC;AAEzC,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAG9B,IAAM,YAAY,KAAK,KAAK,QAAQ,IAAI,GAAG,kBAAkB;AAC7D,IAAM,YAAY,KAAK,KAAK,QAAQ,IAAI,GAAG,kBAAkB;AAE7D,IAAM,EAAE,KAAK,IAAI,MAAM,OAAO,cAAc,MAAM,gBAAgB,SAAS,IAAI,YAAY,SAAS,EAAE;AAEtG,IAAM,eAAe,KAAK,KAAK,QAAQ,IAAI,GAAG,8BAA8B;AAC5E,IAAM,eAAe,KAAK,KAAK,QAAQ,IAAI,GAAG,8BAA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AAa,CAAC,IAAI,MAAM,UAAU,IACnF,CAAC;AACP,QAAI,MAAM,IAAI,MAAM,UAAU,GAAG,YAAY,IAAI,MAAM,QAAQ;AAAA,EACnE;AACJ,CAAC;","names":[]}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fileExistsAsync
|
|
3
|
+
} from "./chunk-W3W3X2OE.js";
|
|
1
4
|
import {
|
|
2
5
|
ENV
|
|
3
6
|
} from "./chunk-EWQYVPOL.js";
|
|
@@ -17,10 +20,11 @@ async function getMySqlPool() {
|
|
|
17
20
|
if (!pool) {
|
|
18
21
|
let options;
|
|
19
22
|
try {
|
|
20
|
-
const
|
|
21
|
-
const
|
|
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
|
+
const { MYSQL_POOL_OPTIONS } = await import(pathToFileURL(await fileExistsAsync(mySqlConfigFileJs) ? mySqlConfigFileJs : mySqlConfigFileTs).href);
|
|
22
26
|
options = MYSQL_POOL_OPTIONS || {};
|
|
23
|
-
options.uri = ENV.SQL_DB_URL;
|
|
27
|
+
if (!options.uri) options.uri = ENV.SQL_DB_URL;
|
|
24
28
|
} catch (error) {
|
|
25
29
|
options = {};
|
|
26
30
|
}
|
|
@@ -32,16 +36,16 @@ async function getMySqlPool() {
|
|
|
32
36
|
console.error("\u274C Failed to connect to MySQL:", err.message);
|
|
33
37
|
process.exit(1);
|
|
34
38
|
});
|
|
35
|
-
pool.on("connection", (
|
|
39
|
+
pool.on("connection", () => {
|
|
36
40
|
console.log("\u{1F50C} New MySQL connection established");
|
|
37
41
|
});
|
|
38
|
-
pool.on("acquire", (
|
|
42
|
+
pool.on("acquire", () => {
|
|
39
43
|
console.log("\u{1F4E5} MySQL connection acquired");
|
|
40
44
|
});
|
|
41
45
|
pool.on("enqueue", () => {
|
|
42
46
|
console.log("\u23F3 MySQL connection queued");
|
|
43
47
|
});
|
|
44
|
-
pool.on("release", (
|
|
48
|
+
pool.on("release", () => {
|
|
45
49
|
console.log("\u{1F4E4} MySQL connection released");
|
|
46
50
|
});
|
|
47
51
|
}
|
|
@@ -88,4 +92,4 @@ export {
|
|
|
88
92
|
runMySqlScript,
|
|
89
93
|
closePool
|
|
90
94
|
};
|
|
91
|
-
//# sourceMappingURL=chunk-
|
|
95
|
+
//# sourceMappingURL=chunk-QVTKG7FD.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/engine/sql/mySql.ts"],"sourcesContent":["// mySql.ts\r\nimport mysql from 'mysql2/promise';\r\nimport dotenv from 'dotenv';\r\nimport fs from 'fs/promises';\r\nimport path from \"node:path\"\r\nimport {pathToFileURL} from \"node:url\";\r\nimport {ENV} from \"../../utility/libs/env.js\";\r\nimport {fileExistsAsync} from \"../../utility/utilis/general/file-operations.js\";\r\n\r\n\r\ndotenv.config();\r\nlet pool: mysql.Pool | null = null;\r\n\r\n\r\n\r\n\r\n\r\nexport async function getMySqlPool(): Promise<mysql.Pool> {\r\n if (!pool) {\r\n\r\n let options: mysql.PoolOptions;\r\n\r\n try {\r\n const mySqlConfigFileTs = path.join(process.cwd(), \"src/config/mySql.config.ts\");\r\n const mySqlConfigFileJs = path.join(process.cwd(), \"src/config/mySql.config.js\");\r\n const {MYSQL_POOL_OPTIONS} = await import(pathToFileURL(await fileExistsAsync(mySqlConfigFileJs) ? mySqlConfigFileJs : mySqlConfigFileTs).href);\r\n options = MYSQL_POOL_OPTIONS || {};\r\n if (!options.uri) options.uri = ENV.SQL_DB_URL\r\n }\r\n catch (error) {\r\n options = {};\r\n }\r\n\r\n pool = mysql.createPool(options);\r\n\r\n // Test connection on startup\r\n pool.getConnection()\r\n .then(conn => {\r\n console.log('✅ MySQL Database connected successfully');\r\n conn.release();\r\n })\r\n .catch(err => {\r\n console.error('❌ Failed to connect to MySQL:', err.message);\r\n process.exit(1);\r\n });\r\n\r\n // Connection event\r\n pool.on('connection', () => {\r\n console.log('🔌 New MySQL connection established');\r\n });\r\n\r\n // Acquire event (when connection is acquired from pool)\r\n pool.on('acquire', () => {\r\n console.log('📥 MySQL connection acquired');\r\n });\r\n\r\n // Enqueue event (when connection is queued)\r\n pool.on('enqueue', () => {\r\n console.log('⏳ MySQL connection queued');\r\n });\r\n\r\n // Release event (when connection is released back to pool)\r\n pool.on('release', () => {\r\n console.log('📤 MySQL connection released');\r\n });\r\n }\r\n\r\n return pool;\r\n}\r\n\r\n\r\n\r\n\r\nexport const runMySqlScript = async () => {\r\n try {\r\n const fileQuery = await fs.readFile('db.sql', 'utf8');\r\n\r\n // Split queries for multiple statements\r\n const queries = fileQuery\r\n .split(';')\r\n .map(q => q.trim())\r\n .filter(q => q.length > 0);\r\n\r\n\r\n const mySqlPool = await getMySqlPool();\r\n\r\n const connection = await mySqlPool.getConnection();\r\n\r\n try {\r\n for (const query of queries) {\r\n await mySqlPool.query(query);\r\n }\r\n console.log(\"✅ Database schema created successfully\");\r\n } finally {\r\n connection.release();\r\n }\r\n } catch (err) {\r\n console.error('❌ Failed to execute SQL script:', err);\r\n throw err;\r\n }\r\n};\r\n\r\n\r\n\r\n\r\n\r\n\r\n// Graceful shutdown\r\nexport const closePool = async () => {\r\n if (pool) {\r\n console.log('Closing database pool...');\r\n await pool.end();\r\n console.log('Database pool closed');\r\n }\r\n};\r\n\r\n\r\n\r\n\r\n// Handle process termination\r\nprocess.on('SIGINT', async () => {\r\n await closePool();\r\n process.exit(0);\r\n});\r\n\r\n\r\n\r\n\r\nprocess.on('SIGTERM', async () => {\r\n await closePool();\r\n process.exit(0);\r\n});\r\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,QAA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SAAS,SAAS;AACzB,cAAM,UAAU,MAAM,KAAK;AAAA,MAC/B;AACA,cAAQ,IAAI,6CAAwC;AAAA,IACxD,UAAE;AACE,iBAAW,QAAQ;AAAA,IACvB;AAAA,EACJ,SAAS,KAAK;AACV,YAAQ,MAAM,wCAAmC,GAAG;AACpD,UAAM;AAAA,EACV;AACJ,GA3B8B;AAmCvB,IAAM,YAAY,mCAAY;AACjC,MAAI,MAAM;AACN,YAAQ,IAAI,0BAA0B;AACtC,UAAM,KAAK,IAAI;AACf,YAAQ,IAAI,sBAAsB;AAAA,EACtC;AACJ,GANyB;AAYzB,QAAQ,GAAG,UAAU,YAAY;AAC7B,QAAM,UAAU;AAChB,UAAQ,KAAK,CAAC;AAClB,CAAC;AAKD,QAAQ,GAAG,WAAW,YAAY;AAC9B,QAAM,UAAU;AAChB,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getMySqlPool
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QVTKG7FD.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-TP3K7DMH.js.map
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fileExistsAsync
|
|
3
|
+
} from "./chunk-W3W3X2OE.js";
|
|
1
4
|
import {
|
|
2
5
|
ENV
|
|
3
6
|
} from "./chunk-EWQYVPOL.js";
|
|
@@ -18,8 +21,9 @@ async function getPgSqlPool() {
|
|
|
18
21
|
if (!pool) {
|
|
19
22
|
let options;
|
|
20
23
|
try {
|
|
21
|
-
const
|
|
22
|
-
const
|
|
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
|
+
const { PGSQL_POOL_OPTIONS } = await import(pathToFileURL(await fileExistsAsync(mySqlConfigFileJs) ? mySqlConfigFileJs : mySqlConfigFileTs).href);
|
|
23
27
|
options = PGSQL_POOL_OPTIONS || {};
|
|
24
28
|
options.connectionString = ENV.SQL_DB_URL;
|
|
25
29
|
} catch (error) {
|
|
@@ -88,4 +92,4 @@ export {
|
|
|
88
92
|
runPgSqlScript,
|
|
89
93
|
closePgPool
|
|
90
94
|
};
|
|
91
|
-
//# sourceMappingURL=chunk-
|
|
95
|
+
//# sourceMappingURL=chunk-VFF4YFA3.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/engine/sql/pgSql.ts"],"sourcesContent":["// pgSql.ts\r\nimport pg from 'pg';\r\nimport dotenv from 'dotenv';\r\nimport {ENV} from \"../../utility/libs/env.js\";\r\nimport fs from 'fs/promises';\r\nimport path from \"node:path\";\r\nimport {pathToFileURL} from \"node:url\";\r\nimport {fileExistsAsync} from \"../../utility/utilis/general/file-operations.js\";\r\n\r\ndotenv.config();\r\n\r\nconst { Pool } = pg;\r\n\r\nlet pool: pg.Pool | null = null;\r\n\r\nexport async function getPgSqlPool(): Promise<pg.Pool> {\r\n if (!pool) {\r\n\r\n let options: pg.PoolConfig;\r\n\r\n try {\r\n const mySqlConfigFileTs = path.join(process.cwd(), \"src/config/pgSql.config.ts\");\r\n const mySqlConfigFileJs = path.join(process.cwd(), \"src/config/pgSql.config.js\");\r\n const {PGSQL_POOL_OPTIONS} = await import(pathToFileURL(await fileExistsAsync(mySqlConfigFileJs) ? mySqlConfigFileJs : mySqlConfigFileTs).href);\r\n options = PGSQL_POOL_OPTIONS || {};\r\n options.connectionString = ENV.SQL_DB_URL\r\n }\r\n catch (error) {\r\n options = {};\r\n }\r\n\r\n pool = new Pool(options);\r\n\r\n // Test connection on startup\r\n pool.connect()\r\n .then(client => {\r\n console.log('✅ PostgreSQL Database connected successfully');\r\n client.release();\r\n })\r\n .catch(err => {\r\n console.error('❌ Failed to connect to PostgreSQL:', err.message);\r\n process.exit(1);\r\n });\r\n\r\n pool.on('connect', () => {\r\n console.log('🔌 New PostgreSQL connection established');\r\n });\r\n\r\n pool.on('error', (err: Error) => {\r\n console.error('❌ Unexpected PostgreSQL error:', err.message);\r\n });\r\n }\r\n\r\n return pool;\r\n}\r\n\r\nexport const runPgSqlScript = async () => {\r\n try {\r\n const fileQuery = await fs.readFile('db.sql', 'utf8');\r\n\r\n // Split queries for multiple statements\r\n const queries = fileQuery\r\n .split(';')\r\n .map(q => q.trim())\r\n .filter(q => q.length > 0);\r\n\r\n const client = await (await getPgSqlPool()).connect();\r\n\r\n try {\r\n // Run all queries in a transaction\r\n await client.query('BEGIN');\r\n\r\n for (const query of queries) {\r\n await client.query(query);\r\n }\r\n\r\n await client.query('COMMIT');\r\n console.log(\"✅ Database schema created successfully\");\r\n } catch (err) {\r\n await client.query('ROLLBACK');\r\n throw err;\r\n } finally {\r\n client.release();\r\n }\r\n } catch (err) {\r\n console.error('❌ Failed to execute SQL script:', err);\r\n throw err;\r\n }\r\n};\r\n\r\n// Graceful shutdown\r\nexport const closePgPool = async () => {\r\n if (pool) {\r\n console.log('🔄 Closing PostgreSQL pool...');\r\n await pool.end();\r\n pool = null;\r\n console.log('✅ PostgreSQL pool closed');\r\n }\r\n};\r\n\r\n// Handle process termination\r\nprocess.on('SIGINT', async () => {\r\n await closePgPool();\r\n process.exit(0);\r\n});\r\n\r\nprocess.on('SIGTERM', async () => {\r\n await closePgPool();\r\n process.exit(0);\r\n});\r\n"],"mappings":";;;;;;;;;;;AACA,OAAO,QAAQ;AACf,OAAO,YAAY;AAEnB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAQ,qBAAoB;AAG5B,OAAO,OAAO;A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,KAAK;AAAA,MAC5B;AAEA,YAAM,OAAO,MAAM,QAAQ;AAC3B,cAAQ,IAAI,6CAAwC;AAAA,IACxD,SAAS,KAAK;AACV,YAAM,OAAO,MAAM,UAAU;AAC7B,YAAM;AAAA,IACV,UAAE;AACE,aAAO,QAAQ;AAAA,IACnB;AAAA,EACJ,SAAS,KAAK;AACV,YAAQ,MAAM,wCAAmC,GAAG;AACpD,UAAM;AAAA,EACV;AACJ,GAhC8B;AAmCvB,IAAM,cAAc,mCAAY;AACnC,MAAI,MAAM;AACN,YAAQ,IAAI,sCAA+B;AAC3C,UAAM,KAAK,IAAI;AACf,WAAO;AACP,YAAQ,IAAI,+BAA0B;AAAA,EAC1C;AACJ,GAP2B;AAU3B,QAAQ,GAAG,UAAU,YAAY;AAC7B,QAAM,YAAY;AAClB,UAAQ,KAAK,CAAC;AAClB,CAAC;AAED,QAAQ,GAAG,WAAW,YAAY;AAC9B,QAAM,YAAY;AAClB,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":[]}
|
|
@@ -8,6 +8,16 @@ import {
|
|
|
8
8
|
// src/utility/utilis/general/file-operations.ts
|
|
9
9
|
import mime from "mime-types";
|
|
10
10
|
import { readFile } from "fs/promises";
|
|
11
|
+
import fs from "fs/promises";
|
|
12
|
+
async function fileExistsAsync(filePath) {
|
|
13
|
+
try {
|
|
14
|
+
await fs.access(filePath);
|
|
15
|
+
return true;
|
|
16
|
+
} catch {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
__name(fileExistsAsync, "fileExistsAsync");
|
|
11
21
|
function getFileExtension(input) {
|
|
12
22
|
if (Buffer.isBuffer(input)) {
|
|
13
23
|
return "";
|
|
@@ -100,6 +110,7 @@ async function toUint8Array(file) {
|
|
|
100
110
|
__name(toUint8Array, "toUint8Array");
|
|
101
111
|
|
|
102
112
|
export {
|
|
113
|
+
fileExistsAsync,
|
|
103
114
|
getFileExtension,
|
|
104
115
|
buildPath,
|
|
105
116
|
downloadedFilePath,
|
|
@@ -107,4 +118,4 @@ export {
|
|
|
107
118
|
url_or_path,
|
|
108
119
|
toUint8Array
|
|
109
120
|
};
|
|
110
|
-
//# sourceMappingURL=chunk-
|
|
121
|
+
//# sourceMappingURL=chunk-W3W3X2OE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utility/utilis/general/file-operations.ts"],"sourcesContent":["import type {PathOptions} from \"../../libs/interface.js\";\r\nimport mime from \"mime-types\";\r\nimport {ENV} from \"../../libs/env.js\";\r\nimport {readFile} from \"node:fs/promises\";\r\nimport fs from \"fs/promises\";\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nexport async function fileExistsAsync(filePath: string) {\r\n try {\r\n await fs.access(filePath);\r\n return true; // File exists and is accessible\r\n } catch {\r\n return false; // File does not exist\r\n }\r\n}\r\n\r\n\r\nasync function fileExistsSync(filePath: string) {\r\n try {\r\n fs.access(filePath);\r\n return true; // File exists and is accessible\r\n } catch {\r\n return false; // File does not exist\r\n }\r\n}\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Extracts the file extension from a supported file input.\r\n *\r\n * Supports Express Multer files, Web API `File` objects, raw `Buffer` values,\r\n * and file paths or URLs. For URLs and paths, query parameters and hash\r\n * fragments are ignored when determining the extension.\r\n *\r\n * @param input - The file, buffer, path, or URL from which to extract the extension.\r\n * @returns The file extension without the leading dot, converted to lowercase.\r\n * Returns an empty string if no extension can be determined.\r\n *\r\n * @example\r\n * const extension = getFileExtension('https://example.com/files/image.PNG');\r\n * // Returns: \"png\"\r\n *\r\n * @example\r\n * const extension = getFileExtension(req.file);\r\n * // Returns: \"pdf\"\r\n *\r\n * @example\r\n * const extension = getFileExtension('documents/report.pdf?download=true');\r\n * // Returns: \"pdf\"\r\n *\r\n * @example\r\n * const extension = getFileExtension(buffer);\r\n * // Returns: \"\"\r\n */\r\nexport function getFileExtension(input: Express.Multer.File | File | Buffer | string): string {\r\n // 1. If it's a raw Buffer, it has no file name/extension metadata\r\n if (Buffer.isBuffer(input)) {\r\n return '';\r\n }\r\n\r\n // 2. Extract the filename string based on the input type\r\n let filename = '';\r\n\r\n if (typeof input === 'string') {\r\n filename = input;\r\n }\r\n else if ('originalname' in input && input.originalname) {\r\n // Express.Multer.File\r\n filename = input.originalname;\r\n }\r\n else if ('name' in input && input.name) {\r\n // Web API File\r\n filename = input.name;\r\n }\r\n\r\n if (!filename) {\r\n return '';\r\n }\r\n\r\n // 3. Remove URL query parameters or hashes (if a URL/path string is passed)\r\n const cleanFilename = filename.split(/[?#]/)[0] as string;\r\n\r\n // 4. Extract the last segment after the final dot\r\n const match = cleanFilename.match(/\\.([^./\\\\]+)$/);\r\n\r\n return match?.[1]?.toLowerCase() ?? '';\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Builds a normalized file path from the provided path components.\r\n *\r\n * Combines the path prefix, path segments, path postfix, and file name,\r\n * while removing empty values and normalizing redundant slashes.\r\n *\r\n * If `fileName` is a Web API `File` object, its `name` property is used.\r\n *\r\n * @param options - The path components used to construct the final path.\r\n * @param options.path_prefix - An optional prefix to prepend to the path.\r\n * @param options.path - An array of path segments.\r\n * @param options.path_postfix - An optional postfix to append before the file name.\r\n * @param options.fileName - The file name or a Web API `File` object.\r\n * @returns A normalized path with components separated by a single slash.\r\n *\r\n * @example\r\n * const filePath = buildPath({\r\n * path_prefix: 'uploads',\r\n * path: ['documents', 'reports'],\r\n * fileName: 'report.pdf',\r\n * });\r\n * // Returns: \"uploads/documents/reports/report.pdf\"\r\n *\r\n * @example\r\n * const filePath = buildPath({\r\n * path: ['documents//', '/reports/'],\r\n * fileName: 'report.pdf',\r\n * });\r\n * // Returns: \"documents/reports/report.pdf\"\r\n */\r\nexport function buildPath({\r\n path_prefix = '',\r\n path = [],\r\n path_postfix = '',\r\n fileName,\r\n }: PathOptions): string {\r\n // Extract string name if fileName is a File object\r\n const resolvedFileName =\r\n fileName instanceof File ? fileName.name : fileName ?? '';\r\n\r\n // Combine all segments into a single array\r\n const allSegments = [\r\n path_prefix,\r\n ...path,\r\n path_postfix,\r\n resolvedFileName,\r\n ];\r\n\r\n return allSegments\r\n // Filter out null/undefined/empty string items\r\n .filter((segment): segment is string => Boolean(segment && segment.trim()))\r\n // Clean leading/trailing slashes from individual segments\r\n .map((segment) => segment.replace(/^\\/+|\\/+$/g, ''))\r\n // Remove any extra slashes inside a segment (e.g. \"folder//subfolder\")\r\n .map((segment) => segment.replace(/\\/+/g, '/'))\r\n // Filter again in case cleaning left an empty string\r\n .filter((segment) => segment.length > 0)\r\n // Join with a single slash\r\n .join('/');\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Builds the local file path for a downloaded file.\r\n *\r\n * Removes any occurrence of the configured in-app bucket from the provided\r\n * path to prevent duplicating the bucket name, then constructs the final\r\n * path using the configured in-app bucket as the path prefix.\r\n *\r\n * @param options - The path and file name options used to build the downloaded file path.\r\n * @param options.path - The path segments leading to the file.\r\n * @param options.fileName - The name of the file or a Web API `File` object.\r\n * @returns The complete local path for the downloaded file.\r\n *\r\n * @example\r\n * const filePath = downloadedFilePath({\r\n * path: ['documents', 'reports'],\r\n * fileName: 'report.pdf',\r\n * });\r\n * // Returns a path prefixed with ENV.IN_APP_BUCKET.\r\n *\r\n * @example\r\n * const filePath = downloadedFilePath({\r\n * path: [ENV.IN_APP_BUCKET, 'documents'],\r\n * fileName: file,\r\n * });\r\n * // The duplicate bucket segment is removed before building the path.\r\n */\r\nexport function downloadedFilePath({path = [], fileName}: PathOptions): string {\r\n // Filter out any occurrence of ENV.IN_APP_BUCKET (case-sensitive or trimmed)\r\n const cleanedPath = path.filter((segment) => segment !== ENV.IN_APP_BUCKET);\r\n\r\n return buildPath({\r\n path_prefix: ENV.IN_APP_BUCKET,\r\n fileName: fileName instanceof File ? fileName.name : fileName ?? '',\r\n path: cleanedPath,\r\n });\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Determines the MIME content type of a file from its available metadata\r\n * or, when given a file path or URL, from its file extension.\r\n *\r\n * Supports Express Multer files, Web API `File` objects, raw `Buffer` values,\r\n * and file paths or URLs.\r\n *\r\n * @param file - The file, buffer, path, or URL whose content type should be determined.\r\n * @returns A promise resolving to the detected MIME content type.\r\n *\r\n * @example\r\n * const contentType = await getFileContentType(req.file);\r\n * // Returns something like: \"image/jpeg\"\r\n *\r\n * @example\r\n * const contentType = await getFileContentType('/uploads/document.pdf');\r\n * // Returns: \"application/pdf\"\r\n *\r\n * @example\r\n * const contentType = await getFileContentType(buffer);\r\n * // Returns: \"application/octet-stream\"\r\n */\r\nexport const getFileContentType = async (\r\n file: Express.Multer.File | File | Buffer | string\r\n): Promise<string> => {\r\n // 1. Raw Buffer: Buffers don't carry MIME metadata, so default to octet-stream\r\n if (Buffer.isBuffer(file)) {\r\n return 'application/octet-stream';\r\n }\r\n\r\n // 2. String path or URL: Look up MIME type based on extension/filename\r\n if (typeof file === 'string') {\r\n const detectedType = mime.lookup(file);\r\n return detectedType || 'application/octet-stream';\r\n }\r\n\r\n // 3. Express.Multer.File: Has 'mimetype' property\r\n if ('mimetype' in file && file.mimetype) {\r\n return file.mimetype;\r\n }\r\n\r\n // 4. Web API File: Has 'type' property\r\n if ('type' in file && file.type) {\r\n return file.type;\r\n }\r\n\r\n // 5. Fallback if object has no recognizable MIME type\r\n return 'application/octet-stream';\r\n};\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Determines whether the provided value is a URL or a local/server based file path.\r\n *\r\n * If the value is a valid HTTP/HTTPS URL, the configured URL environment\r\n * value is returned. Otherwise, the configured local path environment value\r\n * is returned.\r\n *\r\n * @param val - The URL or local file path to evaluate.\r\n * @returns The configured URL or local path based on the input type.\r\n *\r\n * @example\r\n * const basePath = url_or_path('https://example.com/file.png');\r\n * // Returns ENV.URL\r\n *\r\n * @example\r\n * const basePath = url_or_path('/uploads/file.png');\r\n * // Returns ENV.PATH\r\n */\r\nexport const url_or_path = (val: string): string => {\r\n try {\r\n const parsed = new URL(val);\r\n if (parsed.protocol === \"http:\" || parsed.protocol === \"https:\") {\r\n return ENV.URL;\r\n }\r\n } catch {\r\n // If new URL() throws, it is a local path\r\n }\r\n return ENV.PATH;\r\n};\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Safely normalizes Buffer, Express.Multer.File, Web File, or File Path into Uint8Array\r\n */\r\nexport async function toUint8Array(file: Express.Multer.File | File | Buffer | string): Promise<Uint8Array> {\r\n if (typeof file === \"string\") {\r\n // File path on disk\r\n return await readFile(file);\r\n }\r\n\r\n if (Buffer.isBuffer(file)) {\r\n // Raw Node.js Buffer\r\n return new Uint8Array(file);\r\n }\r\n\r\n if (\"buffer\" in file && Buffer.isBuffer(file.buffer)) {\r\n // Express.Multer.File (Memory storage)\r\n return new Uint8Array(file.buffer);\r\n }\r\n\r\n if (\"path\" in file && typeof file.path === \"string\") {\r\n // Express.Multer.File (Disk storage)\r\n return await readFile(file.path);\r\n }\r\n\r\n if (\"arrayBuffer\" in file && typeof file.arrayBuffer === \"function\") {\r\n // Web API File / Blob\r\n return new Uint8Array(await file.arrayBuffer());\r\n }\r\n\r\n throw new Error(\"Unable to parse file input into a valid binary buffer.\");\r\n}\r\n\r\n\r\n\r\n\r\n\r\n"],"mappings":";;;;;;;;AACA,OAAO,UAAU;AAEjB,SAAQ,gBAAe;AACvB,OAAO,QAAQ;AAUf,eAAsB,gBAAgB,UAAkB;AACpD,MAAI;AACA,UAAM,GAAG,OAAO,QAAQ;AACxB,WAAO;AAAA,EACX,QAAQ;AACJ,WAAO;AAAA,EACX;AACJ;AAPsB;AAkDf,SAAS,iBAAiB,OAA6D;AAE1F,MAAI,OAAO,SAAS,KA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} from "./chunk-EWQYVPOL.js";
|
|
@@ -17,8 +20,11 @@ async function connectToMongo() {
|
|
|
17
20
|
if (!client) {
|
|
18
21
|
let options;
|
|
19
22
|
try {
|
|
20
|
-
const
|
|
21
|
-
const
|
|
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
|
+
const { MONGO_CLIENT_OPTIONS } = await import(pathToFileURL(
|
|
26
|
+
await fileExistsAsync(mongoConfigFileJs) ? mongoConfigFileJs : mongoConfigFileTs
|
|
27
|
+
).href);
|
|
22
28
|
options = MONGO_CLIENT_OPTIONS || {};
|
|
23
29
|
} catch (error) {
|
|
24
30
|
options = {};
|
|
@@ -46,4 +52,4 @@ export {
|
|
|
46
52
|
connectToMongo,
|
|
47
53
|
getMongoServer
|
|
48
54
|
};
|
|
49
|
-
//# sourceMappingURL=chunk-
|
|
55
|
+
//# sourceMappingURL=chunk-XBJ3SJ26.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/engine/mondoDb/mongoDB.ts"],"sourcesContent":["import { ENV } from \"../../utility/libs/env.js\";\r\nimport { MongoClient, type MongoClientOptions } from 'mongodb';\r\nimport path from \"node:path\"\r\nimport {pathToFileURL} from \"node:url\";\r\nimport {fileExistsAsync} from \"../../utility/utilis/general/file-operations.js\";\r\n\r\n\r\nconst uri = ENV.MONGO_SERVER_URL;\r\nlet client: MongoClient | null = null;\r\n\r\n\r\nasync function connectToMongo(): Promise<MongoClient|undefined> {\r\n if (!uri) return;\r\n try {\r\n if (!client) {\r\n\r\n let options: MongoClientOptions;\r\n\r\n try {\r\n const mongoConfigFileTs = path.join(process.cwd(), \"src/config/mongo.config.ts\");\r\n const mongoConfigFileJs = path.join(process.cwd(), \"src/config/mongo.config.js\");\r\n\r\n const { MONGO_CLIENT_OPTIONS } = await import(\r\n pathToFileURL(\r\n (await fileExistsAsync(mongoConfigFileJs)) ? mongoConfigFileJs : mongoConfigFileTs\r\n ).href\r\n );\r\n options = MONGO_CLIENT_OPTIONS || {};\r\n }\r\n catch (error) {\r\n options = {}\r\n }\r\n\r\n\r\n client = new MongoClient(uri, options);\r\n await client.connect();\r\n console.log(\"✅ Connected to MongoDB Cluster\");\r\n\r\n }\r\n return client;\r\n } catch (error) {\r\n console.error(\"❌ MongoDB Connection Error:\", error);\r\n throw error;\r\n }\r\n}\r\n\r\n\r\n\r\nfunction getMongoServer(): MongoClient {\r\n if (!client) {\r\n throw new Error(\"Call connectToMongo first!\");\r\n }\r\n return client;\r\n}\r\n\r\n\r\n\r\nexport { connectToMongo, getMongoServer };\r\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,4BAA4B;AAC/E,cAAM,oBAAoB,KAAK,KAAK,QAAQ,IAAI,GAAG,4BAA4B;AAE/E,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":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
fileExistsAsync
|
|
3
|
+
} from "./chunk-W3W3X2OE.js";
|
|
4
|
+
|
|
5
|
+
// src/engine/cloudBucket/r2Storage.ts
|
|
6
|
+
import { S3Client } from "@aws-sdk/client-s3";
|
|
7
|
+
import path from "path";
|
|
8
|
+
import { pathToFileURL } from "url";
|
|
9
|
+
var s3ConfigFileTs = path.join(process.cwd(), "src/config/s3bucket.config.ts");
|
|
10
|
+
var s3ConfigFileJs = path.join(process.cwd(), "src/config/s3bucket.config.js");
|
|
11
|
+
var { S3_BUCKET_CONFIG } = await import(pathToFileURL(
|
|
12
|
+
await fileExistsAsync(s3ConfigFileJs) ? s3ConfigFileJs : s3ConfigFileTs
|
|
13
|
+
).href);
|
|
14
|
+
var s3Client = new S3Client(S3_BUCKET_CONFIG);
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
s3Client
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=chunk-YTBSGKGF.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/engine/cloudBucket/r2Storage.ts"],"sourcesContent":["import { S3Client } from '@aws-sdk/client-s3';\r\nimport path from \"node:path\";\r\nimport {pathToFileURL} from \"node:url\";\r\nimport {fileExistsAsync} from \"../../utility/utilis/general/file-operations.js\";\r\n\r\n\r\n\r\n\r\n\r\nconst s3ConfigFileTs = path.join(process.cwd(), \"src/config/s3bucket.config.ts\");\r\nconst s3ConfigFileJs = path.join(process.cwd(), \"src/config/s3bucket.config.js\");\r\n\r\nconst { S3_BUCKET_CONFIG } = await import(\r\n pathToFileURL(\r\n (await fileExistsAsync(s3ConfigFileJs)) ? s3ConfigFileJs : s3ConfigFileTs\r\n ).href\r\n );\r\n\r\n\r\nexport const s3Client: S3Client = new S3Client(S3_BUCKET_CONFIG);\r\n"],"mappings":";;;;;AAAA,SAAS,gBAAgB;AACzB,OAAO,UAAU;AACjB,SAAQ,qBAAoB;AAO5B,IAAM,iBAAiB,KAAK,KAAK,QAAQ,IAAI,GAAG,+BAA+B;AAC/E,IAAM,iBAAiB,KAAK,KAAK,QAAQ,IAAI,GAAG,+BAA+B;AAE/E,IAAM,EAAE,iBAAiB,IAAI,MAAM,OAC/B;AAAA,EACK,MAAM,gBAAgB,cAAc,IAAK,iBAAiB;AAC/D,EAAE;AAIC,IAAM,WAAqB,IAAI,SAAS,gBAAgB;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/engine/script/run-all.ts"],"sourcesContent":["import {execSync} from \"node:child_process\";\r\nimport path from \"node:path\";\r\n\r\n\r\n\r\nexport function runAll() {\r\n execSync('docker-compose -f ./bucketConfigs/docker-compose.yml up -d', {\r\n cwd: process.cwd(),\r\n stdio: \"inherit\",\r\n })\r\n\r\n execSync(\"tsx \" + path.join(process.cwd() , \"node_modules/backfarm/dist/utility/utilis/server/server.js\"), {\r\n cwd: process.cwd(),\r\n stdio: \"inherit\",\r\n })\r\n\r\n}\r\n\r\n"],"mappings":";;;;;AAAA,SAAQ,gBAAe;AACvB,OAAO,UAAU;AAIV,SAAS,SAAS;AACrB,WAAS,8DAA8D;AAAA,IACnE,KAAK,QAAQ,IAAI;AAAA,IACjB,OAAO;AAAA,EACX,CAAC;AAED,WAAS,SAAS,KAAK,KAAK,QAAQ,IAAI,GAAI,4DAA4D,GAAG;AAAA,IACvG,KAAK,QAAQ,IAAI;AAAA,IACjB,OAAO;AAAA,EACX,CAAC;AAEL;AAXgB;","names":[]}
|
|
@@ -4,15 +4,15 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
buildURL
|
|
6
6
|
} from "./chunk-SSFPGDA3.js";
|
|
7
|
+
import {
|
|
8
|
+
s3Client
|
|
9
|
+
} from "./chunk-YTBSGKGF.js";
|
|
7
10
|
import {
|
|
8
11
|
buildPath,
|
|
9
12
|
getFileContentType,
|
|
10
13
|
getFileExtension,
|
|
11
14
|
toUint8Array
|
|
12
|
-
} from "./chunk-
|
|
13
|
-
import {
|
|
14
|
-
s3Client
|
|
15
|
-
} from "./chunk-3AP6JARL.js";
|
|
15
|
+
} from "./chunk-W3W3X2OE.js";
|
|
16
16
|
import {
|
|
17
17
|
ENV
|
|
18
18
|
} from "./chunk-EWQYVPOL.js";
|
|
@@ -69,4 +69,4 @@ var upload_file = /* @__PURE__ */ __name(async ({ file, path }) => {
|
|
|
69
69
|
export {
|
|
70
70
|
upload_file
|
|
71
71
|
};
|
|
72
|
-
//# sourceMappingURL=chunk-
|
|
72
|
+
//# sourceMappingURL=chunk-ZMDJ45KH.js.map
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HTTP_SERVER,
|
|
3
3
|
startServer
|
|
4
|
-
} from "../../chunk-
|
|
5
|
-
import "../../chunk-P5XJG7OG.js";
|
|
4
|
+
} from "../../chunk-ICFMWIIJ.js";
|
|
6
5
|
import "../../chunk-MNSQSU7T.js";
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
9
|
-
import "../../chunk-
|
|
6
|
+
import "../../chunk-P5XJG7OG.js";
|
|
7
|
+
import "../../chunk-NIOLLLJJ.js";
|
|
8
|
+
import "../../chunk-QVTKG7FD.js";
|
|
9
|
+
import "../../chunk-VFF4YFA3.js";
|
|
10
|
+
import "../../chunk-XBJ3SJ26.js";
|
|
11
|
+
import "../../chunk-W3W3X2OE.js";
|
|
10
12
|
import "../../chunk-EWQYVPOL.js";
|
|
11
|
-
import "../../chunk-W2745SOE.js";
|
|
12
13
|
import "../../chunk-7QVYU63E.js";
|
|
13
14
|
export {
|
|
14
15
|
HTTP_SERVER,
|
package/dist/engine/sql/mySql.js
CHANGED
package/dist/engine/sql/pgSql.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getKeyFromUrl
|
|
3
3
|
} from "../../../chunk-SSFPGDA3.js";
|
|
4
|
-
import {
|
|
5
|
-
url_or_path
|
|
6
|
-
} from "../../../chunk-FMCW72HO.js";
|
|
7
4
|
import {
|
|
8
5
|
s3Client
|
|
9
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-YTBSGKGF.js";
|
|
7
|
+
import {
|
|
8
|
+
url_or_path
|
|
9
|
+
} from "../../../chunk-W3W3X2OE.js";
|
|
10
10
|
import {
|
|
11
11
|
ENV
|
|
12
12
|
} from "../../../chunk-EWQYVPOL.js";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getKeyFromUrl
|
|
3
3
|
} from "../../../chunk-SSFPGDA3.js";
|
|
4
|
-
import {
|
|
5
|
-
url_or_path
|
|
6
|
-
} from "../../../chunk-FMCW72HO.js";
|
|
7
4
|
import {
|
|
8
5
|
s3Client
|
|
9
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-YTBSGKGF.js";
|
|
7
|
+
import {
|
|
8
|
+
url_or_path
|
|
9
|
+
} from "../../../chunk-W3W3X2OE.js";
|
|
10
10
|
import {
|
|
11
11
|
ENV
|
|
12
12
|
} from "../../../chunk-EWQYVPOL.js";
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
getKeyFromUrl
|
|
6
6
|
} from "../../../chunk-SSFPGDA3.js";
|
|
7
|
+
import {
|
|
8
|
+
s3Client
|
|
9
|
+
} from "../../../chunk-YTBSGKGF.js";
|
|
7
10
|
import {
|
|
8
11
|
downloadedFilePath,
|
|
9
12
|
getFileExtension
|
|
10
|
-
} from "../../../chunk-
|
|
11
|
-
import {
|
|
12
|
-
s3Client
|
|
13
|
-
} from "../../../chunk-3AP6JARL.js";
|
|
13
|
+
} from "../../../chunk-W3W3X2OE.js";
|
|
14
14
|
import {
|
|
15
15
|
ENV
|
|
16
16
|
} from "../../../chunk-EWQYVPOL.js";
|
|
@@ -4,13 +4,13 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
getKeyFromUrl
|
|
6
6
|
} from "../../../chunk-SSFPGDA3.js";
|
|
7
|
+
import {
|
|
8
|
+
s3Client
|
|
9
|
+
} from "../../../chunk-YTBSGKGF.js";
|
|
7
10
|
import {
|
|
8
11
|
downloadedFilePath,
|
|
9
12
|
getFileExtension
|
|
10
|
-
} from "../../../chunk-
|
|
11
|
-
import {
|
|
12
|
-
s3Client
|
|
13
|
-
} from "../../../chunk-3AP6JARL.js";
|
|
13
|
+
} from "../../../chunk-W3W3X2OE.js";
|
|
14
14
|
import {
|
|
15
15
|
ENV
|
|
16
16
|
} from "../../../chunk-EWQYVPOL.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utility/utilis/cloud_storage/s3Client.ts"],"sourcesContent":["import {s3Client as sss} from \"../../../engine/cloudBucket/r2Storage.js\";\r\nimport type {S3Client} from \"@aws-sdk/client-s3\";\r\n\r\nexport const getS3Client = async (): Promise<S3Client> => {\r\n return sss;\r\n}\r\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/utility/utilis/cloud_storage/s3Client.ts"],"sourcesContent":["import {s3Client as sss} from \"../../../engine/cloudBucket/r2Storage.js\";\r\nimport type {S3Client} from \"@aws-sdk/client-s3\";\r\n\r\nexport const getS3Client = async (): Promise<S3Client> => {\r\n return sss;\r\n}\r\n"],"mappings":";;;;;;;;;;AAGO,IAAM,cAAc,mCAA+B;AACtD,SAAO;AACX,GAF2B;","names":[]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
upload_file
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-ZMDJ45KH.js";
|
|
4
4
|
import "../../../chunk-X3R3RLXY.js";
|
|
5
5
|
import "../../../chunk-SSFPGDA3.js";
|
|
6
|
-
import "../../../chunk-
|
|
7
|
-
import "../../../chunk-
|
|
6
|
+
import "../../../chunk-YTBSGKGF.js";
|
|
7
|
+
import "../../../chunk-W3W3X2OE.js";
|
|
8
8
|
import "../../../chunk-EWQYVPOL.js";
|
|
9
9
|
import "../../../chunk-7QVYU63E.js";
|
|
10
10
|
export {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
upload_file
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-ZMDJ45KH.js";
|
|
4
4
|
import "../../../chunk-X3R3RLXY.js";
|
|
5
5
|
import "../../../chunk-SSFPGDA3.js";
|
|
6
|
-
import "../../../chunk-
|
|
7
|
-
import "../../../chunk-
|
|
6
|
+
import "../../../chunk-YTBSGKGF.js";
|
|
7
|
+
import "../../../chunk-W3W3X2OE.js";
|
|
8
8
|
import "../../../chunk-EWQYVPOL.js";
|
|
9
9
|
import {
|
|
10
10
|
__name
|
|
@@ -4,6 +4,7 @@ import '../../libs/types.js';
|
|
|
4
4
|
import 'express';
|
|
5
5
|
import '../../libs/env.js';
|
|
6
6
|
|
|
7
|
+
declare function fileExistsAsync(filePath: string): Promise<boolean>;
|
|
7
8
|
/**
|
|
8
9
|
* Extracts the file extension from a supported file input.
|
|
9
10
|
*
|
|
@@ -137,4 +138,4 @@ declare const url_or_path: (val: string) => string;
|
|
|
137
138
|
*/
|
|
138
139
|
declare function toUint8Array(file: Express.Multer.File | File | Buffer | string): Promise<Uint8Array>;
|
|
139
140
|
|
|
140
|
-
export { buildPath, downloadedFilePath, getFileContentType, getFileExtension, toUint8Array, url_or_path };
|
|
141
|
+
export { buildPath, downloadedFilePath, fileExistsAsync, getFileContentType, getFileExtension, toUint8Array, url_or_path };
|
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildPath,
|
|
3
3
|
downloadedFilePath,
|
|
4
|
+
fileExistsAsync,
|
|
4
5
|
getFileContentType,
|
|
5
6
|
getFileExtension,
|
|
6
7
|
toUint8Array,
|
|
7
8
|
url_or_path
|
|
8
|
-
} from "../../../chunk-
|
|
9
|
+
} from "../../../chunk-W3W3X2OE.js";
|
|
9
10
|
import "../../../chunk-EWQYVPOL.js";
|
|
10
11
|
import "../../../chunk-7QVYU63E.js";
|
|
11
12
|
export {
|
|
12
13
|
buildPath,
|
|
13
14
|
downloadedFilePath,
|
|
15
|
+
fileExistsAsync,
|
|
14
16
|
getFileContentType,
|
|
15
17
|
getFileExtension,
|
|
16
18
|
toUint8Array,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utility/utilis/mongoDb/buldWrite.ts"],"sourcesContent":["import {getMongoServer} from \"../../../engine/mondoDb/mongoDB.js\";\r\nimport type {CustomBulkWriteResult} from \"../../libs/types.js\";\r\nimport type {BulkWriteInterface} from \"../../libs/interface.js\";\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Executes multiple write operations against a MongoDB collection in a single\r\n * bulk operation.\r\n *\r\n * The function connects to the specified database and collection, executes\r\n * the provided bulk write operations, and returns a standardized result\r\n * indicating whether the operation succeeded or failed.\r\n *\r\n * @param params - Configuration and operations required for the bulk write.\r\n * @param params.dbName - The name of the MongoDB database.\r\n * @param params.collectionName - The name of the collection to modify.\r\n * @param params.writable - An array of MongoDB bulk write operations to execute.\r\n * @param params.options - Optional MongoDB bulk write configuration.\r\n * @returns A promise resolving to a `CustomBulkWriteResult` containing either\r\n * the `BulkWriteResult` on success or an `Error` on failure.\r\n *\r\n * @example\r\n * const result = await bulkWrite({\r\n * dbName: 'my_database',\r\n * collectionName: 'users',\r\n * writable: [\r\n * {\r\n * insertOne: {\r\n * document: {\r\n * name: 'John',\r\n * email: 'john@example.com',\r\n * },\r\n * },\r\n * },\r\n * {\r\n * updateOne: {\r\n * filter: { name: 'Jane' },\r\n * update: { $set: { active: true } },\r\n * },\r\n * },\r\n * ],\r\n * });\r\n *\r\n * if (result.status) {\r\n * console.log(result.result);\r\n * } else {\r\n * console.error(result.error);\r\n * }\r\n */\r\nexport const mongoBulkWrite = async (\r\n params: BulkWriteInterface\r\n): Promise<CustomBulkWriteResult> => {\r\n const { dbName, collectionName, writable, options } = params;\r\n\r\n try {\r\n const col = getMongoServer().db(dbName).collection(collectionName);\r\n\r\n // Added 'await' to ensure operations complete\r\n const result = await col.bulkWrite(writable, options);\r\n\r\n return {\r\n status: true,\r\n result,\r\n error: null,\r\n };\r\n } catch (err) {\r\n const error = err instanceof Error ? err : new Error(String(err));\r\n return {\r\n status: false,\r\n result: null,\r\n error,\r\n };\r\n }\r\n};\r\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/utility/utilis/mongoDb/buldWrite.ts"],"sourcesContent":["import {getMongoServer} from \"../../../engine/mondoDb/mongoDB.js\";\r\nimport type {CustomBulkWriteResult} from \"../../libs/types.js\";\r\nimport type {BulkWriteInterface} from \"../../libs/interface.js\";\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Executes multiple write operations against a MongoDB collection in a single\r\n * bulk operation.\r\n *\r\n * The function connects to the specified database and collection, executes\r\n * the provided bulk write operations, and returns a standardized result\r\n * indicating whether the operation succeeded or failed.\r\n *\r\n * @param params - Configuration and operations required for the bulk write.\r\n * @param params.dbName - The name of the MongoDB database.\r\n * @param params.collectionName - The name of the collection to modify.\r\n * @param params.writable - An array of MongoDB bulk write operations to execute.\r\n * @param params.options - Optional MongoDB bulk write configuration.\r\n * @returns A promise resolving to a `CustomBulkWriteResult` containing either\r\n * the `BulkWriteResult` on success or an `Error` on failure.\r\n *\r\n * @example\r\n * const result = await bulkWrite({\r\n * dbName: 'my_database',\r\n * collectionName: 'users',\r\n * writable: [\r\n * {\r\n * insertOne: {\r\n * document: {\r\n * name: 'John',\r\n * email: 'john@example.com',\r\n * },\r\n * },\r\n * },\r\n * {\r\n * updateOne: {\r\n * filter: { name: 'Jane' },\r\n * update: { $set: { active: true } },\r\n * },\r\n * },\r\n * ],\r\n * });\r\n *\r\n * if (result.status) {\r\n * console.log(result.result);\r\n * } else {\r\n * console.error(result.error);\r\n * }\r\n */\r\nexport const mongoBulkWrite = async (\r\n params: BulkWriteInterface\r\n): Promise<CustomBulkWriteResult> => {\r\n const { dbName, collectionName, writable, options } = params;\r\n\r\n try {\r\n const col = getMongoServer().db(dbName).collection(collectionName);\r\n\r\n // Added 'await' to ensure operations complete\r\n const result = await col.bulkWrite(writable, options);\r\n\r\n return {\r\n status: true,\r\n result,\r\n error: null,\r\n };\r\n } catch (err) {\r\n const error = err instanceof Error ? err : new Error(String(err));\r\n return {\r\n status: false,\r\n result: null,\r\n error,\r\n };\r\n }\r\n};\r\n"],"mappings":";;;;;;;;;;AAuDO,IAAM,iBAAiB,8BAC1B,WACiC;AACjC,QAAM,EAAE,QAAQ,gBAAgB,UAAU,QAAQ,IAAI;AAEtD,MAAI;AACA,UAAM,MAAM,eAAe,EAAE,GAAG,MAAM,EAAE,WAAW,cAAc;AAGjE,UAAM,SAAS,MAAM,IAAI,UAAU,UAAU,OAAO;AAEpD,WAAO;AAAA,MACH,QAAQ;AAAA,MACR;AAAA,MACA,OAAO;AAAA,IACX;AAAA,EACJ,SAAS,KAAK;AACV,UAAM,QAAQ,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,CAAC;AAChE,WAAO;AAAA,MACH,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR;AAAA,IACJ;AAAA,EACJ;AACJ,GAxB8B;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utility/utilis/mongoDb/deleteDocument.ts"],"sourcesContent":["import { getMongoServer } from \"../../../engine/mondoDb/mongoDB.js\";\r\nimport type {CustomDeleteResult} from \"../../libs/types.js\";\r\nimport type {DeleteDocuments} from \"../../libs/interface.js\";\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Deletes one or more documents from a MongoDB collection.\r\n *\r\n * By default, the function deletes a single document matching the provided\r\n * query. When `deleteMany` is set to `true`, all documents matching the query\r\n * are deleted.\r\n *\r\n * @param params - Configuration options for the delete operation.\r\n * @param params.dbName - The name of the MongoDB database.\r\n * @param params.collection - The name of the collection to delete from.\r\n * @param params.query - The MongoDB filter used to identify the documents.\r\n * @param params.deleteMany - Whether to delete all matching documents instead\r\n * of only the first matching document. Defaults to `false`.\r\n * @param params.options - Optional MongoDB delete operation options.\r\n * @returns A promise resolving to a `CustomDeleteResult` containing the\r\n * `DeleteResult` and number of deleted documents on success, or an `Error`\r\n * on failure.\r\n *\r\n * @example\r\n * const result = await deleteDocument({\r\n * dbName: 'my_database',\r\n * collection: 'users',\r\n * query: {\r\n * email: 'john@example.com',\r\n * },\r\n * });\r\n *\r\n * if (result.status) {\r\n * console.log(`Deleted ${result.deletedCount} document(s)`);\r\n * } else {\r\n * console.error(result.error);\r\n * }\r\n *\r\n * @example\r\n * const result = await deleteDocument({\r\n * dbName: 'my_database',\r\n * collection: 'users',\r\n * query: {\r\n * active: false,\r\n * },\r\n * deleteMany: true,\r\n * });\r\n *\r\n * // Deletes all inactive users matching the query.\r\n */\r\nexport const mongoDeleteDocument = async (\r\n params: DeleteDocuments\r\n): Promise<CustomDeleteResult> => {\r\n\r\n\r\n const { dbName, collection, query, deleteMany = false, options } = params;\r\n\r\n try {\r\n const col = getMongoServer().db(dbName).collection(collection);\r\n\r\n const result = deleteMany\r\n ? await col.deleteMany(query, options)\r\n : await col.deleteOne(query, options);\r\n\r\n return {\r\n status: true,\r\n result,\r\n deletedCount: result.deletedCount,\r\n error: null,\r\n };\r\n } catch (err) {\r\n const error = err instanceof Error ? err : new Error(String(err));\r\n\r\n return {\r\n status: false,\r\n result: null,\r\n deletedCount: 0,\r\n error,\r\n };\r\n }\r\n};\r\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/utility/utilis/mongoDb/deleteDocument.ts"],"sourcesContent":["import { getMongoServer } from \"../../../engine/mondoDb/mongoDB.js\";\r\nimport type {CustomDeleteResult} from \"../../libs/types.js\";\r\nimport type {DeleteDocuments} from \"../../libs/interface.js\";\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Deletes one or more documents from a MongoDB collection.\r\n *\r\n * By default, the function deletes a single document matching the provided\r\n * query. When `deleteMany` is set to `true`, all documents matching the query\r\n * are deleted.\r\n *\r\n * @param params - Configuration options for the delete operation.\r\n * @param params.dbName - The name of the MongoDB database.\r\n * @param params.collection - The name of the collection to delete from.\r\n * @param params.query - The MongoDB filter used to identify the documents.\r\n * @param params.deleteMany - Whether to delete all matching documents instead\r\n * of only the first matching document. Defaults to `false`.\r\n * @param params.options - Optional MongoDB delete operation options.\r\n * @returns A promise resolving to a `CustomDeleteResult` containing the\r\n * `DeleteResult` and number of deleted documents on success, or an `Error`\r\n * on failure.\r\n *\r\n * @example\r\n * const result = await deleteDocument({\r\n * dbName: 'my_database',\r\n * collection: 'users',\r\n * query: {\r\n * email: 'john@example.com',\r\n * },\r\n * });\r\n *\r\n * if (result.status) {\r\n * console.log(`Deleted ${result.deletedCount} document(s)`);\r\n * } else {\r\n * console.error(result.error);\r\n * }\r\n *\r\n * @example\r\n * const result = await deleteDocument({\r\n * dbName: 'my_database',\r\n * collection: 'users',\r\n * query: {\r\n * active: false,\r\n * },\r\n * deleteMany: true,\r\n * });\r\n *\r\n * // Deletes all inactive users matching the query.\r\n */\r\nexport const mongoDeleteDocument = async (\r\n params: DeleteDocuments\r\n): Promise<CustomDeleteResult> => {\r\n\r\n\r\n const { dbName, collection, query, deleteMany = false, options } = params;\r\n\r\n try {\r\n const col = getMongoServer().db(dbName).collection(collection);\r\n\r\n const result = deleteMany\r\n ? await col.deleteMany(query, options)\r\n : await col.deleteOne(query, options);\r\n\r\n return {\r\n status: true,\r\n result,\r\n deletedCount: result.deletedCount,\r\n error: null,\r\n };\r\n } catch (err) {\r\n const error = err instanceof Error ? err : new Error(String(err));\r\n\r\n return {\r\n status: false,\r\n result: null,\r\n deletedCount: 0,\r\n error,\r\n };\r\n }\r\n};\r\n"],"mappings":";;;;;;;;;;AAuDO,IAAM,sBAAsB,8BAC/B,WAC8B;AAG9B,QAAM,EAAE,QAAQ,YAAY,OAAO,aAAa,OAAO,QAAQ,IAAI;AAEnE,MAAI;AACA,UAAM,MAAM,eAAe,EAAE,GAAG,MAAM,EAAE,WAAW,UAAU;AAE7D,UAAM,SAAS,aACT,MAAM,IAAI,WAAW,OAAO,OAAO,IACnC,MAAM,IAAI,UAAU,OAAO,OAAO;AAExC,WAAO;AAAA,MACH,QAAQ;AAAA,MACR;AAAA,MACA,cAAc,OAAO;AAAA,MACrB,OAAO;AAAA,IACX;AAAA,EACJ,SAAS,KAAK;AACV,UAAM,QAAQ,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,CAAC;AAEhE,WAAO;AAAA,MACH,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,cAAc;AAAA,MACd;AAAA,IACJ;AAAA,EACJ;AACJ,GA9BmC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utility/utilis/mongoDb/insertField.ts"],"sourcesContent":["import {getMongoServer} from \"../../../engine/mondoDb/mongoDB.js\";\r\nimport type {CustomInsertOneResult} from \"../../libs/types.js\";\r\nimport type {InsertOneInterface} from \"../../libs/interface.js\";\r\nimport type {Document } from \"mongodb\";\r\n\r\n\r\n\r\n/**\r\n * Inserts a single document into a MongoDB collection.\r\n *\r\n * The document is inserted into the specified database and collection using\r\n * the provided MongoDB insertion options. The generic type `T` allows the\r\n * inserted document and resulting operation to remain type-safe.\r\n *\r\n * @param params - Configuration options for the insert operation.\r\n * @param params.dbName - The name of the MongoDB database.\r\n * @param params.collectionName - The name of the collection to insert into.\r\n * @param params.field - The document to insert.\r\n * @param params.options - Optional MongoDB insert operation options.\r\n * @returns A promise resolving to a `CustomInsertOneResult<T>` containing the\r\n * `InsertOneResult` on success or an `Error` on failure.\r\n *\r\n * @example\r\n * const result = await insertOneField({\r\n * dbName: 'my_database',\r\n * collectionName: 'users',\r\n * field: {\r\n * name: 'John Doe',\r\n * email: 'john@example.com',\r\n * },\r\n * });\r\n *\r\n * if (result.status) {\r\n * console.log('Inserted ID:', result.result.insertedId);\r\n * } else {\r\n * console.error(result.error);\r\n * }\r\n */\r\nexport const mongoInsertOneField = async <T>(\r\n params: InsertOneInterface<T>\r\n): Promise<CustomInsertOneResult<T>> => {\r\n const { dbName, collectionName, field, options } = params;\r\n\r\n try {\r\n const db = getMongoServer().db(dbName);\r\n const collection = db.collection<T & Document>(collectionName);\r\n\r\n const result = await collection.insertOne(field, options);\r\n\r\n return {\r\n status: true,\r\n result,\r\n error: null,\r\n };\r\n } catch (err) {\r\n const error = err instanceof Error ? err : new Error(String(err));\r\n return {\r\n status: false,\r\n result: null,\r\n error,\r\n };\r\n }\r\n};\r\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/utility/utilis/mongoDb/insertField.ts"],"sourcesContent":["import {getMongoServer} from \"../../../engine/mondoDb/mongoDB.js\";\r\nimport type {CustomInsertOneResult} from \"../../libs/types.js\";\r\nimport type {InsertOneInterface} from \"../../libs/interface.js\";\r\nimport type {Document } from \"mongodb\";\r\n\r\n\r\n\r\n/**\r\n * Inserts a single document into a MongoDB collection.\r\n *\r\n * The document is inserted into the specified database and collection using\r\n * the provided MongoDB insertion options. The generic type `T` allows the\r\n * inserted document and resulting operation to remain type-safe.\r\n *\r\n * @param params - Configuration options for the insert operation.\r\n * @param params.dbName - The name of the MongoDB database.\r\n * @param params.collectionName - The name of the collection to insert into.\r\n * @param params.field - The document to insert.\r\n * @param params.options - Optional MongoDB insert operation options.\r\n * @returns A promise resolving to a `CustomInsertOneResult<T>` containing the\r\n * `InsertOneResult` on success or an `Error` on failure.\r\n *\r\n * @example\r\n * const result = await insertOneField({\r\n * dbName: 'my_database',\r\n * collectionName: 'users',\r\n * field: {\r\n * name: 'John Doe',\r\n * email: 'john@example.com',\r\n * },\r\n * });\r\n *\r\n * if (result.status) {\r\n * console.log('Inserted ID:', result.result.insertedId);\r\n * } else {\r\n * console.error(result.error);\r\n * }\r\n */\r\nexport const mongoInsertOneField = async <T>(\r\n params: InsertOneInterface<T>\r\n): Promise<CustomInsertOneResult<T>> => {\r\n const { dbName, collectionName, field, options } = params;\r\n\r\n try {\r\n const db = getMongoServer().db(dbName);\r\n const collection = db.collection<T & Document>(collectionName);\r\n\r\n const result = await collection.insertOne(field, options);\r\n\r\n return {\r\n status: true,\r\n result,\r\n error: null,\r\n };\r\n } catch (err) {\r\n const error = err instanceof Error ? err : new Error(String(err));\r\n return {\r\n status: false,\r\n result: null,\r\n error,\r\n };\r\n }\r\n};\r\n"],"mappings":";;;;;;;;;;AAsCO,IAAM,sBAAsB,8BAC/B,WACoC;AACpC,QAAM,EAAE,QAAQ,gBAAgB,OAAO,QAAQ,IAAI;AAEnD,MAAI;AACA,UAAM,KAAK,eAAe,EAAE,GAAG,MAAM;AACrC,UAAM,aAAa,GAAG,WAAyB,cAAc;AAE7D,UAAM,SAAS,MAAM,WAAW,UAAU,OAAO,OAAO;AAExD,WAAO;AAAA,MACH,QAAQ;AAAA,MACR;AAAA,MACA,OAAO;AAAA,IACX;AAAA,EACJ,SAAS,KAAK;AACV,UAAM,QAAQ,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,CAAC;AAChE,WAAO;AAAA,MACH,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR;AAAA,IACJ;AAAA,EACJ;AACJ,GAxBmC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utility/utilis/mongoDb/insertFields.ts"],"sourcesContent":["import type {InsertManyInterface} from \"../../libs/interface.js\";\r\nimport type {CustomInsertManyResult} from \"../../libs/types.js\";\r\nimport {getMongoServer} from \"../../../engine/mondoDb/mongoDB.js\";\r\nimport type {Document} from \"mongodb\";\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Inserts multiple documents into a MongoDB collection.\r\n *\r\n * The documents are inserted into the specified database and collection\r\n * using the provided MongoDB insertion options. The generic type `T`\r\n * ensures that the inserted documents and resulting operation remain\r\n * type-safe.\r\n *\r\n * @param params - Configuration options for the bulk insert operation.\r\n * @param params.dbName - The name of the MongoDB database.\r\n * @param params.collectionName - The name of the collection to insert into.\r\n * @param params.fields - An array of documents to insert.\r\n * @param params.options - Optional MongoDB bulk write options.\r\n * @returns A promise resolving to a `CustomInsertManyResult<T>` containing\r\n * the `InsertManyResult` and number of inserted documents on success, or\r\n * an `Error` on failure.\r\n *\r\n * @example\r\n * const result = await insertManyFields({\r\n * dbName: 'my_database',\r\n * collectionName: 'users',\r\n * fields: [\r\n * {\r\n * name: 'John Doe',\r\n * email: 'john@example.com',\r\n * },\r\n * {\r\n * name: 'Jane Doe',\r\n * email: 'jane@example.com',\r\n * },\r\n * ],\r\n * });\r\n *\r\n * if (result.status) {\r\n * console.log(`Inserted ${result.insertedCount} documents`);\r\n * } else {\r\n * console.error(result.error);\r\n * }\r\n */\r\nexport const mongoInsertManyFields = async <T>(\r\n params: InsertManyInterface<T>\r\n): Promise<CustomInsertManyResult<T>> => {\r\n const { dbName, collectionName, fields, options } = params;\r\n\r\n try {\r\n const db = getMongoServer().db(dbName);\r\n const collection = db.collection<T & Document>(collectionName);\r\n\r\n const result = await collection.insertMany(fields, options);\r\n\r\n return {\r\n status: true,\r\n result,\r\n insertedCount: result.insertedCount,\r\n error: null,\r\n };\r\n }\r\n catch (err) {\r\n const error = err instanceof Error ? err : new Error(String(err));\r\n return {\r\n status: false,\r\n result: null,\r\n insertedCount: 0,\r\n error,\r\n };\r\n }\r\n};\r\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/utility/utilis/mongoDb/insertFields.ts"],"sourcesContent":["import type {InsertManyInterface} from \"../../libs/interface.js\";\r\nimport type {CustomInsertManyResult} from \"../../libs/types.js\";\r\nimport {getMongoServer} from \"../../../engine/mondoDb/mongoDB.js\";\r\nimport type {Document} from \"mongodb\";\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Inserts multiple documents into a MongoDB collection.\r\n *\r\n * The documents are inserted into the specified database and collection\r\n * using the provided MongoDB insertion options. The generic type `T`\r\n * ensures that the inserted documents and resulting operation remain\r\n * type-safe.\r\n *\r\n * @param params - Configuration options for the bulk insert operation.\r\n * @param params.dbName - The name of the MongoDB database.\r\n * @param params.collectionName - The name of the collection to insert into.\r\n * @param params.fields - An array of documents to insert.\r\n * @param params.options - Optional MongoDB bulk write options.\r\n * @returns A promise resolving to a `CustomInsertManyResult<T>` containing\r\n * the `InsertManyResult` and number of inserted documents on success, or\r\n * an `Error` on failure.\r\n *\r\n * @example\r\n * const result = await insertManyFields({\r\n * dbName: 'my_database',\r\n * collectionName: 'users',\r\n * fields: [\r\n * {\r\n * name: 'John Doe',\r\n * email: 'john@example.com',\r\n * },\r\n * {\r\n * name: 'Jane Doe',\r\n * email: 'jane@example.com',\r\n * },\r\n * ],\r\n * });\r\n *\r\n * if (result.status) {\r\n * console.log(`Inserted ${result.insertedCount} documents`);\r\n * } else {\r\n * console.error(result.error);\r\n * }\r\n */\r\nexport const mongoInsertManyFields = async <T>(\r\n params: InsertManyInterface<T>\r\n): Promise<CustomInsertManyResult<T>> => {\r\n const { dbName, collectionName, fields, options } = params;\r\n\r\n try {\r\n const db = getMongoServer().db(dbName);\r\n const collection = db.collection<T & Document>(collectionName);\r\n\r\n const result = await collection.insertMany(fields, options);\r\n\r\n return {\r\n status: true,\r\n result,\r\n insertedCount: result.insertedCount,\r\n error: null,\r\n };\r\n }\r\n catch (err) {\r\n const error = err instanceof Error ? err : new Error(String(err));\r\n return {\r\n status: false,\r\n result: null,\r\n insertedCount: 0,\r\n error,\r\n };\r\n }\r\n};\r\n"],"mappings":";;;;;;;;;;AAkDO,IAAM,wBAAwB,8BACjC,WACqC;AACrC,QAAM,EAAE,QAAQ,gBAAgB,QAAQ,QAAQ,IAAI;AAEpD,MAAI;AACA,UAAM,KAAK,eAAe,EAAE,GAAG,MAAM;AACrC,UAAM,aAAa,GAAG,WAAyB,cAAc;AAE7D,UAAM,SAAS,MAAM,WAAW,WAAW,QAAQ,OAAO;AAE1D,WAAO;AAAA,MACH,QAAQ;AAAA,MACR;AAAA,MACA,eAAe,OAAO;AAAA,MACtB,OAAO;AAAA,IACX;AAAA,EACJ,SACO,KAAK;AACR,UAAM,QAAQ,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,CAAC;AAChE,WAAO;AAAA,MACH,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR,eAAe;AAAA,MACf;AAAA,IACJ;AAAA,EACJ;AACJ,GA3BqC;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utility/utilis/mongoDb/updateFiled.ts"],"sourcesContent":["import type {CustomUpdateResult} from \"../../libs/types.js\";\r\nimport {getMongoServer} from \"../../../engine/mondoDb/mongoDB.js\";\r\nimport type {UpdateDocument} from \"../../libs/interface.js\";\r\n\r\n\r\n\r\n/**\r\n * Updates one or more documents in a MongoDB collection.\r\n *\r\n * By default, the function updates a single document matching the provided\r\n * query. When `updateMany` is set to `true`, all documents matching the query\r\n * are updated.\r\n *\r\n * @param params - Configuration options for the update operation.\r\n * @param params.dbName - The name of the MongoDB database.\r\n * @param params.collectionName - The name of the collection to update.\r\n * @param params.query - The MongoDB filter used to identify the documents.\r\n * @param params.updatable - The update operations or update pipeline to apply\r\n * to the matching documents.\r\n * @param params.updateMany - Whether to update all matching documents instead\r\n * of only the first matching document. Defaults to `false`.\r\n * @param params.options - Optional MongoDB update operation options.\r\n * @returns A promise resolving to a `CustomUpdateResult` containing the\r\n * `UpdateResult` on success or an `Error` on failure.\r\n *\r\n * @example\r\n * const result = await updateField({\r\n * dbName: 'my_database',\r\n * collectionName: 'users',\r\n * query: {\r\n * email: 'john@example.com',\r\n * },\r\n * updatable: {\r\n * $set: {\r\n * active: true,\r\n * },\r\n * },\r\n * });\r\n *\r\n * if (result.status) {\r\n * console.log('User updated successfully');\r\n * } else {\r\n * console.error(result.error);\r\n * }\r\n *\r\n * @example\r\n * const result = await updateField({\r\n * dbName: 'my_database',\r\n * collectionName: 'users',\r\n * query: {\r\n * active: false,\r\n * },\r\n * updatable: {\r\n * $set: {\r\n * status: 'inactive',\r\n * },\r\n * },\r\n * updateMany: true,\r\n * });\r\n *\r\n * // Updates all users matching the query.\r\n */\r\nexport const mongoUpdateField = async (\r\n params: UpdateDocument\r\n): Promise<CustomUpdateResult> => {\r\n const {\r\n dbName,\r\n collectionName,\r\n query,\r\n updatable,\r\n updateMany = false,\r\n options\r\n } = params;\r\n\r\n try {\r\n const db = getMongoServer().db(dbName);\r\n const collection = db.collection(collectionName);\r\n\r\n // Perform update with await\r\n const result = updateMany\r\n ? await collection.updateMany(query, updatable, options)\r\n : await collection.updateOne(query, updatable, options);\r\n\r\n return {\r\n status: true,\r\n result,\r\n error: null,\r\n };\r\n } catch (err) {\r\n const error = err instanceof Error ? err : new Error(String(err));\r\n\r\n return {\r\n status: false,\r\n result: null,\r\n error,\r\n };\r\n }\r\n};\r\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/utility/utilis/mongoDb/updateFiled.ts"],"sourcesContent":["import type {CustomUpdateResult} from \"../../libs/types.js\";\r\nimport {getMongoServer} from \"../../../engine/mondoDb/mongoDB.js\";\r\nimport type {UpdateDocument} from \"../../libs/interface.js\";\r\n\r\n\r\n\r\n/**\r\n * Updates one or more documents in a MongoDB collection.\r\n *\r\n * By default, the function updates a single document matching the provided\r\n * query. When `updateMany` is set to `true`, all documents matching the query\r\n * are updated.\r\n *\r\n * @param params - Configuration options for the update operation.\r\n * @param params.dbName - The name of the MongoDB database.\r\n * @param params.collectionName - The name of the collection to update.\r\n * @param params.query - The MongoDB filter used to identify the documents.\r\n * @param params.updatable - The update operations or update pipeline to apply\r\n * to the matching documents.\r\n * @param params.updateMany - Whether to update all matching documents instead\r\n * of only the first matching document. Defaults to `false`.\r\n * @param params.options - Optional MongoDB update operation options.\r\n * @returns A promise resolving to a `CustomUpdateResult` containing the\r\n * `UpdateResult` on success or an `Error` on failure.\r\n *\r\n * @example\r\n * const result = await updateField({\r\n * dbName: 'my_database',\r\n * collectionName: 'users',\r\n * query: {\r\n * email: 'john@example.com',\r\n * },\r\n * updatable: {\r\n * $set: {\r\n * active: true,\r\n * },\r\n * },\r\n * });\r\n *\r\n * if (result.status) {\r\n * console.log('User updated successfully');\r\n * } else {\r\n * console.error(result.error);\r\n * }\r\n *\r\n * @example\r\n * const result = await updateField({\r\n * dbName: 'my_database',\r\n * collectionName: 'users',\r\n * query: {\r\n * active: false,\r\n * },\r\n * updatable: {\r\n * $set: {\r\n * status: 'inactive',\r\n * },\r\n * },\r\n * updateMany: true,\r\n * });\r\n *\r\n * // Updates all users matching the query.\r\n */\r\nexport const mongoUpdateField = async (\r\n params: UpdateDocument\r\n): Promise<CustomUpdateResult> => {\r\n const {\r\n dbName,\r\n collectionName,\r\n query,\r\n updatable,\r\n updateMany = false,\r\n options\r\n } = params;\r\n\r\n try {\r\n const db = getMongoServer().db(dbName);\r\n const collection = db.collection(collectionName);\r\n\r\n // Perform update with await\r\n const result = updateMany\r\n ? await collection.updateMany(query, updatable, options)\r\n : await collection.updateOne(query, updatable, options);\r\n\r\n return {\r\n status: true,\r\n result,\r\n error: null,\r\n };\r\n } catch (err) {\r\n const error = err instanceof Error ? err : new Error(String(err));\r\n\r\n return {\r\n status: false,\r\n result: null,\r\n error,\r\n };\r\n }\r\n};\r\n"],"mappings":";;;;;;;;;;AA8DO,IAAM,mBAAmB,8BAC5B,WAC8B;AAC9B,QAAM;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb;AAAA,EACJ,IAAI;AAEJ,MAAI;AACA,UAAM,KAAK,eAAe,EAAE,GAAG,MAAM;AACrC,UAAM,aAAa,GAAG,WAAW,cAAc;AAG/C,UAAM,SAAS,aACT,MAAM,WAAW,WAAW,OAAO,WAAW,OAAO,IACrD,MAAM,WAAW,UAAU,OAAO,WAAW,OAAO;AAE1D,WAAO;AAAA,MACH,QAAQ;AAAA,MACR;AAAA,MACA,OAAO;AAAA,IACX;AAAA,EACJ,SAAS,KAAK;AACV,UAAM,QAAQ,eAAe,QAAQ,MAAM,IAAI,MAAM,OAAO,GAAG,CAAC;AAEhE,WAAO;AAAA,MACH,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR;AAAA,IACJ;AAAA,EACJ;AACJ,GAnCgC;","names":[]}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
executeMySqlQuery
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-TP3K7DMH.js";
|
|
4
4
|
import {
|
|
5
5
|
executePgSqlQuery
|
|
6
|
-
} from "../../../chunk-
|
|
6
|
+
} from "../../../chunk-D7A4TEXY.js";
|
|
7
7
|
import {
|
|
8
8
|
isMySQL,
|
|
9
9
|
isPostgreSQL
|
|
10
10
|
} from "../../../chunk-MNSQSU7T.js";
|
|
11
11
|
import {
|
|
12
12
|
getMySqlPool
|
|
13
|
-
} from "../../../chunk-
|
|
13
|
+
} from "../../../chunk-QVTKG7FD.js";
|
|
14
14
|
import {
|
|
15
15
|
getPgSqlPool
|
|
16
|
-
} from "../../../chunk-
|
|
16
|
+
} from "../../../chunk-VFF4YFA3.js";
|
|
17
|
+
import "../../../chunk-W3W3X2OE.js";
|
|
17
18
|
import {
|
|
18
19
|
ENV
|
|
19
20
|
} from "../../../chunk-EWQYVPOL.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utility/utilis/postgres/executeQuery.ts"],"sourcesContent":["import type {QueryItems} from \"../../libs/interface.js\";\r\nimport {isMySQL, isPostgreSQL} from \"../general/sqlDb.js.js\";\r\nimport {ENV} from \"../../libs/env.js\";\r\nimport {executePgSqlQuery} from \"./subSqlfiles/executePgQuery.js\";\r\nimport {executeMySqlQuery} from \"./subSqlfiles/executeMySqlQuery.js\";\r\nimport {getMySqlPool} from \"../../../engine/sql/mySql.js\";\r\nimport {getPgSqlPool} from \"../../../engine/sql/pgSql.js\";\r\n\r\n\r\n\r\n\r\n/**\r\n * Executes one or more SQL queries using the database configured through\r\n * the `SQL_DB_URL` environment variable.\r\n *\r\n * The function automatically detects whether the configured database is\r\n * PostgreSQL or MySQL and delegates execution to the appropriate database\r\n * implementation.\r\n *\r\n * Supports structured CRUD operations (`insert_one`, `insert_many`, `select`,\r\n * `update`, and `delete`) as well as custom raw SQL queries.\r\n *\r\n * Parameterized conditions and raw queries are supported. The placeholder\r\n * syntax must match the configured database engine:\r\n *\r\n * - MySQL uses `?` placeholders.\r\n * - PostgreSQL uses `$1`, `$2`, `$3`, etc.\r\n *\r\n * The corresponding values are supplied through `conditionalParams` for\r\n * structured CRUD operations or `params` for raw SQL queries.\r\n *\r\n * @param query - The SQL operations to execute.\r\n * @param query.crud - Optional array of structured CRUD operations.\r\n * @param query.custom - Optional raw SQL query or array of raw SQL queries.\r\n *\r\n * @returns A promise resolving to the result returned by the PostgreSQL or\r\n * MySQL query executor. If the configured `SQL_DB_URL` does not represent a\r\n * supported database, an `Error` is returned.\r\n *\r\n * @example\r\n * // Insert a user.\r\n * //\r\n * // This operation is database-independent because the values are passed\r\n * // as an object and the underlying executor generates the appropriate SQL.\r\n * await executeQuery({\r\n * crud: [\r\n * {\r\n * insert_one: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * item: {\r\n * [CONSTANTS.USER_PRIMARY_ID]: generateUniqueValue(32),\r\n * [CONSTANTS.USER_NAME]: 'Divyanshu',\r\n * [CONSTANTS.USER_EMAIL]: 'div@example.com',\r\n * [CONSTANTS.USER_GENDER]: CONSTANTS.GENDER_TYPE.MALE,\r\n * },\r\n * },\r\n * },\r\n * ],\r\n * });\r\n *\r\n * @example\r\n * // Select a user by email.\r\n * //\r\n * // MySQL:\r\n * // condition: 'user_email = ?'\r\n * //\r\n * // PostgreSQL:\r\n * // condition: 'user_email = $1'\r\n * //\r\n * // The value is supplied separately through conditionalParams.\r\n * await executeQuery({\r\n * crud: [\r\n * {\r\n * select: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * columns: [\r\n * CONSTANTS.USER_PRIMARY_ID,\r\n * CONSTANTS.USER_NAME,\r\n * CONSTANTS.USER_EMAIL,\r\n * ],\r\n * condition: 'user_email = ?',\r\n * conditionalParams: ['div@example.com'],\r\n * },\r\n * },\r\n * ],\r\n * });\r\n *\r\n * @example\r\n * // Update a user's information.\r\n * //\r\n * // MySQL:\r\n * // condition: 'user_primary_id = ?'\r\n * //\r\n * // PostgreSQL:\r\n * // condition: 'user_primary_id = $1'\r\n * await executeQuery({\r\n * crud: [\r\n * {\r\n * update: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * item: {\r\n * [CONSTANTS.USER_NAME]: 'Div',\r\n * [CONSTANTS.USER_PHONE_NUMBER]: '+1234567890',\r\n * },\r\n * condition: 'user_primary_id = ?',\r\n * conditionalParams: [\r\n * '550e8400-e29b-41d4-a716-446655440000',\r\n * ],\r\n * },\r\n * },\r\n * ],\r\n * });\r\n *\r\n * @example\r\n * // Delete a user.\r\n * //\r\n * // Replace `?` with `$1` when using PostgreSQL.\r\n * await executeQuery({\r\n * crud: [\r\n * {\r\n * delete: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * condition: 'user_primary_id = ?',\r\n * conditionalParams: [\r\n * '550e8400-e29b-41d4-a716-446655440000',\r\n * ],\r\n * },\r\n * },\r\n * ],\r\n * });\r\n *\r\n * @example\r\n * // Execute a raw SQL query.\r\n * //\r\n * // MySQL:\r\n * // query: 'SELECT * FROM user_infos WHERE user_email = ?'\r\n * //\r\n * // PostgreSQL:\r\n * // query: 'SELECT * FROM user_infos WHERE user_email = $1'\r\n * await executeQuery({\r\n * custom: {\r\n * query: 'SELECT * FROM user_infos WHERE user_email = ?',\r\n * params: ['div@example.com'],\r\n * },\r\n * });\r\n *\r\n * @example\r\n * // Execute multiple operations in one call.\r\n * //\r\n * // The underlying executor handles the operations according to the\r\n * // configured database engine.\r\n * await executeQuery({\r\n * crud: [\r\n * {\r\n * insert_one: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * item: {\r\n * [CONSTANTS.USER_PRIMARY_ID]: generateUniqueValue(32),\r\n * [CONSTANTS.USER_NAME]: 'Alice',\r\n * [CONSTANTS.USER_EMAIL]: 'alice@example.com',\r\n * },\r\n * },\r\n * },\r\n * {\r\n * update: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * item: {\r\n * status: 'active',\r\n * },\r\n * condition: 'user_email = ?',\r\n * conditionalParams: ['alice@example.com'],\r\n * },\r\n * },\r\n * ],\r\n * });\r\n */\r\nexport const executeQuery = async (query: QueryItems) => {\r\n\r\n if (isPostgreSQL(ENV.SQL_DB_URL)) {\r\n return await executePgSqlQuery(query)\r\n }\r\n else if (isMySQL(ENV.SQL_DB_URL)) {\r\n return await executeMySqlQuery(query)\r\n }\r\n else {\r\n return new Error(`Unable to execute query. Please check the SQL_DB_URL in .env file and the db.sql file.`);\r\n }\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Returns the connection pool for the SQL database configured through\r\n * the `SQL_DB_URL` environment variable.\r\n *\r\n * The database type is detected automatically from the connection URL.\r\n * If the URL represents a PostgreSQL database, the PostgreSQL connection\r\n * pool is returned. If it represents a MySQL database, the MySQL connection\r\n * pool is returned.\r\n *\r\n * This function acts as the database-agnostic entry point for obtaining\r\n * the application's SQL connection pool. Callers do not need to know\r\n * whether the application is currently using PostgreSQL or MySQL.\r\n *\r\n * The underlying pool is created lazily and reused across subsequent\r\n * calls through `getPgSqlPool()` or `getMySqlPool()`.\r\n *\r\n * @returns A promise resolving to the PostgreSQL or MySQL connection pool,\r\n * depending on the configured `SQL_DB_URL`. Returns `undefined` if the\r\n * configured database URL does not match a supported SQL database.\r\n *\r\n * @example\r\n * // Get the configured SQL connection pool.\r\n * const pool = await getPool();\r\n *\r\n * if (!pool) {\r\n * throw new Error('Unsupported SQL database configuration.');\r\n * }\r\n *\r\n * @example\r\n * // The same function works regardless of whether the application\r\n * // is configured to use PostgreSQL or MySQL.\r\n * const pool = await getPool();\r\n *\r\n * if (pool) {\r\n * // Use the returned pool with the appropriate database layer.\r\n * console.log('Database pool is ready.');\r\n * }\r\n */\r\nexport const getPool = async () => {\r\n if (isPostgreSQL(ENV.SQL_DB_URL)) {\r\n return getPgSqlPool()\r\n }\r\n if (isMySQL(ENV.SQL_DB_URL)) {\r\n return getMySqlPool()\r\n }\r\n}\r\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/utility/utilis/postgres/executeQuery.ts"],"sourcesContent":["import type {QueryItems} from \"../../libs/interface.js\";\r\nimport {isMySQL, isPostgreSQL} from \"../general/sqlDb.js.js\";\r\nimport {ENV} from \"../../libs/env.js\";\r\nimport {executePgSqlQuery} from \"./subSqlfiles/executePgQuery.js\";\r\nimport {executeMySqlQuery} from \"./subSqlfiles/executeMySqlQuery.js\";\r\nimport {getMySqlPool} from \"../../../engine/sql/mySql.js\";\r\nimport {getPgSqlPool} from \"../../../engine/sql/pgSql.js\";\r\n\r\n\r\n\r\n\r\n/**\r\n * Executes one or more SQL queries using the database configured through\r\n * the `SQL_DB_URL` environment variable.\r\n *\r\n * The function automatically detects whether the configured database is\r\n * PostgreSQL or MySQL and delegates execution to the appropriate database\r\n * implementation.\r\n *\r\n * Supports structured CRUD operations (`insert_one`, `insert_many`, `select`,\r\n * `update`, and `delete`) as well as custom raw SQL queries.\r\n *\r\n * Parameterized conditions and raw queries are supported. The placeholder\r\n * syntax must match the configured database engine:\r\n *\r\n * - MySQL uses `?` placeholders.\r\n * - PostgreSQL uses `$1`, `$2`, `$3`, etc.\r\n *\r\n * The corresponding values are supplied through `conditionalParams` for\r\n * structured CRUD operations or `params` for raw SQL queries.\r\n *\r\n * @param query - The SQL operations to execute.\r\n * @param query.crud - Optional array of structured CRUD operations.\r\n * @param query.custom - Optional raw SQL query or array of raw SQL queries.\r\n *\r\n * @returns A promise resolving to the result returned by the PostgreSQL or\r\n * MySQL query executor. If the configured `SQL_DB_URL` does not represent a\r\n * supported database, an `Error` is returned.\r\n *\r\n * @example\r\n * // Insert a user.\r\n * //\r\n * // This operation is database-independent because the values are passed\r\n * // as an object and the underlying executor generates the appropriate SQL.\r\n * await executeQuery({\r\n * crud: [\r\n * {\r\n * insert_one: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * item: {\r\n * [CONSTANTS.USER_PRIMARY_ID]: generateUniqueValue(32),\r\n * [CONSTANTS.USER_NAME]: 'Divyanshu',\r\n * [CONSTANTS.USER_EMAIL]: 'div@example.com',\r\n * [CONSTANTS.USER_GENDER]: CONSTANTS.GENDER_TYPE.MALE,\r\n * },\r\n * },\r\n * },\r\n * ],\r\n * });\r\n *\r\n * @example\r\n * // Select a user by email.\r\n * //\r\n * // MySQL:\r\n * // condition: 'user_email = ?'\r\n * //\r\n * // PostgreSQL:\r\n * // condition: 'user_email = $1'\r\n * //\r\n * // The value is supplied separately through conditionalParams.\r\n * await executeQuery({\r\n * crud: [\r\n * {\r\n * select: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * columns: [\r\n * CONSTANTS.USER_PRIMARY_ID,\r\n * CONSTANTS.USER_NAME,\r\n * CONSTANTS.USER_EMAIL,\r\n * ],\r\n * condition: 'user_email = ?',\r\n * conditionalParams: ['div@example.com'],\r\n * },\r\n * },\r\n * ],\r\n * });\r\n *\r\n * @example\r\n * // Update a user's information.\r\n * //\r\n * // MySQL:\r\n * // condition: 'user_primary_id = ?'\r\n * //\r\n * // PostgreSQL:\r\n * // condition: 'user_primary_id = $1'\r\n * await executeQuery({\r\n * crud: [\r\n * {\r\n * update: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * item: {\r\n * [CONSTANTS.USER_NAME]: 'Div',\r\n * [CONSTANTS.USER_PHONE_NUMBER]: '+1234567890',\r\n * },\r\n * condition: 'user_primary_id = ?',\r\n * conditionalParams: [\r\n * '550e8400-e29b-41d4-a716-446655440000',\r\n * ],\r\n * },\r\n * },\r\n * ],\r\n * });\r\n *\r\n * @example\r\n * // Delete a user.\r\n * //\r\n * // Replace `?` with `$1` when using PostgreSQL.\r\n * await executeQuery({\r\n * crud: [\r\n * {\r\n * delete: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * condition: 'user_primary_id = ?',\r\n * conditionalParams: [\r\n * '550e8400-e29b-41d4-a716-446655440000',\r\n * ],\r\n * },\r\n * },\r\n * ],\r\n * });\r\n *\r\n * @example\r\n * // Execute a raw SQL query.\r\n * //\r\n * // MySQL:\r\n * // query: 'SELECT * FROM user_infos WHERE user_email = ?'\r\n * //\r\n * // PostgreSQL:\r\n * // query: 'SELECT * FROM user_infos WHERE user_email = $1'\r\n * await executeQuery({\r\n * custom: {\r\n * query: 'SELECT * FROM user_infos WHERE user_email = ?',\r\n * params: ['div@example.com'],\r\n * },\r\n * });\r\n *\r\n * @example\r\n * // Execute multiple operations in one call.\r\n * //\r\n * // The underlying executor handles the operations according to the\r\n * // configured database engine.\r\n * await executeQuery({\r\n * crud: [\r\n * {\r\n * insert_one: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * item: {\r\n * [CONSTANTS.USER_PRIMARY_ID]: generateUniqueValue(32),\r\n * [CONSTANTS.USER_NAME]: 'Alice',\r\n * [CONSTANTS.USER_EMAIL]: 'alice@example.com',\r\n * },\r\n * },\r\n * },\r\n * {\r\n * update: {\r\n * table: CONSTANTS.USER_INFOS,\r\n * item: {\r\n * status: 'active',\r\n * },\r\n * condition: 'user_email = ?',\r\n * conditionalParams: ['alice@example.com'],\r\n * },\r\n * },\r\n * ],\r\n * });\r\n */\r\nexport const executeQuery = async (query: QueryItems) => {\r\n\r\n if (isPostgreSQL(ENV.SQL_DB_URL)) {\r\n return await executePgSqlQuery(query)\r\n }\r\n else if (isMySQL(ENV.SQL_DB_URL)) {\r\n return await executeMySqlQuery(query)\r\n }\r\n else {\r\n return new Error(`Unable to execute query. Please check the SQL_DB_URL in .env file and the db.sql file.`);\r\n }\r\n\r\n}\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Returns the connection pool for the SQL database configured through\r\n * the `SQL_DB_URL` environment variable.\r\n *\r\n * The database type is detected automatically from the connection URL.\r\n * If the URL represents a PostgreSQL database, the PostgreSQL connection\r\n * pool is returned. If it represents a MySQL database, the MySQL connection\r\n * pool is returned.\r\n *\r\n * This function acts as the database-agnostic entry point for obtaining\r\n * the application's SQL connection pool. Callers do not need to know\r\n * whether the application is currently using PostgreSQL or MySQL.\r\n *\r\n * The underlying pool is created lazily and reused across subsequent\r\n * calls through `getPgSqlPool()` or `getMySqlPool()`.\r\n *\r\n * @returns A promise resolving to the PostgreSQL or MySQL connection pool,\r\n * depending on the configured `SQL_DB_URL`. Returns `undefined` if the\r\n * configured database URL does not match a supported SQL database.\r\n *\r\n * @example\r\n * // Get the configured SQL connection pool.\r\n * const pool = await getPool();\r\n *\r\n * if (!pool) {\r\n * throw new Error('Unsupported SQL database configuration.');\r\n * }\r\n *\r\n * @example\r\n * // The same function works regardless of whether the application\r\n * // is configured to use PostgreSQL or MySQL.\r\n * const pool = await getPool();\r\n *\r\n * if (pool) {\r\n * // Use the returned pool with the appropriate database layer.\r\n * console.log('Database pool is ready.');\r\n * }\r\n */\r\nexport const getPool = async () => {\r\n if (isPostgreSQL(ENV.SQL_DB_URL)) {\r\n return getPgSqlPool()\r\n }\r\n if (isMySQL(ENV.SQL_DB_URL)) {\r\n return getMySqlPool()\r\n }\r\n}\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgLO,IAAM,eAAe,8BAAO,UAAsB;AAErD,MAAI,aAAa,IAAI,UAAU,GAAG;AAC9B,WAAO,MAAM,kBAAkB,KAAK;AAAA,EACxC,WACS,QAAQ,IAAI,UAAU,GAAG;AAC9B,WAAO,MAAM,kBAAkB,KAAK;AAAA,EACxC,OACK;AACD,WAAO,IAAI,MAAM,wFAAwF;AAAA,EAC7G;AAEJ,GAZ4B;AAwDrB,IAAM,UAAU,mCAAY;AAC/B,MAAI,aAAa,IAAI,UAAU,GAAG;AAC9B,WAAO,aAAa;AAAA,EACxB;AACA,MAAI,QAAQ,IAAI,UAAU,GAAG;AACzB,WAAO,aAAa;AAAA,EACxB;AACJ,GAPuB;","names":[]}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
executeMySqlQuery
|
|
3
|
-
} from "../../../../chunk-
|
|
4
|
-
import "../../../../chunk-
|
|
3
|
+
} from "../../../../chunk-TP3K7DMH.js";
|
|
4
|
+
import "../../../../chunk-QVTKG7FD.js";
|
|
5
|
+
import "../../../../chunk-W3W3X2OE.js";
|
|
5
6
|
import "../../../../chunk-EWQYVPOL.js";
|
|
6
7
|
import "../../../../chunk-7QVYU63E.js";
|
|
7
8
|
export {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
executeCustom,
|
|
3
3
|
executePgSqlQuery
|
|
4
|
-
} from "../../../../chunk-
|
|
5
|
-
import "../../../../chunk-
|
|
4
|
+
} from "../../../../chunk-D7A4TEXY.js";
|
|
5
|
+
import "../../../../chunk-VFF4YFA3.js";
|
|
6
|
+
import "../../../../chunk-W3W3X2OE.js";
|
|
6
7
|
import "../../../../chunk-EWQYVPOL.js";
|
|
7
8
|
import "../../../../chunk-7QVYU63E.js";
|
|
8
9
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utility/utilis/server/app.ts"],"sourcesContent":["import EXPRESS_APP from \"../../../engine/server/app.js\";\r\n\r\nexport const getApp = () => {\r\n return EXPRESS_APP;\r\n}\r\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/utility/utilis/server/app.ts"],"sourcesContent":["import EXPRESS_APP from \"../../../engine/server/app.js\";\r\n\r\nexport const getApp = () => {\r\n return EXPRESS_APP;\r\n}\r\n"],"mappings":";;;;;;;;;;AAEO,IAAM,SAAS,6BAAM;AACxB,SAAO;AACX,GAFsB;","names":[]}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
HTTP_SERVER,
|
|
3
3
|
startServer
|
|
4
|
-
} from "../../../chunk-
|
|
5
|
-
import "../../../chunk-P5XJG7OG.js";
|
|
4
|
+
} from "../../../chunk-ICFMWIIJ.js";
|
|
6
5
|
import "../../../chunk-MNSQSU7T.js";
|
|
7
|
-
import "../../../chunk-
|
|
8
|
-
import "../../../chunk-
|
|
9
|
-
import "../../../chunk-
|
|
6
|
+
import "../../../chunk-P5XJG7OG.js";
|
|
7
|
+
import "../../../chunk-NIOLLLJJ.js";
|
|
8
|
+
import "../../../chunk-QVTKG7FD.js";
|
|
9
|
+
import "../../../chunk-VFF4YFA3.js";
|
|
10
|
+
import "../../../chunk-XBJ3SJ26.js";
|
|
11
|
+
import "../../../chunk-W3W3X2OE.js";
|
|
10
12
|
import "../../../chunk-EWQYVPOL.js";
|
|
11
|
-
import "../../../chunk-W2745SOE.js";
|
|
12
13
|
import {
|
|
13
14
|
__name
|
|
14
15
|
} from "../../../chunk-7QVYU63E.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/utility/utilis/server/server.ts"],"sourcesContent":["import {HTTP_SERVER, startServer} from \"../../../engine/server/server.js\";\r\n\r\n\r\nawait startServer();\r\n\r\n\r\nexport const getServer = () => {return HTTP_SERVER}\r\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../../src/utility/utilis/server/server.ts"],"sourcesContent":["import {HTTP_SERVER, startServer} from \"../../../engine/server/server.js\";\r\n\r\n\r\nawait startServer();\r\n\r\n\r\nexport const getServer = () => {return HTTP_SERVER}\r\n"],"mappings":";;;;;;;;;;;;;;;;;AAGA,MAAM,YAAY;AAGX,IAAM,YAAa,6BAAO;AAAC,SAAO;AAAW,GAA1B;","names":[]}
|
package/package.json
CHANGED
package/dist/chunk-3AP6JARL.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
// src/engine/cloudBucket/r2Storage.ts
|
|
2
|
-
import { S3Client } from "@aws-sdk/client-s3";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { pathToFileURL } from "url";
|
|
5
|
-
var s3ConfigFilePath = path.join(process.cwd(), "src", "config", "s3bucket.config.ts");
|
|
6
|
-
var { S3_BUCKET_CONFIG } = await import(pathToFileURL(s3ConfigFilePath).href);
|
|
7
|
-
var s3Client = new S3Client(S3_BUCKET_CONFIG);
|
|
8
|
-
|
|
9
|
-
export {
|
|
10
|
-
s3Client
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=chunk-3AP6JARL.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/engine/cloudBucket/r2Storage.ts"],"sourcesContent":["import { S3Client } from '@aws-sdk/client-s3';\r\nimport path from \"node:path\";\r\nimport {pathToFileURL} from \"node:url\";\r\n\r\n\r\n\r\nconst s3ConfigFilePath = path.join(process.cwd(), 'src', 'config', 's3bucket.config.ts');\r\nconst {S3_BUCKET_CONFIG} = await import(pathToFileURL(s3ConfigFilePath).href)\r\n\r\n\r\n\r\n\r\n\r\n\r\nexport const s3Client: S3Client = new S3Client(S3_BUCKET_CONFIG);\r\n"],"mappings":";AAAA,SAAS,gBAAgB;AACzB,OAAO,UAAU;AACjB,SAAQ,qBAAoB;AAI5B,IAAM,mBAAmB,KAAK,KAAK,QAAQ,IAAI,GAAG,OAAO,UAAU,oBAAoB;AACvF,IAAM,EAAC,iBAAgB,IAAI,MAAM,OAAO,cAAc,gBAAgB,EAAE;AAOjE,IAAM,WAAqB,IAAI,SAAS,gBAAgB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/engine/mondoDb/mongoDB.ts"],"sourcesContent":["import { ENV } from \"../../utility/libs/env.js\";\r\nimport { MongoClient, type MongoClientOptions } from 'mongodb';\r\nimport path from \"node:path\"\r\nimport {pathToFileURL} from \"node:url\";\r\n\r\n\r\nconst uri = ENV.MONGO_SERVER_URL;\r\nlet client: MongoClient | null = null;\r\n\r\n\r\nasync function connectToMongo(): Promise<MongoClient|undefined> {\r\n if (!uri) return;\r\n try {\r\n if (!client) {\r\n\r\n let options: MongoClientOptions;\r\n\r\n try {\r\n const mongoConfigFilePath= path.join(process.cwd(), \"src/config/mongo.config.ts\");\r\n const {MONGO_CLIENT_OPTIONS} = await import(pathToFileURL(mongoConfigFilePath).href);\r\n options = MONGO_CLIENT_OPTIONS || {};\r\n }\r\n catch (error) {\r\n options = {}\r\n }\r\n\r\n\r\n client = new MongoClient(uri, options);\r\n await client.connect();\r\n console.log(\"✅ Connected to MongoDB Cluster\");\r\n\r\n }\r\n return client;\r\n } catch (error) {\r\n console.error(\"❌ MongoDB Connection Error:\", error);\r\n throw error;\r\n }\r\n}\r\n\r\n\r\n\r\nfunction getMongoServer(): MongoClient {\r\n if (!client) {\r\n throw new Error(\"Call connectToMongo first!\");\r\n }\r\n return client;\r\n}\r\n\r\n\r\n\r\nexport { connectToMongo, getMongoServer };\r\n"],"mappings":";;;;;;;;AACA,SAAS,mBAA4C;AACrD,OAAO,UAAU;AACjB,SAAQ,qBAAoB;AAG5B,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,sBAAqB,KAAK,KAAK,QAAQ,IAAI,GAAG,4BAA4B;AAChF,cAAM,EAAC,qBAAoB,IAAI,MAAM,OAAO,cAAc,mBAAmB,EAAE;AAC/E,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;AA3Be;AA+Bf,SAAS,iBAA8B;AACrC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,4BAA4B;AAAA,EAC9C;AACA,SAAO;AACT;AALS;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/utility/utilis/general/file-operations.ts"],"sourcesContent":["import type {PathOptions} from \"../../libs/interface.js\";\r\nimport mime from \"mime-types\";\r\nimport {ENV} from \"../../libs/env.js\";\r\nimport {readFile} from \"node:fs/promises\";\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Extracts the file extension from a supported file input.\r\n *\r\n * Supports Express Multer files, Web API `File` objects, raw `Buffer` values,\r\n * and file paths or URLs. For URLs and paths, query parameters and hash\r\n * fragments are ignored when determining the extension.\r\n *\r\n * @param input - The file, buffer, path, or URL from which to extract the extension.\r\n * @returns The file extension without the leading dot, converted to lowercase.\r\n * Returns an empty string if no extension can be determined.\r\n *\r\n * @example\r\n * const extension = getFileExtension('https://example.com/files/image.PNG');\r\n * // Returns: \"png\"\r\n *\r\n * @example\r\n * const extension = getFileExtension(req.file);\r\n * // Returns: \"pdf\"\r\n *\r\n * @example\r\n * const extension = getFileExtension('documents/report.pdf?download=true');\r\n * // Returns: \"pdf\"\r\n *\r\n * @example\r\n * const extension = getFileExtension(buffer);\r\n * // Returns: \"\"\r\n */\r\nexport function getFileExtension(input: Express.Multer.File | File | Buffer | string): string {\r\n // 1. If it's a raw Buffer, it has no file name/extension metadata\r\n if (Buffer.isBuffer(input)) {\r\n return '';\r\n }\r\n\r\n // 2. Extract the filename string based on the input type\r\n let filename = '';\r\n\r\n if (typeof input === 'string') {\r\n filename = input;\r\n }\r\n else if ('originalname' in input && input.originalname) {\r\n // Express.Multer.File\r\n filename = input.originalname;\r\n }\r\n else if ('name' in input && input.name) {\r\n // Web API File\r\n filename = input.name;\r\n }\r\n\r\n if (!filename) {\r\n return '';\r\n }\r\n\r\n // 3. Remove URL query parameters or hashes (if a URL/path string is passed)\r\n const cleanFilename = filename.split(/[?#]/)[0] as string;\r\n\r\n // 4. Extract the last segment after the final dot\r\n const match = cleanFilename.match(/\\.([^./\\\\]+)$/);\r\n\r\n return match?.[1]?.toLowerCase() ?? '';\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Builds a normalized file path from the provided path components.\r\n *\r\n * Combines the path prefix, path segments, path postfix, and file name,\r\n * while removing empty values and normalizing redundant slashes.\r\n *\r\n * If `fileName` is a Web API `File` object, its `name` property is used.\r\n *\r\n * @param options - The path components used to construct the final path.\r\n * @param options.path_prefix - An optional prefix to prepend to the path.\r\n * @param options.path - An array of path segments.\r\n * @param options.path_postfix - An optional postfix to append before the file name.\r\n * @param options.fileName - The file name or a Web API `File` object.\r\n * @returns A normalized path with components separated by a single slash.\r\n *\r\n * @example\r\n * const filePath = buildPath({\r\n * path_prefix: 'uploads',\r\n * path: ['documents', 'reports'],\r\n * fileName: 'report.pdf',\r\n * });\r\n * // Returns: \"uploads/documents/reports/report.pdf\"\r\n *\r\n * @example\r\n * const filePath = buildPath({\r\n * path: ['documents//', '/reports/'],\r\n * fileName: 'report.pdf',\r\n * });\r\n * // Returns: \"documents/reports/report.pdf\"\r\n */\r\nexport function buildPath({\r\n path_prefix = '',\r\n path = [],\r\n path_postfix = '',\r\n fileName,\r\n }: PathOptions): string {\r\n // Extract string name if fileName is a File object\r\n const resolvedFileName =\r\n fileName instanceof File ? fileName.name : fileName ?? '';\r\n\r\n // Combine all segments into a single array\r\n const allSegments = [\r\n path_prefix,\r\n ...path,\r\n path_postfix,\r\n resolvedFileName,\r\n ];\r\n\r\n return allSegments\r\n // Filter out null/undefined/empty string items\r\n .filter((segment): segment is string => Boolean(segment && segment.trim()))\r\n // Clean leading/trailing slashes from individual segments\r\n .map((segment) => segment.replace(/^\\/+|\\/+$/g, ''))\r\n // Remove any extra slashes inside a segment (e.g. \"folder//subfolder\")\r\n .map((segment) => segment.replace(/\\/+/g, '/'))\r\n // Filter again in case cleaning left an empty string\r\n .filter((segment) => segment.length > 0)\r\n // Join with a single slash\r\n .join('/');\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Builds the local file path for a downloaded file.\r\n *\r\n * Removes any occurrence of the configured in-app bucket from the provided\r\n * path to prevent duplicating the bucket name, then constructs the final\r\n * path using the configured in-app bucket as the path prefix.\r\n *\r\n * @param options - The path and file name options used to build the downloaded file path.\r\n * @param options.path - The path segments leading to the file.\r\n * @param options.fileName - The name of the file or a Web API `File` object.\r\n * @returns The complete local path for the downloaded file.\r\n *\r\n * @example\r\n * const filePath = downloadedFilePath({\r\n * path: ['documents', 'reports'],\r\n * fileName: 'report.pdf',\r\n * });\r\n * // Returns a path prefixed with ENV.IN_APP_BUCKET.\r\n *\r\n * @example\r\n * const filePath = downloadedFilePath({\r\n * path: [ENV.IN_APP_BUCKET, 'documents'],\r\n * fileName: file,\r\n * });\r\n * // The duplicate bucket segment is removed before building the path.\r\n */\r\nexport function downloadedFilePath({path = [], fileName}: PathOptions): string {\r\n // Filter out any occurrence of ENV.IN_APP_BUCKET (case-sensitive or trimmed)\r\n const cleanedPath = path.filter((segment) => segment !== ENV.IN_APP_BUCKET);\r\n\r\n return buildPath({\r\n path_prefix: ENV.IN_APP_BUCKET,\r\n fileName: fileName instanceof File ? fileName.name : fileName ?? '',\r\n path: cleanedPath,\r\n });\r\n}\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Determines the MIME content type of a file from its available metadata\r\n * or, when given a file path or URL, from its file extension.\r\n *\r\n * Supports Express Multer files, Web API `File` objects, raw `Buffer` values,\r\n * and file paths or URLs.\r\n *\r\n * @param file - The file, buffer, path, or URL whose content type should be determined.\r\n * @returns A promise resolving to the detected MIME content type.\r\n *\r\n * @example\r\n * const contentType = await getFileContentType(req.file);\r\n * // Returns something like: \"image/jpeg\"\r\n *\r\n * @example\r\n * const contentType = await getFileContentType('/uploads/document.pdf');\r\n * // Returns: \"application/pdf\"\r\n *\r\n * @example\r\n * const contentType = await getFileContentType(buffer);\r\n * // Returns: \"application/octet-stream\"\r\n */\r\nexport const getFileContentType = async (\r\n file: Express.Multer.File | File | Buffer | string\r\n): Promise<string> => {\r\n // 1. Raw Buffer: Buffers don't carry MIME metadata, so default to octet-stream\r\n if (Buffer.isBuffer(file)) {\r\n return 'application/octet-stream';\r\n }\r\n\r\n // 2. String path or URL: Look up MIME type based on extension/filename\r\n if (typeof file === 'string') {\r\n const detectedType = mime.lookup(file);\r\n return detectedType || 'application/octet-stream';\r\n }\r\n\r\n // 3. Express.Multer.File: Has 'mimetype' property\r\n if ('mimetype' in file && file.mimetype) {\r\n return file.mimetype;\r\n }\r\n\r\n // 4. Web API File: Has 'type' property\r\n if ('type' in file && file.type) {\r\n return file.type;\r\n }\r\n\r\n // 5. Fallback if object has no recognizable MIME type\r\n return 'application/octet-stream';\r\n};\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Determines whether the provided value is a URL or a local/server based file path.\r\n *\r\n * If the value is a valid HTTP/HTTPS URL, the configured URL environment\r\n * value is returned. Otherwise, the configured local path environment value\r\n * is returned.\r\n *\r\n * @param val - The URL or local file path to evaluate.\r\n * @returns The configured URL or local path based on the input type.\r\n *\r\n * @example\r\n * const basePath = url_or_path('https://example.com/file.png');\r\n * // Returns ENV.URL\r\n *\r\n * @example\r\n * const basePath = url_or_path('/uploads/file.png');\r\n * // Returns ENV.PATH\r\n */\r\nexport const url_or_path = (val: string): string => {\r\n try {\r\n const parsed = new URL(val);\r\n if (parsed.protocol === \"http:\" || parsed.protocol === \"https:\") {\r\n return ENV.URL;\r\n }\r\n } catch {\r\n // If new URL() throws, it is a local path\r\n }\r\n return ENV.PATH;\r\n};\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n/**\r\n * Safely normalizes Buffer, Express.Multer.File, Web File, or File Path into Uint8Array\r\n */\r\nexport async function toUint8Array(file: Express.Multer.File | File | Buffer | string): Promise<Uint8Array> {\r\n if (typeof file === \"string\") {\r\n // File path on disk\r\n return await readFile(file);\r\n }\r\n\r\n if (Buffer.isBuffer(file)) {\r\n // Raw Node.js Buffer\r\n return new Uint8Array(file);\r\n }\r\n\r\n if (\"buffer\" in file && Buffer.isBuffer(file.buffer)) {\r\n // Express.Multer.File (Memory storage)\r\n return new Uint8Array(file.buffer);\r\n }\r\n\r\n if (\"path\" in file && typeof file.path === \"string\") {\r\n // Express.Multer.File (Disk storage)\r\n return await readFile(file.path);\r\n }\r\n\r\n if (\"arrayBuffer\" in file && typeof file.arrayBuffer === \"function\") {\r\n // Web API File / Blob\r\n return new Uint8Array(await file.arrayBuffer());\r\n }\r\n\r\n throw new Error(\"Unable to parse file input into a valid binary buffer.\");\r\n}\r\n\r\n\r\n\r\n\r\n\r\n"],"mappings":";;;;;;;;AACA,OAAO,UAAU;AAEjB,SAAQ,gBAAe;AA2ChB,SAAS,iBAAiB,OAA6D;AAE1F,MAAI,OAAO,SAAS,KAAK,GAAG;AACxB,WAAO;AAAA,EACX;AAGA,MAAI,WAAW;AAEf,MAAI,OAAO,UAAU,UAAU;AAC3B,eAAW;AAAA,EACf,WACS,kBAAkB,SAAS,MAAM,cAAc;AAEpD,eAAW,MAAM;AAAA,EACrB,WACS,UAAU,SAAS,MAAM,MAAM;AAEpC,eAAW,MAAM;AAAA,EACrB;AAEA,MAAI,CAAC,UAAU;AACX,WAAO;AAAA,EACX;AAGA,QAAM,gBAAgB,SAAS,MAAM,MAAM,EAAE,CAAC;AAG9C,QAAM,QAAQ,cAAc,MAAM,eAAe;AAEjD,SAAO,QAAQ,CAAC,GAAG,YAAY,KAAK;AACxC;AAhCg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W,OAAO,aAAa,UAAU;AAC7D,aAAO,IAAI;AAAA,IACf;AAAA,EACJ,QAAQ;AAAA,EAER;AACA,SAAO,IAAI;AACf,GAV2B;AA2B3B,eAAsB,aAAa,MAAyE;AACxG,MAAI,OAAO,SAAS,UAAU;AAE1B,WAAO,MAAM,SAAS,IAAI;AAAA,EAC9B;AAEA,MAAI,OAAO,SAAS,IAAI,GAAG;AAEvB,WAAO,IAAI,WAAW,IAAI;AAAA,EAC9B;AAEA,MAAI,YAAY,QAAQ,OAAO,SAAS,KAAK,MAAM,GAAG;AAElD,WAAO,IAAI,WAAW,KAAK,MAAM;AAAA,EACrC;AAEA,MAAI,UAAU,QAAQ,OAAO,KAAK,SAAS,UAAU;AAEjD,WAAO,MAAM,SAAS,KAAK,IAAI;AAAA,EACnC;AAEA,MAAI,iBAAiB,QAAQ,OAAO,KAAK,gBAAgB,YAAY;AAEjE,WAAO,IAAI,WAAW,MAAM,KAAK,YAAY,CAAC;AAAA,EAClD;AAEA,QAAM,IAAI,MAAM,wDAAwD;AAC5E;AA3BsB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/engine/sql/mySql.ts"],"sourcesContent":["// mySql.ts\r\nimport mysql from 'mysql2/promise';\r\nimport dotenv from 'dotenv';\r\nimport fs from 'fs/promises';\r\nimport path from \"node:path\"\r\nimport {pathToFileURL} from \"node:url\";\r\nimport {ENV} from \"../../utility/libs/env.js\";\r\n\r\n\r\ndotenv.config();\r\nlet pool: mysql.Pool | null = null;\r\n\r\n\r\n\r\n\r\n\r\nexport async function getMySqlPool(): Promise<mysql.Pool> {\r\n if (!pool) {\r\n\r\n let options: mysql.PoolOptions;\r\n\r\n try {\r\n const mySqlConfigFile = path.join(process.cwd(), \"src/config/mySql.config.ts\");\r\n const {MYSQL_POOL_OPTIONS} = await import(pathToFileURL(mySqlConfigFile).href);\r\n options = MYSQL_POOL_OPTIONS || {};\r\n options.uri = ENV.SQL_DB_URL\r\n }\r\n catch (error) {\r\n options = {};\r\n }\r\n\r\n pool = mysql.createPool(options);\r\n\r\n // Test connection on startup\r\n pool.getConnection()\r\n .then(conn => {\r\n console.log('✅ MySQL Database connected successfully');\r\n conn.release();\r\n })\r\n .catch(err => {\r\n console.error('❌ Failed to connect to MySQL:', err.message);\r\n process.exit(1);\r\n });\r\n\r\n // Connection event\r\n pool.on('connection', (connection) => {\r\n console.log('🔌 New MySQL connection established');\r\n });\r\n\r\n // Acquire event (when connection is acquired from pool)\r\n pool.on('acquire', (connection) => {\r\n console.log('📥 MySQL connection acquired');\r\n });\r\n\r\n // Enqueue event (when connection is queued)\r\n pool.on('enqueue', () => {\r\n console.log('⏳ MySQL connection queued');\r\n });\r\n\r\n // Release event (when connection is released back to pool)\r\n pool.on('release', (connection) => {\r\n console.log('📤 MySQL connection released');\r\n });\r\n }\r\n\r\n return pool;\r\n}\r\n\r\n\r\n\r\n\r\nexport const runMySqlScript = async () => {\r\n try {\r\n const fileQuery = await fs.readFile('db.sql', 'utf8');\r\n\r\n // Split queries for multiple statements\r\n const queries = fileQuery\r\n .split(';')\r\n .map(q => q.trim())\r\n .filter(q => q.length > 0);\r\n\r\n\r\n const mySqlPool = await getMySqlPool();\r\n\r\n const connection = await mySqlPool.getConnection();\r\n\r\n try {\r\n for (const query of queries) {\r\n await mySqlPool.query(query);\r\n }\r\n console.log(\"✅ Database schema created successfully\");\r\n } finally {\r\n connection.release();\r\n }\r\n } catch (err) {\r\n console.error('❌ Failed to execute SQL script:', err);\r\n throw err;\r\n }\r\n};\r\n\r\n\r\n\r\n\r\n\r\n\r\n// Graceful shutdown\r\nexport const closePool = async () => {\r\n if (pool) {\r\n console.log('Closing database pool...');\r\n await pool.end();\r\n console.log('Database pool closed');\r\n }\r\n};\r\n\r\n\r\n\r\n\r\n// Handle process termination\r\nprocess.on('SIGINT', async () => {\r\n await closePool();\r\n process.exit(0);\r\n});\r\n\r\n\r\n\r\n\r\nprocess.on('SIGTERM', async () => {\r\n await closePool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AAO,OAAK,EAAE,SAAS,CAAC;AAG7B,UAAM,YAAY,MAAM,aAAa;AAErC,UAAM,aAAa,MAAM,UAAU,cAAc;AAEjD,QAAI;AACA,iBAAW,SAAS,SAAS;AACzB,cAAM,UAAU,MAAM,KAAK;AAAA,MAC/B;AACA,cAAQ,IAAI,6CAAwC;AAAA,IACxD,UAAE;AACE,iBAAW,QAAQ;AAAA,IACvB;AAAA,EACJ,SAAS,KAAK;AACV,YAAQ,MAAM,wCAAmC,GAAG;AACpD,UAAM;AAAA,EACV;AACJ,GA3B8B;AAmCvB,IAAM,YAAY,mCAAY;AACjC,MAAI,MAAM;AACN,YAAQ,IAAI,0BAA0B;AACtC,UAAM,KAAK,IAAI;AACf,YAAQ,IAAI,sBAAsB;AAAA,EACtC;AACJ,GANyB;AAYzB,QAAQ,GAAG,UAAU,YAAY;AAC7B,QAAM,UAAU;AAChB,UAAQ,KAAK,CAAC;AAClB,CAAC;AAKD,QAAQ,GAAG,WAAW,YAAY;AAC9B,QAAM,UAAU;AAChB,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/engine/sql/pgSql.ts"],"sourcesContent":["// pgSql.ts\r\nimport pg from 'pg';\r\nimport dotenv from 'dotenv';\r\nimport {ENV} from \"../../utility/libs/env.js\";\r\nimport fs from 'fs/promises';\r\nimport path from \"node:path\";\r\nimport {pathToFileURL} from \"node:url\";\r\n\r\ndotenv.config();\r\n\r\nconst { Pool } = pg;\r\n\r\nlet pool: pg.Pool | null = null;\r\n\r\nexport async function getPgSqlPool(): Promise<pg.Pool> {\r\n if (!pool) {\r\n\r\n let options: pg.PoolConfig;\r\n\r\n try {\r\n const mySqlConfigFile = path.join(process.cwd(), \"src/config/pgSql.config.ts\");\r\n const {PGSQL_POOL_OPTIONS} = await import(pathToFileURL(mySqlConfigFile).href);\r\n options = PGSQL_POOL_OPTIONS || {};\r\n options.connectionString = ENV.SQL_DB_URL\r\n }\r\n catch (error) {\r\n options = {};\r\n }\r\n\r\n pool = new Pool(options);\r\n\r\n // Test connection on startup\r\n pool.connect()\r\n .then(client => {\r\n console.log('✅ PostgreSQL Database connected successfully');\r\n client.release();\r\n })\r\n .catch(err => {\r\n console.error('❌ Failed to connect to PostgreSQL:', err.message);\r\n process.exit(1);\r\n });\r\n\r\n pool.on('connect', () => {\r\n console.log('🔌 New PostgreSQL connection established');\r\n });\r\n\r\n pool.on('error', (err: Error) => {\r\n console.error('❌ Unexpected PostgreSQL error:', err.message);\r\n });\r\n }\r\n\r\n return pool;\r\n}\r\n\r\nexport const runPgSqlScript = async () => {\r\n try {\r\n const fileQuery = await fs.readFile('db.sql', 'utf8');\r\n\r\n // Split queries for multiple statements\r\n const queries = fileQuery\r\n .split(';')\r\n .map(q => q.trim())\r\n .filter(q => q.length > 0);\r\n\r\n const client = await (await getPgSqlPool()).connect();\r\n\r\n try {\r\n // Run all queries in a transaction\r\n await client.query('BEGIN');\r\n\r\n for (const query of queries) {\r\n await client.query(query);\r\n }\r\n\r\n await client.query('COMMIT');\r\n console.log(\"✅ Database schema created successfully\");\r\n } catch (err) {\r\n await client.query('ROLLBACK');\r\n throw err;\r\n } finally {\r\n client.release();\r\n }\r\n } catch (err) {\r\n console.error('❌ Failed to execute SQL script:', err);\r\n throw err;\r\n }\r\n};\r\n\r\n// Graceful shutdown\r\nexport const closePgPool = async () => {\r\n if (pool) {\r\n console.log('🔄 Closing PostgreSQL pool...');\r\n await pool.end();\r\n pool = null;\r\n console.log('✅ PostgreSQL pool closed');\r\n }\r\n};\r\n\r\n// Handle process termination\r\nprocess.on('SIGINT', async () => {\r\n await closePgPool();\r\n process.exit(0);\r\n});\r\n\r\nprocess.on('SIGTERM', async () => {\r\n await closePgPool();\r\n process.exit(0);\r\n});\r\n"],"mappings":";;;;;;;;AACA,OAAO,QAAQ;AACf,OAAO,YAAY;AAEnB,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAQ,qBA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wC;AAAA,IACxD,SAAS,KAAK;AACV,YAAM,OAAO,MAAM,UAAU;AAC7B,YAAM;AAAA,IACV,UAAE;AACE,aAAO,QAAQ;AAAA,IACnB;AAAA,EACJ,SAAS,KAAK;AACV,YAAQ,MAAM,wCAAmC,GAAG;AACpD,UAAM;AAAA,EACV;AACJ,GAhC8B;AAmCvB,IAAM,cAAc,mCAAY;AACnC,MAAI,MAAM;AACN,YAAQ,IAAI,sCAA+B;AAC3C,UAAM,KAAK,IAAI;AACf,WAAO;AACP,YAAQ,IAAI,+BAA0B;AAAA,EAC1C;AACJ,GAP2B;AAU3B,QAAQ,GAAG,UAAU,YAAY;AAC7B,QAAM,YAAY;AAClB,UAAQ,KAAK,CAAC;AAClB,CAAC;AAED,QAAQ,GAAG,WAAW,YAAY;AAC9B,QAAM,YAAY;AAClB,UAAQ,KAAK,CAAC;AAClB,CAAC;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/engine/server/server.ts"],"sourcesContent":["import app from \"./app.js\";\r\nimport {connectToMongo} from \"../mondoDb/mongoDB.js\";\r\nimport {ENV} from \"../../utility/libs/env.js\";\r\nimport {runPgSqlScript} from \"../sql/pgSql.js\";\r\nimport {handleError} from \"../../utility/utilis/general/error_handler.js\";\r\nimport {isMySQL, isPostgreSQL} from \"../../utility/utilis/general/sqlDb.js.js\";\r\nimport {runMySqlScript} from \"../sql/mySql.js\";\r\nimport * as http from \"node:http\";\r\n\r\nimport path from \"node:path\"\r\nimport {pathToFileURL} from \"node:url\";\r\n\r\n\r\n\r\n\r\n\r\nconst PORT = ENV.SERVER_PORT;\r\nconst SQL_URL = ENV.SQL_DB_URL;\r\nexport const HTTP_SERVER = http.createServer(app);\r\n\r\n\r\n\r\n\r\n\r\nexport const startServer = async () => {\r\n try {\r\n\r\n if (isPostgreSQL(SQL_URL)) {\r\n await runPgSqlScript()\r\n }\r\n if (isMySQL(SQL_URL)) {\r\n await runMySqlScript()\r\n }\r\n\r\n await connectToMongo();\r\n\r\n try {\r\n const functionPath = path.join(process.cwd(), \"src/app/services/test.services.js\");\r\n const {testFunctions} = await import(pathToFileURL(functionPath).href);\r\n testFunctions()\r\n }\r\n catch {}\r\n\r\n HTTP_SERVER.listen(PORT, () => {\r\n console.log(`Server running on port ${PORT}`);\r\n });\r\n }\r\n catch(err) {\r\n handleError(err)\r\n }\r\n\r\n};\r\n\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAOA,YAAY,UAAU;AAEtB,OAAO,UAAU;AACjB,SAAQ,qBAAoB;AAM5B,IAAM,OAAO,IAAI;AACjB,IAAM,UAAU,IAAI;AACb,IAAM,cAAmB,kBAAa,WAAG;AAMzC,IAAM,cAAc,mCAAY;AACnC,MAAI;AAEA,QAAI,aAAa,OAAO,GAAG;AACvB,YAAM,eAAe;AAAA,IACzB;AACA,QAAI,QAAQ,OAAO,GAAG;AAClB,YAAM,eAAe;AAAA,IACzB;AAEA,UAAM,eAAe;AAErB,QAAI;AACA,YAAM,eAAe,KAAK,KAAK,QAAQ,IAAI,GAAG,mCAAmC;AACjF,YAAM,EAAC,cAAa,IAAI,MAAM,OAAO,cAAc,YAAY,EAAE;AACjE,oBAAc;AAAA,IAClB,QACM;AAAA,IAAC;AAEP,gBAAY,OAAO,MAAM,MAAM;AAC3B,cAAQ,IAAI,0BAA0B,IAAI,EAAE;AAAA,IAChD,CAAC;AAAA,EACL,SACM,KAAK;AACP,gBAAY,GAAG;AAAA,EACnB;AAEJ,GA3B2B;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/engine/script/run-all.ts"],"sourcesContent":["import {execSync} from \"node:child_process\";\nimport path from \"node:path\";\n\n\n\nexport function runAll() {\n execSync('docker-compose -f ./bucketConfigs/docker-compose.yml up -d', {\n cwd: process.cwd(),\n stdio: \"inherit\",\n })\n\n execSync(\"tsx \" + path.join(process.cwd() , \"node_modules/backfarm/dist/utility/utilis/server/server.js\"), {\n cwd: process.cwd(),\n stdio: \"inherit\",\n })\n\n}\n\n"],"mappings":";;;;;AAAA,SAAQ,gBAAe;AACvB,OAAO,UAAU;AAIV,SAAS,SAAS;AACrB,WAAS,8DAA8D;AAAA,IACnE,KAAK,QAAQ,IAAI;AAAA,IACjB,OAAO;AAAA,EACX,CAAC;AAED,WAAS,SAAS,KAAK,KAAK,QAAQ,IAAI,GAAI,4DAA4D,GAAG;AAAA,IACvG,KAAK,QAAQ,IAAI;AAAA,IACjB,OAAO;AAAA,EACX,CAAC;AAEL;AAXgB;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/engine/server/app.ts"],"sourcesContent":["import express, {type Application } from 'express';\r\nimport type {ApisInterface} from \"../../utility/libs/types.js\";\r\nimport path from \"node:path\";\r\nimport { pathToFileURL } from \"node:url\";\r\n\r\nconst apiPath = path.join(process.cwd(), \"src/apis/apis.ts\");\r\nconst configPath = path.join(process.cwd(), \"src/config/express.config.ts\");\r\nconst { APIS } = await import(pathToFileURL(apiPath).href);\r\nconst {express_configurations} = await import(pathToFileURL(configPath).href);\r\n\r\n\r\nconst app: Application = express();\r\nexpress_configurations(app)\r\n\r\n\r\nexport default app;\r\n\r\n\r\n\r\n\r\n\r\n// ======================== APIS ======================== //\r\n\r\n\r\n\r\n\r\n\r\n\r\nAPIS.forEach((api: ApisInterface) => {\r\n if ('get' in api) {\r\n const middleware = api.get.middleware\r\n ? (Array.isArray(api.get.middleware) ? api.get.middleware : [api.get.middleware])\r\n : [];\r\n app.get(api.get.endpoint, ...middleware, api.get.callable);\r\n }\r\n\r\n if ('post' in api) {\r\n const middleware = api.post.middleware\r\n ? (Array.isArray(api.post.middleware) ? api.post.middleware : [api.post.middleware])\r\n : [];\r\n app.post(api.post.endpoint, ...middleware, api.post.callable);\r\n }\r\n\r\n if ('put' in api) {\r\n const middleware = api.put.middleware\r\n ? (Array.isArray(api.put.middleware) ? api.put.middleware : [api.put.middleware])\r\n : [];\r\n app.put(api.put.endpoint, ...middleware, api.put.callable);\r\n }\r\n\r\n if ('delete' in api) {\r\n const middleware = api.delete.middleware\r\n ? (Array.isArray(api.delete.middleware) ? api.delete.middleware : [api.delete.middleware])\r\n : [];\r\n app.delete(api.delete.endpoint, ...middleware, api.delete.callable);\r\n }\r\n\r\n if ('patch' in api) {\r\n const middleware = api.patch.middleware\r\n ? (Array.isArray(api.patch.middleware) ? api.patch.middleware : [api.patch.middleware])\r\n : [];\r\n app.patch(api.patch.endpoint, ...middleware, api.patch.callable);\r\n }\r\n})\r\n\r\n\r\n\r\n\r\n"],"mappings":";AAAA,OAAO,aAAkC;AAEzC,OAAO,UAAU;AACjB,SAAS,qBAAqB;AAE9B,IAAM,UAAU,KAAK,KAAK,QAAQ,IAAI,GAAG,kBAAkB;AAC3D,IAAM,aAAa,KAAK,KAAK,QAAQ,IAAI,GAAG,8BAA8B;AAC1E,IAAM,EAAE,KAAK,IAAI,MAAM,OAAO,cAAc,OAAO,EAAE;AACrD,IAAM,EAAC,uBAAsB,IAAI,MAAM,OAAO,cAAc,UAAU,EAAE;AAGxE,IAAM,MAAmB,QAAQ;AACjC,uBAAuB,GAAG;AAG1B,IAAO,cAAQ;AAaf,KAAK,QAAQ,CAAC,QAAuB;AACjC,MAAI,SAAS,KAAK;AACd,UAAM,aAAa,IAAI,IAAI,aACpB,MAAM,QAAQ,IAAI,IAAI,UAAU,IAAI,IAAI,IAAI,aAAa,CAAC,IAAI,IAAI,UAAU,IAC7E,CAAC;AACP,QAAI,IAAI,IAAI,IAAI,UAAU,GAAG,YAAY,IAAI,IAAI,QAAQ;AAAA,EAC7D;AAEA,MAAI,UAAU,KAAK;AACf,UAAM,aAAa,IAAI,KAAK,aACrB,MAAM,QAAQ,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,aAAa,CAAC,IAAI,KAAK,UAAU,IAChF,CAAC;AACP,QAAI,KAAK,IAAI,KAAK,UAAU,GAAG,YAAY,IAAI,KAAK,QAAQ;AAAA,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