axiodb 2.22.71 → 2.24.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 +29 -1
- package/lib/Services/Database/database.operation.js +80 -14
- package/lib/Services/Database/database.operation.js.map +1 -1
- package/lib/config/Interfaces/Operation/database.operation.interface.d.ts +1 -1
- package/lib/server/config/keys.d.ts +9 -9
- package/lib/server/config/keys.js +79 -33
- package/lib/server/config/keys.js.map +1 -1
- package/lib/server/controller/Collections/Collection.controller.d.ts +33 -0
- package/lib/server/controller/Collections/Collection.controller.js +90 -1
- package/lib/server/controller/Collections/Collection.controller.js.map +1 -1
- package/lib/server/helper/filesCounterInFolder.helper.d.ts +16 -0
- package/lib/server/helper/filesCounterInFolder.helper.js +49 -0
- package/lib/server/helper/filesCounterInFolder.helper.js.map +1 -0
- package/lib/server/public/AxioControl/.vite/manifest.json +2 -2
- package/lib/server/public/AxioControl/.vite/ssr-manifest.json +2 -0
- package/lib/server/public/AxioControl/assets/index--rWHSvem.css +1 -0
- package/lib/server/public/AxioControl/assets/index-1QePTOyA.js +56 -0
- package/lib/server/public/AxioControl/index.html +2 -2
- package/lib/server/public/AxioControl/sw.js +1 -1
- package/lib/server/router/Router.js +6 -0
- package/lib/server/router/Router.js.map +1 -1
- package/lib/server/router/Routers/Collection.routes.d.ts +7 -0
- package/lib/server/router/Routers/Collection.routes.js +29 -0
- package/lib/server/router/Routers/Collection.routes.js.map +1 -0
- package/package.json +1 -1
- package/lib/server/public/AxioControl/assets/index-BHqXlmHD.css +0 -1
- package/lib/server/public/AxioControl/assets/index-BpapO_fH.js +0 -56
|
@@ -9,7 +9,6 @@ export default class Database {
|
|
|
9
9
|
private fileManager;
|
|
10
10
|
private folderManager;
|
|
11
11
|
private ResponseHelper;
|
|
12
|
-
private collectionMap;
|
|
13
12
|
constructor(name: string, path: string);
|
|
14
13
|
/**
|
|
15
14
|
* Creates a new collection inside the specified database.
|
|
@@ -40,4 +39,33 @@ export default class Database {
|
|
|
40
39
|
* @throws {Error} - Throws an error if the database does not exist.
|
|
41
40
|
*/
|
|
42
41
|
getCollectionInfo(): Promise<SuccessInterface | undefined>;
|
|
42
|
+
/**
|
|
43
|
+
* Adds metadata for a collection to the collection metadata file.
|
|
44
|
+
*
|
|
45
|
+
* @param collectionData - The metadata of the collection to add
|
|
46
|
+
* @returns A Promise that resolves when the operation is complete, or rejects with an error if the collection metadata format is invalid
|
|
47
|
+
* @private
|
|
48
|
+
*
|
|
49
|
+
* This method performs the following operations:
|
|
50
|
+
* 1. Checks if the collection metadata file exists
|
|
51
|
+
* 2. If the file doesn't exist, creates it with the provided collection metadata
|
|
52
|
+
* 3. If the file exists, reads the existing metadata, adds the new collection metadata (if not already present), and writes back to the file
|
|
53
|
+
*
|
|
54
|
+
* @throws {Error} If the collection metadata format is invalid
|
|
55
|
+
*/
|
|
56
|
+
private AddCollectionMetadata;
|
|
57
|
+
/**
|
|
58
|
+
* Retrieves metadata details for a specific collection.
|
|
59
|
+
*
|
|
60
|
+
* @param collectionName - The name of the collection to retrieve metadata for
|
|
61
|
+
* @returns A Promise that resolves to the collection's metadata if found, or undefined if not found
|
|
62
|
+
* @private
|
|
63
|
+
*
|
|
64
|
+
* This method:
|
|
65
|
+
* 1. Checks if the collection.meta file exists
|
|
66
|
+
* 2. Reads and parses the metadata file if it exists
|
|
67
|
+
* 3. Validates that the data is an array
|
|
68
|
+
* 4. Finds and returns the metadata for the specified collection
|
|
69
|
+
*/
|
|
70
|
+
private getCollectionMetaDetails;
|
|
43
71
|
}
|
|
@@ -31,7 +31,6 @@ 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();
|
|
35
34
|
}
|
|
36
35
|
/**
|
|
37
36
|
* Creates a new collection inside the specified database.
|
|
@@ -57,25 +56,26 @@ class Database {
|
|
|
57
56
|
const newCryptoInstance = new Crypto_helper_1.CryptoHelper(key);
|
|
58
57
|
const collection = new collection_operation_1.default(collectionName, collectionPath, isSchemaNeeded, schema, crypto, newCryptoInstance, key);
|
|
59
58
|
// Store collection metadata in the collectionMap
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
isCryptoEnabled: crypto,
|
|
63
|
-
cryptoKey: key,
|
|
59
|
+
yield this.AddCollectionMetadata({
|
|
60
|
+
name: collectionName,
|
|
64
61
|
path: collectionPath,
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
isSchemaNeeded: isSchemaNeeded === undefined ? false : isSchemaNeeded,
|
|
63
|
+
schema: schema === undefined ? {} : schema,
|
|
64
|
+
encryptionKey: key === undefined ? "" : key,
|
|
65
|
+
isEncrypted: crypto === undefined ? false : crypto,
|
|
67
66
|
});
|
|
68
67
|
return collection;
|
|
69
68
|
}
|
|
70
69
|
else {
|
|
71
70
|
const collection = new collection_operation_1.default(collectionName, collectionPath, isSchemaNeeded, schema);
|
|
72
71
|
// Store collection metadata in the collectionMap
|
|
73
|
-
this.
|
|
74
|
-
|
|
75
|
-
cryptoKey: key,
|
|
72
|
+
yield this.AddCollectionMetadata({
|
|
73
|
+
name: collectionName,
|
|
76
74
|
path: collectionPath,
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
isSchemaNeeded: isSchemaNeeded === undefined ? false : isSchemaNeeded,
|
|
76
|
+
schema: schema === undefined ? {} : schema,
|
|
77
|
+
encryptionKey: key === undefined ? "" : key,
|
|
78
|
+
isEncrypted: crypto === undefined ? false : crypto,
|
|
79
79
|
});
|
|
80
80
|
return collection;
|
|
81
81
|
}
|
|
@@ -105,7 +105,6 @@ class Database {
|
|
|
105
105
|
const exists = yield this.folderManager.DirectoryExists(collectionPath);
|
|
106
106
|
if (exists.statusCode === outers_1.StatusCodes.OK) {
|
|
107
107
|
yield this.folderManager.DeleteDirectory(collectionPath);
|
|
108
|
-
this.collectionMap.delete(collectionName); // Remove from collectionMap
|
|
109
108
|
return this.ResponseHelper.Success(`Collection: ${collectionName} deleted successfully`);
|
|
110
109
|
}
|
|
111
110
|
else {
|
|
@@ -121,7 +120,11 @@ class Database {
|
|
|
121
120
|
getCollectionInfo() {
|
|
122
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
123
122
|
const collections = yield this.folderManager.ListDirectory(this.path);
|
|
123
|
+
// Remove All .meta related things
|
|
124
|
+
collections.data = collections.data.filter((collection) => !collection.endsWith(".meta"));
|
|
124
125
|
const totalSize = yield this.folderManager.GetDirectorySize(path_1.default.resolve(this.path));
|
|
126
|
+
// Get collection Status
|
|
127
|
+
const CollectionStatus = yield Promise.all(collections.data.map((collection) => this.getCollectionMetaDetails(collection)));
|
|
125
128
|
if ("data" in collections && "data" in totalSize) {
|
|
126
129
|
const FinalCollections = {
|
|
127
130
|
CurrentPath: this.path,
|
|
@@ -130,13 +133,76 @@ class Database {
|
|
|
130
133
|
TotalCollections: `${collections.data.length} Collections`,
|
|
131
134
|
TotalSize: parseInt((totalSize.data / 1024 / 1024).toFixed(4)),
|
|
132
135
|
ListOfCollections: collections.data,
|
|
133
|
-
|
|
136
|
+
collectionMetaStatus: CollectionStatus,
|
|
134
137
|
AllCollectionsPaths: collections.data.map((collection) => path_1.default.join(this.path, collection)),
|
|
135
138
|
};
|
|
136
139
|
return this.ResponseHelper.Success(FinalCollections);
|
|
137
140
|
}
|
|
138
141
|
});
|
|
139
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* Adds metadata for a collection to the collection metadata file.
|
|
145
|
+
*
|
|
146
|
+
* @param collectionData - The metadata of the collection to add
|
|
147
|
+
* @returns A Promise that resolves when the operation is complete, or rejects with an error if the collection metadata format is invalid
|
|
148
|
+
* @private
|
|
149
|
+
*
|
|
150
|
+
* This method performs the following operations:
|
|
151
|
+
* 1. Checks if the collection metadata file exists
|
|
152
|
+
* 2. If the file doesn't exist, creates it with the provided collection metadata
|
|
153
|
+
* 3. If the file exists, reads the existing metadata, adds the new collection metadata (if not already present), and writes back to the file
|
|
154
|
+
*
|
|
155
|
+
* @throws {Error} If the collection metadata format is invalid
|
|
156
|
+
*/
|
|
157
|
+
AddCollectionMetadata(collectionData) {
|
|
158
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
159
|
+
const FileManagement = new FileManager_1.default();
|
|
160
|
+
const isFileExist = yield FileManagement.FileExists(`${this.path}/collection.meta`);
|
|
161
|
+
if (isFileExist.status == false) {
|
|
162
|
+
yield FileManagement.WriteFile(`${this.path}/collection.meta`, JSON.stringify([collectionData]));
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
const FullData = JSON.parse((yield FileManagement.ReadFile(`${this.path}/collection.meta`)).data);
|
|
166
|
+
if (!Array.isArray(FullData)) {
|
|
167
|
+
return new response_helper_1.default().Error("Invalid collection metadata format");
|
|
168
|
+
}
|
|
169
|
+
const isSameExist = FullData.filter((data) => data.name === collectionData.name);
|
|
170
|
+
if (isSameExist.length == 0) {
|
|
171
|
+
FullData.push(collectionData);
|
|
172
|
+
yield FileManagement.WriteFile(`${this.path}/collection.meta`, JSON.stringify(FullData));
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Retrieves metadata details for a specific collection.
|
|
179
|
+
*
|
|
180
|
+
* @param collectionName - The name of the collection to retrieve metadata for
|
|
181
|
+
* @returns A Promise that resolves to the collection's metadata if found, or undefined if not found
|
|
182
|
+
* @private
|
|
183
|
+
*
|
|
184
|
+
* This method:
|
|
185
|
+
* 1. Checks if the collection.meta file exists
|
|
186
|
+
* 2. Reads and parses the metadata file if it exists
|
|
187
|
+
* 3. Validates that the data is an array
|
|
188
|
+
* 4. Finds and returns the metadata for the specified collection
|
|
189
|
+
*/
|
|
190
|
+
getCollectionMetaDetails(collectionName) {
|
|
191
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
+
const FileManagement = new FileManager_1.default();
|
|
193
|
+
const isFileExist = yield FileManagement.FileExists(`${this.path}/collection.meta`);
|
|
194
|
+
if (isFileExist.status == false) {
|
|
195
|
+
return undefined;
|
|
196
|
+
}
|
|
197
|
+
const FullData = JSON.parse((yield FileManagement.ReadFile(`${this.path}/collection.meta`)).data);
|
|
198
|
+
if (!Array.isArray(FullData)) {
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
const collectionMeta = FullData.find((data) => data.name === collectionName);
|
|
202
|
+
console.log("Collection metadata:", collectionMeta);
|
|
203
|
+
return collectionMeta;
|
|
204
|
+
});
|
|
205
|
+
}
|
|
140
206
|
}
|
|
141
207
|
exports.default = Database;
|
|
142
208
|
//# sourceMappingURL=database.operation.js.map
|
|
@@ -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,8FAA4D;AAC5D,sFAA8D;AAC9D,0FAAkE;AAClE,gDAAwB;AAExB,qBAAqB;AACrB,8DAA0D;AAC1D,mFAA0D;AAC1D,mCAAqC;AAiBrC;;GAEG;AACH,MAAqB,QAAQ;IAO3B,YAAY,IAAY,EAAE,IAAY;QACpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,IAAI,qBAAW,EAAE,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,IAAI,uBAAa,EAAE,CAAC;QACzC,IAAI,CAAC,cAAc,GAAG,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A6OC"}
|
|
@@ -17,16 +17,16 @@ export declare const CORS_CONFIG: {
|
|
|
17
17
|
ALLOW_CREDENTIALS: boolean;
|
|
18
18
|
};
|
|
19
19
|
export declare const staticPath: string;
|
|
20
|
-
|
|
20
|
+
interface MainRoutesInterface {
|
|
21
21
|
method: string;
|
|
22
22
|
path: string;
|
|
23
23
|
description: string;
|
|
24
|
-
payload?:
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
|
|
24
|
+
payload?: Record<string, any>;
|
|
25
|
+
}
|
|
26
|
+
interface RouteGroupInterface {
|
|
27
|
+
groupName?: string;
|
|
28
28
|
description: string;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
29
|
+
Paths: MainRoutesInterface[];
|
|
30
|
+
}
|
|
31
|
+
export declare const AvailableRoutes: RouteGroupInterface[];
|
|
32
|
+
export {};
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.AvailableRoutes = exports.staticPath = exports.CORS_CONFIG = exports.ServerKeys = void 0;
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
7
8
|
const path_1 = __importDefault(require("path"));
|
|
8
9
|
var ServerKeys;
|
|
9
10
|
(function (ServerKeys) {
|
|
@@ -29,45 +30,90 @@ exports.staticPath = path_1.default.resolve(__dirname, "../public/AxioControl");
|
|
|
29
30
|
// Routes
|
|
30
31
|
exports.AvailableRoutes = [
|
|
31
32
|
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
groupName: "Information",
|
|
34
|
+
description: "Information Endpoints",
|
|
35
|
+
Paths: [
|
|
36
|
+
{
|
|
37
|
+
method: "GET",
|
|
38
|
+
path: "/api/info",
|
|
39
|
+
description: "To Get Internal Information about this DB",
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
method: "GET",
|
|
43
|
+
path: "/api/health",
|
|
44
|
+
description: "Health check endpoint to verify server status",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
method: "GET",
|
|
48
|
+
path: "/api/routes",
|
|
49
|
+
description: "List all available API routes",
|
|
50
|
+
},
|
|
51
|
+
],
|
|
35
52
|
},
|
|
36
53
|
{
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
54
|
+
groupName: "Key Management",
|
|
55
|
+
description: "Key Management Endpoints",
|
|
56
|
+
Paths: [
|
|
57
|
+
{
|
|
58
|
+
method: "GET",
|
|
59
|
+
path: "/api/get-token",
|
|
60
|
+
description: "Get a new token for transacting with AxioDB Server",
|
|
61
|
+
},
|
|
62
|
+
],
|
|
40
63
|
},
|
|
41
64
|
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
65
|
+
groupName: "Database",
|
|
66
|
+
description: "Database Management Endpoints",
|
|
67
|
+
Paths: [
|
|
68
|
+
{
|
|
69
|
+
method: "GET",
|
|
70
|
+
path: "/api/db/databases",
|
|
71
|
+
description: "Get a list of all databases",
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
method: "POST",
|
|
75
|
+
path: "/api/db/create-database",
|
|
76
|
+
description: "Create a new database",
|
|
77
|
+
payload: {
|
|
78
|
+
name: "string",
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
method: "DELETE",
|
|
83
|
+
path: "/api/db/delete-database",
|
|
84
|
+
description: "Delete a database",
|
|
85
|
+
payload: {
|
|
86
|
+
name: "string",
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
],
|
|
45
90
|
},
|
|
46
91
|
{
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
92
|
+
groupName: "Collection",
|
|
93
|
+
description: "Collection Management Endpoints",
|
|
94
|
+
Paths: [
|
|
95
|
+
{
|
|
96
|
+
method: "GET",
|
|
97
|
+
path: "/api/collection/all/?databaseName",
|
|
98
|
+
description: "Get a list of all collections",
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
method: "POST",
|
|
102
|
+
path: "/api/collection/create-collection",
|
|
103
|
+
description: "Create a new collection",
|
|
104
|
+
payload: {
|
|
105
|
+
dbName: "string",
|
|
106
|
+
collectionName: "string",
|
|
107
|
+
crypto: "boolean",
|
|
108
|
+
key: "string",
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
method: "DELETE",
|
|
113
|
+
path: "/api/collection/delete-collection/?dbName&collectionName",
|
|
114
|
+
description: "Delete a collection",
|
|
115
|
+
},
|
|
116
|
+
],
|
|
71
117
|
},
|
|
72
118
|
];
|
|
73
119
|
//# sourceMappingURL=keys.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../source/server/config/keys.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AAExB,IAAY,UASX;AATD,WAAY,UAAU;IACpB,+CAAY,CAAA;IACZ,mCAAqB,CAAA;IACrB,uCAAyB,CAAA;IACzB,kDAAoC,CAAA;IACpC,oDAAsC,CAAA;IACtC,uEAAyD,CAAA;IACzD,iDAAwB,IAAI,CAAC,GAAG,EAAE,2BAAA,CAAA;IAClC,uEAAsB,CAAA;AACxB,CAAC,EATW,UAAU,0BAAV,UAAU,QASrB;AAED,kBAAkB;AACL,QAAA,WAAW,GAAG;IACzB,MAAM,EAAE,GAAG;IACX,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE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F;YACD;gBACE,MAAM,EAAE,QAAQ;gBAChB,IAAI,EAAE,0DAA0D;gBAChE,WAAW,EAAE,qBAAqB;aACnC;SACF;KACF;CACF,CAAC"}
|
|
@@ -22,4 +22,37 @@ export default class CollectionController {
|
|
|
22
22
|
* @throws Will return an internal server error response if collection creation fails
|
|
23
23
|
*/
|
|
24
24
|
createCollection(request: FastifyRequest): Promise<ResponseBuilder>;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves all collections for a specified database.
|
|
27
|
+
*
|
|
28
|
+
* @param request - The Fastify request object containing query parameters
|
|
29
|
+
* @returns A Promise resolving to a ResponseBuilder object with the response status and data
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* This method expects a 'databaseName' query parameter in the request.
|
|
33
|
+
* It fetches all collections in the specified database and additionally computes
|
|
34
|
+
* the file count for each collection path.
|
|
35
|
+
*
|
|
36
|
+
* @throws Will return a BAD_REQUEST response if databaseName is not provided
|
|
37
|
+
* @throws Will return an INTERNAL_SERVER_ERROR response if collection retrieval fails
|
|
38
|
+
*/
|
|
39
|
+
getCollections(request: FastifyRequest): Promise<ResponseBuilder>;
|
|
40
|
+
/**
|
|
41
|
+
* Deletes a collection from a specified database.
|
|
42
|
+
*
|
|
43
|
+
* @param request - The Fastify request object containing the database and collection names in the body.
|
|
44
|
+
* @returns A ResponseBuilder object with appropriate status code and message.
|
|
45
|
+
*
|
|
46
|
+
* @throws Returns a BAD_REQUEST response if the database name or collection name is invalid.
|
|
47
|
+
* @throws Returns a NOT_FOUND response if the collection does not exist.
|
|
48
|
+
* @throws Returns an INTERNAL_SERVER_ERROR response if the collection deletion fails.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* // Example request body:
|
|
52
|
+
* // {
|
|
53
|
+
* // "dbName": "myDatabase",
|
|
54
|
+
* // "collectionName": "myCollection"
|
|
55
|
+
* // }
|
|
56
|
+
*/
|
|
57
|
+
deleteCollection(request: FastifyRequest): Promise<ResponseBuilder>;
|
|
25
58
|
}
|
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
const outers_1 = require("outers");
|
|
16
16
|
const responseBuilder_helper_1 = __importDefault(require("../../helper/responseBuilder.helper"));
|
|
17
|
+
const filesCounterInFolder_helper_1 = __importDefault(require("../../helper/filesCounterInFolder.helper"));
|
|
17
18
|
/**
|
|
18
19
|
* Controller class for managing collections in AxioDB.
|
|
19
20
|
*
|
|
@@ -54,7 +55,10 @@ class CollectionController {
|
|
|
54
55
|
// Creating the collection
|
|
55
56
|
try {
|
|
56
57
|
yield databaseInstance.createCollection(collectionName, crypto, key);
|
|
57
|
-
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.CREATED, "Collection created successfully"
|
|
58
|
+
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.CREATED, "Collection created successfully", {
|
|
59
|
+
dbName,
|
|
60
|
+
collectionName,
|
|
61
|
+
});
|
|
58
62
|
}
|
|
59
63
|
catch (error) {
|
|
60
64
|
console.error("Error creating collection:", error);
|
|
@@ -62,6 +66,91 @@ class CollectionController {
|
|
|
62
66
|
}
|
|
63
67
|
});
|
|
64
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Retrieves all collections for a specified database.
|
|
71
|
+
*
|
|
72
|
+
* @param request - The Fastify request object containing query parameters
|
|
73
|
+
* @returns A Promise resolving to a ResponseBuilder object with the response status and data
|
|
74
|
+
*
|
|
75
|
+
* @remarks
|
|
76
|
+
* This method expects a 'databaseName' query parameter in the request.
|
|
77
|
+
* It fetches all collections in the specified database and additionally computes
|
|
78
|
+
* the file count for each collection path.
|
|
79
|
+
*
|
|
80
|
+
* @throws Will return a BAD_REQUEST response if databaseName is not provided
|
|
81
|
+
* @throws Will return an INTERNAL_SERVER_ERROR response if collection retrieval fails
|
|
82
|
+
*/
|
|
83
|
+
getCollections(request) {
|
|
84
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
+
var _a;
|
|
86
|
+
// extract databaseName from url query
|
|
87
|
+
const { databaseName } = request.query;
|
|
88
|
+
if (!databaseName) {
|
|
89
|
+
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.BAD_REQUEST, "Database name is required");
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
const collections = yield (yield this.AxioDBInstance.createDB(databaseName)).getCollectionInfo();
|
|
93
|
+
// Read all file count of each Collections
|
|
94
|
+
let FolderPaths = (_a = collections === null || collections === void 0 ? void 0 : collections.data) === null || _a === void 0 ? void 0 : _a.AllCollectionsPaths;
|
|
95
|
+
// Remove .meta extenstion paths
|
|
96
|
+
FolderPaths = FolderPaths.filter((path) => !path.endsWith(".meta"));
|
|
97
|
+
const mainData = collections === null || collections === void 0 ? void 0 : collections.data;
|
|
98
|
+
mainData.CollectionSizeMap = [];
|
|
99
|
+
yield Promise.all([
|
|
100
|
+
...FolderPaths.map((folderPath) => __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
const fileCount = yield (0, filesCounterInFolder_helper_1.default)(folderPath);
|
|
102
|
+
mainData.CollectionSizeMap.push({ folderPath, fileCount });
|
|
103
|
+
})),
|
|
104
|
+
]);
|
|
105
|
+
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.OK, "Collections retrieved successfully", mainData);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
console.error("Error retrieving collections:", error);
|
|
109
|
+
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.INTERNAL_SERVER_ERROR, "Failed to retrieve collections");
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Deletes a collection from a specified database.
|
|
115
|
+
*
|
|
116
|
+
* @param request - The Fastify request object containing the database and collection names in the body.
|
|
117
|
+
* @returns A ResponseBuilder object with appropriate status code and message.
|
|
118
|
+
*
|
|
119
|
+
* @throws Returns a BAD_REQUEST response if the database name or collection name is invalid.
|
|
120
|
+
* @throws Returns a NOT_FOUND response if the collection does not exist.
|
|
121
|
+
* @throws Returns an INTERNAL_SERVER_ERROR response if the collection deletion fails.
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* // Example request body:
|
|
125
|
+
* // {
|
|
126
|
+
* // "dbName": "myDatabase",
|
|
127
|
+
* // "collectionName": "myCollection"
|
|
128
|
+
* // }
|
|
129
|
+
*/
|
|
130
|
+
deleteCollection(request) {
|
|
131
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
const { dbName, collectionName } = request.query;
|
|
133
|
+
if (!dbName || typeof dbName !== "string") {
|
|
134
|
+
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.BAD_REQUEST, "Invalid database name");
|
|
135
|
+
}
|
|
136
|
+
if (!collectionName || typeof collectionName !== "string") {
|
|
137
|
+
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.BAD_REQUEST, "Invalid collection name");
|
|
138
|
+
}
|
|
139
|
+
const databaseInstance = yield this.AxioDBInstance.createDB(dbName);
|
|
140
|
+
const isCollectionExists = yield databaseInstance.isCollectionExists(collectionName);
|
|
141
|
+
if (!isCollectionExists) {
|
|
142
|
+
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.NOT_FOUND, "Collection not found");
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
yield databaseInstance.deleteCollection(collectionName);
|
|
146
|
+
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.OK, "Collection deleted successfully");
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
console.error("Error deleting collection:", error);
|
|
150
|
+
return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.INTERNAL_SERVER_ERROR, "Failed to delete collection");
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
65
154
|
}
|
|
66
155
|
exports.default = CollectionController;
|
|
67
156
|
//# sourceMappingURL=Collection.controller.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Collection.controller.js","sourceRoot":"","sources":["../../../../source/server/controller/Collections/Collection.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mCAAqC;AAErC,iGAE6C;
|
|
1
|
+
{"version":3,"file":"Collection.controller.js","sourceRoot":"","sources":["../../../../source/server/controller/Collections/Collection.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,mCAAqC;AAErC,iGAE6C;AAE7C,2GAA2E;AAE3E;;;;;;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,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,CAAC;gBACxB,OAAO,IAAA,gCAAa,EAAC,oBAAW,CAAC,SAAS,EAAE,sBAAsB,CAAC,CAAC;YACtE,CAAC;YAED,IAAI,CAAC;gBACH,MAAM,gBAAgB,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC;gBACxD,OAAO,IAAA,gCAAa,EAAC,oBAAW,CAAC,EAAE,EAAE,iCAAiC,CAAC,CAAC;YAC1E,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;AAhLD,uCAgLC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Recursively counts the number of files in a folder and its subfolders.
|
|
3
|
+
*
|
|
4
|
+
* This function traverses through the directory structure starting from the provided folder path
|
|
5
|
+
* and counts all files encountered during the traversal. It does not count directories themselves.
|
|
6
|
+
*
|
|
7
|
+
* @param folderPath - The path to the folder to count files in
|
|
8
|
+
* @returns A promise that resolves to the total number of files found
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const count = await countFilesRecursive('/path/to/folder');
|
|
13
|
+
* console.log(`Total files: ${count}`);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export default function countFilesRecursive(folderPath: string): Promise<number>;
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
exports.default = countFilesRecursive;
|
|
16
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
17
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
18
|
+
/**
|
|
19
|
+
* Recursively counts the number of files in a folder and its subfolders.
|
|
20
|
+
*
|
|
21
|
+
* This function traverses through the directory structure starting from the provided folder path
|
|
22
|
+
* and counts all files encountered during the traversal. It does not count directories themselves.
|
|
23
|
+
*
|
|
24
|
+
* @param folderPath - The path to the folder to count files in
|
|
25
|
+
* @returns A promise that resolves to the total number of files found
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const count = await countFilesRecursive('/path/to/folder');
|
|
30
|
+
* console.log(`Total files: ${count}`);
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
function countFilesRecursive(folderPath) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
let count = 0;
|
|
36
|
+
const items = yield promises_1.default.readdir(folderPath, { withFileTypes: true });
|
|
37
|
+
for (const item of items) {
|
|
38
|
+
const fullPath = node_path_1.default.join(folderPath, item.name);
|
|
39
|
+
if (item.isFile()) {
|
|
40
|
+
count++;
|
|
41
|
+
}
|
|
42
|
+
else if (item.isDirectory()) {
|
|
43
|
+
count += yield countFilesRecursive(fullPath);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return count;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=filesCounterInFolder.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filesCounterInFolder.helper.js","sourceRoot":"","sources":["../../../source/server/helper/filesCounterInFolder.helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAkBA,sCAaC;AA/BD,gEAAkC;AAClC,0DAA6B;AAE7B;;;;;;;;;;;;;;GAcG;AACH,SAA8B,mBAAmB,CAAC,UAAkB;;QAClE,IAAI,KAAK,GAAG,CAAC,CAAC;QACd,MAAM,KAAK,GAAG,MAAM,kBAAE,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC,CAAC;QAEpE,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YAClD,IAAI,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;gBAClB,KAAK,EAAE,CAAC;YACV,CAAC;iBAAM,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;gBAC9B,KAAK,IAAI,MAAM,mBAAmB,CAAC,QAAQ,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CAAA"}
|