@common_ch/common 1.0.270 → 1.0.271
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.
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
type EstimateResult = {
|
|
2
2
|
file: string;
|
|
3
|
-
|
|
3
|
+
mimeType: string;
|
|
4
4
|
sizeMB: number;
|
|
5
5
|
sizeGB: number;
|
|
6
6
|
costPerDayUSD: number;
|
|
7
7
|
costPerMonthUSD: number;
|
|
8
8
|
};
|
|
9
|
-
export declare function
|
|
9
|
+
export declare function estimateOpenAIStorageCost(filePath: string, mimeType: string, storagePricePerGBPerDay?: number): EstimateResult | {
|
|
10
10
|
error: string;
|
|
11
11
|
};
|
|
12
12
|
export {};
|
|
@@ -3,10 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.estimateOpenAIStorageCost = estimateOpenAIStorageCost;
|
|
7
7
|
const fs_1 = __importDefault(require("fs"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
function
|
|
9
|
+
function estimateOpenAIStorageCost(filePath, mimeType, storagePricePerGBPerDay = 0.10) {
|
|
10
10
|
var _a;
|
|
11
11
|
if (!fs_1.default.existsSync(filePath)) {
|
|
12
12
|
return { error: "File not found" };
|
|
@@ -14,47 +14,46 @@ function estimateStorageCost(filePath, storagePricePerGBPerDay = 0.10) {
|
|
|
14
14
|
const fileSizeBytes = fs_1.default.statSync(filePath).size;
|
|
15
15
|
const fileSizeMB = fileSizeBytes / (1024 * 1024);
|
|
16
16
|
const fileSizeGB = fileSizeBytes / (1024 * 1024 * 1024);
|
|
17
|
-
const ext = path_1.default.extname(filePath).toLowerCase();
|
|
18
17
|
const multipliers = {
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
".
|
|
22
|
-
".
|
|
23
|
-
".
|
|
24
|
-
"
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
31
|
-
"
|
|
32
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
".avi": 1.0,
|
|
18
|
+
"application/pdf": 2.0,
|
|
19
|
+
"application/msword": 2.0,
|
|
20
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document": 2.0,
|
|
21
|
+
"application/vnd.ms-excel": 2.0,
|
|
22
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": 2.0,
|
|
23
|
+
"text/csv": 1.5,
|
|
24
|
+
"text/plain": 1.2,
|
|
25
|
+
"application/json": 1.5,
|
|
26
|
+
"text/markdown": 1.2,
|
|
27
|
+
"application/javascript": 1.5,
|
|
28
|
+
"text/javascript": 1.5,
|
|
29
|
+
"text/typescript": 1.5,
|
|
30
|
+
"text/x-python": 1.5,
|
|
31
|
+
"text/x-java-source": 1.5,
|
|
32
|
+
"text/x-c": 1.5,
|
|
33
|
+
"text/x-c++": 1.5,
|
|
34
|
+
"text/x-csharp": 1.5,
|
|
35
|
+
"text/x-go": 1.5,
|
|
36
|
+
"text/x-ruby": 1.5,
|
|
37
|
+
"application/x-php": 1.5,
|
|
38
|
+
"text/html": 1.3,
|
|
39
|
+
"text/css": 1.3,
|
|
40
|
+
"image/jpeg": 1.0,
|
|
41
|
+
"image/png": 1.0,
|
|
42
|
+
"image/gif": 1.0,
|
|
43
|
+
"image/svg+xml": 1.0,
|
|
44
|
+
"audio/mpeg": 1.0,
|
|
45
|
+
"audio/wav": 1.0,
|
|
46
|
+
"video/mp4": 1.0,
|
|
47
|
+
"video/quicktime": 1.0,
|
|
48
|
+
"video/x-msvideo": 1.0,
|
|
51
49
|
};
|
|
52
|
-
const
|
|
50
|
+
const key = mimeType.toLowerCase();
|
|
51
|
+
const multiplier = (_a = multipliers[key]) !== null && _a !== void 0 ? _a : 1.0;
|
|
53
52
|
const costPerDay = fileSizeGB * storagePricePerGBPerDay * multiplier;
|
|
54
53
|
const costPerMonth = costPerDay * 30;
|
|
55
54
|
return {
|
|
56
55
|
file: path_1.default.basename(filePath),
|
|
57
|
-
|
|
56
|
+
mimeType: key,
|
|
58
57
|
sizeMB: Number(fileSizeMB.toFixed(2)),
|
|
59
58
|
sizeGB: Number(fileSizeGB.toFixed(4)),
|
|
60
59
|
costPerDayUSD: Number(costPerDay.toFixed(5)),
|