axiodb 3.32.114 → 4.32.115
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/Services/CRUD Operation/Create.operation.js +1 -1
- package/lib/Services/CRUD Operation/Create.operation.js.map +1 -1
- package/lib/Services/CRUD Operation/Delete.operation.js +17 -12
- package/lib/Services/CRUD Operation/Delete.operation.js.map +1 -1
- package/lib/Services/CRUD Operation/Reader.operation.js +10 -2
- package/lib/Services/CRUD Operation/Reader.operation.js.map +1 -1
- package/lib/Services/CRUD Operation/Update.operation.js +19 -18
- package/lib/Services/CRUD Operation/Update.operation.js.map +1 -1
- package/lib/Services/Collection/collection.operation.d.ts +22 -0
- package/lib/Services/Collection/collection.operation.js +32 -0
- package/lib/Services/Collection/collection.operation.js.map +1 -1
- package/lib/Services/Database/database.operation.d.ts +26 -0
- package/lib/Services/Database/database.operation.js +52 -0
- package/lib/Services/Database/database.operation.js.map +1 -1
- package/lib/Services/Index/Index.service.d.ts +125 -0
- package/lib/Services/Index/Index.service.js +231 -0
- package/lib/Services/Index/Index.service.js.map +1 -0
- package/lib/Services/Index/InsertIndex.service.d.ts +34 -0
- package/lib/Services/Index/InsertIndex.service.js +79 -0
- package/lib/Services/Index/InsertIndex.service.js.map +1 -0
- package/lib/Services/Index/ReadIndex.service.d.ts +44 -0
- package/lib/Services/Index/ReadIndex.service.js +81 -0
- package/lib/Services/Index/ReadIndex.service.js.map +1 -0
- package/package.json +1 -1
|
@@ -42,7 +42,7 @@ class Insertion {
|
|
|
42
42
|
const documentId = ExistingdocumentId === undefined
|
|
43
43
|
? yield this.generateUniqueDocumentId()
|
|
44
44
|
: ExistingdocumentId;
|
|
45
|
-
const filePath = `${this.path}
|
|
45
|
+
const filePath = `${this.path}/${documentId}${Keys_1.General.DBMS_File_EXT}`;
|
|
46
46
|
// Directly write data to file (no lock/unlock system)
|
|
47
47
|
const WriteResponse = yield new FileManager_1.default().WriteFile(filePath, this.Converter.ToString(data));
|
|
48
48
|
if (WriteResponse.status) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Create.operation.js","sourceRoot":"","sources":["../../../source/Services/CRUD Operation/Create.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,sFAA8D;AAE9D,mCAAoC;AACpC,mFAA0D;AAK1D,iDAAiD;AACjD,qFAAsD;AAEtD;;GAEG;AACH,MAAqB,SAAS;IAK5B;;;;OAIG;IACH,YAAY,cAAsB,EAAE,IAAkB;QACpD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,EAAE,CAAC;IACnC,CAAC;IAED;;;OAGG;IACU,IAAI,CACf,IAAkB,EAClB,kBAA2B;;YAE3B,IAAI,CAAC;gBACH,MAAM,UAAU,GACd,kBAAkB,KAAK,SAAS;oBAC9B,CAAC,CAAC,MAAM,IAAI,CAAC,wBAAwB,EAAE;oBACvC,CAAC,CAAC,kBAAkB,CAAC;gBAEzB,MAAM,QAAQ,GAAG,GAAG,IAAI,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"Create.operation.js","sourceRoot":"","sources":["../../../source/Services/CRUD Operation/Create.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,sFAA8D;AAE9D,mCAAoC;AACpC,mFAA0D;AAK1D,iDAAiD;AACjD,qFAAsD;AAEtD;;GAEG;AACH,MAAqB,SAAS;IAK5B;;;;OAIG;IACH,YAAY,cAAsB,EAAE,IAAkB;QACpD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,EAAE,CAAC;IACnC,CAAC;IAED;;;OAGG;IACU,IAAI,CACf,IAAkB,EAClB,kBAA2B;;YAE3B,IAAI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AAC;QACZ,CAAC;KAAA;CACF;AApED,4BAoEC"}
|
|
@@ -70,7 +70,7 @@ class DeleteOperation {
|
|
|
70
70
|
let ReadResponse; // Read Response Holder
|
|
71
71
|
if (((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.documentId) !== undefined) {
|
|
72
72
|
const FilePath = [
|
|
73
|
-
|
|
73
|
+
`${this.baseQuery.documentId}${Keys_1.General.DBMS_File_EXT}`,
|
|
74
74
|
];
|
|
75
75
|
ReadResponse = yield this.LoadAllBufferRawData(FilePath);
|
|
76
76
|
}
|
|
@@ -174,18 +174,23 @@ class DeleteOperation {
|
|
|
174
174
|
LoadAllBufferRawData(documentIdDirectFile) {
|
|
175
175
|
return __awaiter(this, void 0, void 0, function* () {
|
|
176
176
|
try {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
// Store all files in DataFilesList
|
|
181
|
-
const DataFilesList = documentIdDirectFile !== undefined
|
|
182
|
-
? documentIdDirectFile
|
|
183
|
-
: ReadResponse.data;
|
|
184
|
-
// Read all files from the directory
|
|
185
|
-
const resultData = yield (0, BufferLoaderWithWorker_utils_1.default)(DataFilesList, this.encryptionKey, this.path, this.isEncrypted, true);
|
|
186
|
-
this.allDataWithFileName = resultData; // Store all data with file name
|
|
187
|
-
return this.ResponseHelper.Success(resultData);
|
|
177
|
+
const DataFilesList = [];
|
|
178
|
+
if (documentIdDirectFile !== undefined) {
|
|
179
|
+
documentIdDirectFile.push(...documentIdDirectFile);
|
|
188
180
|
}
|
|
181
|
+
else {
|
|
182
|
+
// Directly read list of files in directory (no lock/unlock system)
|
|
183
|
+
const ReadResponse = yield new FolderManager_1.default().ListDirectory(this.path);
|
|
184
|
+
if ("data" in ReadResponse) {
|
|
185
|
+
// filter with .axiodb files only
|
|
186
|
+
ReadResponse.data = ReadResponse.data.filter((file) => file.endsWith(".axiodb"));
|
|
187
|
+
DataFilesList.push(...ReadResponse.data);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// Read all files from the directory
|
|
191
|
+
const resultData = yield (0, BufferLoaderWithWorker_utils_1.default)(DataFilesList, this.encryptionKey, this.path, this.isEncrypted, true);
|
|
192
|
+
this.allDataWithFileName = resultData; // Store all data with file name
|
|
193
|
+
return this.ResponseHelper.Success(resultData);
|
|
189
194
|
return this.ResponseHelper.Error("Failed to read directory");
|
|
190
195
|
}
|
|
191
196
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Delete.operation.js","sourceRoot":"","sources":["../../../source/Services/CRUD Operation/Delete.operation.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;;;;;;;;;;;;AAMvD,qFAAsD;AACtD,8DAA0D;AAC1D,mFAA0D;AAC1D,sFAA8D;AAC9D,0FAAkE;AAElE,qBAAqB;AACrB,kFAAoD;AACpD,kFAAmD;AACnD,qFAA0D;AAC1D,iDAAiD;AACjD,8GAA0E;AAC1E;;;GAGG;AACH,MAAqB,eAAe;IAalC,YACE,cAAsB,EACtB,IAAY,EACZ,SAAuB,EACvB,cAAuB,KAAK,EAC5B,aAAsB;QARhB,wBAAmB,GAAU,EAAE,CAAC;QAUtC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACf,IAAI,CAAC,cAAc,GAAG,IAAI,yBAAc,EAAE,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,EAAE,CAAC;QACjC,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;YAC9B,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;gBACxB,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAC;YACJ,CAAC;YACD,IAAI,CAAC,cAAc,GAAG,IAAI,4BAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAC,mCAAmC;IACpE,CAAC;IAED,UAAU;IACV;;;;;;;;;;;;;;OAcG;IACU,SAAS;;;YACpB,oFAAoF;YACpF,IAAI,YAAY,CAAC,CAAC,uBAAuB;YACzC,IAAI,CAAA,MAAA,IAAI,CAAC,SAAS,0CAAE,UAAU,MAAK,SAAS,EAAE,CAAC;gBAC7C,MAAM,QAAQ,GAAG;oBACf,
|
|
1
|
+
{"version":3,"file":"Delete.operation.js","sourceRoot":"","sources":["../../../source/Services/CRUD Operation/Delete.operation.ts"],"names":[],"mappings":";AAAA,uDAAuD;;;;;;;;;;;;;;AAMvD,qFAAsD;AACtD,8DAA0D;AAC1D,mFAA0D;AAC1D,sFAA8D;AAC9D,0FAAkE;AAElE,qBAAqB;AACrB,kFAAoD;AACpD,kFAAmD;AACnD,qFAA0D;AAC1D,iDAAiD;AACjD,8GAA0E;AAC1E;;;GAGG;AACH,MAAqB,eAAe;IAalC,YACE,cAAsB,EACtB,IAAY,EACZ,SAAuB,EACvB,cAAuB,KAAK,EAC5B,aAAsB;QARhB,wBAAmB,GAAU,EAAE,CAAC;QAUtC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACf,IAAI,CAAC,cAAc,GAAG,IAAI,yBAAc,EAAE,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,EAAE,CAAC;QACjC,IAAI,IAAI,CAAC,WAAW,KAAK,IA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;6BAAM,CAAC;4BACN,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;wBAC5D,CAAC;oBACH,CAAC;yBAAM,CAAC;wBACN,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,4BAA4B,CAAC,CAAC;oBACjE,CAAC;gBACH,CAAC;YACH,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC;YAC5D,CAAC;QACH,CAAC;KAAA;IAED;;;;OAIG;IACI,IAAI,CAAC,IAAkB;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AAjRD,kCAiRC"}
|
|
@@ -24,6 +24,7 @@ const Keys_1 = require("../../config/Keys/Keys");
|
|
|
24
24
|
const Searcher_utils_1 = __importDefault(require("../../utility/Searcher.utils"));
|
|
25
25
|
const SortData_utils_1 = __importDefault(require("../../utility/SortData.utils"));
|
|
26
26
|
const BufferLoaderWithWorker_utils_1 = __importDefault(require("../../utility/BufferLoaderWithWorker.utils"));
|
|
27
|
+
const ReadIndex_service_1 = require("../Index/ReadIndex.service");
|
|
27
28
|
/**
|
|
28
29
|
* Class representing a read operation.
|
|
29
30
|
*/
|
|
@@ -80,13 +81,18 @@ class Reader {
|
|
|
80
81
|
let ReadResponse; // Read Response Holder
|
|
81
82
|
if (((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.documentId) !== undefined) {
|
|
82
83
|
const FilePath = Array.isArray((_b = this.baseQuery) === null || _b === void 0 ? void 0 : _b.documentId) == true
|
|
83
|
-
? this.baseQuery.documentId.map((id) =>
|
|
84
|
-
: [
|
|
84
|
+
? this.baseQuery.documentId.map((id) => `${id}${Keys_1.General.DBMS_File_EXT}`)
|
|
85
|
+
: [`${this.baseQuery.documentId}${Keys_1.General.DBMS_File_EXT}`];
|
|
85
86
|
ReadResponse = yield this.LoadAllBufferRawData(FilePath);
|
|
86
87
|
// Send the data to the client directly
|
|
87
88
|
return this.ApplySkipAndLimit(ReadResponse.data);
|
|
88
89
|
}
|
|
89
90
|
else {
|
|
91
|
+
const fileNames = yield new ReadIndex_service_1.ReadIndex(this.path).getFileFromIndex(this.baseQuery);
|
|
92
|
+
if (fileNames.length > 0) {
|
|
93
|
+
// Load File Names from Index
|
|
94
|
+
ReadResponse = yield this.LoadAllBufferRawData(fileNames);
|
|
95
|
+
}
|
|
90
96
|
ReadResponse = yield this.LoadAllBufferRawData();
|
|
91
97
|
}
|
|
92
98
|
if ("data" in ReadResponse) {
|
|
@@ -206,6 +212,8 @@ class Reader {
|
|
|
206
212
|
// Directly read list of files in directory (no lock/unlock system)
|
|
207
213
|
const ReadResponse = yield new FolderManager_1.default().ListDirectory(this.path);
|
|
208
214
|
if ("data" in ReadResponse) {
|
|
215
|
+
// filter with .axiodb files only
|
|
216
|
+
ReadResponse.data = ReadResponse.data.filter((file) => file.endsWith(".axiodb"));
|
|
209
217
|
DataFilesList.push(...ReadResponse.data);
|
|
210
218
|
}
|
|
211
219
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Reader.operation.js","sourceRoot":"","sources":["../../../source/Services/CRUD Operation/Reader.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,0FAAkE;AAMlE,qBAAqB;AACrB,qFAA0D;AAC1D,qFAAsD;AACtD,8DAA0D;AAC1D,mFAA0D;AAC1D,qBAAqB;AACrB,iDAAiD;AACjD,kFAAoD;AACpD,kFAAmD;AACnD,8GAA0E;
|
|
1
|
+
{"version":3,"file":"Reader.operation.js","sourceRoot":"","sources":["../../../source/Services/CRUD Operation/Reader.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,0FAAkE;AAMlE,qBAAqB;AACrB,qFAA0D;AAC1D,qFAAsD;AACtD,8DAA0D;AAC1D,mFAA0D;AAC1D,qBAAqB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CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;4BACxD,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;gCAChB,eAAe,CAAC,GAAG,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;4BACxD,CAAC;wBACH,CAAC;oBACH,CAAC;yBAAM,IAAI,UAAU,EAAE,CAAC;wBACtB,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;4BACvB,IAAI,CAAC,CAAC,GAAG,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;gCAC3B,eAAe,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;4BACnC,CAAC;wBACH,CAAC;oBACH,CAAC;yBAAM,CAAC;wBACN,MAAM,IAAI,KAAK,CACb,oEAAoE,CACrE,CAAC;oBACJ,CAAC;oBAED,uDAAuD;oBACvD,WAAW,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;wBAC1B,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;4BAChB,eAAe,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;wBACnC,CAAC;oBACH,CAAC,CAAC,CAAC;oBACH,OAAO,eAAe,CAAC;gBACzB,CAAC,CAAC,CAAC;gBACH,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;oBACjC,SAAS,EAAE,aAAa;iBACzB,CAAC,CAAC;YACL,CAAC;YACD,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC;gBACjC,SAAS,EAAE,SAAS;aACrB,CAAC,CAAC;QACL,CAAC;KAAA;CACF;AAjXD,yBAiXC"}
|
|
@@ -73,7 +73,7 @@ class UpdateOperation {
|
|
|
73
73
|
let ReadResponse; // Read Response Holder
|
|
74
74
|
if (((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.documentId) !== undefined) {
|
|
75
75
|
const FilePath = [
|
|
76
|
-
|
|
76
|
+
`${this.baseQuery.documentId}${Keys_1.General.DBMS_File_EXT}`,
|
|
77
77
|
];
|
|
78
78
|
ReadResponse = yield this.LoadAllBufferRawData(FilePath);
|
|
79
79
|
}
|
|
@@ -100,9 +100,7 @@ class UpdateOperation {
|
|
|
100
100
|
selectedFirstData = SortedData[0]; // Select the first data
|
|
101
101
|
fileName = selectedFirstData === null || selectedFirstData === void 0 ? void 0 : selectedFirstData.fileName; // Get the file name
|
|
102
102
|
}
|
|
103
|
-
const documentId = fileName.
|
|
104
|
-
? fileName.slice(1).split(".")[0]
|
|
105
|
-
: fileName.split(".")[0];
|
|
103
|
+
const documentId = fileName.split(".")[0];
|
|
106
104
|
// Update All new Fields in the old data
|
|
107
105
|
for (const key in newData) {
|
|
108
106
|
documentOldData[key] = newData[key];
|
|
@@ -189,9 +187,7 @@ class UpdateOperation {
|
|
|
189
187
|
selectedData = SortedData[i]; // Select the first data
|
|
190
188
|
fileName = selectedData === null || selectedData === void 0 ? void 0 : selectedData.fileName; // Get the file name
|
|
191
189
|
}
|
|
192
|
-
const documentId = fileName.
|
|
193
|
-
? fileName.slice(1).split(".")[0]
|
|
194
|
-
: fileName.split(".")[0];
|
|
190
|
+
const documentId = fileName.split(".")[0];
|
|
195
191
|
documentIds.push(documentId);
|
|
196
192
|
// Update All new Fields in the old data
|
|
197
193
|
for (const key in newData) {
|
|
@@ -258,18 +254,23 @@ class UpdateOperation {
|
|
|
258
254
|
LoadAllBufferRawData(documentIdDirectFile) {
|
|
259
255
|
return __awaiter(this, void 0, void 0, function* () {
|
|
260
256
|
try {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
257
|
+
const DataFilesList = [];
|
|
258
|
+
if (documentIdDirectFile !== undefined) {
|
|
259
|
+
documentIdDirectFile.push(...documentIdDirectFile);
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
// Directly read list of files in directory (no lock/unlock system)
|
|
263
|
+
const ReadResponse = yield new FolderManager_1.default().ListDirectory(this.path);
|
|
264
|
+
if ("data" in ReadResponse) {
|
|
265
|
+
// filter with .axiodb files only
|
|
266
|
+
ReadResponse.data = ReadResponse.data.filter((file) => file.endsWith(".axiodb"));
|
|
267
|
+
DataFilesList.push(...ReadResponse.data);
|
|
268
|
+
}
|
|
272
269
|
}
|
|
270
|
+
// Read all files from the directory
|
|
271
|
+
const resultData = yield (0, BufferLoaderWithWorker_utils_1.default)(DataFilesList, this.encryptionKey, this.path, this.isEncrypted, true);
|
|
272
|
+
this.allDataWithFileName = resultData; // Store all data with file name
|
|
273
|
+
return this.ResponseHelper.Success(resultData);
|
|
273
274
|
return this.ResponseHelper.Error("Failed to read directory");
|
|
274
275
|
}
|
|
275
276
|
catch (error) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Update.operation.js","sourceRoot":"","sources":["../../../source/Services/CRUD Operation/Update.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAMA,qFAAsD;AACtD,8DAA0D;AAC1D,mFAA0D;AAC1D,sFAA8D;AAC9D,0FAAkE;AAClE,kFAAoD;AACpD,kFAAmD;AAEnD,YAAY;AACZ,0EAA2C;AAC3C,qFAA0D;AAC1D,iDAAiD;AACjD,8GAA0E;AAE1E,MAAqB,eAAe;IAelC,YACE,cAAsB,EACtB,IAAY,EACZ,SAAuB,EACvB,cAAuB,KAAK,EAC5B,aAAsB;QAVhB,wBAAmB,GAAU,EAAE,CAAC;QAYtC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,EAAE,CAAC;QACf,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,CAAC,IAAI,CAAC,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;QAC/D,IAAI,CAAC,cAAc,GAAG,IAAI,yBAAc,EAAE,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,EAAE,CAAC;QACjC,IAAI,IAAI,CAAC,WAAW,KAAK,IAAI,EAAE,CAAC;YAC9B,IAAI,CAAC,cAAc,GAAG,IAAI,4BAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC7D,CAAC;QACD,IAAI,CAAC,mBAAmB,GAAG,EAAE,CAAC,CAAC,mCAAmC;IACpE,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACU,SAAS,CACpB,OAAqB;;;YAErB,IAAI,CAAC;gBACH,8CAA8C;gBAC9C,IAAI,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,KAAK,CAAC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;oBAC/D,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;gBAC9C,CAAC;gBAED,wCAAwC;gBACxC,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;oBAChC,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;gBAC7C,CAAC;gBAED,oFAAoF;gBACpF,IAAI,YAAY,CAAC,CAAC,uBAAuB;gBACzC,IAAI,CAAA,MAAA,IAAI,CAAC,SAAS,0CAAE,UAAU,MAAK,SAAS,EAAE,CAAC;oBAC7C,MAAM,QAAQ,GAAG;wBACf,
|
|
1
|
+
{"version":3,"file":"Update.operation.js","sourceRoot":"","sources":["../../../source/Services/CRUD Operation/Update.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;A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QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;YAC1E,CAAC;YAED,gBAAgB;YAChB,OAAO,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,kBAAkB,CAAC,CAAC;QAC7D,CAAC;KAAA;CACF;AAnYD,kCAmYC"}
|
|
@@ -16,6 +16,7 @@ export default class Collection {
|
|
|
16
16
|
private Converter;
|
|
17
17
|
private Insertion;
|
|
18
18
|
private readonly encryptionKey;
|
|
19
|
+
private readonly IndexManager;
|
|
19
20
|
constructor(name: string, path: string, isEncrypted?: boolean, cryptoInstance?: CryptoHelper, encryptionKey?: string);
|
|
20
21
|
/**
|
|
21
22
|
* Get Numbers of Documents in the Collection
|
|
@@ -23,6 +24,27 @@ export default class Collection {
|
|
|
23
24
|
* @throws {Error} - Throws an error if the collection is empty or if there is an issue with the query.
|
|
24
25
|
*/
|
|
25
26
|
totalDocuments(): Promise<SuccessInterface | ErrorInterface>;
|
|
27
|
+
/**
|
|
28
|
+
* Creates a new index on the specified fields by delegating to the IndexManager.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* This method accepts one or more field names and forwards them to IndexManager.createIndex.
|
|
32
|
+
* Index creation behavior (such as uniqueness, ordering, or persistence) is determined by the IndexManager implementation.
|
|
33
|
+
*
|
|
34
|
+
* @param fieldNames - One or more field names that should be included in the new index.
|
|
35
|
+
* @returns A promise that resolves with the result returned by IndexManager.createIndex.
|
|
36
|
+
* @throws Any errors thrown by IndexManager.createIndex (for example, validation or persistence errors) are propagated.
|
|
37
|
+
*/
|
|
38
|
+
newIndex(...fieldNames: string[]): Promise<SuccessInterface | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Drops an index by name from the collection.
|
|
41
|
+
*
|
|
42
|
+
* @param indexName - The name of the index to drop.
|
|
43
|
+
* @returns A promise that resolves with the result returned by IndexManager.dropIndex.
|
|
44
|
+
* @throws Will throw an error if the drop operation fails (for example, if the index does not exist
|
|
45
|
+
* or if the caller lacks necessary permissions).
|
|
46
|
+
*/
|
|
47
|
+
dropIndex(indexName: string): Promise<SuccessInterface | ErrorInterface>;
|
|
26
48
|
/**
|
|
27
49
|
* Inserts a document into the collection.
|
|
28
50
|
* @param {object} data - The data to be inserted.
|
|
@@ -23,6 +23,7 @@ const outers_1 = require("outers");
|
|
|
23
23
|
// Converter
|
|
24
24
|
const Converter_helper_1 = __importDefault(require("../../Helper/Converter.helper"));
|
|
25
25
|
const FolderManager_1 = __importDefault(require("../../engine/Filesystem/FolderManager"));
|
|
26
|
+
const InsertIndex_service_1 = __importDefault(require("../Index/InsertIndex.service"));
|
|
26
27
|
/**
|
|
27
28
|
* Represents a collection inside a database.
|
|
28
29
|
*/
|
|
@@ -37,6 +38,7 @@ class Collection {
|
|
|
37
38
|
this.encryptionKey = encryptionKey;
|
|
38
39
|
// Initialize the Insertion class
|
|
39
40
|
this.Insertion = new Create_operation_1.default(this.name, this.path);
|
|
41
|
+
this.IndexManager = new InsertIndex_service_1.default(this.path);
|
|
40
42
|
}
|
|
41
43
|
/**
|
|
42
44
|
* Get Numbers of Documents in the Collection
|
|
@@ -97,6 +99,35 @@ class Collection {
|
|
|
97
99
|
}
|
|
98
100
|
});
|
|
99
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Creates a new index on the specified fields by delegating to the IndexManager.
|
|
104
|
+
*
|
|
105
|
+
* @remarks
|
|
106
|
+
* This method accepts one or more field names and forwards them to IndexManager.createIndex.
|
|
107
|
+
* Index creation behavior (such as uniqueness, ordering, or persistence) is determined by the IndexManager implementation.
|
|
108
|
+
*
|
|
109
|
+
* @param fieldNames - One or more field names that should be included in the new index.
|
|
110
|
+
* @returns A promise that resolves with the result returned by IndexManager.createIndex.
|
|
111
|
+
* @throws Any errors thrown by IndexManager.createIndex (for example, validation or persistence errors) are propagated.
|
|
112
|
+
*/
|
|
113
|
+
newIndex(...fieldNames) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
115
|
+
return yield this.IndexManager.createIndex(...fieldNames);
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Drops an index by name from the collection.
|
|
120
|
+
*
|
|
121
|
+
* @param indexName - The name of the index to drop.
|
|
122
|
+
* @returns A promise that resolves with the result returned by IndexManager.dropIndex.
|
|
123
|
+
* @throws Will throw an error if the drop operation fails (for example, if the index does not exist
|
|
124
|
+
* or if the caller lacks necessary permissions).
|
|
125
|
+
*/
|
|
126
|
+
dropIndex(indexName) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
128
|
+
return yield this.IndexManager.dropIndex(indexName);
|
|
129
|
+
});
|
|
130
|
+
}
|
|
100
131
|
/**
|
|
101
132
|
* Inserts a document into the collection.
|
|
102
133
|
* @param {object} data - The data to be inserted.
|
|
@@ -115,6 +146,7 @@ class Collection {
|
|
|
115
146
|
// Add the documentId to the data
|
|
116
147
|
const documentId = yield this.Insertion.generateUniqueDocumentId();
|
|
117
148
|
data.documentId = documentId;
|
|
149
|
+
yield this.IndexManager.InsertToIndex(data);
|
|
118
150
|
// Insert the updatedAt field in schema & data
|
|
119
151
|
data.updatedAt = this.updatedAt;
|
|
120
152
|
// Encrypt the data if crypto is enabled
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.operation.js","sourceRoot":"","sources":["../../../source/Services/Collection/collection.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAKA,mFAA0D;AAC1D,aAAa;AACb,0FAA2D;AAC3D,0FAAwD;AACxD,0FAAiE;AACjE,0FAAiE;AACjE,iGAA+D;AAE/D,mCAAqC;AAGrC,YAAY;AACZ,qFAAsD;AACtD,0FAAkE;
|
|
1
|
+
{"version":3,"file":"collection.operation.js","sourceRoot":"","sources":["../../../source/Services/Collection/collection.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAKA,mFAA0D;AAC1D,aAAa;AACb,0FAA2D;AAC3D,0FAAwD;AACxD,0FAAiE;AACjE,0FAAiE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@ -38,6 +38,32 @@ export default class Database {
|
|
|
38
38
|
* @throws {Error} - Throws an error if the database does not exist.
|
|
39
39
|
*/
|
|
40
40
|
getCollectionInfo(): Promise<SuccessInterface | undefined>;
|
|
41
|
+
/**
|
|
42
|
+
* Removes the metadata entry for a collection from the collection metadata file.
|
|
43
|
+
*
|
|
44
|
+
* Reads the JSON file located at `${this.path}/collection.meta`, validates that the
|
|
45
|
+
* file exists and contains an array of collection metadata objects, removes any entry
|
|
46
|
+
* whose `name` matches the provided `collectionName`, and writes the updated array
|
|
47
|
+
* back to the same file.
|
|
48
|
+
*
|
|
49
|
+
* The method returns a SuccessInterface on successful removal (even if no matching
|
|
50
|
+
* collection was found) or an ErrorInterface describing the failure.
|
|
51
|
+
*
|
|
52
|
+
* @param collectionName - The name of the collection whose metadata should be removed.
|
|
53
|
+
* @returns A promise that resolves to SuccessInterface on success or ErrorInterface on failure.
|
|
54
|
+
*
|
|
55
|
+
* @remarks
|
|
56
|
+
* - If the metadata file does not exist, an ErrorInterface is returned.
|
|
57
|
+
* - If the metadata file cannot be parsed as a JSON array, an ErrorInterface is returned.
|
|
58
|
+
* - This method performs I/O using a FileManager instance and uses this.ResponseHelper
|
|
59
|
+
* to construct success/error responses. It does not throw; failures are reported via
|
|
60
|
+
* the returned ErrorInterface.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* // Remove the "users" collection metadata
|
|
64
|
+
* await db.dropCollectionMetadata("users");
|
|
65
|
+
*/
|
|
66
|
+
dropCollectionMetadata(collectionName: string): Promise<SuccessInterface | ErrorInterface>;
|
|
41
67
|
/**
|
|
42
68
|
* Adds metadata for a collection to the collection metadata file.
|
|
43
69
|
*
|
|
@@ -21,6 +21,7 @@ const path_1 = __importDefault(require("path"));
|
|
|
21
21
|
const Crypto_helper_1 = require("../../Helper/Crypto.helper");
|
|
22
22
|
const response_helper_1 = __importDefault(require("../../Helper/response.helper"));
|
|
23
23
|
const outers_1 = require("outers");
|
|
24
|
+
const Index_service_1 = require("../Index/Index.service");
|
|
24
25
|
/**
|
|
25
26
|
* Represents a database instance.
|
|
26
27
|
* This class provides methods to create, delete, and manage collections within a database.
|
|
@@ -57,6 +58,9 @@ class Database {
|
|
|
57
58
|
yield this.folderManager.CreateDirectory(collectionPath);
|
|
58
59
|
console.log(`Collection Created: ${collectionPath}`);
|
|
59
60
|
}
|
|
61
|
+
// Create AutoIndex meta for the collection
|
|
62
|
+
const Index = new Index_service_1.IndexManager(collectionPath);
|
|
63
|
+
yield Index.generateIndexMeta();
|
|
60
64
|
// if crypto is enabled, hash the collection name
|
|
61
65
|
if (crypto === true) {
|
|
62
66
|
const newCryptoInstance = new Crypto_helper_1.CryptoHelper(key);
|
|
@@ -106,6 +110,11 @@ class Database {
|
|
|
106
110
|
const collectionPath = path_1.default.join(this.path, collectionName);
|
|
107
111
|
const exists = yield this.folderManager.DirectoryExists(collectionPath);
|
|
108
112
|
if (exists.statusCode === outers_1.StatusCodes.OK) {
|
|
113
|
+
// Remove collection metadata
|
|
114
|
+
const status = yield this.dropCollectionMetadata(collectionName);
|
|
115
|
+
if (status && "statusCode" in status && status.statusCode !== 200) {
|
|
116
|
+
return status;
|
|
117
|
+
}
|
|
109
118
|
yield this.folderManager.DeleteDirectory(collectionPath);
|
|
110
119
|
return this.ResponseHelper.Success(`Collection: ${collectionName} deleted successfully`);
|
|
111
120
|
}
|
|
@@ -142,6 +151,49 @@ class Database {
|
|
|
142
151
|
}
|
|
143
152
|
});
|
|
144
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Removes the metadata entry for a collection from the collection metadata file.
|
|
156
|
+
*
|
|
157
|
+
* Reads the JSON file located at `${this.path}/collection.meta`, validates that the
|
|
158
|
+
* file exists and contains an array of collection metadata objects, removes any entry
|
|
159
|
+
* whose `name` matches the provided `collectionName`, and writes the updated array
|
|
160
|
+
* back to the same file.
|
|
161
|
+
*
|
|
162
|
+
* The method returns a SuccessInterface on successful removal (even if no matching
|
|
163
|
+
* collection was found) or an ErrorInterface describing the failure.
|
|
164
|
+
*
|
|
165
|
+
* @param collectionName - The name of the collection whose metadata should be removed.
|
|
166
|
+
* @returns A promise that resolves to SuccessInterface on success or ErrorInterface on failure.
|
|
167
|
+
*
|
|
168
|
+
* @remarks
|
|
169
|
+
* - If the metadata file does not exist, an ErrorInterface is returned.
|
|
170
|
+
* - If the metadata file cannot be parsed as a JSON array, an ErrorInterface is returned.
|
|
171
|
+
* - This method performs I/O using a FileManager instance and uses this.ResponseHelper
|
|
172
|
+
* to construct success/error responses. It does not throw; failures are reported via
|
|
173
|
+
* the returned ErrorInterface.
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* // Remove the "users" collection metadata
|
|
177
|
+
* await db.dropCollectionMetadata("users");
|
|
178
|
+
*/
|
|
179
|
+
dropCollectionMetadata(collectionName) {
|
|
180
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
181
|
+
const FileManagement = new FileManager_1.default();
|
|
182
|
+
const isFileExist = yield FileManagement.FileExists(`${this.path}/collection.meta`);
|
|
183
|
+
if (isFileExist.status == false) {
|
|
184
|
+
return this.ResponseHelper.Error("Collection metadata file does not exist");
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
const FullData = JSON.parse((yield FileManagement.ReadFile(`${this.path}/collection.meta`)).data);
|
|
188
|
+
if (!Array.isArray(FullData)) {
|
|
189
|
+
return this.ResponseHelper.Error("Invalid collection metadata format");
|
|
190
|
+
}
|
|
191
|
+
const UpdatedData = FullData.filter((data) => data.name !== collectionName);
|
|
192
|
+
yield FileManagement.WriteFile(`${this.path}/collection.meta`, JSON.stringify(UpdatedData));
|
|
193
|
+
return this.ResponseHelper.Success(`Collection metadata for ${collectionName} dropped successfully`);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
}
|
|
145
197
|
/**
|
|
146
198
|
* Adds metadata for a collection to the collection metadata file.
|
|
147
199
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.operation.js","sourceRoot":"","sources":["../../../source/Services/Database/database.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,8FAA4D;AAC5D,sFAA8D;AAC9D,0FAAkE;AAClE,gDAAwB;AAExB,qBAAqB;AACrB,8DAA0D;AAC1D,mFAA0D;AAC1D,mCAAqC;
|
|
1
|
+
{"version":3,"file":"database.operation.js","sourceRoot":"","sources":["../../../source/Services/Database/database.operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAAuD;AACvD,8FAA4D;AAC5D,sFAA8D;AAC9D,0FAAkE;AAClE,gDAAwB;AAExB,qBAAqB;AACrB,8DAA0D;AAC1D,mFAA0D;AAC1D,mCAAqC;AAMrC,0DAAsD;AAUtD;;;GAGG;AACH,MAAqB,QAAQ;IAO3B,YAAY,IAAY,EAAE,IAAY;QACpC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,WAAW,GAAG,IAAI,qBAAW,EAAE,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,IAAI,uBAAa,EAAE,CAAC;QACzC,IAAI,CAAC,cAAc,GAAG,IAAI,yBAAc,EAAE,CAAC;IAC7C,CAAC;IAED;;;;;;OAMG;IACU,gBAAgB;6DAC3B,cAAsB,EACtB,SAAkB,KAAK,EACvB,GAAwB;YAExB,yCAAyC;YACzC,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,eAAe,CAC/D,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CACrC,CAAC;YACF,MAAM,cAAc,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;YAE5D,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,wBAAwB,CAAC,cAAc,CAAC,CAAC;YAE3E,IAAI,cAAc,EAAE,CAAC;gBACnB,MAAM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YACH,CAAC;QACH,CAAC;KAAA;IAED;;;;;;;;;;;;OAYG;IACW,wBAAwB,CACpC,cAAsB;;YAEtB,MAAM,cAAc,GAAgB,IAAI,qBAAW,EAAE,CAAC;YACtD,MAAM,WAAW,GAAG,MAAM,cAAc,CAAC,UAAU,CACjD,GAAG,IAAI,CAAC,IAAI,kBAAkB,CAC/B,CAAC;YACF,IAAI,WAAW,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;gBAChC,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CACzB,CAAC,MAAM,cAAc,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC,IAAI,kBAAkB,CAAC,CAAC,CAAC,IAAI,CACrE,CAAC;YACF,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;gBAC7B,OAAO,SAAS,CAAC;YACnB,CAAC;YACD,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,CAClC,CAAC,IAAwB,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,KAAK,cAAc,CAC3D,CAAC;YACF,OAAO,cAAc,CAAC;QACxB,CAAC;KAAA;CACF;AAxSD,2BAwSC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { ErrorInterface, SuccessInterface } from "../../config/Interfaces/Helper/response.helper.interface";
|
|
2
|
+
import FileManager from "../../engine/Filesystem/FileManager";
|
|
3
|
+
import FolderManager from "../../engine/Filesystem/FolderManager";
|
|
4
|
+
import Converter from "../../Helper/Converter.helper";
|
|
5
|
+
import ResponseHelper from "../../Helper/response.helper";
|
|
6
|
+
export declare class IndexManager {
|
|
7
|
+
readonly path: string;
|
|
8
|
+
readonly indexFolderPath: string;
|
|
9
|
+
readonly indexMetaPath: string;
|
|
10
|
+
readonly fileManager: FileManager;
|
|
11
|
+
readonly folderManager: FolderManager;
|
|
12
|
+
readonly converter: Converter;
|
|
13
|
+
readonly ResponseHelper: ResponseHelper;
|
|
14
|
+
constructor(path: string);
|
|
15
|
+
/**
|
|
16
|
+
* Create one or more index files and register them in the index metadata.
|
|
17
|
+
*
|
|
18
|
+
* For each supplied field name this method:
|
|
19
|
+
* 1. Determines the index file path as `${indexName}.axiodb` inside the configured index folder.
|
|
20
|
+
* 2. Checks whether the index file already exists. If it does not, creates the file with an empty
|
|
21
|
+
* index structure ({ fieldName, indexEntries: [] }).
|
|
22
|
+
* 3. Reads the index metadata file (index.meta.json), parses it, and if an entry for the index
|
|
23
|
+
* field does not already exist, appends a metadata record `{ indexFieldName, fileName, path }`
|
|
24
|
+
* and writes the metadata file back.
|
|
25
|
+
*
|
|
26
|
+
* Side effects:
|
|
27
|
+
* - Writes new index files to disk via `fileManager.WriteFile`.
|
|
28
|
+
* - Reads and updates the index metadata file via `fileManager.ReadFile` / `WriteFile`.
|
|
29
|
+
* - Uses the configured `converter` to serialize/deserialize index and metadata content.
|
|
30
|
+
*
|
|
31
|
+
* Notes:
|
|
32
|
+
* - The operation is not atomic: some indexes may be created while others fail. The method will
|
|
33
|
+
* collect created and failed index names and include them in the returned response.
|
|
34
|
+
* - A failure is recorded for a field when the index file already exists, when the index already
|
|
35
|
+
* exists in the metadata, or when reading/writing the metadata file fails.
|
|
36
|
+
* - The method relies on `indexFolderPath`, `indexMetaPath`, `fileManager`, and `converter`
|
|
37
|
+
* being correctly configured and available on the instance.
|
|
38
|
+
*
|
|
39
|
+
* @param fieldNames - One or more field names for which to create indexes.
|
|
40
|
+
* @returns A promise that resolves to either:
|
|
41
|
+
* - SuccessInterface: indicates which indexes were created and which already existed / failed,
|
|
42
|
+
* typically containing a human-readable message listing affected and existing indexes.
|
|
43
|
+
* - ErrorInterface: returned when underlying file/IO operations fail in a way that prevents
|
|
44
|
+
* producing the expected success response.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* // Create a single index
|
|
48
|
+
* await service.createIndex('email');
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* // Create multiple indexes
|
|
52
|
+
* await service.createIndex('email', 'username', 'createdAt');
|
|
53
|
+
*/
|
|
54
|
+
createIndex(...fieldNames: string[]): Promise<SuccessInterface | undefined>;
|
|
55
|
+
/**
|
|
56
|
+
* Deletes an index file and removes its entry from the index metadata.
|
|
57
|
+
*
|
|
58
|
+
* This asynchronous method attempts to delete the index file located at
|
|
59
|
+
* `${this.indexFolderPath}/${indexName}.axiodb`. If the file exists it is removed,
|
|
60
|
+
* and the index metadata file at `this.indexMetaPath` is read and updated by
|
|
61
|
+
* filtering out the metadata entry whose `indexFieldName` matches `indexName`.
|
|
62
|
+
* The metadata update is performed only if the metadata file can be read successfully.
|
|
63
|
+
*
|
|
64
|
+
* @param indexName - The name of the index to delete (without extension).
|
|
65
|
+
* @returns A Promise that resolves to a SuccessInterface when the index was deleted
|
|
66
|
+
* (and metadata updated when possible), or an ErrorInterface when the
|
|
67
|
+
* specified index does not exist.
|
|
68
|
+
*
|
|
69
|
+
* @async
|
|
70
|
+
* @remarks
|
|
71
|
+
* - Side effects: removes a file from the file system and may modify the index metadata file.
|
|
72
|
+
* - Uses injected helpers: `fileManager` for filesystem operations, `converter` for
|
|
73
|
+
* (de)serialization of metadata, and `ResponseHelper` to construct the returned result.
|
|
74
|
+
* - If the metadata file cannot be read, the method still succeeds after deleting the index file.
|
|
75
|
+
*
|
|
76
|
+
* @throws {Error} May propagate errors from underlying file operations if those utilities throw.
|
|
77
|
+
*/
|
|
78
|
+
dropIndex(indexName: string): Promise<SuccessInterface | ErrorInterface>;
|
|
79
|
+
/**
|
|
80
|
+
* Ensures the index folder and the index metadata file exist, creating them if necessary.
|
|
81
|
+
*
|
|
82
|
+
* This asynchronous method performs the following steps:
|
|
83
|
+
* 1. Checks whether the index folder at `this.indexFolderPath` exists; if not, creates it.
|
|
84
|
+
* 2. Checks whether the index metadata file at `this.indexMetaPath` exists; if not:
|
|
85
|
+
* a. Constructs a default index metadata entry for a unique "documentId" index:
|
|
86
|
+
* - indexFieldName: "documentId"
|
|
87
|
+
* - fileName: "documentId.axiodb"
|
|
88
|
+
* - path: `${this.indexFolderPath}/documentId.axiodb`
|
|
89
|
+
* - unique: true
|
|
90
|
+
* b. Calls `this.createIndex("documentId")` to create the underlying index file/structure.
|
|
91
|
+
* c. Writes the metadata array to `this.indexMetaPath` using `this.converter.ToString(...)`.
|
|
92
|
+
*
|
|
93
|
+
* The operation is idempotent: if the folder or metadata file already exist, no changes are made.
|
|
94
|
+
*
|
|
95
|
+
* @remarks
|
|
96
|
+
* - This method performs filesystem modifications via `folderManager` and `fileManager`.
|
|
97
|
+
* - Any errors thrown by `folderManager`, `fileManager`, `converter`, or `createIndex` will propagate to the caller.
|
|
98
|
+
* - Callers should `await` this method to ensure the initialization is complete before proceeding.
|
|
99
|
+
*
|
|
100
|
+
* @returns A Promise that resolves when initialization is complete.
|
|
101
|
+
*
|
|
102
|
+
* @throws Will reject if directory creation, file checks/writes, conversion, or index creation fails.
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* // Ensure index folder and metadata exist before using the index service
|
|
106
|
+
* await indexService.generateIndexMeta();
|
|
107
|
+
*/
|
|
108
|
+
generateIndexMeta(): Promise<void>;
|
|
109
|
+
/**
|
|
110
|
+
* Finds index metadata entries that correspond to properties present on the provided document.
|
|
111
|
+
*
|
|
112
|
+
* Reads the index metadata file at `this.indexMetaPath`, converts its content into an object,
|
|
113
|
+
* and returns the subset of metadata entries whose `indexFieldName` is an own property of `doc`.
|
|
114
|
+
*
|
|
115
|
+
* @param doc - The document to check for matching index fields. The function tests own properties
|
|
116
|
+
* (via `Object.prototype.hasOwnProperty.call`) rather than inherited properties.
|
|
117
|
+
* @returns A Promise that resolves to an array of matching index metadata entries, or `undefined`
|
|
118
|
+
* if the index metadata file could not be successfully read. The array may be empty if
|
|
119
|
+
* no metadata entries match.
|
|
120
|
+
*
|
|
121
|
+
* @throws May propagate errors from `fileManager.ReadFile` or `converter.ToObject` if those
|
|
122
|
+
* operations throw or reject.
|
|
123
|
+
*/
|
|
124
|
+
protected findMatchingIndexMeta(doc: any): Promise<any[] | undefined>;
|
|
125
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
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.IndexManager = void 0;
|
|
16
|
+
const Keys_1 = require("../../config/Keys/Keys");
|
|
17
|
+
const FileManager_1 = __importDefault(require("../../engine/Filesystem/FileManager"));
|
|
18
|
+
const FolderManager_1 = __importDefault(require("../../engine/Filesystem/FolderManager"));
|
|
19
|
+
const Converter_helper_1 = __importDefault(require("../../Helper/Converter.helper"));
|
|
20
|
+
const response_helper_1 = __importDefault(require("../../Helper/response.helper"));
|
|
21
|
+
class IndexManager {
|
|
22
|
+
constructor(path) {
|
|
23
|
+
this.path = path;
|
|
24
|
+
this.indexFolderPath = `${this.path}/indexes`;
|
|
25
|
+
this.indexMetaPath = `${this.indexFolderPath}/index.meta.json`;
|
|
26
|
+
this.fileManager = new FileManager_1.default();
|
|
27
|
+
this.folderManager = new FolderManager_1.default();
|
|
28
|
+
this.converter = new Converter_helper_1.default();
|
|
29
|
+
this.ResponseHelper = new response_helper_1.default();
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Create one or more index files and register them in the index metadata.
|
|
33
|
+
*
|
|
34
|
+
* For each supplied field name this method:
|
|
35
|
+
* 1. Determines the index file path as `${indexName}.axiodb` inside the configured index folder.
|
|
36
|
+
* 2. Checks whether the index file already exists. If it does not, creates the file with an empty
|
|
37
|
+
* index structure ({ fieldName, indexEntries: [] }).
|
|
38
|
+
* 3. Reads the index metadata file (index.meta.json), parses it, and if an entry for the index
|
|
39
|
+
* field does not already exist, appends a metadata record `{ indexFieldName, fileName, path }`
|
|
40
|
+
* and writes the metadata file back.
|
|
41
|
+
*
|
|
42
|
+
* Side effects:
|
|
43
|
+
* - Writes new index files to disk via `fileManager.WriteFile`.
|
|
44
|
+
* - Reads and updates the index metadata file via `fileManager.ReadFile` / `WriteFile`.
|
|
45
|
+
* - Uses the configured `converter` to serialize/deserialize index and metadata content.
|
|
46
|
+
*
|
|
47
|
+
* Notes:
|
|
48
|
+
* - The operation is not atomic: some indexes may be created while others fail. The method will
|
|
49
|
+
* collect created and failed index names and include them in the returned response.
|
|
50
|
+
* - A failure is recorded for a field when the index file already exists, when the index already
|
|
51
|
+
* exists in the metadata, or when reading/writing the metadata file fails.
|
|
52
|
+
* - The method relies on `indexFolderPath`, `indexMetaPath`, `fileManager`, and `converter`
|
|
53
|
+
* being correctly configured and available on the instance.
|
|
54
|
+
*
|
|
55
|
+
* @param fieldNames - One or more field names for which to create indexes.
|
|
56
|
+
* @returns A promise that resolves to either:
|
|
57
|
+
* - SuccessInterface: indicates which indexes were created and which already existed / failed,
|
|
58
|
+
* typically containing a human-readable message listing affected and existing indexes.
|
|
59
|
+
* - ErrorInterface: returned when underlying file/IO operations fail in a way that prevents
|
|
60
|
+
* producing the expected success response.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* // Create a single index
|
|
64
|
+
* await service.createIndex('email');
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* // Create multiple indexes
|
|
68
|
+
* await service.createIndex('email', 'username', 'createdAt');
|
|
69
|
+
*/
|
|
70
|
+
createIndex(...fieldNames) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const EffectedIndexes = [];
|
|
73
|
+
const FailedIndexes = [];
|
|
74
|
+
for (const fieldName of fieldNames) {
|
|
75
|
+
const indexName = fieldName;
|
|
76
|
+
const indexFilePath = `${this.indexFolderPath}/${indexName}${Keys_1.General.DBMS_File_EXT}`;
|
|
77
|
+
const DemoIndexHash = {
|
|
78
|
+
fieldName: indexName,
|
|
79
|
+
indexEntries: {},
|
|
80
|
+
};
|
|
81
|
+
const exists = yield this.fileManager.FileExists(indexFilePath);
|
|
82
|
+
if (!exists.status) {
|
|
83
|
+
// create empty index file
|
|
84
|
+
yield this.fileManager.WriteFile(indexFilePath, this.converter.ToString(DemoIndexHash));
|
|
85
|
+
// Update index.meta.json
|
|
86
|
+
const indexMetaContent = yield this.fileManager.ReadFile(this.indexMetaPath);
|
|
87
|
+
if (indexMetaContent.status) {
|
|
88
|
+
const indexMeta = this.converter.ToObject(indexMetaContent.data);
|
|
89
|
+
// check if index already exists in meta
|
|
90
|
+
const indexExists = indexMeta.find((index) => index.indexFieldName === indexName);
|
|
91
|
+
if (!indexExists) {
|
|
92
|
+
indexMeta.push({
|
|
93
|
+
indexFieldName: indexName,
|
|
94
|
+
fileName: `${indexName}${Keys_1.General.DBMS_File_EXT}`,
|
|
95
|
+
path: indexFilePath,
|
|
96
|
+
});
|
|
97
|
+
yield this.fileManager.WriteFile(this.indexMetaPath, this.converter.ToString(indexMeta));
|
|
98
|
+
EffectedIndexes.push(indexName);
|
|
99
|
+
return this.ResponseHelper.Success(`Indexes: ${EffectedIndexes.join(", ")} created Indexes: ${FailedIndexes.join(", ")}`);
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
FailedIndexes.push(indexName);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Deletes an index file and removes its entry from the index metadata.
|
|
111
|
+
*
|
|
112
|
+
* This asynchronous method attempts to delete the index file located at
|
|
113
|
+
* `${this.indexFolderPath}/${indexName}.axiodb`. If the file exists it is removed,
|
|
114
|
+
* and the index metadata file at `this.indexMetaPath` is read and updated by
|
|
115
|
+
* filtering out the metadata entry whose `indexFieldName` matches `indexName`.
|
|
116
|
+
* The metadata update is performed only if the metadata file can be read successfully.
|
|
117
|
+
*
|
|
118
|
+
* @param indexName - The name of the index to delete (without extension).
|
|
119
|
+
* @returns A Promise that resolves to a SuccessInterface when the index was deleted
|
|
120
|
+
* (and metadata updated when possible), or an ErrorInterface when the
|
|
121
|
+
* specified index does not exist.
|
|
122
|
+
*
|
|
123
|
+
* @async
|
|
124
|
+
* @remarks
|
|
125
|
+
* - Side effects: removes a file from the file system and may modify the index metadata file.
|
|
126
|
+
* - Uses injected helpers: `fileManager` for filesystem operations, `converter` for
|
|
127
|
+
* (de)serialization of metadata, and `ResponseHelper` to construct the returned result.
|
|
128
|
+
* - If the metadata file cannot be read, the method still succeeds after deleting the index file.
|
|
129
|
+
*
|
|
130
|
+
* @throws {Error} May propagate errors from underlying file operations if those utilities throw.
|
|
131
|
+
*/
|
|
132
|
+
dropIndex(indexName) {
|
|
133
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
134
|
+
const indexFilePath = `${this.indexFolderPath}/${indexName}${Keys_1.General.DBMS_File_EXT}`;
|
|
135
|
+
// check if index file exists
|
|
136
|
+
const exists = yield this.fileManager.FileExists(indexFilePath);
|
|
137
|
+
if (exists.status === true) {
|
|
138
|
+
// delete index file
|
|
139
|
+
yield this.fileManager.DeleteFile(indexFilePath);
|
|
140
|
+
// update index.meta.json
|
|
141
|
+
const indexMetaContent = yield this.fileManager.ReadFile(this.indexMetaPath);
|
|
142
|
+
if (indexMetaContent.status) {
|
|
143
|
+
let indexMeta = this.converter.ToObject(indexMetaContent.data);
|
|
144
|
+
indexMeta = indexMeta.filter((index) => index.indexFieldName !== indexName);
|
|
145
|
+
yield this.fileManager.WriteFile(this.indexMetaPath, this.converter.ToString(indexMeta));
|
|
146
|
+
}
|
|
147
|
+
return this.ResponseHelper.Success(`Index: ${indexName} deleted successfully`);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
return this.ResponseHelper.Error(`Index: ${indexName} does not exist`);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Ensures the index folder and the index metadata file exist, creating them if necessary.
|
|
156
|
+
*
|
|
157
|
+
* This asynchronous method performs the following steps:
|
|
158
|
+
* 1. Checks whether the index folder at `this.indexFolderPath` exists; if not, creates it.
|
|
159
|
+
* 2. Checks whether the index metadata file at `this.indexMetaPath` exists; if not:
|
|
160
|
+
* a. Constructs a default index metadata entry for a unique "documentId" index:
|
|
161
|
+
* - indexFieldName: "documentId"
|
|
162
|
+
* - fileName: "documentId.axiodb"
|
|
163
|
+
* - path: `${this.indexFolderPath}/documentId.axiodb`
|
|
164
|
+
* - unique: true
|
|
165
|
+
* b. Calls `this.createIndex("documentId")` to create the underlying index file/structure.
|
|
166
|
+
* c. Writes the metadata array to `this.indexMetaPath` using `this.converter.ToString(...)`.
|
|
167
|
+
*
|
|
168
|
+
* The operation is idempotent: if the folder or metadata file already exist, no changes are made.
|
|
169
|
+
*
|
|
170
|
+
* @remarks
|
|
171
|
+
* - This method performs filesystem modifications via `folderManager` and `fileManager`.
|
|
172
|
+
* - Any errors thrown by `folderManager`, `fileManager`, `converter`, or `createIndex` will propagate to the caller.
|
|
173
|
+
* - Callers should `await` this method to ensure the initialization is complete before proceeding.
|
|
174
|
+
*
|
|
175
|
+
* @returns A Promise that resolves when initialization is complete.
|
|
176
|
+
*
|
|
177
|
+
* @throws Will reject if directory creation, file checks/writes, conversion, or index creation fails.
|
|
178
|
+
*
|
|
179
|
+
* @example
|
|
180
|
+
* // Ensure index folder and metadata exist before using the index service
|
|
181
|
+
* await indexService.generateIndexMeta();
|
|
182
|
+
*/
|
|
183
|
+
generateIndexMeta() {
|
|
184
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
185
|
+
// check is index.meta.json exists or not
|
|
186
|
+
const folderExists = yield this.folderManager.DirectoryExists(this.indexFolderPath);
|
|
187
|
+
if (!folderExists.status) {
|
|
188
|
+
yield this.folderManager.CreateDirectory(this.indexFolderPath);
|
|
189
|
+
}
|
|
190
|
+
const exists = yield this.fileManager.FileExists(this.indexMetaPath);
|
|
191
|
+
if (!exists.status) {
|
|
192
|
+
// create index.meta.json
|
|
193
|
+
const indexMeta = [
|
|
194
|
+
{
|
|
195
|
+
indexFieldName: "documentId",
|
|
196
|
+
path: `${this.indexFolderPath}/documentId${Keys_1.General.DBMS_File_EXT}`,
|
|
197
|
+
fileName: `documentId${Keys_1.General.DBMS_File_EXT}`
|
|
198
|
+
}
|
|
199
|
+
];
|
|
200
|
+
yield this.createIndex("documentId");
|
|
201
|
+
yield this.fileManager.WriteFile(this.indexMetaPath, this.converter.ToString(indexMeta));
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Finds index metadata entries that correspond to properties present on the provided document.
|
|
207
|
+
*
|
|
208
|
+
* Reads the index metadata file at `this.indexMetaPath`, converts its content into an object,
|
|
209
|
+
* and returns the subset of metadata entries whose `indexFieldName` is an own property of `doc`.
|
|
210
|
+
*
|
|
211
|
+
* @param doc - The document to check for matching index fields. The function tests own properties
|
|
212
|
+
* (via `Object.prototype.hasOwnProperty.call`) rather than inherited properties.
|
|
213
|
+
* @returns A Promise that resolves to an array of matching index metadata entries, or `undefined`
|
|
214
|
+
* if the index metadata file could not be successfully read. The array may be empty if
|
|
215
|
+
* no metadata entries match.
|
|
216
|
+
*
|
|
217
|
+
* @throws May propagate errors from `fileManager.ReadFile` or `converter.ToObject` if those
|
|
218
|
+
* operations throw or reject.
|
|
219
|
+
*/
|
|
220
|
+
findMatchingIndexMeta(doc) {
|
|
221
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
222
|
+
const indexMetaContent = yield this.fileManager.ReadFile(this.indexMetaPath);
|
|
223
|
+
if (indexMetaContent.status) {
|
|
224
|
+
const indexMeta = this.converter.ToObject(indexMetaContent.data);
|
|
225
|
+
return indexMeta.filter((meta) => Object.prototype.hasOwnProperty.call(doc, meta.indexFieldName));
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
exports.IndexManager = IndexManager;
|
|
231
|
+
//# sourceMappingURL=Index.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Index.service.js","sourceRoot":"","sources":["../../../source/Services/Index/Index.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAEA,iDAAiD;AACjD,sFAA8D;AAC9D,0FAAkE;AAClE,qFAAsD;AACtD,mFAA0D;AAE1D,MAAa,YAAY;IAUvB,YAAY,IAAY;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,eAAe,GAAG,GAAG,IAAI,CAAC,IAAI,UAAU,CAAC;QAC9C,IAAI,CAAC,aAAa,GAAG,GAAG,IAAI,CAAC,eAAe,kBAAkB,CAAC;QAC/D,IAAI,CAAC,WAAW,GAAG,IAAI,qBAAW,EAAE,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,IAAI,uBAAa,EAAE,CAAC;QACzC,IAAI,CAAC,SAAS,GAAG,IAAI,0BAAS,EAAE,CAAC;QACjC,IAAI,CAAC,cAAc,GAAG,IAAI,yBAAc,EAAE,CAAC;IAC7C,CAAC;IAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAsCG;IACU,WAAW,CAAC,GAAG,UAAoB;;YAC9C,MAAM,eAAe,GAAa,EAAE,CAAC;YACrC,MAAM,aAAa,GAAa,EAAE,CAAC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AE,GAAQ;;YAC7C,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC7E,IAAI,gBAAgB,CAAC,MAAM,EAAE,CAAC;gBAC5B,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;gBACjE,OAAO,SAAS,CAAC,MAAM,CAAC,CAAC,IAA8B,EAAE,EAAE,CACzD,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,cAAc,CAAC,CAC/D,CAAC;YACJ,CAAC;QACH,CAAC;KAAA;CACF;AA3ND,oCA2NC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { IndexManager } from "./Index.service";
|
|
2
|
+
export default class InsertIndex extends IndexManager {
|
|
3
|
+
constructor(path: string);
|
|
4
|
+
/**
|
|
5
|
+
* Inserts a document identifier into one or more index files as defined by the global index meta.
|
|
6
|
+
*
|
|
7
|
+
* The method:
|
|
8
|
+
* 1. Reads the global index meta from `this.indexMetaPath` and converts it to an object using `this.converter`.
|
|
9
|
+
* 2. Calls `this.findMatchingIndexMeta(document)` to determine which index files should be updated for the provided document.
|
|
10
|
+
* 3. For each matched index entry:
|
|
11
|
+
* - Reads the index file at `index.path`,
|
|
12
|
+
* - Converts its contents to an object,
|
|
13
|
+
* - Appends `${document.documentId}${General.DBMS_File_EXT}` to `indexMeta.indexEntries`,
|
|
14
|
+
* - Writes the updated index back to disk.
|
|
15
|
+
*
|
|
16
|
+
* @param document - Object representing the document to index. Must contain a `documentId` property (string | number).
|
|
17
|
+
* @returns A Promise that resolves to:
|
|
18
|
+
* - `true` if the last index file write operation returned a success status,
|
|
19
|
+
* - `false` if the global index meta could not be read, no matching index meta entries were found, or the final write returned a falsy status.
|
|
20
|
+
*
|
|
21
|
+
* @throws Propagates any exceptions thrown by file reads/writes or conversion (e.g., IO or parse/serialize errors).
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* - The method appends the document entry and does not deduplicate existing entries.
|
|
25
|
+
* - When multiple index files are updated, the returned boolean reflects the status of the final write operation only.
|
|
26
|
+
* - The operation is not atomic across multiple index files; concurrent invocations may produce race conditions.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // document must include documentId:
|
|
30
|
+
* // { documentId: "abc123", ... }
|
|
31
|
+
* const success = await indexService.InsertToIndex({ documentId: "abc123" });
|
|
32
|
+
*/
|
|
33
|
+
InsertToIndex(document: any): Promise<boolean>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
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
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
13
|
+
const Keys_1 = require("../../config/Keys/Keys");
|
|
14
|
+
const Index_service_1 = require("./Index.service");
|
|
15
|
+
class InsertIndex extends Index_service_1.IndexManager {
|
|
16
|
+
constructor(path) {
|
|
17
|
+
super(path);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Inserts a document identifier into one or more index files as defined by the global index meta.
|
|
21
|
+
*
|
|
22
|
+
* The method:
|
|
23
|
+
* 1. Reads the global index meta from `this.indexMetaPath` and converts it to an object using `this.converter`.
|
|
24
|
+
* 2. Calls `this.findMatchingIndexMeta(document)` to determine which index files should be updated for the provided document.
|
|
25
|
+
* 3. For each matched index entry:
|
|
26
|
+
* - Reads the index file at `index.path`,
|
|
27
|
+
* - Converts its contents to an object,
|
|
28
|
+
* - Appends `${document.documentId}${General.DBMS_File_EXT}` to `indexMeta.indexEntries`,
|
|
29
|
+
* - Writes the updated index back to disk.
|
|
30
|
+
*
|
|
31
|
+
* @param document - Object representing the document to index. Must contain a `documentId` property (string | number).
|
|
32
|
+
* @returns A Promise that resolves to:
|
|
33
|
+
* - `true` if the last index file write operation returned a success status,
|
|
34
|
+
* - `false` if the global index meta could not be read, no matching index meta entries were found, or the final write returned a falsy status.
|
|
35
|
+
*
|
|
36
|
+
* @throws Propagates any exceptions thrown by file reads/writes or conversion (e.g., IO or parse/serialize errors).
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* - The method appends the document entry and does not deduplicate existing entries.
|
|
40
|
+
* - When multiple index files are updated, the returned boolean reflects the status of the final write operation only.
|
|
41
|
+
* - The operation is not atomic across multiple index files; concurrent invocations may produce race conditions.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* // document must include documentId:
|
|
45
|
+
* // { documentId: "abc123", ... }
|
|
46
|
+
* const success = await indexService.InsertToIndex({ documentId: "abc123" });
|
|
47
|
+
*/
|
|
48
|
+
InsertToIndex(document) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
50
|
+
const matchedIndex = yield this.findMatchingIndexMeta(document);
|
|
51
|
+
if (matchedIndex) {
|
|
52
|
+
if (matchedIndex.length == 0) {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
let status = false;
|
|
56
|
+
for (const indexes of matchedIndex) {
|
|
57
|
+
const path = indexes.path;
|
|
58
|
+
const IndexName = indexes.indexFieldName;
|
|
59
|
+
const indexContent = yield this.fileManager.ReadFile(path);
|
|
60
|
+
const indexMeta = this.converter.ToObject(indexContent.data);
|
|
61
|
+
const alreadyhave = Object.keys(indexMeta.indexEntries).some(keys => keys == document[IndexName]);
|
|
62
|
+
if (alreadyhave) {
|
|
63
|
+
indexMeta.indexEntries[document[IndexName]].push(`${document.documentId}${Keys_1.General.DBMS_File_EXT}`);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
indexMeta.indexEntries[document[IndexName]] = [`${document.documentId}${Keys_1.General.DBMS_File_EXT}`];
|
|
67
|
+
}
|
|
68
|
+
// Write it back
|
|
69
|
+
const staus = yield this.fileManager.WriteFile(path, this.converter.ToString(indexMeta));
|
|
70
|
+
status = staus.status;
|
|
71
|
+
}
|
|
72
|
+
return status;
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.default = InsertIndex;
|
|
79
|
+
//# sourceMappingURL=InsertIndex.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InsertIndex.service.js","sourceRoot":"","sources":["../../../source/Services/Index/InsertIndex.service.ts"],"names":[],"mappings":";;;;;;;;;;;AAAA,uDAAuD;AACvD,iDAAiD;AACjD,mDAA+C;AAE/C,MAAqB,WAAY,SAAQ,4BAAY;IAEnD,YAAa,IAAY;QACvB,KAAK,CAAC,IAAI,CAAC,CAAA;IACb,CAAC;IAGD;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA4BC;IACY,aAAa,CAAC,QAAa;;YACpC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAA;YAE/D,IAAI,YAAY,EAAC,CAAC;gBAElB,IAAI,YAAY,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;oBAC7B,OAAO,KAAK,CAAA;gBACd,CAAC;gBAED,IAAI,MAAM,GAAY,KAAK,CAAC;gBAC5B,KAAK,MAAM,OAAO,IAAI,YAAY,EAAE,CAAC;oBACnC,MAAM,IAA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
5
|
+
* Retrieve file path(s) from an index that match the provided query.
|
|
6
|
+
*
|
|
7
|
+
* @param query - An object containing the value to look up. The concrete lookup key is determined
|
|
8
|
+
* by the matched index metadata's `fieldName` (i.e. the method will use
|
|
9
|
+
* query[metaContent.fieldName] to find entries).
|
|
10
|
+
*
|
|
11
|
+
* @returns A Promise that resolves to an array of string file paths associated with the query value.
|
|
12
|
+
* If no matching index metadata is found, the promise resolves to an empty array.
|
|
13
|
+
* If a matching index is found but no entries exist for the queried value, the returned
|
|
14
|
+
* value may be undefined at runtime (callers should guard against a missing entry).
|
|
15
|
+
*
|
|
16
|
+
* @remarks
|
|
17
|
+
* - This method calls `findMatchingIndexMeta(query)` to locate the appropriate index metadata.
|
|
18
|
+
* - When a match is found, it reads the index file via `fileManager.ReadFile(...)` and converts the
|
|
19
|
+
* file content to an object using `converter.ToObject(...)`.
|
|
20
|
+
* - The resolved object is expected to have `indexEntries` and `fieldName` properties. The method
|
|
21
|
+
* uses `indexEntries[query[fieldName]]` to obtain the associated file list.
|
|
22
|
+
* - The index object is logged to the console for debugging purposes.
|
|
23
|
+
*
|
|
24
|
+
* @throws The returned promise will reject if reading or parsing the index file fails (for example,
|
|
25
|
+
* due to I/O errors or converter failures).
|
|
26
|
+
*/
|
|
27
|
+
getFileFromIndex(query: any): Promise<string[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Finds index metadata entries that correspond to properties present on the provided document.
|
|
30
|
+
*
|
|
31
|
+
* Reads the index metadata file at `this.indexMetaPath`, converts its content into an object,
|
|
32
|
+
* and returns the subset of metadata entries whose `indexFieldName` is an own property of `doc`.
|
|
33
|
+
*
|
|
34
|
+
* @param doc - The document to check for matching index fields. The function tests own properties
|
|
35
|
+
* (via `Object.prototype.hasOwnProperty.call`) rather than inherited properties.
|
|
36
|
+
* @returns A Promise that resolves to an array of matching index metadata entries, or `undefined`
|
|
37
|
+
* if the index metadata file could not be successfully read. The array may be empty if
|
|
38
|
+
* no metadata entries match.
|
|
39
|
+
*
|
|
40
|
+
* @throws May propagate errors from `fileManager.ReadFile` or `converter.ToObject` if those
|
|
41
|
+
* operations throw or reject.
|
|
42
|
+
*/
|
|
43
|
+
protected findMatchingIndexMeta(document: any): Promise<any | undefined>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
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
|
+
exports.ReadIndex = void 0;
|
|
13
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
14
|
+
const Index_service_1 = require("./Index.service");
|
|
15
|
+
class ReadIndex extends Index_service_1.IndexManager {
|
|
16
|
+
constructor(path) {
|
|
17
|
+
super(path);
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Retrieve file path(s) from an index that match the provided query.
|
|
21
|
+
*
|
|
22
|
+
* @param query - An object containing the value to look up. The concrete lookup key is determined
|
|
23
|
+
* by the matched index metadata's `fieldName` (i.e. the method will use
|
|
24
|
+
* query[metaContent.fieldName] to find entries).
|
|
25
|
+
*
|
|
26
|
+
* @returns A Promise that resolves to an array of string file paths associated with the query value.
|
|
27
|
+
* If no matching index metadata is found, the promise resolves to an empty array.
|
|
28
|
+
* If a matching index is found but no entries exist for the queried value, the returned
|
|
29
|
+
* value may be undefined at runtime (callers should guard against a missing entry).
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* - This method calls `findMatchingIndexMeta(query)` to locate the appropriate index metadata.
|
|
33
|
+
* - When a match is found, it reads the index file via `fileManager.ReadFile(...)` and converts the
|
|
34
|
+
* file content to an object using `converter.ToObject(...)`.
|
|
35
|
+
* - The resolved object is expected to have `indexEntries` and `fieldName` properties. The method
|
|
36
|
+
* uses `indexEntries[query[fieldName]]` to obtain the associated file list.
|
|
37
|
+
* - The index object is logged to the console for debugging purposes.
|
|
38
|
+
*
|
|
39
|
+
* @throws The returned promise will reject if reading or parsing the index file fails (for example,
|
|
40
|
+
* due to I/O errors or converter failures).
|
|
41
|
+
*/
|
|
42
|
+
getFileFromIndex(query) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const matchedIndexFile = yield this.findMatchingIndexMeta(query);
|
|
45
|
+
if (matchedIndexFile !== undefined) {
|
|
46
|
+
const metaContent = this.converter.ToObject((yield this.fileManager.ReadFile(matchedIndexFile.path)).data);
|
|
47
|
+
const finalValueFiles = metaContent.indexEntries[query[metaContent.fieldName]];
|
|
48
|
+
return finalValueFiles;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Finds index metadata entries that correspond to properties present on the provided document.
|
|
57
|
+
*
|
|
58
|
+
* Reads the index metadata file at `this.indexMetaPath`, converts its content into an object,
|
|
59
|
+
* and returns the subset of metadata entries whose `indexFieldName` is an own property of `doc`.
|
|
60
|
+
*
|
|
61
|
+
* @param doc - The document to check for matching index fields. The function tests own properties
|
|
62
|
+
* (via `Object.prototype.hasOwnProperty.call`) rather than inherited properties.
|
|
63
|
+
* @returns A Promise that resolves to an array of matching index metadata entries, or `undefined`
|
|
64
|
+
* if the index metadata file could not be successfully read. The array may be empty if
|
|
65
|
+
* no metadata entries match.
|
|
66
|
+
*
|
|
67
|
+
* @throws May propagate errors from `fileManager.ReadFile` or `converter.ToObject` if those
|
|
68
|
+
* operations throw or reject.
|
|
69
|
+
*/
|
|
70
|
+
findMatchingIndexMeta(document) {
|
|
71
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
72
|
+
const indexMetaContent = yield this.fileManager.ReadFile(this.indexMetaPath);
|
|
73
|
+
if (indexMetaContent.status) {
|
|
74
|
+
const indexMeta = this.converter.ToObject(indexMetaContent.data);
|
|
75
|
+
return indexMeta.find((meta) => Object.prototype.hasOwnProperty.call(document, meta.indexFieldName));
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.ReadIndex = ReadIndex;
|
|
81
|
+
//# sourceMappingURL=ReadIndex.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReadIndex.service.js","sourceRoot":"","sources":["../../../source/Services/Index/ReadIndex.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAuD;AACvD,mDAA+C;AAE/C,MAAa,SAAU,SAAQ,4BAAY;IAEzC,YAAa,IAAY;QACvB,KAAK,CAAC,IAAI,CAAC,CAAA;IACb,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACU,gBAAgB,CAAE,KAAU;;YACvC,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,KAAK,CAAC,CAAA;YAChE,IAAG,gBAAgB,KAAK,SAAS,EAAE,CAAC;gBAClC,MAAM,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;gBAC3G,MAAM,eAAe,GAAG,WAAW,CAAC,YAAY,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,CAAA;gBAC9E,OAAO,eAAe,CAAC;YACzB,CAAC;iBACI,CAAC;gBACJ,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;KAAA;IAED;;;;;;;;;;;;;;KAcC;IACe,qBAAqB,CAAC,QAAa;;YACjD,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;YAC7E,IAAI,gBAAgB,CAAC,MAAM,EAAE,CAAC;gBAC5B,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;gBACjE,OAAO,SAAS,CAAC,IAAI,CAAC,CAAC,IAA8B,EAAE,EAAE,CACvD,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,cAAc,CAAC,CACpE,CAAC;YACJ,CAAC;QACH,CAAC;KAAA;CACF;AAjED,8BAiEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "axiodb",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.32.115",
|
|
4
4
|
"description": "The Pure JavaScript Alternative to SQLite. Embedded NoSQL database for Node.js with MongoDB-style queries, zero native dependencies, built-in InMemoryCache, and web GUI. Perfect for desktop apps, CLI tools, and embedded systems. No compilation, no platform issues—pure JavaScript from npm install to production.",
|
|
5
5
|
"main": "./lib/config/DB.js",
|
|
6
6
|
"types": "./lib/config/DB.d.ts",
|