axiodb 2.25.73 → 2.26.74
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/lib/Services/Indexation.operation.js +1 -2
- package/lib/Services/Indexation.operation.js.map +1 -1
- package/lib/caching/cache.operation.d.ts +19 -0
- package/lib/caching/cache.operation.js +63 -0
- package/lib/caching/cache.operation.js.map +1 -1
- package/lib/config/Interfaces/Operation/Indexation.operation.interface.d.ts +0 -1
- package/lib/server/config/PortFreeChecker.d.ts +0 -38
- package/lib/server/config/PortFreeChecker.js +0 -74
- package/lib/server/config/PortFreeChecker.js.map +1 -1
- package/lib/server/controller/Stats.controller.d.ts +28 -0
- package/lib/server/controller/Stats.controller.js +127 -0
- package/lib/server/controller/Stats.controller.js.map +1 -0
- package/lib/server/public/AxioControl/.vite/manifest.json +1 -1
- package/lib/server/public/AxioControl/assets/{index-CAFsNx4j.js → index-BCa5aR5j.js} +22 -22
- package/lib/server/public/AxioControl/index.html +1 -1
- package/lib/server/public/AxioControl/sw.js +1 -1
- package/lib/server/router/Router.js +6 -1
- package/lib/server/router/Router.js.map +1 -1
- package/package.json +2 -2
|
@@ -117,8 +117,7 @@ class AxioDB {
|
|
|
117
117
|
const FinalDatabaseInfo = {
|
|
118
118
|
CurrentPath: this.currentPATH,
|
|
119
119
|
RootName: this.RootName,
|
|
120
|
-
|
|
121
|
-
TotalSize: parseFloat((totalSize.data / 1024 / 1024).toFixed(6)),
|
|
120
|
+
TotalSize: parseFloat(totalSize.data),
|
|
122
121
|
TotalDatabases: `${totalDatabases.data.length} Databases`,
|
|
123
122
|
ListOfDatabases: totalDatabases.data,
|
|
124
123
|
DatabaseMap: this.DatabaseMap,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Indexation.operation.js","sourceRoot":"","sources":["../../source/Services/Indexation.operation.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;;;;;;;;;;;;;AAEvD,mBAAmB;AACnB,mFAA2D;A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IAAI,CAAC,cAAc,CAAC,OAAO,CAChC,aAAa,MAAM,uBAAuB,CAC3C,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,aAAa,MAAM,iBAAiB,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;KAAA;CACF;AAxKD,wBAwKC"}
|
|
@@ -44,6 +44,25 @@ export declare class InMemoryCache {
|
|
|
44
44
|
* @returns A Promise that resolves to true when the cache has been successfully cleared.
|
|
45
45
|
*/
|
|
46
46
|
clearAllCache(): Promise<boolean>;
|
|
47
|
+
/**
|
|
48
|
+
* Retrieves detailed information about the current state of the cache.
|
|
49
|
+
*
|
|
50
|
+
* This method calculates:
|
|
51
|
+
* - Total estimated size of the cache in bytes (including keys, values, and timestamps)
|
|
52
|
+
* - Available system memory (in Node.js environments)
|
|
53
|
+
* - Number of items currently in the cache
|
|
54
|
+
* - Number of temporary search queries stored
|
|
55
|
+
*
|
|
56
|
+
* @returns {Promise<any>} A promise that resolves to an object containing cache details:
|
|
57
|
+
* - cacheSizeInBytes: Estimated size of the cache in bytes
|
|
58
|
+
* - availableMemoryInBytes: Available system memory in bytes (or -1 if not in Node.js)
|
|
59
|
+
* - cacheItemCount: Number of items in the cache
|
|
60
|
+
* - tempQueryCount: Number of temporary search queries
|
|
61
|
+
* - Or false if an error occurs during calculation
|
|
62
|
+
*
|
|
63
|
+
* @throws {Error} Logs the error to console but doesn't throw; returns false instead
|
|
64
|
+
*/
|
|
65
|
+
getCacheDetails(): Promise<any>;
|
|
47
66
|
/**
|
|
48
67
|
* Sets up an automatic cache reset mechanism.
|
|
49
68
|
* This method creates an interval timer that periodically checks and removes expired items from the cache.
|
|
@@ -8,8 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.InMemoryCache = void 0;
|
|
16
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
17
|
+
const os_1 = __importDefault(require("os"));
|
|
13
18
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
14
19
|
/**
|
|
15
20
|
* @description This class is responsible for caching data in memory
|
|
@@ -128,6 +133,64 @@ class InMemoryCache {
|
|
|
128
133
|
return true;
|
|
129
134
|
});
|
|
130
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Retrieves detailed information about the current state of the cache.
|
|
138
|
+
*
|
|
139
|
+
* This method calculates:
|
|
140
|
+
* - Total estimated size of the cache in bytes (including keys, values, and timestamps)
|
|
141
|
+
* - Available system memory (in Node.js environments)
|
|
142
|
+
* - Number of items currently in the cache
|
|
143
|
+
* - Number of temporary search queries stored
|
|
144
|
+
*
|
|
145
|
+
* @returns {Promise<any>} A promise that resolves to an object containing cache details:
|
|
146
|
+
* - cacheSizeInBytes: Estimated size of the cache in bytes
|
|
147
|
+
* - availableMemoryInBytes: Available system memory in bytes (or -1 if not in Node.js)
|
|
148
|
+
* - cacheItemCount: Number of items in the cache
|
|
149
|
+
* - tempQueryCount: Number of temporary search queries
|
|
150
|
+
* - Or false if an error occurs during calculation
|
|
151
|
+
*
|
|
152
|
+
* @throws {Error} Logs the error to console but doesn't throw; returns false instead
|
|
153
|
+
*/
|
|
154
|
+
getCacheDetails() {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
try {
|
|
157
|
+
// Calculate the total size of cache
|
|
158
|
+
let totalCacheSize = 0;
|
|
159
|
+
// Convert cache map to entries for size calculation
|
|
160
|
+
for (const [key, value] of this.cacheObject.entries()) {
|
|
161
|
+
// Estimate size of key
|
|
162
|
+
totalCacheSize += key.length * 2; // String characters in JS use ~2 bytes
|
|
163
|
+
// Estimate size of value using JSON stringify
|
|
164
|
+
const valueSize = JSON.stringify(value.value).length * 2;
|
|
165
|
+
totalCacheSize += valueSize;
|
|
166
|
+
// Add size of Date object (~8 bytes)
|
|
167
|
+
totalCacheSize += 8;
|
|
168
|
+
}
|
|
169
|
+
// Add size of temp search queries
|
|
170
|
+
totalCacheSize += JSON.stringify(this.tempSearchQuery).length * 2;
|
|
171
|
+
// Get total memory of the machine
|
|
172
|
+
let availableMemory = 0;
|
|
173
|
+
try {
|
|
174
|
+
// Only works in Node.js environment
|
|
175
|
+
availableMemory = os_1.default.freemem();
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
// If we're in a browser or other environment where os is not available
|
|
179
|
+
availableMemory = -1;
|
|
180
|
+
}
|
|
181
|
+
return {
|
|
182
|
+
cacheSizeInBytes: totalCacheSize,
|
|
183
|
+
availableMemoryInBytes: availableMemory,
|
|
184
|
+
cacheItemCount: this.cacheObject.size,
|
|
185
|
+
tempQueryCount: this.tempSearchQuery.length,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
console.error("Error getting cache details:", error);
|
|
190
|
+
return false;
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
}
|
|
131
194
|
/**
|
|
132
195
|
* Sets up an automatic cache reset mechanism.
|
|
133
196
|
* This method creates an interval timer that periodically checks and removes expired items from the cache.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cache.operation.js","sourceRoot":"","sources":["../../source/caching/cache.operation.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cache.operation.js","sourceRoot":"","sources":["../../source/caching/cache.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sDAAsD;AACtD,4CAAoB;AAEpB,uDAAuD;AACvD;;;;;;IAMI;AACJ,MAAa,aAAa;IAOxB;;;OAGG;IACH,YAAY,MAAuB,KAAK;QAPhC,oBAAe,GAAoD,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AsNC;AACD,kBAAe,IAAI,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW"}
|
|
@@ -19,44 +19,6 @@ import { ServerKeys } from "./keys";
|
|
|
19
19
|
* }
|
|
20
20
|
*/
|
|
21
21
|
export declare function isPortInUse(port: number, host?: ServerKeys): Promise<unknown>;
|
|
22
|
-
/**
|
|
23
|
-
* Checks if a specified port is currently mapped to any running Docker container.
|
|
24
|
-
*
|
|
25
|
-
* This function executes a Docker command to list all running containers and their port mappings,
|
|
26
|
-
* then filters for containers that are using the specified port.
|
|
27
|
-
*
|
|
28
|
-
* @param port - The port number to check for Docker container mappings
|
|
29
|
-
* @throws {Error} If the specified port is already mapped to a Docker container
|
|
30
|
-
* @returns {Promise<void>}
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```typescript
|
|
34
|
-
* try {
|
|
35
|
-
* await checkDockerPortMapping(3000);
|
|
36
|
-
* // Port 3000 is free for use
|
|
37
|
-
* } catch (error) {
|
|
38
|
-
* // Port 3000 is already in use by a Docker container
|
|
39
|
-
* console.error(error.message);
|
|
40
|
-
* }
|
|
41
|
-
* ```
|
|
42
|
-
*/
|
|
43
|
-
export declare function checkDockerPortMapping(port: number): Promise<void>;
|
|
44
|
-
/**
|
|
45
|
-
* Checks if Docker is installed on the system.
|
|
46
|
-
*
|
|
47
|
-
* @returns A Promise that resolves to true if Docker is installed, false otherwise
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```typescript
|
|
51
|
-
* const dockerInstalled = await isDockerInstalled();
|
|
52
|
-
* if (dockerInstalled) {
|
|
53
|
-
* console.log('Docker is available');
|
|
54
|
-
* } else {
|
|
55
|
-
* console.log('Docker is not installed');
|
|
56
|
-
* }
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
export declare function isDockerInstalled(): Promise<boolean>;
|
|
60
22
|
/**
|
|
61
23
|
* Checks if a specified port is in use and if there's a Docker port mapping for that port.
|
|
62
24
|
*
|
|
@@ -13,12 +13,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.isPortInUse = isPortInUse;
|
|
16
|
-
exports.checkDockerPortMapping = checkDockerPortMapping;
|
|
17
|
-
exports.isDockerInstalled = isDockerInstalled;
|
|
18
16
|
exports.default = checkPortAndDocker;
|
|
19
17
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
20
18
|
const net_1 = __importDefault(require("net"));
|
|
21
|
-
const child_process_1 = require("child_process");
|
|
22
19
|
const keys_1 = require("./keys");
|
|
23
20
|
/**
|
|
24
21
|
* Checks whether a specific port is already in use.
|
|
@@ -59,73 +56,6 @@ function isPortInUse(port, host = keys_1.ServerKeys.LOCALHOST) {
|
|
|
59
56
|
.listen(port, String(host));
|
|
60
57
|
});
|
|
61
58
|
}
|
|
62
|
-
/**
|
|
63
|
-
* Checks if a specified port is currently mapped to any running Docker container.
|
|
64
|
-
*
|
|
65
|
-
* This function executes a Docker command to list all running containers and their port mappings,
|
|
66
|
-
* then filters for containers that are using the specified port.
|
|
67
|
-
*
|
|
68
|
-
* @param port - The port number to check for Docker container mappings
|
|
69
|
-
* @throws {Error} If the specified port is already mapped to a Docker container
|
|
70
|
-
* @returns {Promise<void>}
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```typescript
|
|
74
|
-
* try {
|
|
75
|
-
* await checkDockerPortMapping(3000);
|
|
76
|
-
* // Port 3000 is free for use
|
|
77
|
-
* } catch (error) {
|
|
78
|
-
* // Port 3000 is already in use by a Docker container
|
|
79
|
-
* console.error(error.message);
|
|
80
|
-
* }
|
|
81
|
-
* ```
|
|
82
|
-
*/
|
|
83
|
-
function checkDockerPortMapping(port) {
|
|
84
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
(0, child_process_1.exec)(`docker ps --format "{{.ID}} {{.Ports}}"`, (error, stdout, _stderr) => {
|
|
86
|
-
if (error) {
|
|
87
|
-
console.error(`Error executing docker: ${error.message}`);
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
const containers = stdout.trim().split("\n");
|
|
91
|
-
const matching = containers.filter((line) => line.includes(`:${port}->`));
|
|
92
|
-
if (matching.length > 0) {
|
|
93
|
-
console.log(`Docker container(s) found using port ${port}:`);
|
|
94
|
-
matching.forEach((c) => console.log(c));
|
|
95
|
-
throw new Error(`Port ${port} is already mapped to a Docker container. Please stop the container or Please Free the port to get the GUI.`);
|
|
96
|
-
}
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Checks if Docker is installed on the system.
|
|
102
|
-
*
|
|
103
|
-
* @returns A Promise that resolves to true if Docker is installed, false otherwise
|
|
104
|
-
*
|
|
105
|
-
* @example
|
|
106
|
-
* ```typescript
|
|
107
|
-
* const dockerInstalled = await isDockerInstalled();
|
|
108
|
-
* if (dockerInstalled) {
|
|
109
|
-
* console.log('Docker is available');
|
|
110
|
-
* } else {
|
|
111
|
-
* console.log('Docker is not installed');
|
|
112
|
-
* }
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
function isDockerInstalled() {
|
|
116
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
-
return new Promise((resolve) => {
|
|
118
|
-
(0, child_process_1.exec)("docker --version", (error, stdout, stderr) => {
|
|
119
|
-
if (error) {
|
|
120
|
-
resolve(false); // Docker is not installed or not accessible
|
|
121
|
-
}
|
|
122
|
-
else {
|
|
123
|
-
resolve(true); // Docker is installed
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
59
|
/**
|
|
130
60
|
* Checks if a specified port is in use and if there's a Docker port mapping for that port.
|
|
131
61
|
*
|
|
@@ -136,10 +66,6 @@ function isDockerInstalled() {
|
|
|
136
66
|
function checkPortAndDocker(port) {
|
|
137
67
|
return __awaiter(this, void 0, void 0, function* () {
|
|
138
68
|
yield isPortInUse(port);
|
|
139
|
-
const status = yield isDockerInstalled();
|
|
140
|
-
if (status) {
|
|
141
|
-
yield checkDockerPortMapping(port);
|
|
142
|
-
}
|
|
143
69
|
});
|
|
144
70
|
}
|
|
145
71
|
//# sourceMappingURL=PortFreeChecker.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PortFreeChecker.js","sourceRoot":"","sources":["../../../source/server/config/PortFreeChecker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAwBA,kCAoBC;
|
|
1
|
+
{"version":3,"file":"PortFreeChecker.js","sourceRoot":"","sources":["../../../source/server/config/PortFreeChecker.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAwBA,kCAoBC;AASD,qCAEC;AAvDD,sDAAsD;AACtD,8CAAsB;AAEtB,iCAAoC;AAEpC;;;;;;;;;;;;;;;;;;GAkBG;AACH,SAAgB,WAAW,CAAC,IAAY,EAAE,IAAI,GAAG,iBAAU,CAAC,SAAS;IACnE,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;QAC7B,MAAM,MAAM,GAAG,aAAG;aACf,YAAY,EAAE;aACd,IAAI,CAAC,OAAO,EAAE,CAAC,GAA0B,EAAE,EAAE;YAC5C,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;gBAC9B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB;gBAChC,MAAM,IAAI,KAAK,CACb,QAAQ,IAAI,0DAA0D,CACvE,CAAC;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,cAAc;YAChC,CAAC;QACH,CAAC,CAAC;aACD,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE;YACtB,MAAM,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,eAAe;QACjC,CAAC,CAAC;aACD,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;GAMG;AACH,SAA8B,kBAAkB,CAAC,IAAY;;QAC3D,MAAM,WAAW,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;CAAA"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { AxioDB } from "../../Services/Indexation.operation";
|
|
2
|
+
export default class StatsController {
|
|
3
|
+
private AxioDBInstance;
|
|
4
|
+
constructor(AxioDBInstance: AxioDB);
|
|
5
|
+
/**
|
|
6
|
+
* Retrieves dashboard statistics for the AxioDB instance.
|
|
7
|
+
*
|
|
8
|
+
* This method gathers and compiles various statistics about the database system:
|
|
9
|
+
* - Count of databases, collections, and documents
|
|
10
|
+
* - Storage information (used storage and total machine storage)
|
|
11
|
+
* - In-memory cache details
|
|
12
|
+
*
|
|
13
|
+
* All storage metrics are converted to MB for consistency.
|
|
14
|
+
*
|
|
15
|
+
* @returns {Promise<Object>} A formatted response object containing:
|
|
16
|
+
* - HTTP status code
|
|
17
|
+
* - Status message
|
|
18
|
+
* - Data payload with the following statistics:
|
|
19
|
+
* - totalDatabases: Number of databases in the instance
|
|
20
|
+
* - totalCollections: Total number of collections across all databases
|
|
21
|
+
* - totalDocuments: Total number of documents across all collections
|
|
22
|
+
* - storageInfo: Object containing storage metrics (total used, machine total, and units)
|
|
23
|
+
* - cacheStorage: Object containing cache storage metrics (current usage, maximum, and units)
|
|
24
|
+
*
|
|
25
|
+
* @throws Will return an error response with status 500 if the operation fails
|
|
26
|
+
*/
|
|
27
|
+
getDashBoardStat(): Promise<object>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
/* eslint-disable no-self-assign */
|
|
16
|
+
const outers_1 = require("outers");
|
|
17
|
+
const responseBuilder_helper_1 = __importDefault(require("../helper/responseBuilder.helper")); // ResponseBuilder,
|
|
18
|
+
// import { FastifyRequest } from "fastify";
|
|
19
|
+
// import countFilesRecursive from "../../helper/filesCounterInFolder.helper";
|
|
20
|
+
const cache_operation_1 = __importDefault(require("../../caching/cache.operation"));
|
|
21
|
+
const fs_1 = __importDefault(require("fs"));
|
|
22
|
+
class StatsController {
|
|
23
|
+
constructor(AxioDBInstance) {
|
|
24
|
+
this.AxioDBInstance = AxioDBInstance;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves dashboard statistics for the AxioDB instance.
|
|
28
|
+
*
|
|
29
|
+
* This method gathers and compiles various statistics about the database system:
|
|
30
|
+
* - Count of databases, collections, and documents
|
|
31
|
+
* - Storage information (used storage and total machine storage)
|
|
32
|
+
* - In-memory cache details
|
|
33
|
+
*
|
|
34
|
+
* All storage metrics are converted to MB for consistency.
|
|
35
|
+
*
|
|
36
|
+
* @returns {Promise<Object>} A formatted response object containing:
|
|
37
|
+
* - HTTP status code
|
|
38
|
+
* - Status message
|
|
39
|
+
* - Data payload with the following statistics:
|
|
40
|
+
* - totalDatabases: Number of databases in the instance
|
|
41
|
+
* - totalCollections: Total number of collections across all databases
|
|
42
|
+
* - totalDocuments: Total number of documents across all collections
|
|
43
|
+
* - storageInfo: Object containing storage metrics (total used, machine total, and units)
|
|
44
|
+
* - cacheStorage: Object containing cache storage metrics (current usage, maximum, and units)
|
|
45
|
+
*
|
|
46
|
+
* @throws Will return an error response with status 500 if the operation fails
|
|
47
|
+
*/
|
|
48
|
+
getDashBoardStat() {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
var _a, _b, _c, _d, _e;
|
|
51
|
+
try {
|
|
52
|
+
const InstanceInfo = yield this.AxioDBInstance.getInstanceInfo();
|
|
53
|
+
let totalCollections = 0;
|
|
54
|
+
let totalDocuments = 0;
|
|
55
|
+
const treeMap = [];
|
|
56
|
+
// Extract Total Stats from the InstanceInfo
|
|
57
|
+
if (InstanceInfo && InstanceInfo.data) {
|
|
58
|
+
for (const db of InstanceInfo.data.ListOfDatabases) {
|
|
59
|
+
const dbTree = {
|
|
60
|
+
name: db,
|
|
61
|
+
collections: [],
|
|
62
|
+
};
|
|
63
|
+
const DB_instance = this.AxioDBInstance.createDB(db);
|
|
64
|
+
const Collection_stats = yield (yield DB_instance).getCollectionInfo();
|
|
65
|
+
if (Collection_stats) {
|
|
66
|
+
totalCollections +=
|
|
67
|
+
Collection_stats.data.ListOfCollections.length || 0;
|
|
68
|
+
for (const collection of Collection_stats.data.ListOfCollections) {
|
|
69
|
+
const Collection_Instance = yield (yield this.AxioDBInstance.createDB(db)).createCollection(collection);
|
|
70
|
+
const Document_stats = yield Collection_Instance.totalDocuments();
|
|
71
|
+
totalDocuments += ((_a = Document_stats.data) === null || _a === void 0 ? void 0 : _a.total) || 0;
|
|
72
|
+
dbTree.collections.push({
|
|
73
|
+
name: collection,
|
|
74
|
+
documentCount: ((_b = Document_stats.data) === null || _b === void 0 ? void 0 : _b.total) || 0,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
treeMap.push(dbTree);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
// Get storage info and convert to MB
|
|
82
|
+
let totalMachineStorage = 0;
|
|
83
|
+
let totalUsedStorage = ((_c = InstanceInfo === null || InstanceInfo === void 0 ? void 0 : InstanceInfo.data) === null || _c === void 0 ? void 0 : _c.TotalSize) || 0;
|
|
84
|
+
try {
|
|
85
|
+
// Get disk info for the root directory
|
|
86
|
+
const stats = fs_1.default.statfsSync("/");
|
|
87
|
+
const totalBytes = stats.blocks * stats.bsize;
|
|
88
|
+
// Convert to MB
|
|
89
|
+
totalMachineStorage = parseFloat((totalBytes / (1024 * 1024)).toFixed(2));
|
|
90
|
+
totalUsedStorage = parseFloat((totalUsedStorage / (1024 * 1024)).toFixed(2));
|
|
91
|
+
}
|
|
92
|
+
catch (storageError) {
|
|
93
|
+
console.error("Error fetching machine storage:", storageError);
|
|
94
|
+
}
|
|
95
|
+
const MatrixUnitsForUsedStorage = "MB";
|
|
96
|
+
const MatrixUnitsForMachineStorage = "MB";
|
|
97
|
+
const CacheStorageDetails = yield cache_operation_1.default.getCacheDetails();
|
|
98
|
+
const totalCacheSize = parseFloat((CacheStorageDetails.cacheSizeInBytes / (1024 * 1024)).toFixed(2));
|
|
99
|
+
const maxCacheSize = parseFloat((CacheStorageDetails.availableMemoryInBytes / (1024 * 1024)).toFixed(2));
|
|
100
|
+
const response = {
|
|
101
|
+
totalDatabases: ((_e = (_d = InstanceInfo === null || InstanceInfo === void 0 ? void 0 : InstanceInfo.data) === null || _d === void 0 ? void 0 : _d.ListOfDatabases) === null || _e === void 0 ? void 0 : _e.length) || 0,
|
|
102
|
+
totalCollections: totalCollections || 0,
|
|
103
|
+
totalDocuments: totalDocuments || 0,
|
|
104
|
+
storageInfo: {
|
|
105
|
+
total: totalUsedStorage || 0,
|
|
106
|
+
matrixUnit: MatrixUnitsForUsedStorage || "MB",
|
|
107
|
+
machine: totalMachineStorage || 0,
|
|
108
|
+
machineUnit: MatrixUnitsForMachineStorage || "B",
|
|
109
|
+
},
|
|
110
|
+
cacheStorage: {
|
|
111
|
+
Storage: totalCacheSize || 0,
|
|
112
|
+
Max: maxCacheSize || 0,
|
|
113
|
+
Unit: "MB",
|
|
114
|
+
},
|
|
115
|
+
nodeTree: treeMap,
|
|
116
|
+
};
|
|
117
|
+
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.OK, "Dashboard stats fetched successfully", response);
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
console.error("Error fetching dashboard stats:", error);
|
|
121
|
+
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.INTERNAL_SERVER_ERROR, "Failed to fetch dashboard stats");
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
exports.default = StatsController;
|
|
127
|
+
//# sourceMappingURL=Stats.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Stats.controller.js","sourceRoot":"","sources":["../../../source/server/controller/Stats.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mCAAmC;AACnC,mCAAqC;AAErC,8FAA6D,CAAC,mBAAmB;AACjF,4CAA4C;AAC5C,8EAA8E;AAC9E,oFAA0D;AAC1D,4CAAoB;AAEpB,MAAqB,eAAe;IAGlC,YAAY,cAAsB;QAChC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;OAqBG;IACU,gBAAgB;;;YAC3B,IAAI,CAAC;gBACH,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,eAAe,EAAE,CAAC;gBACjE,IAAI,gBAAgB,GAAG,CAAC,CAAC;gBACzB,IAAI,cAAc,GAAG,CAAC,CAAC;gBACvB,MAAM,OAAO,GAAG,EAAE,CAAC;gBAEnB,4CAA4C;gBAC5C,IAAI,YAAY,IAAI,YAAY,CAAC,IAAI,EAAE,CAAC;oBACtC,KAAK,MAAM,EAAE,IAAI,YAAY,CAAC,IAAI,CAA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