Skip to content

Commit ca394a9

Browse files
author
Nino van Galen
committed
feat: Added Attachment related DTOs and entities
1 parent 782cb00 commit ca394a9

6 files changed

Lines changed: 147 additions & 0 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
const Joi = require('@hapi/joi');
15+
const FileDto = require('./FileDto');
16+
17+
const BodyDto = Joi.object({
18+
filename: Joi.string()
19+
.required()
20+
.min(3),
21+
log: Joi.number()
22+
.required(),
23+
});
24+
25+
const FilesDto = Joi.array().items(FileDto);
26+
27+
const QueryDto = Joi.object({
28+
token: Joi.string(),
29+
});
30+
31+
const CreateAttachmentDto = Joi.object({
32+
query: QueryDto,
33+
body: BodyDto,
34+
file: FileDto,
35+
files: FilesDto,
36+
params: Joi.object({}),
37+
}).xor('file', 'files');
38+
39+
module.exports = CreateAttachmentDto;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
const Joi = require('@hapi/joi');
15+
const FileDto = require('./FileDto');
16+
17+
const ParamsDto = Joi.object({
18+
logId: Joi.number().required(),
19+
});
20+
21+
const BodyDto = Joi.object({
22+
filename: Joi.string()
23+
.required()
24+
.min(3),
25+
});
26+
27+
const FilesDto = Joi.array().items(FileDto);
28+
29+
const QueryDto = Joi.object({
30+
token: Joi.string(),
31+
});
32+
33+
const CreateAttachmentDto = Joi.object({
34+
query: QueryDto,
35+
body: BodyDto,
36+
file: FileDto,
37+
files: FilesDto,
38+
params: ParamsDto,
39+
}).xor('file', 'files');
40+
41+
module.exports = CreateAttachmentDto;

lib/domain/dtos/FileDto.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
const Joi = require('@hapi/joi');
15+
16+
const FileDto = Joi.object({
17+
mimetype: Joi.string().required(),
18+
filename: Joi.string().required().min(3),
19+
fieldname: Joi.string().required().min(3),
20+
originalname: Joi.string().required().min(3),
21+
encoding: Joi.string().required(),
22+
size: Joi.number().required(),
23+
destination: Joi.string(),
24+
path: Joi.string().required(),
25+
});
26+
27+
module.exports = FileDto;

lib/domain/dtos/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
* or submit itself to any jurisdiction.
1212
*/
1313

14+
const CreateAttachmentDto = require('./CreateAttachmentDto');
15+
const CreateLogAttachmentDto = require('./CreateLogAttachmentDto');
1416
const CreateLogDto = require('./CreateLogDto');
1517
const CreateSubsystemDto = require('./CreateSubsystemDto');
1618
const CreateTagDto = require('./CreateTagDto');
@@ -24,6 +26,8 @@ const GetTagDto = require('./GetTagDto');
2426
const PaginationDto = require('./PaginationDto');
2527

2628
module.exports = {
29+
CreateAttachmentDto,
30+
CreateLogAttachmentDto,
2731
CreateLogDto,
2832
CreateSubsystemDto,
2933
CreateTagDto,

lib/domain/entities/Attachment.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* @license
3+
* Copyright CERN and copyright holders of ALICE O2. This software is
4+
* distributed under the terms of the GNU General Public License v3 (GPL
5+
* Version 3), copied verbatim in the file "COPYING".
6+
*
7+
* See http://alice-o2.web.cern.ch/license for full licensing information.
8+
*
9+
* In applying this license CERN does not waive the privileges and immunities
10+
* granted to it by virtue of its status as an Intergovernmental Organization
11+
* or submit itself to any jurisdiction.
12+
*/
13+
14+
/**
15+
* Attachment
16+
*/
17+
class Attachment {
18+
/**
19+
* Creates a new `Attachment` instance.
20+
*/
21+
constructor() {
22+
this.filename = undefined;
23+
this.size = -1;
24+
this.mimeType = undefined;
25+
this.originalName = undefined;
26+
this.path = undefined;
27+
this.encoding = undefined;
28+
this.logId = -1;
29+
this.createdAt = undefined;
30+
this.updatedAt = undefined;
31+
}
32+
}
33+
34+
module.exports = Attachment;

lib/presentation/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@
1212
*/
1313

1414
const log = require('./log');
15+
const Attachment = require('./Attachment');
1516

1617
module.exports = {
1718
log,
19+
Attachment,
1820
};

0 commit comments

Comments
 (0)