c2-mongoose 1.0.0 → 1.0.2
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/dist/configuration/Environment.d.ts +4 -0
- package/dist/configuration/Environment.js +5 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +7 -0
- package/dist/model/Search.d.ts +26 -0
- package/dist/model/Search.js +260 -0
- package/dist/src/index.js +4 -24
- package/dist/utils/Utils.d.ts +6 -0
- package/dist/utils/Utils.js +56 -0
- package/package.json +5 -2
- package/src/index.ts +3 -1
- package/src/model/Search.ts +1 -1
- package/tsconfig.json +10 -102
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
var Search_1 = __importDefault(require("./model/Search"));
|
|
7
|
+
exports.default = Search_1.default;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import mongoose from "mongoose";
|
|
2
|
+
declare abstract class Search {
|
|
3
|
+
searchText: string;
|
|
4
|
+
order: string;
|
|
5
|
+
orderBy: string;
|
|
6
|
+
page: number;
|
|
7
|
+
limit: number;
|
|
8
|
+
select: string;
|
|
9
|
+
populate: string | [] | any;
|
|
10
|
+
filters: any;
|
|
11
|
+
constructor(params: any);
|
|
12
|
+
buildPopulate: () => any;
|
|
13
|
+
buildPath: (target: string, nested?: string) => any;
|
|
14
|
+
buildOrdenation: () => any;
|
|
15
|
+
private isPageable;
|
|
16
|
+
private diacriticSensitiveRegex;
|
|
17
|
+
search: (model: mongoose.Model<any>) => Promise<SearchResponse<any>>;
|
|
18
|
+
private searchPageable;
|
|
19
|
+
private searchNoPageable;
|
|
20
|
+
private result;
|
|
21
|
+
count: (model: mongoose.Model<any>) => Promise<number>;
|
|
22
|
+
sumBy: (model: mongoose.Model<any>, _sum: any, _by: any) => Promise<any[]>;
|
|
23
|
+
buildDefaultFilters: (objectSearch: any) => any;
|
|
24
|
+
addFilterModel: (model: any, filters: any) => void;
|
|
25
|
+
}
|
|
26
|
+
export default Search;
|
|
@@ -0,0 +1,260 @@
|
|
|
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
|
+
var Environment_1 = require("../configuration/Environment");
|
|
51
|
+
var Utils_1 = require("../utils/Utils");
|
|
52
|
+
var Search = /** @class */ (function () {
|
|
53
|
+
function Search(params) {
|
|
54
|
+
var _this = this;
|
|
55
|
+
this.buildPopulate = function () {
|
|
56
|
+
if ((0, Utils_1.isEmpty)(_this.populate)) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
var propertiesArray = _this.populate.split(',');
|
|
60
|
+
var populates = [];
|
|
61
|
+
for (var _i = 0, propertiesArray_1 = propertiesArray; _i < propertiesArray_1.length; _i++) {
|
|
62
|
+
var property = propertiesArray_1[_i];
|
|
63
|
+
var _a = property.split('.'), first = _a[0], rest = _a.slice(1);
|
|
64
|
+
var nested = rest.join('.');
|
|
65
|
+
populates.push(_this.buildPath(first, nested));
|
|
66
|
+
}
|
|
67
|
+
_this.populate = populates;
|
|
68
|
+
};
|
|
69
|
+
this.buildPath = function (target, nested) {
|
|
70
|
+
if (nested === void 0) { nested = ""; }
|
|
71
|
+
var populate = {};
|
|
72
|
+
populate.path = target;
|
|
73
|
+
if ((0, Utils_1.isNotEmpty)(nested)) {
|
|
74
|
+
var _a = nested.split('.'), first = _a[0], rest = _a.slice(1);
|
|
75
|
+
var nested2 = rest.join('.');
|
|
76
|
+
populate.populate = _this.buildPath(first, nested2);
|
|
77
|
+
}
|
|
78
|
+
return populate;
|
|
79
|
+
};
|
|
80
|
+
this.buildOrdenation = function () {
|
|
81
|
+
var order = {};
|
|
82
|
+
_this.orderBy = _this.orderBy || "_id";
|
|
83
|
+
order[_this.orderBy] = _this.order === "desc" ? -1 : 1;
|
|
84
|
+
return order;
|
|
85
|
+
};
|
|
86
|
+
this.isPageable = function () {
|
|
87
|
+
if (_this.page >= 0) {
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
return false;
|
|
91
|
+
};
|
|
92
|
+
this.diacriticSensitiveRegex = function (string) {
|
|
93
|
+
if (string === void 0) { string = ""; }
|
|
94
|
+
return string
|
|
95
|
+
.replace(/[a|á|à|ä|â|A|Á|Â|Ã|Ä]/g, '[a,á,à,ä,â,A,Á,Â,Ã,Ä]')
|
|
96
|
+
.replace(/[e|é|ë|è|E|É|Ë|È]/g, '[e,é,ë,è,E,É,Ë,È]')
|
|
97
|
+
.replace(/[i|í|ï|ì|I|Í|Ï|Ì]/g, '[i,í,ï,ì,I,Í,Ï,Ì]')
|
|
98
|
+
.replace(/[o|ó|ö|ò|õ|O|Ó|Ö|Ô|Õ]/g, '[o,ó,ö,ò,õ,O,Ó,Ö,Ô,Õ]')
|
|
99
|
+
.replace(/[u|ü|ú|ù|U|Ú|Ü|Ù]/g, '[u,ü,ú,ù,U,Ú,Ü,Ù]')
|
|
100
|
+
.replace(/[ç|Ç|c|C]/g, '[c,C,ç,Ç]');
|
|
101
|
+
};
|
|
102
|
+
this.search = function (model) { return __awaiter(_this, void 0, void 0, function () {
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0:
|
|
106
|
+
if (!this.isPageable()) return [3 /*break*/, 2];
|
|
107
|
+
return [4 /*yield*/, this.searchPageable(model)];
|
|
108
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
109
|
+
case 2: return [4 /*yield*/, this.searchNoPageable(model)];
|
|
110
|
+
case 3: return [2 /*return*/, _a.sent()];
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}); };
|
|
114
|
+
this.searchPageable = function (model) { return __awaiter(_this, void 0, void 0, function () {
|
|
115
|
+
var sort, items;
|
|
116
|
+
return __generator(this, function (_a) {
|
|
117
|
+
switch (_a.label) {
|
|
118
|
+
case 0:
|
|
119
|
+
sort = this.buildOrdenation();
|
|
120
|
+
return [4 /*yield*/, model
|
|
121
|
+
.find(this.filters, this.select)
|
|
122
|
+
.populate(this.populate)
|
|
123
|
+
.skip(this.page * this.limit)
|
|
124
|
+
.limit(this.limit)
|
|
125
|
+
.sort(sort)
|
|
126
|
+
.collation({
|
|
127
|
+
locale: Environment_1.dbCollation || "pt"
|
|
128
|
+
})];
|
|
129
|
+
case 1:
|
|
130
|
+
items = _a.sent();
|
|
131
|
+
return [2 /*return*/, this.result(model, items)];
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
}); };
|
|
135
|
+
this.searchNoPageable = function (model) { return __awaiter(_this, void 0, void 0, function () {
|
|
136
|
+
var sort, items;
|
|
137
|
+
return __generator(this, function (_a) {
|
|
138
|
+
switch (_a.label) {
|
|
139
|
+
case 0:
|
|
140
|
+
sort = this.buildOrdenation();
|
|
141
|
+
return [4 /*yield*/, model
|
|
142
|
+
.find(this.filters, this.select)
|
|
143
|
+
.populate(this.populate)
|
|
144
|
+
.sort(sort)
|
|
145
|
+
.collation({
|
|
146
|
+
locale: Environment_1.dbCollation || "pt"
|
|
147
|
+
})];
|
|
148
|
+
case 1:
|
|
149
|
+
items = _a.sent();
|
|
150
|
+
return [2 /*return*/, this.result(model, items)];
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}); };
|
|
154
|
+
this.result = function (model, items) { return __awaiter(_this, void 0, void 0, function () {
|
|
155
|
+
var total, paging, searchResponse;
|
|
156
|
+
return __generator(this, function (_a) {
|
|
157
|
+
switch (_a.label) {
|
|
158
|
+
case 0: return [4 /*yield*/, this.count(model)];
|
|
159
|
+
case 1:
|
|
160
|
+
total = _a.sent();
|
|
161
|
+
paging = {};
|
|
162
|
+
paging.total = total;
|
|
163
|
+
paging.page = this.page;
|
|
164
|
+
paging.limit = this.limit;
|
|
165
|
+
searchResponse = {};
|
|
166
|
+
searchResponse.items = items;
|
|
167
|
+
searchResponse.paging = paging;
|
|
168
|
+
return [2 /*return*/, searchResponse];
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
}); };
|
|
172
|
+
this.count = function (model) { return __awaiter(_this, void 0, void 0, function () {
|
|
173
|
+
return __generator(this, function (_a) {
|
|
174
|
+
switch (_a.label) {
|
|
175
|
+
case 0: return [4 /*yield*/, model.countDocuments(this.filters).exec()];
|
|
176
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}); };
|
|
180
|
+
this.sumBy = function (model, _sum, _by) { return __awaiter(_this, void 0, void 0, function () {
|
|
181
|
+
var ret;
|
|
182
|
+
return __generator(this, function (_a) {
|
|
183
|
+
switch (_a.label) {
|
|
184
|
+
case 0: return [4 /*yield*/, model.aggregate([
|
|
185
|
+
{
|
|
186
|
+
'$match': this.filters
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
$group: {
|
|
190
|
+
_id: _by,
|
|
191
|
+
totalValue: { "$sum": _sum },
|
|
192
|
+
count: { "$sum": 1 }
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
])];
|
|
196
|
+
case 1:
|
|
197
|
+
ret = _a.sent();
|
|
198
|
+
return [2 /*return*/, ret];
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}); };
|
|
202
|
+
this.buildDefaultFilters = function (objectSearch) {
|
|
203
|
+
var filters = { $and: [] };
|
|
204
|
+
Object.entries(objectSearch).forEach(function (_a) {
|
|
205
|
+
var key = _a[0], value = _a[1];
|
|
206
|
+
if ((0, Utils_1.isNotEmpty)(value)) {
|
|
207
|
+
var condition = {};
|
|
208
|
+
if (['order', 'orderBy', 'properties', 'populate', 'page', 'limit', 'model', 'searchText'].includes(key)) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
if (key.endsWith('DateRange')) {
|
|
212
|
+
var keyAux = key.replace('Range', '');
|
|
213
|
+
var values = value;
|
|
214
|
+
if ((0, Utils_1.isNotEmpty)(values[0])) {
|
|
215
|
+
condition[keyAux] = __assign(__assign({}, condition[keyAux]), { $gte: new Date(values[0]) });
|
|
216
|
+
}
|
|
217
|
+
if ((0, Utils_1.isNotEmpty)(values[1])) {
|
|
218
|
+
condition[keyAux] = __assign(__assign({}, condition[keyAux]), { $lte: new Date(values[1]) });
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
if (!Array.isArray(value)) {
|
|
223
|
+
condition[key] = value;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
condition[key] = { $in: value };
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
filters.$and.push(condition);
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
if ((0, Utils_1.isNotEmpty)(objectSearch.model)) {
|
|
233
|
+
_this.addFilterModel(objectSearch.model, filters);
|
|
234
|
+
}
|
|
235
|
+
if (filters.$and.length === 0)
|
|
236
|
+
delete filters['$and'];
|
|
237
|
+
return filters;
|
|
238
|
+
};
|
|
239
|
+
this.addFilterModel = function (model, filters) {
|
|
240
|
+
Object.entries(model).forEach(function (_a) {
|
|
241
|
+
var key = _a[0], value = _a[1];
|
|
242
|
+
if ((0, Utils_1.isNotEmpty)(value)) {
|
|
243
|
+
var condition = {};
|
|
244
|
+
condition[key] = value;
|
|
245
|
+
filters.$and.push(condition);
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
};
|
|
249
|
+
this.searchText = params.searchText || "";
|
|
250
|
+
this.order = params.order || "asc";
|
|
251
|
+
this.orderBy = params.orderBy || "_id";
|
|
252
|
+
this.select = params.select;
|
|
253
|
+
this.populate = params.populate;
|
|
254
|
+
this.page = params.page || -1;
|
|
255
|
+
this.limit = params.limit || 25;
|
|
256
|
+
this.buildPopulate();
|
|
257
|
+
}
|
|
258
|
+
return Search;
|
|
259
|
+
}());
|
|
260
|
+
exports.default = Search;
|
package/dist/src/index.js
CHANGED
|
@@ -1,27 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
24
4
|
};
|
|
25
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
|
|
27
|
-
exports.
|
|
6
|
+
const Search_1 = __importDefault(require("./model/Search"));
|
|
7
|
+
exports.default = Search_1.default;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const isNotEmpty: (obj: any) => boolean;
|
|
2
|
+
export declare const isEmpty: (obj: any) => boolean;
|
|
3
|
+
export declare const isIterable: (input: any) => boolean;
|
|
4
|
+
export declare const isNotIterable: (input: any) => boolean;
|
|
5
|
+
export declare const compareAsc: (a: any, b: any) => 0 | 1 | -1;
|
|
6
|
+
export declare const compareDesc: (a: any, b: any) => 0 | 1 | -1;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.compareDesc = exports.compareAsc = exports.isNotIterable = exports.isIterable = exports.isEmpty = exports.isNotEmpty = void 0;
|
|
4
|
+
var isNotEmpty = function (obj) {
|
|
5
|
+
return !(0, exports.isEmpty)(obj);
|
|
6
|
+
};
|
|
7
|
+
exports.isNotEmpty = isNotEmpty;
|
|
8
|
+
var isEmpty = function (obj) {
|
|
9
|
+
if (!obj) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
if (Array.isArray(obj)) {
|
|
13
|
+
if (obj.length == 0) {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
if (obj === "") {
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
};
|
|
22
|
+
exports.isEmpty = isEmpty;
|
|
23
|
+
var isIterable = function (input) {
|
|
24
|
+
if (input === null || input === undefined) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
if ('string' === typeof input) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return typeof input[Symbol.iterator] === 'function';
|
|
31
|
+
};
|
|
32
|
+
exports.isIterable = isIterable;
|
|
33
|
+
var isNotIterable = function (input) {
|
|
34
|
+
return !(0, exports.isIterable)(input);
|
|
35
|
+
};
|
|
36
|
+
exports.isNotIterable = isNotIterable;
|
|
37
|
+
var compareAsc = function (a, b) {
|
|
38
|
+
if (a._id < b._id) {
|
|
39
|
+
return -1;
|
|
40
|
+
}
|
|
41
|
+
if (a._id > b._id) {
|
|
42
|
+
return 1;
|
|
43
|
+
}
|
|
44
|
+
return 0;
|
|
45
|
+
};
|
|
46
|
+
exports.compareAsc = compareAsc;
|
|
47
|
+
var compareDesc = function (a, b) {
|
|
48
|
+
if (a._id > b._id) {
|
|
49
|
+
return -1;
|
|
50
|
+
}
|
|
51
|
+
if (a._id < b._id) {
|
|
52
|
+
return 1;
|
|
53
|
+
}
|
|
54
|
+
return 0;
|
|
55
|
+
};
|
|
56
|
+
exports.compareDesc = compareDesc;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "c2-mongoose",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "Lib to make any search in database mongoose and use as basic crud",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"
|
|
8
|
+
"build": "tsc"
|
|
9
9
|
},
|
|
10
10
|
"repository": {
|
|
11
11
|
"type": "git",
|
|
@@ -24,5 +24,8 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"dotenv": "^16.0.3",
|
|
26
26
|
"mongoose": "^7.0.1"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"typescript": "^4.9.5"
|
|
27
30
|
}
|
|
28
31
|
}
|
package/src/index.ts
CHANGED
package/src/model/Search.ts
CHANGED
|
@@ -64,7 +64,7 @@ abstract class Search {
|
|
|
64
64
|
return false
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
public diacriticSensitiveRegex = (string = "") => {
|
|
68
68
|
return string
|
|
69
69
|
.replace(/[a|á|à|ä|â|A|Á|Â|Ã|Ä]/g, '[a,á,à,ä,â,A,Á,Â,Ã,Ä]')
|
|
70
70
|
.replace(/[e|é|ë|è|E|É|Ë|È]/g, '[e,é,ë,è,E,É,Ë,È]')
|
package/tsconfig.json
CHANGED
|
@@ -1,104 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"include": [
|
|
3
|
-
"**/*.ts"
|
|
4
|
-
],
|
|
5
|
-
"exclude": [
|
|
6
|
-
"node_modules"
|
|
7
|
-
],
|
|
8
|
-
"buildOnSave": true,
|
|
9
|
-
"compileOnSave": true,
|
|
10
|
-
"declaration": true,
|
|
11
2
|
"compilerOptions": {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
23
|
-
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
24
|
-
// "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
|
|
25
|
-
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
26
|
-
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
27
|
-
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
28
|
-
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
29
|
-
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
30
|
-
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
31
|
-
// "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
32
|
-
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
33
|
-
/* Modules */
|
|
34
|
-
"module": "commonjs", /* Specify what module code is generated. */
|
|
35
|
-
"rootDir": "./", /* Specify the root folder within your source files. */
|
|
36
|
-
// "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
37
|
-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
38
|
-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
39
|
-
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
40
|
-
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
41
|
-
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
42
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
43
|
-
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
44
|
-
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
45
|
-
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
46
|
-
/* JavaScript Support */
|
|
47
|
-
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
48
|
-
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
49
|
-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
50
|
-
/* Emit */
|
|
51
|
-
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
52
|
-
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
53
|
-
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
54
|
-
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
55
|
-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
56
|
-
"outDir": "./dist", /* Specify an output folder for all emitted files. */
|
|
57
|
-
// "removeComments": true, /* Disable emitting comments. */
|
|
58
|
-
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
59
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
60
|
-
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
61
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
62
|
-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
63
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
64
|
-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
65
|
-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
66
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
67
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
68
|
-
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
69
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
70
|
-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
71
|
-
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
72
|
-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
73
|
-
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
74
|
-
/* Interop Constraints */
|
|
75
|
-
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
76
|
-
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
77
|
-
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
78
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
79
|
-
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
80
|
-
/* Type Checking */
|
|
81
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
82
|
-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
83
|
-
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
84
|
-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
85
|
-
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
86
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
87
|
-
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
88
|
-
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
89
|
-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
90
|
-
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
91
|
-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
92
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
93
|
-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
94
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
95
|
-
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
96
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
97
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
98
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
99
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
100
|
-
/* Completeness */
|
|
101
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
102
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
103
|
-
}
|
|
104
|
-
}
|
|
3
|
+
"declaration": true,
|
|
4
|
+
"declarationDir": "./dist",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"target": "es5",
|
|
7
|
+
"module": "commonjs",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true
|
|
10
|
+
},
|
|
11
|
+
"include": ["src/**/*"]
|
|
12
|
+
}
|