axiodb 2.21.70 → 2.22.71
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/Database/database.operation.d.ts +10 -3
- package/lib/Services/Database/database.operation.js +35 -3
- package/lib/Services/Database/database.operation.js.map +1 -1
- package/lib/Services/Indexation.operation.d.ts +1 -0
- package/lib/Services/Indexation.operation.js +8 -1
- package/lib/Services/Indexation.operation.js.map +1 -1
- package/lib/config/Interfaces/Operation/Indexation.operation.interface.d.ts +2 -0
- package/lib/config/Interfaces/Operation/database.operation.interface.d.ts +12 -0
- package/lib/config/Interfaces/Operation/database.operation.interface.js +1 -0
- package/lib/config/Interfaces/Operation/database.operation.interface.js.map +1 -1
- package/lib/engine/Filesystem/FileManager.js +62 -9
- package/lib/engine/Filesystem/FileManager.js.map +1 -1
- package/lib/engine/Filesystem/FolderManager.d.ts +15 -0
- package/lib/engine/Filesystem/FolderManager.js +151 -5
- package/lib/engine/Filesystem/FolderManager.js.map +1 -1
- package/lib/server/controller/Collections/Collection.controller.d.ts +25 -0
- package/lib/server/controller/Collections/Collection.controller.js +67 -0
- package/lib/server/controller/Collections/Collection.controller.js.map +1 -0
- package/lib/server/public/AxioControl/.vite/manifest.json +1 -1
- package/lib/server/public/AxioControl/assets/{index-BrzSFweB.js → index-BpapO_fH.js} +1 -1
- package/lib/server/public/AxioControl/index.html +1 -1
- package/lib/server/public/AxioControl/sw.js +1 -1
- package/package.json +1 -1
|
@@ -9,17 +9,24 @@ export default class Database {
|
|
|
9
9
|
private fileManager;
|
|
10
10
|
private folderManager;
|
|
11
11
|
private ResponseHelper;
|
|
12
|
+
private collectionMap;
|
|
12
13
|
constructor(name: string, path: string);
|
|
13
14
|
/**
|
|
14
15
|
* Creates a new collection inside the specified database.
|
|
15
16
|
* @param {string} collectionName - Name of the collection.
|
|
16
|
-
* @param {boolean} isSchemaNeeded - Whether the collection requires a schema.
|
|
17
|
-
* @param {object} schema - Schema of the collection.
|
|
18
17
|
* @param {boolean} crypto - Enable crypto for the collection.
|
|
19
18
|
* @param {string} key - Key for crypto.
|
|
19
|
+
* @param {boolean} isSchemaNeeded - Whether the collection requires a schema.
|
|
20
|
+
* @param {object} schema - Schema of the collection.
|
|
20
21
|
* @returns {Promise<AxioDB>} - Returns the instance of AxioDB.
|
|
21
22
|
*/
|
|
22
|
-
createCollection(collectionName: string,
|
|
23
|
+
createCollection(collectionName: string, crypto?: boolean, key?: string | undefined, isSchemaNeeded?: boolean, schema?: object | any): Promise<Collection>;
|
|
24
|
+
/**
|
|
25
|
+
* Checks if a collection exists in the database.
|
|
26
|
+
* @param {string} collectionName - Name of the collection to check.
|
|
27
|
+
* @returns {Promise<boolean>} - Returns true if the collection exists, false otherwise.
|
|
28
|
+
**/
|
|
29
|
+
isCollectionExists(collectionName: string): Promise<boolean>;
|
|
23
30
|
/**
|
|
24
31
|
* Deletes a collection from the database.
|
|
25
32
|
* @param {string} collectionName - Name of the collection to delete.
|
|
@@ -31,18 +31,19 @@ class Database {
|
|
|
31
31
|
this.fileManager = new FileManager_1.default();
|
|
32
32
|
this.folderManager = new FolderManager_1.default();
|
|
33
33
|
this.ResponseHelper = new response_helper_1.default();
|
|
34
|
+
this.collectionMap = new Map();
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
37
|
* Creates a new collection inside the specified database.
|
|
37
38
|
* @param {string} collectionName - Name of the collection.
|
|
38
|
-
* @param {boolean} isSchemaNeeded - Whether the collection requires a schema.
|
|
39
|
-
* @param {object} schema - Schema of the collection.
|
|
40
39
|
* @param {boolean} crypto - Enable crypto for the collection.
|
|
41
40
|
* @param {string} key - Key for crypto.
|
|
41
|
+
* @param {boolean} isSchemaNeeded - Whether the collection requires a schema.
|
|
42
|
+
* @param {object} schema - Schema of the collection.
|
|
42
43
|
* @returns {Promise<AxioDB>} - Returns the instance of AxioDB.
|
|
43
44
|
*/
|
|
44
45
|
createCollection(collectionName_1) {
|
|
45
|
-
return __awaiter(this, arguments, void 0, function* (collectionName,
|
|
46
|
+
return __awaiter(this, arguments, void 0, function* (collectionName, crypto = false, key, isSchemaNeeded = false, schema) {
|
|
46
47
|
// Check if the collection already exists
|
|
47
48
|
const collectionExists = yield this.folderManager.DirectoryExists(path_1.default.join(this.path, collectionName));
|
|
48
49
|
const collectionPath = path_1.default.join(this.path, collectionName);
|
|
@@ -55,14 +56,43 @@ class Database {
|
|
|
55
56
|
if (crypto === true) {
|
|
56
57
|
const newCryptoInstance = new Crypto_helper_1.CryptoHelper(key);
|
|
57
58
|
const collection = new collection_operation_1.default(collectionName, collectionPath, isSchemaNeeded, schema, crypto, newCryptoInstance, key);
|
|
59
|
+
// Store collection metadata in the collectionMap
|
|
60
|
+
// Note: The collectionMap is now storing an object instead of a Collection instance
|
|
61
|
+
this.collectionMap.set(collectionName, {
|
|
62
|
+
isCryptoEnabled: crypto,
|
|
63
|
+
cryptoKey: key,
|
|
64
|
+
path: collectionPath,
|
|
65
|
+
schema: schema,
|
|
66
|
+
isSchema: isSchemaNeeded,
|
|
67
|
+
});
|
|
58
68
|
return collection;
|
|
59
69
|
}
|
|
60
70
|
else {
|
|
61
71
|
const collection = new collection_operation_1.default(collectionName, collectionPath, isSchemaNeeded, schema);
|
|
72
|
+
// Store collection metadata in the collectionMap
|
|
73
|
+
this.collectionMap.set(collectionName, {
|
|
74
|
+
isCryptoEnabled: crypto,
|
|
75
|
+
cryptoKey: key,
|
|
76
|
+
path: collectionPath,
|
|
77
|
+
schema: schema,
|
|
78
|
+
isSchema: isSchemaNeeded,
|
|
79
|
+
});
|
|
62
80
|
return collection;
|
|
63
81
|
}
|
|
64
82
|
});
|
|
65
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Checks if a collection exists in the database.
|
|
86
|
+
* @param {string} collectionName - Name of the collection to check.
|
|
87
|
+
* @returns {Promise<boolean>} - Returns true if the collection exists, false otherwise.
|
|
88
|
+
**/
|
|
89
|
+
isCollectionExists(collectionName) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const collectionPath = path_1.default.join(this.path, collectionName);
|
|
92
|
+
const exists = yield this.folderManager.DirectoryExists(collectionPath);
|
|
93
|
+
return exists.statusCode === outers_1.StatusCodes.OK;
|
|
94
|
+
});
|
|
95
|
+
}
|
|
66
96
|
/**
|
|
67
97
|
* Deletes a collection from the database.
|
|
68
98
|
* @param {string} collectionName - Name of the collection to delete.
|
|
@@ -75,6 +105,7 @@ class Database {
|
|
|
75
105
|
const exists = yield this.folderManager.DirectoryExists(collectionPath);
|
|
76
106
|
if (exists.statusCode === outers_1.StatusCodes.OK) {
|
|
77
107
|
yield this.folderManager.DeleteDirectory(collectionPath);
|
|
108
|
+
this.collectionMap.delete(collectionName); // Remove from collectionMap
|
|
78
109
|
return this.ResponseHelper.Success(`Collection: ${collectionName} deleted successfully`);
|
|
79
110
|
}
|
|
80
111
|
else {
|
|
@@ -99,6 +130,7 @@ class Database {
|
|
|
99
130
|
TotalCollections: `${collections.data.length} Collections`,
|
|
100
131
|
TotalSize: parseInt((totalSize.data / 1024 / 1024).toFixed(4)),
|
|
101
132
|
ListOfCollections: collections.data,
|
|
133
|
+
CollectionMap: this.collectionMap,
|
|
102
134
|
AllCollectionsPaths: collections.data.map((collection) => path_1.default.join(this.path, collection)),
|
|
103
135
|
};
|
|
104
136
|
return this.ResponseHelper.Success(FinalCollections);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.operation.js","sourceRoot":"","sources":["../../../source/Services/Database/database.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,8FAA4D;AAC5D,sFAA8D;AAC9D,0FAAkE;AAClE,gDAAwB;AAExB,qBAAqB;AACrB,8DAA0D;AAC1D,mFAA0D;AAC1D,mCAAqC;
|
|
1
|
+
{"version":3,"file":"database.operation.js","sourceRoot":"","sources":["../../../source/Services/Database/database.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,8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G,CAAC,CAAC,UAAkB,EAAE,EAAE,CAC/D,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CACjC;iBACF,CAAC;gBACF,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;YACvD,CAAC;QACH,CAAC;KAAA;CACF;AAnJD,2BAmJC"}
|
|
@@ -44,6 +44,7 @@ class AxioDB {
|
|
|
44
44
|
this.Converter = new Converter_helper_1.default(); // Initialize the Converter class
|
|
45
45
|
this.ResponseHelper = new response_helper_1.default(); // Initialize the ResponseHelper class
|
|
46
46
|
this.initializeRoot(); // Ensure root initialization
|
|
47
|
+
this.DatabaseMap = new Map(); // Initialize the DatabaseMap
|
|
47
48
|
}
|
|
48
49
|
/**
|
|
49
50
|
* Initializes the root directory for the AxioDB.
|
|
@@ -86,6 +87,9 @@ class AxioDB {
|
|
|
86
87
|
console.log(`Database Created: ${dbPath}`);
|
|
87
88
|
}
|
|
88
89
|
const newDB = new database_operation_1.default(DBName, dbPath);
|
|
90
|
+
// Store database metadata in the DatabaseMap
|
|
91
|
+
// Note: The DatabaseMap is now storing an object instead of a Database instance
|
|
92
|
+
this.DatabaseMap.set(DBName, { DatabaseName: DBName, path: dbPath });
|
|
89
93
|
return newDB;
|
|
90
94
|
});
|
|
91
95
|
}
|
|
@@ -106,6 +110,7 @@ class AxioDB {
|
|
|
106
110
|
getInstanceInfo() {
|
|
107
111
|
return __awaiter(this, void 0, void 0, function* () {
|
|
108
112
|
const totalDatabases = yield this.folderManager.ListDirectory(path_1.default.resolve(this.currentPATH));
|
|
113
|
+
// First
|
|
109
114
|
const totalSize = yield this.folderManager.GetDirectorySize(path_1.default.resolve(this.currentPATH));
|
|
110
115
|
// check if all data is returned
|
|
111
116
|
if ("data" in totalDatabases && "data" in totalSize) {
|
|
@@ -113,9 +118,10 @@ class AxioDB {
|
|
|
113
118
|
CurrentPath: this.currentPATH,
|
|
114
119
|
RootName: this.RootName,
|
|
115
120
|
MatrixUnits: "MB",
|
|
116
|
-
TotalSize:
|
|
121
|
+
TotalSize: parseFloat((totalSize.data / 1024 / 1024).toFixed(6)),
|
|
117
122
|
TotalDatabases: `${totalDatabases.data.length} Databases`,
|
|
118
123
|
ListOfDatabases: totalDatabases.data,
|
|
124
|
+
DatabaseMap: this.DatabaseMap,
|
|
119
125
|
AllDatabasesPaths: totalDatabases.data.map((db) => path_1.default.join(this.currentPATH, db)),
|
|
120
126
|
};
|
|
121
127
|
return this.ResponseHelper.Success(FinalDatabaseInfo);
|
|
@@ -164,6 +170,7 @@ class AxioDB {
|
|
|
164
170
|
const exists = yield this.folderManager.DirectoryExists(dbPath);
|
|
165
171
|
if (exists.statusCode === outers_1.StatusCodes.OK) {
|
|
166
172
|
yield this.folderManager.DeleteDirectory(dbPath);
|
|
173
|
+
this.DatabaseMap.delete(DBName); // Remove from DatabaseMap
|
|
167
174
|
return this.ResponseHelper.Success(`Database: ${DBName} deleted successfully`);
|
|
168
175
|
}
|
|
169
176
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Indexation.operation.js","sourceRoot":"","sources":["../../source/Services/Indexation.operation.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;;;;;;;;;;;;;AAEvD,mBAAmB;AACnB,mFAA2D;AAC3D,uFAA+D;AAC/D,8CAA8C;AAC9C,gDAAwB;AACxB,uFAAqD;AACrD,kDAAkD;AAElD,iBAAiB;AACjB,kFAAmD;AACnD,mCAAqC;AACrC,gFAAuD;AAQvD,qEAAgE;
|
|
1
|
+
{"version":3,"file":"Indexation.operation.js","sourceRoot":"","sources":["../../source/Services/Indexation.operation.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;;;;;;;;;;;;;AAEvD,mBAAmB;AACnB,mFAA2D;AAC3D,uFAA+D;AAC/D,8CAA8C;AAC9C,gDAAwB;AACxB,uFAAqD;AACrD,kDAAkD;AAElD,iBAAiB;AACjB,kFAAmD;AACnD,mCAAqC;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CAAC,CAAC;YAChE,OAAO,MAAM,CAAC,UAAU,KAAK,oBAAW,CAAC,EAAE,CAAC;QAC9C,CAAC;KAAA;IAED,kBAAkB;IAClB;;;;;;;;;;OAUG;IACU,cAAc,CACzB,MAAc;;YAEd,MAAM,MAAM,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;YACnD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;YAEhE,IAAI,MAAM,CAAC,UAAU,KAAK,oBAAW,CAAC,EAAE,EAAE,CAAC;gBACzC,MAAM,IAAI,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;gBACjD,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,0BAA0B;gBAC3D,OAAO,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;AAzKD,wBAyKC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { DatabaseMap } from "./database.operation.interface";
|
|
1
2
|
export interface FinalDatabaseInfo {
|
|
2
3
|
CurrentPath: string;
|
|
3
4
|
RootName: string;
|
|
@@ -5,5 +6,6 @@ export interface FinalDatabaseInfo {
|
|
|
5
6
|
TotalSize: number;
|
|
6
7
|
TotalDatabases: string;
|
|
7
8
|
ListOfDatabases: string[];
|
|
9
|
+
DatabaseMap: Map<string, DatabaseMap>;
|
|
8
10
|
AllDatabasesPaths: string[];
|
|
9
11
|
}
|
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
export interface CollectionMap {
|
|
2
|
+
isCryptoEnabled: boolean;
|
|
3
|
+
cryptoKey?: string;
|
|
4
|
+
path: string;
|
|
5
|
+
schema?: any;
|
|
6
|
+
isSchema: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface DatabaseMap {
|
|
9
|
+
DatabaseName: string;
|
|
10
|
+
path: string;
|
|
11
|
+
}
|
|
1
12
|
export interface FinalCollectionsInfo {
|
|
2
13
|
CurrentPath: string;
|
|
3
14
|
RootName: string;
|
|
@@ -5,5 +16,6 @@ export interface FinalCollectionsInfo {
|
|
|
5
16
|
TotalSize: number;
|
|
6
17
|
TotalCollections: number | string;
|
|
7
18
|
ListOfCollections: string[];
|
|
19
|
+
CollectionMap: Map<string, CollectionMap>;
|
|
8
20
|
AllCollectionsPaths: string[];
|
|
9
21
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.operation.interface.js","sourceRoot":"","sources":["../../../../source/config/Interfaces/Operation/database.operation.interface.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"database.operation.interface.js","sourceRoot":"","sources":["../../../../source/config/Interfaces/Operation/database.operation.interface.ts"],"names":[],"mappings":";AAAA,uDAAuD"}
|
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
15
16
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
16
17
|
const response_helper_1 = __importDefault(require("../../Helper/response.helper"));
|
|
17
18
|
const worker_process_1 = __importDefault(require("../cli/worker_process"));
|
|
@@ -187,18 +188,70 @@ class FileManager {
|
|
|
187
188
|
GetFileSize(path) {
|
|
188
189
|
return __awaiter(this, void 0, void 0, function* () {
|
|
189
190
|
try {
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
191
|
+
// Try using native Node.js first (most reliable)
|
|
192
|
+
try {
|
|
193
|
+
// Check file permissions before reading
|
|
194
|
+
let originalMode = null;
|
|
195
|
+
try {
|
|
196
|
+
const stats = yield promises_1.default.stat(path);
|
|
197
|
+
originalMode = stats.mode;
|
|
198
|
+
// If file isn't readable, temporarily make it readable
|
|
199
|
+
if ((stats.mode & 0o444) !== 0o444) {
|
|
200
|
+
yield promises_1.default.chmod(path, 0o644);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
catch (permError) {
|
|
204
|
+
// Continue with attempt to read the file even if we couldn't modify permissions
|
|
205
|
+
}
|
|
206
|
+
try {
|
|
207
|
+
const stats = yield promises_1.default.stat(path);
|
|
208
|
+
// Restore original permissions if they were modified
|
|
209
|
+
if (originalMode !== null && (originalMode & 0o444) !== 0o444) {
|
|
210
|
+
yield promises_1.default.chmod(path, originalMode);
|
|
211
|
+
}
|
|
212
|
+
return this.responseHelper.Success(stats.size);
|
|
213
|
+
}
|
|
214
|
+
catch (statError) {
|
|
215
|
+
// Fall back to system commands if native method fails
|
|
216
|
+
const osType = worker_process_1.default.getOS();
|
|
217
|
+
if (osType === "windows") {
|
|
218
|
+
const stdout = yield this.WorkerProcess.execCommand(`powershell -command "(Get-Item '${path}').length"`);
|
|
219
|
+
const size = parseInt(stdout, 10) || 0;
|
|
220
|
+
// Restore original permissions if they were modified
|
|
221
|
+
if (originalMode !== null && (originalMode & 0o444) !== 0o444) {
|
|
222
|
+
yield promises_1.default.chmod(path, originalMode);
|
|
223
|
+
}
|
|
224
|
+
return this.responseHelper.Success(size);
|
|
225
|
+
}
|
|
226
|
+
else {
|
|
227
|
+
// For Unix-like systems
|
|
228
|
+
const stdout = yield this.WorkerProcess.execCommand(`wc -c < "${path}" 2>/dev/null || echo 0`);
|
|
229
|
+
const size = parseInt(stdout, 10) || 0;
|
|
230
|
+
// Restore original permissions if they were modified
|
|
231
|
+
if (originalMode !== null && (originalMode & 0o444) !== 0o444) {
|
|
232
|
+
yield promises_1.default.chmod(path, originalMode);
|
|
233
|
+
}
|
|
234
|
+
return this.responseHelper.Success(size);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
catch (err) {
|
|
239
|
+
// Try to restore original permissions if they were saved, even if an error occurred
|
|
240
|
+
try {
|
|
241
|
+
const stats = yield promises_1.default.stat(path);
|
|
242
|
+
const originalMode = stats.mode;
|
|
243
|
+
if ((originalMode & 0o444) !== 0o444) {
|
|
244
|
+
yield promises_1.default.chmod(path, originalMode);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch (_a) {
|
|
248
|
+
// Ignore errors in the final cleanup attempt
|
|
249
|
+
}
|
|
250
|
+
return this.responseHelper.Error(`Failed to get file size: ${err}`);
|
|
195
251
|
}
|
|
196
|
-
const stdout = yield this.WorkerProcess.execCommand(`du -sb ${path}`);
|
|
197
|
-
const size = parseInt(stdout.split("\t")[0], 10);
|
|
198
|
-
return this.responseHelper.Success(size);
|
|
199
252
|
}
|
|
200
253
|
catch (err) {
|
|
201
|
-
return this.responseHelper.Error(`Failed to get
|
|
254
|
+
return this.responseHelper.Error(`Failed to get file size: ${err}`);
|
|
202
255
|
}
|
|
203
256
|
});
|
|
204
257
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileManager.js","sourceRoot":"","sources":["../../../source/engine/Filesystem/FileManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2DAA6B;AAC7B,mFAA0D;AAK1D,2EAAkD;AAElD,MAAqB,WAAW;IAI9B;QACE,IAAI,CAAC,cAAc,GAAG,IAAI,yBAAc,EAAE,CAAC;QAC3C,IAAI,CAAC,aAAa,GAAG,IAAI,wBAAa,EAAE,CAAC;IAC3C,CAAC;IAED;;;;;;;OAOG;IACU,SAAS,CACpB,IAAY,EACZ,IAAY;;YAEZ,IAAI,CAAC;gBACH,MAAM,kBAAE,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;gBACxC,OAAO,IAAI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AAK,CAAC,4BAA4B,GAAG,EAAE,CAAC,CAAC;YACtE,CAAC;QACH,CAAC;KAAA;CACF;AA7PD,8BA6PC"}
|
|
@@ -39,6 +39,21 @@ export default class FolderManager {
|
|
|
39
39
|
IsDirectoryLocked(path: string): Promise<SuccessInterface | ErrorInterface>;
|
|
40
40
|
/**
|
|
41
41
|
* get the size of a directory at the specified path.
|
|
42
|
+
* Handles permission issues by temporarily modifying permissions if needed.
|
|
42
43
|
*/
|
|
43
44
|
GetDirectorySize(path: string): Promise<SuccessInterface | ErrorInterface>;
|
|
45
|
+
/**
|
|
46
|
+
* Recursively prepares a directory and its contents for size calculation
|
|
47
|
+
* by temporarily modifying permissions if needed.
|
|
48
|
+
*/
|
|
49
|
+
private prepareDirectoryForSizeCalculation;
|
|
50
|
+
/**
|
|
51
|
+
* Restores original permissions for all modified files and directories
|
|
52
|
+
*/
|
|
53
|
+
private restoreDirectoryPermissions;
|
|
54
|
+
/**
|
|
55
|
+
* Calculates directory size recursively using Node.js native functions.
|
|
56
|
+
* This is a fallback method for when command-line tools fail.
|
|
57
|
+
*/
|
|
58
|
+
private calculateDirectorySizeRecursively;
|
|
44
59
|
}
|
|
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
15
16
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
16
17
|
const fs_1 = __importDefault(require("fs"));
|
|
17
18
|
const worker_process_1 = __importDefault(require("../cli/worker_process"));
|
|
@@ -139,24 +140,169 @@ class FolderManager {
|
|
|
139
140
|
}
|
|
140
141
|
/**
|
|
141
142
|
* get the size of a directory at the specified path.
|
|
143
|
+
* Handles permission issues by temporarily modifying permissions if needed.
|
|
142
144
|
*/
|
|
143
145
|
GetDirectorySize(path) {
|
|
144
146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
+
// Store original permissions to restore later
|
|
148
|
+
const permissionsMap = new Map();
|
|
145
149
|
try {
|
|
150
|
+
// Check if directory exists
|
|
151
|
+
try {
|
|
152
|
+
yield this.fileSystem.access(path);
|
|
153
|
+
}
|
|
154
|
+
catch (error) {
|
|
155
|
+
return this.responseHelper.Error(`Directory does not exist or is inaccessible: ${error}`);
|
|
156
|
+
}
|
|
157
|
+
// Collect and store original permissions, unlock files/folders as needed
|
|
158
|
+
yield this.prepareDirectoryForSizeCalculation(path, permissionsMap);
|
|
159
|
+
// Now perform the size calculation
|
|
146
160
|
const osType = worker_process_1.default.getOS();
|
|
161
|
+
let size;
|
|
147
162
|
if (osType === "windows") {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
163
|
+
try {
|
|
164
|
+
// More comprehensive PowerShell command that handles directories better
|
|
165
|
+
const stdout = yield this.WorkerProcess.execCommand(`powershell -command "(Get-ChildItem '${path}' -Recurse -Force | Measure-Object -Property Length -Sum).Sum"`);
|
|
166
|
+
size = parseInt(stdout, 10) || 0;
|
|
167
|
+
}
|
|
168
|
+
catch (cmdError) {
|
|
169
|
+
console.warn(`Windows command failed: ${cmdError}, using fallback method`);
|
|
170
|
+
size = yield this.calculateDirectorySizeRecursively(path);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
try {
|
|
175
|
+
// Try du with error redirection
|
|
176
|
+
const stdout = yield this.WorkerProcess.execCommand(`du -sb "${path}" 2>/dev/null`);
|
|
177
|
+
size = parseInt(stdout.split("\t")[0], 10) || 0;
|
|
178
|
+
}
|
|
179
|
+
catch (cmdError) {
|
|
180
|
+
console.warn(`Unix command failed: ${cmdError}, using fallback method`);
|
|
181
|
+
size = yield this.calculateDirectorySizeRecursively(path);
|
|
182
|
+
}
|
|
151
183
|
}
|
|
152
|
-
const stdout = yield this.WorkerProcess.execCommand(`du -sb "${path}"`);
|
|
153
|
-
const size = parseInt(stdout.split("\t")[0], 10);
|
|
154
184
|
return this.responseHelper.Success(size);
|
|
155
185
|
}
|
|
156
186
|
catch (err) {
|
|
157
187
|
console.error(`Error getting directory size: ${err}`);
|
|
158
188
|
return this.responseHelper.Error(`Failed to get directory size: ${err}`);
|
|
159
189
|
}
|
|
190
|
+
finally {
|
|
191
|
+
// Restore original permissions
|
|
192
|
+
yield this.restoreDirectoryPermissions(permissionsMap);
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Recursively prepares a directory and its contents for size calculation
|
|
198
|
+
* by temporarily modifying permissions if needed.
|
|
199
|
+
*/
|
|
200
|
+
prepareDirectoryForSizeCalculation(dirPath, permissionsMap) {
|
|
201
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
try {
|
|
203
|
+
// Store original directory permissions
|
|
204
|
+
try {
|
|
205
|
+
const stats = yield this.fileSystem.stat(dirPath);
|
|
206
|
+
permissionsMap.set(dirPath, stats.mode);
|
|
207
|
+
// If directory isn't readable, make it readable
|
|
208
|
+
if ((stats.mode & 0o444) !== 0o444) {
|
|
209
|
+
yield this.fileSystem.chmod(dirPath, 0o755);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
console.warn(`Could not check/modify permissions for ${dirPath}: ${error}`);
|
|
214
|
+
return;
|
|
215
|
+
}
|
|
216
|
+
// Process directory contents
|
|
217
|
+
let items;
|
|
218
|
+
try {
|
|
219
|
+
items = yield this.fileSystem.readdir(dirPath);
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
console.warn(`Could not read directory ${dirPath}: ${error}`);
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
// Process each item recursively
|
|
226
|
+
for (const item of items) {
|
|
227
|
+
const itemPath = `${dirPath}/${item}`;
|
|
228
|
+
try {
|
|
229
|
+
const stats = yield this.fileSystem.stat(itemPath);
|
|
230
|
+
// Store original permissions
|
|
231
|
+
permissionsMap.set(itemPath, stats.mode);
|
|
232
|
+
if (stats.isDirectory()) {
|
|
233
|
+
// If subdirectory isn't readable, make it readable
|
|
234
|
+
if ((stats.mode & 0o444) !== 0o444) {
|
|
235
|
+
yield this.fileSystem.chmod(itemPath, 0o755);
|
|
236
|
+
}
|
|
237
|
+
// Recursively process subdirectory
|
|
238
|
+
yield this.prepareDirectoryForSizeCalculation(itemPath, permissionsMap);
|
|
239
|
+
}
|
|
240
|
+
else if (stats.isFile()) {
|
|
241
|
+
// If file isn't readable, make it readable
|
|
242
|
+
if ((stats.mode & 0o444) !== 0o444) {
|
|
243
|
+
yield this.fileSystem.chmod(itemPath, 0o644);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
catch (itemError) {
|
|
248
|
+
// Continue with other items
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
catch (error) {
|
|
253
|
+
console.warn(`Error preparing directory ${dirPath}: ${error}`);
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Restores original permissions for all modified files and directories
|
|
259
|
+
*/
|
|
260
|
+
restoreDirectoryPermissions(permissionsMap) {
|
|
261
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
262
|
+
// Convert to array and reverse to handle deepest paths first
|
|
263
|
+
const paths = Array.from(permissionsMap.keys()).reverse();
|
|
264
|
+
for (const path of paths) {
|
|
265
|
+
const originalMode = permissionsMap.get(path);
|
|
266
|
+
if (originalMode !== undefined) {
|
|
267
|
+
try {
|
|
268
|
+
yield this.fileSystem.chmod(path, originalMode);
|
|
269
|
+
}
|
|
270
|
+
catch (error) {
|
|
271
|
+
console.warn(`Failed to restore permissions for ${path}: ${error}`);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* Calculates directory size recursively using Node.js native functions.
|
|
279
|
+
* This is a fallback method for when command-line tools fail.
|
|
280
|
+
*/
|
|
281
|
+
calculateDirectorySizeRecursively(dirPath) {
|
|
282
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
283
|
+
let totalSize = 0;
|
|
284
|
+
try {
|
|
285
|
+
const items = yield this.fileSystem.readdir(dirPath);
|
|
286
|
+
for (const item of items) {
|
|
287
|
+
const itemPath = `${dirPath}/${item}`;
|
|
288
|
+
try {
|
|
289
|
+
const stats = yield this.fileSystem.stat(itemPath);
|
|
290
|
+
if (stats.isDirectory()) {
|
|
291
|
+
totalSize += yield this.calculateDirectorySizeRecursively(itemPath);
|
|
292
|
+
}
|
|
293
|
+
else if (stats.isFile()) {
|
|
294
|
+
totalSize += stats.size;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
catch (itemError) {
|
|
298
|
+
console.warn(`Skipping item during size calculation: ${itemPath}: ${itemError}`);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
catch (error) {
|
|
303
|
+
console.warn(`Error reading directory during size calculation: ${dirPath}: ${error}`);
|
|
304
|
+
}
|
|
305
|
+
return totalSize;
|
|
160
306
|
});
|
|
161
307
|
}
|
|
162
308
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FolderManager.js","sourceRoot":"","sources":["../../../source/engine/Filesystem/FolderManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2DAAqC;AACrC,4CAAgC;AAChC,2EAAkD;AAElD,iBAAiB;AACjB,mFAA0D;AAM1D,MAAqB,aAAa;IAMhC;QACE,IAAI,CAAC,UAAU,GAAG,kBAAU,CAAC;QAC7B,IAAI,CAAC,cAAc,GAAG,YAAc,CAAC;QACrC,IAAI,CAAC,cAAc,GAAG,IAAI,yBAAc,EAAE,CAAC;QAC3C,IAAI,CAAC,aAAa,GAAG,IAAI,wBAAa,EAAE,CAAC;IAC3C,CAAC;IAED;;OAEG;IACU,eA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AEf,IAAI,SAAS,GAAG,CAAC,CAAC;YAElB,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAErD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;oBACzB,MAAM,QAAQ,GAAG,GAAG,OAAO,IAAI,IAAI,EAAE,CAAC;oBAEtC,IAAI,CAAC;wBACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;wBAEnD,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;4BACxB,SAAS,IAAI,MAAM,IAAI,CAAC,iCAAiC,CAAC,QAAQ,CAAC,CAAC;wBACtE,CAAC;6BAAM,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,CAAC;4BAC1B,SAAS,IAAI,KAAK,CAAC,IAAI,CAAC;wBAC1B,CAAC;oBACH,CAAC;oBAAC,OAAO,SAAS,EAAE,CAAC;wBACnB,OAAO,CAAC,IAAI,CACV,0CAA0C,QAAQ,KAAK,SAAS,EAAE,CACnE,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,IAAI,CACV,oDAAoD,OAAO,KAAK,KAAK,EAAE,CACxE,CAAC;YACJ,CAAC;YAED,OAAO,SAAS,CAAC;QACnB,CAAC;KAAA;CACF;AA/TD,gCA+TC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { AxioDB } from "../../../Services/Indexation.operation";
|
|
2
|
+
import { ResponseBuilder } from "../../helper/responseBuilder.helper";
|
|
3
|
+
import { FastifyRequest } from "fastify";
|
|
4
|
+
/**
|
|
5
|
+
* Controller class for managing collections in AxioDB.
|
|
6
|
+
*
|
|
7
|
+
* This class provides methods for creating, retrieving, and managing collections
|
|
8
|
+
* within the AxioDB instance. It acts as an interface between the API routes and
|
|
9
|
+
* the AxioDB instance.
|
|
10
|
+
*/
|
|
11
|
+
export default class CollectionController {
|
|
12
|
+
private AxioDBInstance;
|
|
13
|
+
constructor(AxioDBInstance: AxioDB);
|
|
14
|
+
/**
|
|
15
|
+
* Creates a new collection in the specified database.
|
|
16
|
+
*
|
|
17
|
+
* @param request - The Fastify request object containing the collection details in the body
|
|
18
|
+
* @returns A ResponseBuilder object containing the status and message of the operation
|
|
19
|
+
*
|
|
20
|
+
* @throws Will return a conflict response if collection already exists
|
|
21
|
+
* @throws Will return a bad request response if name is missing, not a string, or empty
|
|
22
|
+
* @throws Will return an internal server error response if collection creation fails
|
|
23
|
+
*/
|
|
24
|
+
createCollection(request: FastifyRequest): Promise<ResponseBuilder>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
const outers_1 = require("outers");
|
|
16
|
+
const responseBuilder_helper_1 = __importDefault(require("../../helper/responseBuilder.helper"));
|
|
17
|
+
/**
|
|
18
|
+
* Controller class for managing collections in AxioDB.
|
|
19
|
+
*
|
|
20
|
+
* This class provides methods for creating, retrieving, and managing collections
|
|
21
|
+
* within the AxioDB instance. It acts as an interface between the API routes and
|
|
22
|
+
* the AxioDB instance.
|
|
23
|
+
*/
|
|
24
|
+
class CollectionController {
|
|
25
|
+
constructor(AxioDBInstance) {
|
|
26
|
+
this.AxioDBInstance = AxioDBInstance;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new collection in the specified database.
|
|
30
|
+
*
|
|
31
|
+
* @param request - The Fastify request object containing the collection details in the body
|
|
32
|
+
* @returns A ResponseBuilder object containing the status and message of the operation
|
|
33
|
+
*
|
|
34
|
+
* @throws Will return a conflict response if collection already exists
|
|
35
|
+
* @throws Will return a bad request response if name is missing, not a string, or empty
|
|
36
|
+
* @throws Will return an internal server error response if collection creation fails
|
|
37
|
+
*/
|
|
38
|
+
createCollection(request) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
// Extracting parameters from the request body
|
|
41
|
+
const { dbName, collectionName, crypto, key } = request.body;
|
|
42
|
+
// Validating extracted parameters
|
|
43
|
+
if (!dbName || typeof dbName !== "string") {
|
|
44
|
+
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.BAD_REQUEST, "Invalid database name");
|
|
45
|
+
}
|
|
46
|
+
if (!collectionName || typeof collectionName !== "string") {
|
|
47
|
+
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.BAD_REQUEST, "Invalid collection name");
|
|
48
|
+
}
|
|
49
|
+
const databaseInstance = yield this.AxioDBInstance.createDB(dbName);
|
|
50
|
+
const isCollectionExists = yield databaseInstance.isCollectionExists(collectionName);
|
|
51
|
+
if (isCollectionExists) {
|
|
52
|
+
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.CONFLICT, "Collection already exists");
|
|
53
|
+
}
|
|
54
|
+
// Creating the collection
|
|
55
|
+
try {
|
|
56
|
+
yield databaseInstance.createCollection(collectionName, crypto, key);
|
|
57
|
+
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.CREATED, "Collection created successfully");
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
console.error("Error creating collection:", error);
|
|
61
|
+
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.INTERNAL_SERVER_ERROR, "Failed to create collection");
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.default = CollectionController;
|
|
67
|
+
//# sourceMappingURL=Collection.controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Collection.controller.js","sourceRoot":"","sources":["../../../../source/server/controller/Collections/Collection.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mCAAqC;AAErC,iGAE6C;AAG7C;;;;;;GAMG;AACH,MAAqB,oBAAoB;IAGvC,YAAY,cAAsB;QAChC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED;;;;;;;;;OASG;IACU,gBAAgB,CAC3B,OAAuB;;YAEvB,8CAA8C;YAC9C,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAKvD,CAAC;YAEF,kCAAkC;YAClC,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC1C,OAAO,IAAA,gCAAa,EAAC,oBAAW,CAAC,WAAW,EAAE,uBAAuB,CAAC,CAAC;YACzE,CAAC;YACD,IAAI,CAAC,cAAc,IAAI,OAAO,cAAc,KAAK,QAAQ,EAAE,CAAC;gBAC1D,OAAO,IAAA,gCAAa,EAAC,oBAAW,CAAC,WAAW,EAAE,yBAAyB,CAAC,CAAC;YAC3E,CAAC;YAED,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;YAEpE,MAAM,kBAAkB,GACtB,MAAM,gBAAgB,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAC;YAC5D,IAAI,kBAAkB,EAAE,CAAC;gBACvB,OAAO,IAAA,gCAAa,EAAC,oBAAW,CAAC,QAAQ,EAAE,2BAA2B,CAAC,CAAC;YAC1E,CAAC;YACD,0BAA0B;YAC1B,IAAI,CAAC;gBACH,MAAM,gBAAgB,CAAC,gBAAgB,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;gBACrE,OAAO,IAAA,gCAAa,EAClB,oBAAW,CAAC,OAAO,EACnB,iCAAiC,CAClC,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,4BAA4B,EAAE,KAAK,CAAC,CAAC;gBACnD,OAAO,IAAA,gCAAa,EAClB,oBAAW,CAAC,qBAAqB,EACjC,6BAA6B,CAC9B,CAAC;YACJ,CAAC;QACH,CAAC;KAAA;CACF;AA1DD,uCA0DC"}
|
|
@@ -53,4 +53,4 @@ Please change the parent <Route path="${X}"> to <Route path="${X==="/"?"*":`${X}
|
|
|
53
53
|
`)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(c){return c instanceof this?c:new this(c)}static concat(c,...s){const r=new this(c);return s.forEach(o=>r.set(o)),r}static accessor(c){const r=(this[lm]=this[lm]={accessors:{}}).accessors,o=this.prototype;function d(m){const v=Pn(m);r[v]||(b1(o,m),r[v]=!0)}return M.isArray(c)?c.forEach(d):d(c),this}};ct.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);M.reduceDescriptors(ct.prototype,({value:u},c)=>{let s=c[0].toUpperCase()+c.slice(1);return{get:()=>u,set(r){this[s]=r}}});M.freezeMethods(ct);function vs(u,c){const s=this||ru,r=c||s,o=ct.from(r.headers);let d=r.data;return M.forEach(u,function(v){d=v.call(s,d,o.normalize(),c?c.status:void 0)}),o.normalize(),d}function Qm(u){return!!(u&&u.__CANCEL__)}function ka(u,c,s){ae.call(this,u==null?"canceled":u,ae.ERR_CANCELED,c,s),this.name="CanceledError"}M.inherits(ka,ae,{__CANCEL__:!0});function Zm(u,c,s){const r=s.config.validateStatus;!s.status||!r||r(s.status)?u(s):c(new ae("Request failed with status code "+s.status,[ae.ERR_BAD_REQUEST,ae.ERR_BAD_RESPONSE][Math.floor(s.status/100)-4],s.config,s.request,s))}function S1(u){const c=/^([-+\w]{1,25})(:?\/\/|:)/.exec(u);return c&&c[1]||""}function x1(u,c){u=u||10;const s=new Array(u),r=new Array(u);let o=0,d=0,m;return c=c!==void 0?c:1e3,function(g){const y=Date.now(),p=r[d];m||(m=y),s[o]=g,r[o]=y;let N=d,D=0;for(;N!==o;)D+=s[N++],N=N%u;if(o=(o+1)%u,o===d&&(d=(d+1)%u),y-m<c)return;const Y=p&&y-p;return Y?Math.round(D*1e3/Y):void 0}}function E1(u,c){let s=0,r=1e3/c,o,d;const m=(y,p=Date.now())=>{s=p,o=null,d&&(clearTimeout(d),d=null),u(...y)};return[(...y)=>{const p=Date.now(),N=p-s;N>=r?m(y,p):(o=y,d||(d=setTimeout(()=>{d=null,m(o)},r-N)))},()=>o&&m(o)]}const zi=(u,c,s=3)=>{let r=0;const o=x1(50,250);return E1(d=>{const m=d.loaded,v=d.lengthComputable?d.total:void 0,g=m-r,y=o(g),p=m<=v;r=m;const N={loaded:m,total:v,progress:v?m/v:void 0,bytes:g,rate:y||void 0,estimated:y&&v&&p?(v-m)/y:void 0,event:d,lengthComputable:v!=null,[c?"download":"upload"]:!0};u(N)},s)},am=(u,c)=>{const s=u!=null;return[r=>c[0]({lengthComputable:s,total:u,loaded:r}),c[1]]},nm=u=>(...c)=>M.asap(()=>u(...c)),T1=Ie.hasStandardBrowserEnv?((u,c)=>s=>(s=new URL(s,Ie.origin),u.protocol===s.protocol&&u.host===s.host&&(c||u.port===s.port)))(new URL(Ie.origin),Ie.navigator&&/(msie|trident)/i.test(Ie.navigator.userAgent)):()=>!0,R1=Ie.hasStandardBrowserEnv?{write(u,c,s,r,o,d){const m=[u+"="+encodeURIComponent(c)];M.isNumber(s)&&m.push("expires="+new Date(s).toGMTString()),M.isString(r)&&m.push("path="+r),M.isString(o)&&m.push("domain="+o),d===!0&&m.push("secure"),document.cookie=m.join("; ")},read(u){const c=document.cookie.match(new RegExp("(^|;\\s*)("+u+")=([^;]*)"));return c?decodeURIComponent(c[3]):null},remove(u){this.write(u,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function A1(u){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(u)}function O1(u,c){return c?u.replace(/\/?\/$/,"")+"/"+c.replace(/^\/+/,""):u}function Km(u,c,s){let r=!A1(c);return u&&(r||s==!1)?O1(u,c):c}const um=u=>u instanceof ct?Se({},u):u;function la(u,c){c=c||{};const s={};function r(y,p,N,D){return M.isPlainObject(y)&&M.isPlainObject(p)?M.merge.call({caseless:D},y,p):M.isPlainObject(p)?M.merge({},p):M.isArray(p)?p.slice():p}function o(y,p,N,D){if(M.isUndefined(p)){if(!M.isUndefined(y))return r(void 0,y,N,D)}else return r(y,p,N,D)}function d(y,p){if(!M.isUndefined(p))return r(void 0,p)}function m(y,p){if(M.isUndefined(p)){if(!M.isUndefined(y))return r(void 0,y)}else return r(void 0,p)}function v(y,p,N){if(N in c)return r(y,p);if(N in u)return r(void 0,y)}const g={url:d,method:d,data:d,baseURL:m,transformRequest:m,transformResponse:m,paramsSerializer:m,timeout:m,timeoutMessage:m,withCredentials:m,withXSRFToken:m,adapter:m,responseType:m,xsrfCookieName:m,xsrfHeaderName:m,onUploadProgress:m,onDownloadProgress:m,decompress:m,maxContentLength:m,maxBodyLength:m,beforeRedirect:m,transport:m,httpAgent:m,httpsAgent:m,cancelToken:m,socketPath:m,responseEncoding:m,validateStatus:v,headers:(y,p,N)=>o(um(y),um(p),N,!0)};return M.forEach(Object.keys(Se(Se({},u),c)),function(p){const N=g[p]||o,D=N(u[p],c[p],p);M.isUndefined(D)&&N!==v||(s[p]=D)}),s}const Jm=u=>{const c=la({},u);let{data:s,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:d,headers:m,auth:v}=c;c.headers=m=ct.from(m),c.url=Gm(Km(c.baseURL,c.url,c.allowAbsoluteUrls),u.params,u.paramsSerializer),v&&m.set("Authorization","Basic "+btoa((v.username||"")+":"+(v.password?unescape(encodeURIComponent(v.password)):"")));let g;if(M.isFormData(s)){if(Ie.hasStandardBrowserEnv||Ie.hasStandardBrowserWebWorkerEnv)m.setContentType(void 0);else if((g=m.getContentType())!==!1){const[y,...p]=g?g.split(";").map(N=>N.trim()).filter(Boolean):[];m.setContentType([y||"multipart/form-data",...p].join("; "))}}if(Ie.hasStandardBrowserEnv&&(r&&M.isFunction(r)&&(r=r(c)),r||r!==!1&&T1(c.url))){const y=o&&d&&R1.read(d);y&&m.set(o,y)}return c},N1=typeof XMLHttpRequest!="undefined",D1=N1&&function(u){return new Promise(function(s,r){const o=Jm(u);let d=o.data;const m=ct.from(o.headers).normalize();let{responseType:v,onUploadProgress:g,onDownloadProgress:y}=o,p,N,D,Y,C;function z(){Y&&Y(),C&&C(),o.cancelToken&&o.cancelToken.unsubscribe(p),o.signal&&o.signal.removeEventListener("abort",p)}let j=new XMLHttpRequest;j.open(o.method.toUpperCase(),o.url,!0),j.timeout=o.timeout;function G(){if(!j)return;const K=ct.from("getAllResponseHeaders"in j&&j.getAllResponseHeaders()),V={data:!v||v==="text"||v==="json"?j.responseText:j.response,status:j.status,statusText:j.statusText,headers:K,config:u,request:j};Zm(function(fe){s(fe),z()},function(fe){r(fe),z()},V),j=null}"onloadend"in j?j.onloadend=G:j.onreadystatechange=function(){!j||j.readyState!==4||j.status===0&&!(j.responseURL&&j.responseURL.indexOf("file:")===0)||setTimeout(G)},j.onabort=function(){j&&(r(new ae("Request aborted",ae.ECONNABORTED,u,j)),j=null)},j.onerror=function(){r(new ae("Network Error",ae.ERR_NETWORK,u,j)),j=null},j.ontimeout=function(){let te=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const V=o.transitional||Xm;o.timeoutErrorMessage&&(te=o.timeoutErrorMessage),r(new ae(te,V.clarifyTimeoutError?ae.ETIMEDOUT:ae.ECONNABORTED,u,j)),j=null},d===void 0&&m.setContentType(null),"setRequestHeader"in j&&M.forEach(m.toJSON(),function(te,V){j.setRequestHeader(V,te)}),M.isUndefined(o.withCredentials)||(j.withCredentials=!!o.withCredentials),v&&v!=="json"&&(j.responseType=o.responseType),y&&([D,C]=zi(y,!0),j.addEventListener("progress",D)),g&&j.upload&&([N,Y]=zi(g),j.upload.addEventListener("progress",N),j.upload.addEventListener("loadend",Y)),(o.cancelToken||o.signal)&&(p=K=>{j&&(r(!K||K.type?new ka(null,u,j):K),j.abort(),j=null)},o.cancelToken&&o.cancelToken.subscribe(p),o.signal&&(o.signal.aborted?p():o.signal.addEventListener("abort",p)));const X=S1(o.url);if(X&&Ie.protocols.indexOf(X)===-1){r(new ae("Unsupported protocol "+X+":",ae.ERR_BAD_REQUEST,u));return}j.send(d||null)})},w1=(u,c)=>{const{length:s}=u=u?u.filter(Boolean):[];if(c||s){let r=new AbortController,o;const d=function(y){if(!o){o=!0,v();const p=y instanceof Error?y:this.reason;r.abort(p instanceof ae?p:new ka(p instanceof Error?p.message:p))}};let m=c&&setTimeout(()=>{m=null,d(new ae(`timeout ${c} of ms exceeded`,ae.ETIMEDOUT))},c);const v=()=>{u&&(m&&clearTimeout(m),m=null,u.forEach(y=>{y.unsubscribe?y.unsubscribe(d):y.removeEventListener("abort",d)}),u=null)};u.forEach(y=>y.addEventListener("abort",d));const{signal:g}=r;return g.unsubscribe=()=>M.asap(v),g}},_1=function*(u,c){let s=u.byteLength;if(s<c){yield u;return}let r=0,o;for(;r<s;)o=r+c,yield u.slice(r,o),r=o},C1=function(u,c){return is(this,null,function*(){try{for(var s=zh(M1(u)),r,o,d;r=!(o=yield new Il(s.next())).done;r=!1){const m=o.value;yield*cs(_1(m,c))}}catch(o){d=[o]}finally{try{r&&(o=s.return)&&(yield new Il(o.call(s)))}finally{if(d)throw d[0]}}})},M1=function(u){return is(this,null,function*(){if(u[Symbol.asyncIterator]){yield*cs(u);return}const c=u.getReader();try{for(;;){const{done:s,value:r}=yield new Il(c.read());if(s)break;yield r}}finally{yield new Il(c.cancel())}})},im=(u,c,s,r)=>{const o=C1(u,c);let d=0,m,v=y=>{m||(m=!0,r&&r(y))};return new ReadableStream({pull(y){return Ze(this,null,function*(){try{const{done:p,value:N}=yield o.next();if(p){v(),y.close();return}let D=N.byteLength;if(s){let Y=d+=D;s(Y)}y.enqueue(new Uint8Array(N))}catch(p){throw v(p),p}})},cancel(y){return v(y),o.return()}},{highWaterMark:2})},Vi=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",km=Vi&&typeof ReadableStream=="function",j1=Vi&&(typeof TextEncoder=="function"?(u=>c=>u.encode(c))(new TextEncoder):u=>Ze(null,null,function*(){return new Uint8Array(yield new Response(u).arrayBuffer())})),$m=(u,...c)=>{try{return!!u(...c)}catch(s){return!1}},z1=km&&$m(()=>{let u=!1;const c=new Request(Ie.origin,{body:new ReadableStream,method:"POST",get duplex(){return u=!0,"half"}}).headers.has("Content-Type");return u&&!c}),cm=64*1024,As=km&&$m(()=>M.isReadableStream(new Response("").body)),Ui={stream:As&&(u=>u.body)};Vi&&(u=>{["text","arrayBuffer","blob","formData","stream"].forEach(c=>{!Ui[c]&&(Ui[c]=M.isFunction(u[c])?s=>s[c]():(s,r)=>{throw new ae(`Response type '${c}' is not supported`,ae.ERR_NOT_SUPPORT,r)})})})(new Response);const U1=u=>Ze(null,null,function*(){if(u==null)return 0;if(M.isBlob(u))return u.size;if(M.isSpecCompliantForm(u))return(yield new Request(Ie.origin,{method:"POST",body:u}).arrayBuffer()).byteLength;if(M.isArrayBufferView(u)||M.isArrayBuffer(u))return u.byteLength;if(M.isURLSearchParams(u)&&(u=u+""),M.isString(u))return(yield j1(u)).byteLength}),B1=(u,c)=>Ze(null,null,function*(){const s=M.toFiniteNumber(u.getContentLength());return s==null?U1(c):s}),H1=Vi&&(u=>Ze(null,null,function*(){let{url:c,method:s,data:r,signal:o,cancelToken:d,timeout:m,onDownloadProgress:v,onUploadProgress:g,responseType:y,headers:p,withCredentials:N="same-origin",fetchOptions:D}=Jm(u);y=y?(y+"").toLowerCase():"text";let Y=w1([o,d&&d.toAbortSignal()],m),C;const z=Y&&Y.unsubscribe&&(()=>{Y.unsubscribe()});let j;try{if(g&&z1&&s!=="get"&&s!=="head"&&(j=yield B1(p,r))!==0){let V=new Request(c,{method:"POST",body:r,duplex:"half"}),se;if(M.isFormData(r)&&(se=V.headers.get("content-type"))&&p.setContentType(se),V.body){const[fe,Te]=am(j,zi(nm(g)));r=im(V.body,cm,fe,Te)}}M.isString(N)||(N=N?"include":"omit");const G="credentials"in Request.prototype;C=new Request(c,bt(Se({},D),{signal:Y,method:s.toUpperCase(),headers:p.normalize().toJSON(),body:r,duplex:"half",credentials:G?N:void 0}));let X=yield fetch(C,D);const K=As&&(y==="stream"||y==="response");if(As&&(v||K&&z)){const V={};["status","statusText","headers"].forEach(je=>{V[je]=X[je]});const se=M.toFiniteNumber(X.headers.get("content-length")),[fe,Te]=v&&am(se,zi(nm(v),!0))||[];X=new Response(im(X.body,cm,fe,()=>{Te&&Te(),z&&z()}),V)}y=y||"text";let te=yield Ui[M.findKey(Ui,y)||"text"](X,u);return!K&&z&&z(),yield new Promise((V,se)=>{Zm(V,se,{data:te,headers:ct.from(X.headers),status:X.status,statusText:X.statusText,config:u,request:C})})}catch(G){throw z&&z(),G&&G.name==="TypeError"&&/Load failed|fetch/i.test(G.message)?Object.assign(new ae("Network Error",ae.ERR_NETWORK,u,C),{cause:G.cause||G}):ae.from(G,G&&G.code,u,C)}})),Os={http:Pp,xhr:D1,fetch:H1};M.forEach(Os,(u,c)=>{if(u){try{Object.defineProperty(u,"name",{value:c})}catch(s){}Object.defineProperty(u,"adapterName",{value:c})}});const rm=u=>`- ${u}`,L1=u=>M.isFunction(u)||u===null||u===!1,Fm={getAdapter:u=>{u=M.isArray(u)?u:[u];const{length:c}=u;let s,r;const o={};for(let d=0;d<c;d++){s=u[d];let m;if(r=s,!L1(s)&&(r=Os[(m=String(s)).toLowerCase()],r===void 0))throw new ae(`Unknown adapter '${m}'`);if(r)break;o[m||"#"+d]=r}if(!r){const d=Object.entries(o).map(([v,g])=>`adapter ${v} `+(g===!1?"is not supported by the environment":"is not available in the build"));let m=c?d.length>1?`since :
|
|
54
54
|
`+d.map(rm).join(`
|
|
55
55
|
`):" "+rm(d[0]):"as no adapter specified";throw new ae("There is no suitable adapter to dispatch the request "+m,"ERR_NOT_SUPPORT")}return r},adapters:Os};function ps(u){if(u.cancelToken&&u.cancelToken.throwIfRequested(),u.signal&&u.signal.aborted)throw new ka(null,u)}function sm(u){return ps(u),u.headers=ct.from(u.headers),u.data=vs.call(u,u.transformRequest),["post","put","patch"].indexOf(u.method)!==-1&&u.headers.setContentType("application/x-www-form-urlencoded",!1),Fm.getAdapter(u.adapter||ru.adapter)(u).then(function(r){return ps(u),r.data=vs.call(u,u.transformResponse,r),r.headers=ct.from(r.headers),r},function(r){return Qm(r)||(ps(u),r&&r.response&&(r.response.data=vs.call(u,u.transformResponse,r.response),r.response.headers=ct.from(r.response.headers))),Promise.reject(r)})}const Wm="1.11.0",Qi={};["object","boolean","number","function","string","symbol"].forEach((u,c)=>{Qi[u]=function(r){return typeof r===u||"a"+(c<1?"n ":" ")+u}});const om={};Qi.transitional=function(c,s,r){function o(d,m){return"[Axios v"+Wm+"] Transitional option '"+d+"'"+m+(r?". "+r:"")}return(d,m,v)=>{if(c===!1)throw new ae(o(m," has been removed"+(s?" in "+s:"")),ae.ERR_DEPRECATED);return s&&!om[m]&&(om[m]=!0,console.warn(o(m," has been deprecated since v"+s+" and will be removed in the near future"))),c?c(d,m,v):!0}};Qi.spelling=function(c){return(s,r)=>(console.warn(`${r} is likely a misspelling of ${c}`),!0)};function q1(u,c,s){if(typeof u!="object")throw new ae("options must be an object",ae.ERR_BAD_OPTION_VALUE);const r=Object.keys(u);let o=r.length;for(;o-- >0;){const d=r[o],m=c[d];if(m){const v=u[d],g=v===void 0||m(v,d,u);if(g!==!0)throw new ae("option "+d+" must be "+g,ae.ERR_BAD_OPTION_VALUE);continue}if(s!==!0)throw new ae("Unknown option "+d,ae.ERR_BAD_OPTION)}}const Mi={assertOptions:q1,validators:Qi},Gt=Mi.validators;let ta=class{constructor(c){this.defaults=c||{},this.interceptors={request:new tm,response:new tm}}request(c,s){return Ze(this,null,function*(){try{return yield this._request(c,s)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const d=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?d&&!String(r.stack).endsWith(d.replace(/^.+\n.+\n/,""))&&(r.stack+=`
|
|
56
|
-
`+d):r.stack=d}catch(m){}}throw r}})}_request(c,s){typeof c=="string"?(s=s||{},s.url=c):s=c||{},s=la(this.defaults,s);const{transitional:r,paramsSerializer:o,headers:d}=s;r!==void 0&&Mi.assertOptions(r,{silentJSONParsing:Gt.transitional(Gt.boolean),forcedJSONParsing:Gt.transitional(Gt.boolean),clarifyTimeoutError:Gt.transitional(Gt.boolean)},!1),o!=null&&(M.isFunction(o)?s.paramsSerializer={serialize:o}:Mi.assertOptions(o,{encode:Gt.function,serialize:Gt.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),Mi.assertOptions(s,{baseUrl:Gt.spelling("baseURL"),withXsrfToken:Gt.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let m=d&&M.merge(d.common,d[s.method]);d&&M.forEach(["delete","get","head","post","put","patch","common"],C=>{delete d[C]}),s.headers=ct.concat(m,d);const v=[];let g=!0;this.interceptors.request.forEach(function(z){typeof z.runWhen=="function"&&z.runWhen(s)===!1||(g=g&&z.synchronous,v.unshift(z.fulfilled,z.rejected))});const y=[];this.interceptors.response.forEach(function(z){y.push(z.fulfilled,z.rejected)});let p,N=0,D;if(!g){const C=[sm.bind(this),void 0];for(C.unshift(...v),C.push(...y),D=C.length,p=Promise.resolve(s);N<D;)p=p.then(C[N++],C[N++]);return p}D=v.length;let Y=s;for(N=0;N<D;){const C=v[N++],z=v[N++];try{Y=C(Y)}catch(j){z.call(this,j);break}}try{p=sm.call(this,Y)}catch(C){return Promise.reject(C)}for(N=0,D=y.length;N<D;)p=p.then(y[N++],y[N++]);return p}getUri(c){c=la(this.defaults,c);const s=Km(c.baseURL,c.url,c.allowAbsoluteUrls);return Gm(s,c.params,c.paramsSerializer)}};M.forEach(["delete","get","head","options"],function(c){ta.prototype[c]=function(s,r){return this.request(la(r||{},{method:c,url:s,data:(r||{}).data}))}});M.forEach(["post","put","patch"],function(c){function s(r){return function(d,m,v){return this.request(la(v||{},{method:c,headers:r?{"Content-Type":"multipart/form-data"}:{},url:d,data:m}))}}ta.prototype[c]=s(),ta.prototype[c+"Form"]=s(!0)});let Y1=class Pm{constructor(c){if(typeof c!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(d){s=d});const r=this;this.promise.then(o=>{if(!r._listeners)return;let d=r._listeners.length;for(;d-- >0;)r._listeners[d](o);r._listeners=null}),this.promise.then=o=>{let d;const m=new Promise(v=>{r.subscribe(v),d=v}).then(o);return m.cancel=function(){r.unsubscribe(d)},m},c(function(d,m,v){r.reason||(r.reason=new ka(d,m,v),s(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(c){if(this.reason){c(this.reason);return}this._listeners?this._listeners.push(c):this._listeners=[c]}unsubscribe(c){if(!this._listeners)return;const s=this._listeners.indexOf(c);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const c=new AbortController,s=r=>{c.abort(r)};return this.subscribe(s),c.signal.unsubscribe=()=>this.unsubscribe(s),c.signal}static source(){let c;return{token:new Pm(function(o){c=o}),cancel:c}}};function G1(u){return function(s){return u.apply(null,s)}}function X1(u){return M.isObject(u)&&u.isAxiosError===!0}const Ns={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ns).forEach(([u,c])=>{Ns[c]=u});function Im(u){const c=new ta(u),s=wm(ta.prototype.request,c);return M.extend(s,ta.prototype,c,{allOwnKeys:!0}),M.extend(s,c,null,{allOwnKeys:!0}),s.create=function(o){return Im(la(u,o))},s}const Ae=Im(ru);Ae.Axios=ta;Ae.CanceledError=ka;Ae.CancelToken=Y1;Ae.isCancel=Qm;Ae.VERSION=Wm;Ae.toFormData=Xi;Ae.AxiosError=ae;Ae.Cancel=Ae.CanceledError;Ae.all=function(c){return Promise.all(c)};Ae.spread=G1;Ae.isAxiosError=X1;Ae.mergeConfig=la;Ae.AxiosHeaders=ct;Ae.formToJSON=u=>Vm(M.isHTMLForm(u)?new FormData(u):u);Ae.getAdapter=Fm.getAdapter;Ae.HttpStatusCode=Ns;Ae.default=Ae;const{Axios:Ab,AxiosError:Ob,CanceledError:Nb,isCancel:Db,CancelToken:wb,VERSION:_b,all:Cb,Cancel:Mb,isAxiosError:jb,spread:zb,toFormData:Ub,AxiosHeaders:Bb,HttpStatusCode:Hb,formToJSON:Lb,getAdapter:qb,mergeConfig:Yb}=Ae,fm=u=>{let c;const s=new Set,r=(y,p)=>{const N=typeof y=="function"?y(c):y;if(!Object.is(N,c)){const D=c;c=(p!=null?p:typeof N!="object"||N===null)?N:Object.assign({},c,N),s.forEach(Y=>Y(c,D))}},o=()=>c,v={setState:r,getState:o,getInitialState:()=>g,subscribe:y=>(s.add(y),()=>s.delete(y))},g=c=u(r,o,v);return v},V1=u=>u?fm(u):fm,Q1=u=>u;function Z1(u,c=Q1){const s=qh.useSyncExternalStore(u.subscribe,()=>c(u.getState()),()=>c(u.getInitialState()));return qh.useDebugValue(s),s}const dm=u=>{const c=V1(u),s=r=>Z1(c,r);return Object.assign(s,c),s},e0=u=>u?dm(u):dm,su=window.location.origin,tu=e0(u=>({Rootname:"",setRootname:c=>u({Rootname:c})})),$a=e0(u=>({TransactionKey:"",setTransactionKey:c=>u({TransactionKey:c}),loadKey:()=>Ze(null,null,function*(){yield Ae.get(`${su}/api/get-token`).then(c=>{var s,r;c.status===200&&u({TransactionKey:(r=(s=c.data)==null?void 0:s.data)==null?void 0:r.originSessionKey})}).catch(c=>{console.error("Error fetching transaction key:",c)})})})),K1=()=>{const[u,c]=R.useState(!1),{Rootname:s}=tu(r=>r);return S.jsx("header",{className:"bg-gradient-to-r from-blue-700 to-indigo-800 shadow-lg",children:S.jsx("nav",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:S.jsx("div",{className:"flex items-center justify-between h-16",children:S.jsxs("div",{className:"flex items-center",children:[S.jsx("div",{className:"flex-shrink-0",children:S.jsxs(Qa,{to:"/",className:"flex items-center",children:[S.jsx("img",{src:"/AXioDB.png",alt:"AxioDB Logo",className:"h-9 w-9"}),S.jsxs("span",{className:"ml-2 text-white font-bold text-xl tracking-tight",children:[s," Admin Hub"]})]})}),S.jsx("div",{className:"hidden md:block ml-10",children:S.jsxs("div",{className:"flex space-x-4",children:[S.jsx(Qa,{to:"/",className:"text-blue-100 hover:bg-blue-600 hover:text-white px-3 py-2 rounded-md text-sm font-medium transition-colors",children:"Dashboard"}),S.jsx(Qa,{to:"/databases",className:"text-blue-100 hover:bg-blue-600 hover:text-white px-3 py-2 rounded-md text-sm font-medium transition-colors",children:"Databases"}),S.jsx(Qa,{to:"/queries",className:"text-blue-100 hover:bg-blue-600 hover:text-white px-3 py-2 rounded-md text-sm font-medium transition-colors",children:"Queries"})]})})]})})})})};function J1(u,c){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:c},u),R.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z"}))}const k1=R.forwardRef(J1);function $1(u,c){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:c},u),R.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"}))}const F1=R.forwardRef($1);function W1(u,c){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:c},u),R.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"}))}const t0=R.forwardRef(W1);function P1(u,c){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:c},u),R.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"}))}const I1=R.forwardRef(P1);function eb(u,c){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:c},u),R.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"}))}const tb=R.forwardRef(eb);function lb(u,c){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:c},u),R.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01"}))}const ab=R.forwardRef(lb);function nb(u,c){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:c},u),R.createElement("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"}))}const ub=R.forwardRef(nb);function ib(u,c){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:c},u),R.createElement("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"}))}const cb=R.forwardRef(ib),rb=()=>{const[u,c]=R.useState(!0),[s,r]=R.useState({}),[o,d]=R.useState([]),m=g=>{r(y=>bt(Se({},y),{[g]:!y[g]}))};R.useEffect(()=>{(()=>{setTimeout(()=>{const y=[{id:"db1",name:"UsersDB",type:"database",children:[{id:"db1_col1",name:"accounts",type:"collection",documentCount:1250,size:"2.3 MB"},{id:"db1_col2",name:"profiles",type:"collection",documentCount:1200,size:"4.1 MB"},{id:"db1_col3",name:"sessions",type:"collection",documentCount:5400,size:"1.8 MB"}]},{id:"db2",name:"ProductsDB",type:"database",children:[{id:"db2_col1",name:"inventory",type:"collection",documentCount:850,size:"3.2 MB"},{id:"db2_col2",name:"categories",type:"collection",documentCount:45,size:"0.3 MB"},{id:"db2_col3",name:"suppliers",type:"collection",documentCount:120,size:"0.7 MB"}]},{id:"db3",name:"AnalyticsDB",type:"database",children:[{id:"db3_col1",name:"events",type:"collection",documentCount:4250,size:"8.5 MB"},{id:"db3_col2",name:"metrics",type:"collection",documentCount:1850,size:"4.2 MB"},{id:"db3_col3",name:"reports",type:"collection",documentCount:320,size:"1.5 MB"}]}];r({db1:!0}),d(y),c(!1)},1e3)})()},[]);const v=g=>{const y=s[g.id];return S.jsxs("div",{children:[S.jsxs("div",{className:`flex items-center py-2 px-3 ${g.type==="database"?"bg-blue-50 hover:bg-blue-100 border-b border-blue-100":"hover:bg-gray-50 pl-10"} cursor-pointer transition-colors`,onClick:()=>g.children&&m(g.id),children:[g.children?S.jsx("div",{className:"mr-1",children:y?S.jsx(ub,{className:"h-4 w-4 text-gray-500"}):S.jsx(cb,{className:"h-4 w-4 text-gray-500"})}):S.jsx("div",{className:"w-4 mr-1"}),g.type==="database"?S.jsx(t0,{className:"h-5 w-5 text-blue-600 mr-2"}):S.jsx(tb,{className:"h-5 w-5 text-yellow-600 mr-2"}),S.jsx("div",{className:"flex-grow",children:S.jsx("span",{className:"font-medium",children:g.name})}),g.type==="collection"&&S.jsxs("div",{className:"text-xs text-gray-500",children:[S.jsxs("span",{className:"mr-2",children:[g.documentCount," docs"]}),S.jsx("span",{children:g.size})]})]}),g.children&&y&&S.jsx("div",{className:"border-l border-gray-200 ml-5",children:g.children.map(v)})]},g.id)};return S.jsxs("div",{className:"bg-white rounded-lg shadow-md hover:shadow-lg transition-shadow",children:[S.jsxs("div",{className:"border-b border-gray-200 py-4 px-6",children:[S.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Database Structure"}),S.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Overview of databases and collections"})]}),S.jsx("div",{className:"overflow-y-auto",style:{maxHeight:"400px"},children:u?S.jsx("div",{className:"p-6 space-y-3",children:[1,2,3].map(g=>S.jsxs("div",{className:"animate-pulse",children:[S.jsx("div",{className:"h-6 bg-gray-200 rounded w-3/4 mb-2"}),S.jsxs("div",{className:"pl-6 space-y-2",children:[S.jsx("div",{className:"h-5 bg-gray-100 rounded w-2/3"}),S.jsx("div",{className:"h-5 bg-gray-100 rounded w-2/3"}),S.jsx("div",{className:"h-5 bg-gray-100 rounded w-2/3"})]})]},g))}):S.jsx("div",{children:o.map(v)})})]})},sb=()=>{const[u,c]=R.useState(0),[s,r]=R.useState(0),[o,d]=R.useState(!0);R.useEffect(()=>{(()=>{setTimeout(()=>{c(512),r(1024),d(!1)},800)})()},[]);const m=u/s*100;return S.jsxs("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:[S.jsxs("div",{className:"flex justify-between mb-3",children:[S.jsxs("div",{children:[S.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"In-Memory Cache"}),o?S.jsx("div",{className:"h-8 mt-2 bg-gray-200 rounded animate-pulse w-24"}):S.jsxs("p",{className:"text-3xl font-bold text-orange-600 mt-2",children:[u," ",S.jsx("span",{className:"text-lg",children:"MB"})]}),S.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["of ",s," MB allocated"]})]}),S.jsx("div",{className:"p-3 bg-orange-100 rounded-full",children:S.jsx(k1,{className:"h-8 w-8 text-orange-600"})})]}),S.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2.5 mt-2",children:S.jsx("div",{className:"bg-orange-600 h-2.5 rounded-full",style:{width:`${o?0:m}%`}})})]})},ob=()=>{const[u,c]=R.useState(0),[s,r]=R.useState(0),[o,d]=R.useState(!0);R.useEffect(()=>{(()=>{setTimeout(()=>{c(2.7),r(10),d(!1)},800)})()},[]);const m=u/s*100;return S.jsxs("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:[S.jsxs("div",{className:"flex justify-between mb-3",children:[S.jsxs("div",{children:[S.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Storage Used"}),o?S.jsx("div",{className:"h-8 mt-2 bg-gray-200 rounded animate-pulse w-24"}):S.jsxs("p",{className:"text-3xl font-bold text-green-600 mt-2",children:[u," ",S.jsx("span",{className:"text-lg",children:"GB"})]}),S.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["of ",s," GB available"]})]}),S.jsx("div",{className:"p-3 bg-green-100 rounded-full",children:S.jsx(ab,{className:"h-8 w-8 text-green-600"})})]}),S.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2.5 mt-2",children:S.jsx("div",{className:"bg-green-600 h-2.5 rounded-full",style:{width:`${o?0:m}%`}})})]})},fb=()=>{const[u,c]=R.useState(0),[s,r]=R.useState(!0);return R.useEffect(()=>{(()=>{setTimeout(()=>{c(67),r(!1)},600)})()},[]),S.jsx("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:S.jsxs("div",{className:"flex justify-between",children:[S.jsxs("div",{children:[S.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Total Collections"}),s?S.jsx("div",{className:"h-8 mt-2 bg-gray-200 rounded animate-pulse w-16"}):S.jsx("p",{className:"text-3xl font-bold text-indigo-600 mt-2",children:u}),S.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Across all databases"})]}),S.jsx("div",{className:"p-3 bg-indigo-100 rounded-full",children:S.jsx(F1,{className:"h-8 w-8 text-indigo-600"})})]})})},db=({totalDatabases:u})=>{const[c,s]=R.useState(!0);return R.useEffect(()=>{setTimeout(()=>{s(!1)},1e3)},[]),S.jsx("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:S.jsxs("div",{className:"flex justify-between",children:[S.jsxs("div",{children:[S.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Total Databases"}),c?S.jsx("div",{className:"h-8 mt-2 bg-gray-200 rounded animate-pulse w-16"}):S.jsx("p",{className:"text-3xl font-bold text-blue-600 mt-2",children:u}),S.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Across all instances"})]}),S.jsx("div",{className:"p-3 bg-blue-100 rounded-full",children:S.jsx(t0,{className:"h-8 w-8 text-blue-600"})})]})})},hb=()=>{const[u,c]=R.useState(0),[s,r]=R.useState(!0);return R.useEffect(()=>{(()=>{setTimeout(()=>{c(14825),r(!1)},700)})()},[]),S.jsx("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:S.jsxs("div",{className:"flex justify-between",children:[S.jsxs("div",{children:[S.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Total Documents"}),s?S.jsx("div",{className:"h-8 mt-2 bg-gray-200 rounded animate-pulse w-20"}):S.jsx("p",{className:"text-3xl font-bold text-purple-600 mt-2",children:u.toLocaleString()}),S.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Across all collections"})]}),S.jsx("div",{className:"p-3 bg-purple-100 rounded-full",children:S.jsx(I1,{className:"h-8 w-8 text-purple-600"})})]})})},mb=()=>{const[u,c]=R.useState(!0),[s,r]=R.useState(null),{setRootname:o}=tu(v=>v),{TransactionKey:d}=$a(v=>v),{Rootname:m}=tu(v=>v);return R.useEffect(()=>{Ae.get(`${su}/api/db/databases?transactiontoken=${d}`).then(v=>{var g;v.status===200&&(console.log("All Instance Info:",v.data.data),r(v.data.data),o((g=v.data.data.RootName)!=null?g:"AxioDB"),c(!1))})},[]),S.jsxs("div",{className:"container mx-auto px-4 py-6",children:[S.jsxs("div",{className:"mb-6",children:[S.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Dashboard"}),S.jsxs("p",{className:"text-gray-600",children:["Welcome to ",m," Management Console"]})]}),u?S.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-6 mb-8",children:[1,2,3,4,5].map(v=>S.jsx("div",{className:"h-32 bg-gray-200 rounded-lg animate-pulse"},v))}):S.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-6 mb-8",children:[S.jsx(db,{totalDatabases:(s==null?void 0:s.ListOfDatabases.length)||0}),S.jsx(fb,{}),S.jsx(hb,{}),S.jsx(ob,{}),S.jsx(sb,{})]}),S.jsx("div",{className:"mb-8",children:S.jsx(rb,{})})]})},yb=({isOpen:u,onClose:c,onDatabaseCreated:s})=>{const[r,o]=R.useState(""),[d,m]=R.useState(!1),[v,g]=R.useState(""),{TransactionKey:y}=$a(D=>D),p=()=>{o(""),g(""),m(!1),c()},N=D=>Ze(null,null,function*(){var Y,C;if(D.preventDefault(),!r.trim()){g("Database name is required");return}if(!/^[a-zA-Z0-9_]+$/.test(r)){g("Database name can only contain letters, numbers, and underscores");return}m(!0),g("");try{const z=yield Ae.post(`${su}/api/db/create-database`,{name:r},{params:{transactiontoken:y}});if(z.data.statusCode===200||z.data.statusCode===201)s(r),m(!1),p();else throw m(!1),new Error("Failed to create database")}catch(z){console.error("Error creating database:",z),g(((C=(Y=z.response)==null?void 0:Y.data)==null?void 0:C.message)||"Failed to create database. Please try again."),m(!1)}});return u?S.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 animate-fadeIn",children:S.jsxs("div",{className:"bg-white rounded-lg max-w-md w-full p-6",children:[S.jsx("h3",{className:"text-xl font-bold text-gray-900 mb-4",children:"Create New Database"}),S.jsxs("form",{onSubmit:N,children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{htmlFor:"databaseName",className:"block text-sm font-medium text-gray-700 mb-1",children:"Database Name"}),S.jsx("input",{type:"text",id:"databaseName",value:r,onChange:D=>o(D.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"Enter database name",disabled:d}),v&&S.jsx("p",{className:"mt-2 text-sm text-red-600",children:v})]}),S.jsxs("div",{className:"flex justify-end space-x-4 mt-6",children:[S.jsx("button",{type:"button",onClick:p,className:"px-4 py-2 text-gray-700 hover:text-gray-900 transition-colors",disabled:d,children:"Cancel"}),S.jsx("button",{type:"submit",className:`px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700 transition-colors flex items-center ${d?"opacity-75 cursor-not-allowed":""}`,disabled:d,children:d?S.jsxs(S.Fragment,{children:[S.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[S.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),S.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Creating..."]}):"Create Database"})]})]})]})}):null},gb=({isOpen:u,dbName:c,onClose:s,onConfirmDelete:r})=>{const{TransactionKey:o}=$a(g=>g),[d,m]=R.useState(!1);if(!u)return null;const v=()=>Ze(null,null,function*(){var g,y;m(!0);try{const p=yield Ae.delete(`${su}/api/db/delete-database`,{params:{transactiontoken:o,dbName:c}});if(p.status===200)console.log("Database deleted successfully:",p.data),r();else throw new Error("Failed to delete database")}catch(p){console.error("Error deleting database:",p),alert(((y=(g=p.response)==null?void 0:g.data)==null?void 0:y.message)||"Failed to delete database. Please try again.")}finally{m(!1)}});return S.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:S.jsxs("div",{className:"bg-white rounded-lg max-w-md w-full p-6 animate-fadeIn",children:[S.jsx("h3",{className:"text-xl font-bold text-gray-900 mb-4",children:"Confirm Deletion"}),S.jsxs("p",{className:"text-gray-700 mb-6",children:['Are you sure you want to delete the database "',c,'"? This action cannot be undone.']}),S.jsxs("div",{className:"flex justify-end space-x-4",children:[S.jsx("button",{onClick:s,disabled:d,className:"px-4 py-2 text-gray-700 hover:text-gray-900 transition-colors",children:"Cancel"}),S.jsx("button",{onClick:v,disabled:d,className:`px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700 transition-colors flex items-center ${d?"opacity-75 cursor-not-allowed":""}`,children:d?S.jsxs(S.Fragment,{children:[S.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[S.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),S.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Deleting..."]}):"Delete"})]})]})})},vb=({databases:u,onDeleteClick:c,loading:s})=>{const r=Hi(),[o,d]=R.useState({}),m=g=>{d(y=>bt(Se({},y),{[g]:!1}))},v=g=>{r(`/collections?database=${encodeURIComponent(g)}`)};return S.jsxs("div",{className:"bg-white rounded-lg shadow-md overflow-hidden",children:[S.jsxs("div",{className:"border-b border-gray-200 bg-gray-50 px-6 py-4",children:[S.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Your Databases"}),S.jsxs("p",{className:"text-sm text-gray-500",children:["Total: ",s?"Loading...":u.TotalDatabases]})]}),s?S.jsx("div",{className:"p-6",children:[1,2,3].map(g=>S.jsxs("div",{className:"animate-pulse flex items-center justify-between py-4 border-b border-gray-100",children:[S.jsxs("div",{children:[S.jsx("div",{className:"h-6 bg-gray-200 rounded w-48 mb-2"}),S.jsx("div",{className:"h-4 bg-gray-100 rounded w-32"})]}),S.jsx("div",{className:"h-8 bg-gray-200 rounded w-24"})]},g))}):S.jsx("ul",{className:"divide-y divide-gray-200",children:u.ListOfDatabases&&u.ListOfDatabases.length>0?u.ListOfDatabases.map((g,y)=>S.jsxs("li",{className:`px-6 py-4 flex items-center justify-between hover:bg-gray-50 transition-all duration-300 ${o[g]?"animate-slideIn":"animate-fadeIn"}`,onAnimationEnd:()=>m(g),children:[S.jsxs("div",{children:[S.jsx("h4",{className:"text-lg font-medium text-gray-900",children:g}),S.jsxs("p",{className:"text-sm text-gray-500",children:["Path: ",u.AllDatabasesPaths[y]]})]}),S.jsxs("div",{className:"flex space-x-2",children:[S.jsx("button",{onClick:()=>v(g),className:"text-blue-600 hover:text-blue-800 px-3 py-1 rounded border border-blue-200 hover:border-blue-400 transition-colors",children:"View Collections"}),S.jsx("button",{onClick:()=>c(g),className:"text-red-600 hover:text-red-800 px-3 py-1 rounded border border-red-200 hover:border-red-400 transition-colors",children:"Delete"})]})]},g)):S.jsx("li",{className:"px-6 py-8 text-center text-gray-500",children:'No databases found. Click "Create Database" to add one.'})})]})},pb=()=>{const[u,c]=R.useState(!0),[s,r]=R.useState([]),[o,d]=R.useState(!1),[m,v]=R.useState(!1),[g,y]=R.useState(""),{TransactionKey:p}=$a(z=>z),{Rootname:N}=tu(z=>z);R.useEffect(()=>{p&&Ze(null,null,function*(){try{const j=yield Ae.get(`${su}/api/db/databases?transactiontoken=${p}`);j.status===200&&(r(j.data.data),c(!1))}catch(j){console.error("Error fetching databases:",j),c(!1),r([])}})},[p]);const D=z=>{y(z),d(!0)},Y=()=>{r(z=>bt(Se({},z),{ListOfDatabases:z.ListOfDatabases.filter(j=>j!==g),TotalDatabases:`${z.ListOfDatabases.length-1} Databases`})),d(!1),y("")},C=z=>{r(j=>bt(Se({},j),{ListOfDatabases:[...j.ListOfDatabases,z],TotalDatabases:`${j.ListOfDatabases.length+1} Databases`,AllDatabasesPaths:[...j.AllDatabasesPaths,`${j.CurrentPath}/${z}`]}))};return S.jsxs("div",{className:"container mx-auto px-4 py-6",children:[S.jsxs("div",{className:"flex justify-between items-center mb-6",children:[S.jsxs("div",{children:[S.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Databases"}),S.jsxs("p",{className:"text-gray-600",children:["Manage your ",N," databases"]})]}),S.jsxs("button",{onClick:()=>v(!0),className:"bg-green-600 hover:bg-green-700 text-white py-2 px-4 rounded-lg flex items-center transition-colors",children:[S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 mr-2",viewBox:"0 0 20 20",fill:"currentColor",children:S.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})}),"Create Database"]})]}),S.jsx(vb,{databases:s,onDeleteClick:D,loading:u}),S.jsx(yb,{isOpen:m,onClose:()=>v(!1),onDatabaseCreated:C}),S.jsx(gb,{isOpen:o,dbName:g,onClose:()=>d(!1),onConfirmDelete:Y})]})},bb=()=>{const[u]=ip(),c=Hi(),[s,r]=R.useState(!0),[o,d]=R.useState([]),m=u.get("database"),{TransactionKey:v}=$a(p=>p),{Rootname:g}=tu(p=>p);R.useEffect(()=>{if(!m){c("/databases");return}v&&Ze(null,null,function*(){try{setTimeout(()=>{d([{name:"users",documentCount:1250,size:"2.3 MB"},{name:"orders",documentCount:850,size:"1.8 MB"},{name:"products",documentCount:420,size:"3.1 MB"}]),r(!1)},1e3)}catch(N){console.error("Error fetching collections:",N),r(!1),d([])}})},[v,m,c]);const y=()=>{c("/databases")};return S.jsxs("div",{className:"container mx-auto px-4 py-6",children:[S.jsxs("div",{className:"flex justify-between items-center mb-6",children:[S.jsxs("div",{children:[S.jsx("div",{className:"flex items-center mb-2",children:S.jsx("button",{onClick:y,className:"text-blue-600 hover:text-blue-800 mr-3",children:"← Back to Databases"})}),S.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Collections"}),S.jsxs("p",{className:"text-gray-600",children:["Collections in database:"," ",S.jsx("span",{className:"font-medium",children:m})]})]}),S.jsxs("button",{className:"bg-green-600 hover:bg-green-700 text-white py-2 px-4 rounded-lg flex items-center transition-colors",children:[S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 mr-2",viewBox:"0 0 20 20",fill:"currentColor",children:S.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})}),"Create Collection"]})]}),S.jsxs("div",{className:"bg-white rounded-lg shadow-md overflow-hidden",children:[S.jsxs("div",{className:"border-b border-gray-200 bg-gray-50 px-6 py-4",children:[S.jsxs("h3",{className:"text-lg font-medium text-gray-900",children:["Collections in ",m]}),S.jsxs("p",{className:"text-sm text-gray-500",children:["Total:"," ",s?"Loading...":`${o.length} Collections`]})]}),s?S.jsx("div",{className:"p-6",children:[1,2,3].map(p=>S.jsxs("div",{className:"animate-pulse flex items-center justify-between py-4 border-b border-gray-100",children:[S.jsxs("div",{children:[S.jsx("div",{className:"h-6 bg-gray-200 rounded w-48 mb-2"}),S.jsx("div",{className:"h-4 bg-gray-100 rounded w-32"})]}),S.jsx("div",{className:"h-8 bg-gray-200 rounded w-24"})]},p))}):S.jsx("ul",{className:"divide-y divide-gray-200",children:o.length>0?o.map(p=>S.jsxs("li",{className:"px-6 py-4 flex items-center justify-between hover:bg-gray-50 transition-colors",children:[S.jsxs("div",{children:[S.jsx("h4",{className:"text-lg font-medium text-gray-900",children:p.name}),S.jsxs("p",{className:"text-sm text-gray-500",children:[p.documentCount," documents • ",p.size]})]}),S.jsxs("div",{className:"flex space-x-2",children:[S.jsx("button",{className:"text-blue-600 hover:text-blue-800 px-3 py-1 rounded border border-blue-200 hover:border-blue-400 transition-colors",children:"View Documents"}),S.jsx("button",{className:"text-red-600 hover:text-red-800 px-3 py-1 rounded border border-red-200 hover:border-red-400 transition-colors",children:"Delete"})]})]},p.name)):S.jsx("li",{className:"px-6 py-8 text-center text-gray-500",children:'No collections found in this database. Click "Create Collection" to add one.'})})]})]})};function Sb(){const{loadKey:u}=$a(r=>r),[c,s]=R.useState(!0);return R.useEffect(()=>{Ze(null,null,function*(){try{yield u()}finally{s(!1)}})},[u]),c?S.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:S.jsxs("div",{className:"text-center",children:[S.jsx("div",{className:"spinner-border text-primary mb-3",role:"status",children:S.jsx("span",{className:"sr-only",children:"Loading..."})}),S.jsx("p",{className:"text-gray-600",children:"Loading application..."})]})}):S.jsx(tp,{children:S.jsxs("div",{className:"min-h-screen bg-gray-50 flex flex-col",children:[S.jsx(K1,{}),S.jsx("main",{className:"flex-grow",children:S.jsxs(_v,{children:[S.jsx(Ni,{path:"/",element:S.jsx(mb,{})}),S.jsx(Ni,{path:"/databases",element:S.jsx(pb,{})}),S.jsx(Ni,{path:"/collections",element:S.jsx(bb,{})})]})}),S.jsx(dp,{})]})})}qg.createRoot(document.getElementById("root")).render(S.jsx(R.StrictMode,{children:S.jsx(Sb,{})}))});export default xb();
|
|
56
|
+
`+d):r.stack=d}catch(m){}}throw r}})}_request(c,s){typeof c=="string"?(s=s||{},s.url=c):s=c||{},s=la(this.defaults,s);const{transitional:r,paramsSerializer:o,headers:d}=s;r!==void 0&&Mi.assertOptions(r,{silentJSONParsing:Gt.transitional(Gt.boolean),forcedJSONParsing:Gt.transitional(Gt.boolean),clarifyTimeoutError:Gt.transitional(Gt.boolean)},!1),o!=null&&(M.isFunction(o)?s.paramsSerializer={serialize:o}:Mi.assertOptions(o,{encode:Gt.function,serialize:Gt.function},!0)),s.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?s.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:s.allowAbsoluteUrls=!0),Mi.assertOptions(s,{baseUrl:Gt.spelling("baseURL"),withXsrfToken:Gt.spelling("withXSRFToken")},!0),s.method=(s.method||this.defaults.method||"get").toLowerCase();let m=d&&M.merge(d.common,d[s.method]);d&&M.forEach(["delete","get","head","post","put","patch","common"],C=>{delete d[C]}),s.headers=ct.concat(m,d);const v=[];let g=!0;this.interceptors.request.forEach(function(z){typeof z.runWhen=="function"&&z.runWhen(s)===!1||(g=g&&z.synchronous,v.unshift(z.fulfilled,z.rejected))});const y=[];this.interceptors.response.forEach(function(z){y.push(z.fulfilled,z.rejected)});let p,N=0,D;if(!g){const C=[sm.bind(this),void 0];for(C.unshift(...v),C.push(...y),D=C.length,p=Promise.resolve(s);N<D;)p=p.then(C[N++],C[N++]);return p}D=v.length;let Y=s;for(N=0;N<D;){const C=v[N++],z=v[N++];try{Y=C(Y)}catch(j){z.call(this,j);break}}try{p=sm.call(this,Y)}catch(C){return Promise.reject(C)}for(N=0,D=y.length;N<D;)p=p.then(y[N++],y[N++]);return p}getUri(c){c=la(this.defaults,c);const s=Km(c.baseURL,c.url,c.allowAbsoluteUrls);return Gm(s,c.params,c.paramsSerializer)}};M.forEach(["delete","get","head","options"],function(c){ta.prototype[c]=function(s,r){return this.request(la(r||{},{method:c,url:s,data:(r||{}).data}))}});M.forEach(["post","put","patch"],function(c){function s(r){return function(d,m,v){return this.request(la(v||{},{method:c,headers:r?{"Content-Type":"multipart/form-data"}:{},url:d,data:m}))}}ta.prototype[c]=s(),ta.prototype[c+"Form"]=s(!0)});let Y1=class Pm{constructor(c){if(typeof c!="function")throw new TypeError("executor must be a function.");let s;this.promise=new Promise(function(d){s=d});const r=this;this.promise.then(o=>{if(!r._listeners)return;let d=r._listeners.length;for(;d-- >0;)r._listeners[d](o);r._listeners=null}),this.promise.then=o=>{let d;const m=new Promise(v=>{r.subscribe(v),d=v}).then(o);return m.cancel=function(){r.unsubscribe(d)},m},c(function(d,m,v){r.reason||(r.reason=new ka(d,m,v),s(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(c){if(this.reason){c(this.reason);return}this._listeners?this._listeners.push(c):this._listeners=[c]}unsubscribe(c){if(!this._listeners)return;const s=this._listeners.indexOf(c);s!==-1&&this._listeners.splice(s,1)}toAbortSignal(){const c=new AbortController,s=r=>{c.abort(r)};return this.subscribe(s),c.signal.unsubscribe=()=>this.unsubscribe(s),c.signal}static source(){let c;return{token:new Pm(function(o){c=o}),cancel:c}}};function G1(u){return function(s){return u.apply(null,s)}}function X1(u){return M.isObject(u)&&u.isAxiosError===!0}const Ns={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ns).forEach(([u,c])=>{Ns[c]=u});function Im(u){const c=new ta(u),s=wm(ta.prototype.request,c);return M.extend(s,ta.prototype,c,{allOwnKeys:!0}),M.extend(s,c,null,{allOwnKeys:!0}),s.create=function(o){return Im(la(u,o))},s}const Ae=Im(ru);Ae.Axios=ta;Ae.CanceledError=ka;Ae.CancelToken=Y1;Ae.isCancel=Qm;Ae.VERSION=Wm;Ae.toFormData=Xi;Ae.AxiosError=ae;Ae.Cancel=Ae.CanceledError;Ae.all=function(c){return Promise.all(c)};Ae.spread=G1;Ae.isAxiosError=X1;Ae.mergeConfig=la;Ae.AxiosHeaders=ct;Ae.formToJSON=u=>Vm(M.isHTMLForm(u)?new FormData(u):u);Ae.getAdapter=Fm.getAdapter;Ae.HttpStatusCode=Ns;Ae.default=Ae;const{Axios:Ab,AxiosError:Ob,CanceledError:Nb,isCancel:Db,CancelToken:wb,VERSION:_b,all:Cb,Cancel:Mb,isAxiosError:jb,spread:zb,toFormData:Ub,AxiosHeaders:Bb,HttpStatusCode:Hb,formToJSON:Lb,getAdapter:qb,mergeConfig:Yb}=Ae,fm=u=>{let c;const s=new Set,r=(y,p)=>{const N=typeof y=="function"?y(c):y;if(!Object.is(N,c)){const D=c;c=(p!=null?p:typeof N!="object"||N===null)?N:Object.assign({},c,N),s.forEach(Y=>Y(c,D))}},o=()=>c,v={setState:r,getState:o,getInitialState:()=>g,subscribe:y=>(s.add(y),()=>s.delete(y))},g=c=u(r,o,v);return v},V1=u=>u?fm(u):fm,Q1=u=>u;function Z1(u,c=Q1){const s=qh.useSyncExternalStore(u.subscribe,()=>c(u.getState()),()=>c(u.getInitialState()));return qh.useDebugValue(s),s}const dm=u=>{const c=V1(u),s=r=>Z1(c,r);return Object.assign(s,c),s},e0=u=>u?dm(u):dm,su=window.location.origin,tu=e0(u=>({Rootname:"",setRootname:c=>u({Rootname:c})})),$a=e0(u=>({TransactionKey:"",setTransactionKey:c=>u({TransactionKey:c}),loadKey:()=>Ze(null,null,function*(){yield Ae.get(`${su}/api/get-token`).then(c=>{var s,r;c.status===200&&u({TransactionKey:(r=(s=c.data)==null?void 0:s.data)==null?void 0:r.originSessionKey})}).catch(c=>{console.error("Error fetching transaction key:",c)})})})),K1=()=>{const[u,c]=R.useState(!1),{Rootname:s}=tu(r=>r);return S.jsx("header",{className:"bg-gradient-to-r from-blue-700 to-indigo-800 shadow-lg",children:S.jsx("nav",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:S.jsx("div",{className:"flex items-center justify-between h-16",children:S.jsxs("div",{className:"flex items-center",children:[S.jsx("div",{className:"flex-shrink-0",children:S.jsxs(Qa,{to:"/",className:"flex items-center",children:[S.jsx("img",{src:"/AXioDB.png",alt:"AxioDB Logo",className:"h-9 w-9"}),S.jsxs("span",{className:"ml-2 text-white font-bold text-xl tracking-tight",children:[s," Admin Hub"]})]})}),S.jsx("div",{className:"hidden md:block ml-10",children:S.jsxs("div",{className:"flex space-x-4",children:[S.jsx(Qa,{to:"/",className:"text-blue-100 hover:bg-blue-600 hover:text-white px-3 py-2 rounded-md text-sm font-medium transition-colors",children:"Dashboard"}),S.jsx(Qa,{to:"/databases",className:"text-blue-100 hover:bg-blue-600 hover:text-white px-3 py-2 rounded-md text-sm font-medium transition-colors",children:"Databases"}),S.jsx(Qa,{to:"/queries",className:"text-blue-100 hover:bg-blue-600 hover:text-white px-3 py-2 rounded-md text-sm font-medium transition-colors",children:"Queries"})]})})]})})})})};function J1(u,c){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:c},u),R.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 3v2m6-2v2M9 19v2m6-2v2M5 9H3m2 6H3m18-6h-2m2 6h-2M7 19h10a2 2 0 002-2V7a2 2 0 00-2-2H7a2 2 0 00-2 2v10a2 2 0 002 2zM9 9h6v6H9V9z"}))}const k1=R.forwardRef(J1);function $1(u,c){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:c},u),R.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"}))}const F1=R.forwardRef($1);function W1(u,c){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:c},u),R.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M4 7v10c0 2.21 3.582 4 8 4s8-1.79 8-4V7M4 7c0 2.21 3.582 4 8 4s8-1.79 8-4M4 7c0-2.21 3.582-4 8-4s8 1.79 8 4m0 5c0 2.21-3.582 4-8 4s-8-1.79-8-4"}))}const t0=R.forwardRef(W1);function P1(u,c){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:c},u),R.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"}))}const I1=R.forwardRef(P1);function eb(u,c){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:c},u),R.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M3 7v10a2 2 0 002 2h14a2 2 0 002-2V9a2 2 0 00-2-2h-6l-2-2H5a2 2 0 00-2 2z"}))}const tb=R.forwardRef(eb);function lb(u,c){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor","aria-hidden":"true",ref:c},u),R.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M5 12h14M5 12a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v4a2 2 0 01-2 2M5 12a2 2 0 00-2 2v4a2 2 0 002 2h14a2 2 0 002-2v-4a2 2 0 00-2-2m-2-4h.01M17 16h.01"}))}const ab=R.forwardRef(lb);function nb(u,c){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:c},u),R.createElement("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"}))}const ub=R.forwardRef(nb);function ib(u,c){return R.createElement("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",ref:c},u),R.createElement("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"}))}const cb=R.forwardRef(ib),rb=()=>{const[u,c]=R.useState(!0),[s,r]=R.useState({}),[o,d]=R.useState([]),m=g=>{r(y=>bt(Se({},y),{[g]:!y[g]}))};R.useEffect(()=>{(()=>{setTimeout(()=>{const y=[{id:"db1",name:"UsersDB",type:"database",children:[{id:"db1_col1",name:"accounts",type:"collection",documentCount:1250,size:"2.3 MB"},{id:"db1_col2",name:"profiles",type:"collection",documentCount:1200,size:"4.1 MB"},{id:"db1_col3",name:"sessions",type:"collection",documentCount:5400,size:"1.8 MB"}]},{id:"db2",name:"ProductsDB",type:"database",children:[{id:"db2_col1",name:"inventory",type:"collection",documentCount:850,size:"3.2 MB"},{id:"db2_col2",name:"categories",type:"collection",documentCount:45,size:"0.3 MB"},{id:"db2_col3",name:"suppliers",type:"collection",documentCount:120,size:"0.7 MB"}]},{id:"db3",name:"AnalyticsDB",type:"database",children:[{id:"db3_col1",name:"events",type:"collection",documentCount:4250,size:"8.5 MB"},{id:"db3_col2",name:"metrics",type:"collection",documentCount:1850,size:"4.2 MB"},{id:"db3_col3",name:"reports",type:"collection",documentCount:320,size:"1.5 MB"}]}];r({db1:!0}),d(y),c(!1)},1e3)})()},[]);const v=g=>{const y=s[g.id];return S.jsxs("div",{children:[S.jsxs("div",{className:`flex items-center py-2 px-3 ${g.type==="database"?"bg-blue-50 hover:bg-blue-100 border-b border-blue-100":"hover:bg-gray-50 pl-10"} cursor-pointer transition-colors`,onClick:()=>g.children&&m(g.id),children:[g.children?S.jsx("div",{className:"mr-1",children:y?S.jsx(ub,{className:"h-4 w-4 text-gray-500"}):S.jsx(cb,{className:"h-4 w-4 text-gray-500"})}):S.jsx("div",{className:"w-4 mr-1"}),g.type==="database"?S.jsx(t0,{className:"h-5 w-5 text-blue-600 mr-2"}):S.jsx(tb,{className:"h-5 w-5 text-yellow-600 mr-2"}),S.jsx("div",{className:"flex-grow",children:S.jsx("span",{className:"font-medium",children:g.name})}),g.type==="collection"&&S.jsxs("div",{className:"text-xs text-gray-500",children:[S.jsxs("span",{className:"mr-2",children:[g.documentCount," docs"]}),S.jsx("span",{children:g.size})]})]}),g.children&&y&&S.jsx("div",{className:"border-l border-gray-200 ml-5",children:g.children.map(v)})]},g.id)};return S.jsxs("div",{className:"bg-white rounded-lg shadow-md hover:shadow-lg transition-shadow",children:[S.jsxs("div",{className:"border-b border-gray-200 py-4 px-6",children:[S.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Database Structure"}),S.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Overview of databases and collections"})]}),S.jsx("div",{className:"overflow-y-auto",style:{maxHeight:"400px"},children:u?S.jsx("div",{className:"p-6 space-y-3",children:[1,2,3].map(g=>S.jsxs("div",{className:"animate-pulse",children:[S.jsx("div",{className:"h-6 bg-gray-200 rounded w-3/4 mb-2"}),S.jsxs("div",{className:"pl-6 space-y-2",children:[S.jsx("div",{className:"h-5 bg-gray-100 rounded w-2/3"}),S.jsx("div",{className:"h-5 bg-gray-100 rounded w-2/3"}),S.jsx("div",{className:"h-5 bg-gray-100 rounded w-2/3"})]})]},g))}):S.jsx("div",{children:o.map(v)})})]})},sb=()=>{const[u,c]=R.useState(0),[s,r]=R.useState(0),[o,d]=R.useState(!0);R.useEffect(()=>{(()=>{setTimeout(()=>{c(512),r(1024),d(!1)},800)})()},[]);const m=u/s*100;return S.jsxs("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:[S.jsxs("div",{className:"flex justify-between mb-3",children:[S.jsxs("div",{children:[S.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"In-Memory Cache"}),o?S.jsx("div",{className:"h-8 mt-2 bg-gray-200 rounded animate-pulse w-24"}):S.jsxs("p",{className:"text-3xl font-bold text-orange-600 mt-2",children:[u," ",S.jsx("span",{className:"text-lg",children:"MB"})]}),S.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["of ",s," MB allocated"]})]}),S.jsx("div",{className:"p-3 bg-orange-100 rounded-full",children:S.jsx(k1,{className:"h-8 w-8 text-orange-600"})})]}),S.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2.5 mt-2",children:S.jsx("div",{className:"bg-orange-600 h-2.5 rounded-full",style:{width:`${o?0:m}%`}})})]})},ob=()=>{const[u,c]=R.useState(0),[s,r]=R.useState(0),[o,d]=R.useState(!0);R.useEffect(()=>{(()=>{setTimeout(()=>{c(2.7),r(10),d(!1)},800)})()},[]);const m=u/s*100;return S.jsxs("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:[S.jsxs("div",{className:"flex justify-between mb-3",children:[S.jsxs("div",{children:[S.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Storage Used"}),o?S.jsx("div",{className:"h-8 mt-2 bg-gray-200 rounded animate-pulse w-24"}):S.jsxs("p",{className:"text-3xl font-bold text-green-600 mt-2",children:[u," ",S.jsx("span",{className:"text-lg",children:"GB"})]}),S.jsxs("p",{className:"text-sm text-gray-500 mt-1",children:["of ",s," GB available"]})]}),S.jsx("div",{className:"p-3 bg-green-100 rounded-full",children:S.jsx(ab,{className:"h-8 w-8 text-green-600"})})]}),S.jsx("div",{className:"w-full bg-gray-200 rounded-full h-2.5 mt-2",children:S.jsx("div",{className:"bg-green-600 h-2.5 rounded-full",style:{width:`${o?0:m}%`}})})]})},fb=()=>{const[u,c]=R.useState(0),[s,r]=R.useState(!0);return R.useEffect(()=>{(()=>{setTimeout(()=>{c(67),r(!1)},600)})()},[]),S.jsx("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:S.jsxs("div",{className:"flex justify-between",children:[S.jsxs("div",{children:[S.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Total Collections"}),s?S.jsx("div",{className:"h-8 mt-2 bg-gray-200 rounded animate-pulse w-16"}):S.jsx("p",{className:"text-3xl font-bold text-indigo-600 mt-2",children:u}),S.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Across all databases"})]}),S.jsx("div",{className:"p-3 bg-indigo-100 rounded-full",children:S.jsx(F1,{className:"h-8 w-8 text-indigo-600"})})]})})},db=({totalDatabases:u})=>{const[c,s]=R.useState(!0);return R.useEffect(()=>{setTimeout(()=>{s(!1)},1e3)},[]),S.jsx("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:S.jsxs("div",{className:"flex justify-between",children:[S.jsxs("div",{children:[S.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Total Databases"}),c?S.jsx("div",{className:"h-8 mt-2 bg-gray-200 rounded animate-pulse w-16"}):S.jsx("p",{className:"text-3xl font-bold text-blue-600 mt-2",children:u}),S.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Across all instances"})]}),S.jsx("div",{className:"p-3 bg-blue-100 rounded-full",children:S.jsx(t0,{className:"h-8 w-8 text-blue-600"})})]})})},hb=()=>{const[u,c]=R.useState(0),[s,r]=R.useState(!0);return R.useEffect(()=>{(()=>{setTimeout(()=>{c(14825),r(!1)},700)})()},[]),S.jsx("div",{className:"bg-white rounded-lg shadow-md p-6 hover:shadow-lg transition-shadow",children:S.jsxs("div",{className:"flex justify-between",children:[S.jsxs("div",{children:[S.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Total Documents"}),s?S.jsx("div",{className:"h-8 mt-2 bg-gray-200 rounded animate-pulse w-20"}):S.jsx("p",{className:"text-3xl font-bold text-purple-600 mt-2",children:u.toLocaleString()}),S.jsx("p",{className:"text-sm text-gray-500 mt-1",children:"Across all collections"})]}),S.jsx("div",{className:"p-3 bg-purple-100 rounded-full",children:S.jsx(I1,{className:"h-8 w-8 text-purple-600"})})]})})},mb=()=>{const[u,c]=R.useState(!0),[s,r]=R.useState(null),{setRootname:o}=tu(v=>v),{TransactionKey:d}=$a(v=>v),{Rootname:m}=tu(v=>v);return R.useEffect(()=>{Ae.get(`${su}/api/db/databases?transactiontoken=${d}`).then(v=>{var g;v.status===200&&(console.log("All Instance Info:",v.data.data),r(v.data.data),o((g=v.data.data.RootName)!=null?g:"AxioDB"),c(!1))})},[]),S.jsxs("div",{className:"container mx-auto px-4 py-6",children:[S.jsxs("div",{className:"mb-6",children:[S.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Dashboard"}),S.jsxs("p",{className:"text-gray-600",children:["Welcome to ",m," Management Console"]})]}),u?S.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-6 mb-8",children:[1,2,3,4,5].map(v=>S.jsx("div",{className:"h-32 bg-gray-200 rounded-lg animate-pulse"},v))}):S.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-6 mb-8",children:[S.jsx(db,{totalDatabases:(s==null?void 0:s.ListOfDatabases.length)||0}),S.jsx(fb,{}),S.jsx(hb,{}),S.jsx(ob,{}),S.jsx(sb,{})]}),S.jsx("div",{className:"mb-8",children:S.jsx(rb,{})})]})},yb=({isOpen:u,onClose:c,onDatabaseCreated:s})=>{const[r,o]=R.useState(""),[d,m]=R.useState(!1),[v,g]=R.useState(""),{TransactionKey:y}=$a(D=>D),p=()=>{o(""),g(""),m(!1),c()},N=D=>Ze(null,null,function*(){var Y,C;if(D.preventDefault(),!r.trim()){g("Database name is required");return}if(!/^[a-zA-Z0-9_]+$/.test(r)){g("Database name can only contain letters, numbers, and underscores");return}m(!0),g("");try{const z=yield Ae.post(`${su}/api/db/create-database`,{name:r},{params:{transactiontoken:y}});if(z.data.statusCode===200||z.data.statusCode===201)s(r),m(!1),p();else throw m(!1),new Error("Failed to create database")}catch(z){console.error("Error creating database:",z),g(((C=(Y=z.response)==null?void 0:Y.data)==null?void 0:C.message)||"Failed to create database. Please try again."),m(!1)}});return u?S.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 animate-fadeIn",children:S.jsxs("div",{className:"bg-white rounded-lg max-w-md w-full p-6",children:[S.jsx("h3",{className:"text-xl font-bold text-gray-900 mb-4",children:"Create New Database"}),S.jsxs("form",{onSubmit:N,children:[S.jsxs("div",{className:"mb-4",children:[S.jsx("label",{htmlFor:"databaseName",className:"block text-sm font-medium text-gray-700 mb-1",children:"Database Name"}),S.jsx("input",{type:"text",id:"databaseName",value:r,onChange:D=>o(D.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",placeholder:"Enter database name",disabled:d}),v&&S.jsx("p",{className:"mt-2 text-sm text-red-600",children:v})]}),S.jsxs("div",{className:"flex justify-end space-x-4 mt-6",children:[S.jsx("button",{type:"button",onClick:p,className:"px-4 py-2 text-gray-700 hover:text-gray-900 transition-colors",disabled:d,children:"Cancel"}),S.jsx("button",{type:"submit",className:`px-4 py-2 bg-green-600 text-white rounded hover:bg-green-700 transition-colors flex items-center ${d?"opacity-75 cursor-not-allowed":""}`,disabled:d,children:d?S.jsxs(S.Fragment,{children:[S.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[S.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),S.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Creating..."]}):"Create Database"})]})]})]})}):null},gb=({isOpen:u,dbName:c,onClose:s,onConfirmDelete:r})=>{const{TransactionKey:o}=$a(g=>g),[d,m]=R.useState(!1);if(!u)return null;const v=()=>Ze(null,null,function*(){var g,y;m(!0);try{const p=yield Ae.delete(`${su}/api/db/delete-database`,{params:{transactiontoken:o,dbName:c}});if(p.status===200)console.log("Database deleted successfully:",p.data),r();else throw new Error("Failed to delete database")}catch(p){console.error("Error deleting database:",p),alert(((y=(g=p.response)==null?void 0:g.data)==null?void 0:y.message)||"Failed to delete database. Please try again.")}finally{m(!1)}});return S.jsx("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:S.jsxs("div",{className:"bg-white rounded-lg max-w-md w-full p-6 animate-fadeIn",children:[S.jsx("h3",{className:"text-xl font-bold text-gray-900 mb-4",children:"Confirm Deletion"}),S.jsxs("p",{className:"text-gray-700 mb-6",children:['Are you sure you want to delete the database "',c,'"? This action cannot be undone.']}),S.jsxs("div",{className:"flex justify-end space-x-4",children:[S.jsx("button",{onClick:s,disabled:d,className:"px-4 py-2 text-gray-700 hover:text-gray-900 transition-colors",children:"Cancel"}),S.jsx("button",{onClick:v,disabled:d,className:`px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700 transition-colors flex items-center ${d?"opacity-75 cursor-not-allowed":""}`,children:d?S.jsxs(S.Fragment,{children:[S.jsxs("svg",{className:"animate-spin -ml-1 mr-2 h-4 w-4 text-white",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[S.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),S.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"})]}),"Deleting..."]}):"Delete"})]})]})})},vb=({databases:u,onDeleteClick:c,loading:s})=>{const r=Hi(),[o,d]=R.useState({}),m=g=>{d(y=>bt(Se({},y),{[g]:!1}))},v=g=>{r(`/collections?database=${encodeURIComponent(g)}`)};return S.jsxs("div",{className:"bg-white rounded-lg shadow-md overflow-hidden",children:[S.jsxs("div",{className:"border-b border-gray-200 bg-gray-50 px-6 py-4",children:[S.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"Your Databases"}),S.jsxs("p",{className:"text-sm text-gray-500",children:["Total: ",s?"Loading...":u==null?void 0:u.TotalDatabases]})]}),s?S.jsx("div",{className:"p-6",children:[1,2,3].map(g=>S.jsxs("div",{className:"animate-pulse flex items-center justify-between py-4 border-b border-gray-100",children:[S.jsxs("div",{children:[S.jsx("div",{className:"h-6 bg-gray-200 rounded w-48 mb-2"}),S.jsx("div",{className:"h-4 bg-gray-100 rounded w-32"})]}),S.jsx("div",{className:"h-8 bg-gray-200 rounded w-24"})]},g))}):S.jsx("ul",{className:"divide-y divide-gray-200",children:u!=null&&u.ListOfDatabases&&(u==null?void 0:u.ListOfDatabases.length)>0?u.ListOfDatabases.map((g,y)=>S.jsxs("li",{className:`px-6 py-4 flex items-center justify-between hover:bg-gray-50 transition-all duration-300 ${o[g]?"animate-slideIn":"animate-fadeIn"}`,onAnimationEnd:()=>m(g),children:[S.jsxs("div",{children:[S.jsx("h4",{className:"text-lg font-medium text-gray-900",children:g}),S.jsxs("p",{className:"text-sm text-gray-500",children:["Path: ",u.AllDatabasesPaths[y]]})]}),S.jsxs("div",{className:"flex space-x-2",children:[S.jsx("button",{onClick:()=>v(g),className:"text-blue-600 hover:text-blue-800 px-3 py-1 rounded border border-blue-200 hover:border-blue-400 transition-colors",children:"View Collections"}),S.jsx("button",{onClick:()=>c(g),className:"text-red-600 hover:text-red-800 px-3 py-1 rounded border border-red-200 hover:border-red-400 transition-colors",children:"Delete"})]})]},g)):S.jsx("li",{className:"px-6 py-8 text-center text-gray-500",children:'No databases found. Click "Create Database" to add one.'})})]})},pb=()=>{const[u,c]=R.useState(!0),[s,r]=R.useState([]),[o,d]=R.useState(!1),[m,v]=R.useState(!1),[g,y]=R.useState(""),{TransactionKey:p}=$a(z=>z),{Rootname:N}=tu(z=>z);R.useEffect(()=>{p&&Ze(null,null,function*(){try{const j=yield Ae.get(`${su}/api/db/databases?transactiontoken=${p}`);j.status===200&&(r(j.data.data),c(!1))}catch(j){console.error("Error fetching databases:",j),c(!1),r([])}})},[p]);const D=z=>{y(z),d(!0)},Y=()=>{r(z=>bt(Se({},z),{ListOfDatabases:z.ListOfDatabases.filter(j=>j!==g),TotalDatabases:`${z.ListOfDatabases.length-1} Databases`})),d(!1),y("")},C=z=>{r(j=>bt(Se({},j),{ListOfDatabases:[...j.ListOfDatabases,z],TotalDatabases:`${j.ListOfDatabases.length+1} Databases`,AllDatabasesPaths:[...j.AllDatabasesPaths,`${j.CurrentPath}/${z}`]}))};return S.jsxs("div",{className:"container mx-auto px-4 py-6",children:[S.jsxs("div",{className:"flex justify-between items-center mb-6",children:[S.jsxs("div",{children:[S.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Databases"}),S.jsxs("p",{className:"text-gray-600",children:["Manage your ",N," databases"]})]}),S.jsxs("button",{onClick:()=>v(!0),className:"bg-green-600 hover:bg-green-700 text-white py-2 px-4 rounded-lg flex items-center transition-colors",children:[S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 mr-2",viewBox:"0 0 20 20",fill:"currentColor",children:S.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})}),"Create Database"]})]}),S.jsx(vb,{databases:s,onDeleteClick:D,loading:u}),S.jsx(yb,{isOpen:m,onClose:()=>v(!1),onDatabaseCreated:C}),S.jsx(gb,{isOpen:o,dbName:g,onClose:()=>d(!1),onConfirmDelete:Y})]})},bb=()=>{const[u]=ip(),c=Hi(),[s,r]=R.useState(!0),[o,d]=R.useState([]),m=u.get("database"),{TransactionKey:v}=$a(p=>p),{Rootname:g}=tu(p=>p);R.useEffect(()=>{if(!m){c("/databases");return}v&&Ze(null,null,function*(){try{setTimeout(()=>{d([{name:"users",documentCount:1250,size:"2.3 MB"},{name:"orders",documentCount:850,size:"1.8 MB"},{name:"products",documentCount:420,size:"3.1 MB"}]),r(!1)},1e3)}catch(N){console.error("Error fetching collections:",N),r(!1),d([])}})},[v,m,c]);const y=()=>{c("/databases")};return S.jsxs("div",{className:"container mx-auto px-4 py-6",children:[S.jsxs("div",{className:"flex justify-between items-center mb-6",children:[S.jsxs("div",{children:[S.jsx("div",{className:"flex items-center mb-2",children:S.jsx("button",{onClick:y,className:"text-blue-600 hover:text-blue-800 mr-3",children:"← Back to Databases"})}),S.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Collections"}),S.jsxs("p",{className:"text-gray-600",children:["Collections in database:"," ",S.jsx("span",{className:"font-medium",children:m})]})]}),S.jsxs("button",{className:"bg-green-600 hover:bg-green-700 text-white py-2 px-4 rounded-lg flex items-center transition-colors",children:[S.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-5 w-5 mr-2",viewBox:"0 0 20 20",fill:"currentColor",children:S.jsx("path",{fillRule:"evenodd",d:"M10 3a1 1 0 011 1v5h5a1 1 0 110 2h-5v5a1 1 0 11-2 0v-5H4a1 1 0 110-2h5V4a1 1 0 011-1z",clipRule:"evenodd"})}),"Create Collection"]})]}),S.jsxs("div",{className:"bg-white rounded-lg shadow-md overflow-hidden",children:[S.jsxs("div",{className:"border-b border-gray-200 bg-gray-50 px-6 py-4",children:[S.jsxs("h3",{className:"text-lg font-medium text-gray-900",children:["Collections in ",m]}),S.jsxs("p",{className:"text-sm text-gray-500",children:["Total:"," ",s?"Loading...":`${o.length} Collections`]})]}),s?S.jsx("div",{className:"p-6",children:[1,2,3].map(p=>S.jsxs("div",{className:"animate-pulse flex items-center justify-between py-4 border-b border-gray-100",children:[S.jsxs("div",{children:[S.jsx("div",{className:"h-6 bg-gray-200 rounded w-48 mb-2"}),S.jsx("div",{className:"h-4 bg-gray-100 rounded w-32"})]}),S.jsx("div",{className:"h-8 bg-gray-200 rounded w-24"})]},p))}):S.jsx("ul",{className:"divide-y divide-gray-200",children:o.length>0?o.map(p=>S.jsxs("li",{className:"px-6 py-4 flex items-center justify-between hover:bg-gray-50 transition-colors",children:[S.jsxs("div",{children:[S.jsx("h4",{className:"text-lg font-medium text-gray-900",children:p.name}),S.jsxs("p",{className:"text-sm text-gray-500",children:[p.documentCount," documents • ",p.size]})]}),S.jsxs("div",{className:"flex space-x-2",children:[S.jsx("button",{className:"text-blue-600 hover:text-blue-800 px-3 py-1 rounded border border-blue-200 hover:border-blue-400 transition-colors",children:"View Documents"}),S.jsx("button",{className:"text-red-600 hover:text-red-800 px-3 py-1 rounded border border-red-200 hover:border-red-400 transition-colors",children:"Delete"})]})]},p.name)):S.jsx("li",{className:"px-6 py-8 text-center text-gray-500",children:'No collections found in this database. Click "Create Collection" to add one.'})})]})]})};function Sb(){const{loadKey:u}=$a(r=>r),[c,s]=R.useState(!0);return R.useEffect(()=>{Ze(null,null,function*(){try{yield u()}finally{s(!1)}})},[u]),c?S.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:S.jsxs("div",{className:"text-center",children:[S.jsx("div",{className:"spinner-border text-primary mb-3",role:"status",children:S.jsx("span",{className:"sr-only",children:"Loading..."})}),S.jsx("p",{className:"text-gray-600",children:"Loading application..."})]})}):S.jsx(tp,{children:S.jsxs("div",{className:"min-h-screen bg-gray-50 flex flex-col",children:[S.jsx(K1,{}),S.jsx("main",{className:"flex-grow",children:S.jsxs(_v,{children:[S.jsx(Ni,{path:"/",element:S.jsx(mb,{})}),S.jsx(Ni,{path:"/databases",element:S.jsx(pb,{})}),S.jsx(Ni,{path:"/collections",element:S.jsx(bb,{})})]})}),S.jsx(dp,{})]})})}qg.createRoot(document.getElementById("root")).render(S.jsx(R.StrictMode,{children:S.jsx(Sb,{})}))});export default xb();
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
<meta name="twitter:card" content="summary_large_image" />
|
|
26
26
|
<link rel="canonical" href="https://axiodb.site" />
|
|
27
27
|
<link rel="icon" type="image/svg+xml" href="AXioDB.png" />
|
|
28
|
-
<script type="module" crossorigin src="/assets/index-
|
|
28
|
+
<script type="module" crossorigin src="/assets/index-BpapO_fH.js"></script>
|
|
29
29
|
<link rel="stylesheet" crossorigin href="/assets/index-BHqXlmHD.css">
|
|
30
30
|
<link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
|
|
31
31
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(n,r)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(s[t])return;let o={};const l=e=>i(e,t),c={module:{uri:t},exports:o,require:l};s[t]=Promise.all(n.map(e=>c[e]||l(e))).then(e=>(r(...e),o))}}define(["./workbox-5ffe50d4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"assets/index-BHqXlmHD.css",revision:null},{url:"assets/index-
|
|
1
|
+
if(!self.define){let e,s={};const i=(i,n)=>(i=new URL(i+".js",n).href,s[i]||new Promise(s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()}).then(()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e}));self.define=(n,r)=>{const t=e||("document"in self?document.currentScript.src:"")||location.href;if(s[t])return;let o={};const l=e=>i(e,t),c={module:{uri:t},exports:o,require:l};s[t]=Promise.all(n.map(e=>c[e]||l(e))).then(e=>(r(...e),o))}}define(["./workbox-5ffe50d4"],function(e){"use strict";self.skipWaiting(),e.clientsClaim(),e.precacheAndRoute([{url:"assets/index-BHqXlmHD.css",revision:null},{url:"assets/index-BpapO_fH.js",revision:null},{url:"index.html",revision:"89b209245f3521ad54659d5a95709c1b"},{url:"registerSW.js",revision:"1872c500de691dce40960bb85481de07"},{url:"manifest.webmanifest",revision:"531c27931688c6a365595ec1badc959b"}],{}),e.cleanupOutdatedCaches(),e.registerRoute(new e.NavigationRoute(e.createHandlerBoundToURL("index.html")))});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axiodb",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.71",
|
|
4
4
|
"description": "A blazing-fast, lightweight, and scalable nodejs package based DBMS for modern application. Supports schemas, encryption, and advanced query capabilities.",
|
|
5
5
|
"main": "./lib/config/DB.js",
|
|
6
6
|
"types": "./lib/config/DB.d.ts",
|