axiodb 1.0.0
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/LICENSE +21 -0
- package/README.md +29 -0
- package/eslint.config.mjs +10 -0
- package/lib/Helper/response.helper.d.ts +56 -0
- package/lib/Helper/response.helper.js +88 -0
- package/lib/Helper/response.helper.js.map +1 -0
- package/lib/Models/DataTypes.models.d.ts +26 -0
- package/lib/Models/DataTypes.models.js +36 -0
- package/lib/Models/DataTypes.models.js.map +1 -0
- package/lib/Models/validator.models.d.ts +9 -0
- package/lib/Models/validator.models.js +37 -0
- package/lib/Models/validator.models.js.map +1 -0
- package/lib/Operation/Indexation.operation.d.ts +23 -0
- package/lib/Operation/Indexation.operation.js +83 -0
- package/lib/Operation/Indexation.operation.js.map +1 -0
- package/lib/Storage/FileManager.d.ts +100 -0
- package/lib/Storage/FileManager.js +226 -0
- package/lib/Storage/FileManager.js.map +1 -0
- package/lib/Storage/FolderManager.d.ts +65 -0
- package/lib/Storage/FolderManager.js +166 -0
- package/lib/Storage/FolderManager.js.map +1 -0
- package/lib/Web/DBstatusApi.d.ts +0 -0
- package/lib/Web/DBstatusApi.js +2 -0
- package/lib/Web/DBstatusApi.js.map +1 -0
- package/lib/config/DB.d.ts +40 -0
- package/lib/config/DB.js +29 -0
- package/lib/config/DB.js.map +1 -0
- package/lib/config/Interfaces/Helper/response.helper.interface.d.ts +10 -0
- package/lib/config/Interfaces/Helper/response.helper.interface.js +4 -0
- package/lib/config/Interfaces/Helper/response.helper.interface.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Ankan Saha
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# AxioDB
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/axiodb)
|
|
4
|
+
|
|
5
|
+
AxioDB is a JSON-based database management system built using Node.js streams, designed to offer an all-in-one solution for data management. It provides a flexible and efficient way to handle data storage, retrieval, and manipulation without the need for a traditional database setup.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Custom Schemas:** Define your own data schemas for structured data management.
|
|
10
|
+
- **Data Manipulation:** Easily perform operations like create, read, update, and delete (CRUD) on your JSON files.
|
|
11
|
+
- **Query Capabilities:** Support for advanced querying with methods like `find()`, `skip()`, and `limit()`.
|
|
12
|
+
- **Stream Support:** Utilize Node.js streams for efficient data reading and writing.
|
|
13
|
+
- **Custom Encryption:** Implement your own encryption algorithms to secure sensitive data.
|
|
14
|
+
- **DaaS (Data as a Service):** Easily integrate your data management capabilities into a DaaS model.
|
|
15
|
+
|
|
16
|
+
## Getting Started
|
|
17
|
+
|
|
18
|
+
### Prerequisites
|
|
19
|
+
|
|
20
|
+
- Node.js (v14 or higher)
|
|
21
|
+
- npm (v6 or higher)
|
|
22
|
+
|
|
23
|
+
### Installation
|
|
24
|
+
|
|
25
|
+
To install AxioDB, run the following command:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install axiodb@latest --save
|
|
29
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import globals from 'globals'
|
|
2
|
+
import pluginJs from '@eslint/js'
|
|
3
|
+
import tseslint from 'typescript-eslint'
|
|
4
|
+
|
|
5
|
+
export default [
|
|
6
|
+
{ files: ['**/*.{js,mjs,cjs,ts}'] },
|
|
7
|
+
{ languageOptions: { globals: globals.browser } },
|
|
8
|
+
pluginJs.configs.recommended,
|
|
9
|
+
...tseslint.configs.recommended
|
|
10
|
+
]
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ErrorInterface, SuccessInterface } from "../config/Interfaces/Helper/response.helper.interface";
|
|
2
|
+
/**
|
|
3
|
+
* @class ResponseHelper
|
|
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
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```typescript
|
|
31
|
+
* const responseHelper = new ResponseHelper();
|
|
32
|
+
* const successResponse = await responseHelper.Success({ key: 'value' });
|
|
33
|
+
* const errorResponse = await responseHelper.Error('An error occurred');
|
|
34
|
+
* ```
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export default class ResponseHelper {
|
|
39
|
+
private SucessCode;
|
|
40
|
+
private ErrorCode;
|
|
41
|
+
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
|
+
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
|
+
Error(message?: any): Promise<ErrorInterface>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
// Purpose: Helper class for response.
|
|
13
|
+
const outers_1 = require("outers");
|
|
14
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
15
|
+
/**
|
|
16
|
+
* @class ResponseHelper
|
|
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
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const responseHelper = new ResponseHelper();
|
|
45
|
+
* const successResponse = await responseHelper.Success({ key: 'value' });
|
|
46
|
+
* const errorResponse = await responseHelper.Error('An error occurred');
|
|
47
|
+
* ```
|
|
48
|
+
*
|
|
49
|
+
* @public
|
|
50
|
+
*/
|
|
51
|
+
class ResponseHelper {
|
|
52
|
+
constructor() {
|
|
53
|
+
this.SucessCode = outers_1.StatusCodes.OK;
|
|
54
|
+
this.ErrorCode = outers_1.StatusCodes.INTERNAL_SERVER_ERROR;
|
|
55
|
+
}
|
|
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
|
+
Success(data) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
return {
|
|
65
|
+
statusCode: this.SucessCode,
|
|
66
|
+
status: true,
|
|
67
|
+
data: data,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
}
|
|
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
|
+
Error(message) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
return {
|
|
80
|
+
statusCode: this.ErrorCode,
|
|
81
|
+
status: false,
|
|
82
|
+
message: message,
|
|
83
|
+
};
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.default = ResponseHelper;
|
|
88
|
+
//# sourceMappingURL=response.helper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.helper.js","sourceRoot":"","sources":["../../source/Helper/response.helper.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,sCAAsC;AACtC,mCAAqC;AAQrC,uDAAuD;AACvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH;;;;;;;;;;;;;;;GAeG;AACH,MAAqB,cAAc;IAKjC;QACE,IAAI,CAAC,UAAU,GAAG,oBAAW,CAAC,EAAE,CAAC;QACjC,IAAI,CAAC,SAAS,GAAG,oBAAW,CAAC,qBAAqB,CAAC;IACrD,CAAC;IAED;;;;;OAKG;IACU,OAAO,CAAC,IAAU;;YAC7B,OAAO;gBACL,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,MAAM,EAAE,IAAI;gBACZ,IAAI,EAAE,IAAI;aACX,CAAC;QACJ,CAAC;KAAA;IAED;;;;;OAKG;IACU,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;AArCD,iCAqCC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import Joi from "joi";
|
|
2
|
+
export declare const SchemaTypes: {
|
|
3
|
+
string: <TSchema = string>() => Joi.StringSchema<TSchema>;
|
|
4
|
+
number: <TSchema = number>() => Joi.NumberSchema<TSchema>;
|
|
5
|
+
boolean: <TSchema = boolean>() => Joi.BooleanSchema<TSchema>;
|
|
6
|
+
object: <TSchema = any, isStrict = false, T = TSchema>(schema?: Joi.SchemaMap<T, isStrict>) => Joi.ObjectSchema<TSchema>;
|
|
7
|
+
array: <TSchema = any[]>() => Joi.ArraySchema<TSchema>;
|
|
8
|
+
date: <TSchema = Date>() => Joi.DateSchema<TSchema>;
|
|
9
|
+
binary: <TSchema = Buffer>() => Joi.BinarySchema<TSchema>;
|
|
10
|
+
func: <TSchema = Function>() => Joi.FunctionSchema<TSchema>;
|
|
11
|
+
ref: (key: string, options?: Joi.ReferenceOptions) => Joi.Reference;
|
|
12
|
+
any: <TSchema = any>() => Joi.AnySchema<TSchema>;
|
|
13
|
+
alphanum: () => Joi.StringSchema<string>;
|
|
14
|
+
email: (options?: Joi.EmailOptions) => Joi.StringSchema<string>;
|
|
15
|
+
guid: (options?: Joi.GuidOptions) => Joi.StringSchema<string>;
|
|
16
|
+
ip: (options?: Joi.IpOptions) => Joi.StringSchema<string>;
|
|
17
|
+
uri: (options?: Joi.UriOptions) => Joi.StringSchema<string>;
|
|
18
|
+
max: (limit: number | Joi.Reference) => Joi.NumberSchema<number>;
|
|
19
|
+
min: (limit: number | Joi.Reference) => Joi.NumberSchema<number>;
|
|
20
|
+
length: (limit: number | Joi.Reference) => Joi.StringSchema<string>;
|
|
21
|
+
pattern: (regex: RegExp) => Joi.StringSchema<string>;
|
|
22
|
+
required: () => Joi.Schema<any>;
|
|
23
|
+
optional: () => Joi.Schema<any>;
|
|
24
|
+
allow: (values: any[]) => Joi.Schema<any>;
|
|
25
|
+
valid: (values: any[]) => Joi.Schema<any>;
|
|
26
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SchemaTypes = void 0;
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
8
|
+
const joi_1 = __importDefault(require("joi"));
|
|
9
|
+
// Create an object to hold all Joi types under the name SchemaTypes
|
|
10
|
+
exports.SchemaTypes = {
|
|
11
|
+
string: joi_1.default.string,
|
|
12
|
+
number: joi_1.default.number,
|
|
13
|
+
boolean: joi_1.default.boolean,
|
|
14
|
+
object: joi_1.default.object,
|
|
15
|
+
array: joi_1.default.array,
|
|
16
|
+
date: joi_1.default.date,
|
|
17
|
+
binary: joi_1.default.binary,
|
|
18
|
+
func: joi_1.default.func,
|
|
19
|
+
ref: joi_1.default.ref,
|
|
20
|
+
any: joi_1.default.any,
|
|
21
|
+
// Add additional types from Joi if needed
|
|
22
|
+
alphanum: joi_1.default.string().alphanum,
|
|
23
|
+
email: joi_1.default.string().email,
|
|
24
|
+
guid: joi_1.default.string().guid,
|
|
25
|
+
ip: joi_1.default.string().ip,
|
|
26
|
+
uri: joi_1.default.string().uri,
|
|
27
|
+
max: (limit) => joi_1.default.number().max(limit),
|
|
28
|
+
min: (limit) => joi_1.default.number().min(limit),
|
|
29
|
+
length: (limit) => joi_1.default.string().length(limit),
|
|
30
|
+
pattern: (regex) => joi_1.default.string().pattern(regex),
|
|
31
|
+
required: () => joi_1.default.required(),
|
|
32
|
+
optional: () => joi_1.default.optional(),
|
|
33
|
+
allow: (values) => joi_1.default.allow(values),
|
|
34
|
+
valid: (values) => joi_1.default.valid(values),
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=DataTypes.models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DataTypes.models.js","sourceRoot":"","sources":["../../source/Models/DataTypes.models.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAuD;AACvD,8CAAsB;AAEtB,oEAAoE;AACvD,QAAA,WAAW,GAAG;IACzB,MAAM,EAAE,aAAG,CAAC,MAAM;IAClB,MAAM,EAAE,aAAG,CAAC,MAAM;IAClB,OAAO,EAAE,aAAG,CAAC,OAAO;IACpB,MAAM,EAAE,aAAG,CAAC,MAAM;IAClB,KAAK,EAAE,aAAG,CAAC,KAAK;IAChB,IAAI,EAAE,aAAG,CAAC,IAAI;IACd,MAAM,EAAE,aAAG,CAAC,MAAM;IAClB,IAAI,EAAE,aAAG,CAAC,IAAI;IACd,GAAG,EAAE,aAAG,CAAC,GAAG;IACZ,GAAG,EAAE,aAAG,CAAC,GAAG;IACZ,0CAA0C;IAC1C,QAAQ,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,QAAQ;IAC/B,KAAK,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,KAAK;IACzB,IAAI,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,IAAI;IACvB,EAAE,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,EAAE;IACnB,GAAG,EAAE,aAAG,CAAC,MAAM,EAAE,CAAC,GAAG;IACrB,GAAG,EAAE,CAAC,KAA6B,EAAE,EAAE,CAAC,aAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC;IAC/D,GAAG,EAAE,CAAC,KAA6B,EAAE,EAAE,CAAC,aAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC;IAC/D,MAAM,EAAE,CAAC,KAA6B,EAAE,EAAE,CAAC,aAAG,CAAC,MAAM,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC;IACrE,OAAO,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,aAAG,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;IACvD,QAAQ,EAAE,GAAG,EAAE,CAAC,aAAG,CAAC,QAAQ,EAAE;IAC9B,QAAQ,EAAE,GAAG,EAAE,CAAC,aAAG,CAAC,QAAQ,EAAE;IAC9B,KAAK,EAAE,CAAC,MAAa,EAAE,EAAE,CAAC,aAAG,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3C,KAAK,EAAE,CAAC,MAAa,EAAE,EAAE,CAAC,aAAG,CAAC,KAAK,CAAC,MAAM,CAAC;CAC5C,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Schema } from "joi";
|
|
2
|
+
/**
|
|
3
|
+
* Validates the provided data against the given Joi schema.
|
|
4
|
+
*
|
|
5
|
+
* @param dataSchema - The Joi schema to validate against.
|
|
6
|
+
* @param data - The data to be validated.
|
|
7
|
+
* @returns A promise that resolves with the validated data if validation is successful, or rejects with a validation error.
|
|
8
|
+
*/
|
|
9
|
+
export default function schemaValidate(dataSchema: Schema, data: any): Promise<any>;
|
|
@@ -0,0 +1,37 @@
|
|
|
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 = schemaValidate;
|
|
16
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
17
|
+
const joi_1 = __importDefault(require("joi")); // Ensure to import Joi correctly
|
|
18
|
+
/**
|
|
19
|
+
* Validates the provided data against the given Joi schema.
|
|
20
|
+
*
|
|
21
|
+
* @param dataSchema - The Joi schema to validate against.
|
|
22
|
+
* @param data - The data to be validated.
|
|
23
|
+
* @returns A promise that resolves with the validated data if validation is successful, or rejects with a validation error.
|
|
24
|
+
*/
|
|
25
|
+
function schemaValidate(dataSchema, data) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
try {
|
|
28
|
+
// Use Joi.object() correctly to wrap the schema and validate data.
|
|
29
|
+
const joiSchema = joi_1.default.object(dataSchema); // Converts the provided schema to a Joi object
|
|
30
|
+
return yield joiSchema.validateAsync(data); // Validate the actual data against the schema
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
return error;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=validator.models.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator.models.js","sourceRoot":"","sources":["../../source/Models/validator.models.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAUA,iCAQC;AAlBD,uDAAuD;AACvD,8CAAkC,CAAC,iCAAiC;AAEpE;;;;;;GAMG;AACH,SAA8B,cAAc,CAAC,UAAkB,EAAE,IAAS;;QACxE,IAAI,CAAC;YACH,mEAAmE;YACnE,MAAM,SAAS,GAAG,aAAG,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,+CAA+C;YACzF,OAAO,MAAM,SAAS,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,8CAA8C;QAC5F,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export default class Configure {
|
|
2
|
+
#private;
|
|
3
|
+
private readonly Schema;
|
|
4
|
+
private isEncrypted;
|
|
5
|
+
private readonly clusterName;
|
|
6
|
+
private readonly currentPATH;
|
|
7
|
+
constructor(Schema: object | any, isEncrypted?: boolean, ClusterName?: string);
|
|
8
|
+
getSchema(): object | any;
|
|
9
|
+
EncryptionStatus(): boolean;
|
|
10
|
+
getEncryptionKey(): string;
|
|
11
|
+
setEncryptionKey(key: string): void;
|
|
12
|
+
setEncryptionStatus(status: boolean): void;
|
|
13
|
+
getConfiguration(): object | any;
|
|
14
|
+
/**
|
|
15
|
+
* Creates the root directory for the tree structure.
|
|
16
|
+
*
|
|
17
|
+
* This method initializes the root directory using the cluster name.
|
|
18
|
+
* It utilizes the FolderManager to create the directory asynchronously.
|
|
19
|
+
*
|
|
20
|
+
* @returns {Promise<void>} A promise that resolves when the directory is created.
|
|
21
|
+
*/
|
|
22
|
+
private CreateTreeRoot;
|
|
23
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
5
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
6
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
7
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
8
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
9
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
13
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
14
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
15
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
16
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17
|
+
};
|
|
18
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
19
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
20
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
21
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
22
|
+
};
|
|
23
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
24
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
25
|
+
};
|
|
26
|
+
var _Configure_encryptionKey;
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
// Import Libraries
|
|
29
|
+
const DB_1 = require("../config/DB");
|
|
30
|
+
const path_1 = __importDefault(require("path"));
|
|
31
|
+
class Configure {
|
|
32
|
+
constructor(Schema, isEncrypted = false, ClusterName = DB_1.DBMS_Name) {
|
|
33
|
+
_Configure_encryptionKey.set(this, void 0); // Private Property
|
|
34
|
+
this.Schema = Schema;
|
|
35
|
+
this.isEncrypted = isEncrypted;
|
|
36
|
+
__classPrivateFieldSet(this, _Configure_encryptionKey, DB_1.DBMS_Name, "f");
|
|
37
|
+
this.clusterName = ClusterName;
|
|
38
|
+
this.currentPATH = path_1.default.resolve(".");
|
|
39
|
+
this.CreateTreeRoot(); // Create
|
|
40
|
+
}
|
|
41
|
+
// Configure Method
|
|
42
|
+
getSchema() {
|
|
43
|
+
return this.Schema;
|
|
44
|
+
}
|
|
45
|
+
EncryptionStatus() {
|
|
46
|
+
return this.isEncrypted;
|
|
47
|
+
}
|
|
48
|
+
getEncryptionKey() {
|
|
49
|
+
return __classPrivateFieldGet(this, _Configure_encryptionKey, "f");
|
|
50
|
+
}
|
|
51
|
+
setEncryptionKey(key) {
|
|
52
|
+
__classPrivateFieldSet(this, _Configure_encryptionKey, key, "f");
|
|
53
|
+
}
|
|
54
|
+
setEncryptionStatus(status) {
|
|
55
|
+
this.isEncrypted = status;
|
|
56
|
+
}
|
|
57
|
+
getConfiguration() {
|
|
58
|
+
return {
|
|
59
|
+
Schema: this.getSchema(),
|
|
60
|
+
Encryption: {
|
|
61
|
+
Status: this.EncryptionStatus(),
|
|
62
|
+
Key: this.getEncryptionKey(),
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
// Internal Functions
|
|
67
|
+
/**
|
|
68
|
+
* Creates the root directory for the tree structure.
|
|
69
|
+
*
|
|
70
|
+
* This method initializes the root directory using the cluster name.
|
|
71
|
+
* It utilizes the FolderManager to create the directory asynchronously.
|
|
72
|
+
*
|
|
73
|
+
* @returns {Promise<void>} A promise that resolves when the directory is created.
|
|
74
|
+
*/
|
|
75
|
+
CreateTreeRoot() {
|
|
76
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
+
yield new DB_1.FolderManager().CreateDirectory(`${this.currentPATH}/${this.clusterName}`);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
_Configure_encryptionKey = new WeakMap();
|
|
82
|
+
exports.default = Configure;
|
|
83
|
+
//# sourceMappingURL=Indexation.operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Indexation.operation.js","sourceRoot":"","sources":["../../source/Operation/Indexation.operation.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;;;;;;;;;;;;;;;;;;;;;;;;AAEvD,mBAAmB;AACnB,qCAAwD;AACxD,gDAAwB;AAExB,MAAqB,SAAS;IAQ5B,YACE,MAAoB,EACpB,WAAW,GAAG,KAAK,EACnB,cAAsB,cAAS;QAPjC,2CAAuB,CAAC,mBAAmB;QASzC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,uBAAA,IAAI,4BAAkB,cAAS,MAAA,CAAC;QAChC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,cAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,CAAC,cAAc,EAAE,CAAC,CAAC,SAAS;IAClC,CAAC;IAED,mBAAmB;IACZ,SAAS;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAEM,gBAAgB;QACrB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAEM,gBAAgB;QACrB,OAAO,uBAAA,IAAI,gCAAe,CAAC;IAC7B,CAAC;IAEM,gBAAgB,CAAC,GAAW;QACjC,uBAAA,IAAI,4BAAkB,GAAG,MAAA,CAAC;IAC5B,CAAC;IAEM,mBAAmB,CAAC,MAAe;QACxC,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;IAC5B,CAAC;IAEM,gBAAgB;QACrB,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE;YACxB,UAAU,EAAE;gBACV,MAAM,EAAE,IAAI,CAAC,gBAAgB,EAAE;gBAC/B,GAAG,EAAE,IAAI,CAAC,gBAAgB,EAAE;aAC7B;SACF,CAAC;IACJ,CAAC;IAED,qBAAqB;IACrB;;;;;;;OAOG;IACW,cAAc;;YAC1B,MAAM,IAAI,kBAAa,EAAE,CAAC,eAAe,CACvC,GAAG,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,WAAW,EAAE,CAC1C,CAAC;QACJ,CAAC;KAAA;CACF;;kBAlEoB,SAAS"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import FileSystemSync from "fs";
|
|
2
|
+
import { ErrorInterface, SuccessInterface } from "../config/Interfaces/Helper/response.helper.interface";
|
|
3
|
+
/**
|
|
4
|
+
* Class responsible for managing file operations.
|
|
5
|
+
*/
|
|
6
|
+
export default class FileManager {
|
|
7
|
+
/**
|
|
8
|
+
* Reference to the file system module.
|
|
9
|
+
*/
|
|
10
|
+
private readonly fileSystem;
|
|
11
|
+
private readonly fileSystemSync;
|
|
12
|
+
private readonly responseHelper;
|
|
13
|
+
/**
|
|
14
|
+
* Initializes a new instance of the FileManager class.
|
|
15
|
+
*/
|
|
16
|
+
constructor();
|
|
17
|
+
/**
|
|
18
|
+
* Writes data to a file at the specified path.
|
|
19
|
+
*
|
|
20
|
+
* @param path - The path where the file will be written.
|
|
21
|
+
* @param data - The data to write to the file.
|
|
22
|
+
* @returns A promise that resolves when the file has been written.
|
|
23
|
+
*/
|
|
24
|
+
WriteFile(path: string, data: string): Promise<SuccessInterface | ErrorInterface>;
|
|
25
|
+
/**
|
|
26
|
+
* Reads data from a file at the specified path.
|
|
27
|
+
*
|
|
28
|
+
* @param path - The path of the file to read.
|
|
29
|
+
* @returns A promise that resolves with the data read from the file.
|
|
30
|
+
*/
|
|
31
|
+
ReadFile(path: string): Promise<SuccessInterface | ErrorInterface>;
|
|
32
|
+
/**
|
|
33
|
+
* Deletes a file at the specified path.
|
|
34
|
+
*
|
|
35
|
+
* @param path - The path of the file to delete.
|
|
36
|
+
* @returns A promise that resolves when the file has been deleted.
|
|
37
|
+
*/
|
|
38
|
+
DeleteFile(path: string): Promise<SuccessInterface | ErrorInterface>;
|
|
39
|
+
/**
|
|
40
|
+
* Checks if a file exists at the specified path.
|
|
41
|
+
*
|
|
42
|
+
* @param path - The path of the file to check.
|
|
43
|
+
* @returns A promise that resolves with a boolean indicating if the file exists.
|
|
44
|
+
*/
|
|
45
|
+
FileExists(path: string): Promise<SuccessInterface | ErrorInterface>;
|
|
46
|
+
/**
|
|
47
|
+
* Creates a new file at the specified path.
|
|
48
|
+
*
|
|
49
|
+
* @param path - The path of the file to create.
|
|
50
|
+
* @returns A promise that resolves when the file has been created.
|
|
51
|
+
*/
|
|
52
|
+
CreateFile(path: string): Promise<SuccessInterface | ErrorInterface>;
|
|
53
|
+
/**
|
|
54
|
+
* Locks a file at the specified path.
|
|
55
|
+
*
|
|
56
|
+
* @param path - The path of the file to lock.
|
|
57
|
+
* @returns A promise that resolves when the file has been locked.
|
|
58
|
+
*/
|
|
59
|
+
LockFile(path: string): Promise<SuccessInterface | ErrorInterface>;
|
|
60
|
+
/**
|
|
61
|
+
* Unlocks a file at the specified path.
|
|
62
|
+
*
|
|
63
|
+
* @param path - The path of the file to unlock.
|
|
64
|
+
* @returns A promise that resolves when the file has been unlocked.
|
|
65
|
+
*/
|
|
66
|
+
UnlockFile(path: string): Promise<SuccessInterface | ErrorInterface>;
|
|
67
|
+
/**
|
|
68
|
+
* Moves a file from the specified old path to the new path.
|
|
69
|
+
*
|
|
70
|
+
* @param oldPath - The current path of the file to be moved.
|
|
71
|
+
* @param newPath - The destination path where the file should be moved.
|
|
72
|
+
* @returns A promise that resolves to a SuccessInterface if the file is moved successfully,
|
|
73
|
+
* or an ErrorInterface if an error occurs during the move operation.
|
|
74
|
+
*/
|
|
75
|
+
MoveFile(oldPath: string, newPath: string): Promise<SuccessInterface | ErrorInterface>;
|
|
76
|
+
/**
|
|
77
|
+
* Checks if a file is locked by examining its file mode.
|
|
78
|
+
*
|
|
79
|
+
* @param path - The path to the file to check.
|
|
80
|
+
* @returns A promise that resolves to a `SuccessInterface` if the file is locked,
|
|
81
|
+
* or an `ErrorInterface` if an error occurs.
|
|
82
|
+
*
|
|
83
|
+
* The file is considered locked if its mode (permissions) ends with "400".
|
|
84
|
+
*/
|
|
85
|
+
IsFileLocked(path: string): Promise<SuccessInterface | ErrorInterface>;
|
|
86
|
+
/**
|
|
87
|
+
* Creates a read stream for the file at the specified path.
|
|
88
|
+
*
|
|
89
|
+
* @param path - The path of the file to read.
|
|
90
|
+
* @returns A read stream for the file.
|
|
91
|
+
*/
|
|
92
|
+
CreateReadStream(path: string): Promise<ErrorInterface | FileSystemSync.ReadStream>;
|
|
93
|
+
/**
|
|
94
|
+
* Creates a write stream for the file at the specified path.
|
|
95
|
+
*
|
|
96
|
+
* @param path - The path of the file to write.
|
|
97
|
+
* @returns A write stream for the file.
|
|
98
|
+
*/
|
|
99
|
+
CreateWriteStream(path: string): Promise<ErrorInterface | FileSystemSync.WriteStream>;
|
|
100
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
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 promises_1 = __importDefault(require("fs/promises"));
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
// Import Helpers
|
|
18
|
+
const response_helper_1 = __importDefault(require("../Helper/response.helper"));
|
|
19
|
+
/**
|
|
20
|
+
* Class responsible for managing file operations.
|
|
21
|
+
*/
|
|
22
|
+
class FileManager {
|
|
23
|
+
/**
|
|
24
|
+
* Initializes a new instance of the FileManager class.
|
|
25
|
+
*/
|
|
26
|
+
constructor() {
|
|
27
|
+
this.fileSystem = promises_1.default;
|
|
28
|
+
this.fileSystemSync = fs_1.default;
|
|
29
|
+
this.responseHelper = new response_helper_1.default();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Writes data to a file at the specified path.
|
|
33
|
+
*
|
|
34
|
+
* @param path - The path where the file will be written.
|
|
35
|
+
* @param data - The data to write to the file.
|
|
36
|
+
* @returns A promise that resolves when the file has been written.
|
|
37
|
+
*/
|
|
38
|
+
WriteFile(path, data) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
try {
|
|
41
|
+
const SuccesResponse = yield this.fileSystem.writeFile(path, data);
|
|
42
|
+
return yield this.responseHelper.Success(SuccesResponse);
|
|
43
|
+
}
|
|
44
|
+
catch (error) {
|
|
45
|
+
return yield this.responseHelper.Error(error);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Reads data from a file at the specified path.
|
|
51
|
+
*
|
|
52
|
+
* @param path - The path of the file to read.
|
|
53
|
+
* @returns A promise that resolves with the data read from the file.
|
|
54
|
+
*/
|
|
55
|
+
ReadFile(path) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
try {
|
|
58
|
+
const ReadResponse = yield this.fileSystem.readFile(path, "utf-8");
|
|
59
|
+
return yield this.responseHelper.Success(ReadResponse);
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
return yield this.responseHelper.Error(error);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Deletes a file at the specified path.
|
|
68
|
+
*
|
|
69
|
+
* @param path - The path of the file to delete.
|
|
70
|
+
* @returns A promise that resolves when the file has been deleted.
|
|
71
|
+
*/
|
|
72
|
+
DeleteFile(path) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
try {
|
|
75
|
+
const DeleteResponse = yield this.fileSystem.unlink(path);
|
|
76
|
+
return this.responseHelper.Success(DeleteResponse);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
return this.responseHelper.Error(error);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Checks if a file exists at the specified path.
|
|
85
|
+
*
|
|
86
|
+
* @param path - The path of the file to check.
|
|
87
|
+
* @returns A promise that resolves with a boolean indicating if the file exists.
|
|
88
|
+
*/
|
|
89
|
+
FileExists(path) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
try {
|
|
92
|
+
const ExistsResponse = yield this.fileSystem.access(path);
|
|
93
|
+
return this.responseHelper.Success(ExistsResponse);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
return this.responseHelper.Error(error);
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Creates a new file at the specified path.
|
|
102
|
+
*
|
|
103
|
+
* @param path - The path of the file to create.
|
|
104
|
+
* @returns A promise that resolves when the file has been created.
|
|
105
|
+
*/
|
|
106
|
+
CreateFile(path) {
|
|
107
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
108
|
+
try {
|
|
109
|
+
const CreateResponse = yield this.fileSystem.writeFile(path, "");
|
|
110
|
+
return this.responseHelper.Success(CreateResponse);
|
|
111
|
+
}
|
|
112
|
+
catch (error) {
|
|
113
|
+
return this.responseHelper.Error(error);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
// Lock/Unlock Operations
|
|
118
|
+
/**
|
|
119
|
+
* Locks a file at the specified path.
|
|
120
|
+
*
|
|
121
|
+
* @param path - The path of the file to lock.
|
|
122
|
+
* @returns A promise that resolves when the file has been locked.
|
|
123
|
+
*/
|
|
124
|
+
LockFile(path) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
try {
|
|
127
|
+
const LockResponse = yield this.fileSystem.chmod(path, 0o400);
|
|
128
|
+
return this.responseHelper.Success(LockResponse);
|
|
129
|
+
}
|
|
130
|
+
catch (error) {
|
|
131
|
+
return this.responseHelper.Error(error);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Unlocks a file at the specified path.
|
|
137
|
+
*
|
|
138
|
+
* @param path - The path of the file to unlock.
|
|
139
|
+
* @returns A promise that resolves when the file has been unlocked.
|
|
140
|
+
*/
|
|
141
|
+
UnlockFile(path) {
|
|
142
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
143
|
+
try {
|
|
144
|
+
const UnlockResponse = yield this.fileSystem.chmod(path, 0o777);
|
|
145
|
+
return this.responseHelper.Success(UnlockResponse);
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
return this.responseHelper.Error(error);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Moves a file from the specified old path to the new path.
|
|
154
|
+
*
|
|
155
|
+
* @param oldPath - The current path of the file to be moved.
|
|
156
|
+
* @param newPath - The destination path where the file should be moved.
|
|
157
|
+
* @returns A promise that resolves to a SuccessInterface if the file is moved successfully,
|
|
158
|
+
* or an ErrorInterface if an error occurs during the move operation.
|
|
159
|
+
*/
|
|
160
|
+
MoveFile(oldPath, newPath) {
|
|
161
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
162
|
+
try {
|
|
163
|
+
const MoveResponse = yield this.fileSystem.rename(oldPath, newPath);
|
|
164
|
+
return this.responseHelper.Success(MoveResponse);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
return this.responseHelper.Error(error);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Checks if a file is locked by examining its file mode.
|
|
173
|
+
*
|
|
174
|
+
* @param path - The path to the file to check.
|
|
175
|
+
* @returns A promise that resolves to a `SuccessInterface` if the file is locked,
|
|
176
|
+
* or an `ErrorInterface` if an error occurs.
|
|
177
|
+
*
|
|
178
|
+
* The file is considered locked if its mode (permissions) ends with "400".
|
|
179
|
+
*/
|
|
180
|
+
IsFileLocked(path) {
|
|
181
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
182
|
+
try {
|
|
183
|
+
const Stats = yield this.fileSystem.stat(path);
|
|
184
|
+
return this.responseHelper.Success(Stats.mode.toString(8).slice(-3) === "400");
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
return this.responseHelper.Error(error);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
// Stream Operations
|
|
192
|
+
/**
|
|
193
|
+
* Creates a read stream for the file at the specified path.
|
|
194
|
+
*
|
|
195
|
+
* @param path - The path of the file to read.
|
|
196
|
+
* @returns A read stream for the file.
|
|
197
|
+
*/
|
|
198
|
+
CreateReadStream(path) {
|
|
199
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
+
try {
|
|
201
|
+
return this.fileSystemSync.createReadStream(path);
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
return yield this.responseHelper.Error(error);
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Creates a write stream for the file at the specified path.
|
|
210
|
+
*
|
|
211
|
+
* @param path - The path of the file to write.
|
|
212
|
+
* @returns A write stream for the file.
|
|
213
|
+
*/
|
|
214
|
+
CreateWriteStream(path) {
|
|
215
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
216
|
+
try {
|
|
217
|
+
return this.fileSystemSync.createWriteStream(path);
|
|
218
|
+
}
|
|
219
|
+
catch (error) {
|
|
220
|
+
return yield this.responseHelper.Error(error);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
exports.default = FileManager;
|
|
226
|
+
//# sourceMappingURL=FileManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FileManager.js","sourceRoot":"","sources":["../../source/Storage/FileManager.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2DAAqC;AACrC,4CAAgC;AAEhC,iBAAiB;AACjB,gFAAuD;AAMvD;;GAEG;AACH,MAAqB,WAAW;IAQ9B;;OAEG;IACH;QACE,IAAI,CAAC,UAAU,GAAG,kBAAU,CAAC;QAC7B,IAAI,CAAC,cAAc,GAAG,YAAc,CAAC;QACrC,IAAI,CAAC,cAAc,GAAG,IAAI,yBAAc,EAAE,CAAC;IAC7C,CAAC;IAED;;;;;;OAMG;IACU,SAAS,CACpB,IAAY,EACZ,IAAY;;YAEZ,IAAI,CAAC;gBACH,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACnE,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;YAC3D,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;KAAA;IAED;;;;;OAKG;IACU,QAAQ,CACnB,IAAY;;YAEZ,IAAI,CAAC;gBACH,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;gBACnE,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,OA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IAAI,CAAC,IAAI,CAAC,CAAC;gBAC/C,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAChC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAC3C,CAAC;YACJ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;KAAA;IAED,oBAAoB;IAEpB;;;;;OAKG;IACU,gBAAgB,CAC3B,IAAY;;YAEZ,IAAI,CAAC;gBACH,OAAO,IAAI,CAAC,cAAc,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;YACpD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;KAAA;IAED;;;;;OAKG;IACU,iBAAiB,CAC5B,IAAY;;YAEZ,IAAI,CAAC;gBACH,OAAO,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;YACrD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAChD,CAAC;QACH,CAAC;KAAA;CACF;AAxND,8BAwNC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { ErrorInterface, SuccessInterface } from "../config/Interfaces/Helper/response.helper.interface";
|
|
2
|
+
export default class FolderManager {
|
|
3
|
+
private readonly fileSystem;
|
|
4
|
+
private readonly fileSystemSync;
|
|
5
|
+
private readonly responseHelper;
|
|
6
|
+
constructor();
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new directory at the specified path.
|
|
9
|
+
*
|
|
10
|
+
* @param path - The path of the directory to create.
|
|
11
|
+
* @returns A promise that resolves when the directory has been created.
|
|
12
|
+
*/
|
|
13
|
+
CreateDirectory(path: string): Promise<SuccessInterface | ErrorInterface>;
|
|
14
|
+
/**
|
|
15
|
+
* Deletes a directory at the specified path.
|
|
16
|
+
*
|
|
17
|
+
* @param path - The path of the directory to delete.
|
|
18
|
+
* @returns A promise that resolves when the directory has been deleted.
|
|
19
|
+
*/
|
|
20
|
+
DeleteDirectory(path: string): Promise<SuccessInterface | ErrorInterface>;
|
|
21
|
+
/**
|
|
22
|
+
* Checks if a directory exists at the specified path.
|
|
23
|
+
*
|
|
24
|
+
* @param path - The path of the directory to check.
|
|
25
|
+
* @returns A promise that resolves with a boolean indicating if the directory exists.
|
|
26
|
+
*/
|
|
27
|
+
DirectoryExists(path: string): Promise<SuccessInterface | ErrorInterface>;
|
|
28
|
+
/**
|
|
29
|
+
* Lists the contents of a directory at the specified path.
|
|
30
|
+
*
|
|
31
|
+
* @param path - The path of the directory to list.
|
|
32
|
+
* @returns A promise that resolves with an array of directory contents.
|
|
33
|
+
*/
|
|
34
|
+
ListDirectory(path: string): Promise<SuccessInterface | ErrorInterface>;
|
|
35
|
+
/**
|
|
36
|
+
* Moves a directory from the old path to the new path.
|
|
37
|
+
*
|
|
38
|
+
* @param oldPath - The current path of the directory to be moved.
|
|
39
|
+
* @param newPath - The new path where the directory should be moved.
|
|
40
|
+
* @returns A promise that resolves to a SuccessInterface if the operation is successful,
|
|
41
|
+
* or an ErrorInterface if an error occurs.
|
|
42
|
+
*/
|
|
43
|
+
MoveDirectory(oldPath: string, newPath: string): Promise<SuccessInterface | ErrorInterface>;
|
|
44
|
+
/**
|
|
45
|
+
* Locks a directory at the specified path.
|
|
46
|
+
*
|
|
47
|
+
* @param path - The path of the directory to lock.
|
|
48
|
+
* @returns A promise that resolves when the directory has been locked.
|
|
49
|
+
*/
|
|
50
|
+
LockDirectory(path: string): Promise<SuccessInterface | ErrorInterface>;
|
|
51
|
+
/**
|
|
52
|
+
* Unlocks a directory at the specified path.
|
|
53
|
+
*
|
|
54
|
+
* @param path - The path of the directory to unlock.
|
|
55
|
+
* @returns A promise that resolves when the directory has been unlocked.
|
|
56
|
+
*/
|
|
57
|
+
UnlockDirectory(path: string): Promise<SuccessInterface | ErrorInterface>;
|
|
58
|
+
/**
|
|
59
|
+
* Checks if a directory is locked at the specified path.
|
|
60
|
+
*
|
|
61
|
+
* @param path - The path of the directory to check.
|
|
62
|
+
* @returns A promise that resolves with a boolean indicating if the directory is locked.
|
|
63
|
+
*/
|
|
64
|
+
IsDirectoryLocked(path: string): Promise<SuccessInterface | ErrorInterface>;
|
|
65
|
+
}
|
|
@@ -0,0 +1,166 @@
|
|
|
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 promises_1 = __importDefault(require("fs/promises"));
|
|
16
|
+
const fs_1 = __importDefault(require("fs"));
|
|
17
|
+
// Import Helpers
|
|
18
|
+
const response_helper_1 = __importDefault(require("../Helper/response.helper"));
|
|
19
|
+
class FolderManager {
|
|
20
|
+
constructor() {
|
|
21
|
+
this.fileSystem = promises_1.default;
|
|
22
|
+
this.fileSystemSync = fs_1.default;
|
|
23
|
+
this.responseHelper = new response_helper_1.default();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new directory at the specified path.
|
|
27
|
+
*
|
|
28
|
+
* @param path - The path of the directory to create.
|
|
29
|
+
* @returns A promise that resolves when the directory has been created.
|
|
30
|
+
*/
|
|
31
|
+
CreateDirectory(path) {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
try {
|
|
34
|
+
const CreateResponse = yield this.fileSystem.mkdir(path);
|
|
35
|
+
return this.responseHelper.Success(CreateResponse);
|
|
36
|
+
}
|
|
37
|
+
catch (error) {
|
|
38
|
+
return this.responseHelper.Error(error);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Deletes a directory at the specified path.
|
|
44
|
+
*
|
|
45
|
+
* @param path - The path of the directory to delete.
|
|
46
|
+
* @returns A promise that resolves when the directory has been deleted.
|
|
47
|
+
*/
|
|
48
|
+
DeleteDirectory(path) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
try {
|
|
51
|
+
const DeleteResponse = yield this.fileSystem.rmdir(path);
|
|
52
|
+
return this.responseHelper.Success(DeleteResponse);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
return this.responseHelper.Error(error);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Checks if a directory exists at the specified path.
|
|
61
|
+
*
|
|
62
|
+
* @param path - The path of the directory to check.
|
|
63
|
+
* @returns A promise that resolves with a boolean indicating if the directory exists.
|
|
64
|
+
*/
|
|
65
|
+
DirectoryExists(path) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
try {
|
|
68
|
+
const ExistsResponse = yield this.fileSystem.access(path);
|
|
69
|
+
return this.responseHelper.Success(ExistsResponse);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
return this.responseHelper.Error(error);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Lists the contents of a directory at the specified path.
|
|
78
|
+
*
|
|
79
|
+
* @param path - The path of the directory to list.
|
|
80
|
+
* @returns A promise that resolves with an array of directory contents.
|
|
81
|
+
*/
|
|
82
|
+
ListDirectory(path) {
|
|
83
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
84
|
+
try {
|
|
85
|
+
const ListResponse = yield this.fileSystem.readdir(path);
|
|
86
|
+
return this.responseHelper.Success(ListResponse);
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
return this.responseHelper.Error(error);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Moves a directory from the old path to the new path.
|
|
95
|
+
*
|
|
96
|
+
* @param oldPath - The current path of the directory to be moved.
|
|
97
|
+
* @param newPath - The new path where the directory should be moved.
|
|
98
|
+
* @returns A promise that resolves to a SuccessInterface if the operation is successful,
|
|
99
|
+
* or an ErrorInterface if an error occurs.
|
|
100
|
+
*/
|
|
101
|
+
MoveDirectory(oldPath, newPath) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
try {
|
|
104
|
+
const MoveResponse = yield this.fileSystem.rename(oldPath, newPath);
|
|
105
|
+
return this.responseHelper.Success(MoveResponse);
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
return this.responseHelper.Error(error);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Locks a directory at the specified path.
|
|
114
|
+
*
|
|
115
|
+
* @param path - The path of the directory to lock.
|
|
116
|
+
* @returns A promise that resolves when the directory has been locked.
|
|
117
|
+
*/
|
|
118
|
+
LockDirectory(path) {
|
|
119
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
120
|
+
try {
|
|
121
|
+
const LockResponse = yield this.fileSystem.chmod(path, 0o400);
|
|
122
|
+
return this.responseHelper.Success(LockResponse);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
return this.responseHelper.Error(error);
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Unlocks a directory at the specified path.
|
|
131
|
+
*
|
|
132
|
+
* @param path - The path of the directory to unlock.
|
|
133
|
+
* @returns A promise that resolves when the directory has been unlocked.
|
|
134
|
+
*/
|
|
135
|
+
UnlockDirectory(path) {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
137
|
+
try {
|
|
138
|
+
const UnlockResponse = yield this.fileSystem.chmod(path, 0o777);
|
|
139
|
+
return this.responseHelper.Success(UnlockResponse);
|
|
140
|
+
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
return this.responseHelper.Error(error);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Checks if a directory is locked at the specified path.
|
|
148
|
+
*
|
|
149
|
+
* @param path - The path of the directory to check.
|
|
150
|
+
* @returns A promise that resolves with a boolean indicating if the directory is locked.
|
|
151
|
+
*/
|
|
152
|
+
IsDirectoryLocked(path) {
|
|
153
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
154
|
+
try {
|
|
155
|
+
const Stats = yield this.fileSystem.stat(path);
|
|
156
|
+
const IsLocked = Stats.mode.toString(8).slice(-3) === "400";
|
|
157
|
+
return this.responseHelper.Success(IsLocked);
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
return this.responseHelper.Error(error);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
exports.default = FolderManager;
|
|
166
|
+
//# sourceMappingURL=FolderManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FolderManager.js","sourceRoot":"","sources":["../../source/Storage/FolderManager.ts"],"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;gBACH,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;gBAChE,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;YACrD,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;KAAA;IAED;;;;;OAKG;IACU,iBAAiB,CAC5B,IAAY;;YAEZ,IAAI,CAAC;gBACH,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBAC/C,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC;gBAC5D,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;YAC/C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;YAC1C,CAAC;QACH,CAAC;KAAA;CACF;AAvJD,gCAuJC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DBstatusApi.js","sourceRoot":"","sources":["../../source/Web/DBstatusApi.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { SchemaTypes } from "../Models/DataTypes.models";
|
|
2
|
+
import schemaValidate from "../Models/validator.models";
|
|
3
|
+
import FileManager from "../Storage/FileManager";
|
|
4
|
+
import FolderManager from "../Storage/FolderManager";
|
|
5
|
+
import Configure from "../Operation/Indexation.operation";
|
|
6
|
+
export declare const DBMS_Name = "AxioDB";
|
|
7
|
+
export declare const DBMS_File_EXT = ".axiodb";
|
|
8
|
+
export { SchemaTypes, schemaValidate, FileManager, FolderManager, Configure };
|
|
9
|
+
declare const _default: {
|
|
10
|
+
SchemaTypes: {
|
|
11
|
+
string: <TSchema = string>() => import("joi").StringSchema<TSchema>;
|
|
12
|
+
number: <TSchema = number>() => import("joi").NumberSchema<TSchema>;
|
|
13
|
+
boolean: <TSchema = boolean>() => import("joi").BooleanSchema<TSchema>;
|
|
14
|
+
object: <TSchema = any, isStrict = false, T = TSchema>(schema?: import("joi").SchemaMap<T, isStrict>) => import("joi").ObjectSchema<TSchema>;
|
|
15
|
+
array: <TSchema = any[]>() => import("joi").ArraySchema<TSchema>;
|
|
16
|
+
date: <TSchema = Date>() => import("joi").DateSchema<TSchema>;
|
|
17
|
+
binary: <TSchema = Buffer>() => import("joi").BinarySchema<TSchema>;
|
|
18
|
+
func: <TSchema = Function>() => import("joi").FunctionSchema<TSchema>;
|
|
19
|
+
ref: (key: string, options?: import("joi").ReferenceOptions) => import("joi").Reference;
|
|
20
|
+
any: <TSchema = any>() => import("joi").AnySchema<TSchema>;
|
|
21
|
+
alphanum: () => import("joi").StringSchema<string>;
|
|
22
|
+
email: (options?: import("joi").EmailOptions) => import("joi").StringSchema<string>;
|
|
23
|
+
guid: (options?: import("joi").GuidOptions) => import("joi").StringSchema<string>;
|
|
24
|
+
ip: (options?: import("joi").IpOptions) => import("joi").StringSchema<string>;
|
|
25
|
+
uri: (options?: import("joi").UriOptions) => import("joi").StringSchema<string>;
|
|
26
|
+
max: (limit: number | import("joi").Reference) => import("joi").NumberSchema<number>;
|
|
27
|
+
min: (limit: number | import("joi").Reference) => import("joi").NumberSchema<number>;
|
|
28
|
+
length: (limit: number | import("joi").Reference) => import("joi").StringSchema<string>;
|
|
29
|
+
pattern: (regex: RegExp) => import("joi").StringSchema<string>;
|
|
30
|
+
required: () => import("joi").Schema<any>;
|
|
31
|
+
optional: () => import("joi").Schema<any>;
|
|
32
|
+
allow: (values: any[]) => import("joi").Schema<any>;
|
|
33
|
+
valid: (values: any[]) => import("joi").Schema<any>;
|
|
34
|
+
};
|
|
35
|
+
schemaValidate: typeof schemaValidate;
|
|
36
|
+
FileManager: typeof FileManager;
|
|
37
|
+
Configure: typeof Configure;
|
|
38
|
+
FolderManager: typeof FolderManager;
|
|
39
|
+
};
|
|
40
|
+
export default _default;
|
package/lib/config/DB.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Configure = exports.FolderManager = exports.FileManager = exports.schemaValidate = exports.SchemaTypes = exports.DBMS_File_EXT = exports.DBMS_Name = void 0;
|
|
7
|
+
// Import All Required Sub Modules
|
|
8
|
+
const DataTypes_models_1 = require("../Models/DataTypes.models");
|
|
9
|
+
Object.defineProperty(exports, "SchemaTypes", { enumerable: true, get: function () { return DataTypes_models_1.SchemaTypes; } });
|
|
10
|
+
const validator_models_1 = __importDefault(require("../Models/validator.models"));
|
|
11
|
+
exports.schemaValidate = validator_models_1.default;
|
|
12
|
+
const FileManager_1 = __importDefault(require("../Storage/FileManager"));
|
|
13
|
+
exports.FileManager = FileManager_1.default;
|
|
14
|
+
const FolderManager_1 = __importDefault(require("../Storage/FolderManager"));
|
|
15
|
+
exports.FolderManager = FolderManager_1.default;
|
|
16
|
+
const Indexation_operation_1 = __importDefault(require("../Operation/Indexation.operation"));
|
|
17
|
+
exports.Configure = Indexation_operation_1.default;
|
|
18
|
+
// Default Keys
|
|
19
|
+
exports.DBMS_Name = "AxioDB";
|
|
20
|
+
exports.DBMS_File_EXT = ".axiodb";
|
|
21
|
+
// Export With All Sub Modules
|
|
22
|
+
exports.default = {
|
|
23
|
+
SchemaTypes: DataTypes_models_1.SchemaTypes,
|
|
24
|
+
schemaValidate: validator_models_1.default,
|
|
25
|
+
FileManager: FileManager_1.default,
|
|
26
|
+
Configure: Indexation_operation_1.default,
|
|
27
|
+
FolderManager: FolderManager_1.default,
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=DB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DB.js","sourceRoot":"","sources":["../../source/config/DB.ts"],"names":[],"mappings":";;;;;;AAAA,kCAAkC;AAClC,iEAAyD;AAWhD,4FAXA,8BAAW,OAWA;AAVpB,kFAAwD;AAUlC,yBAVf,0BAAc,CAUe;AATpC,yEAAiD;AASX,sBAT/B,qBAAW,CAS+B;AARjD,6EAAqD;AAQF,wBAR5C,uBAAa,CAQ4C;AAPhE,6FAA0D;AAOQ,oBAP3D,8BAAS,CAO2D;AAL3E,eAAe;AACF,QAAA,SAAS,GAAG,QAAQ,CAAC;AACrB,QAAA,aAAa,GAAG,SAAS,CAAC;AAKvC,8BAA8B;AAC9B,kBAAe;IACb,WAAW,EAAX,8BAAW;IACX,cAAc,EAAd,0BAAc;IACd,WAAW,EAAX,qBAAW;IACX,SAAS,EAAT,8BAAS;IACT,aAAa,EAAb,uBAAa;CACd,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"response.helper.interface.js","sourceRoot":"","sources":["../../../../source/config/Interfaces/Helper/response.helper.interface.ts"],"names":[],"mappings":";AAAA,uDAAuD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "axiodb",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "A fast, lightweight, and scalable open-source DBMS for modern apps. Supports JSON-based data storage, simple APIs, and secure data management. Ideal for projects needing efficient and flexible database solutions.",
|
|
5
|
+
"main": "./lib/config/DB.js",
|
|
6
|
+
"types": "./lib/config/DB.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"test": "eslint source/**/*.ts --fix",
|
|
9
|
+
"build": "npm test && tsc",
|
|
10
|
+
"prepare": "npm run build"
|
|
11
|
+
},
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/AnkanSaha/AxioDB.git"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"database",
|
|
18
|
+
"dbms",
|
|
19
|
+
"db",
|
|
20
|
+
"json",
|
|
21
|
+
"json database",
|
|
22
|
+
"json db",
|
|
23
|
+
"json storage",
|
|
24
|
+
"json data storage",
|
|
25
|
+
"json data management"
|
|
26
|
+
],
|
|
27
|
+
"author": "Ankan Saha",
|
|
28
|
+
"license": "MIT",
|
|
29
|
+
"sponsor": {
|
|
30
|
+
"url": "https://github.com/sponsors/AnkanSaha"
|
|
31
|
+
},
|
|
32
|
+
"funding": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/sponsors/AnkanSaha"
|
|
35
|
+
},
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"joi": "^17.13.3",
|
|
38
|
+
"outers": "^8.5.8"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@eslint/js": "^9.11.1",
|
|
42
|
+
"@types/crypto-js": "^4.2.1",
|
|
43
|
+
"eslint": "^8.57.1",
|
|
44
|
+
"fastify": "^5.1.0",
|
|
45
|
+
"globals": "^15.9.0",
|
|
46
|
+
"typescript": "^5.6.2",
|
|
47
|
+
"typescript-eslint": "^8.8.0"
|
|
48
|
+
}
|
|
49
|
+
}
|