@tmlmobilidade/controllers 20260911.1742.59 → 20260914.1727.46
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/exporter/exporter.d.ts +1 -28
- package/dist/exporter/exporter.js +73 -70
- package/package.json +1 -1
|
@@ -1,28 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { type CreateFileExportDto, type FileExport } from '@tmlmobilidade/go-types-downloads';
|
|
3
|
-
export declare class ExporterSharedController {
|
|
4
|
-
/**
|
|
5
|
-
* Returns an Agency by ID.
|
|
6
|
-
* @param request The request object
|
|
7
|
-
* @param reply The reply object
|
|
8
|
-
*/
|
|
9
|
-
static create(request: FastifyRequest<{
|
|
10
|
-
Body: CreateFileExportDto<any>;
|
|
11
|
-
}>, reply: FastifyReply<FileExport>): Promise<never>;
|
|
12
|
-
/**
|
|
13
|
-
* Downloads a FileExport by ID.
|
|
14
|
-
* @param request The request object
|
|
15
|
-
* @param reply The reply object
|
|
16
|
-
*/
|
|
17
|
-
static download(request: FastifyRequest<{
|
|
18
|
-
Params: {
|
|
19
|
-
id: string;
|
|
20
|
-
};
|
|
21
|
-
}>, reply: FastifyReply<string>): Promise<never>;
|
|
22
|
-
/**
|
|
23
|
-
* Returns all FileExport sorted by ID.
|
|
24
|
-
* @param request The request object
|
|
25
|
-
* @param reply The reply object
|
|
26
|
-
*/
|
|
27
|
-
static getAll(request: FastifyRequest, reply: FastifyReply<FileExport[]>): Promise<never>;
|
|
28
|
-
}
|
|
1
|
+
export {};
|
|
@@ -1,70 +1,73 @@
|
|
|
1
|
-
/* * */
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
1
|
+
// /* * */
|
|
2
|
+
export {};
|
|
3
|
+
// import { HTTP_STATUS, HttpException } from '@tmlmobilidade/consts';
|
|
4
|
+
// import { type FastifyReply, type FastifyRequest } from '@tmlmobilidade/go-clients-fastify';
|
|
5
|
+
// import { goDb } from '@tmlmobilidade/go-interfaces-godb';
|
|
6
|
+
// import { storageProvider } from '@tmlmobilidade/go-providers-storage';
|
|
7
|
+
// import { type CreateFileExportDto, type FileExport } from '@tmlmobilidade/go-types-downloads';
|
|
8
|
+
// import { Logger } from '@tmlmobilidade/logger';
|
|
9
|
+
// /* * */
|
|
10
|
+
// export class ExporterSharedController {
|
|
11
|
+
// //
|
|
12
|
+
// /**
|
|
13
|
+
// * Returns an Agency by ID.
|
|
14
|
+
// * @param request The request object
|
|
15
|
+
// * @param reply The reply object
|
|
16
|
+
// */
|
|
17
|
+
// // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
// static async create(request: FastifyRequest<{ Body: CreateFileExportDto<any> }>, reply: FastifyReply<FileExport>) {
|
|
19
|
+
// const fileExportData = await goDb.core.exports.insertOne({
|
|
20
|
+
// ...request.body,
|
|
21
|
+
// created_by: request.me._id,
|
|
22
|
+
// processing_status: 'waiting',
|
|
23
|
+
// updated_by: request.me._id,
|
|
24
|
+
// });
|
|
25
|
+
// return reply.send({ data: fileExportData, error: null, statusCode: HTTP_STATUS.CREATED });
|
|
26
|
+
// }
|
|
27
|
+
// /**
|
|
28
|
+
// * Downloads a FileExport by ID.
|
|
29
|
+
// * @param request The request object
|
|
30
|
+
// * @param reply The reply object
|
|
31
|
+
// */
|
|
32
|
+
// static async download(request: FastifyRequest<{ Params: { id: string } }>, reply: FastifyReply<string>) {
|
|
33
|
+
// //
|
|
34
|
+
// const { id } = request.params;
|
|
35
|
+
// const context = { action: 'download', feature: 'exporter', request, value: id };
|
|
36
|
+
// // Find file export by ID
|
|
37
|
+
// const fileExport = await goDb.core.exports.findById(id);
|
|
38
|
+
// if (!fileExport) {
|
|
39
|
+
// const error = new HttpException(HTTP_STATUS.NOT_FOUND, 'File export not found');
|
|
40
|
+
// Logger.issue({ context, level: 'error', messageOrError: error });
|
|
41
|
+
// throw error;
|
|
42
|
+
// }
|
|
43
|
+
// // Retrieve file data from storage
|
|
44
|
+
// const foundFileData = await storageProvider.findById(fileExport.file_id);
|
|
45
|
+
// const storageServiceResponse = await fetch(foundFileData.url);
|
|
46
|
+
// if (!storageServiceResponse.ok || !storageServiceResponse.body) {
|
|
47
|
+
// const error = new HttpException(HTTP_STATUS.INTERNAL_SERVER_ERROR, 'Could not fetch file');
|
|
48
|
+
// Logger.issue({ context, level: 'error', messageOrError: error });
|
|
49
|
+
// throw error;
|
|
50
|
+
// }
|
|
51
|
+
// // Set headers and pipe the response body to the client
|
|
52
|
+
// reply.header('Content-Disposition', `attachment; filename="${foundFileData.name}"`);
|
|
53
|
+
// reply.header('Content-Type', foundFileData.type);
|
|
54
|
+
// // Set content length if available
|
|
55
|
+
// const contentLength = storageServiceResponse.headers.get('Content-Length');
|
|
56
|
+
// if (contentLength) reply.header('Content-Length', contentLength);
|
|
57
|
+
// // Pipe the response body to the client
|
|
58
|
+
// return reply.send(storageServiceResponse.body);
|
|
59
|
+
// }
|
|
60
|
+
// /**
|
|
61
|
+
// * Returns all FileExport sorted by ID.
|
|
62
|
+
// * @param request The request object
|
|
63
|
+
// * @param reply The reply object
|
|
64
|
+
// */
|
|
65
|
+
// static async getAll(request: FastifyRequest, reply: FastifyReply<FileExport[]>) {
|
|
66
|
+
// const filters = {
|
|
67
|
+
// created_by: request.me._id,
|
|
68
|
+
// };
|
|
69
|
+
// const allFileExport = await goDb.core.exports.findMany(filters);
|
|
70
|
+
// return reply.send({ data: allFileExport, error: null, statusCode: HTTP_STATUS.OK });
|
|
71
|
+
// }
|
|
72
|
+
// //
|
|
73
|
+
// }
|