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.
- package/dist/chunk-22GJTNKR.js +47 -0
- package/dist/chunk-22GJTNKR.js.map +1 -0
- package/dist/{chunk-XBJ3SJ26.js → chunk-2QNCQ5L5.js} +3 -3
- package/dist/chunk-2QNCQ5L5.js.map +1 -0
- package/dist/chunk-3DJ6GERS.js +17 -0
- package/dist/chunk-3DJ6GERS.js.map +1 -0
- package/dist/chunk-452DWS46.js +88 -0
- package/dist/chunk-452DWS46.js.map +1 -0
- package/dist/{chunk-UWIMSKL5.js → chunk-4L35JPDH.js} +2 -2
- package/dist/chunk-4L35JPDH.js.map +1 -0
- package/dist/{chunk-VFF4YFA3.js → chunk-5AJKFCEE.js} +3 -3
- package/dist/chunk-5AJKFCEE.js.map +1 -0
- package/dist/chunk-6BNQOIVA.js +34 -0
- package/dist/chunk-6BNQOIVA.js.map +1 -0
- package/dist/{chunk-P5XJG7OG.js → chunk-A7GR4LD2.js} +1 -1
- package/dist/chunk-A7GR4LD2.js.map +1 -0
- package/dist/chunk-EEQ2SXDE.js +32 -0
- package/dist/chunk-EEQ2SXDE.js.map +1 -0
- package/dist/chunk-EUWCMMGI.js +35 -0
- package/dist/chunk-EUWCMMGI.js.map +1 -0
- package/dist/chunk-HC4IDQP6.js +89 -0
- package/dist/chunk-HC4IDQP6.js.map +1 -0
- package/dist/{chunk-QVTKG7FD.js → chunk-HV3IQJH3.js} +3 -3
- package/dist/chunk-HV3IQJH3.js.map +1 -0
- package/dist/{chunk-X3R3RLXY.js → chunk-IZEPCXYK.js} +1 -1
- package/dist/chunk-IZEPCXYK.js.map +1 -0
- package/dist/{chunk-YTBSGKGF.js → chunk-J3P6W53K.js} +2 -2
- package/dist/chunk-J3P6W53K.js.map +1 -0
- package/dist/{chunk-EWQYVPOL.js → chunk-LE2SDA4O.js} +1 -1
- package/dist/chunk-LE2SDA4O.js.map +1 -0
- package/dist/chunk-M7PVDT2D.js +60 -0
- package/dist/chunk-M7PVDT2D.js.map +1 -0
- package/dist/chunk-O2ZDXQ2Z.js +44 -0
- package/dist/chunk-O2ZDXQ2Z.js.map +1 -0
- package/dist/{chunk-MNSQSU7T.js → chunk-O5ILFRFV.js} +2 -2
- package/dist/chunk-O5ILFRFV.js.map +1 -0
- package/dist/chunk-O76OK6Y7.js +40 -0
- package/dist/chunk-O76OK6Y7.js.map +1 -0
- package/dist/{chunk-W3W3X2OE.js → chunk-QW2GGDEG.js} +54 -19
- package/dist/chunk-QW2GGDEG.js.map +1 -0
- package/dist/chunk-RZ7XHAUV.js +74 -0
- package/dist/chunk-RZ7XHAUV.js.map +1 -0
- package/dist/{chunk-TP3K7DMH.js → chunk-U7BCM2WN.js} +2 -2
- package/dist/chunk-U7BCM2WN.js.map +1 -0
- package/dist/chunk-UPP2FW3G.js +336 -0
- package/dist/chunk-UPP2FW3G.js.map +1 -0
- package/dist/chunk-YA3MW2CJ.js +33 -0
- package/dist/chunk-YA3MW2CJ.js.map +1 -0
- package/dist/{chunk-SSFPGDA3.js → chunk-ZC33GE2U.js} +5 -5
- package/dist/chunk-ZC33GE2U.js.map +1 -0
- package/dist/{chunk-D7A4TEXY.js → chunk-ZC6ZFZ2J.js} +2 -2
- package/dist/chunk-ZC6ZFZ2J.js.map +1 -0
- package/dist/{chunk-ZMDJ45KH.js → chunk-ZGOMCU4T.js} +7 -7
- package/dist/chunk-ZGOMCU4T.js.map +1 -0
- package/dist/chunk-ZTTB4NMA.js +18 -0
- package/dist/chunk-ZTTB4NMA.js.map +1 -0
- package/dist/engine/cloudBucket/r2Storage.js +3 -3
- package/dist/engine/mondoDb/mongoDB.js +3 -3
- package/dist/engine/multer/multer_configs.js +2 -2
- package/dist/engine/server/server.d.ts +5 -3
- package/dist/engine/server/server.js +30 -9
- package/dist/engine/sql/mySql.d.ts +2 -2
- package/dist/engine/sql/mySql.js +3 -3
- package/dist/engine/sql/pgSql.js +3 -3
- package/dist/utility/libs/env.js +1 -1
- package/dist/utility/libs/index.d.ts +1772 -0
- package/dist/utility/libs/index.js +101 -0
- package/dist/utility/libs/interface.d.ts +5 -7
- package/dist/utility/libs/run-all.js +46 -0
- package/dist/utility/libs/run-all.js.map +1 -0
- package/dist/{chunk-LFRKRR7G.js → utility/libs/run-bucket.js} +4 -7
- package/dist/utility/libs/run-bucket.js.map +1 -0
- package/dist/utility/libs/run-node-server.js +35 -0
- package/dist/utility/libs/run-node-server.js.map +1 -0
- package/dist/utility/libs/types.d.ts +11 -31
- package/dist/utility/libs/types.js +1 -1
- package/dist/utility/libs/types.js.map +1 -1
- package/dist/utility/utilis/cloud_storage/deleteFile.js +7 -54
- package/dist/utility/utilis/cloud_storage/deleteFile.js.map +1 -1
- package/dist/utility/utilis/cloud_storage/deleteFiles.js +7 -83
- package/dist/utility/utilis/cloud_storage/deleteFiles.js.map +1 -1
- package/dist/utility/utilis/cloud_storage/downloadFile.js +8 -68
- package/dist/utility/utilis/cloud_storage/downloadFile.js.map +1 -1
- package/dist/utility/utilis/cloud_storage/downloadFiles.js +8 -82
- package/dist/utility/utilis/cloud_storage/downloadFiles.js.map +1 -1
- package/dist/utility/utilis/cloud_storage/uploadFile.js +6 -6
- package/dist/utility/utilis/cloud_storage/uploadFiles.d.ts +0 -64
- package/dist/utility/utilis/cloud_storage/uploadFiles.js +9 -43
- package/dist/utility/utilis/cloud_storage/uploadFiles.js.map +1 -1
- package/dist/utility/utilis/general/error_handler.js +1 -1
- package/dist/utility/utilis/general/file-operations.d.ts +7 -132
- package/dist/utility/utilis/general/file-operations.js +6 -4
- package/dist/utility/utilis/general/sqlDb.js.d.ts +0 -141
- package/dist/utility/utilis/general/sqlDb.js.js +2 -2
- package/dist/utility/utilis/general/uuids.d.ts +0 -43
- package/dist/utility/utilis/general/uuids.js +1 -1
- package/dist/utility/utilis/general/web.d.ts +2 -238
- package/dist/utility/utilis/general/web.js +4 -4
- package/dist/utility/utilis/mongoDb/buldWrite.d.ts +0 -44
- package/dist/utility/utilis/mongoDb/buldWrite.js +6 -28
- package/dist/utility/utilis/mongoDb/buldWrite.js.map +1 -1
- package/dist/utility/utilis/mongoDb/deleteDocument.d.ts +0 -45
- package/dist/utility/utilis/mongoDb/deleteDocument.js +6 -30
- package/dist/utility/utilis/mongoDb/deleteDocument.js.map +1 -1
- package/dist/utility/utilis/mongoDb/insertField.d.ts +2 -33
- package/dist/utility/utilis/mongoDb/insertField.js +7 -30
- package/dist/utility/utilis/mongoDb/insertField.js.map +1 -1
- package/dist/utility/utilis/mongoDb/insertFields.d.ts +2 -41
- package/dist/utility/utilis/mongoDb/insertFields.js +7 -32
- package/dist/utility/utilis/mongoDb/insertFields.js.map +1 -1
- package/dist/utility/utilis/mongoDb/updateFiled.d.ts +0 -56
- package/dist/utility/utilis/mongoDb/updateFiled.js +6 -36
- package/dist/utility/utilis/mongoDb/updateFiled.js.map +1 -1
- package/dist/utility/utilis/multer/upload_batch.js +5 -12
- package/dist/utility/utilis/multer/upload_batch.js.map +1 -1
- package/dist/utility/utilis/multer/upload_single.d.ts +41 -0
- package/dist/utility/utilis/multer/upload_single.js +5 -11
- package/dist/utility/utilis/multer/upload_single.js.map +1 -1
- package/dist/utility/utilis/postgres/executeQuery.d.ts +2 -205
- package/dist/utility/utilis/postgres/executeQuery.js +11 -41
- package/dist/utility/utilis/postgres/executeQuery.js.map +1 -1
- package/dist/utility/utilis/postgres/subSqlfiles/executeMySqlQuery.js +4 -4
- package/dist/utility/utilis/postgres/subSqlfiles/executePgQuery.js +4 -4
- package/dist/utility/utilis/server/app.js +30 -12
- package/dist/utility/utilis/server/app.js.map +1 -1
- package/dist/utility/utilis/server/server.d.ts +2 -2
- package/dist/utility/utilis/server/server.js +30 -20
- package/dist/utility/utilis/server/server.js.map +1 -1
- package/package.json +55 -56
- package/dist/chunk-5A3RVJNT.js +0 -19
- package/dist/chunk-5A3RVJNT.js.map +0 -1
- package/dist/chunk-D7A4TEXY.js.map +0 -1
- package/dist/chunk-EWQYVPOL.js.map +0 -1
- package/dist/chunk-ICFMWIIJ.js +0 -53
- package/dist/chunk-ICFMWIIJ.js.map +0 -1
- package/dist/chunk-LFRKRR7G.js.map +0 -1
- package/dist/chunk-MNSQSU7T.js.map +0 -1
- package/dist/chunk-NIOLLLJJ.js +0 -44
- package/dist/chunk-NIOLLLJJ.js.map +0 -1
- package/dist/chunk-P5XJG7OG.js.map +0 -1
- package/dist/chunk-QVTKG7FD.js.map +0 -1
- package/dist/chunk-SSFPGDA3.js.map +0 -1
- package/dist/chunk-TP3K7DMH.js.map +0 -1
- package/dist/chunk-UWIMSKL5.js.map +0 -1
- package/dist/chunk-VFF4YFA3.js.map +0 -1
- package/dist/chunk-W3W3X2OE.js.map +0 -1
- package/dist/chunk-X3R3RLXY.js.map +0 -1
- package/dist/chunk-XBJ3SJ26.js.map +0 -1
- package/dist/chunk-YTBSGKGF.js.map +0 -1
- package/dist/chunk-YWFCWT6R.js +0 -23
- package/dist/chunk-YWFCWT6R.js.map +0 -1
- package/dist/chunk-ZMDJ45KH.js.map +0 -1
- package/dist/engine/script/run-all.d.ts +0 -3
- package/dist/engine/script/run-all.js +0 -8
- package/dist/engine/script/run-bucket.d.ts +0 -3
- package/dist/engine/script/run-bucket.js +0 -8
- package/dist/engine/script/run-bucket.js.map +0 -1
- package/dist/engine/script/run-node-server.d.ts +0 -3
- package/dist/engine/script/run-node-server.js +0 -8
- package/dist/engine/script/run-node-server.js.map +0 -1
- package/dist/engine/server/app.d.ts +0 -5
- package/dist/engine/server/app.js +0 -10
- package/dist/engine/server/app.js.map +0 -1
- package/dist/utility/script/run-all.js +0 -8
- package/dist/utility/script/run-all.js.map +0 -1
- package/dist/utility/script/run-bucket.js +0 -8
- package/dist/utility/script/run-bucket.js.map +0 -1
- package/dist/utility/script/run-node-server.js +0 -8
- package/dist/utility/script/run-node-server.js.map +0 -1
- package/dist/utility/utilis/cloud_storage/s3Client.d.ts +0 -5
- package/dist/utility/utilis/cloud_storage/s3Client.js +0 -17
- package/dist/utility/utilis/cloud_storage/s3Client.js.map +0 -1
- /package/dist/{engine/script/run-all.js.map → utility/libs/index.js.map} +0 -0
- /package/dist/utility/{script → libs}/run-all.d.ts +0 -0
- /package/dist/utility/{script → libs}/run-bucket.d.ts +0 -0
- /package/dist/utility/{script → libs}/run-node-server.d.ts +0 -0
|
@@ -1,86 +1,12 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
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/downloadFiles.ts
|
|
22
|
-
import { GetObjectCommand } from "@aws-sdk/client-s3";
|
|
23
|
-
import path from "path";
|
|
24
|
-
import fsPromises from "fs/promises";
|
|
25
|
-
import * as fs from "fs";
|
|
26
|
-
import { pipeline } from "stream/promises";
|
|
27
|
-
var downloadFiles = /* @__PURE__ */ __name(async ({
|
|
28
|
-
files,
|
|
29
|
-
globalPath
|
|
30
|
-
}) => {
|
|
31
|
-
const hasIndividualOutputPath = files.some(
|
|
32
|
-
(file) => file.outputPath && file.outputPath.length > 0
|
|
33
|
-
);
|
|
34
|
-
if (globalPath && hasIndividualOutputPath) {
|
|
35
|
-
throw new Error(
|
|
36
|
-
"Conflict: Cannot specify both 'globalPath' and individual 'outputPath' on files."
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
const downloadPromises = files.map(async (file) => {
|
|
40
|
-
const { url, outputPath } = file;
|
|
41
|
-
try {
|
|
42
|
-
const key = getKeyFromUrl(url);
|
|
43
|
-
const command = new GetObjectCommand({
|
|
44
|
-
Bucket: ENV.BUCKET_NAME,
|
|
45
|
-
Key: key
|
|
46
|
-
});
|
|
47
|
-
const response = await s3Client.send(command);
|
|
48
|
-
if (!response.Body) {
|
|
49
|
-
return {
|
|
50
|
-
status: false,
|
|
51
|
-
url,
|
|
52
|
-
error: new Error(`Empty response body received for key: ${key}`)
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
const fileExtension = getFileExtension(url);
|
|
56
|
-
const fileName = generateUniqueValue(16);
|
|
57
|
-
const finalFileName = `${fileName}.${fileExtension}`;
|
|
58
|
-
const resolvedPathSegments = outputPath || (globalPath ? [globalPath] : []);
|
|
59
|
-
const targetPath = downloadedFilePath({
|
|
60
|
-
path: resolvedPathSegments,
|
|
61
|
-
fileName: finalFileName
|
|
62
|
-
});
|
|
63
|
-
const dir = path.dirname(targetPath);
|
|
64
|
-
if (!fs.existsSync(dir)) {
|
|
65
|
-
await fsPromises.mkdir(dir, { recursive: true });
|
|
66
|
-
}
|
|
67
|
-
const stream = response.Body;
|
|
68
|
-
await pipeline(stream, fs.createWriteStream(targetPath));
|
|
69
|
-
return {
|
|
70
|
-
status: true,
|
|
71
|
-
url,
|
|
72
|
-
path: targetPath
|
|
73
|
-
};
|
|
74
|
-
} catch (error) {
|
|
75
|
-
return {
|
|
76
|
-
status: false,
|
|
77
|
-
url,
|
|
78
|
-
error: error instanceof Error ? error : new Error(String(error))
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
return Promise.all(downloadPromises);
|
|
83
|
-
}, "downloadFiles");
|
|
2
|
+
downloadFiles
|
|
3
|
+
} from "../../../chunk-452DWS46.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";
|
|
84
10
|
export {
|
|
85
11
|
downloadFiles
|
|
86
12
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
upload_file
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
5
|
-
import "../../../chunk-
|
|
6
|
-
import "../../../chunk-
|
|
7
|
-
import "../../../chunk-
|
|
8
|
-
import "../../../chunk-
|
|
3
|
+
} from "../../../chunk-ZGOMCU4T.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
9
|
import "../../../chunk-7QVYU63E.js";
|
|
10
10
|
export {
|
|
11
11
|
upload_file
|
|
@@ -4,70 +4,6 @@ import '../../libs/types.js';
|
|
|
4
4
|
import 'express';
|
|
5
5
|
import '../../libs/env.js';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Uploads multiple files to the configured S3-compatible storage bucket
|
|
9
|
-
* concurrently with a configurable concurrency limit.
|
|
10
|
-
*
|
|
11
|
-
* Each file is uploaded using the `upload_file` function. A global path can
|
|
12
|
-
* be applied to all files, or each file can specify its own individual path,
|
|
13
|
-
* but both options cannot be used at the same time.
|
|
14
|
-
*
|
|
15
|
-
* Failed uploads are collected separately from successful uploads, allowing
|
|
16
|
-
* the caller to inspect the result of every individual file without stopping
|
|
17
|
-
* the entire batch operation.
|
|
18
|
-
*
|
|
19
|
-
* @param params - Configuration options for the batch upload.
|
|
20
|
-
* @param params.files - The files to upload along with their optional paths.
|
|
21
|
-
* @param params.globalPath - An optional path applied to all files that do
|
|
22
|
-
* not specify an individual path.
|
|
23
|
-
* @param params.concurrency - The maximum number of files uploaded
|
|
24
|
-
* concurrently. Defaults to `5`.
|
|
25
|
-
* @returns A promise resolving to a `FilesUploadedResponseData` containing
|
|
26
|
-
* separate arrays of successfully uploaded and failed files.
|
|
27
|
-
* @throws {Error} If both `globalPath` and an individual file `path` are
|
|
28
|
-
* provided.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* const result = await upload_files({
|
|
32
|
-
* files: [
|
|
33
|
-
* { file: file1 },
|
|
34
|
-
* { file: file2 },
|
|
35
|
-
* { file: file3 },
|
|
36
|
-
* ],
|
|
37
|
-
* globalPath: ['temporary_files'],
|
|
38
|
-
* concurrency: 5,
|
|
39
|
-
* });
|
|
40
|
-
*
|
|
41
|
-
* console.log('Successful uploads:', result.successFiles);
|
|
42
|
-
* console.log('Failed uploads:', result.failedFiles);
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* const result = await upload_files({
|
|
46
|
-
* files: [
|
|
47
|
-
* {
|
|
48
|
-
* file: file1,
|
|
49
|
-
* path: ['documents', 'reports'],
|
|
50
|
-
* },
|
|
51
|
-
* {
|
|
52
|
-
* file: file2,
|
|
53
|
-
* path: ['documents', 'images'],
|
|
54
|
-
* },
|
|
55
|
-
* ],
|
|
56
|
-
* concurrency: 10,
|
|
57
|
-
* });
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* // This throws because globalPath and an individual path cannot be used together.
|
|
61
|
-
* const result = await upload_files({
|
|
62
|
-
* files: [
|
|
63
|
-
* {
|
|
64
|
-
* file: file1,
|
|
65
|
-
* path: ['documents'],
|
|
66
|
-
* },
|
|
67
|
-
* ],
|
|
68
|
-
* globalPath: ['temporary_files'],
|
|
69
|
-
* });
|
|
70
|
-
*/
|
|
71
7
|
declare const upload_files: ({ files, globalPath, concurrency }: UploadFilesInput) => Promise<FilesUploadedResponseData>;
|
|
72
8
|
|
|
73
9
|
export { upload_files };
|
|
@@ -1,47 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
} from "../../../chunk-
|
|
4
|
-
import "../../../chunk-
|
|
5
|
-
import "../../../chunk-
|
|
6
|
-
import "../../../chunk-
|
|
7
|
-
import "../../../chunk-
|
|
8
|
-
import "../../../chunk-
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
} from "../../../chunk-7QVYU63E.js";
|
|
12
|
-
|
|
13
|
-
// src/utility/utilis/cloud_storage/uploadFiles.ts
|
|
14
|
-
import pLimit from "p-limit";
|
|
15
|
-
var upload_files = /* @__PURE__ */ __name(async ({
|
|
16
|
-
files,
|
|
17
|
-
globalPath,
|
|
18
|
-
concurrency = 5
|
|
19
|
-
}) => {
|
|
20
|
-
if (globalPath && files.some((item) => item.path && item.path.length > 0)) {
|
|
21
|
-
throw new Error("Invalid options: 'globalPath' and individual 'path' cannot both exist.");
|
|
22
|
-
}
|
|
23
|
-
const limiter = pLimit(concurrency);
|
|
24
|
-
const returnData = {
|
|
25
|
-
successFiles: [],
|
|
26
|
-
failedFiles: []
|
|
27
|
-
};
|
|
28
|
-
const uploadTasks = files.map(
|
|
29
|
-
({ file, path }) => limiter(async () => {
|
|
30
|
-
const resolvedPath = path ?? (globalPath?.length ? globalPath : void 0);
|
|
31
|
-
const result = await upload_file({
|
|
32
|
-
file,
|
|
33
|
-
path: resolvedPath
|
|
34
|
-
});
|
|
35
|
-
if ("error" in result && result.error) {
|
|
36
|
-
returnData.failedFiles.push(result);
|
|
37
|
-
} else {
|
|
38
|
-
returnData.successFiles.push(result);
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
);
|
|
42
|
-
await Promise.all(uploadTasks);
|
|
43
|
-
return returnData;
|
|
44
|
-
}, "upload_files");
|
|
2
|
+
upload_files
|
|
3
|
+
} from "../../../chunk-O2ZDXQ2Z.js";
|
|
4
|
+
import "../../../chunk-ZGOMCU4T.js";
|
|
5
|
+
import "../../../chunk-IZEPCXYK.js";
|
|
6
|
+
import "../../../chunk-ZC33GE2U.js";
|
|
7
|
+
import "../../../chunk-J3P6W53K.js";
|
|
8
|
+
import "../../../chunk-QW2GGDEG.js";
|
|
9
|
+
import "../../../chunk-LE2SDA4O.js";
|
|
10
|
+
import "../../../chunk-7QVYU63E.js";
|
|
45
11
|
export {
|
|
46
12
|
upload_files
|
|
47
13
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,141 +1,16 @@
|
|
|
1
|
-
import { PathOptions } from '../../libs/
|
|
1
|
+
import { PathOptions } from '../../libs/types.js';
|
|
2
|
+
import { DownloadablePath } from '../../libs/interface.js';
|
|
2
3
|
import 'mongodb';
|
|
3
|
-
import '../../libs/types.js';
|
|
4
4
|
import 'express';
|
|
5
5
|
import '../../libs/env.js';
|
|
6
6
|
|
|
7
7
|
declare function fileExistsAsync(filePath: string): Promise<boolean>;
|
|
8
|
-
|
|
9
|
-
* Extracts the file extension from a supported file input.
|
|
10
|
-
*
|
|
11
|
-
* Supports Express Multer files, Web API `File` objects, raw `Buffer` values,
|
|
12
|
-
* and file paths or URLs. For URLs and paths, query parameters and hash
|
|
13
|
-
* fragments are ignored when determining the extension.
|
|
14
|
-
*
|
|
15
|
-
* @param input - The file, buffer, path, or URL from which to extract the extension.
|
|
16
|
-
* @returns The file extension without the leading dot, converted to lowercase.
|
|
17
|
-
* Returns an empty string if no extension can be determined.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* const extension = getFileExtension('https://example.com/files/image.PNG');
|
|
21
|
-
* // Returns: "png"
|
|
22
|
-
*
|
|
23
|
-
* @example
|
|
24
|
-
* const extension = getFileExtension(req.file);
|
|
25
|
-
* // Returns: "pdf"
|
|
26
|
-
*
|
|
27
|
-
* @example
|
|
28
|
-
* const extension = getFileExtension('documents/report.pdf?download=true');
|
|
29
|
-
* // Returns: "pdf"
|
|
30
|
-
*
|
|
31
|
-
* @example
|
|
32
|
-
* const extension = getFileExtension(buffer);
|
|
33
|
-
* // Returns: ""
|
|
34
|
-
*/
|
|
8
|
+
declare function fileExistsSync(filePath: string): boolean;
|
|
35
9
|
declare function getFileExtension(input: Express.Multer.File | File | Buffer | string): string;
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
*
|
|
39
|
-
* Combines the path prefix, path segments, path postfix, and file name,
|
|
40
|
-
* while removing empty values and normalizing redundant slashes.
|
|
41
|
-
*
|
|
42
|
-
* If `fileName` is a Web API `File` object, its `name` property is used.
|
|
43
|
-
*
|
|
44
|
-
* @param options - The path components used to construct the final path.
|
|
45
|
-
* @param options.path_prefix - An optional prefix to prepend to the path.
|
|
46
|
-
* @param options.path - An array of path segments.
|
|
47
|
-
* @param options.path_postfix - An optional postfix to append before the file name.
|
|
48
|
-
* @param options.fileName - The file name or a Web API `File` object.
|
|
49
|
-
* @returns A normalized path with components separated by a single slash.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* const filePath = buildPath({
|
|
53
|
-
* path_prefix: 'uploads',
|
|
54
|
-
* path: ['documents', 'reports'],
|
|
55
|
-
* fileName: 'report.pdf',
|
|
56
|
-
* });
|
|
57
|
-
* // Returns: "uploads/documents/reports/report.pdf"
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* const filePath = buildPath({
|
|
61
|
-
* path: ['documents//', '/reports/'],
|
|
62
|
-
* fileName: 'report.pdf',
|
|
63
|
-
* });
|
|
64
|
-
* // Returns: "documents/reports/report.pdf"
|
|
65
|
-
*/
|
|
66
|
-
declare function buildPath({ path_prefix, path, path_postfix, fileName, }: PathOptions): string;
|
|
67
|
-
/**
|
|
68
|
-
* Builds the local file path for a downloaded file.
|
|
69
|
-
*
|
|
70
|
-
* Removes any occurrence of the configured in-app bucket from the provided
|
|
71
|
-
* path to prevent duplicating the bucket name, then constructs the final
|
|
72
|
-
* path using the configured in-app bucket as the path prefix.
|
|
73
|
-
*
|
|
74
|
-
* @param options - The path and file name options used to build the downloaded file path.
|
|
75
|
-
* @param options.path - The path segments leading to the file.
|
|
76
|
-
* @param options.fileName - The name of the file or a Web API `File` object.
|
|
77
|
-
* @returns The complete local path for the downloaded file.
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* const filePath = downloadedFilePath({
|
|
81
|
-
* path: ['documents', 'reports'],
|
|
82
|
-
* fileName: 'report.pdf',
|
|
83
|
-
* });
|
|
84
|
-
* // Returns a path prefixed with ENV.IN_APP_BUCKET.
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* const filePath = downloadedFilePath({
|
|
88
|
-
* path: [ENV.IN_APP_BUCKET, 'documents'],
|
|
89
|
-
* fileName: file,
|
|
90
|
-
* });
|
|
91
|
-
* // The duplicate bucket segment is removed before building the path.
|
|
92
|
-
*/
|
|
93
|
-
declare function downloadedFilePath({ path, fileName }: PathOptions): string;
|
|
94
|
-
/**
|
|
95
|
-
* Determines the MIME content type of a file from its available metadata
|
|
96
|
-
* or, when given a file path or URL, from its file extension.
|
|
97
|
-
*
|
|
98
|
-
* Supports Express Multer files, Web API `File` objects, raw `Buffer` values,
|
|
99
|
-
* and file paths or URLs.
|
|
100
|
-
*
|
|
101
|
-
* @param file - The file, buffer, path, or URL whose content type should be determined.
|
|
102
|
-
* @returns A promise resolving to the detected MIME content type.
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* const contentType = await getFileContentType(req.file);
|
|
106
|
-
* // Returns something like: "image/jpeg"
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* const contentType = await getFileContentType('/uploads/document.pdf');
|
|
110
|
-
* // Returns: "application/pdf"
|
|
111
|
-
*
|
|
112
|
-
* @example
|
|
113
|
-
* const contentType = await getFileContentType(buffer);
|
|
114
|
-
* // Returns: "application/octet-stream"
|
|
115
|
-
*/
|
|
10
|
+
declare function buildPath(options: PathOptions): string;
|
|
11
|
+
declare function getInAppBucketDownloadPath({ segments, fileName, }?: DownloadablePath): string;
|
|
116
12
|
declare const getFileContentType: (file: Express.Multer.File | File | Buffer | string) => Promise<string>;
|
|
117
|
-
|
|
118
|
-
* Determines whether the provided value is a URL or a local/server based file path.
|
|
119
|
-
*
|
|
120
|
-
* If the value is a valid HTTP/HTTPS URL, the configured URL environment
|
|
121
|
-
* value is returned. Otherwise, the configured local path environment value
|
|
122
|
-
* is returned.
|
|
123
|
-
*
|
|
124
|
-
* @param val - The URL or local file path to evaluate.
|
|
125
|
-
* @returns The configured URL or local path based on the input type.
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* const basePath = url_or_path('https://example.com/file.png');
|
|
129
|
-
* // Returns ENV.URL
|
|
130
|
-
*
|
|
131
|
-
* @example
|
|
132
|
-
* const basePath = url_or_path('/uploads/file.png');
|
|
133
|
-
* // Returns ENV.PATH
|
|
134
|
-
*/
|
|
135
|
-
declare const url_or_path: (val: string) => string;
|
|
136
|
-
/**
|
|
137
|
-
* Safely normalizes Buffer, Express.Multer.File, Web File, or File Path into Uint8Array
|
|
138
|
-
*/
|
|
13
|
+
declare const url_or_path: (val: string) => "url" | "path";
|
|
139
14
|
declare function toUint8Array(file: Express.Multer.File | File | Buffer | string): Promise<Uint8Array>;
|
|
140
15
|
|
|
141
|
-
export { buildPath,
|
|
16
|
+
export { buildPath, fileExistsAsync, fileExistsSync, getFileContentType, getFileExtension, getInAppBucketDownloadPath, toUint8Array, url_or_path };
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
2
|
buildPath,
|
|
3
|
-
downloadedFilePath,
|
|
4
3
|
fileExistsAsync,
|
|
4
|
+
fileExistsSync,
|
|
5
5
|
getFileContentType,
|
|
6
6
|
getFileExtension,
|
|
7
|
+
getInAppBucketDownloadPath,
|
|
7
8
|
toUint8Array,
|
|
8
9
|
url_or_path
|
|
9
|
-
} from "../../../chunk-
|
|
10
|
-
import "../../../chunk-
|
|
10
|
+
} from "../../../chunk-QW2GGDEG.js";
|
|
11
|
+
import "../../../chunk-LE2SDA4O.js";
|
|
11
12
|
import "../../../chunk-7QVYU63E.js";
|
|
12
13
|
export {
|
|
13
14
|
buildPath,
|
|
14
|
-
downloadedFilePath,
|
|
15
15
|
fileExistsAsync,
|
|
16
|
+
fileExistsSync,
|
|
16
17
|
getFileContentType,
|
|
17
18
|
getFileExtension,
|
|
19
|
+
getInAppBucketDownloadPath,
|
|
18
20
|
toUint8Array,
|
|
19
21
|
url_or_path
|
|
20
22
|
};
|
|
@@ -3,149 +3,8 @@ import 'mongodb';
|
|
|
3
3
|
import 'express';
|
|
4
4
|
import '../../libs/env.js';
|
|
5
5
|
|
|
6
|
-
/**
|
|
7
|
-
* Detects the SQL database type from a database connection URL.
|
|
8
|
-
*
|
|
9
|
-
* The function supports MySQL and PostgreSQL connection URL schemes,
|
|
10
|
-
* including common driver-specific variants such as `mysql2`,
|
|
11
|
-
* `mysql+pymysql`, `postgresql+psycopg2`, and `postgresql+asyncpg`.
|
|
12
|
-
*
|
|
13
|
-
* If the connection string does not contain a recognized protocol, the
|
|
14
|
-
* function attempts to identify the database using keywords in the
|
|
15
|
-
* connection string or the default database ports:
|
|
16
|
-
*
|
|
17
|
-
* - MySQL: `3306`
|
|
18
|
-
* - PostgreSQL: `5432`
|
|
19
|
-
*
|
|
20
|
-
* Invalid URLs are also checked as raw connection strings before an error
|
|
21
|
-
* is thrown. This allows common connection strings without a protocol to
|
|
22
|
-
* still be detected.
|
|
23
|
-
*
|
|
24
|
-
* @param url - The SQL database connection URL or connection string.
|
|
25
|
-
* @returns `ENV.MY_SQL` for MySQL connections or `ENV.POSTGRES_SQL` for
|
|
26
|
-
* PostgreSQL connections.
|
|
27
|
-
* @throws {Error} If the URL is invalid or the database type cannot be
|
|
28
|
-
* identified as MySQL or PostgreSQL.
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* // Detect PostgreSQL from a standard connection URL.
|
|
32
|
-
* const database = detectSQLDatabase(
|
|
33
|
-
* 'postgresql://user:password@localhost:5432/my_database'
|
|
34
|
-
* );
|
|
35
|
-
*
|
|
36
|
-
* // Returns: ENV.POSTGRES_SQL
|
|
37
|
-
*
|
|
38
|
-
* @example
|
|
39
|
-
* // Detect MySQL from a standard connection URL.
|
|
40
|
-
* const database = detectSQLDatabase(
|
|
41
|
-
* 'mysql://user:password@localhost:3306/my_database'
|
|
42
|
-
* );
|
|
43
|
-
*
|
|
44
|
-
* // Returns: ENV.MY_SQL
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* // Driver-specific PostgreSQL URLs are also supported.
|
|
48
|
-
* const database = detectSQLDatabase(
|
|
49
|
-
* 'postgresql+psycopg2://user:password@localhost:5432/my_database'
|
|
50
|
-
* );
|
|
51
|
-
*
|
|
52
|
-
* // Returns: ENV.POSTGRES_SQL
|
|
53
|
-
*
|
|
54
|
-
* @example
|
|
55
|
-
* // A connection string without a recognized protocol can be detected
|
|
56
|
-
* // using the default PostgreSQL port.
|
|
57
|
-
* const database = detectSQLDatabase(
|
|
58
|
-
* 'localhost:5432/my_database'
|
|
59
|
-
* );
|
|
60
|
-
*
|
|
61
|
-
* // Returns: ENV.POSTGRES_SQL
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* // Throws when the database type cannot be determined.
|
|
65
|
-
* const database = detectSQLDatabase(
|
|
66
|
-
* 'mongodb://localhost:27017/my_database'
|
|
67
|
-
* );
|
|
68
|
-
*
|
|
69
|
-
* // Error: Unsupported or unrecognized database type.
|
|
70
|
-
*/
|
|
71
6
|
declare function detectSQLDatabase(url: string): DatabaseType;
|
|
72
|
-
/**
|
|
73
|
-
* Determines whether a database connection URL represents a MySQL database.
|
|
74
|
-
*
|
|
75
|
-
* This function delegates database detection to `detectSQLDatabase()` and
|
|
76
|
-
* compares the detected database type with the configured MySQL database
|
|
77
|
-
* identifier.
|
|
78
|
-
*
|
|
79
|
-
* Any error encountered while parsing or detecting the database type is
|
|
80
|
-
* handled internally, and the function returns `false` instead of throwing.
|
|
81
|
-
* This makes the function safe to use when validating or conditionally
|
|
82
|
-
* selecting a database implementation.
|
|
83
|
-
*
|
|
84
|
-
* @param url - The SQL database connection URL or connection string.
|
|
85
|
-
* @returns `true` if the URL represents a MySQL database; otherwise `false`.
|
|
86
|
-
*
|
|
87
|
-
* @example
|
|
88
|
-
* // Standard MySQL connection URL.
|
|
89
|
-
* const result = isMySQL(
|
|
90
|
-
* 'mysql://user:password@localhost:3306/my_database'
|
|
91
|
-
* );
|
|
92
|
-
*
|
|
93
|
-
* // Returns: true
|
|
94
|
-
*
|
|
95
|
-
* @example
|
|
96
|
-
* // PostgreSQL URL.
|
|
97
|
-
* const result = isMySQL(
|
|
98
|
-
* 'postgresql://user:password@localhost:5432/my_database'
|
|
99
|
-
* );
|
|
100
|
-
*
|
|
101
|
-
* // Returns: false
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* // Invalid or unsupported connection URL.
|
|
105
|
-
* const result = isMySQL('invalid-database-url');
|
|
106
|
-
*
|
|
107
|
-
* // Returns: false instead of throwing an error.
|
|
108
|
-
*/
|
|
109
7
|
declare function isMySQL(url: string): boolean;
|
|
110
|
-
/**
|
|
111
|
-
* Determines whether a database connection URL represents a PostgreSQL
|
|
112
|
-
* database.
|
|
113
|
-
*
|
|
114
|
-
* This function delegates database detection to `detectSQLDatabase()` and
|
|
115
|
-
* compares the detected database type with the configured PostgreSQL
|
|
116
|
-
* identifier.
|
|
117
|
-
*
|
|
118
|
-
* Any error encountered while parsing or detecting the database type is
|
|
119
|
-
* handled internally, causing the function to return `false` instead of
|
|
120
|
-
* throwing. This makes the function safe to use when conditionally selecting
|
|
121
|
-
* PostgreSQL-specific database logic.
|
|
122
|
-
*
|
|
123
|
-
* @param url - The SQL database connection URL or connection string.
|
|
124
|
-
* @returns `true` if the URL represents a PostgreSQL database; otherwise
|
|
125
|
-
* `false`.
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* // Standard PostgreSQL connection URL.
|
|
129
|
-
* const result = isPostgreSQL(
|
|
130
|
-
* 'postgresql://user:password@localhost:5432/my_database'
|
|
131
|
-
* );
|
|
132
|
-
*
|
|
133
|
-
* // Returns: true
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
* // MySQL connection URL.
|
|
137
|
-
* const result = isPostgreSQL(
|
|
138
|
-
* 'mysql://user:password@localhost:3306/my_database'
|
|
139
|
-
* );
|
|
140
|
-
*
|
|
141
|
-
* // Returns: false
|
|
142
|
-
*
|
|
143
|
-
* @example
|
|
144
|
-
* // Invalid or unsupported connection URL.
|
|
145
|
-
* const result = isPostgreSQL('invalid-database-url');
|
|
146
|
-
*
|
|
147
|
-
* // Returns: false instead of throwing an error.
|
|
148
|
-
*/
|
|
149
8
|
declare function isPostgreSQL(url: string): boolean;
|
|
150
9
|
|
|
151
10
|
export { detectSQLDatabase, isMySQL, isPostgreSQL };
|
|
@@ -2,8 +2,8 @@ import {
|
|
|
2
2
|
detectSQLDatabase,
|
|
3
3
|
isMySQL,
|
|
4
4
|
isPostgreSQL
|
|
5
|
-
} from "../../../chunk-
|
|
6
|
-
import "../../../chunk-
|
|
5
|
+
} from "../../../chunk-O5ILFRFV.js";
|
|
6
|
+
import "../../../chunk-LE2SDA4O.js";
|
|
7
7
|
import "../../../chunk-7QVYU63E.js";
|
|
8
8
|
export {
|
|
9
9
|
detectSQLDatabase,
|
|
@@ -4,49 +4,6 @@ import '../../libs/types.js';
|
|
|
4
4
|
import 'express';
|
|
5
5
|
import '../../libs/env.js';
|
|
6
6
|
|
|
7
|
-
/**
|
|
8
|
-
* Generates one or more cryptographically secure unique values.
|
|
9
|
-
*
|
|
10
|
-
* Values can be generated using hexadecimal characters or a custom
|
|
11
|
-
* alphanumeric character set. Optional timestamps and prefixes can be
|
|
12
|
-
* included in the generated values.
|
|
13
|
-
*
|
|
14
|
-
* When `count` is provided, multiple unique values are returned as an array.
|
|
15
|
-
* Otherwise, a single string is returned.
|
|
16
|
-
*
|
|
17
|
-
* @param length - The length of the randomly generated portion of each value.
|
|
18
|
-
* @param options - Optional configuration for generating the value(s).
|
|
19
|
-
* @param options.useHex - Whether to generate the random portion using hexadecimal characters.
|
|
20
|
-
* @param options.includeTimestamp - Whether to prepend a hexadecimal timestamp.
|
|
21
|
-
* @param options.prefix - An optional prefix to prepend to the generated value.
|
|
22
|
-
* @param options.count - The number of values to generate. If omitted, one value is returned.
|
|
23
|
-
* @returns A single unique string when `count` is not provided, or an array of unique strings when `count` is specified.
|
|
24
|
-
* @throws {Error} If `length` or `count` is less than or equal to zero.
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* const id = generateUniqueValue(16);
|
|
28
|
-
* // Returns: "aZ7_kP2mQ9xL3nBc"
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* const id = generateUniqueValue(16, {
|
|
32
|
-
* useHex: true,
|
|
33
|
-
* prefix: 'file',
|
|
34
|
-
* });
|
|
35
|
-
* // Returns: "file-7f3a9c12d84e..."
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* const id = generateUniqueValue(12, {
|
|
39
|
-
* includeTimestamp: true,
|
|
40
|
-
* });
|
|
41
|
-
* // Returns: "198a7f3c12a-7Kx9mP..."
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* const ids = generateUniqueValue(10, {
|
|
45
|
-
* count: 5,
|
|
46
|
-
* prefix: 'file',
|
|
47
|
-
* });
|
|
48
|
-
* // Returns: ["file-...", "file-...", "file-...", "file-...", "file-..."]
|
|
49
|
-
*/
|
|
50
7
|
declare function generateUniqueValue(length: number, options?: GenerateIdOptions): string;
|
|
51
8
|
declare function generateUniqueValue(length: number, options: GenerateIdOptions & {
|
|
52
9
|
count: number;
|