axiodb 12.10.17 → 12.10.20
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/Helper/Converter.helper.d.ts +0 -25
- package/lib/Helper/Converter.helper.js +1 -26
- package/lib/Helper/Converter.helper.js.map +1 -1
- package/lib/Helper/Crypto.helper.d.ts +1 -44
- package/lib/Helper/Crypto.helper.js +1 -40
- package/lib/Helper/Crypto.helper.js.map +1 -1
- package/lib/Helper/DocumentLoader.helper.d.ts +3 -38
- package/lib/Helper/DocumentLoader.helper.js +4 -42
- package/lib/Helper/DocumentLoader.helper.js.map +1 -1
- package/lib/Helper/PathSanitizer.helper.js +6 -12
- package/lib/Helper/PathSanitizer.helper.js.map +1 -1
- package/lib/Helper/response.helper.d.ts +1 -42
- package/lib/Helper/response.helper.js +1 -43
- package/lib/Helper/response.helper.js.map +1 -1
- package/lib/Memory/memory.operation.d.ts +13 -93
- package/lib/Memory/memory.operation.js +20 -122
- package/lib/Memory/memory.operation.js.map +1 -1
- package/lib/client/AggregationProxy.d.ts +1 -7
- package/lib/client/AggregationProxy.js +1 -7
- package/lib/client/AggregationProxy.js.map +1 -1
- package/lib/client/AxioDBCloud.client.d.ts +1 -12
- package/lib/client/AxioDBCloud.client.js +1 -15
- package/lib/client/AxioDBCloud.client.js.map +1 -1
- package/lib/client/CollectionProxy.d.ts +1 -37
- package/lib/client/CollectionProxy.js +1 -37
- package/lib/client/CollectionProxy.js.map +1 -1
- package/lib/client/DatabaseProxy.d.ts +1 -19
- package/lib/client/DatabaseProxy.js +1 -19
- package/lib/client/DatabaseProxy.js.map +1 -1
- package/lib/client/DeleteOperationProxy.d.ts +1 -10
- package/lib/client/DeleteOperationProxy.js +1 -10
- package/lib/client/DeleteOperationProxy.js.map +1 -1
- package/lib/client/PooledConnection.d.ts +0 -1
- package/lib/client/PooledConnection.js +1 -2
- package/lib/client/PooledConnection.js.map +1 -1
- package/lib/client/ReaderProxy.d.ts +1 -19
- package/lib/client/ReaderProxy.js +1 -19
- package/lib/client/ReaderProxy.js.map +1 -1
- package/lib/client/UpdateOperationProxy.d.ts +1 -10
- package/lib/client/UpdateOperationProxy.js +1 -10
- package/lib/client/UpdateOperationProxy.js.map +1 -1
- package/lib/client/types/client.types.d.ts +1 -12
- package/lib/client/types/client.types.js +0 -6
- package/lib/client/types/client.types.js.map +1 -1
- package/lib/config/DB.js +0 -3
- package/lib/config/DB.js.map +1 -1
- package/lib/config/Keys/Keys.js +0 -1
- package/lib/config/Keys/Keys.js.map +1 -1
- package/lib/engine/Filesystem/FileManager.d.ts +4 -74
- package/lib/engine/Filesystem/FileManager.js +4 -76
- package/lib/engine/Filesystem/FileManager.js.map +1 -1
- package/lib/engine/Filesystem/FolderManager.d.ts +1 -31
- package/lib/engine/Filesystem/FolderManager.js +2 -47
- package/lib/engine/Filesystem/FolderManager.js.map +1 -1
- package/lib/engine/cli/worker_process.d.ts +1 -24
- package/lib/engine/cli/worker_process.js +1 -24
- package/lib/engine/cli/worker_process.js.map +1 -1
- package/lib/engine/node/WorkerForDataLoad.engine.js +3 -17
- package/lib/engine/node/WorkerForDataLoad.engine.js.map +1 -1
- package/lib/engine/node/WorkerForSearch.engine.js +2 -4
- package/lib/engine/node/WorkerForSearch.engine.js.map +1 -1
- package/lib/server/config/PortFreeChecker.d.ts +0 -26
- package/lib/server/config/PortFreeChecker.js +3 -29
- package/lib/server/config/PortFreeChecker.js.map +1 -1
- package/lib/server/config/keys.js +0 -2
- package/lib/server/config/keys.js.map +1 -1
- package/lib/server/config/server.js +13 -15
- package/lib/server/config/server.js.map +1 -1
- package/lib/server/controller/Collections/Collection.controller.d.ts +0 -48
- package/lib/server/controller/Collections/Collection.controller.js +2 -55
- package/lib/server/controller/Collections/Collection.controller.js.map +1 -1
- package/lib/server/controller/Database/Databse.controller.d.ts +2 -65
- package/lib/server/controller/Database/Databse.controller.js +3 -80
- package/lib/server/controller/Database/Databse.controller.js.map +1 -1
- package/lib/server/controller/Index/Index.controller.d.ts +3 -25
- package/lib/server/controller/Index/Index.controller.js +3 -25
- package/lib/server/controller/Index/Index.controller.js.map +1 -1
- package/lib/server/controller/Operation/CRUD.controller.d.ts +0 -167
- package/lib/server/controller/Operation/CRUD.controller.js +0 -195
- package/lib/server/controller/Operation/CRUD.controller.js.map +1 -1
- package/lib/server/controller/Stats.controller.d.ts +1 -22
- package/lib/server/controller/Stats.controller.js +2 -29
- package/lib/server/controller/Stats.controller.js.map +1 -1
- package/lib/server/helper/filesCounterInFolder.helper.d.ts +0 -15
- package/lib/server/helper/filesCounterInFolder.helper.js +0 -15
- package/lib/server/helper/filesCounterInFolder.helper.js.map +1 -1
- package/lib/server/helper/responseBuilder.helper.d.ts +0 -16
- package/lib/server/helper/responseBuilder.helper.js +0 -16
- package/lib/server/helper/responseBuilder.helper.js.map +1 -1
- package/lib/server/router/Router.d.ts +0 -6
- package/lib/server/router/Router.js +6 -22
- package/lib/server/router/Router.js.map +1 -1
- package/lib/server/router/Routers/Collection.routes.js +0 -4
- package/lib/server/router/Routers/Collection.routes.js.map +1 -1
- package/lib/server/router/Routers/DB.routes.js +1 -7
- package/lib/server/router/Routers/DB.routes.js.map +1 -1
- package/lib/server/router/Routers/Index.routes.js +0 -4
- package/lib/server/router/Routers/Index.routes.js.map +1 -1
- package/lib/server/router/Routers/Operation.routes.js +0 -9
- package/lib/server/router/Routers/Operation.routes.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,34 +1,9 @@
|
|
|
1
1
|
export default class Converter {
|
|
2
2
|
static ToObject(): string;
|
|
3
3
|
constructor();
|
|
4
|
-
/**
|
|
5
|
-
* Converts a string to a boolean.
|
|
6
|
-
* @param value The string to convert.
|
|
7
|
-
* @returns The boolean value.
|
|
8
|
-
*/
|
|
9
4
|
ToBoolean(value: string): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Converts a string to a number.
|
|
12
|
-
* @param value The string to convert.
|
|
13
|
-
* @returns The number value.
|
|
14
|
-
*/
|
|
15
5
|
ToNumber(value: string): number;
|
|
16
|
-
/**
|
|
17
|
-
* Converts a string to a JSON object.
|
|
18
|
-
* @param value The string to convert.
|
|
19
|
-
* @returns The JSON object.
|
|
20
|
-
*/
|
|
21
6
|
ToObject(value: string): any;
|
|
22
|
-
/**
|
|
23
|
-
* Converts a JSON object to a string.
|
|
24
|
-
* @param value The JSON object to convert.
|
|
25
|
-
* @returns The string.
|
|
26
|
-
*/
|
|
27
7
|
ToString(value: object): string;
|
|
28
|
-
/**
|
|
29
|
-
* Converts a string to a string array.
|
|
30
|
-
* @param value The string to convert.
|
|
31
|
-
* @returns The string array.
|
|
32
|
-
*/
|
|
33
8
|
ToStringArray(value: string): string[];
|
|
34
9
|
}
|
|
@@ -5,44 +5,19 @@ class Converter {
|
|
|
5
5
|
static ToObject() {
|
|
6
6
|
throw new Error("Method not implemented.");
|
|
7
7
|
}
|
|
8
|
-
constructor() { }
|
|
9
|
-
/**
|
|
10
|
-
* Converts a string to a boolean.
|
|
11
|
-
* @param value The string to convert.
|
|
12
|
-
* @returns The boolean value.
|
|
13
|
-
*/
|
|
8
|
+
constructor() { }
|
|
14
9
|
ToBoolean(value) {
|
|
15
10
|
return value === "true";
|
|
16
11
|
}
|
|
17
|
-
/**
|
|
18
|
-
* Converts a string to a number.
|
|
19
|
-
* @param value The string to convert.
|
|
20
|
-
* @returns The number value.
|
|
21
|
-
*/
|
|
22
12
|
ToNumber(value) {
|
|
23
13
|
return parseInt(value);
|
|
24
14
|
}
|
|
25
|
-
/**
|
|
26
|
-
* Converts a string to a JSON object.
|
|
27
|
-
* @param value The string to convert.
|
|
28
|
-
* @returns The JSON object.
|
|
29
|
-
*/
|
|
30
15
|
ToObject(value) {
|
|
31
16
|
return JSON.parse(value);
|
|
32
17
|
}
|
|
33
|
-
/**
|
|
34
|
-
* Converts a JSON object to a string.
|
|
35
|
-
* @param value The JSON object to convert.
|
|
36
|
-
* @returns The string.
|
|
37
|
-
*/
|
|
38
18
|
ToString(value) {
|
|
39
19
|
return JSON.stringify(value);
|
|
40
20
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Converts a string to a string array.
|
|
43
|
-
* @param value The string to convert.
|
|
44
|
-
* @returns The string array.
|
|
45
|
-
*/
|
|
46
21
|
ToStringArray(value) {
|
|
47
22
|
return value.split(",");
|
|
48
23
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Converter.helper.js","sourceRoot":"","sources":["../../source/Helper/Converter.helper.ts"],"names":[],"mappings":";;AAAA,uDAAuD;AACvD;IACE,MAAM,CAAC,QAAQ;QACb,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,gBAAe,CAAC
|
|
1
|
+
{"version":3,"file":"Converter.helper.js","sourceRoot":"","sources":["../../source/Helper/Converter.helper.ts"],"names":[],"mappings":";;AAAA,uDAAuD;AACvD;IACE,MAAM,CAAC,QAAQ;QACb,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC7C,CAAC;IACD,gBAAe,CAAC;IAET,SAAS,CAAC,KAAa;QAC5B,OAAO,KAAK,KAAK,MAAM,CAAC;IAC1B,CAAC;IAEM,QAAQ,CAAC,KAAa;QAC3B,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC;IACzB,CAAC;IAEM,QAAQ,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC3B,CAAC;IAEM,QAAQ,CAAC,KAAa;QAC3B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IAC/B,CAAC;IAEM,aAAa,CAAC,KAAa;QAChC,OAAO,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC1B,CAAC;CACF"}
|
|
@@ -1,57 +1,14 @@
|
|
|
1
1
|
import { SuccessInterface } from "../config/Interfaces/Helper/response.helper.interface";
|
|
2
|
-
/**
|
|
3
|
-
* Helper class for cryptographic operations such as encryption and decryption.
|
|
4
|
-
*/
|
|
5
2
|
export declare class CryptoHelper {
|
|
6
|
-
/**
|
|
7
|
-
* The encryption key used for cryptographic operations.
|
|
8
|
-
*/
|
|
9
3
|
private encryptionKey;
|
|
10
|
-
/**
|
|
11
|
-
* Instance of ResponseHelper to handle responses.
|
|
12
|
-
*/
|
|
13
4
|
private readonly responseHelper;
|
|
14
|
-
/**
|
|
15
|
-
* Instance of Cryptography class for performing cryptographic operations.
|
|
16
|
-
*/
|
|
17
5
|
private readonly Cryptography;
|
|
18
|
-
/**
|
|
19
|
-
* Instance of Converter class for converting data formats.
|
|
20
|
-
*/
|
|
21
6
|
private readonly Converter;
|
|
22
|
-
/**
|
|
23
|
-
* Constructor to initialize the CryptoHelper class.
|
|
24
|
-
* @param encryptionKey - Optional encryption key. If not provided, a default key based on hostname and platform will be used.
|
|
25
|
-
*/
|
|
7
|
+
/** If no encryptionKey is given, falls back to a default key derived from hostname + platform. */
|
|
26
8
|
constructor(encryptionKey?: string);
|
|
27
|
-
/**
|
|
28
|
-
* Sets a new encryption key.
|
|
29
|
-
* @param encryptionKey - The new encryption key to be set.
|
|
30
|
-
* @returns A promise that resolves to a success response.
|
|
31
|
-
*/
|
|
32
9
|
setEncryptionKey(encryptionKey: string): Promise<SuccessInterface>;
|
|
33
|
-
/**
|
|
34
|
-
* Encrypts data asynchronously.
|
|
35
|
-
* @param data - The data to be encrypted.
|
|
36
|
-
* @returns A promise that resolves to the encrypted data as a string.
|
|
37
|
-
*/
|
|
38
10
|
encrypt(data: string): Promise<string>;
|
|
39
|
-
/**
|
|
40
|
-
* Decrypts data asynchronously.
|
|
41
|
-
* @param data - The data to be decrypted.
|
|
42
|
-
* @returns A promise that resolves to the decrypted data as an object.
|
|
43
|
-
*/
|
|
44
11
|
decrypt(data: string): Promise<any>;
|
|
45
|
-
/**
|
|
46
|
-
* Encrypts data synchronously.
|
|
47
|
-
* @param data - The data to be encrypted.
|
|
48
|
-
* @returns The encrypted data as a string.
|
|
49
|
-
*/
|
|
50
12
|
encryptSync(data: string): string;
|
|
51
|
-
/**
|
|
52
|
-
* Decrypts data synchronously.
|
|
53
|
-
* @param data - The data to be decrypted.
|
|
54
|
-
* @returns The decrypted data as an object.
|
|
55
|
-
*/
|
|
56
13
|
decryptSync(data: string): object;
|
|
57
14
|
}
|
|
@@ -14,78 +14,39 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.CryptoHelper = void 0;
|
|
16
16
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
17
|
-
// All Imports
|
|
18
17
|
const node_os_1 = require("node:os");
|
|
19
18
|
const response_helper_1 = __importDefault(require("./response.helper"));
|
|
20
19
|
const CryptoGraphy_helper_1 = __importDefault(require("./CryptoGraphy.helper"));
|
|
21
20
|
const Converter_helper_1 = __importDefault(require("./Converter.helper"));
|
|
22
|
-
/**
|
|
23
|
-
* Helper class for cryptographic operations such as encryption and decryption.
|
|
24
|
-
*/
|
|
25
21
|
class CryptoHelper {
|
|
26
|
-
/**
|
|
27
|
-
* Constructor to initialize the CryptoHelper class.
|
|
28
|
-
* @param encryptionKey - Optional encryption key. If not provided, a default key based on hostname and platform will be used.
|
|
29
|
-
*/
|
|
22
|
+
/** If no encryptionKey is given, falls back to a default key derived from hostname + platform. */
|
|
30
23
|
constructor(encryptionKey) {
|
|
31
|
-
/**
|
|
32
|
-
* Instance of ResponseHelper to handle responses.
|
|
33
|
-
*/
|
|
34
24
|
this.responseHelper = new response_helper_1.default();
|
|
35
|
-
/**
|
|
36
|
-
* Instance of Converter class for converting data formats.
|
|
37
|
-
*/
|
|
38
25
|
this.Converter = new Converter_helper_1.default();
|
|
39
26
|
this.encryptionKey = encryptionKey || `${(0, node_os_1.hostname)()}-${(0, node_os_1.platform)()}`;
|
|
40
27
|
this.responseHelper = new response_helper_1.default();
|
|
41
28
|
this.Cryptography = new CryptoGraphy_helper_1.default(this.encryptionKey);
|
|
42
29
|
this.Converter = new Converter_helper_1.default();
|
|
43
30
|
}
|
|
44
|
-
// methods
|
|
45
|
-
/**
|
|
46
|
-
* Sets a new encryption key.
|
|
47
|
-
* @param encryptionKey - The new encryption key to be set.
|
|
48
|
-
* @returns A promise that resolves to a success response.
|
|
49
|
-
*/
|
|
50
31
|
setEncryptionKey(encryptionKey) {
|
|
51
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
33
|
this.encryptionKey = encryptionKey;
|
|
53
34
|
return this.responseHelper.Success("Encryption key has been set successfully");
|
|
54
35
|
});
|
|
55
36
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Encrypts data asynchronously.
|
|
58
|
-
* @param data - The data to be encrypted.
|
|
59
|
-
* @returns A promise that resolves to the encrypted data as a string.
|
|
60
|
-
*/
|
|
61
37
|
encrypt(data) {
|
|
62
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
39
|
return yield this.Cryptography.Encrypt(data);
|
|
64
40
|
});
|
|
65
41
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Decrypts data asynchronously.
|
|
68
|
-
* @param data - The data to be decrypted.
|
|
69
|
-
* @returns A promise that resolves to the decrypted data as an object.
|
|
70
|
-
*/
|
|
71
42
|
decrypt(data) {
|
|
72
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
73
44
|
return this.Converter.ToObject(yield this.Cryptography.Decrypt(data));
|
|
74
45
|
});
|
|
75
46
|
}
|
|
76
|
-
/**
|
|
77
|
-
* Encrypts data synchronously.
|
|
78
|
-
* @param data - The data to be encrypted.
|
|
79
|
-
* @returns The encrypted data as a string.
|
|
80
|
-
*/
|
|
81
47
|
encryptSync(data) {
|
|
82
48
|
return this.Cryptography.EncryptSync(data);
|
|
83
49
|
}
|
|
84
|
-
/**
|
|
85
|
-
* Decrypts data synchronously.
|
|
86
|
-
* @param data - The data to be decrypted.
|
|
87
|
-
* @returns The decrypted data as an object.
|
|
88
|
-
*/
|
|
89
50
|
decryptSync(data) {
|
|
90
51
|
return this.Converter.ToObject(this.Cryptography.DecryptSync(data));
|
|
91
52
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Crypto.helper.js","sourceRoot":"","sources":["../../source/Helper/Crypto.helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,
|
|
1
|
+
{"version":3,"file":"Crypto.helper.js","sourceRoot":"","sources":["../../source/Helper/Crypto.helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,qCAA6C;AAC7C,wEAA+C;AAE/C,gFAAiD;AACjD,0EAA2C;AAE3C;IAME,kGAAkG;IAClG,YAAY,aAAsB;QALjB,mBAAc,GAAmB,IAAI,yBAAc,EAAE,CAAC;QAEtD,cAAS,GAAG,IAAI,0BAAS,EAAE,CAAC;QAI3C,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,GAAG,IAAA,kBAAQ,GAAE,IAAI,IAAA,kBAAQ,GAAE,EAAE,CAAC;QACpE,IAAI,CAAC,cAAc,GAAG,IAAI,yBAAc,EAAE,CAAC;QAC3C,IAAI,CAAC,YAAY,GAAG,IAAI,6BAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACzD,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,EAAE,CAAC;IACnC,CAAC;IAEY,gBAAgB,CAC3B,aAAqB;;YAErB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;YACnC,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAChC,0CAA0C,CAC3C,CAAC;QACJ,CAAC;KAAA;IAEY,OAAO,CAAC,IAAY;;YAC/B,OAAO,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/C,CAAC;KAAA;IAEY,OAAO,CAAC,IAAY;;YAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACxE,CAAC;KAAA;IAEM,WAAW,CAAC,IAAY;QAC7B,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;IAEM,WAAW,CAAC,IAAY;QAC7B,OAAO,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;IACtE,CAAC;CACF"}
|
|
@@ -1,45 +1,10 @@
|
|
|
1
1
|
import { SuccessInterface, ErrorInterface } from '../config/Interfaces/Helper/response.helper.interface';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* replacing duplicated code in Reader, Update, Delete, and Aggregation operations.
|
|
7
|
-
*
|
|
8
|
-
* @class DocumentLoader
|
|
3
|
+
* Centralizes document-loading logic that used to be duplicated across the Reader,
|
|
4
|
+
* Update, Delete, and Aggregation operations - handles both a direct file list and
|
|
5
|
+
* full directory scanning (filtered to `.axiodb` files), loaded via worker threads.
|
|
9
6
|
*/
|
|
10
7
|
export default class DocumentLoader {
|
|
11
8
|
private static readonly ResponseHelper;
|
|
12
|
-
/**
|
|
13
|
-
* Loads all documents from a collection directory using worker threads
|
|
14
|
-
*
|
|
15
|
-
* This method consolidates the LoadAllBufferRawData logic that was previously
|
|
16
|
-
* duplicated across multiple CRUD operations. It handles both direct file
|
|
17
|
-
* specification and directory scanning with .axiodb file filtering.
|
|
18
|
-
*
|
|
19
|
-
* @param collectionPath - Full path to collection directory
|
|
20
|
-
* @param encryptionKey - Optional encryption key for encrypted documents
|
|
21
|
-
* @param isEncrypted - Whether documents are encrypted (default: false)
|
|
22
|
-
* @param documentFiles - Optional specific file names to load
|
|
23
|
-
* @param includeFileName - Whether to include fileName in result (default: false)
|
|
24
|
-
* @returns Success with document array or Error
|
|
25
|
-
*
|
|
26
|
-
* @example
|
|
27
|
-
* // Load all documents from a collection
|
|
28
|
-
* const result = await DocumentLoader.loadDocuments(
|
|
29
|
-
* '/path/to/collection',
|
|
30
|
-
* undefined,
|
|
31
|
-
* false
|
|
32
|
-
* );
|
|
33
|
-
*
|
|
34
|
-
* @example
|
|
35
|
-
* // Load specific documents with filenames included
|
|
36
|
-
* const result = await DocumentLoader.loadDocuments(
|
|
37
|
-
* '/path/to/collection',
|
|
38
|
-
* 'encryption-key',
|
|
39
|
-
* true,
|
|
40
|
-
* ['doc1.axiodb', 'doc2.axiodb'],
|
|
41
|
-
* true
|
|
42
|
-
* );
|
|
43
|
-
*/
|
|
44
9
|
static loadDocuments(collectionPath: string, encryptionKey?: string, isEncrypted?: boolean, documentFiles?: string[], includeFileName?: boolean): Promise<SuccessInterface | ErrorInterface>;
|
|
45
10
|
}
|
|
@@ -16,59 +16,21 @@ const FolderManager_1 = __importDefault(require("../engine/Filesystem/FolderMana
|
|
|
16
16
|
const BufferLoaderWithWorker_utils_1 = __importDefault(require("../utility/BufferLoaderWithWorker.utils"));
|
|
17
17
|
const response_helper_1 = __importDefault(require("./response.helper"));
|
|
18
18
|
/**
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* replacing duplicated code in Reader, Update, Delete, and Aggregation operations.
|
|
23
|
-
*
|
|
24
|
-
* @class DocumentLoader
|
|
19
|
+
* Centralizes document-loading logic that used to be duplicated across the Reader,
|
|
20
|
+
* Update, Delete, and Aggregation operations - handles both a direct file list and
|
|
21
|
+
* full directory scanning (filtered to `.axiodb` files), loaded via worker threads.
|
|
25
22
|
*/
|
|
26
23
|
class DocumentLoader {
|
|
27
|
-
/**
|
|
28
|
-
* Loads all documents from a collection directory using worker threads
|
|
29
|
-
*
|
|
30
|
-
* This method consolidates the LoadAllBufferRawData logic that was previously
|
|
31
|
-
* duplicated across multiple CRUD operations. It handles both direct file
|
|
32
|
-
* specification and directory scanning with .axiodb file filtering.
|
|
33
|
-
*
|
|
34
|
-
* @param collectionPath - Full path to collection directory
|
|
35
|
-
* @param encryptionKey - Optional encryption key for encrypted documents
|
|
36
|
-
* @param isEncrypted - Whether documents are encrypted (default: false)
|
|
37
|
-
* @param documentFiles - Optional specific file names to load
|
|
38
|
-
* @param includeFileName - Whether to include fileName in result (default: false)
|
|
39
|
-
* @returns Success with document array or Error
|
|
40
|
-
*
|
|
41
|
-
* @example
|
|
42
|
-
* // Load all documents from a collection
|
|
43
|
-
* const result = await DocumentLoader.loadDocuments(
|
|
44
|
-
* '/path/to/collection',
|
|
45
|
-
* undefined,
|
|
46
|
-
* false
|
|
47
|
-
* );
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* // Load specific documents with filenames included
|
|
51
|
-
* const result = await DocumentLoader.loadDocuments(
|
|
52
|
-
* '/path/to/collection',
|
|
53
|
-
* 'encryption-key',
|
|
54
|
-
* true,
|
|
55
|
-
* ['doc1.axiodb', 'doc2.axiodb'],
|
|
56
|
-
* true
|
|
57
|
-
* );
|
|
58
|
-
*/
|
|
59
24
|
static loadDocuments(collectionPath_1, encryptionKey_1) {
|
|
60
25
|
return __awaiter(this, arguments, void 0, function* (collectionPath, encryptionKey, isEncrypted = false, documentFiles, includeFileName = false) {
|
|
61
26
|
try {
|
|
62
27
|
const dataFilesList = [];
|
|
63
28
|
if (documentFiles !== undefined) {
|
|
64
|
-
// Use provided file list
|
|
65
29
|
dataFilesList.push(...documentFiles);
|
|
66
30
|
}
|
|
67
31
|
else {
|
|
68
|
-
// Scan directory for .axiodb files
|
|
69
32
|
const readResponse = yield new FolderManager_1.default().ListDirectory(collectionPath);
|
|
70
33
|
if ("data" in readResponse) {
|
|
71
|
-
// Filter for .axiodb files only
|
|
72
34
|
const axiodbFiles = readResponse.data.filter((file) => file.endsWith(".axiodb"));
|
|
73
35
|
dataFilesList.push(...axiodbFiles);
|
|
74
36
|
}
|
|
@@ -76,7 +38,7 @@ class DocumentLoader {
|
|
|
76
38
|
return this.ResponseHelper.Error("Failed to read directory");
|
|
77
39
|
}
|
|
78
40
|
}
|
|
79
|
-
//
|
|
41
|
+
// Loaded via worker threads for parallelism
|
|
80
42
|
const resultData = yield (0, BufferLoaderWithWorker_utils_1.default)(dataFilesList, encryptionKey, collectionPath, isEncrypted, includeFileName);
|
|
81
43
|
return this.ResponseHelper.Success(resultData);
|
|
82
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentLoader.helper.js","sourceRoot":"","sources":["../../source/Helper/DocumentLoader.helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,uFAA+D;AAC/D,2GAAuE;AACvE,wEAA+C;AAE/C
|
|
1
|
+
{"version":3,"file":"DocumentLoader.helper.js","sourceRoot":"","sources":["../../source/Helper/DocumentLoader.helper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,uFAA+D;AAC/D,2GAAuE;AACvE,wEAA+C;AAE/C;;;;GAIG;AACH,MAAqB,cAAc;IAGjC,MAAM,CAAO,aAAa;6DACxB,cAAsB,EACtB,aAAsB,EACtB,WAAW,GAAY,KAAK,EAC5B,aAAwB,EACxB,eAAe,GAAY,KAAK;YAEhC,IAAI,CAAC;gBACH,MAAM,aAAa,GAAa,EAAE,CAAC;gBAEnC,IAAI,aAAa,KAAK,SAAS,EAAE,CAAC;oBAChC,aAAa,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;gBACvC,CAAC;qBAAM,CAAC;oBACN,MAAM,YAAY,GAAG,MAAM,IAAI,uBAAa,EAAE,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;oBAE7E,IAAI,MAAM,IAAI,YAAY,EAAE,CAAC;wBAC3B,MAAM,WAAW,GAAG,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAY,EAAE,EAAE,CAC5D,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CACzB,CAAC;wBACF,aAAa,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC;oBACrC,CAAC;yBAAM,CAAC;wBACN,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAC;oBAC/D,CAAC;gBACH,CAAC;gBAED,4CAA4C;gBAC5C,MAAM,UAAU,GAAG,MAAM,IAAA,sCAAgB,EACvC,aAAa,EACb,aAAa,EACb,cAAc,EACd,WAAW,EACX,eAAe,CAChB,CAAC;gBAEF,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;YACjD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;KAAA;CACF;AAzCyB,6BAAc,GAAG,IAAI,yBAAc,EAAE,CAAC"}
|
|
@@ -37,20 +37,17 @@ class PathSanitizer {
|
|
|
37
37
|
if (!userInput || typeof userInput !== 'string') {
|
|
38
38
|
throw new Error('Invalid path component: must be a non-empty string');
|
|
39
39
|
}
|
|
40
|
-
// Remove all directory traversal attempts
|
|
41
40
|
let sanitized = userInput
|
|
42
|
-
.replace(/\.\./g, '_') //
|
|
43
|
-
.replace(/\//g, '_') //
|
|
44
|
-
.replace(/\\/g, '_') //
|
|
45
|
-
.replace(/\0/g, '_'); //
|
|
46
|
-
//
|
|
47
|
-
// Note: We preserve dots for file extensions but removed '..' above
|
|
41
|
+
.replace(/\.\./g, '_') // parent directory
|
|
42
|
+
.replace(/\//g, '_') // Unix path separator
|
|
43
|
+
.replace(/\\/g, '_') // Windows path separator
|
|
44
|
+
.replace(/\0/g, '_'); // null bytes
|
|
45
|
+
// Dots are preserved (for file extensions) since '..' was already stripped above
|
|
48
46
|
sanitized = sanitized.replace(/[^a-zA-Z0-9-_.]/g, '_');
|
|
49
|
-
// Prevent empty result
|
|
50
47
|
if (sanitized.length === 0) {
|
|
51
48
|
throw new Error('Invalid path component: results in empty string after sanitization');
|
|
52
49
|
}
|
|
53
|
-
//
|
|
50
|
+
// Avoid producing a hidden file
|
|
54
51
|
if (sanitized.startsWith('.')) {
|
|
55
52
|
sanitized = '_' + sanitized.substring(1);
|
|
56
53
|
}
|
|
@@ -100,11 +97,8 @@ class PathSanitizer {
|
|
|
100
97
|
* // Throws: Security violation (after sanitization and validation)
|
|
101
98
|
*/
|
|
102
99
|
static safePath(basePath, ...components) {
|
|
103
|
-
// Sanitize each component
|
|
104
100
|
const sanitizedComponents = components.map(c => this.sanitizePathComponent(c));
|
|
105
|
-
// Join paths using Node.js path.join (handles platform differences)
|
|
106
101
|
const fullPath = path_1.default.join(basePath, ...sanitizedComponents);
|
|
107
|
-
// Validate final path is within base (defense in depth)
|
|
108
102
|
this.validatePath(basePath, fullPath);
|
|
109
103
|
return fullPath;
|
|
110
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PathSanitizer.helper.js","sourceRoot":"","sources":["../../source/Helper/PathSanitizer.helper.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AAExB;;;;;;;;;;GAUG;AACH;IACE;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,qBAAqB,CAAC,SAAiB;QAC5C,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACxE,CAAC;QAED,
|
|
1
|
+
{"version":3,"file":"PathSanitizer.helper.js","sourceRoot":"","sources":["../../source/Helper/PathSanitizer.helper.ts"],"names":[],"mappings":";;;;;AAAA,gDAAwB;AAExB;;;;;;;;;;GAUG;AACH;IACE;;;;;;;;;;;;;;;;OAgBG;IACH,MAAM,CAAC,qBAAqB,CAAC,SAAiB;QAC5C,IAAI,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,EAAE,CAAC;YAChD,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAC;QACxE,CAAC;QAED,IAAI,SAAS,GAAG,SAAS;aACtB,OAAO,CAAC,OAAO,EAAE,GAAG,CAAC,CAAI,mBAAmB;aAC5C,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAM,sBAAsB;aAC/C,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAM,yBAAyB;aAClD,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,CAAK,aAAa;QAEzC,iFAAiF;QACjF,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;QAEvD,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,oEAAoE,CAAC,CAAC;QACxF,CAAC;QAED,gCAAgC;QAChC,IAAI,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9B,SAAS,GAAG,GAAG,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;QAC3C,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,YAAY,CAAC,QAAgB,EAAE,QAAgB;QACpD,MAAM,YAAY,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC5C,MAAM,YAAY,GAAG,cAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE5C,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;YAC3C,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IAED;;;;;;;;;;;;;;;;;OAiBG;IACH,MAAM,CAAC,QAAQ,CAAC,QAAgB,EAAE,GAAG,UAAoB;QACvD,MAAM,mBAAmB,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;QAC/E,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,mBAAmB,CAAC,CAAC;QAC7D,IAAI,CAAC,YAAY,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAEtC,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -1,56 +1,15 @@
|
|
|
1
1
|
import { ErrorInterface, SuccessInterface } from "../config/Interfaces/Helper/response.helper.interface";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @description A helper class to standardize API responses.
|
|
5
|
-
*
|
|
6
|
-
* @property {number} SucessCode - The HTTP status code for a successful response.
|
|
7
|
-
* @property {number} ErrorCode - The HTTP status code for an error response.
|
|
8
|
-
*
|
|
9
|
-
* @constructor
|
|
10
|
-
* Initializes the ResponseHelper with default status codes.
|
|
11
|
-
*
|
|
12
|
-
* @method Success
|
|
13
|
-
* @async
|
|
14
|
-
* @param {any} [data] - Optional data to include in the success response.
|
|
15
|
-
* @returns {Promise<SuccessInterface>} A promise that resolves to a success response object.
|
|
16
|
-
*
|
|
17
|
-
* @method Error
|
|
18
|
-
* @async
|
|
19
|
-
* @param {string} [message] - Optional error message to include in the error response.
|
|
20
|
-
* @returns {Promise<ErrorInterface>} A promise that resolves to an error response object.
|
|
21
|
-
*/
|
|
22
|
-
/**
|
|
23
|
-
* A helper class for generating standardized success and error response objects.
|
|
24
|
-
*
|
|
25
|
-
* @remarks
|
|
26
|
-
* This class provides methods to generate success and error responses with predefined status codes.
|
|
27
|
-
* It uses the `StatusCodes` enumeration to set the HTTP status codes for success and error responses.
|
|
28
|
-
*
|
|
3
|
+
* Generates standardized success/error response objects.
|
|
29
4
|
* @example
|
|
30
|
-
* ```typescript
|
|
31
5
|
* const responseHelper = new ResponseHelper();
|
|
32
6
|
* const successResponse = await responseHelper.Success({ key: 'value' });
|
|
33
7
|
* const errorResponse = await responseHelper.Error('An error occurred');
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* @public
|
|
37
8
|
*/
|
|
38
9
|
export default class ResponseHelper {
|
|
39
10
|
private SucessCode;
|
|
40
11
|
private ErrorCode;
|
|
41
12
|
constructor();
|
|
42
|
-
/**
|
|
43
|
-
* Generates a success response object.
|
|
44
|
-
*
|
|
45
|
-
* @param data - Optional data to include in the success response.
|
|
46
|
-
* @returns A promise that resolves to a success response object implementing the SuccessInterface.
|
|
47
|
-
*/
|
|
48
13
|
Success(data?: any): Promise<SuccessInterface>;
|
|
49
|
-
/**
|
|
50
|
-
* Generates an error response object.
|
|
51
|
-
*
|
|
52
|
-
* @param {string} [message] - Optional error message to include in the response.
|
|
53
|
-
* @returns {Promise<ErrorInterface>} A promise that resolves to an error response object.
|
|
54
|
-
*/
|
|
55
14
|
Error(message?: any): Promise<ErrorInterface>;
|
|
56
15
|
}
|
|
@@ -9,56 +9,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
// Purpose: Helper class for response.
|
|
13
12
|
const StatusCode_1 = require("../config/Keys/StatusCode");
|
|
14
13
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
15
14
|
/**
|
|
16
|
-
*
|
|
17
|
-
* @description A helper class to standardize API responses.
|
|
18
|
-
*
|
|
19
|
-
* @property {number} SucessCode - The HTTP status code for a successful response.
|
|
20
|
-
* @property {number} ErrorCode - The HTTP status code for an error response.
|
|
21
|
-
*
|
|
22
|
-
* @constructor
|
|
23
|
-
* Initializes the ResponseHelper with default status codes.
|
|
24
|
-
*
|
|
25
|
-
* @method Success
|
|
26
|
-
* @async
|
|
27
|
-
* @param {any} [data] - Optional data to include in the success response.
|
|
28
|
-
* @returns {Promise<SuccessInterface>} A promise that resolves to a success response object.
|
|
29
|
-
*
|
|
30
|
-
* @method Error
|
|
31
|
-
* @async
|
|
32
|
-
* @param {string} [message] - Optional error message to include in the error response.
|
|
33
|
-
* @returns {Promise<ErrorInterface>} A promise that resolves to an error response object.
|
|
34
|
-
*/
|
|
35
|
-
/**
|
|
36
|
-
* A helper class for generating standardized success and error response objects.
|
|
37
|
-
*
|
|
38
|
-
* @remarks
|
|
39
|
-
* This class provides methods to generate success and error responses with predefined status codes.
|
|
40
|
-
* It uses the `StatusCodes` enumeration to set the HTTP status codes for success and error responses.
|
|
41
|
-
*
|
|
15
|
+
* Generates standardized success/error response objects.
|
|
42
16
|
* @example
|
|
43
|
-
* ```typescript
|
|
44
17
|
* const responseHelper = new ResponseHelper();
|
|
45
18
|
* const successResponse = await responseHelper.Success({ key: 'value' });
|
|
46
19
|
* const errorResponse = await responseHelper.Error('An error occurred');
|
|
47
|
-
* ```
|
|
48
|
-
*
|
|
49
|
-
* @public
|
|
50
20
|
*/
|
|
51
21
|
class ResponseHelper {
|
|
52
22
|
constructor() {
|
|
53
23
|
this.SucessCode = StatusCode_1.StatusCodes.OK;
|
|
54
24
|
this.ErrorCode = StatusCode_1.StatusCodes.INTERNAL_SERVER_ERROR;
|
|
55
25
|
}
|
|
56
|
-
/**
|
|
57
|
-
* Generates a success response object.
|
|
58
|
-
*
|
|
59
|
-
* @param data - Optional data to include in the success response.
|
|
60
|
-
* @returns A promise that resolves to a success response object implementing the SuccessInterface.
|
|
61
|
-
*/
|
|
62
26
|
Success(data) {
|
|
63
27
|
return __awaiter(this, void 0, void 0, function* () {
|
|
64
28
|
return {
|
|
@@ -68,12 +32,6 @@ class ResponseHelper {
|
|
|
68
32
|
};
|
|
69
33
|
});
|
|
70
34
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Generates an error response object.
|
|
73
|
-
*
|
|
74
|
-
* @param {string} [message] - Optional error message to include in the response.
|
|
75
|
-
* @returns {Promise<ErrorInterface>} A promise that resolves to an error response object.
|
|
76
|
-
*/
|
|
77
35
|
Error(message) {
|
|
78
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
37
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"response.helper.js","sourceRoot":"","sources":["../../source/Helper/response.helper.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"response.helper.js","sourceRoot":"","sources":["../../source/Helper/response.helper.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,0DAAwD;AAMxD,uDAAuD;AACvD;;;;;;GAMG;AACH;IAIE;QACE,IAAI,CAAC,UAAU,GAAG,wBAAW,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,wBAAW,CAAC,qBAAqB,CAAC;IACrD,CAAC;IAEY,OAAO,CAAC,IAAU;;YAC7B,OAAO;gBACL,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,MAAM,EAAE,IAAI;gBACZ,IAAI,EAAE,IAAI;aACX,CAAC;QACJ,CAAC;KAAA;IAEY,KAAK,CAAC,OAAa;;YAC9B,OAAO;gBACL,UAAU,EAAE,IAAI,CAAC,SAAS;gBAC1B,MAAM,EAAE,KAAK;gBACb,OAAO,EAAE,OAAO;aACjB,CAAC;QACJ,CAAC;KAAA;CACF"}
|