backfarm 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/dist/chunk-22GJTNKR.js +47 -0
  2. package/dist/chunk-22GJTNKR.js.map +1 -0
  3. package/dist/{chunk-XBJ3SJ26.js → chunk-2QNCQ5L5.js} +3 -3
  4. package/dist/chunk-2QNCQ5L5.js.map +1 -0
  5. package/dist/chunk-3DJ6GERS.js +17 -0
  6. package/dist/chunk-3DJ6GERS.js.map +1 -0
  7. package/dist/chunk-452DWS46.js +88 -0
  8. package/dist/chunk-452DWS46.js.map +1 -0
  9. package/dist/{chunk-UWIMSKL5.js → chunk-4L35JPDH.js} +2 -2
  10. package/dist/chunk-4L35JPDH.js.map +1 -0
  11. package/dist/{chunk-VFF4YFA3.js → chunk-5AJKFCEE.js} +3 -3
  12. package/dist/chunk-5AJKFCEE.js.map +1 -0
  13. package/dist/chunk-6BNQOIVA.js +34 -0
  14. package/dist/chunk-6BNQOIVA.js.map +1 -0
  15. package/dist/{chunk-P5XJG7OG.js → chunk-A7GR4LD2.js} +1 -1
  16. package/dist/chunk-A7GR4LD2.js.map +1 -0
  17. package/dist/chunk-EEQ2SXDE.js +32 -0
  18. package/dist/chunk-EEQ2SXDE.js.map +1 -0
  19. package/dist/chunk-EUWCMMGI.js +35 -0
  20. package/dist/chunk-EUWCMMGI.js.map +1 -0
  21. package/dist/chunk-HC4IDQP6.js +89 -0
  22. package/dist/chunk-HC4IDQP6.js.map +1 -0
  23. package/dist/{chunk-QVTKG7FD.js → chunk-HV3IQJH3.js} +3 -3
  24. package/dist/chunk-HV3IQJH3.js.map +1 -0
  25. package/dist/{chunk-X3R3RLXY.js → chunk-IZEPCXYK.js} +1 -1
  26. package/dist/chunk-IZEPCXYK.js.map +1 -0
  27. package/dist/{chunk-YTBSGKGF.js → chunk-J3P6W53K.js} +2 -2
  28. package/dist/chunk-J3P6W53K.js.map +1 -0
  29. package/dist/{chunk-EWQYVPOL.js → chunk-LE2SDA4O.js} +1 -1
  30. package/dist/chunk-LE2SDA4O.js.map +1 -0
  31. package/dist/chunk-M7PVDT2D.js +60 -0
  32. package/dist/chunk-M7PVDT2D.js.map +1 -0
  33. package/dist/chunk-O2ZDXQ2Z.js +44 -0
  34. package/dist/chunk-O2ZDXQ2Z.js.map +1 -0
  35. package/dist/{chunk-MNSQSU7T.js → chunk-O5ILFRFV.js} +2 -2
  36. package/dist/chunk-O5ILFRFV.js.map +1 -0
  37. package/dist/chunk-O76OK6Y7.js +40 -0
  38. package/dist/chunk-O76OK6Y7.js.map +1 -0
  39. package/dist/{chunk-W3W3X2OE.js → chunk-QW2GGDEG.js} +54 -19
  40. package/dist/chunk-QW2GGDEG.js.map +1 -0
  41. package/dist/chunk-RZ7XHAUV.js +74 -0
  42. package/dist/chunk-RZ7XHAUV.js.map +1 -0
  43. package/dist/{chunk-TP3K7DMH.js → chunk-U7BCM2WN.js} +2 -2
  44. package/dist/chunk-U7BCM2WN.js.map +1 -0
  45. package/dist/chunk-UPP2FW3G.js +336 -0
  46. package/dist/chunk-UPP2FW3G.js.map +1 -0
  47. package/dist/chunk-YA3MW2CJ.js +33 -0
  48. package/dist/chunk-YA3MW2CJ.js.map +1 -0
  49. package/dist/{chunk-SSFPGDA3.js → chunk-ZC33GE2U.js} +5 -5
  50. package/dist/chunk-ZC33GE2U.js.map +1 -0
  51. package/dist/{chunk-D7A4TEXY.js → chunk-ZC6ZFZ2J.js} +2 -2
  52. package/dist/chunk-ZC6ZFZ2J.js.map +1 -0
  53. package/dist/{chunk-ZMDJ45KH.js → chunk-ZGOMCU4T.js} +7 -7
  54. package/dist/chunk-ZGOMCU4T.js.map +1 -0
  55. package/dist/chunk-ZTTB4NMA.js +18 -0
  56. package/dist/chunk-ZTTB4NMA.js.map +1 -0
  57. package/dist/engine/cloudBucket/r2Storage.js +3 -3
  58. package/dist/engine/mondoDb/mongoDB.js +3 -3
  59. package/dist/engine/multer/multer_configs.js +2 -2
  60. package/dist/engine/server/server.d.ts +5 -3
  61. package/dist/engine/server/server.js +30 -9
  62. package/dist/engine/sql/mySql.d.ts +2 -2
  63. package/dist/engine/sql/mySql.js +3 -3
  64. package/dist/engine/sql/pgSql.js +3 -3
  65. package/dist/utility/libs/env.js +1 -1
  66. package/dist/utility/libs/index.d.ts +1772 -0
  67. package/dist/utility/libs/index.js +101 -0
  68. package/dist/utility/libs/interface.d.ts +5 -7
  69. package/dist/utility/libs/run-all.js +46 -0
  70. package/dist/utility/libs/run-all.js.map +1 -0
  71. package/dist/{chunk-LFRKRR7G.js → utility/libs/run-bucket.js} +4 -7
  72. package/dist/utility/libs/run-bucket.js.map +1 -0
  73. package/dist/utility/libs/run-node-server.js +35 -0
  74. package/dist/utility/libs/run-node-server.js.map +1 -0
  75. package/dist/utility/libs/types.d.ts +11 -31
  76. package/dist/utility/libs/types.js +1 -1
  77. package/dist/utility/libs/types.js.map +1 -1
  78. package/dist/utility/utilis/cloud_storage/deleteFile.js +7 -54
  79. package/dist/utility/utilis/cloud_storage/deleteFile.js.map +1 -1
  80. package/dist/utility/utilis/cloud_storage/deleteFiles.js +7 -83
  81. package/dist/utility/utilis/cloud_storage/deleteFiles.js.map +1 -1
  82. package/dist/utility/utilis/cloud_storage/downloadFile.js +8 -68
  83. package/dist/utility/utilis/cloud_storage/downloadFile.js.map +1 -1
  84. package/dist/utility/utilis/cloud_storage/downloadFiles.js +8 -82
  85. package/dist/utility/utilis/cloud_storage/downloadFiles.js.map +1 -1
  86. package/dist/utility/utilis/cloud_storage/uploadFile.js +6 -6
  87. package/dist/utility/utilis/cloud_storage/uploadFiles.d.ts +0 -64
  88. package/dist/utility/utilis/cloud_storage/uploadFiles.js +9 -43
  89. package/dist/utility/utilis/cloud_storage/uploadFiles.js.map +1 -1
  90. package/dist/utility/utilis/general/error_handler.js +1 -1
  91. package/dist/utility/utilis/general/file-operations.d.ts +7 -132
  92. package/dist/utility/utilis/general/file-operations.js +6 -4
  93. package/dist/utility/utilis/general/sqlDb.js.d.ts +0 -141
  94. package/dist/utility/utilis/general/sqlDb.js.js +2 -2
  95. package/dist/utility/utilis/general/uuids.d.ts +0 -43
  96. package/dist/utility/utilis/general/uuids.js +1 -1
  97. package/dist/utility/utilis/general/web.d.ts +2 -238
  98. package/dist/utility/utilis/general/web.js +4 -4
  99. package/dist/utility/utilis/mongoDb/buldWrite.d.ts +0 -44
  100. package/dist/utility/utilis/mongoDb/buldWrite.js +6 -28
  101. package/dist/utility/utilis/mongoDb/buldWrite.js.map +1 -1
  102. package/dist/utility/utilis/mongoDb/deleteDocument.d.ts +0 -45
  103. package/dist/utility/utilis/mongoDb/deleteDocument.js +6 -30
  104. package/dist/utility/utilis/mongoDb/deleteDocument.js.map +1 -1
  105. package/dist/utility/utilis/mongoDb/insertField.d.ts +2 -33
  106. package/dist/utility/utilis/mongoDb/insertField.js +7 -30
  107. package/dist/utility/utilis/mongoDb/insertField.js.map +1 -1
  108. package/dist/utility/utilis/mongoDb/insertFields.d.ts +2 -41
  109. package/dist/utility/utilis/mongoDb/insertFields.js +7 -32
  110. package/dist/utility/utilis/mongoDb/insertFields.js.map +1 -1
  111. package/dist/utility/utilis/mongoDb/updateFiled.d.ts +0 -56
  112. package/dist/utility/utilis/mongoDb/updateFiled.js +6 -36
  113. package/dist/utility/utilis/mongoDb/updateFiled.js.map +1 -1
  114. package/dist/utility/utilis/multer/upload_batch.js +5 -12
  115. package/dist/utility/utilis/multer/upload_batch.js.map +1 -1
  116. package/dist/utility/utilis/multer/upload_single.d.ts +41 -0
  117. package/dist/utility/utilis/multer/upload_single.js +5 -11
  118. package/dist/utility/utilis/multer/upload_single.js.map +1 -1
  119. package/dist/utility/utilis/postgres/executeQuery.d.ts +2 -205
  120. package/dist/utility/utilis/postgres/executeQuery.js +11 -41
  121. package/dist/utility/utilis/postgres/executeQuery.js.map +1 -1
  122. package/dist/utility/utilis/postgres/subSqlfiles/executeMySqlQuery.js +4 -4
  123. package/dist/utility/utilis/postgres/subSqlfiles/executePgQuery.js +4 -4
  124. package/dist/utility/utilis/server/app.js +30 -12
  125. package/dist/utility/utilis/server/app.js.map +1 -1
  126. package/dist/utility/utilis/server/server.d.ts +2 -2
  127. package/dist/utility/utilis/server/server.js +30 -20
  128. package/dist/utility/utilis/server/server.js.map +1 -1
  129. package/package.json +55 -56
  130. package/dist/chunk-5A3RVJNT.js +0 -19
  131. package/dist/chunk-5A3RVJNT.js.map +0 -1
  132. package/dist/chunk-D7A4TEXY.js.map +0 -1
  133. package/dist/chunk-EWQYVPOL.js.map +0 -1
  134. package/dist/chunk-ICFMWIIJ.js +0 -53
  135. package/dist/chunk-ICFMWIIJ.js.map +0 -1
  136. package/dist/chunk-LFRKRR7G.js.map +0 -1
  137. package/dist/chunk-MNSQSU7T.js.map +0 -1
  138. package/dist/chunk-NIOLLLJJ.js +0 -44
  139. package/dist/chunk-NIOLLLJJ.js.map +0 -1
  140. package/dist/chunk-P5XJG7OG.js.map +0 -1
  141. package/dist/chunk-QVTKG7FD.js.map +0 -1
  142. package/dist/chunk-SSFPGDA3.js.map +0 -1
  143. package/dist/chunk-TP3K7DMH.js.map +0 -1
  144. package/dist/chunk-UWIMSKL5.js.map +0 -1
  145. package/dist/chunk-VFF4YFA3.js.map +0 -1
  146. package/dist/chunk-W3W3X2OE.js.map +0 -1
  147. package/dist/chunk-X3R3RLXY.js.map +0 -1
  148. package/dist/chunk-XBJ3SJ26.js.map +0 -1
  149. package/dist/chunk-YTBSGKGF.js.map +0 -1
  150. package/dist/chunk-YWFCWT6R.js +0 -23
  151. package/dist/chunk-YWFCWT6R.js.map +0 -1
  152. package/dist/chunk-ZMDJ45KH.js.map +0 -1
  153. package/dist/engine/script/run-all.d.ts +0 -3
  154. package/dist/engine/script/run-all.js +0 -8
  155. package/dist/engine/script/run-bucket.d.ts +0 -3
  156. package/dist/engine/script/run-bucket.js +0 -8
  157. package/dist/engine/script/run-bucket.js.map +0 -1
  158. package/dist/engine/script/run-node-server.d.ts +0 -3
  159. package/dist/engine/script/run-node-server.js +0 -8
  160. package/dist/engine/script/run-node-server.js.map +0 -1
  161. package/dist/engine/server/app.d.ts +0 -5
  162. package/dist/engine/server/app.js +0 -10
  163. package/dist/engine/server/app.js.map +0 -1
  164. package/dist/utility/script/run-all.js +0 -8
  165. package/dist/utility/script/run-all.js.map +0 -1
  166. package/dist/utility/script/run-bucket.js +0 -8
  167. package/dist/utility/script/run-bucket.js.map +0 -1
  168. package/dist/utility/script/run-node-server.js +0 -8
  169. package/dist/utility/script/run-node-server.js.map +0 -1
  170. package/dist/utility/utilis/cloud_storage/s3Client.d.ts +0 -5
  171. package/dist/utility/utilis/cloud_storage/s3Client.js +0 -17
  172. package/dist/utility/utilis/cloud_storage/s3Client.js.map +0 -1
  173. /package/dist/{engine/script/run-all.js.map → utility/libs/index.js.map} +0 -0
  174. /package/dist/utility/{script → libs}/run-all.d.ts +0 -0
  175. /package/dist/utility/{script → libs}/run-bucket.d.ts +0 -0
  176. /package/dist/utility/{script → libs}/run-node-server.d.ts +0 -0
@@ -0,0 +1,101 @@
1
+ import {
2
+ buildPath,
3
+ buildURL,
4
+ deleteFile,
5
+ deleteFiles,
6
+ detectSQLDatabase,
7
+ downloadFile,
8
+ downloadFiles,
9
+ executeQuery,
10
+ fileExistsAsync,
11
+ fileExistsSync,
12
+ generateUniqueValue,
13
+ getApp2 as getApp,
14
+ getFileContentType,
15
+ getFileExtension,
16
+ getInAppBucketDownloadPath,
17
+ getKeyFromUrl,
18
+ getPool,
19
+ getS3Client,
20
+ getServer2 as getServer,
21
+ handleError,
22
+ isMySQL,
23
+ isPostgreSQL,
24
+ mongoBulkWrite,
25
+ mongoDeleteDocument,
26
+ mongoInsertField,
27
+ mongoInsertFields,
28
+ mongoUpdateField,
29
+ responseToClient,
30
+ toUint8Array,
31
+ upload_batch,
32
+ upload_file,
33
+ upload_files,
34
+ upload_single,
35
+ url_or_path
36
+ } from "../../chunk-UPP2FW3G.js";
37
+ import "../../chunk-ZTTB4NMA.js";
38
+ import "../../chunk-3DJ6GERS.js";
39
+ import "../../chunk-EEQ2SXDE.js";
40
+ import "../../chunk-6BNQOIVA.js";
41
+ import "../../chunk-YA3MW2CJ.js";
42
+ import "../../chunk-EUWCMMGI.js";
43
+ import "../../chunk-O76OK6Y7.js";
44
+ import "../../chunk-22GJTNKR.js";
45
+ import "../../chunk-U7BCM2WN.js";
46
+ import "../../chunk-ZC6ZFZ2J.js";
47
+ import "../../chunk-452DWS46.js";
48
+ import "../../chunk-O2ZDXQ2Z.js";
49
+ import "../../chunk-ZGOMCU4T.js";
50
+ import "../../chunk-A7GR4LD2.js";
51
+ import "../../chunk-O5ILFRFV.js";
52
+ import "../../chunk-M7PVDT2D.js";
53
+ import "../../chunk-HC4IDQP6.js";
54
+ import "../../chunk-RZ7XHAUV.js";
55
+ import "../../chunk-IZEPCXYK.js";
56
+ import "../../chunk-ZC33GE2U.js";
57
+ import "../../chunk-J3P6W53K.js";
58
+ import "../../chunk-2QNCQ5L5.js";
59
+ import "../../chunk-4L35JPDH.js";
60
+ import "../../chunk-HV3IQJH3.js";
61
+ import "../../chunk-5AJKFCEE.js";
62
+ import "../../chunk-QW2GGDEG.js";
63
+ import "../../chunk-LE2SDA4O.js";
64
+ import "../../chunk-7QVYU63E.js";
65
+ export {
66
+ buildPath,
67
+ buildURL,
68
+ deleteFile,
69
+ deleteFiles,
70
+ detectSQLDatabase,
71
+ downloadFile,
72
+ downloadFiles,
73
+ executeQuery,
74
+ fileExistsAsync,
75
+ fileExistsSync,
76
+ generateUniqueValue,
77
+ getApp,
78
+ getFileContentType,
79
+ getFileExtension,
80
+ getInAppBucketDownloadPath,
81
+ getKeyFromUrl,
82
+ getPool,
83
+ getS3Client,
84
+ getServer,
85
+ handleError,
86
+ isMySQL,
87
+ isPostgreSQL,
88
+ mongoBulkWrite,
89
+ mongoDeleteDocument,
90
+ mongoInsertField,
91
+ mongoInsertFields,
92
+ mongoUpdateField,
93
+ responseToClient,
94
+ toUint8Array,
95
+ upload_batch,
96
+ upload_file,
97
+ upload_files,
98
+ upload_single,
99
+ url_or_path
100
+ };
101
+ //# sourceMappingURL=index.js.map
@@ -1,13 +1,11 @@
1
1
  import { AnyBulkWriteOperation, BulkWriteOptions, Filter, Document, DeleteOptions, OptionalUnlessRequiredId, InsertOneOptions, UpdateFilter, UpdateOptions, Sort } from 'mongodb';
2
- import { FileUploadedResponseData, SqlQuery, SqlRawQuery } from './types.js';
2
+ import { SqlQuery, SqlRawQuery, FileUploadedResponseData } from './types.js';
3
3
  import 'express';
4
4
  import './env.js';
5
5
 
6
- interface PathOptions {
7
- path_prefix?: string;
8
- path?: string[];
9
- path_postfix?: string;
10
- fileName?: string | File;
6
+ interface DownloadablePath {
7
+ segments?: string[];
8
+ fileName?: Express.Multer.File | File | Buffer | string;
11
9
  }
12
10
  interface URLOptions {
13
11
  end_point?: string;
@@ -111,4 +109,4 @@ interface QueryItems {
111
109
  custom?: SqlRawQuery | SqlRawQuery[];
112
110
  }
113
111
 
114
- export type { BulkWriteInterface, CustomErrorTemplate, DeleteDocuments, DeleteFile, DeleteFiles, DownloadFileParams, DownloadFilesParams, DownloadedFile, DownloadedFiles, FilesUploadedResponseData, GenerateIdOptions, InsertManyInterface, InsertOneInterface, PathOptions, QueryItems, URLOptions, UpdateDocument, UploadFileInput, UploadFilesInput };
112
+ export type { BulkWriteInterface, CustomErrorTemplate, DeleteDocuments, DeleteFile, DeleteFiles, DownloadFileParams, DownloadFilesParams, DownloadablePath, DownloadedFile, DownloadedFiles, FilesUploadedResponseData, GenerateIdOptions, InsertManyInterface, InsertOneInterface, QueryItems, URLOptions, UpdateDocument, UploadFileInput, UploadFilesInput };
@@ -0,0 +1,46 @@
1
+ import {
2
+ startServer
3
+ } from "../../chunk-UPP2FW3G.js";
4
+ import "../../chunk-ZTTB4NMA.js";
5
+ import "../../chunk-3DJ6GERS.js";
6
+ import "../../chunk-EEQ2SXDE.js";
7
+ import "../../chunk-6BNQOIVA.js";
8
+ import "../../chunk-YA3MW2CJ.js";
9
+ import "../../chunk-EUWCMMGI.js";
10
+ import "../../chunk-O76OK6Y7.js";
11
+ import "../../chunk-22GJTNKR.js";
12
+ import "../../chunk-U7BCM2WN.js";
13
+ import "../../chunk-ZC6ZFZ2J.js";
14
+ import "../../chunk-452DWS46.js";
15
+ import "../../chunk-O2ZDXQ2Z.js";
16
+ import "../../chunk-ZGOMCU4T.js";
17
+ import "../../chunk-A7GR4LD2.js";
18
+ import "../../chunk-O5ILFRFV.js";
19
+ import "../../chunk-M7PVDT2D.js";
20
+ import "../../chunk-HC4IDQP6.js";
21
+ import "../../chunk-RZ7XHAUV.js";
22
+ import "../../chunk-IZEPCXYK.js";
23
+ import "../../chunk-ZC33GE2U.js";
24
+ import "../../chunk-J3P6W53K.js";
25
+ import "../../chunk-2QNCQ5L5.js";
26
+ import "../../chunk-4L35JPDH.js";
27
+ import "../../chunk-HV3IQJH3.js";
28
+ import "../../chunk-5AJKFCEE.js";
29
+ import "../../chunk-QW2GGDEG.js";
30
+ import "../../chunk-LE2SDA4O.js";
31
+ import {
32
+ __name
33
+ } from "../../chunk-7QVYU63E.js";
34
+
35
+ // src/utility/libs/run-all.ts
36
+ import { execSync } from "child_process";
37
+ async function runAll() {
38
+ execSync("docker-compose -f ./bucketConfigs/docker-compose.yml up -d", {
39
+ cwd: process.cwd(),
40
+ stdio: "inherit"
41
+ });
42
+ await startServer();
43
+ }
44
+ __name(runAll, "runAll");
45
+ await runAll();
46
+ //# sourceMappingURL=run-all.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utility/libs/run-all.ts"],"sourcesContent":["import {execSync} from \"node:child_process\";\nimport {startServer} from \"../../engine/server/server.js\";\n\n\nasync function runAll() {\n\n\n execSync('docker-compose -f ./bucketConfigs/docker-compose.yml up -d', {\n cwd: process.cwd(),\n stdio: \"inherit\",\n })\n\n await startServer()\n\n}\n\n\nawait runAll();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,SAAQ,gBAAe;AAIvB,eAAe,SAAS;AAGpB,WAAS,8DAA8D;AAAA,IACnE,KAAK,QAAQ,IAAI;AAAA,IACjB,OAAO;AAAA,EACX,CAAC;AAED,QAAM,YAAY;AAEtB;AAVe;AAaf,MAAM,OAAO;","names":[]}
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  __name
3
- } from "./chunk-7QVYU63E.js";
3
+ } from "../../chunk-7QVYU63E.js";
4
4
 
5
- // src/engine/script/run-bucket.ts
5
+ // src/utility/libs/run-bucket.ts
6
6
  import { execSync } from "child_process";
7
7
  function runBucket() {
8
8
  execSync("docker-compose -f ./bucketConfigs/docker-compose.yml up", {
@@ -11,8 +11,5 @@ function runBucket() {
11
11
  });
12
12
  }
13
13
  __name(runBucket, "runBucket");
14
-
15
- export {
16
- runBucket
17
- };
18
- //# sourceMappingURL=chunk-LFRKRR7G.js.map
14
+ runBucket();
15
+ //# sourceMappingURL=run-bucket.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utility/libs/run-bucket.ts"],"sourcesContent":["import {execSync} from \"node:child_process\";\n\nfunction runBucket() {\n execSync('docker-compose -f ./bucketConfigs/docker-compose.yml up', {\n cwd: process.cwd(),\n stdio: \"inherit\",\n })\n}\n\nrunBucket();\n"],"mappings":";;;;;AAAA,SAAQ,gBAAe;AAEvB,SAAS,YAAY;AACjB,WAAS,2DAA2D;AAAA,IAChE,KAAK,QAAQ,IAAI;AAAA,IACjB,OAAO;AAAA,EACX,CAAC;AACL;AALS;AAOT,UAAU;","names":[]}
@@ -0,0 +1,35 @@
1
+ import {
2
+ startServer
3
+ } from "../../chunk-UPP2FW3G.js";
4
+ import "../../chunk-ZTTB4NMA.js";
5
+ import "../../chunk-3DJ6GERS.js";
6
+ import "../../chunk-EEQ2SXDE.js";
7
+ import "../../chunk-6BNQOIVA.js";
8
+ import "../../chunk-YA3MW2CJ.js";
9
+ import "../../chunk-EUWCMMGI.js";
10
+ import "../../chunk-O76OK6Y7.js";
11
+ import "../../chunk-22GJTNKR.js";
12
+ import "../../chunk-U7BCM2WN.js";
13
+ import "../../chunk-ZC6ZFZ2J.js";
14
+ import "../../chunk-452DWS46.js";
15
+ import "../../chunk-O2ZDXQ2Z.js";
16
+ import "../../chunk-ZGOMCU4T.js";
17
+ import "../../chunk-A7GR4LD2.js";
18
+ import "../../chunk-O5ILFRFV.js";
19
+ import "../../chunk-M7PVDT2D.js";
20
+ import "../../chunk-HC4IDQP6.js";
21
+ import "../../chunk-RZ7XHAUV.js";
22
+ import "../../chunk-IZEPCXYK.js";
23
+ import "../../chunk-ZC33GE2U.js";
24
+ import "../../chunk-J3P6W53K.js";
25
+ import "../../chunk-2QNCQ5L5.js";
26
+ import "../../chunk-4L35JPDH.js";
27
+ import "../../chunk-HV3IQJH3.js";
28
+ import "../../chunk-5AJKFCEE.js";
29
+ import "../../chunk-QW2GGDEG.js";
30
+ import "../../chunk-LE2SDA4O.js";
31
+ import "../../chunk-7QVYU63E.js";
32
+
33
+ // src/utility/libs/run-node-server.ts
34
+ await startServer();
35
+ //# sourceMappingURL=run-node-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/utility/libs/run-node-server.ts"],"sourcesContent":["\nimport {startServer} from \"../../engine/server/server.js\";\n\n// export async function runNodeServer () {\n// execSync(\"tsx \" + path.join(process.cwd() , \"node_modules/backfarm/dist/utility/libs/script/server.js\"), {\n// cwd: process.cwd(),\n// stdio: \"inherit\",\n// })\n// }\n\n\n\nawait startServer();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAYA,MAAM,YAAY;","names":[]}
@@ -1,8 +1,15 @@
1
- import { BulkWriteResult, DeleteResult, InsertManyResult, InsertOneResult, UpdateResult } from 'mongodb';
2
- import { RequestHandler, Request, Response } from 'express';
1
+ import { BulkWriteResult, DeleteResult, InsertOneResult, InsertManyResult, UpdateResult } from 'mongodb';
2
+ import { Response, RequestHandler, Request } from 'express';
3
3
  import { ENV } from './env.js';
4
4
 
5
- type ExpressConfigurables = (() => void)[];
5
+ type PathOptions = {
6
+ path_prefix?: string;
7
+ segments?: string[];
8
+ path_postfix?: string;
9
+ fileName?: Express.Multer.File | File | Buffer | string;
10
+ } | {
11
+ path: string;
12
+ };
6
13
  type DatabaseType = typeof ENV.MY_SQL | typeof ENV.POSTGRES_SQL;
7
14
  type FileUploadedResponseData = {
8
15
  url?: string;
@@ -172,36 +179,9 @@ type SqlQuery = {
172
179
  conditionalParams?: any[];
173
180
  };
174
181
  };
175
- interface MySqlQuery {
176
- insert_one: {
177
- table: string;
178
- item: Record<string, any>;
179
- };
180
- insert_many: {
181
- table: string;
182
- item: Record<string, any>[];
183
- };
184
- update: {
185
- table: string;
186
- item: Record<string, any>;
187
- condition: string;
188
- conditionalParams?: any[];
189
- };
190
- select?: {
191
- table: string;
192
- columns?: string[];
193
- condition?: string;
194
- conditionalParams?: any[];
195
- };
196
- delete?: {
197
- table: string;
198
- condition: string;
199
- conditionalParams?: any[];
200
- };
201
- }
202
182
  type SqlRawQuery = {
203
183
  query: string;
204
184
  params?: any[];
205
185
  };
206
186
 
207
- export type { ApisInterface, CustomBulkWriteResult, CustomDeleteResult, CustomInsertManyResult, CustomInsertOneResult, CustomUpdateResult, DatabaseType, ExpressConfigurables, FileUploadedResponseData, MySqlQuery, ResponseInterface, ResponseType, SqlQuery, SqlRawQuery, TableColsAndVals };
187
+ export type { ApisInterface, CustomBulkWriteResult, CustomDeleteResult, CustomInsertManyResult, CustomInsertOneResult, CustomUpdateResult, DatabaseType, FileUploadedResponseData, PathOptions, ResponseInterface, ResponseType, SqlQuery, SqlRawQuery, TableColsAndVals };
@@ -1,4 +1,4 @@
1
- import "../../chunk-EWQYVPOL.js";
1
+ import "../../chunk-LE2SDA4O.js";
2
2
  import "../../chunk-7QVYU63E.js";
3
3
 
4
4
  // src/utility/libs/types.ts
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/utility/libs/types.ts"],"sourcesContent":["import {\r\n type InsertOneResult,\r\n type InsertManyResult,\r\n type UpdateResult,\r\n BulkWriteResult,\r\n type DeleteResult\r\n} from \"mongodb\";\r\nimport type {Request, RequestHandler, Response} from \"express\";\r\nimport {ENV} from \"./env.js\";\r\n\r\n\r\n\r\nexport type ExpressConfigurables = (() => void)[];\r\n\r\n\r\n\r\nexport type DatabaseType = typeof ENV.MY_SQL | typeof ENV.POSTGRES_SQL;\r\n\r\n\r\n\r\nexport type FileUploadedResponseData =\r\n\r\n | {\r\n url?: string;\r\n path?: string;\r\n file?: File;\r\n buffer?: Buffer;\r\n multerFile?: Express.Multer.File\r\n\r\n }\r\n | {\r\n error?: Error | unknown | any;\r\n path?: string;\r\n file?: File;\r\n buffer?: Buffer;\r\n multerFile?: Express.Multer.File;\r\n }\r\n\r\n\r\n\r\n\r\n\r\n\r\nexport type ResponseType<T = any> =\r\n | {\r\n success: true;\r\n status: number;\r\n message?: string;\r\n data?: T;\r\n meta?: {\r\n timestamp: string; // ISO 8601 string (e.g., \"2026-08-22T20:10:22Z\")\r\n requestId?: string; // For log tracing / distributed systems\r\n page?: number;\r\n limit?: number;\r\n totalItems?: number;\r\n totalPages?: number;\r\n };\r\n }\r\n |\r\n {\r\n success: false;\r\n status: number;\r\n message?: string;\r\n error: {\r\n code: string; // Machine-readable code (e.g., \"UNAUTHORIZED\", \"VALIDATION_ERROR\")\r\n path?: string; // Request endpoint or field path\r\n details?: Record<string, any> | Array<any>; // Structured error context or validation issues\r\n stack?: string; // Included strictly during development\r\n };\r\n meta?: {\r\n timestamp: string;\r\n requestId?: string;\r\n };\r\n };\r\n\r\nexport type ResponseInterface = {\r\n response: Response;\r\n} & ResponseType;\r\n\r\n\r\nexport type CustomInsertOneResult<T> =\r\n | {\r\n status: true;\r\n result: InsertOneResult<T>;\r\n error: null;\r\n}\r\n | {\r\n status: false;\r\n result: null;\r\n error: Error;\r\n};\r\n\r\n\r\nexport type CustomInsertManyResult<T> =\r\n | {\r\n status: true;\r\n result: InsertManyResult<T>;\r\n insertedCount: number;\r\n error: null;\r\n}\r\n | {\r\n status: false;\r\n result: null;\r\n insertedCount: 0;\r\n error: Error;\r\n};\r\n\r\n\r\nexport type CustomUpdateResult =\r\n | {\r\n status: true;\r\n result: UpdateResult;\r\n error: null;\r\n }\r\n | {\r\n status: false;\r\n result: null;\r\n error: Error;\r\n };\r\n\r\n\r\nexport type CustomBulkWriteResult =\r\n | {\r\n status: true;\r\n result: BulkWriteResult;\r\n error: null;\r\n}\r\n | {\r\n status: false;\r\n result: null;\r\n error: Error;\r\n};\r\n\r\n\r\nexport type CustomDeleteResult =\r\n | {\r\n status: true;\r\n result: DeleteResult;\r\n deletedCount: number;\r\n error: null;\r\n }\r\n | {\r\n status: false;\r\n result: null;\r\n deletedCount: 0;\r\n error: Error;\r\n};\r\n\r\n\r\n\r\n\r\n\r\n\r\nexport type ApisInterface =\r\n | {\r\n get: {\r\n endpoint: string;\r\n middleware?: RequestHandler | RequestHandler[];\r\n callable: (request: Request, response: Response) => void;\r\n }\r\n }\r\n | {\r\n post: {\r\n endpoint: string;\r\n middleware?: RequestHandler | RequestHandler[];\r\n callable: (request: Request, response: Response) => void;\r\n }\r\n }\r\n | {\r\n put: {\r\n endpoint: string;\r\n middleware?: RequestHandler | RequestHandler[];\r\n callable: (request: Request, response: Response) => void;\r\n }\r\n }\r\n | {\r\n delete: {\r\n endpoint: string;\r\n middleware?: RequestHandler | RequestHandler[];\r\n callable: (request: Request, response: Response) => void;\r\n }\r\n }\r\n | {\r\n patch: {\r\n endpoint: string;\r\n middleware?: RequestHandler | RequestHandler[];\r\n callable: (request: Request, response: Response) => void;\r\n }\r\n }\r\n | {\r\n head: {\r\n endpoint: string;\r\n middleware?: RequestHandler | RequestHandler[];\r\n callable: (request: Request, response: Response) => void;\r\n }\r\n }\r\n | {\r\n options: {\r\n endpoint: string;\r\n middleware?: RequestHandler | RequestHandler[];\r\n callable: (request: Request, response: Response) => void;\r\n }\r\n };\r\n\r\n\r\n\r\n\r\n\r\nexport type TableColsAndVals = Record<string, any>\r\n\r\nexport type SqlQuery =\r\n | {\r\n insert_one: {\r\n item: TableColsAndVals;\r\n table: string;\r\n };\r\n }\r\n | {\r\n insert_many: {\r\n item: TableColsAndVals[];\r\n table: string;\r\n };\r\n }\r\n | {\r\n update: {\r\n item: TableColsAndVals;\r\n table: string;\r\n condition: string;\r\n conditionalParams?: any[];\r\n };\r\n}\r\n | {\r\n select: {\r\n columns?: string[];\r\n table: string;\r\n condition?: string;\r\n conditionalParams?: any[];\r\n };\r\n}\r\n | {\r\n delete: {\r\n table: string;\r\n condition: string;\r\n conditionalParams?: any[];\r\n };\r\n\r\n};\r\n\r\n\r\nexport interface MySqlQuery {\r\n insert_one: {\r\n table: string;\r\n item: Record<string, any>;\r\n };\r\n insert_many: {\r\n table: string;\r\n item: Record<string, any>[];\r\n };\r\n update: {\r\n table: string;\r\n item: Record<string, any>;\r\n condition: string;\r\n conditionalParams?: any[];\r\n };\r\n select?: {\r\n table: string;\r\n columns?: string[];\r\n condition?: string;\r\n conditionalParams?: any[];\r\n };\r\n delete?: {\r\n table: string;\r\n condition: string;\r\n conditionalParams?: any[];\r\n };\r\n}\r\n\r\n\r\n\r\n\r\nexport type SqlRawQuery = {\r\n query: string;\r\n params?: any[];\r\n};\r\n"],"mappings":";;;;AAAA,OAMO;","names":[]}
1
+ {"version":3,"sources":["../../../src/utility/libs/types.ts"],"sourcesContent":["import {\n type InsertOneResult,\n type InsertManyResult,\n type UpdateResult,\n BulkWriteResult,\n type DeleteResult\n} from \"mongodb\";\nimport type {Request, RequestHandler, Response} from \"express\";\nimport {ENV} from \"./env.js\";\n\n\nexport type PathOptions =\n| {\n path_prefix?: string;\n segments?: string[];\n path_postfix?: string;\n fileName?: Express.Multer.File | File | Buffer | string;\n}\n |\n{\n path: string\n}\n\n\n\n\nexport type DatabaseType = typeof ENV.MY_SQL | typeof ENV.POSTGRES_SQL;\n\n\n\nexport type FileUploadedResponseData =\n\n | {\n url?: string;\n path?: string;\n file?: File;\n buffer?: Buffer;\n multerFile?: Express.Multer.File\n\n }\n | {\n error?: Error | unknown | any;\n path?: string;\n file?: File;\n buffer?: Buffer;\n multerFile?: Express.Multer.File;\n }\n\n\n\n\n\n\nexport type ResponseType<T = any> =\n | {\n success: true;\n status: number;\n message?: string;\n data?: T;\n meta?: {\n timestamp: string; // ISO 8601 string (e.g., \"2026-08-22T20:10:22Z\")\n requestId?: string; // For log tracing / distributed systems\n page?: number;\n limit?: number;\n totalItems?: number;\n totalPages?: number;\n };\n }\n |\n {\n success: false;\n status: number;\n message?: string;\n error: {\n code: string; // Machine-readable code (e.g., \"UNAUTHORIZED\", \"VALIDATION_ERROR\")\n path?: string; // Request endpoint or field path\n details?: Record<string, any> | Array<any>; // Structured error context or validation issues\n stack?: string; // Included strictly during development\n };\n meta?: {\n timestamp: string;\n requestId?: string;\n };\n };\n\nexport type ResponseInterface = {\n response: Response;\n} & ResponseType;\n\n\nexport type CustomInsertOneResult<T> =\n | {\n status: true;\n result: InsertOneResult<T>;\n error: null;\n}\n | {\n status: false;\n result: null;\n error: Error;\n};\n\n\nexport type CustomInsertManyResult<T> =\n | {\n status: true;\n result: InsertManyResult<T>;\n insertedCount: number;\n error: null;\n}\n | {\n status: false;\n result: null;\n insertedCount: 0;\n error: Error;\n};\n\n\nexport type CustomUpdateResult =\n | {\n status: true;\n result: UpdateResult;\n error: null;\n }\n | {\n status: false;\n result: null;\n error: Error;\n };\n\n\nexport type CustomBulkWriteResult =\n | {\n status: true;\n result: BulkWriteResult;\n error: null;\n}\n | {\n status: false;\n result: null;\n error: Error;\n};\n\n\nexport type CustomDeleteResult =\n | {\n status: true;\n result: DeleteResult;\n deletedCount: number;\n error: null;\n }\n | {\n status: false;\n result: null;\n deletedCount: 0;\n error: Error;\n};\n\n\n\n\n\n\nexport type ApisInterface =\n | {\n get: {\n endpoint: string;\n middleware?: RequestHandler | RequestHandler[];\n callable: (request: Request, response: Response) => void;\n }\n }\n | {\n post: {\n endpoint: string;\n middleware?: RequestHandler | RequestHandler[];\n callable: (request: Request, response: Response) => void;\n }\n }\n | {\n put: {\n endpoint: string;\n middleware?: RequestHandler | RequestHandler[];\n callable: (request: Request, response: Response) => void;\n }\n }\n | {\n delete: {\n endpoint: string;\n middleware?: RequestHandler | RequestHandler[];\n callable: (request: Request, response: Response) => void;\n }\n }\n | {\n patch: {\n endpoint: string;\n middleware?: RequestHandler | RequestHandler[];\n callable: (request: Request, response: Response) => void;\n }\n }\n | {\n head: {\n endpoint: string;\n middleware?: RequestHandler | RequestHandler[];\n callable: (request: Request, response: Response) => void;\n }\n }\n | {\n options: {\n endpoint: string;\n middleware?: RequestHandler | RequestHandler[];\n callable: (request: Request, response: Response) => void;\n }\n };\n\n\n\n\n\nexport type TableColsAndVals = Record<string, any>\n\nexport type SqlQuery =\n | {\n insert_one: {\n item: TableColsAndVals;\n table: string;\n };\n }\n | {\n insert_many: {\n item: TableColsAndVals[];\n table: string;\n };\n }\n | {\n update: {\n item: TableColsAndVals;\n table: string;\n condition: string;\n conditionalParams?: any[];\n };\n}\n | {\n select: {\n columns?: string[];\n table: string;\n condition?: string;\n conditionalParams?: any[];\n };\n}\n | {\n delete: {\n table: string;\n condition: string;\n conditionalParams?: any[];\n };\n\n};\n\n\n\n\n\n\nexport type SqlRawQuery = {\n query: string;\n params?: any[];\n};\n"],"mappings":";;;;AAAA,OAMO;","names":[]}
@@ -1,58 +1,11 @@
1
1
  import {
2
- getKeyFromUrl
3
- } from "../../../chunk-SSFPGDA3.js";
4
- import {
5
- s3Client
6
- } from "../../../chunk-YTBSGKGF.js";
7
- import {
8
- url_or_path
9
- } from "../../../chunk-W3W3X2OE.js";
10
- import {
11
- ENV
12
- } from "../../../chunk-EWQYVPOL.js";
13
- import {
14
- __name
15
- } from "../../../chunk-7QVYU63E.js";
16
-
17
- // src/utility/utilis/cloud_storage/deleteFile.ts
18
- import { DeleteObjectCommand } from "@aws-sdk/client-s3";
19
- import * as fs from "fs";
20
- var deleteFile = /* @__PURE__ */ __name(async (item_file) => {
21
- try {
22
- const fileType = url_or_path(item_file);
23
- if (fileType === ENV.URL) {
24
- const key = getKeyFromUrl(item_file);
25
- const command = new DeleteObjectCommand({
26
- Bucket: ENV.BUCKET_NAME,
27
- Key: key
28
- });
29
- await s3Client.send(command);
30
- return {
31
- status: true,
32
- url_or_path: item_file
33
- };
34
- }
35
- if (fileType === ENV.PATH) {
36
- if (fs.existsSync(item_file)) {
37
- await fs.promises.unlink(item_file);
38
- }
39
- return {
40
- status: true,
41
- url_or_path: item_file
42
- };
43
- }
44
- return {
45
- url_or_path: item_file,
46
- status: false
47
- };
48
- } catch (error) {
49
- return {
50
- status: false,
51
- url_or_path: item_file,
52
- error
53
- };
54
- }
55
- }, "deleteFile");
2
+ deleteFile
3
+ } from "../../../chunk-M7PVDT2D.js";
4
+ import "../../../chunk-ZC33GE2U.js";
5
+ import "../../../chunk-J3P6W53K.js";
6
+ import "../../../chunk-QW2GGDEG.js";
7
+ import "../../../chunk-LE2SDA4O.js";
8
+ import "../../../chunk-7QVYU63E.js";
56
9
  export {
57
10
  deleteFile
58
11
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utility/utilis/cloud_storage/deleteFile.ts"],"sourcesContent":["import {ENV} from \"../../libs/env.js\";\r\nimport {url_or_path} from \"../general/file-operations.js\";\r\nimport {getKeyFromUrl} from \"../general/web.js\";\r\nimport {DeleteObjectCommand} from \"@aws-sdk/client-s3\";\r\nimport * as fs from \"node:fs\";\r\nimport type {DeleteFile} from \"../../libs/interface.js\";\r\nimport {s3Client} from \"../../../engine/cloudBucket/r2Storage.js\";\r\n\r\nexport const deleteFile = async (item_file: string): Promise<DeleteFile> => {\r\n try {\r\n const fileType = url_or_path(item_file);\r\n\r\n if (fileType === ENV.URL) {\r\n // Extract the MinIO object key from the full public URL\r\n const key = getKeyFromUrl(item_file);\r\n\r\n const command = new DeleteObjectCommand({\r\n Bucket: ENV.BUCKET_NAME,\r\n Key: key,\r\n });\r\n\r\n await s3Client.send(command);\r\n return {\r\n status: true,\r\n url_or_path: item_file,\r\n }\r\n }\r\n\r\n if (fileType === ENV.PATH) {\r\n // Check if file exists locally before unlinking\r\n if (fs.existsSync(item_file)) {\r\n await fs.promises.unlink(item_file);\r\n }\r\n return {\r\n status: true,\r\n url_or_path: item_file,\r\n }\r\n }\r\n\r\n return {\r\n url_or_path: item_file,\r\n status: false,\r\n }\r\n } catch (error) {\r\n return {\r\n status: false,\r\n url_or_path: item_file,\r\n error: error,\r\n }\r\n }\r\n};\r\n"],"mappings":";;;;;;;;;;;;;;;;;AAGA,SAAQ,2BAA0B;AAClC,YAAY,QAAQ;AAIb,IAAM,aAAa,8BAAO,cAA2C;AACxE,MAAI;AACA,UAAM,WAAW,YAAY,SAAS;AAEtC,QAAI,aAAa,IAAI,KAAK;AAEtB,YAAM,MAAM,cAAc,SAAS;AAEnC,YAAM,UAAU,IAAI,oBAAoB;AAAA,QACpC,QAAQ,IAAI;AAAA,QACZ,KAAK;AAAA,MACT,CAAC;AAED,YAAM,SAAS,KAAK,OAAO;AAC3B,aAAO;AAAA,QACH,QAAQ;AAAA,QACR,aAAa;AAAA,MACjB;AAAA,IACJ;AAEA,QAAI,aAAa,IAAI,MAAM;AAEvB,UAAO,cAAW,SAAS,GAAG;AAC1B,cAAS,YAAS,OAAO,SAAS;AAAA,MACtC;AACA,aAAO;AAAA,QACH,QAAQ;AAAA,QACR,aAAa;AAAA,MACjB;AAAA,IACJ;AAEA,WAAO;AAAA,MACH,aAAa;AAAA,MACb,QAAQ;AAAA,IACZ;AAAA,EACJ,SAAS,OAAO;AACZ,WAAO;AAAA,MACH,QAAQ;AAAA,MACR,aAAa;AAAA,MACb;AAAA,IACJ;AAAA,EACJ;AACJ,GA1C0B;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,87 +1,11 @@
1
1
  import {
2
- getKeyFromUrl
3
- } from "../../../chunk-SSFPGDA3.js";
4
- import {
5
- s3Client
6
- } from "../../../chunk-YTBSGKGF.js";
7
- import {
8
- url_or_path
9
- } from "../../../chunk-W3W3X2OE.js";
10
- import {
11
- ENV
12
- } from "../../../chunk-EWQYVPOL.js";
13
- import {
14
- __name
15
- } from "../../../chunk-7QVYU63E.js";
16
-
17
- // src/utility/utilis/cloud_storage/deleteFiles.ts
18
- import { DeleteObjectCommand } from "@aws-sdk/client-s3";
19
- import * as fs from "fs";
20
- var deleteFiles = /* @__PURE__ */ __name(async (item_files) => {
21
- if (!item_files || item_files.length === 0) {
22
- return { items: [] };
23
- }
24
- const uniqueFiles = [...new Set(item_files)];
25
- const BATCH_SIZE = 50;
26
- const results = [];
27
- const deleteSingleFile = /* @__PURE__ */ __name(async (item_file) => {
28
- try {
29
- const fileType = url_or_path(item_file);
30
- if (fileType === ENV.URL) {
31
- const key = getKeyFromUrl(item_file);
32
- const command = new DeleteObjectCommand({
33
- Bucket: ENV.BUCKET_NAME,
34
- Key: key
35
- });
36
- await s3Client.send(command);
37
- return {
38
- url_or_path: item_file,
39
- status: true
40
- };
41
- }
42
- if (fileType === ENV.PATH) {
43
- try {
44
- await fs.promises.access(item_file);
45
- await fs.promises.unlink(item_file);
46
- } catch (accessError) {
47
- }
48
- return {
49
- url_or_path: item_file,
50
- status: true
51
- };
52
- }
53
- return {
54
- url_or_path: item_file,
55
- status: false
56
- };
57
- } catch (error) {
58
- return {
59
- url_or_path: item_file,
60
- status: false,
61
- error
62
- };
63
- }
64
- }, "deleteSingleFile");
65
- for (let i = 0; i < uniqueFiles.length; i += BATCH_SIZE) {
66
- const batch = uniqueFiles.slice(i, i + BATCH_SIZE);
67
- const batchResults = await Promise.allSettled(
68
- batch.map((file) => deleteSingleFile(file))
69
- );
70
- batchResults.forEach((result, index) => {
71
- if (result.status === "fulfilled") {
72
- results.push(result.value);
73
- } else {
74
- results.push({
75
- url_or_path: batch[index] || "unknown",
76
- // Provide fallback
77
- status: false,
78
- error: result.reason
79
- });
80
- }
81
- });
82
- }
83
- return { items: results };
84
- }, "deleteFiles");
2
+ deleteFiles
3
+ } from "../../../chunk-HC4IDQP6.js";
4
+ import "../../../chunk-ZC33GE2U.js";
5
+ import "../../../chunk-J3P6W53K.js";
6
+ import "../../../chunk-QW2GGDEG.js";
7
+ import "../../../chunk-LE2SDA4O.js";
8
+ import "../../../chunk-7QVYU63E.js";
85
9
  export {
86
10
  deleteFiles
87
11
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utility/utilis/cloud_storage/deleteFiles.ts"],"sourcesContent":["import {ENV} from \"../../libs/env.js\";\r\nimport {url_or_path} from \"../general/file-operations.js\";\r\nimport {getKeyFromUrl} from \"../general/web.js\";\r\nimport {DeleteObjectCommand} from \"@aws-sdk/client-s3\";\r\nimport * as fs from \"node:fs\";\r\nimport type {DeleteFiles} from \"../../libs/interface.js\";\r\nimport {s3Client} from \"../../../engine/cloudBucket/r2Storage.js\";\r\n\r\nexport const deleteFiles = async (item_files: string[]): Promise<DeleteFiles> => {\r\n // Early return for empty array\r\n if (!item_files || item_files.length === 0) {\r\n return { items: [] };\r\n }\r\n\r\n // Optional: Deduplicate files to avoid redundant operations\r\n const uniqueFiles = [...new Set(item_files)];\r\n\r\n // Optional: Limit concurrency to avoid overwhelming the system\r\n const BATCH_SIZE = 50; // Adjust based on your needs\r\n const results: DeleteFiles['items'] = [];\r\n\r\n const deleteSingleFile = async (item_file: string): Promise<DeleteFiles['items'][0]> => {\r\n try {\r\n const fileType = url_or_path(item_file);\r\n\r\n if (fileType === ENV.URL) {\r\n const key = getKeyFromUrl(item_file);\r\n const command = new DeleteObjectCommand({\r\n Bucket: ENV.BUCKET_NAME,\r\n Key: key,\r\n });\r\n await s3Client.send(command);\r\n return {\r\n url_or_path: item_file,\r\n status: true,\r\n };\r\n }\r\n\r\n if (fileType === ENV.PATH) {\r\n try {\r\n await fs.promises.access(item_file);\r\n await fs.promises.unlink(item_file);\r\n } catch (accessError) {\r\n // File doesn't exist - consider this a success (idempotent)\r\n }\r\n return {\r\n url_or_path: item_file,\r\n status: true,\r\n };\r\n }\r\n\r\n return {\r\n url_or_path: item_file,\r\n status: false,\r\n };\r\n } catch (error) {\r\n return {\r\n url_or_path: item_file,\r\n status: false,\r\n error: error,\r\n };\r\n }\r\n };\r\n\r\n // Process in batches to control memory/connection usage\r\n for (let i = 0; i < uniqueFiles.length; i += BATCH_SIZE) {\r\n const batch = uniqueFiles.slice(i, i + BATCH_SIZE);\r\n const batchResults = await Promise.allSettled(\r\n batch.map(file => deleteSingleFile(file))\r\n );\r\n\r\n batchResults.forEach((result, index) => {\r\n if (result.status === 'fulfilled') {\r\n results.push(result.value);\r\n } else {\r\n // result.reason should never happen with allSettled, but handle it anyway\r\n results.push({\r\n url_or_path: batch[index] || 'unknown', // Provide fallback\r\n status: false,\r\n error: result.reason,\r\n });\r\n }\r\n });\r\n }\r\n\r\n return { items: results };\r\n};\r\n"],"mappings":";;;;;;;;;;;;;;;;;AAGA,SAAQ,2BAA0B;AAClC,YAAY,QAAQ;AAIb,IAAM,cAAc,8BAAO,eAA+C;AAE7E,MAAI,CAAC,cAAc,WAAW,WAAW,GAAG;AACxC,WAAO,EAAE,OAAO,CAAC,EAAE;AAAA,EACvB;AAGA,QAAM,cAAc,CAAC,GAAG,IAAI,IAAI,UAAU,CAAC;AAG3C,QAAM,aAAa;AACnB,QAAM,UAAgC,CAAC;AAEvC,QAAM,mBAAmB,8BAAO,cAAwD;AACpF,QAAI;AACA,YAAM,WAAW,YAAY,SAAS;AAEtC,UAAI,aAAa,IAAI,KAAK;AACtB,cAAM,MAAM,cAAc,SAAS;AACnC,cAAM,UAAU,IAAI,oBAAoB;AAAA,UACpC,QAAQ,IAAI;AAAA,UACZ,KAAK;AAAA,QACT,CAAC;AACD,cAAM,SAAS,KAAK,OAAO;AAC3B,eAAO;AAAA,UACH,aAAa;AAAA,UACb,QAAQ;AAAA,QACZ;AAAA,MACJ;AAEA,UAAI,aAAa,IAAI,MAAM;AACvB,YAAI;AACA,gBAAS,YAAS,OAAO,SAAS;AAClC,gBAAS,YAAS,OAAO,SAAS;AAAA,QACtC,SAAS,aAAa;AAAA,QAEtB;AACA,eAAO;AAAA,UACH,aAAa;AAAA,UACb,QAAQ;AAAA,QACZ;AAAA,MACJ;AAEA,aAAO;AAAA,QACH,aAAa;AAAA,QACb,QAAQ;AAAA,MACZ;AAAA,IACJ,SAAS,OAAO;AACZ,aAAO;AAAA,QACH,aAAa;AAAA,QACb,QAAQ;AAAA,QACR;AAAA,MACJ;AAAA,IACJ;AAAA,EACJ,GAzCyB;AA4CzB,WAAS,IAAI,GAAG,IAAI,YAAY,QAAQ,KAAK,YAAY;AACrD,UAAM,QAAQ,YAAY,MAAM,GAAG,IAAI,UAAU;AACjD,UAAM,eAAe,MAAM,QAAQ;AAAA,MAC/B,MAAM,IAAI,UAAQ,iBAAiB,IAAI,CAAC;AAAA,IAC5C;AAEA,iBAAa,QAAQ,CAAC,QAAQ,UAAU;AACpC,UAAI,OAAO,WAAW,aAAa;AAC/B,gBAAQ,KAAK,OAAO,KAAK;AAAA,MAC7B,OAAO;AAEH,gBAAQ,KAAK;AAAA,UACT,aAAa,MAAM,KAAK,KAAK;AAAA;AAAA,UAC7B,QAAQ;AAAA,UACR,OAAO,OAAO;AAAA,QAClB,CAAC;AAAA,MACL;AAAA,IACJ,CAAC;AAAA,EACL;AAEA,SAAO,EAAE,OAAO,QAAQ;AAC5B,GA9E2B;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,72 +1,12 @@
1
1
  import {
2
- generateUniqueValue
3
- } from "../../../chunk-X3R3RLXY.js";
4
- import {
5
- getKeyFromUrl
6
- } from "../../../chunk-SSFPGDA3.js";
7
- import {
8
- s3Client
9
- } from "../../../chunk-YTBSGKGF.js";
10
- import {
11
- downloadedFilePath,
12
- getFileExtension
13
- } from "../../../chunk-W3W3X2OE.js";
14
- import {
15
- ENV
16
- } from "../../../chunk-EWQYVPOL.js";
17
- import {
18
- __name
19
- } from "../../../chunk-7QVYU63E.js";
20
-
21
- // src/utility/utilis/cloud_storage/downloadFile.ts
22
- import { GetObjectCommand } from "@aws-sdk/client-s3";
23
- import { pipeline } from "stream/promises";
24
- import path from "path";
25
- import fsPromises from "fs/promises";
26
- import * as fs from "fs";
27
- var downloadFile = /* @__PURE__ */ __name(async ({
28
- url,
29
- outputPath
30
- }) => {
31
- try {
32
- const key = getKeyFromUrl(url);
33
- const command = new GetObjectCommand({
34
- Bucket: ENV.BUCKET_NAME,
35
- Key: key
36
- });
37
- const response = await s3Client.send(command);
38
- if (!response.Body) {
39
- console.log(response);
40
- return {
41
- status: true,
42
- url,
43
- error: new Error(`Empty response body received for key: ${key}`)
44
- };
45
- }
46
- const fileExtension = getFileExtension(url);
47
- const fileName = generateUniqueValue(16);
48
- const finalFileName = `${fileName}.${fileExtension}`;
49
- const targetPath = downloadedFilePath({ path: outputPath || [], fileName: finalFileName });
50
- const dir = path.dirname(targetPath);
51
- if (!fs.existsSync(dir)) {
52
- await fsPromises.mkdir(dir, { recursive: true });
53
- }
54
- const stream = response.Body;
55
- await pipeline(stream, fs.createWriteStream(targetPath));
56
- return {
57
- status: true,
58
- url,
59
- path: targetPath
60
- };
61
- } catch (error) {
62
- console.error(error);
63
- return {
64
- status: false,
65
- url,
66
- error: error instanceof Error ? error : new Error(String(error))
67
- };
68
- }
69
- }, "downloadFile");
2
+ downloadFile
3
+ } from "../../../chunk-RZ7XHAUV.js";
4
+ import "../../../chunk-IZEPCXYK.js";
5
+ import "../../../chunk-ZC33GE2U.js";
6
+ import "../../../chunk-J3P6W53K.js";
7
+ import "../../../chunk-QW2GGDEG.js";
8
+ import "../../../chunk-LE2SDA4O.js";
9
+ import "../../../chunk-7QVYU63E.js";
70
10
  export {
71
11
  downloadFile
72
12
  };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/utility/utilis/cloud_storage/downloadFile.ts"],"sourcesContent":["import {GetObjectCommand} from \"@aws-sdk/client-s3\";\r\nimport {getKeyFromUrl} from \"../general/web.js\";\r\nimport { pipeline } from \"stream/promises\";\r\nimport path from 'node:path'\r\nimport fsPromises from 'fs/promises';\r\nimport * as fs from \"node:fs\";\r\nimport type {DownloadedFile, DownloadFileParams} from \"../../libs/interface.js\";\r\nimport {ENV} from \"../../libs/env.js\";\r\nimport {downloadedFilePath, getFileExtension} from \"../general/file-operations.js\";\r\nimport {generateUniqueValue} from \"../general/uuids.js\";\r\nimport {s3Client} from \"../../../engine/cloudBucket/r2Storage.js\";\r\n\r\n\r\n\r\nexport const downloadFile = async ({\r\n url,\r\n outputPath,\r\n }: DownloadFileParams): Promise<DownloadedFile> => {\r\n try {\r\n const key = getKeyFromUrl(url);\r\n\r\n const command = new GetObjectCommand({\r\n Bucket: ENV.BUCKET_NAME,\r\n Key: key,\r\n });\r\n\r\n const response = await s3Client.send(command);\r\n\r\n if (!response.Body) {\r\n console.log(response);\r\n return {\r\n status: true,\r\n url: url,\r\n error: new Error(`Empty response body received for key: ${key}`),\r\n };\r\n }\r\n\r\n const fileExtension = getFileExtension(url);\r\n const fileName = generateUniqueValue(16);\r\n const finalFileName = `${fileName}.${fileExtension}`;\r\n const targetPath = downloadedFilePath({ path: outputPath || [], fileName: finalFileName });\r\n\r\n // Ensure directory structure exists for targetPath\r\n const dir = path.dirname(targetPath);\r\n if (!fs.existsSync(dir)) {\r\n await fsPromises.mkdir(dir, { recursive: true });\r\n }\r\n\r\n // Cast stream to NodeJS.ReadableStream for pipeline overload\r\n const stream = response.Body as NodeJS.ReadableStream;\r\n await pipeline(stream, fs.createWriteStream(targetPath));\r\n\r\n return {\r\n status: true,\r\n url: url,\r\n path: targetPath,\r\n };\r\n\r\n } catch (error) {\r\n console.error(error);\r\n return {\r\n status: false,\r\n url: url,\r\n error: error instanceof Error ? error : new Error(String(error)),\r\n };\r\n }\r\n};\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,SAAQ,wBAAuB;AAE/B,SAAS,gBAAgB;AACzB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AACvB,YAAY,QAAQ;AASb,IAAM,eAAe,8BAAO;AAAA,EACI;AAAA,EACA;AACJ,MAAmD;AAClF,MAAI;AACA,UAAM,MAAM,cAAc,GAAG;AAE7B,UAAM,UAAU,IAAI,iBAAiB;AAAA,MACjC,QAAQ,IAAI;AAAA,MACZ,KAAK;AAAA,IACT,CAAC;AAED,UAAM,WAAW,MAAM,SAAS,KAAK,OAAO;AAE5C,QAAI,CAAC,SAAS,MAAM;AAChB,cAAQ,IAAI,QAAQ;AACpB,aAAO;AAAA,QACH,QAAQ;AAAA,QACR;AAAA,QACA,OAAO,IAAI,MAAM,yCAAyC,GAAG,EAAE;AAAA,MACnE;AAAA,IACJ;AAEA,UAAM,gBAAgB,iBAAiB,GAAG;AAC1C,UAAM,WAAW,oBAAoB,EAAE;AACvC,UAAM,gBAAgB,GAAG,QAAQ,IAAI,aAAa;AAClD,UAAM,aAAa,mBAAmB,EAAE,MAAM,cAAc,CAAC,GAAG,UAAU,cAAc,CAAC;AAGzF,UAAM,MAAM,KAAK,QAAQ,UAAU;AACnC,QAAI,CAAI,cAAW,GAAG,GAAG;AACrB,YAAM,WAAW,MAAM,KAAK,EAAE,WAAW,KAAK,CAAC;AAAA,IACnD;AAGA,UAAM,SAAS,SAAS;AACxB,UAAM,SAAS,QAAW,qBAAkB,UAAU,CAAC;AAEvD,WAAO;AAAA,MACH,QAAQ;AAAA,MACR;AAAA,MACA,MAAM;AAAA,IACV;AAAA,EAEJ,SAAS,OAAO;AACZ,YAAQ,MAAM,KAAK;AACnB,WAAO;AAAA,MACH,QAAQ;AAAA,MACR;AAAA,MACA,OAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;AAAA,IACnE;AAAA,EACJ;AACJ,GApD4B;","names":[]}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}