axiodb 2.21.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.
Files changed (38) hide show
  1. package/lib/Services/Database/database.operation.d.ts +38 -3
  2. package/lib/Services/Database/database.operation.js +101 -3
  3. package/lib/Services/Database/database.operation.js.map +1 -1
  4. package/lib/Services/Indexation.operation.d.ts +1 -0
  5. package/lib/Services/Indexation.operation.js +8 -1
  6. package/lib/Services/Indexation.operation.js.map +1 -1
  7. package/lib/config/Interfaces/Operation/Indexation.operation.interface.d.ts +2 -0
  8. package/lib/config/Interfaces/Operation/database.operation.interface.d.ts +12 -0
  9. package/lib/config/Interfaces/Operation/database.operation.interface.js +1 -0
  10. package/lib/config/Interfaces/Operation/database.operation.interface.js.map +1 -1
  11. package/lib/engine/Filesystem/FileManager.js +62 -9
  12. package/lib/engine/Filesystem/FileManager.js.map +1 -1
  13. package/lib/engine/Filesystem/FolderManager.d.ts +15 -0
  14. package/lib/engine/Filesystem/FolderManager.js +151 -5
  15. package/lib/engine/Filesystem/FolderManager.js.map +1 -1
  16. package/lib/server/config/keys.d.ts +9 -9
  17. package/lib/server/config/keys.js +79 -33
  18. package/lib/server/config/keys.js.map +1 -1
  19. package/lib/server/controller/Collections/Collection.controller.d.ts +58 -0
  20. package/lib/server/controller/Collections/Collection.controller.js +156 -0
  21. package/lib/server/controller/Collections/Collection.controller.js.map +1 -0
  22. package/lib/server/helper/filesCounterInFolder.helper.d.ts +16 -0
  23. package/lib/server/helper/filesCounterInFolder.helper.js +49 -0
  24. package/lib/server/helper/filesCounterInFolder.helper.js.map +1 -0
  25. package/lib/server/public/AxioControl/.vite/manifest.json +2 -2
  26. package/lib/server/public/AxioControl/.vite/ssr-manifest.json +2 -0
  27. package/lib/server/public/AxioControl/assets/index--rWHSvem.css +1 -0
  28. package/lib/server/public/AxioControl/assets/index-1QePTOyA.js +56 -0
  29. package/lib/server/public/AxioControl/index.html +2 -2
  30. package/lib/server/public/AxioControl/sw.js +1 -1
  31. package/lib/server/router/Router.js +6 -0
  32. package/lib/server/router/Router.js.map +1 -1
  33. package/lib/server/router/Routers/Collection.routes.d.ts +7 -0
  34. package/lib/server/router/Routers/Collection.routes.js +29 -0
  35. package/lib/server/router/Routers/Collection.routes.js.map +1 -0
  36. package/package.json +1 -1
  37. package/lib/server/public/AxioControl/assets/index-BHqXlmHD.css +0 -1
  38. package/lib/server/public/AxioControl/assets/index-BrzSFweB.js +0 -56
@@ -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
- const stdout = yield this.WorkerProcess.execCommand(`powershell -command "(Get-Item '${path}').length"`);
149
- const size = parseInt(stdout, 10);
150
- return this.responseHelper.Success(size);
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,eAAe,CAC1B,IAAY;;YAEZ,IAAI,CAAC;gBACH,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;gBACvD,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,yBAAyB,IAAI,EAAE,CAAC,CAAC;YACtE,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,+BAA+B,KAAK,EAAE,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;KAAA;IAED;;OAEG;IACU,eAAe,CAC1B,IAAY;;YAEZ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H,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"}
@@ -17,16 +17,16 @@ export declare const CORS_CONFIG: {
17
17
  ALLOW_CREDENTIALS: boolean;
18
18
  };
19
19
  export declare const staticPath: string;
20
- export declare const AvailableRoutes: ({
20
+ interface MainRoutesInterface {
21
21
  method: string;
22
22
  path: string;
23
23
  description: string;
24
- payload?: undefined;
25
- } | {
26
- method: string;
27
- path: string;
24
+ payload?: Record<string, any>;
25
+ }
26
+ interface RouteGroupInterface {
27
+ groupName?: string;
28
28
  description: string;
29
- payload: {
30
- name: string;
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
- method: "GET",
33
- path: "/api/info",
34
- description: "To Get Internal Informations about this DB",
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
- method: "GET",
38
- path: "/api/health",
39
- description: "Health check endpoint to verify server status",
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
- method: "GET",
43
- path: "/api/routes",
44
- description: "List all available API routes",
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
- method: "GET",
48
- path: "/api/get-token",
49
- description: "Get a new token for transacting with AxioDB Server",
50
- },
51
- {
52
- method: "GET",
53
- path: "/api/db/databases",
54
- description: "Get a list of all databases",
55
- },
56
- {
57
- method: "POST",
58
- path: "/api/db/create-database",
59
- description: "Create a new database",
60
- payload: {
61
- name: "string",
62
- },
63
- },
64
- {
65
- method: "DELETE",
66
- path: "/api/db/delete-database",
67
- description: "Delete a database",
68
- payload: {
69
- name: "string",
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,QAAQ,CAAC;IAC1D,eAAe,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC;IAClD,eAAe,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,CAAC;IACvD,OAAO,EAAE,KAAK,EAAE,sBAAsB;IACtC,iBAAiB,EAAE,IAAI;CACxB,CAAC;AAEW,QAAA,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAC;AAE3E,SAAS;AAEI,QAAA,eAAe,GAAG;IAC7B;QACE,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,WAAW;QACjB,WAAW,EAAE,4CAA4C;KAC1D;IACD;QACE,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,+CAA+C;KAC7D;IACD;QACE,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,+BAA+B;KAC7C;IACD;QACE,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,gBAAgB;QACtB,WAAW,EAAE,oDAAoD;KAClE;IACD;QACE,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,mBAAmB;QACzB,WAAW,EAAE,6BAA6B;KAC3C;IACD;QACE,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,yBAAyB;QAC/B,WAAW,EAAE,uBAAuB;QACpC,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;SACf;KACF;IACD;QACE,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,yBAAyB;QAC/B,WAAW,EAAE,mBAAmB;QAChC,OAAO,EAAE;YACP,IAAI,EAAE,QAAQ;SACf;KACF;CACF,CAAC"}
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../source/server/config/keys.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAuD;AACvD,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,QAAQ,CAAC;IAC1D,eAAe,EAAE,CAAC,cAAc,EAAE,eAAe,CAAC;IAClD,eAAe,EAAE,CAAC,gBAAgB,EAAE,kBAAkB,CAAC;IACvD,OAAO,EAAE,KAAK,EAAE,sBAAsB;IACtC,iBAAiB,EAAE,IAAI;CACxB,CAAC;AAEW,QAAA,UAAU,GAAG,cAAI,CAAC,OAAO,CAAC,SAAS,EAAE,uBAAuB,CAAC,CAAC;AAc3E,SAAS;AACI,QAAA,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B;gBACtC,OAAO,EAAE;oBACP,MAAM,EAAE,QAAQ;oBAChB,cAAc,EAAE,QAAQ;oBACxB,MAAM,EAAE,SAAS;oBACjB,GAAG,EAAE,QAAQ;iBACd;aACF;YACD;gBACE,MAAM,EAAE,QAAQ;gBAChB,IAAI,EAAE,0DAA0D;gBAChE,WAAW,EAAE,qBAAqB;aACnC;SACF;KACF;CACF,CAAC"}
@@ -0,0 +1,58 @@
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
+ /**
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>;
58
+ }
@@ -0,0 +1,156 @@
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
+ const filesCounterInFolder_helper_1 = __importDefault(require("../../helper/filesCounterInFolder.helper"));
18
+ /**
19
+ * Controller class for managing collections in AxioDB.
20
+ *
21
+ * This class provides methods for creating, retrieving, and managing collections
22
+ * within the AxioDB instance. It acts as an interface between the API routes and
23
+ * the AxioDB instance.
24
+ */
25
+ class CollectionController {
26
+ constructor(AxioDBInstance) {
27
+ this.AxioDBInstance = AxioDBInstance;
28
+ }
29
+ /**
30
+ * Creates a new collection in the specified database.
31
+ *
32
+ * @param request - The Fastify request object containing the collection details in the body
33
+ * @returns A ResponseBuilder object containing the status and message of the operation
34
+ *
35
+ * @throws Will return a conflict response if collection already exists
36
+ * @throws Will return a bad request response if name is missing, not a string, or empty
37
+ * @throws Will return an internal server error response if collection creation fails
38
+ */
39
+ createCollection(request) {
40
+ return __awaiter(this, void 0, void 0, function* () {
41
+ // Extracting parameters from the request body
42
+ const { dbName, collectionName, crypto, key } = request.body;
43
+ // Validating extracted parameters
44
+ if (!dbName || typeof dbName !== "string") {
45
+ return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.BAD_REQUEST, "Invalid database name");
46
+ }
47
+ if (!collectionName || typeof collectionName !== "string") {
48
+ return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.BAD_REQUEST, "Invalid collection name");
49
+ }
50
+ const databaseInstance = yield this.AxioDBInstance.createDB(dbName);
51
+ const isCollectionExists = yield databaseInstance.isCollectionExists(collectionName);
52
+ if (isCollectionExists) {
53
+ return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.CONFLICT, "Collection already exists");
54
+ }
55
+ // Creating the collection
56
+ try {
57
+ yield databaseInstance.createCollection(collectionName, crypto, key);
58
+ return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.CREATED, "Collection created successfully", {
59
+ dbName,
60
+ collectionName,
61
+ });
62
+ }
63
+ catch (error) {
64
+ console.error("Error creating collection:", error);
65
+ return (0, responseBuilder_helper_1.default)(outers_1.StatusCodes.INTERNAL_SERVER_ERROR, "Failed to create collection");
66
+ }
67
+ });
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
+ }
154
+ }
155
+ exports.default = CollectionController;
156
+ //# 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;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,K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vB,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG,OAAO,CAAC,KAG1C,CAAC;YAEF,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,CAAC,kBAAkB,EAAE,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>;