@warlock.js/core 2.6.1 → 2.7.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/cjs/application.js +1 -1
- package/cjs/application.js.map +1 -1
- package/cjs/builder/app-builder.d.ts +1 -1
- package/cjs/builder/app-builder.d.ts.map +1 -1
- package/cjs/builder/app-builder.js +33 -20
- package/cjs/builder/app-builder.js.map +1 -1
- package/cjs/builder/build-http-app.d.ts.map +1 -1
- package/cjs/builder/build-http-app.js +49 -15
- package/cjs/builder/build-http-app.js.map +1 -1
- package/cjs/builder/config-loader-builder.js +1 -1
- package/cjs/config/get-warlock-config.js +1 -1
- package/cjs/config/get-warlock-config.js.map +1 -1
- package/cjs/console/commander.js +1 -1
- package/cjs/console/commander.js.map +1 -1
- package/cjs/esbuild/execute-ts-file.d.ts +1 -1
- package/cjs/esbuild/execute-ts-file.d.ts.map +1 -1
- package/cjs/esbuild/execute-ts-file.js +35 -19
- package/cjs/esbuild/execute-ts-file.js.map +1 -1
- package/cjs/esbuild/index.d.ts +8 -0
- package/cjs/esbuild/index.d.ts.map +1 -1
- package/cjs/esbuild/index.js +68 -0
- package/cjs/esbuild/index.js.map +1 -0
- package/cjs/esbuild/plugins.d.ts +2 -12
- package/cjs/esbuild/plugins.d.ts.map +1 -1
- package/cjs/esbuild/plugins.js +71 -117
- package/cjs/esbuild/plugins.js.map +1 -1
- package/cjs/esbuild/transpile.d.ts.map +1 -1
- package/cjs/esbuild/transpile.js +8 -5
- package/cjs/esbuild/transpile.js.map +1 -1
- package/cjs/http/middleware/inject-request-context.d.ts +4 -3
- package/cjs/http/middleware/inject-request-context.d.ts.map +1 -1
- package/cjs/http/middleware/inject-request-context.js +3 -2
- package/cjs/http/middleware/inject-request-context.js.map +1 -1
- package/cjs/http/plugins/index.d.ts +3 -0
- package/cjs/http/plugins/index.d.ts.map +1 -0
- package/cjs/http/plugins.d.ts.map +1 -1
- package/cjs/http/plugins.js +7 -1
- package/cjs/http/plugins.js.map +1 -1
- package/cjs/http/request.d.ts +1 -1
- package/cjs/http/request.js +1 -1
- package/cjs/http/request.js.map +1 -1
- package/cjs/index.js +1 -1
- package/cjs/modules/uploads/controllers/get-uploaded-file.js +1 -1
- package/cjs/modules/uploads/controllers/get-uploaded-file.js.map +1 -1
- package/cjs/modules/uploads/utils/get-watermark-options.js +1 -1
- package/cjs/modules/uploads/utils/get-watermark-options.js.map +1 -1
- package/cjs/modules/uploads/utils/uploadable.d.ts.map +1 -1
- package/cjs/modules/uploads/utils/uploadable.js +2 -0
- package/cjs/modules/uploads/utils/uploadable.js.map +1 -1
- package/cjs/output/output.js +1 -1
- package/cjs/output/output.js.map +1 -1
- package/cjs/postman/index.js +1 -1
- package/cjs/postman/index.js.map +1 -1
- package/cjs/postman/postman-generator.js +8 -8
- package/cjs/postman/postman-generator.js.map +1 -1
- package/cjs/react/index.d.ts +8 -0
- package/cjs/react/index.d.ts.map +1 -1
- package/cjs/react/index.js +1 -1
- package/cjs/react/index.js.map +1 -1
- package/cjs/react/page-renderer.d.ts +18 -0
- package/cjs/react/page-renderer.d.ts.map +1 -0
- package/cjs/react/plugin.d.ts +15 -0
- package/cjs/react/plugin.d.ts.map +1 -0
- package/cjs/react/plugin.js +22 -0
- package/cjs/react/plugin.js.map +1 -0
- package/cjs/react/vite-config.d.ts +9 -0
- package/cjs/react/vite-config.d.ts.map +1 -0
- package/cjs/react/vite-config.js +70 -0
- package/cjs/react/vite-config.js.map +1 -0
- package/cjs/repositories/repository-list-manager.d.ts +1 -3
- package/cjs/repositories/repository-list-manager.d.ts.map +1 -1
- package/cjs/repositories/repository-listing.d.ts +8 -44
- package/cjs/repositories/repository-listing.d.ts.map +1 -1
- package/cjs/repositories/repository-listing.js +13 -635
- package/cjs/repositories/repository-listing.js.map +1 -1
- package/cjs/repositories/types.d.ts +2 -4
- package/cjs/repositories/types.d.ts.map +1 -1
- package/cjs/router/router.d.ts +8 -0
- package/cjs/router/router.d.ts.map +1 -1
- package/cjs/router/router.js +40 -8
- package/cjs/router/router.js.map +1 -1
- package/cjs/router/types.d.ts +6 -2
- package/cjs/router/types.d.ts.map +1 -1
- package/cjs/starters/build-http-production.d.ts.map +1 -1
- package/cjs/starters/build-http-production.js +3 -2
- package/cjs/starters/build-http-production.js.map +1 -1
- package/cjs/starters/start-cli-server.js +4 -4
- package/cjs/starters/start-cli-server.js.map +1 -1
- package/cjs/starters/start-http-server.d.ts.map +1 -1
- package/cjs/starters/start-http-server.js +18 -4
- package/cjs/starters/start-http-server.js.map +1 -1
- package/cjs/utils/cleanup-temp-files.d.ts +5 -0
- package/cjs/utils/cleanup-temp-files.d.ts.map +1 -0
- package/cjs/utils/cleanup-temp-files.js +21 -0
- package/cjs/utils/cleanup-temp-files.js.map +1 -0
- package/cjs/validator/v/database.d.ts +8 -0
- package/cjs/validator/v/database.d.ts.map +1 -0
- package/cjs/validator/v/database.js +129 -0
- package/cjs/validator/v/database.js.map +1 -0
- package/cjs/validator/v/rules.d.ts +2 -19
- package/cjs/validator/v/rules.d.ts.map +1 -1
- package/cjs/validator/v/rules.js +2 -56
- package/cjs/validator/v/rules.js.map +1 -1
- package/cjs/validator/v/schema.d.ts +44 -5
- package/cjs/validator/v/schema.d.ts.map +1 -1
- package/cjs/validator/v/schema.js +72 -6
- package/cjs/validator/v/schema.js.map +1 -1
- package/cjs/validator/v/types.d.ts +96 -3
- package/cjs/validator/v/types.d.ts.map +1 -1
- package/esm/application.js +1 -1
- package/esm/application.js.map +1 -1
- package/esm/builder/app-builder.d.ts +1 -1
- package/esm/builder/app-builder.d.ts.map +1 -1
- package/esm/builder/app-builder.js +32 -19
- package/esm/builder/app-builder.js.map +1 -1
- package/esm/builder/build-http-app.d.ts.map +1 -1
- package/esm/builder/build-http-app.js +49 -15
- package/esm/builder/build-http-app.js.map +1 -1
- package/esm/builder/config-loader-builder.js +1 -1
- package/esm/config/get-warlock-config.js +1 -1
- package/esm/console/commander.js +1 -1
- package/esm/console/commander.js.map +1 -1
- package/esm/esbuild/execute-ts-file.d.ts +1 -1
- package/esm/esbuild/execute-ts-file.d.ts.map +1 -1
- package/esm/esbuild/execute-ts-file.js +35 -19
- package/esm/esbuild/execute-ts-file.js.map +1 -1
- package/esm/esbuild/index.d.ts +8 -0
- package/esm/esbuild/index.d.ts.map +1 -1
- package/esm/esbuild/index.js +68 -0
- package/esm/esbuild/index.js.map +1 -0
- package/esm/esbuild/plugins.d.ts +2 -12
- package/esm/esbuild/plugins.d.ts.map +1 -1
- package/esm/esbuild/plugins.js +71 -117
- package/esm/esbuild/plugins.js.map +1 -1
- package/esm/esbuild/transpile.d.ts.map +1 -1
- package/esm/esbuild/transpile.js +7 -4
- package/esm/esbuild/transpile.js.map +1 -1
- package/esm/http/middleware/inject-request-context.d.ts +4 -3
- package/esm/http/middleware/inject-request-context.d.ts.map +1 -1
- package/esm/http/middleware/inject-request-context.js +3 -2
- package/esm/http/middleware/inject-request-context.js.map +1 -1
- package/esm/http/plugins/index.d.ts +3 -0
- package/esm/http/plugins/index.d.ts.map +1 -0
- package/esm/http/plugins.d.ts.map +1 -1
- package/esm/http/plugins.js +7 -1
- package/esm/http/plugins.js.map +1 -1
- package/esm/http/request.d.ts +1 -1
- package/esm/http/request.js +1 -1
- package/esm/http/request.js.map +1 -1
- package/esm/index.js +1 -1
- package/esm/modules/uploads/controllers/get-uploaded-file.js +2 -2
- package/esm/modules/uploads/controllers/get-uploaded-file.js.map +1 -1
- package/esm/modules/uploads/utils/get-watermark-options.js +1 -1
- package/esm/modules/uploads/utils/get-watermark-options.js.map +1 -1
- package/esm/modules/uploads/utils/uploadable.d.ts.map +1 -1
- package/esm/modules/uploads/utils/uploadable.js +2 -0
- package/esm/modules/uploads/utils/uploadable.js.map +1 -1
- package/esm/output/output.js +1 -1
- package/esm/output/output.js.map +1 -1
- package/esm/postman/index.js +1 -1
- package/esm/postman/index.js.map +1 -1
- package/esm/postman/postman-generator.js +8 -8
- package/esm/postman/postman-generator.js.map +1 -1
- package/esm/react/index.d.ts +8 -0
- package/esm/react/index.d.ts.map +1 -1
- package/esm/react/index.js +1 -1
- package/esm/react/index.js.map +1 -1
- package/esm/react/page-renderer.d.ts +18 -0
- package/esm/react/page-renderer.d.ts.map +1 -0
- package/esm/react/plugin.d.ts +15 -0
- package/esm/react/plugin.d.ts.map +1 -0
- package/esm/react/plugin.js +22 -0
- package/esm/react/plugin.js.map +1 -0
- package/esm/react/vite-config.d.ts +9 -0
- package/esm/react/vite-config.d.ts.map +1 -0
- package/esm/react/vite-config.js +70 -0
- package/esm/react/vite-config.js.map +1 -0
- package/esm/repositories/repository-list-manager.d.ts +1 -3
- package/esm/repositories/repository-list-manager.d.ts.map +1 -1
- package/esm/repositories/repository-listing.d.ts +8 -44
- package/esm/repositories/repository-listing.d.ts.map +1 -1
- package/esm/repositories/repository-listing.js +13 -635
- package/esm/repositories/repository-listing.js.map +1 -1
- package/esm/repositories/types.d.ts +2 -4
- package/esm/repositories/types.d.ts.map +1 -1
- package/esm/router/router.d.ts +8 -0
- package/esm/router/router.d.ts.map +1 -1
- package/esm/router/router.js +40 -8
- package/esm/router/router.js.map +1 -1
- package/esm/router/types.d.ts +6 -2
- package/esm/router/types.d.ts.map +1 -1
- package/esm/starters/build-http-production.d.ts.map +1 -1
- package/esm/starters/build-http-production.js +2 -1
- package/esm/starters/build-http-production.js.map +1 -1
- package/esm/starters/start-cli-server.js +3 -3
- package/esm/starters/start-cli-server.js.map +1 -1
- package/esm/starters/start-http-server.d.ts.map +1 -1
- package/esm/starters/start-http-server.js +16 -2
- package/esm/starters/start-http-server.js.map +1 -1
- package/esm/utils/cleanup-temp-files.d.ts +5 -0
- package/esm/utils/cleanup-temp-files.d.ts.map +1 -0
- package/esm/utils/cleanup-temp-files.js +21 -0
- package/esm/utils/cleanup-temp-files.js.map +1 -0
- package/esm/validator/v/database.d.ts +8 -0
- package/esm/validator/v/database.d.ts.map +1 -0
- package/esm/validator/v/database.js +129 -0
- package/esm/validator/v/database.js.map +1 -0
- package/esm/validator/v/rules.d.ts +2 -19
- package/esm/validator/v/rules.d.ts.map +1 -1
- package/esm/validator/v/rules.js +2 -56
- package/esm/validator/v/rules.js.map +1 -1
- package/esm/validator/v/schema.d.ts +44 -5
- package/esm/validator/v/schema.d.ts.map +1 -1
- package/esm/validator/v/schema.js +70 -4
- package/esm/validator/v/schema.js.map +1 -1
- package/esm/validator/v/types.d.ts +96 -3
- package/esm/validator/v/types.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
'use strict';var reinforcements=require('@mongez/reinforcements')
|
|
1
|
+
'use strict';var reinforcements=require('@mongez/reinforcements');class RepositoryListing {
|
|
2
2
|
repositoryManager;
|
|
3
|
-
|
|
3
|
+
filters;
|
|
4
4
|
/**
|
|
5
5
|
* Aggregate query
|
|
6
6
|
*/
|
|
@@ -30,10 +30,9 @@
|
|
|
30
30
|
/**
|
|
31
31
|
* Constructor
|
|
32
32
|
*/
|
|
33
|
-
constructor(repositoryManager,
|
|
33
|
+
constructor(repositoryManager, filters = {}, options) {
|
|
34
34
|
this.repositoryManager = repositoryManager;
|
|
35
|
-
this.
|
|
36
|
-
//
|
|
35
|
+
this.filters = filters;
|
|
37
36
|
this.prepareOptions(options);
|
|
38
37
|
}
|
|
39
38
|
/**
|
|
@@ -69,6 +68,15 @@
|
|
|
69
68
|
}
|
|
70
69
|
return this.query;
|
|
71
70
|
}
|
|
71
|
+
/**
|
|
72
|
+
* Parse filter by
|
|
73
|
+
*/
|
|
74
|
+
async parseFilterBy() {
|
|
75
|
+
this.query.applyFilters(this.filters, this.options, {
|
|
76
|
+
dateFormat: this.dateFormat,
|
|
77
|
+
dateTimeFormat: this.dateTimeFormat,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
72
80
|
/**
|
|
73
81
|
* perform listing
|
|
74
82
|
*/
|
|
@@ -135,622 +143,6 @@
|
|
|
135
143
|
hasPagination() {
|
|
136
144
|
return Boolean(this.paginationInfo);
|
|
137
145
|
}
|
|
138
|
-
/**
|
|
139
|
-
* Int filter
|
|
140
|
-
*/
|
|
141
|
-
intFilter(column, value, columns) {
|
|
142
|
-
if (column) {
|
|
143
|
-
this.query.where(column, parseInt(value));
|
|
144
|
-
}
|
|
145
|
-
else if (columns) {
|
|
146
|
-
const columnsAsObject = {};
|
|
147
|
-
for (const column of columns) {
|
|
148
|
-
columnsAsObject[column] = parseInt(value);
|
|
149
|
-
}
|
|
150
|
-
this.query.orWhere(columnsAsObject);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* float filter
|
|
155
|
-
*/
|
|
156
|
-
floatFilter(column, value, columns) {
|
|
157
|
-
if (column) {
|
|
158
|
-
this.query.where(column, parseFloat(value));
|
|
159
|
-
}
|
|
160
|
-
else if (columns) {
|
|
161
|
-
const columnsAsObject = {};
|
|
162
|
-
for (const column of columns) {
|
|
163
|
-
columnsAsObject[column] = parseFloat(value);
|
|
164
|
-
}
|
|
165
|
-
this.query.orWhere(columnsAsObject);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Where operators filter
|
|
170
|
-
*/
|
|
171
|
-
whereOperatorsFilter(column, value, columns, filterType) {
|
|
172
|
-
if (column) {
|
|
173
|
-
this.query.where(column, filterType, value);
|
|
174
|
-
}
|
|
175
|
-
else if (columns) {
|
|
176
|
-
const columnsAsObject = {};
|
|
177
|
-
for (const column of columns) {
|
|
178
|
-
columnsAsObject[column] = {
|
|
179
|
-
[cascade.toOperator(filterType)]: value,
|
|
180
|
-
};
|
|
181
|
-
}
|
|
182
|
-
this.query.orWhere(columnsAsObject);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Parse filter by
|
|
187
|
-
*/
|
|
188
|
-
async parseFilterBy() {
|
|
189
|
-
// TODO: Use filter maps instead of these tons of if statements
|
|
190
|
-
// get where operators from WhereOperator type
|
|
191
|
-
// just get the keys
|
|
192
|
-
// const filtersKeys = Object.keys(this.filterBy).filter(
|
|
193
|
-
// key => this.option(key) !== undefined,
|
|
194
|
-
// );
|
|
195
|
-
// for (const filterKey of filtersKeys) {
|
|
196
|
-
// const filterValue = this.option(filterKey);
|
|
197
|
-
// if (filterValue === undefined) continue;
|
|
198
|
-
// const { filterType, columns, column } = this.prepareFilterType(
|
|
199
|
-
// filterKey,
|
|
200
|
-
// this.filterBy[filterKey],
|
|
201
|
-
// );
|
|
202
|
-
// if (typeof filterType === "function") {
|
|
203
|
-
// await filterType(filterValue, this.query);
|
|
204
|
-
// continue;
|
|
205
|
-
// }
|
|
206
|
-
// // where operators
|
|
207
|
-
// if (whereOperators.includes(filterType as WhereOperator)) {
|
|
208
|
-
// this.whereOperatorsFilter(
|
|
209
|
-
// column,
|
|
210
|
-
// filterValue,
|
|
211
|
-
// columns,
|
|
212
|
-
// filterType as WhereOperator,
|
|
213
|
-
// );
|
|
214
|
-
// continue;
|
|
215
|
-
// }
|
|
216
|
-
// }
|
|
217
|
-
for (const optionKey in this.filterBy) {
|
|
218
|
-
const filterValue = this.option(optionKey);
|
|
219
|
-
if (filterValue === undefined)
|
|
220
|
-
continue;
|
|
221
|
-
const { filterType, columns, column } = this.prepareFilterType(optionKey, this.filterBy[optionKey]);
|
|
222
|
-
if (typeof filterType === "function") {
|
|
223
|
-
await filterType(filterValue, this.query, this.options);
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
// in
|
|
227
|
-
if (filterType === "in") {
|
|
228
|
-
const value = this.returnAsArray(filterValue);
|
|
229
|
-
if (column) {
|
|
230
|
-
this.query.whereIn(column, value);
|
|
231
|
-
}
|
|
232
|
-
else if (columns) {
|
|
233
|
-
const columnsAsObject = {};
|
|
234
|
-
for (const column of columns) {
|
|
235
|
-
columnsAsObject[column] = value;
|
|
236
|
-
}
|
|
237
|
-
this.query.orWhere(columnsAsObject);
|
|
238
|
-
}
|
|
239
|
-
continue;
|
|
240
|
-
}
|
|
241
|
-
// where operators
|
|
242
|
-
if (cascade.whereOperators.includes(filterType)) {
|
|
243
|
-
if (column) {
|
|
244
|
-
this.query.where(column, filterType, filterValue);
|
|
245
|
-
}
|
|
246
|
-
else if (columns) {
|
|
247
|
-
const columnsAsObject = {};
|
|
248
|
-
for (const column of columns) {
|
|
249
|
-
const filterExpression = cascade.WhereExpression.parse.apply(null, [
|
|
250
|
-
column,
|
|
251
|
-
filterType,
|
|
252
|
-
filterValue,
|
|
253
|
-
]);
|
|
254
|
-
columnsAsObject[column] = filterExpression[column];
|
|
255
|
-
}
|
|
256
|
-
this.query.orWhere(columnsAsObject);
|
|
257
|
-
}
|
|
258
|
-
continue;
|
|
259
|
-
}
|
|
260
|
-
// bool, boolean
|
|
261
|
-
if (["bool", "boolean"].includes(filterType)) {
|
|
262
|
-
const value = filterValue === "0" ? false : Boolean(filterValue);
|
|
263
|
-
if (column) {
|
|
264
|
-
this.query.where(column, value);
|
|
265
|
-
}
|
|
266
|
-
else if (columns) {
|
|
267
|
-
const columnsAsObject = {};
|
|
268
|
-
for (const column of columns) {
|
|
269
|
-
columnsAsObject[column] = value;
|
|
270
|
-
}
|
|
271
|
-
this.query.orWhere(columnsAsObject);
|
|
272
|
-
}
|
|
273
|
-
continue;
|
|
274
|
-
}
|
|
275
|
-
// !int
|
|
276
|
-
if (filterType === "!int") {
|
|
277
|
-
if (column) {
|
|
278
|
-
this.query.where(column, "!=", parseInt(filterValue));
|
|
279
|
-
}
|
|
280
|
-
else if (columns) {
|
|
281
|
-
const columnsAsObject = {};
|
|
282
|
-
for (const column of columns) {
|
|
283
|
-
columnsAsObject[column] = {
|
|
284
|
-
$ne: parseInt(filterValue),
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
this.query.orWhere(columnsAsObject);
|
|
288
|
-
}
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
// inInt
|
|
292
|
-
// int, integer
|
|
293
|
-
if (["int", "integer"].includes(filterType)) {
|
|
294
|
-
if (column) {
|
|
295
|
-
this.query.where(column, parseInt(filterValue));
|
|
296
|
-
}
|
|
297
|
-
else if (columns) {
|
|
298
|
-
const columnsAsObject = {};
|
|
299
|
-
for (const column of columns) {
|
|
300
|
-
columnsAsObject[column] = parseInt(filterValue);
|
|
301
|
-
}
|
|
302
|
-
this.query.orWhere(columnsAsObject);
|
|
303
|
-
}
|
|
304
|
-
continue;
|
|
305
|
-
}
|
|
306
|
-
// int>
|
|
307
|
-
if (filterType === "int>") {
|
|
308
|
-
const value = parseInt(filterValue);
|
|
309
|
-
if (column) {
|
|
310
|
-
this.query.where(column, ">", value);
|
|
311
|
-
}
|
|
312
|
-
else if (columns) {
|
|
313
|
-
const columnsAsObject = {};
|
|
314
|
-
for (const column of columns) {
|
|
315
|
-
columnsAsObject[column] = {
|
|
316
|
-
$gt: value,
|
|
317
|
-
};
|
|
318
|
-
}
|
|
319
|
-
this.query.orWhere(columnsAsObject);
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
// int>=
|
|
323
|
-
if (filterType === "int>=") {
|
|
324
|
-
const value = parseInt(filterValue);
|
|
325
|
-
if (column) {
|
|
326
|
-
this.query.where(column, ">=", value);
|
|
327
|
-
}
|
|
328
|
-
else if (columns) {
|
|
329
|
-
const columnsAsObject = {};
|
|
330
|
-
for (const column of columns) {
|
|
331
|
-
columnsAsObject[column] = {
|
|
332
|
-
$gte: value,
|
|
333
|
-
};
|
|
334
|
-
}
|
|
335
|
-
this.query.orWhere(columnsAsObject);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
// int<
|
|
339
|
-
if (filterType === "int<") {
|
|
340
|
-
const value = parseInt(filterValue);
|
|
341
|
-
if (column) {
|
|
342
|
-
this.query.where(column, "<", value);
|
|
343
|
-
}
|
|
344
|
-
else if (columns) {
|
|
345
|
-
const columnsAsObject = {};
|
|
346
|
-
for (const column of columns) {
|
|
347
|
-
columnsAsObject[column] = {
|
|
348
|
-
$lt: value,
|
|
349
|
-
};
|
|
350
|
-
}
|
|
351
|
-
this.query.orWhere(columnsAsObject);
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
// int<=
|
|
355
|
-
if (filterType === "int<=") {
|
|
356
|
-
const value = parseInt(filterValue);
|
|
357
|
-
if (column) {
|
|
358
|
-
this.query.where(column, "<=", value);
|
|
359
|
-
}
|
|
360
|
-
else if (columns) {
|
|
361
|
-
const columnsAsObject = {};
|
|
362
|
-
for (const column of columns) {
|
|
363
|
-
columnsAsObject[column] = {
|
|
364
|
-
$lte: value,
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
|
-
this.query.orWhere(columnsAsObject);
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
// inInt
|
|
371
|
-
if (filterType === "inInt") {
|
|
372
|
-
const value = this.returnAsArray(filterValue).map((v) => parseInt(v));
|
|
373
|
-
if (column) {
|
|
374
|
-
this.query.whereIn(column, value);
|
|
375
|
-
}
|
|
376
|
-
else if (columns) {
|
|
377
|
-
const columnsAsObject = {};
|
|
378
|
-
for (const column of columns) {
|
|
379
|
-
columnsAsObject[column] = {
|
|
380
|
-
$in: value,
|
|
381
|
-
};
|
|
382
|
-
}
|
|
383
|
-
this.query.orWhere(columnsAsObject);
|
|
384
|
-
}
|
|
385
|
-
continue;
|
|
386
|
-
}
|
|
387
|
-
// number
|
|
388
|
-
if (filterType === "number") {
|
|
389
|
-
if (column) {
|
|
390
|
-
this.query.where(column, Number(filterValue));
|
|
391
|
-
}
|
|
392
|
-
else if (columns) {
|
|
393
|
-
const columnsAsObject = {};
|
|
394
|
-
for (const column of columns) {
|
|
395
|
-
columnsAsObject[column] = Number(filterValue);
|
|
396
|
-
}
|
|
397
|
-
this.query.orWhere(columnsAsObject);
|
|
398
|
-
}
|
|
399
|
-
continue;
|
|
400
|
-
}
|
|
401
|
-
// inNumber
|
|
402
|
-
if (filterType === "inNumber") {
|
|
403
|
-
const value = this.returnAsArray(filterValue).map((v) => Number(v));
|
|
404
|
-
if (column) {
|
|
405
|
-
this.query.whereIn(column, value);
|
|
406
|
-
}
|
|
407
|
-
else if (columns) {
|
|
408
|
-
const columnsAsObject = {};
|
|
409
|
-
for (const column of columns) {
|
|
410
|
-
columnsAsObject[column] = {
|
|
411
|
-
$in: value,
|
|
412
|
-
};
|
|
413
|
-
}
|
|
414
|
-
this.query.orWhere(columnsAsObject);
|
|
415
|
-
}
|
|
416
|
-
continue;
|
|
417
|
-
}
|
|
418
|
-
// float, double
|
|
419
|
-
if (["float", "double"].includes(filterType)) {
|
|
420
|
-
const value = this.returnAsArray(filterValue).map((v) => parseFloat(v));
|
|
421
|
-
if (column) {
|
|
422
|
-
this.query.whereIn(column, value);
|
|
423
|
-
}
|
|
424
|
-
else if (columns) {
|
|
425
|
-
const columnsAsObject = {};
|
|
426
|
-
for (const column of columns) {
|
|
427
|
-
columnsAsObject[column] = {
|
|
428
|
-
$in: value,
|
|
429
|
-
};
|
|
430
|
-
}
|
|
431
|
-
this.query.orWhere(columnsAsObject);
|
|
432
|
-
}
|
|
433
|
-
continue;
|
|
434
|
-
}
|
|
435
|
-
// date
|
|
436
|
-
if (filterType === "date") {
|
|
437
|
-
const value = this.parseDate(filterValue);
|
|
438
|
-
if (column) {
|
|
439
|
-
this.query.where(column, value);
|
|
440
|
-
}
|
|
441
|
-
else if (columns) {
|
|
442
|
-
const columnsAsObject = {};
|
|
443
|
-
for (const column of columns) {
|
|
444
|
-
columnsAsObject[column] = value;
|
|
445
|
-
}
|
|
446
|
-
this.query.orWhere(columnsAsObject);
|
|
447
|
-
}
|
|
448
|
-
continue;
|
|
449
|
-
}
|
|
450
|
-
// date>
|
|
451
|
-
if (filterType === "date>") {
|
|
452
|
-
const value = this.parseDate(filterValue);
|
|
453
|
-
if (column) {
|
|
454
|
-
this.query.where(column, ">", value);
|
|
455
|
-
}
|
|
456
|
-
else if (columns) {
|
|
457
|
-
const columnsAsObject = {};
|
|
458
|
-
for (const column of columns) {
|
|
459
|
-
columnsAsObject[column] = {
|
|
460
|
-
$gt: value,
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
this.query.orWhere(columnsAsObject);
|
|
464
|
-
}
|
|
465
|
-
continue;
|
|
466
|
-
}
|
|
467
|
-
// date>=
|
|
468
|
-
if (filterType === "date>=") {
|
|
469
|
-
const value = this.parseDate(filterValue);
|
|
470
|
-
if (column) {
|
|
471
|
-
this.query.where(column, ">=", value);
|
|
472
|
-
}
|
|
473
|
-
else if (columns) {
|
|
474
|
-
const columnsAsObject = {};
|
|
475
|
-
for (const column of columns) {
|
|
476
|
-
columnsAsObject[column] = {
|
|
477
|
-
$gte: value,
|
|
478
|
-
};
|
|
479
|
-
}
|
|
480
|
-
this.query.orWhere(columnsAsObject);
|
|
481
|
-
}
|
|
482
|
-
continue;
|
|
483
|
-
}
|
|
484
|
-
// date<
|
|
485
|
-
if (filterType === "date<") {
|
|
486
|
-
const value = this.parseDate(filterValue);
|
|
487
|
-
if (column) {
|
|
488
|
-
this.query.where(column, "<", value);
|
|
489
|
-
}
|
|
490
|
-
else if (columns) {
|
|
491
|
-
const columnsAsObject = {};
|
|
492
|
-
for (const column of columns) {
|
|
493
|
-
columnsAsObject[column] = {
|
|
494
|
-
$gte: value,
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
this.query.orWhere(columnsAsObject);
|
|
498
|
-
}
|
|
499
|
-
continue;
|
|
500
|
-
}
|
|
501
|
-
// date<=
|
|
502
|
-
if (filterType === "date<=") {
|
|
503
|
-
const value = this.parseDate(filterValue);
|
|
504
|
-
if (column) {
|
|
505
|
-
this.query.where(column, "<=", value);
|
|
506
|
-
}
|
|
507
|
-
else if (columns) {
|
|
508
|
-
const columnsAsObject = {};
|
|
509
|
-
for (const column of columns) {
|
|
510
|
-
columnsAsObject[column] = {
|
|
511
|
-
$gte: value,
|
|
512
|
-
};
|
|
513
|
-
}
|
|
514
|
-
this.query.orWhere(columnsAsObject);
|
|
515
|
-
}
|
|
516
|
-
continue;
|
|
517
|
-
}
|
|
518
|
-
// null
|
|
519
|
-
if (filterType === "null") {
|
|
520
|
-
if (column) {
|
|
521
|
-
this.query.whereNull(column);
|
|
522
|
-
}
|
|
523
|
-
else if (columns) {
|
|
524
|
-
const columnsAsObject = {};
|
|
525
|
-
for (const column of columns) {
|
|
526
|
-
columnsAsObject[column] = null;
|
|
527
|
-
}
|
|
528
|
-
this.query.orWhere(columnsAsObject);
|
|
529
|
-
}
|
|
530
|
-
continue;
|
|
531
|
-
}
|
|
532
|
-
// notNull | !null
|
|
533
|
-
if (["notNull", "!null"].includes(filterType)) {
|
|
534
|
-
if (column) {
|
|
535
|
-
this.query.whereNotNull(column);
|
|
536
|
-
}
|
|
537
|
-
else if (columns) {
|
|
538
|
-
const columnsAsObject = {};
|
|
539
|
-
for (const column of columns) {
|
|
540
|
-
columnsAsObject[column] = {
|
|
541
|
-
$ne: null,
|
|
542
|
-
};
|
|
543
|
-
}
|
|
544
|
-
this.query.orWhere(columnsAsObject);
|
|
545
|
-
}
|
|
546
|
-
continue;
|
|
547
|
-
}
|
|
548
|
-
// inDate
|
|
549
|
-
if (filterType === "inDate") {
|
|
550
|
-
const value = this.returnAsArray(filterValue).map((v) => this.parseDate(v));
|
|
551
|
-
if (column) {
|
|
552
|
-
this.query.whereIn(column, value);
|
|
553
|
-
}
|
|
554
|
-
else if (columns) {
|
|
555
|
-
const columnsAsObject = {};
|
|
556
|
-
for (const column of columns) {
|
|
557
|
-
columnsAsObject[column] = {
|
|
558
|
-
$in: value,
|
|
559
|
-
};
|
|
560
|
-
}
|
|
561
|
-
this.query.orWhere(columnsAsObject);
|
|
562
|
-
}
|
|
563
|
-
continue;
|
|
564
|
-
}
|
|
565
|
-
// dateBetween
|
|
566
|
-
if (filterType === "dateBetween") {
|
|
567
|
-
const value = this.returnAsArray(filterValue).map((v) => this.parseDate(v));
|
|
568
|
-
if (column) {
|
|
569
|
-
this.query.whereBetween(column, value);
|
|
570
|
-
}
|
|
571
|
-
else if (columns) {
|
|
572
|
-
const columnsAsObject = {};
|
|
573
|
-
for (const column of columns) {
|
|
574
|
-
columnsAsObject[column] = {
|
|
575
|
-
$between: value,
|
|
576
|
-
};
|
|
577
|
-
}
|
|
578
|
-
this.query.orWhere(columnsAsObject);
|
|
579
|
-
}
|
|
580
|
-
continue;
|
|
581
|
-
}
|
|
582
|
-
// dateTime
|
|
583
|
-
if (filterType === "dateTime") {
|
|
584
|
-
const value = this.parseDate(filterValue, this.dateTimeFormat);
|
|
585
|
-
if (column) {
|
|
586
|
-
this.query.where(column, value);
|
|
587
|
-
}
|
|
588
|
-
else if (columns) {
|
|
589
|
-
const columnsAsObject = {};
|
|
590
|
-
for (const column of columns) {
|
|
591
|
-
columnsAsObject[column] = value;
|
|
592
|
-
}
|
|
593
|
-
this.query.orWhere(columnsAsObject);
|
|
594
|
-
}
|
|
595
|
-
continue;
|
|
596
|
-
}
|
|
597
|
-
// dateTime>
|
|
598
|
-
if (filterType === "dateTime>") {
|
|
599
|
-
const value = this.parseDate(filterValue, this.dateTimeFormat);
|
|
600
|
-
if (column) {
|
|
601
|
-
this.query.where(column, ">", value);
|
|
602
|
-
}
|
|
603
|
-
else if (columns) {
|
|
604
|
-
const columnsAsObject = {};
|
|
605
|
-
for (const column of columns) {
|
|
606
|
-
columnsAsObject[column] = {
|
|
607
|
-
$gt: value,
|
|
608
|
-
};
|
|
609
|
-
}
|
|
610
|
-
this.query.orWhere(columnsAsObject);
|
|
611
|
-
}
|
|
612
|
-
continue;
|
|
613
|
-
}
|
|
614
|
-
// dateTime>=
|
|
615
|
-
if (filterType === "dateTime>=") {
|
|
616
|
-
const value = this.parseDate(filterValue, this.dateTimeFormat);
|
|
617
|
-
if (column) {
|
|
618
|
-
this.query.where(column, ">=", value);
|
|
619
|
-
}
|
|
620
|
-
else if (columns) {
|
|
621
|
-
const columnsAsObject = {};
|
|
622
|
-
for (const column of columns) {
|
|
623
|
-
columnsAsObject[column] = {
|
|
624
|
-
$gte: value,
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
this.query.orWhere(columnsAsObject);
|
|
628
|
-
}
|
|
629
|
-
continue;
|
|
630
|
-
}
|
|
631
|
-
// dateTime<
|
|
632
|
-
if (filterType === "dateTime<") {
|
|
633
|
-
const value = this.parseDate(filterValue, this.dateTimeFormat);
|
|
634
|
-
if (column) {
|
|
635
|
-
this.query.where(column, "<", value);
|
|
636
|
-
}
|
|
637
|
-
else if (columns) {
|
|
638
|
-
const columnsAsObject = {};
|
|
639
|
-
for (const column of columns) {
|
|
640
|
-
columnsAsObject[column] = {
|
|
641
|
-
$gte: value,
|
|
642
|
-
};
|
|
643
|
-
}
|
|
644
|
-
this.query.orWhere(columnsAsObject);
|
|
645
|
-
}
|
|
646
|
-
continue;
|
|
647
|
-
}
|
|
648
|
-
// dateTime<=
|
|
649
|
-
if (filterType === "dateTime<=") {
|
|
650
|
-
const value = this.parseDate(filterValue, this.dateTimeFormat);
|
|
651
|
-
if (column) {
|
|
652
|
-
this.query.where(column, "<=", value);
|
|
653
|
-
}
|
|
654
|
-
else if (columns) {
|
|
655
|
-
const columnsAsObject = {};
|
|
656
|
-
for (const column of columns) {
|
|
657
|
-
columnsAsObject[column] = {
|
|
658
|
-
$gte: value,
|
|
659
|
-
};
|
|
660
|
-
}
|
|
661
|
-
this.query.orWhere(columnsAsObject);
|
|
662
|
-
}
|
|
663
|
-
continue;
|
|
664
|
-
}
|
|
665
|
-
// inDateTime
|
|
666
|
-
if (filterType === "inDateTime") {
|
|
667
|
-
const value = this.returnAsArray(filterValue).map((v) => this.parseDate(v, this.dateTimeFormat));
|
|
668
|
-
if (column) {
|
|
669
|
-
this.query.whereIn(column, value);
|
|
670
|
-
}
|
|
671
|
-
else if (columns) {
|
|
672
|
-
const columnsAsObject = {};
|
|
673
|
-
for (const column of columns) {
|
|
674
|
-
columnsAsObject[column] = {
|
|
675
|
-
$in: value,
|
|
676
|
-
};
|
|
677
|
-
}
|
|
678
|
-
this.query.orWhere(columnsAsObject);
|
|
679
|
-
}
|
|
680
|
-
continue;
|
|
681
|
-
}
|
|
682
|
-
// dateTimeBetween
|
|
683
|
-
if (filterType === "dateTimeBetween") {
|
|
684
|
-
const value = this.returnAsArray(filterValue).map((v) => this.parseDate(v, this.dateTimeFormat));
|
|
685
|
-
if (column) {
|
|
686
|
-
this.query.whereBetween(column, value);
|
|
687
|
-
}
|
|
688
|
-
else if (columns) {
|
|
689
|
-
const columnsAsObject = {};
|
|
690
|
-
for (const column of columns) {
|
|
691
|
-
columnsAsObject[column] = {
|
|
692
|
-
$between: value,
|
|
693
|
-
};
|
|
694
|
-
}
|
|
695
|
-
this.query.orWhere(columnsAsObject);
|
|
696
|
-
}
|
|
697
|
-
continue;
|
|
698
|
-
}
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
/**
|
|
702
|
-
* Return the given value as a array
|
|
703
|
-
*/
|
|
704
|
-
returnAsArray(value) {
|
|
705
|
-
if (!Array.isArray(value)) {
|
|
706
|
-
if (supportiveIs.isIterable(value) && value.toArray) {
|
|
707
|
-
return value.toArray();
|
|
708
|
-
}
|
|
709
|
-
else {
|
|
710
|
-
return [value];
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
return value;
|
|
714
|
-
}
|
|
715
|
-
/**
|
|
716
|
-
* Sum the value of the given column
|
|
717
|
-
*/
|
|
718
|
-
sum(column) {
|
|
719
|
-
return this.query.sum(column);
|
|
720
|
-
}
|
|
721
|
-
/**
|
|
722
|
-
* Prepare filter type
|
|
723
|
-
*/
|
|
724
|
-
prepareFilterType(optionKey, filterType) {
|
|
725
|
-
if (Array.isArray(filterType)) {
|
|
726
|
-
if (filterType.length === 1) {
|
|
727
|
-
return {
|
|
728
|
-
filterType: filterType[0],
|
|
729
|
-
column: optionKey,
|
|
730
|
-
columns: undefined,
|
|
731
|
-
};
|
|
732
|
-
}
|
|
733
|
-
if (Array.isArray(filterType[1])) {
|
|
734
|
-
return {
|
|
735
|
-
filterType: filterType[0],
|
|
736
|
-
column: undefined,
|
|
737
|
-
columns: filterType[1],
|
|
738
|
-
};
|
|
739
|
-
}
|
|
740
|
-
else {
|
|
741
|
-
return {
|
|
742
|
-
filterType: filterType[0],
|
|
743
|
-
column: filterType[1],
|
|
744
|
-
columns: undefined,
|
|
745
|
-
};
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
return {
|
|
749
|
-
filterType,
|
|
750
|
-
column: optionKey,
|
|
751
|
-
columns: undefined,
|
|
752
|
-
};
|
|
753
|
-
}
|
|
754
146
|
/**
|
|
755
147
|
* Get option's value for the given key
|
|
756
148
|
*/
|
|
@@ -782,18 +174,4 @@
|
|
|
782
174
|
...options,
|
|
783
175
|
};
|
|
784
176
|
}
|
|
785
|
-
/**
|
|
786
|
-
* Parse date value
|
|
787
|
-
*/
|
|
788
|
-
parseDate(value, format = this.dateFormat) {
|
|
789
|
-
if (value instanceof Date)
|
|
790
|
-
return value;
|
|
791
|
-
if (supportiveIs.isNumeric(value)) {
|
|
792
|
-
return new Date(parseInt(value));
|
|
793
|
-
}
|
|
794
|
-
if (typeof value === "string") {
|
|
795
|
-
return dayjs__default.default(value, format);
|
|
796
|
-
}
|
|
797
|
-
return value;
|
|
798
|
-
}
|
|
799
177
|
}exports.RepositoryListing=RepositoryListing;//# sourceMappingURL=repository-listing.js.map
|