apexify.js 2.4.4 → 3.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/README.md +4 -710
- package/dataSQL/data.sql +5 -0
- package/dataSQL/dataName.sql +0 -0
- package/dataSQL/example_table.sql +1 -0
- package/index.js +3 -78
- package/lib/ai/apexAI.js +2 -2
- package/lib/{discord/events/handler → ai/buttons}/tools.js +1 -1
- package/lib/utils.js +2 -72
- package/package.json +2 -81
- package/lib/canvas/themes/level ara.ttf +0 -0
- package/lib/canvas/themes/levelFont.ttf +0 -0
- package/lib/canvas/themes/levels-card.js +0 -884
- package/lib/canvas/themes/music-card.js +0 -342
- package/lib/canvas/themes/numbers.ttf +0 -0
- package/lib/canvas/themes/tajawal.ttf +0 -0
- package/lib/database/MongoDB.js +0 -126
- package/lib/database/NanoDB.js +0 -1341
- package/lib/database/mongoDb/aggregate.js +0 -120
- package/lib/database/mongoDb/countDocs.js +0 -115
- package/lib/database/mongoDb/createCollection.js +0 -125
- package/lib/database/mongoDb/dataSize.js +0 -89
- package/lib/database/mongoDb/distinct.js +0 -110
- package/lib/database/mongoDb/drop.js +0 -76
- package/lib/database/mongoDb/find.js +0 -122
- package/lib/database/mongoDb/geoNear.js +0 -91
- package/lib/database/mongoDb/index.js +0 -71
- package/lib/database/mongoDb/listCollections.js +0 -81
- package/lib/database/mongoDb/migrateAndPrune.js +0 -89
- package/lib/database/mongoDb/migrateData.js +0 -79
- package/lib/database/mongoDb/remove.js +0 -73
- package/lib/database/mongoDb/removeMany.js +0 -73
- package/lib/database/mongoDb/removeManyExcept.js +0 -91
- package/lib/database/mongoDb/removeSpecific.js +0 -93
- package/lib/database/mongoDb/save.js +0 -94
- package/lib/database/mongoDb/searchMany.js +0 -109
- package/lib/database/mongoDb/textSearch.js +0 -88
- package/lib/database/mongoDb/updateAll.js +0 -80
- package/lib/database/mongoDb/updateAllExcept.js +0 -108
- package/lib/database/mongoDb/updateData.js +0 -106
- package/lib/database/nanoDb/fetchData.js +0 -39
- package/lib/database/nanoDb/removeField.js +0 -46
- package/lib/database/nanoDb/saveData.js +0 -68
- package/lib/database/nanoDb/updateFilter.js +0 -24
- package/lib/database/ready-schemas.js +0 -245
- package/lib/database/utils.js +0 -58
- package/lib/discord/discord-build/commands-(prefix)/music/functions/buttons.js +0 -361
- package/lib/discord/discord-build/commands-(prefix)/music/functions/end.js +0 -58
- package/lib/discord/discord-build/commands-(prefix)/music/functions/start.js +0 -115
- package/lib/discord/discord-build/commands-(prefix)/music/play.js +0 -152
- package/lib/discord/discord-build/commands-(prefix)/music/previous.js +0 -82
- package/lib/discord/discord-build/commands-(prefix)/music/resume.js +0 -93
- package/lib/discord/discord-build/commands-(prefix)/music/skip.js +0 -82
- package/lib/discord/discord-build/commands-(prefix)/music/stop.js +0 -79
- package/lib/discord/discord-build/components/buttons.js +0 -75
- package/lib/discord/discord-build/components/menus.js +0 -81
- package/lib/discord/discord-build/components/paginator.js +0 -156
- package/lib/discord/discord-build/components/permsChecker.js +0 -81
- package/lib/discord/discord-build/levelingSystem/cLevel.js +0 -829
- package/lib/discord/discord-build/levelingSystem/cLevelsArray.json +0 -104
- package/lib/discord/discord-build/utils.js +0 -23
- package/lib/discord/events/eventer.js +0 -145
- package/lib/discord/events/prefixRegister.js +0 -148
- package/lib/discord/events/prefixResponder.js +0 -163
- package/lib/discord/events/slashRegister.js +0 -183
- package/lib/discord/events/slashResponder.js +0 -108
- package/lib/discord/events/starter.js +0 -441
- package/lib/discord/functions/perms.js +0 -19
- package/lib/discord/utils.js +0 -6
- package/lib/general-functions/discord/typeWriter.js +0 -77
- package/lib/general-functions/utils.js +0 -19
- /package/lib/{discord/events/handler → ai/buttons}/drawMenu.js +0 -0
|
@@ -1,120 +0,0 @@
|
|
|
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 __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.aggregate = void 0;
|
|
40
|
-
var { getDb } = require("../MongoDB");
|
|
41
|
-
function aggregate(collectionName, pipeline, options) {
|
|
42
|
-
if (options === void 0) { options = {}; }
|
|
43
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
44
|
-
var db, validOptions, aggregationOptions, _i, _a, _b, key, expectedType, result, error_1;
|
|
45
|
-
return __generator(this, function (_c) {
|
|
46
|
-
switch (_c.label) {
|
|
47
|
-
case 0:
|
|
48
|
-
_c.trys.push([0, 3, , 4]);
|
|
49
|
-
return [4 /*yield*/, (0, getDb)()];
|
|
50
|
-
case 1:
|
|
51
|
-
db = _c.sent();
|
|
52
|
-
if (!db)
|
|
53
|
-
return [2 /*return*/, { success: false, result: null, message: 'Failed to connect to the database.' }];
|
|
54
|
-
if (typeof collectionName !== 'string') {
|
|
55
|
-
throw new Error('Invalid input. Collection name must be a string.');
|
|
56
|
-
}
|
|
57
|
-
if (!Array.isArray(pipeline)) {
|
|
58
|
-
throw new Error('Invalid input. Aggregation pipeline must be an array.');
|
|
59
|
-
}
|
|
60
|
-
validOptions = {
|
|
61
|
-
allowDiskUse: 'boolean',
|
|
62
|
-
batchSize: 'number',
|
|
63
|
-
collation: 'object',
|
|
64
|
-
maxTimeMS: 'number',
|
|
65
|
-
explain: 'boolean',
|
|
66
|
-
hint: 'object',
|
|
67
|
-
comment: 'string',
|
|
68
|
-
maxAwaitTimeMS: 'number',
|
|
69
|
-
bypassDocumentValidation: 'boolean',
|
|
70
|
-
session: 'object',
|
|
71
|
-
readConcern: 'object',
|
|
72
|
-
writeConcern: 'object',
|
|
73
|
-
raw: 'boolean',
|
|
74
|
-
promoteLongs: 'boolean',
|
|
75
|
-
promoteValues: 'boolean',
|
|
76
|
-
promoteBuffers: 'boolean',
|
|
77
|
-
cursor: 'object',
|
|
78
|
-
max: 'number',
|
|
79
|
-
maxScan: 'number',
|
|
80
|
-
min: 'number',
|
|
81
|
-
returnKey: 'boolean',
|
|
82
|
-
showDiskLoc: 'boolean',
|
|
83
|
-
snapshot: 'boolean',
|
|
84
|
-
sort: 'object',
|
|
85
|
-
tailable: 'boolean',
|
|
86
|
-
};
|
|
87
|
-
aggregationOptions = {};
|
|
88
|
-
for (_i = 0, _a = Object.entries(validOptions); _i < _a.length; _i++) {
|
|
89
|
-
_b = _a[_i], key = _b[0], expectedType = _b[1];
|
|
90
|
-
if (options[key] !== undefined) {
|
|
91
|
-
if (typeof options[key] === expectedType) {
|
|
92
|
-
aggregationOptions[key] = options[key];
|
|
93
|
-
}
|
|
94
|
-
else {
|
|
95
|
-
throw new Error("Invalid input. ".concat(key, " must be of type ").concat(expectedType, "."));
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return [4 /*yield*/, db.collection(collectionName).aggregate(pipeline, aggregationOptions).toArray()];
|
|
100
|
-
case 2:
|
|
101
|
-
result = _c.sent();
|
|
102
|
-
return [2 /*return*/, {
|
|
103
|
-
success: true,
|
|
104
|
-
result: result || null,
|
|
105
|
-
}];
|
|
106
|
-
case 3:
|
|
107
|
-
error_1 = _c.sent();
|
|
108
|
-
console.error('Error:', error_1.message);
|
|
109
|
-
return [2 /*return*/, {
|
|
110
|
-
success: false,
|
|
111
|
-
message: error_1.message,
|
|
112
|
-
result: null,
|
|
113
|
-
}];
|
|
114
|
-
case 4: return [2 /*return*/];
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
exports.aggregate = aggregate;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.countDocs = void 0;
|
|
51
|
-
var { getDb } = require("../MongoDB");
|
|
52
|
-
function countDocs(collectionName, fieldName, options) {
|
|
53
|
-
if (fieldName === void 0) { fieldName = '_id'; }
|
|
54
|
-
if (options === void 0) { options = {}; }
|
|
55
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
-
var db, validOptions, countOptions, _i, _a, _b, key, expectedType, filter, result, error_1;
|
|
57
|
-
var _c;
|
|
58
|
-
return __generator(this, function (_d) {
|
|
59
|
-
switch (_d.label) {
|
|
60
|
-
case 0:
|
|
61
|
-
_d.trys.push([0, 3, , 4]);
|
|
62
|
-
return [4 /*yield*/, (0, getDb)()];
|
|
63
|
-
case 1:
|
|
64
|
-
db = _d.sent();
|
|
65
|
-
if (!db)
|
|
66
|
-
return [2 /*return*/, { success: false, count: null, errorMessage: 'Failed to connect to the database.' }];
|
|
67
|
-
if (typeof collectionName !== 'string') {
|
|
68
|
-
throw new Error('Invalid input. Collection name must be a string.');
|
|
69
|
-
}
|
|
70
|
-
if (typeof fieldName !== 'string') {
|
|
71
|
-
throw new Error('Invalid input. Field name must be a string.');
|
|
72
|
-
}
|
|
73
|
-
validOptions = {
|
|
74
|
-
filter: 'object',
|
|
75
|
-
limit: 'number',
|
|
76
|
-
skip: 'number',
|
|
77
|
-
collation: 'object',
|
|
78
|
-
maxTimeMS: 'number',
|
|
79
|
-
readConcern: 'object',
|
|
80
|
-
};
|
|
81
|
-
countOptions = {};
|
|
82
|
-
for (_i = 0, _a = Object.entries(validOptions); _i < _a.length; _i++) {
|
|
83
|
-
_b = _a[_i], key = _b[0], expectedType = _b[1];
|
|
84
|
-
if (options[key] !== undefined) {
|
|
85
|
-
if (typeof options[key] === expectedType) {
|
|
86
|
-
countOptions[key] = options[key];
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
throw new Error("Invalid input. ".concat(key, " must be of type ").concat(expectedType, "."));
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
filter = __assign((_c = {}, _c[fieldName] = { $exists: true }, _c), countOptions.filter);
|
|
94
|
-
return [4 /*yield*/, db.collection(collectionName).countDocuments(filter, countOptions)];
|
|
95
|
-
case 2:
|
|
96
|
-
result = _d.sent();
|
|
97
|
-
return [2 /*return*/, {
|
|
98
|
-
success: true,
|
|
99
|
-
count: result,
|
|
100
|
-
}];
|
|
101
|
-
case 3:
|
|
102
|
-
error_1 = _d.sent();
|
|
103
|
-
console.error('Error:', error_1.message);
|
|
104
|
-
return [2 /*return*/, {
|
|
105
|
-
success: false,
|
|
106
|
-
errorMessage: error_1.message,
|
|
107
|
-
count: null,
|
|
108
|
-
}];
|
|
109
|
-
case 4: return [2 /*return*/];
|
|
110
|
-
}
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
exports.countDocs = countDocs;
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.createTable = void 0;
|
|
51
|
-
var { getDb } = require("../MongoDB");
|
|
52
|
-
function createTable(collectionName, options) {
|
|
53
|
-
if (options === void 0) { options = {}; }
|
|
54
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
55
|
-
var db, existingCollections, existingCollectionNames, createOptions, validOptions, _i, _a, _b, key, expectedType, error_1;
|
|
56
|
-
return __generator(this, function (_c) {
|
|
57
|
-
switch (_c.label) {
|
|
58
|
-
case 0:
|
|
59
|
-
_c.trys.push([0, 4, , 5]);
|
|
60
|
-
if (!collectionName || typeof collectionName !== 'string' || collectionName.trim().length === 0) {
|
|
61
|
-
throw new Error('Invalid input. Collection name must be provided as a non-empty string.');
|
|
62
|
-
}
|
|
63
|
-
return [4 /*yield*/, (0, getDb)()];
|
|
64
|
-
case 1:
|
|
65
|
-
db = _c.sent();
|
|
66
|
-
if (!db) {
|
|
67
|
-
return [2 /*return*/, {
|
|
68
|
-
success: false,
|
|
69
|
-
message: 'Failed to create collection. No active MongoDB connection.',
|
|
70
|
-
}];
|
|
71
|
-
}
|
|
72
|
-
return [4 /*yield*/, db.listCollections().toArray()];
|
|
73
|
-
case 2:
|
|
74
|
-
existingCollections = _c.sent();
|
|
75
|
-
existingCollectionNames = existingCollections.map(function (collection) { return collection.name; });
|
|
76
|
-
if (existingCollectionNames.includes(collectionName)) {
|
|
77
|
-
throw new Error("Collection with name '".concat(collectionName, "' already exists."));
|
|
78
|
-
}
|
|
79
|
-
createOptions = __assign({}, options);
|
|
80
|
-
validOptions = {
|
|
81
|
-
capped: 'boolean',
|
|
82
|
-
autoIndexId: 'boolean',
|
|
83
|
-
size: 'number',
|
|
84
|
-
max: 'number',
|
|
85
|
-
storageEngine: 'object',
|
|
86
|
-
validator: 'object',
|
|
87
|
-
validationLevel: 'string',
|
|
88
|
-
validationAction: 'string',
|
|
89
|
-
collation: 'object',
|
|
90
|
-
indexOptionDefaults: 'object',
|
|
91
|
-
writeConcern: 'object',
|
|
92
|
-
raw: 'boolean',
|
|
93
|
-
};
|
|
94
|
-
for (_i = 0, _a = Object.entries(validOptions); _i < _a.length; _i++) {
|
|
95
|
-
_b = _a[_i], key = _b[0], expectedType = _b[1];
|
|
96
|
-
if (options[key] !== undefined) {
|
|
97
|
-
if (typeof options[key] === expectedType) {
|
|
98
|
-
createOptions[key] = options[key];
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
throw new Error("Invalid input. ".concat(key, " must be of type ").concat(expectedType, "."));
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return [4 /*yield*/, db.createCollection(collectionName, createOptions)];
|
|
106
|
-
case 3:
|
|
107
|
-
_c.sent();
|
|
108
|
-
return [2 /*return*/, {
|
|
109
|
-
success: true,
|
|
110
|
-
message: "Created collection: ".concat(collectionName),
|
|
111
|
-
}];
|
|
112
|
-
case 4:
|
|
113
|
-
error_1 = _c.sent();
|
|
114
|
-
console.error('Error:', error_1.message);
|
|
115
|
-
return [2 /*return*/, {
|
|
116
|
-
success: false,
|
|
117
|
-
message: "Failed to create collection in MongoDB. ".concat(error_1.message || 'Error details not available.'),
|
|
118
|
-
}];
|
|
119
|
-
case 5: return [2 /*return*/];
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
exports.createTable = createTable;
|
|
@@ -1,89 +0,0 @@
|
|
|
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 __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.dataSize = void 0;
|
|
40
|
-
var { getDb } = require("../MongoDB");
|
|
41
|
-
function dataSize(collectionName) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var db, collectionExists, stats, dataSizeInBytes, dataSizeInKB, error_1;
|
|
44
|
-
return __generator(this, function (_a) {
|
|
45
|
-
switch (_a.label) {
|
|
46
|
-
case 0:
|
|
47
|
-
_a.trys.push([0, 4, , 5]);
|
|
48
|
-
if (!collectionName || typeof collectionName !== 'string' || collectionName.trim().length === 0) {
|
|
49
|
-
throw new Error('Invalid input. Collection name must be provided as a non-empty string.');
|
|
50
|
-
}
|
|
51
|
-
return [4 /*yield*/, (0, getDb)()];
|
|
52
|
-
case 1:
|
|
53
|
-
db = _a.sent();
|
|
54
|
-
if (!db) {
|
|
55
|
-
return [2 /*return*/, {
|
|
56
|
-
success: false,
|
|
57
|
-
message: 'Failed to retrieve data size. No active MongoDB connection.',
|
|
58
|
-
}];
|
|
59
|
-
}
|
|
60
|
-
return [4 /*yield*/, db.listCollections({ name: collectionName }).hasNext()];
|
|
61
|
-
case 2:
|
|
62
|
-
collectionExists = _a.sent();
|
|
63
|
-
if (!collectionExists) {
|
|
64
|
-
throw new Error("Collection '".concat(collectionName, "' not found."));
|
|
65
|
-
}
|
|
66
|
-
return [4 /*yield*/, db.collection(collectionName).stats()];
|
|
67
|
-
case 3:
|
|
68
|
-
stats = _a.sent();
|
|
69
|
-
dataSizeInBytes = stats.size;
|
|
70
|
-
dataSizeInKB = dataSizeInBytes / 1024;
|
|
71
|
-
return [2 /*return*/, {
|
|
72
|
-
success: true,
|
|
73
|
-
dataSizeInKB: dataSizeInKB,
|
|
74
|
-
}];
|
|
75
|
-
case 4:
|
|
76
|
-
error_1 = _a.sent();
|
|
77
|
-
console.error('Error:', error_1.message);
|
|
78
|
-
return [2 /*return*/, {
|
|
79
|
-
success: false,
|
|
80
|
-
message: error_1.message,
|
|
81
|
-
dataSizeInKB: null,
|
|
82
|
-
}];
|
|
83
|
-
case 5: return [2 /*return*/];
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
exports.dataSize = dataSize;
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
-
exports.distinct = void 0;
|
|
51
|
-
var { getDb } = require("../MongoDB");
|
|
52
|
-
function distinct(collectionName, key, filter, options) {
|
|
53
|
-
if (filter === void 0) { filter = {}; }
|
|
54
|
-
if (options === void 0) { options = {}; }
|
|
55
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
-
var db, distinctOptions, validOptions, _i, _a, _b, option, expectedType, result, error_1;
|
|
57
|
-
return __generator(this, function (_c) {
|
|
58
|
-
switch (_c.label) {
|
|
59
|
-
case 0:
|
|
60
|
-
_c.trys.push([0, 3, , 4]);
|
|
61
|
-
return [4 /*yield*/, (0, getDb)()];
|
|
62
|
-
case 1:
|
|
63
|
-
db = _c.sent();
|
|
64
|
-
if (!db)
|
|
65
|
-
return [2 /*return*/, { success: false, distinctValues: null, message: 'No active MongoDB connection.' }];
|
|
66
|
-
if (!collectionName || typeof collectionName !== 'string' || collectionName.trim().length === 0) {
|
|
67
|
-
throw new Error('Invalid input. Collection name must be provided as a non-empty string.');
|
|
68
|
-
}
|
|
69
|
-
if (!key || typeof key !== 'string' || key.trim().length === 0) {
|
|
70
|
-
throw new Error('Invalid input. Key must be provided as a non-empty string.');
|
|
71
|
-
}
|
|
72
|
-
distinctOptions = __assign({}, options);
|
|
73
|
-
validOptions = {
|
|
74
|
-
collation: 'object',
|
|
75
|
-
maxTimeMS: 'number',
|
|
76
|
-
readConcern: 'object',
|
|
77
|
-
};
|
|
78
|
-
for (_i = 0, _a = Object.entries(validOptions); _i < _a.length; _i++) {
|
|
79
|
-
_b = _a[_i], option = _b[0], expectedType = _b[1];
|
|
80
|
-
if (options[option] !== undefined) {
|
|
81
|
-
if (typeof options[option] === expectedType) {
|
|
82
|
-
distinctOptions[option] = options[option];
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
throw new Error("Invalid input. ".concat(option, " must be of type ").concat(expectedType, "."));
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
return [4 /*yield*/, db.collection(collectionName).distinct(key, filter, distinctOptions)];
|
|
90
|
-
case 2:
|
|
91
|
-
result = _c.sent();
|
|
92
|
-
return [2 /*return*/, {
|
|
93
|
-
success: true,
|
|
94
|
-
distinctValues: result,
|
|
95
|
-
}];
|
|
96
|
-
case 3:
|
|
97
|
-
error_1 = _c.sent();
|
|
98
|
-
console.error('Error:', error_1.message);
|
|
99
|
-
return [2 /*return*/, {
|
|
100
|
-
success: false,
|
|
101
|
-
message: error_1.message,
|
|
102
|
-
distinctValues: null,
|
|
103
|
-
}];
|
|
104
|
-
case 4: return [2 /*return*/];
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
exports.distinct = distinct;
|
|
@@ -1,76 +0,0 @@
|
|
|
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 __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.drop = void 0;
|
|
40
|
-
var { getDb } = require("../MongoDB");
|
|
41
|
-
function drop(collectionName) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var db, result, error_1;
|
|
44
|
-
return __generator(this, function (_a) {
|
|
45
|
-
switch (_a.label) {
|
|
46
|
-
case 0:
|
|
47
|
-
_a.trys.push([0, 3, , 4]);
|
|
48
|
-
return [4 /*yield*/, (0, getDb)()];
|
|
49
|
-
case 1:
|
|
50
|
-
db = _a.sent();
|
|
51
|
-
if (!db)
|
|
52
|
-
return [2 /*return*/, { success: false, message: 'No active MongoDB connection.' }];
|
|
53
|
-
if (!collectionName || typeof collectionName !== 'string' || collectionName.trim().length === 0) {
|
|
54
|
-
throw new Error('Invalid input. Collection name must be provided as a non-empty string.');
|
|
55
|
-
}
|
|
56
|
-
return [4 /*yield*/, db.collection(collectionName).drop()];
|
|
57
|
-
case 2:
|
|
58
|
-
result = _a.sent();
|
|
59
|
-
return [2 /*return*/, {
|
|
60
|
-
success: true,
|
|
61
|
-
message: "Collection ".concat(collectionName, " dropped successfully."),
|
|
62
|
-
}];
|
|
63
|
-
case 3:
|
|
64
|
-
error_1 = _a.sent();
|
|
65
|
-
console.error('Error:', error_1.message);
|
|
66
|
-
return [2 /*return*/, {
|
|
67
|
-
success: false,
|
|
68
|
-
message: "Failed to drop collection in MongoDB. ".concat(error_1.message || 'Error details not available.'),
|
|
69
|
-
}];
|
|
70
|
-
case 4: return [2 /*return*/];
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
exports.drop = drop;
|