@drax/crud-back 0.33.1 → 0.36.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/dist/controllers/AbstractFastifyController.js +3 -1
- package/dist/exports/AbstractExport.js +0 -0
- package/dist/exports/ExportCsv.js +0 -0
- package/dist/exports/ExportJson.js +0 -0
- package/dist/index.js +0 -0
- package/dist/regexs/QueryFilterRegex.js +1 -1
- package/dist/repository/AbstractMongoRepository.js +0 -0
- package/dist/repository/AbstractSqliteRepository.js +0 -0
- package/dist/schemas/PaginateBodySchema.js +20 -0
- package/dist/services/AbstractService.js +0 -0
- package/dist/workers/ExportCsvWorker.js +0 -0
- package/dist/zod/DeleteBodySchema.js +6 -0
- package/dist/zod/IdParamSchema.js +6 -0
- package/dist/zod/PaginateBodySchema.js +20 -0
- package/package.json +6 -6
- package/src/controllers/AbstractFastifyController.ts +5 -1
- package/src/regexs/QueryFilterRegex.ts +1 -1
- package/src/workers/ExportCsvWorker.js +12 -0
- package/test/exports/output_base_test.csv/export_50969507-e285-464e-bdd3-3ed1b1854b2e.csv +2 -0
- package/test/exports/output_object_test.csv/export_ac96f27e-4fb4-44ed-a025-bf03392d761a.csv +2 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/types/controllers/AbstractFastifyController.d.ts +0 -0
- package/types/controllers/AbstractFastifyController.d.ts.map +1 -1
- package/types/exports/AbstractExport.d.ts +0 -0
- package/types/exports/AbstractExport.d.ts.map +0 -0
- package/types/exports/ExportCsv.d.ts +0 -0
- package/types/exports/ExportCsv.d.ts.map +0 -0
- package/types/exports/ExportJson.d.ts +0 -0
- package/types/exports/ExportJson.d.ts.map +0 -0
- package/types/index.d.ts +0 -0
- package/types/index.d.ts.map +0 -0
- package/types/repository/AbstractMongoRepository.d.ts +0 -0
- package/types/repository/AbstractMongoRepository.d.ts.map +0 -0
- package/types/repository/AbstractSqliteRepository.d.ts +0 -0
- package/types/repository/AbstractSqliteRepository.d.ts.map +0 -0
- package/types/schemas/ExportBodyResponseSchema.d.ts +2 -2
- package/types/schemas/PaginateBodySchema.d.ts +61 -0
- package/types/schemas/PaginateBodySchema.d.ts.map +1 -0
- package/types/services/AbstractService.d.ts +0 -0
- package/types/services/AbstractService.d.ts.map +0 -0
- package/types/workers/ExportCsvWorker.d.ts +0 -0
- package/types/workers/ExportCsvWorker.d.ts.map +0 -0
- package/types/zod/DeleteBodySchema.d.ts +11 -0
- package/types/zod/DeleteBodySchema.d.ts.map +1 -0
- package/types/zod/IdParamSchema.d.ts +11 -0
- package/types/zod/IdParamSchema.d.ts.map +1 -0
- package/types/zod/PaginateBodySchema.d.ts +61 -0
- package/types/zod/PaginateBodySchema.d.ts.map +1 -0
|
@@ -41,7 +41,9 @@ class AbstractFastifyController extends CommonController {
|
|
|
41
41
|
const filters = [];
|
|
42
42
|
filterArray.forEach((filter) => {
|
|
43
43
|
const [field, operator, value] = filter.split(";");
|
|
44
|
-
|
|
44
|
+
if (field && operator && (value !== undefined && value !== '')) {
|
|
45
|
+
filters.push({ field, operator, value });
|
|
46
|
+
}
|
|
45
47
|
});
|
|
46
48
|
return filters;
|
|
47
49
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
package/dist/index.js
CHANGED
|
File without changes
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const QueryFilterRegex = /^(?:[a-zA-Z0-9_.\-]+;(?:eq|like|ne|in|nin|gt|gte|lt|lte);[a-zA-Z0-9_.\-:\., áéíóúÁÉÍÓÚ]
|
|
1
|
+
const QueryFilterRegex = /^(?:[a-zA-Z0-9_.\-]+;(?:eq|like|ne|in|nin|gt|gte|lt|lte);[a-zA-Z0-9_.\-:\., áéíóúÁÉÍÓÚ]*)(?:\|[a-zA-Z0-9_.\-]+;(?:eq|like|ne|in|nin|gt|gte|lt|lte);[a-zA-Z0-9_.\-:\., áéíóúÁÉÍÓÚ]*)*$/;
|
|
2
2
|
export default QueryFilterRegex;
|
|
3
3
|
export { QueryFilterRegex };
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
const PaginateQuerySchema = z.object({
|
|
3
|
+
page: z.number(),
|
|
4
|
+
limit: z.number(),
|
|
5
|
+
orderBy: z.string().optional(),
|
|
6
|
+
order: z.enum(["asc", "desc"]).optional(),
|
|
7
|
+
search: z.string().optional(),
|
|
8
|
+
filters: z.array(z.object({
|
|
9
|
+
field: z.string(),
|
|
10
|
+
operator: z.string(),
|
|
11
|
+
value: z.any(),
|
|
12
|
+
})).optional()
|
|
13
|
+
});
|
|
14
|
+
const PaginateBodyResponseSchema = z.object({
|
|
15
|
+
page: z.number(),
|
|
16
|
+
limit: z.number(),
|
|
17
|
+
total: z.number(),
|
|
18
|
+
items: z.array(z.any())
|
|
19
|
+
});
|
|
20
|
+
export { PaginateQuerySchema, PaginateBodyResponseSchema };
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import z from "zod";
|
|
2
|
+
const PaginateBodyRequestSchema = z.object({
|
|
3
|
+
page: z.number(),
|
|
4
|
+
limit: z.number(),
|
|
5
|
+
orderBy: z.string().optional(),
|
|
6
|
+
order: z.enum(["asc", "desc"]).optional(),
|
|
7
|
+
search: z.string().optional(),
|
|
8
|
+
filters: z.array(z.object({
|
|
9
|
+
field: z.string(),
|
|
10
|
+
operator: z.string(),
|
|
11
|
+
value: z.any(),
|
|
12
|
+
}))
|
|
13
|
+
});
|
|
14
|
+
const PaginateBodyResponseSchema = z.object({
|
|
15
|
+
page: z.number(),
|
|
16
|
+
limit: z.number(),
|
|
17
|
+
total: z.number(),
|
|
18
|
+
items: z.array(z.any())
|
|
19
|
+
});
|
|
20
|
+
export { PaginateBodyRequestSchema, PaginateBodyResponseSchema };
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.36.0",
|
|
7
7
|
"description": "Crud utils across modules",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"types": "types/index.d.ts",
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"author": "Cristian Incarnato & Drax Team",
|
|
23
23
|
"license": "ISC",
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@drax/common-back": "^0.
|
|
26
|
-
"@drax/common-share": "^0.
|
|
27
|
-
"@drax/identity-share": "^0.
|
|
28
|
-
"@drax/media-back": "^0.
|
|
25
|
+
"@drax/common-back": "^0.36.0",
|
|
26
|
+
"@drax/common-share": "^0.36.0",
|
|
27
|
+
"@drax/identity-share": "^0.36.0",
|
|
28
|
+
"@drax/media-back": "^0.36.0",
|
|
29
29
|
"@graphql-tools/load-files": "^7.0.0",
|
|
30
30
|
"@graphql-tools/merge": "^9.0.4",
|
|
31
31
|
"mongoose": "^8.6.3",
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"tsc-alias": "^1.8.10",
|
|
46
46
|
"typescript": "^5.6.2"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "096f17a9a7f6e6969b8367a978137e090916f16d"
|
|
49
49
|
}
|
|
@@ -97,7 +97,11 @@ class AbstractFastifyController<T, C, U> extends CommonController {
|
|
|
97
97
|
const filters: IDraxFieldFilter[] = []
|
|
98
98
|
filterArray.forEach((filter) => {
|
|
99
99
|
const [field, operator, value] = filter.split(";")
|
|
100
|
-
|
|
100
|
+
|
|
101
|
+
if(field && operator && (value !== undefined && value !== '') ) {
|
|
102
|
+
filters.push({field, operator, value})
|
|
103
|
+
}
|
|
104
|
+
|
|
101
105
|
})
|
|
102
106
|
return filters
|
|
103
107
|
} catch (e) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const QueryFilterRegex = /^(?:[a-zA-Z0-9_.\-]+;(?:eq|like|ne|in|nin|gt|gte|lt|lte);[a-zA-Z0-9_.\-:\., áéíóúÁÉÍÓÚ]
|
|
1
|
+
const QueryFilterRegex = /^(?:[a-zA-Z0-9_.\-]+;(?:eq|like|ne|in|nin|gt|gte|lt|lte);[a-zA-Z0-9_.\-:\., áéíóúÁÉÍÓÚ]*)(?:\|[a-zA-Z0-9_.\-]+;(?:eq|like|ne|in|nin|gt|gte|lt|lte);[a-zA-Z0-9_.\-:\., áéíóúÁÉÍÓÚ]*)*$/
|
|
2
2
|
|
|
3
3
|
export default QueryFilterRegex
|
|
4
4
|
export {QueryFilterRegex}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { parentPort } from 'worker_threads';
|
|
2
|
+
import ExportCsv from '../exports/ExportCsv.js'; // Ajusta la ruta según sea necesario
|
|
3
|
+
|
|
4
|
+
parentPort.on('message', async (options) => {
|
|
5
|
+
const exporter = new ExportCsv(options);
|
|
6
|
+
try {
|
|
7
|
+
let result = await exporter.process();
|
|
8
|
+
parentPort.postMessage({result: result});
|
|
9
|
+
} catch (error) {
|
|
10
|
+
parentPort.postMessage({error: error.message});
|
|
11
|
+
}
|
|
12
|
+
});
|